@dudousxd/nestjs-agent-dashboard 0.18.0 → 0.19.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.
@@ -29,430 +29,39 @@ __export(index_exports, {
29
29
  AGENT_PRICING_STORE: () => AGENT_PRICING_STORE,
30
30
  AgentApiController: () => AgentApiController,
31
31
  AgentApiModule: () => AgentApiModule,
32
- AgentDashboardAuthController: () => AgentDashboardAuthController,
33
32
  AgentDashboardModule: () => AgentDashboardModule,
34
33
  AgentUiController: () => AgentUiController,
35
34
  DASHBOARD_API_PATH: () => DASHBOARD_API_PATH,
36
35
  DASHBOARD_APPROVAL_ACTOR_REF: () => DASHBOARD_APPROVAL_ACTOR_REF,
37
- DASHBOARD_AUTH: () => DASHBOARD_AUTH,
38
36
  DASHBOARD_BASE_PATH: () => DASHBOARD_BASE_PATH,
39
37
  DashboardService: () => DashboardService,
40
38
  agentDashboardMountPaths: () => agentDashboardMountPaths,
41
- parsePriceInput: () => parsePriceInput,
42
- resolveDashboardAuth: () => resolveDashboardAuth
39
+ parsePriceInput: () => parsePriceInput
43
40
  });
44
41
  module.exports = __toCommonJS(index_exports);
45
42
 
46
43
  // src/server/agent-api.controller.ts
47
- var import_common6 = require("@nestjs/common");
48
-
49
- // src/server/auth/dashboard-auth.guard.ts
50
- var import_common = require("@nestjs/common");
51
-
52
- // src/server/tokens.ts
53
- var AGENT_GOVERNANCE_QUERIES = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:governance-queries");
54
- var AGENT_ACTOR_DIRECTORY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:actor-directory");
55
- var AGENT_PRICING_STORE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:pricing-store");
56
- var AGENT_APPROVAL_PORT = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:approval-port");
57
- var AGENT_ACTOR_RESOLVER = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:actor-resolver");
58
- var DASHBOARD_BASE_PATH = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent-dashboard:base-path");
59
- var DASHBOARD_API_PATH = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent-dashboard:api-path");
60
- var DASHBOARD_APPROVAL_ACTOR_REF = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent-dashboard:approval-actor-ref");
61
- var DASHBOARD_AUTH = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent-dashboard:dashboard-auth");
62
-
63
- // src/server/auth/cookie-header.ts
64
- function parseCookieHeader(header) {
65
- const cookies = {};
66
- if (typeof header !== "string" || header === "") return cookies;
67
- for (const segment of header.split(";")) {
68
- const eq = segment.indexOf("=");
69
- if (eq <= 0) continue;
70
- const name = segment.slice(0, eq).trim();
71
- if (name === "") continue;
72
- let rawValue = segment.slice(eq + 1).trim();
73
- if (rawValue.length >= 2 && rawValue.startsWith('"') && rawValue.endsWith('"')) {
74
- rawValue = rawValue.slice(1, -1);
75
- }
76
- if (name in cookies) continue;
77
- try {
78
- cookies[name] = decodeURIComponent(rawValue);
79
- } catch {
80
- cookies[name] = rawValue;
81
- }
82
- }
83
- return cookies;
84
- }
85
- __name(parseCookieHeader, "parseCookieHeader");
86
- function serializeSetCookie(name, value, options) {
87
- const parts = [
88
- `${name}=${options.clear ? "" : encodeURIComponent(value)}`
89
- ];
90
- parts.push(`Path=${options.path}`);
91
- parts.push("HttpOnly");
92
- parts.push("SameSite=Lax");
93
- if (options.secure) parts.push("Secure");
94
- if (options.clear) {
95
- parts.push("Max-Age=0");
96
- parts.push("Expires=Thu, 01 Jan 1970 00:00:00 GMT");
97
- } else {
98
- parts.push(`Max-Age=${options.maxAgeSeconds}`);
99
- }
100
- return parts.join("; ");
101
- }
102
- __name(serializeSetCookie, "serializeSetCookie");
103
-
104
- // src/server/auth/http-request.ts
105
- function isRecord(value) {
106
- return typeof value === "object" && value !== null;
107
- }
108
- __name(isRecord, "isRecord");
109
- function readHeaders(request) {
110
- if (!isRecord(request)) return {};
111
- const headers = request.headers;
112
- return isRecord(headers) ? headers : {};
113
- }
114
- __name(readHeaders, "readHeaders");
115
- function headerToString(value) {
116
- if (typeof value === "string") return value;
117
- if (Array.isArray(value) && value.every((part) => typeof part === "string")) {
118
- return value.join(",");
119
- }
120
- return void 0;
121
- }
122
- __name(headerToString, "headerToString");
123
- function readCookieHeader(request) {
124
- return headerToString(readHeaders(request).cookie);
125
- }
126
- __name(readCookieHeader, "readCookieHeader");
127
- function isHttpsRequest(request) {
128
- if (isRecord(request) && request.protocol === "https") return true;
129
- const forwarded = headerToString(readHeaders(request)["x-forwarded-proto"]);
130
- if (forwarded === void 0) return false;
131
- return forwarded.split(",").map((proto) => proto.trim().toLowerCase()).includes("https");
132
- }
133
- __name(isHttpsRequest, "isHttpsRequest");
134
- function readOriginalUrl(request) {
135
- if (!isRecord(request)) return "/";
136
- const originalUrl = request.originalUrl;
137
- if (typeof originalUrl === "string" && originalUrl !== "") return originalUrl;
138
- const url = request.url;
139
- return typeof url === "string" && url !== "" ? url : "/";
140
- }
141
- __name(readOriginalUrl, "readOriginalUrl");
142
- function attachSession(request, session) {
143
- if (!isRecord(request)) return;
144
- const target = request;
145
- target.dashboardSession = session;
146
- }
147
- __name(attachSession, "attachSession");
148
-
149
- // src/server/auth/response.ts
150
- function isRecord2(value) {
151
- return typeof value === "object" && value !== null;
152
- }
153
- __name(isRecord2, "isRecord");
154
- function isHeaderCapableResponse(value) {
155
- return isRecord2(value) && typeof value.getHeader === "function" && typeof value.setHeader === "function";
156
- }
157
- __name(isHeaderCapableResponse, "isHeaderCapableResponse");
158
- function resolveHeaderCapableResponse(response) {
159
- if (isHeaderCapableResponse(response)) return response;
160
- if (isRecord2(response) && isHeaderCapableResponse(response.raw)) return response.raw;
161
- return null;
162
- }
163
- __name(resolveHeaderCapableResponse, "resolveHeaderCapableResponse");
164
- function existingSetCookies(response) {
165
- const current = response.getHeader("set-cookie");
166
- if (Array.isArray(current)) return current;
167
- if (typeof current === "string") return [
168
- current
169
- ];
170
- return [];
171
- }
172
- __name(existingSetCookies, "existingSetCookies");
173
- function appendSetCookie(response, cookie) {
174
- const raw = resolveHeaderCapableResponse(response);
175
- if (!raw) return;
176
- raw.setHeader("set-cookie", [
177
- ...existingSetCookies(raw),
178
- cookie
179
- ]);
180
- }
181
- __name(appendSetCookie, "appendSetCookie");
182
- function isRawNodeResponse(value) {
183
- return isRecord2(value) && typeof value.getHeader === "function" && typeof value.setHeader === "function" && typeof value.end === "function";
184
- }
185
- __name(isRawNodeResponse, "isRawNodeResponse");
186
- function resolveRawResponse(response) {
187
- if (isRawNodeResponse(response)) return response;
188
- if (isRecord2(response) && isRawNodeResponse(response.raw)) return response.raw;
189
- return null;
190
- }
191
- __name(resolveRawResponse, "resolveRawResponse");
192
- function responseAlreadyWritten(response) {
193
- const raw = resolveRawResponse(response);
194
- return raw?.headersSent === true;
195
- }
196
- __name(responseAlreadyWritten, "responseAlreadyWritten");
197
- function sendHtml(response, status, html) {
198
- const raw = resolveRawResponse(response);
199
- if (!raw) return;
200
- raw.statusCode = status;
201
- raw.setHeader("content-type", "text/html; charset=utf-8");
202
- raw.setHeader("cache-control", "no-store, must-revalidate");
203
- raw.end(html);
204
- }
205
- __name(sendHtml, "sendHtml");
206
- function sendRedirect(response, status, location) {
207
- const raw = resolveRawResponse(response);
208
- if (!raw) return;
209
- raw.statusCode = status;
210
- raw.setHeader("location", location);
211
- raw.end();
212
- }
213
- __name(sendRedirect, "sendRedirect");
214
-
215
- // src/server/auth/session-cookie.ts
216
- var import_node_crypto = require("crypto");
217
- var EXP_GRACE_MS = 3e4;
218
- function base64urlEncode(value) {
219
- return Buffer.from(value, "utf8").toString("base64url");
220
- }
221
- __name(base64urlEncode, "base64urlEncode");
222
- function base64urlDecode(value) {
223
- return Buffer.from(value, "base64url").toString("utf8");
224
- }
225
- __name(base64urlDecode, "base64urlDecode");
226
- function hmac(secret, payload) {
227
- return (0, import_node_crypto.createHmac)("sha256", secret).update(payload).digest("base64url");
228
- }
229
- __name(hmac, "hmac");
230
- function signSessionCookie(user, options) {
231
- const issuedAt = options.now ?? Date.now();
232
- const session = {
233
- sub: user.id,
234
- ...user.name !== void 0 ? {
235
- name: user.name
236
- } : {},
237
- roles: user.roles ?? [],
238
- iat: issuedAt,
239
- exp: issuedAt + options.ttlMs
240
- };
241
- const encodedPayload = base64urlEncode(JSON.stringify(session));
242
- const signature = hmac(options.secret, encodedPayload);
243
- return `${encodedPayload}.${signature}`;
244
- }
245
- __name(signSessionCookie, "signSessionCookie");
246
- function isSessionPayload(value) {
247
- if (typeof value !== "object" || value === null) return false;
248
- const record = {
249
- ...value
250
- };
251
- if (typeof record.sub !== "string") return false;
252
- if (record.name !== void 0 && typeof record.name !== "string") return false;
253
- if (!Array.isArray(record.roles)) return false;
254
- if (!record.roles.every((role) => typeof role === "string")) return false;
255
- if (typeof record.iat !== "number" || !Number.isFinite(record.iat)) return false;
256
- if (typeof record.exp !== "number" || !Number.isFinite(record.exp)) return false;
257
- return true;
258
- }
259
- __name(isSessionPayload, "isSessionPayload");
260
- function verifySessionCookie(value, options) {
261
- try {
262
- const dot = value.indexOf(".");
263
- if (dot <= 0 || dot === value.length - 1) return null;
264
- const encodedPayload = value.slice(0, dot);
265
- const providedSignature = value.slice(dot + 1);
266
- const expectedSignature = hmac(options.secret, encodedPayload);
267
- const provided = Buffer.from(providedSignature, "base64url");
268
- const expected = Buffer.from(expectedSignature, "base64url");
269
- if (provided.length !== expected.length) return null;
270
- if (!(0, import_node_crypto.timingSafeEqual)(provided, expected)) return null;
271
- const decoded = JSON.parse(base64urlDecode(encodedPayload));
272
- if (!isSessionPayload(decoded)) return null;
273
- const now = options.now ?? Date.now();
274
- if (now > decoded.exp + EXP_GRACE_MS) return null;
275
- const session = {
276
- sub: decoded.sub,
277
- ...decoded.name !== void 0 ? {
278
- name: decoded.name
279
- } : {},
280
- roles: decoded.roles,
281
- iat: decoded.iat,
282
- exp: decoded.exp
283
- };
284
- return session;
285
- } catch {
286
- return null;
287
- }
288
- }
289
- __name(verifySessionCookie, "verifySessionCookie");
290
-
291
- // src/server/auth/session-cookie-io.ts
292
- var SESSION_COOKIE_NAME = "agent_dashboard_session";
293
- var COOKIE_PATH = "/";
294
- function issueSessionCookie(user, context) {
295
- const value = signSessionCookie(user, {
296
- secret: context.auth.secret,
297
- ttlMs: context.auth.ttlMs,
298
- ...context.now !== void 0 ? {
299
- now: context.now
300
- } : {}
301
- });
302
- const cookie = serializeSetCookie(SESSION_COOKIE_NAME, value, {
303
- path: COOKIE_PATH,
304
- maxAgeSeconds: Math.floor(context.auth.ttlMs / 1e3),
305
- secure: isHttpsRequest(context.request)
306
- });
307
- appendSetCookie(context.response, cookie);
308
- }
309
- __name(issueSessionCookie, "issueSessionCookie");
310
- function clearSessionCookie(context) {
311
- const cookie = serializeSetCookie(SESSION_COOKIE_NAME, "", {
312
- path: COOKIE_PATH,
313
- maxAgeSeconds: 0,
314
- secure: isHttpsRequest(context.request),
315
- clear: true
316
- });
317
- appendSetCookie(context.response, cookie);
318
- }
319
- __name(clearSessionCookie, "clearSessionCookie");
320
- var inFlightRevalidations = /* @__PURE__ */ new Map();
321
- function revalidationKey(session) {
322
- return `${session.sub}:${session.iat}`;
323
- }
324
- __name(revalidationKey, "revalidationKey");
325
- function getOrStartRevalidation(auth, session, user) {
326
- const hook = auth.revalidate;
327
- if (!hook) return Promise.resolve(true);
328
- const key = revalidationKey(session);
329
- const inFlight = inFlightRevalidations.get(key);
330
- if (inFlight) return inFlight;
331
- const outcome = (async () => {
332
- try {
333
- return await hook(user);
334
- } catch {
335
- return false;
336
- }
337
- })().finally(() => {
338
- inFlightRevalidations.delete(key);
339
- });
340
- inFlightRevalidations.set(key, outcome);
341
- return outcome;
342
- }
343
- __name(getOrStartRevalidation, "getOrStartRevalidation");
344
- async function maybeRenewSession(auth, session, request, response, now = Date.now()) {
345
- if (now - session.iat <= auth.ttlMs / 2) return true;
346
- const user = {
347
- id: session.sub,
348
- ...session.name !== void 0 ? {
349
- name: session.name
350
- } : {},
351
- roles: session.roles
352
- };
353
- const allowed = await getOrStartRevalidation(auth, session, user);
354
- if (!allowed) {
355
- clearSessionCookie({
356
- request,
357
- response
358
- });
359
- return false;
360
- }
361
- issueSessionCookie(user, {
362
- auth,
363
- request,
364
- response,
365
- now
366
- });
367
- return true;
368
- }
369
- __name(maybeRenewSession, "maybeRenewSession");
370
-
371
- // src/server/auth/dashboard-auth.guard.ts
372
- function _ts_decorate(decorators, target, key, desc) {
373
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
374
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
375
- r = Reflect.decorate(decorators, target, key, desc);
376
- } else {
377
- for (var i = decorators.length - 1; i >= 0; i--) {
378
- if (d = decorators[i]) {
379
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
380
- }
381
- }
382
- }
383
- return c > 3 && r && Object.defineProperty(target, key, r), r;
384
- }
385
- __name(_ts_decorate, "_ts_decorate");
386
- function _ts_metadata(metadataKey, metadataValue) {
387
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
388
- return Reflect.metadata(metadataKey, metadataValue);
389
- }
390
- }
391
- __name(_ts_metadata, "_ts_metadata");
392
- function _ts_param(paramIndex, decorator) {
393
- return function(target, key) {
394
- decorator(target, key, paramIndex);
395
- };
396
- }
397
- __name(_ts_param, "_ts_param");
398
- var DashboardAuthGuard = class {
399
- static {
400
- __name(this, "DashboardAuthGuard");
401
- }
402
- auth;
403
- constructor(auth) {
404
- this.auth = auth;
405
- }
406
- async canActivate(context) {
407
- if (!this.auth) return true;
408
- const http = context.switchToHttp();
409
- const request = http.getRequest();
410
- const session = this.verifyRequestSession(request);
411
- if (!session) throw new import_common.UnauthorizedException();
412
- attachSession(request, session);
413
- if (!await maybeRenewSession(this.auth, session, request, http.getResponse())) {
414
- throw new import_common.UnauthorizedException();
415
- }
416
- return true;
417
- }
418
- verifyRequestSession(request) {
419
- const auth = this.auth;
420
- if (!auth) return null;
421
- const cookieValue = parseCookieHeader(readCookieHeader(request))[SESSION_COOKIE_NAME];
422
- if (cookieValue === void 0) return null;
423
- return verifySessionCookie(cookieValue, {
424
- secret: auth.secret
425
- });
426
- }
427
- };
428
- DashboardAuthGuard = _ts_decorate([
429
- (0, import_common.Injectable)(),
430
- _ts_param(0, (0, import_common.Optional)()),
431
- _ts_param(0, (0, import_common.Inject)(DASHBOARD_AUTH)),
432
- _ts_metadata("design:type", Function),
433
- _ts_metadata("design:paramtypes", [
434
- Object
435
- ])
436
- ], DashboardAuthGuard);
44
+ var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
45
+ var import_common5 = require("@nestjs/common");
437
46
 
438
47
  // src/server/dashboard.service.ts
439
48
  var import_node_diagnostics_channel = require("diagnostics_channel");
440
49
  var import_nestjs_diagnostics = require("@dudousxd/nestjs-diagnostics");
441
- var import_common4 = require("@nestjs/common");
50
+ var import_common3 = require("@nestjs/common");
442
51
  var import_rxjs = require("rxjs");
443
52
 
444
53
  // src/server/parse-approval-decision.ts
445
- var import_common2 = require("@nestjs/common");
54
+ var import_common = require("@nestjs/common");
446
55
  function parseApprovalDecision(body) {
447
56
  if (typeof body !== "object" || body === null) {
448
- throw new import_common2.BadRequestException("Expected a JSON object body.");
57
+ throw new import_common.BadRequestException("Expected a JSON object body.");
449
58
  }
450
59
  const { approved, reason } = body;
451
60
  if (typeof approved !== "boolean") {
452
- throw new import_common2.BadRequestException('"approved" must be a boolean.');
61
+ throw new import_common.BadRequestException('"approved" must be a boolean.');
453
62
  }
454
63
  if (reason !== void 0 && typeof reason !== "string") {
455
- throw new import_common2.BadRequestException('"reason" must be a string when present.');
64
+ throw new import_common.BadRequestException('"reason" must be a string when present.');
456
65
  }
457
66
  return {
458
67
  approved,
@@ -464,26 +73,26 @@ function parseApprovalDecision(body) {
464
73
  __name(parseApprovalDecision, "parseApprovalDecision");
465
74
 
466
75
  // src/server/parse-price-input.ts
467
- var import_common3 = require("@nestjs/common");
76
+ var import_common2 = require("@nestjs/common");
468
77
  function parsePriceInput(body) {
469
78
  if (typeof body !== "object" || body === null) {
470
- throw new import_common3.BadRequestException("Expected a JSON object body.");
79
+ throw new import_common2.BadRequestException("Expected a JSON object body.");
471
80
  }
472
81
  const { modelId, inputPricePer1m, outputPricePer1m, cacheWritePricePer1m, cacheReadPricePer1m } = body;
473
82
  if (typeof modelId !== "string" || modelId.trim().length === 0) {
474
- throw new import_common3.BadRequestException('"modelId" must be a non-empty string.');
83
+ throw new import_common2.BadRequestException('"modelId" must be a non-empty string.');
475
84
  }
476
85
  if (!isFiniteNonNegative(inputPricePer1m)) {
477
- throw new import_common3.BadRequestException('"inputPricePer1m" must be a non-negative number.');
86
+ throw new import_common2.BadRequestException('"inputPricePer1m" must be a non-negative number.');
478
87
  }
479
88
  if (!isFiniteNonNegative(outputPricePer1m)) {
480
- throw new import_common3.BadRequestException('"outputPricePer1m" must be a non-negative number.');
89
+ throw new import_common2.BadRequestException('"outputPricePer1m" must be a non-negative number.');
481
90
  }
482
91
  if (cacheWritePricePer1m !== void 0 && !isFiniteNonNegative(cacheWritePricePer1m)) {
483
- throw new import_common3.BadRequestException('"cacheWritePricePer1m" must be a non-negative number when present.');
92
+ throw new import_common2.BadRequestException('"cacheWritePricePer1m" must be a non-negative number when present.');
484
93
  }
485
94
  if (cacheReadPricePer1m !== void 0 && !isFiniteNonNegative(cacheReadPricePer1m)) {
486
- throw new import_common3.BadRequestException('"cacheReadPricePer1m" must be a non-negative number when present.');
95
+ throw new import_common2.BadRequestException('"cacheReadPricePer1m" must be a non-negative number when present.');
487
96
  }
488
97
  return {
489
98
  modelId,
@@ -503,8 +112,18 @@ function isFiniteNonNegative(value) {
503
112
  }
504
113
  __name(isFiniteNonNegative, "isFiniteNonNegative");
505
114
 
115
+ // src/server/tokens.ts
116
+ var AGENT_GOVERNANCE_QUERIES = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:governance-queries");
117
+ var AGENT_ACTOR_DIRECTORY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:actor-directory");
118
+ var AGENT_PRICING_STORE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:pricing-store");
119
+ var AGENT_APPROVAL_PORT = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:approval-port");
120
+ var AGENT_ACTOR_RESOLVER = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:actor-resolver");
121
+ var DASHBOARD_BASE_PATH = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent-dashboard:base-path");
122
+ var DASHBOARD_API_PATH = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent-dashboard:api-path");
123
+ var DASHBOARD_APPROVAL_ACTOR_REF = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent-dashboard:approval-actor-ref");
124
+
506
125
  // src/server/dashboard.service.ts
507
- function _ts_decorate2(decorators, target, key, desc) {
126
+ function _ts_decorate(decorators, target, key, desc) {
508
127
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
509
128
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
510
129
  r = Reflect.decorate(decorators, target, key, desc);
@@ -517,19 +136,19 @@ function _ts_decorate2(decorators, target, key, desc) {
517
136
  }
518
137
  return c > 3 && r && Object.defineProperty(target, key, r), r;
519
138
  }
520
- __name(_ts_decorate2, "_ts_decorate");
521
- function _ts_metadata2(metadataKey, metadataValue) {
139
+ __name(_ts_decorate, "_ts_decorate");
140
+ function _ts_metadata(metadataKey, metadataValue) {
522
141
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
523
142
  return Reflect.metadata(metadataKey, metadataValue);
524
143
  }
525
144
  }
526
- __name(_ts_metadata2, "_ts_metadata");
527
- function _ts_param2(paramIndex, decorator) {
145
+ __name(_ts_metadata, "_ts_metadata");
146
+ function _ts_param(paramIndex, decorator) {
528
147
  return function(target, key) {
529
148
  decorator(target, key, paramIndex);
530
149
  };
531
150
  }
532
- __name(_ts_param2, "_ts_param");
151
+ __name(_ts_param, "_ts_param");
533
152
  var PRICING_STORE_UNBOUND_MESSAGE = "Pricing CRUD is unavailable: no AGENT_PRICING_STORE is bound. Bind a pricing store (e.g. MikroOrmPricingStore from @dudousxd/nestjs-agent-store-mikro-orm) to enable it.";
534
153
  var APPROVAL_PORT_UNBOUND_MESSAGE = "Approve/reject is unavailable: no AGENT_APPROVAL_PORT is bound. Import AgentModule from @dudousxd/nestjs-agent alongside this dashboard to enable it \u2014 the approvals inbox stays read-only until then.";
535
154
  var GENUI_STATS_UNSUPPORTED_MESSAGE = "Generative UI telemetry is unavailable: the bound AGENT_GOVERNANCE_QUERIES store does not implement genuiStats. Use a store adapter that records generative-UI calls (recordGenuiCalls) to enable it.";
@@ -635,7 +254,7 @@ var DashboardService = class {
635
254
  async runDetail(runId) {
636
255
  const detail = await this.queries.runDetail(runId);
637
256
  if (detail === null) {
638
- throw new import_common4.NotFoundException(`No run "${runId}".`);
257
+ throw new import_common3.NotFoundException(`No run "${runId}".`);
639
258
  }
640
259
  const [thread] = await this.withActorLabels([
641
260
  detail.thread
@@ -652,7 +271,7 @@ var DashboardService = class {
652
271
  async threadDetail(query) {
653
272
  const detail = await this.queries.threadDetail(query);
654
273
  if (detail === null) {
655
- throw new import_common4.NotFoundException(`No thread "${query.threadId}".`);
274
+ throw new import_common3.NotFoundException(`No thread "${query.threadId}".`);
656
275
  }
657
276
  const [thread] = await this.withActorLabels([
658
277
  detail.thread
@@ -677,7 +296,7 @@ var DashboardService = class {
677
296
  */
678
297
  async genuiStats(range) {
679
298
  if (this.queries.genuiStats === void 0) {
680
- throw new import_common4.NotImplementedException(GENUI_STATS_UNSUPPORTED_MESSAGE);
299
+ throw new import_common3.NotImplementedException(GENUI_STATS_UNSUPPORTED_MESSAGE);
681
300
  }
682
301
  return this.queries.genuiStats(range);
683
302
  }
@@ -691,7 +310,7 @@ var DashboardService = class {
691
310
  */
692
311
  async decideApproval(toolCallId, body, executedByRef) {
693
312
  if (this.approvalPort === void 0) {
694
- throw new import_common4.NotImplementedException(APPROVAL_PORT_UNBOUND_MESSAGE);
313
+ throw new import_common3.NotImplementedException(APPROVAL_PORT_UNBOUND_MESSAGE);
695
314
  }
696
315
  const decision = parseApprovalDecision(body);
697
316
  const opts = executedByRef !== void 0 ? {
@@ -752,7 +371,7 @@ var DashboardService = class {
752
371
  /** Current price row per model, for the pricing tab. 501s when no `AGENT_PRICING_STORE` is bound. */
753
372
  async listPrices() {
754
373
  if (this.pricingStore === void 0) {
755
- throw new import_common4.NotImplementedException(PRICING_STORE_UNBOUND_MESSAGE);
374
+ throw new import_common3.NotImplementedException(PRICING_STORE_UNBOUND_MESSAGE);
756
375
  }
757
376
  return this.pricingStore.listCurrentPrices();
758
377
  }
@@ -763,7 +382,7 @@ var DashboardService = class {
763
382
  */
764
383
  async upsertPrice(body) {
765
384
  if (this.pricingStore === void 0) {
766
- throw new import_common4.NotImplementedException(PRICING_STORE_UNBOUND_MESSAGE);
385
+ throw new import_common3.NotImplementedException(PRICING_STORE_UNBOUND_MESSAGE);
767
386
  }
768
387
  await this.pricingStore.upsertModelPrice(parsePriceInput(body));
769
388
  }
@@ -798,17 +417,17 @@ var DashboardService = class {
798
417
  });
799
418
  }
800
419
  };
801
- DashboardService = _ts_decorate2([
802
- (0, import_common4.Injectable)(),
803
- _ts_param2(0, (0, import_common4.Inject)(AGENT_GOVERNANCE_QUERIES)),
804
- _ts_param2(1, (0, import_common4.Optional)()),
805
- _ts_param2(1, (0, import_common4.Inject)(AGENT_ACTOR_DIRECTORY)),
806
- _ts_param2(2, (0, import_common4.Optional)()),
807
- _ts_param2(2, (0, import_common4.Inject)(AGENT_PRICING_STORE)),
808
- _ts_param2(3, (0, import_common4.Optional)()),
809
- _ts_param2(3, (0, import_common4.Inject)(AGENT_APPROVAL_PORT)),
810
- _ts_metadata2("design:type", Function),
811
- _ts_metadata2("design:paramtypes", [
420
+ DashboardService = _ts_decorate([
421
+ (0, import_common3.Injectable)(),
422
+ _ts_param(0, (0, import_common3.Inject)(AGENT_GOVERNANCE_QUERIES)),
423
+ _ts_param(1, (0, import_common3.Optional)()),
424
+ _ts_param(1, (0, import_common3.Inject)(AGENT_ACTOR_DIRECTORY)),
425
+ _ts_param(2, (0, import_common3.Optional)()),
426
+ _ts_param(2, (0, import_common3.Inject)(AGENT_PRICING_STORE)),
427
+ _ts_param(3, (0, import_common3.Optional)()),
428
+ _ts_param(3, (0, import_common3.Inject)(AGENT_APPROVAL_PORT)),
429
+ _ts_metadata("design:type", Function),
430
+ _ts_metadata("design:paramtypes", [
812
431
  typeof AgentGovernanceQueries === "undefined" ? Object : AgentGovernanceQueries,
813
432
  typeof ActorDirectory === "undefined" ? Object : ActorDirectory,
814
433
  typeof AgentPricingStore === "undefined" ? Object : AgentPricingStore,
@@ -817,7 +436,7 @@ DashboardService = _ts_decorate2([
817
436
  ], DashboardService);
818
437
 
819
438
  // src/server/parse-page-query.ts
820
- var import_common5 = require("@nestjs/common");
439
+ var import_common4 = require("@nestjs/common");
821
440
  var ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
822
441
  function parsePageNumber(value) {
823
442
  const parsed = value === void 0 ? Number.NaN : Number.parseInt(value, 10);
@@ -828,7 +447,7 @@ __name(parsePageNumber, "parsePageNumber");
828
447
  function assertKnownFields(raw, allowed) {
829
448
  for (const field of Object.keys(raw)) {
830
449
  if (!allowed.includes(field)) {
831
- throw new import_common5.BadRequestException(`Unknown where field "${field}".`);
450
+ throw new import_common4.BadRequestException(`Unknown where field "${field}".`);
832
451
  }
833
452
  }
834
453
  }
@@ -837,7 +456,7 @@ function assertDayFields(raw, dayFields) {
837
456
  for (const field of dayFields) {
838
457
  const value = raw[field];
839
458
  if (value !== void 0 && !ISO_DAY.test(value)) {
840
- throw new import_common5.BadRequestException(`"where[${field}]" must be YYYY-MM-DD.`);
459
+ throw new import_common4.BadRequestException(`"where[${field}]" must be YYYY-MM-DD.`);
841
460
  }
842
461
  }
843
462
  }
@@ -976,7 +595,7 @@ function parseApprovalWhere(raw) {
976
595
  __name(parseApprovalWhere, "parseApprovalWhere");
977
596
 
978
597
  // src/server/agent-api.controller.ts
979
- function _ts_decorate3(decorators, target, key, desc) {
598
+ function _ts_decorate2(decorators, target, key, desc) {
980
599
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
981
600
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
982
601
  r = Reflect.decorate(decorators, target, key, desc);
@@ -989,19 +608,19 @@ function _ts_decorate3(decorators, target, key, desc) {
989
608
  }
990
609
  return c > 3 && r && Object.defineProperty(target, key, r), r;
991
610
  }
992
- __name(_ts_decorate3, "_ts_decorate");
993
- function _ts_metadata3(metadataKey, metadataValue) {
611
+ __name(_ts_decorate2, "_ts_decorate");
612
+ function _ts_metadata2(metadataKey, metadataValue) {
994
613
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
995
614
  return Reflect.metadata(metadataKey, metadataValue);
996
615
  }
997
616
  }
998
- __name(_ts_metadata3, "_ts_metadata");
999
- function _ts_param3(paramIndex, decorator) {
617
+ __name(_ts_metadata2, "_ts_metadata");
618
+ function _ts_param2(paramIndex, decorator) {
1000
619
  return function(target, key) {
1001
620
  decorator(target, key, paramIndex);
1002
621
  };
1003
622
  }
1004
- __name(_ts_param3, "_ts_param");
623
+ __name(_ts_param2, "_ts_param");
1005
624
  var DAY_MS = 864e5;
1006
625
  var ISO_DAY2 = /^\d{4}-\d{2}-\d{2}$/;
1007
626
  function utcDay(daysAgo) {
@@ -1219,620 +838,222 @@ var AgentApiController = class {
1219
838
  return this.dashboard.streamEvents();
1220
839
  }
1221
840
  };
1222
- _ts_decorate3([
1223
- (0, import_common6.Get)("spend"),
1224
- _ts_param3(0, (0, import_common6.Query)("from")),
1225
- _ts_param3(1, (0, import_common6.Query)("to")),
1226
- _ts_metadata3("design:type", Function),
1227
- _ts_metadata3("design:paramtypes", [
841
+ _ts_decorate2([
842
+ (0, import_common5.Get)("spend"),
843
+ _ts_param2(0, (0, import_common5.Query)("from")),
844
+ _ts_param2(1, (0, import_common5.Query)("to")),
845
+ _ts_metadata2("design:type", Function),
846
+ _ts_metadata2("design:paramtypes", [
1228
847
  String,
1229
848
  String
1230
849
  ]),
1231
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
850
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1232
851
  ], AgentApiController.prototype, "spend", null);
1233
- _ts_decorate3([
1234
- (0, import_common6.Get)("top-threads"),
1235
- _ts_param3(0, (0, import_common6.Query)("from")),
1236
- _ts_param3(1, (0, import_common6.Query)("to")),
1237
- _ts_param3(2, (0, import_common6.Query)("limit")),
1238
- _ts_metadata3("design:type", Function),
1239
- _ts_metadata3("design:paramtypes", [
852
+ _ts_decorate2([
853
+ (0, import_common5.Get)("top-threads"),
854
+ _ts_param2(0, (0, import_common5.Query)("from")),
855
+ _ts_param2(1, (0, import_common5.Query)("to")),
856
+ _ts_param2(2, (0, import_common5.Query)("limit")),
857
+ _ts_metadata2("design:type", Function),
858
+ _ts_metadata2("design:paramtypes", [
1240
859
  String,
1241
860
  String,
1242
861
  String
1243
862
  ]),
1244
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
863
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1245
864
  ], AgentApiController.prototype, "topThreads", null);
1246
- _ts_decorate3([
1247
- (0, import_common6.Get)("reliability"),
1248
- _ts_param3(0, (0, import_common6.Query)("from")),
1249
- _ts_param3(1, (0, import_common6.Query)("to")),
1250
- _ts_metadata3("design:type", Function),
1251
- _ts_metadata3("design:paramtypes", [
865
+ _ts_decorate2([
866
+ (0, import_common5.Get)("reliability"),
867
+ _ts_param2(0, (0, import_common5.Query)("from")),
868
+ _ts_param2(1, (0, import_common5.Query)("to")),
869
+ _ts_metadata2("design:type", Function),
870
+ _ts_metadata2("design:paramtypes", [
1252
871
  String,
1253
872
  String
1254
873
  ]),
1255
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
874
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1256
875
  ], AgentApiController.prototype, "reliability", null);
1257
- _ts_decorate3([
1258
- (0, import_common6.Get)("runs"),
1259
- _ts_param3(0, (0, import_common6.Query)("limit")),
1260
- _ts_metadata3("design:type", Function),
1261
- _ts_metadata3("design:paramtypes", [
876
+ _ts_decorate2([
877
+ (0, import_common5.Get)("runs"),
878
+ _ts_param2(0, (0, import_common5.Query)("limit")),
879
+ _ts_metadata2("design:type", Function),
880
+ _ts_metadata2("design:paramtypes", [
1262
881
  String
1263
882
  ]),
1264
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
883
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1265
884
  ], AgentApiController.prototype, "runs", null);
1266
- _ts_decorate3([
1267
- (0, import_common6.Get)("runs-page"),
1268
- _ts_param3(0, (0, import_common6.Query)("page")),
1269
- _ts_param3(1, (0, import_common6.Query)("limit")),
1270
- _ts_param3(2, (0, import_common6.Query)("where")),
1271
- _ts_metadata3("design:type", Function),
1272
- _ts_metadata3("design:paramtypes", [
885
+ _ts_decorate2([
886
+ (0, import_common5.Get)("runs-page"),
887
+ _ts_param2(0, (0, import_common5.Query)("page")),
888
+ _ts_param2(1, (0, import_common5.Query)("limit")),
889
+ _ts_param2(2, (0, import_common5.Query)("where")),
890
+ _ts_metadata2("design:type", Function),
891
+ _ts_metadata2("design:paramtypes", [
1273
892
  String,
1274
893
  String,
1275
894
  typeof Record === "undefined" ? Object : Record
1276
895
  ]),
1277
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
896
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1278
897
  ], AgentApiController.prototype, "runsPage", null);
1279
- _ts_decorate3([
1280
- (0, import_common6.Get)("runs/:runId"),
1281
- _ts_param3(0, (0, import_common6.Param)("runId")),
1282
- _ts_metadata3("design:type", Function),
1283
- _ts_metadata3("design:paramtypes", [
898
+ _ts_decorate2([
899
+ (0, import_common5.Get)("runs/:runId"),
900
+ _ts_param2(0, (0, import_common5.Param)("runId")),
901
+ _ts_metadata2("design:type", Function),
902
+ _ts_metadata2("design:paramtypes", [
1284
903
  String
1285
904
  ]),
1286
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
905
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1287
906
  ], AgentApiController.prototype, "runDetail", null);
1288
- _ts_decorate3([
1289
- (0, import_common6.Get)("tool-calls"),
1290
- _ts_param3(0, (0, import_common6.Query)("limit")),
1291
- _ts_metadata3("design:type", Function),
1292
- _ts_metadata3("design:paramtypes", [
907
+ _ts_decorate2([
908
+ (0, import_common5.Get)("tool-calls"),
909
+ _ts_param2(0, (0, import_common5.Query)("limit")),
910
+ _ts_metadata2("design:type", Function),
911
+ _ts_metadata2("design:paramtypes", [
1293
912
  String
1294
913
  ]),
1295
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
914
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1296
915
  ], AgentApiController.prototype, "toolCalls", null);
1297
- _ts_decorate3([
1298
- (0, import_common6.Get)("tool-calls-page"),
1299
- _ts_param3(0, (0, import_common6.Query)("page")),
1300
- _ts_param3(1, (0, import_common6.Query)("limit")),
1301
- _ts_param3(2, (0, import_common6.Query)("where")),
1302
- _ts_metadata3("design:type", Function),
1303
- _ts_metadata3("design:paramtypes", [
916
+ _ts_decorate2([
917
+ (0, import_common5.Get)("tool-calls-page"),
918
+ _ts_param2(0, (0, import_common5.Query)("page")),
919
+ _ts_param2(1, (0, import_common5.Query)("limit")),
920
+ _ts_param2(2, (0, import_common5.Query)("where")),
921
+ _ts_metadata2("design:type", Function),
922
+ _ts_metadata2("design:paramtypes", [
1304
923
  String,
1305
924
  String,
1306
925
  typeof Record === "undefined" ? Object : Record
1307
926
  ]),
1308
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
927
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1309
928
  ], AgentApiController.prototype, "toolCallsPage", null);
1310
- _ts_decorate3([
1311
- (0, import_common6.Get)("approvals"),
1312
- _ts_param3(0, (0, import_common6.Query)("limit")),
1313
- _ts_metadata3("design:type", Function),
1314
- _ts_metadata3("design:paramtypes", [
929
+ _ts_decorate2([
930
+ (0, import_common5.Get)("approvals"),
931
+ _ts_param2(0, (0, import_common5.Query)("limit")),
932
+ _ts_metadata2("design:type", Function),
933
+ _ts_metadata2("design:paramtypes", [
1315
934
  String
1316
935
  ]),
1317
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
936
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1318
937
  ], AgentApiController.prototype, "approvals", null);
1319
- _ts_decorate3([
1320
- (0, import_common6.Get)("approvals-page"),
1321
- _ts_param3(0, (0, import_common6.Query)("page")),
1322
- _ts_param3(1, (0, import_common6.Query)("limit")),
1323
- _ts_param3(2, (0, import_common6.Query)("where")),
1324
- _ts_metadata3("design:type", Function),
1325
- _ts_metadata3("design:paramtypes", [
938
+ _ts_decorate2([
939
+ (0, import_common5.Get)("approvals-page"),
940
+ _ts_param2(0, (0, import_common5.Query)("page")),
941
+ _ts_param2(1, (0, import_common5.Query)("limit")),
942
+ _ts_param2(2, (0, import_common5.Query)("where")),
943
+ _ts_metadata2("design:type", Function),
944
+ _ts_metadata2("design:paramtypes", [
1326
945
  String,
1327
946
  String,
1328
947
  typeof Record === "undefined" ? Object : Record
1329
948
  ]),
1330
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
949
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1331
950
  ], AgentApiController.prototype, "approvalsPage", null);
1332
- _ts_decorate3([
1333
- (0, import_common6.Post)("approvals/:toolCallId"),
1334
- (0, import_common6.HttpCode)(204),
1335
- _ts_param3(0, (0, import_common6.Param)("toolCallId")),
1336
- _ts_param3(1, (0, import_common6.Body)()),
1337
- _ts_param3(2, (0, import_common6.Req)()),
1338
- _ts_metadata3("design:type", Function),
1339
- _ts_metadata3("design:paramtypes", [
951
+ _ts_decorate2([
952
+ (0, import_common5.Post)("approvals/:toolCallId"),
953
+ (0, import_common5.HttpCode)(204),
954
+ _ts_param2(0, (0, import_common5.Param)("toolCallId")),
955
+ _ts_param2(1, (0, import_common5.Body)()),
956
+ _ts_param2(2, (0, import_common5.Req)()),
957
+ _ts_metadata2("design:type", Function),
958
+ _ts_metadata2("design:paramtypes", [
1340
959
  String,
1341
960
  Object,
1342
961
  Object
1343
962
  ]),
1344
- _ts_metadata3("design:returntype", Promise)
963
+ _ts_metadata2("design:returntype", Promise)
1345
964
  ], AgentApiController.prototype, "decideApproval", null);
1346
- _ts_decorate3([
1347
- (0, import_common6.Get)("tools"),
1348
- _ts_param3(0, (0, import_common6.Query)("from")),
1349
- _ts_param3(1, (0, import_common6.Query)("to")),
1350
- _ts_metadata3("design:type", Function),
1351
- _ts_metadata3("design:paramtypes", [
965
+ _ts_decorate2([
966
+ (0, import_common5.Get)("tools"),
967
+ _ts_param2(0, (0, import_common5.Query)("from")),
968
+ _ts_param2(1, (0, import_common5.Query)("to")),
969
+ _ts_metadata2("design:type", Function),
970
+ _ts_metadata2("design:paramtypes", [
1352
971
  String,
1353
972
  String
1354
973
  ]),
1355
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
974
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1356
975
  ], AgentApiController.prototype, "tools", null);
1357
- _ts_decorate3([
1358
- (0, import_common6.Get)("genui"),
1359
- _ts_param3(0, (0, import_common6.Query)("from")),
1360
- _ts_param3(1, (0, import_common6.Query)("to")),
1361
- _ts_metadata3("design:type", Function),
1362
- _ts_metadata3("design:paramtypes", [
976
+ _ts_decorate2([
977
+ (0, import_common5.Get)("genui"),
978
+ _ts_param2(0, (0, import_common5.Query)("from")),
979
+ _ts_param2(1, (0, import_common5.Query)("to")),
980
+ _ts_metadata2("design:type", Function),
981
+ _ts_metadata2("design:paramtypes", [
1363
982
  String,
1364
983
  String
1365
984
  ]),
1366
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
985
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1367
986
  ], AgentApiController.prototype, "genui", null);
1368
- _ts_decorate3([
1369
- (0, import_common6.Get)("threads"),
1370
- _ts_param3(0, (0, import_common6.Query)("limit")),
1371
- _ts_metadata3("design:type", Function),
1372
- _ts_metadata3("design:paramtypes", [
987
+ _ts_decorate2([
988
+ (0, import_common5.Get)("threads"),
989
+ _ts_param2(0, (0, import_common5.Query)("limit")),
990
+ _ts_metadata2("design:type", Function),
991
+ _ts_metadata2("design:paramtypes", [
1373
992
  String
1374
993
  ]),
1375
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
994
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1376
995
  ], AgentApiController.prototype, "threads", null);
1377
- _ts_decorate3([
1378
- (0, import_common6.Get)("threads-page"),
1379
- _ts_param3(0, (0, import_common6.Query)("page")),
1380
- _ts_param3(1, (0, import_common6.Query)("limit")),
1381
- _ts_param3(2, (0, import_common6.Query)("where")),
1382
- _ts_metadata3("design:type", Function),
1383
- _ts_metadata3("design:paramtypes", [
996
+ _ts_decorate2([
997
+ (0, import_common5.Get)("threads-page"),
998
+ _ts_param2(0, (0, import_common5.Query)("page")),
999
+ _ts_param2(1, (0, import_common5.Query)("limit")),
1000
+ _ts_param2(2, (0, import_common5.Query)("where")),
1001
+ _ts_metadata2("design:type", Function),
1002
+ _ts_metadata2("design:paramtypes", [
1384
1003
  String,
1385
1004
  String,
1386
1005
  typeof Record === "undefined" ? Object : Record
1387
1006
  ]),
1388
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1007
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1389
1008
  ], AgentApiController.prototype, "threadsPage", null);
1390
- _ts_decorate3([
1391
- (0, import_common6.Get)("threads/:threadId"),
1392
- _ts_param3(0, (0, import_common6.Param)("threadId")),
1393
- _ts_param3(1, (0, import_common6.Query)("messages")),
1394
- _ts_param3(2, (0, import_common6.Query)("runs")),
1395
- _ts_metadata3("design:type", Function),
1396
- _ts_metadata3("design:paramtypes", [
1009
+ _ts_decorate2([
1010
+ (0, import_common5.Get)("threads/:threadId"),
1011
+ _ts_param2(0, (0, import_common5.Param)("threadId")),
1012
+ _ts_param2(1, (0, import_common5.Query)("messages")),
1013
+ _ts_param2(2, (0, import_common5.Query)("runs")),
1014
+ _ts_metadata2("design:type", Function),
1015
+ _ts_metadata2("design:paramtypes", [
1397
1016
  String,
1398
1017
  String,
1399
1018
  String
1400
1019
  ]),
1401
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1020
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1402
1021
  ], AgentApiController.prototype, "threadDetail", null);
1403
- _ts_decorate3([
1404
- (0, import_common6.Get)("pricing"),
1405
- _ts_metadata3("design:type", Function),
1406
- _ts_metadata3("design:paramtypes", []),
1407
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1022
+ _ts_decorate2([
1023
+ (0, import_common5.Get)("pricing"),
1024
+ _ts_metadata2("design:type", Function),
1025
+ _ts_metadata2("design:paramtypes", []),
1026
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1408
1027
  ], AgentApiController.prototype, "listPrices", null);
1409
- _ts_decorate3([
1410
- (0, import_common6.Post)("pricing"),
1411
- _ts_param3(0, (0, import_common6.Body)()),
1412
- _ts_metadata3("design:type", Function),
1413
- _ts_metadata3("design:paramtypes", [
1028
+ _ts_decorate2([
1029
+ (0, import_common5.Post)("pricing"),
1030
+ _ts_param2(0, (0, import_common5.Body)()),
1031
+ _ts_metadata2("design:type", Function),
1032
+ _ts_metadata2("design:paramtypes", [
1414
1033
  Object
1415
1034
  ]),
1416
- _ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1035
+ _ts_metadata2("design:returntype", typeof Promise === "undefined" ? Object : Promise)
1417
1036
  ], AgentApiController.prototype, "upsertPrice", null);
1418
- _ts_decorate3([
1419
- (0, import_common6.Sse)("stream"),
1420
- _ts_metadata3("design:type", Function),
1421
- _ts_metadata3("design:paramtypes", []),
1422
- _ts_metadata3("design:returntype", typeof Observable === "undefined" ? Object : Observable)
1037
+ _ts_decorate2([
1038
+ (0, import_common5.Sse)("stream"),
1039
+ _ts_metadata2("design:type", Function),
1040
+ _ts_metadata2("design:paramtypes", []),
1041
+ _ts_metadata2("design:returntype", typeof Observable === "undefined" ? Object : Observable)
1423
1042
  ], AgentApiController.prototype, "stream", null);
1424
- AgentApiController = _ts_decorate3([
1425
- (0, import_common6.Controller)(),
1426
- (0, import_common6.UseGuards)(DashboardAuthGuard),
1427
- _ts_param3(1, (0, import_common6.Inject)(DASHBOARD_APPROVAL_ACTOR_REF)),
1428
- _ts_param3(2, (0, import_common6.Optional)()),
1429
- _ts_param3(2, (0, import_common6.Inject)(AGENT_ACTOR_RESOLVER)),
1430
- _ts_metadata3("design:type", Function),
1431
- _ts_metadata3("design:paramtypes", [
1043
+ AgentApiController = _ts_decorate2([
1044
+ (0, import_nestjs_agent_core.CanAnyone)(),
1045
+ (0, import_common5.Controller)(),
1046
+ _ts_param2(1, (0, import_common5.Inject)(DASHBOARD_APPROVAL_ACTOR_REF)),
1047
+ _ts_param2(2, (0, import_common5.Optional)()),
1048
+ _ts_param2(2, (0, import_common5.Inject)(AGENT_ACTOR_RESOLVER)),
1049
+ _ts_metadata2("design:type", Function),
1050
+ _ts_metadata2("design:paramtypes", [
1432
1051
  typeof DashboardService === "undefined" ? Object : DashboardService,
1433
1052
  Object,
1434
1053
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1435
1054
  ])
1436
1055
  ], AgentApiController);
1437
1056
 
1438
- // src/server/agent-dashboard-auth.controller.ts
1439
- var import_common7 = require("@nestjs/common");
1440
-
1441
- // src/server/auth/login-page.ts
1442
- function escapeHtml(value) {
1443
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1444
- }
1445
- __name(escapeHtml, "escapeHtml");
1446
- function pageShell(content, title) {
1447
- return `<!doctype html>
1448
- <html lang="en">
1449
- <head>
1450
- <meta charset="utf-8" />
1451
- <meta name="viewport" content="width=device-width, initial-scale=1" />
1452
- <meta name="robots" content="noindex, nofollow" />
1453
- <title>${title}</title>
1454
- <style>
1455
- :root { color-scheme: dark; }
1456
- * { box-sizing: border-box; }
1457
- body {
1458
- margin: 0;
1459
- min-height: 100vh;
1460
- display: flex;
1461
- align-items: center;
1462
- justify-content: center;
1463
- background: #09090b;
1464
- color: #e4e4e7;
1465
- font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
1466
- padding: 16px;
1467
- }
1468
- .card {
1469
- width: 100%;
1470
- max-width: 384px;
1471
- border: 1px solid #27272a;
1472
- background: #18181b;
1473
- border-radius: 8px;
1474
- padding: 32px;
1475
- box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.5);
1476
- }
1477
- .brand {
1478
- margin: 0 0 24px;
1479
- text-align: center;
1480
- font-size: 18px;
1481
- font-weight: 600;
1482
- color: #34d399;
1483
- }
1484
- h1 {
1485
- margin: 0 0 12px;
1486
- font-size: 16px;
1487
- font-weight: 600;
1488
- color: #f4f4f5;
1489
- }
1490
- p { margin: 0 0 16px; color: #a1a1aa; }
1491
- form { display: flex; flex-direction: column; gap: 16px; }
1492
- label { display: flex; flex-direction: column; gap: 6px; }
1493
- .field-label {
1494
- font-size: 11px;
1495
- text-transform: uppercase;
1496
- letter-spacing: 0.05em;
1497
- color: #71717a;
1498
- }
1499
- input {
1500
- border-radius: 4px;
1501
- border: 1px solid #3f3f46;
1502
- background: #09090b;
1503
- color: #f4f4f5;
1504
- padding: 8px 12px;
1505
- font: inherit;
1506
- outline: none;
1507
- }
1508
- input:focus { border-color: rgb(52 211 153 / 0.6); }
1509
- .error { margin: 0; font-size: 12px; color: #fb7185; }
1510
- button {
1511
- margin-top: 8px;
1512
- border-radius: 4px;
1513
- border: 1px solid rgb(52 211 153 / 0.4);
1514
- background: rgb(52 211 153 / 0.1);
1515
- color: #6ee7b7;
1516
- padding: 8px 12px;
1517
- font: inherit;
1518
- font-size: 12px;
1519
- font-weight: 500;
1520
- text-transform: uppercase;
1521
- letter-spacing: 0.05em;
1522
- cursor: pointer;
1523
- }
1524
- button:hover { background: rgb(52 211 153 / 0.2); }
1525
- </style>
1526
- </head>
1527
- <body>
1528
- <div class="card">
1529
- ${content}
1530
- </div>
1531
- </body>
1532
- </html>`;
1533
- }
1534
- __name(pageShell, "pageShell");
1535
- function renderLoginPage(options) {
1536
- const action = escapeHtml(options.actionUrl);
1537
- const returnTo = escapeHtml(options.returnTo);
1538
- const errorBanner = options.error === true ? '<p role="alert" class="error">Invalid username or password.</p>' : "";
1539
- return pageShell(`<p class="brand">AI Gateway</p>
1540
- <form method="post" action="${action}">
1541
- <input type="hidden" name="returnTo" value="${returnTo}" />
1542
- <label>
1543
- <span class="field-label">Username</span>
1544
- <input type="text" name="username" autocomplete="username" autofocus />
1545
- </label>
1546
- <label>
1547
- <span class="field-label">Password</span>
1548
- <input type="password" name="password" autocomplete="current-password" />
1549
- </label>
1550
- ${errorBanner}
1551
- <button type="submit">Sign in</button>
1552
- </form>`, "Sign in \u2014 AI Gateway");
1553
- }
1554
- __name(renderLoginPage, "renderLoginPage");
1555
- function renderSessionRequiredPage() {
1556
- return pageShell(`<p class="brand">AI Gateway</p>
1557
- <h1>Open this console from your application</h1>
1558
- <p>Your session is minted by the host app. Use its console launcher to sign in, then reload.</p>`, "Sign in \u2014 AI Gateway");
1559
- }
1560
- __name(renderSessionRequiredPage, "renderSessionRequiredPage");
1561
-
1562
- // src/server/auth/sanitize-return-to.ts
1563
- function sanitizeReturnTo(basePath, returnTo) {
1564
- if (typeof returnTo !== "string" || returnTo === "") return basePath;
1565
- if (!returnTo.startsWith("/") || returnTo.startsWith("//")) return basePath;
1566
- if (returnTo !== basePath && !returnTo.startsWith(`${basePath}/`) && !returnTo.startsWith(`${basePath}?`)) {
1567
- return basePath;
1568
- }
1569
- return returnTo;
1570
- }
1571
- __name(sanitizeReturnTo, "sanitizeReturnTo");
1572
-
1573
- // src/server/agent-dashboard-auth.controller.ts
1574
- function _ts_decorate4(decorators, target, key, desc) {
1575
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1576
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1577
- r = Reflect.decorate(decorators, target, key, desc);
1578
- } else {
1579
- for (var i = decorators.length - 1; i >= 0; i--) {
1580
- if (d = decorators[i]) {
1581
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1582
- }
1583
- }
1584
- }
1585
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1586
- }
1587
- __name(_ts_decorate4, "_ts_decorate");
1588
- function _ts_metadata4(metadataKey, metadataValue) {
1589
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1590
- return Reflect.metadata(metadataKey, metadataValue);
1591
- }
1592
- }
1593
- __name(_ts_metadata4, "_ts_metadata");
1594
- function _ts_param4(paramIndex, decorator) {
1595
- return function(target, key) {
1596
- decorator(target, key, paramIndex);
1597
- };
1598
- }
1599
- __name(_ts_param4, "_ts_param");
1600
- function isNonEmptyString(value) {
1601
- return typeof value === "string" && value.trim() !== "";
1602
- }
1603
- __name(isNonEmptyString, "isNonEmptyString");
1604
- function isString(value) {
1605
- return typeof value === "string";
1606
- }
1607
- __name(isString, "isString");
1608
- var AgentDashboardAuthController = class _AgentDashboardAuthController {
1609
- static {
1610
- __name(this, "AgentDashboardAuthController");
1611
- }
1612
- auth;
1613
- basePath;
1614
- logger = new import_common7.Logger(_AgentDashboardAuthController.name);
1615
- /** Warn once PER HOOK KIND (not per request) so a broken hook can't be used to flood the logs. */
1616
- warnedHooks = /* @__PURE__ */ new Set();
1617
- constructor(auth, basePath) {
1618
- this.auth = auth;
1619
- this.basePath = basePath;
1620
- }
1621
- loginPage(req, res, returnToQuery, error) {
1622
- const auth = this.requireAuth();
1623
- if (!auth.modes.includes("login")) throw new import_common7.NotFoundException();
1624
- const returnTo = sanitizeReturnTo(this.basePath, returnToQuery);
1625
- if (this.currentSession(req)) {
1626
- res.status(302);
1627
- res.setHeader("Location", returnTo);
1628
- return "";
1629
- }
1630
- return renderLoginPage({
1631
- actionUrl: `${this.basePath}/auth/login`,
1632
- returnTo,
1633
- error: error !== void 0
1634
- });
1635
- }
1636
- async login(body, req, res) {
1637
- const auth = this.requireAuth();
1638
- if (!auth.modes.includes("login")) throw new import_common7.NotFoundException();
1639
- const returnTo = sanitizeReturnTo(this.basePath, body?.returnTo);
1640
- const username = body?.username;
1641
- const password = body?.password;
1642
- if (!isNonEmptyString(username) || password !== void 0 && !isString(password)) {
1643
- this.redirectToLoginError(res, returnTo);
1644
- return "";
1645
- }
1646
- const user = await this.runHook("login", () => auth.login?.(username.trim(), isString(password) ? password : "") ?? null);
1647
- if (!user) {
1648
- this.redirectToLoginError(res, returnTo);
1649
- return "";
1650
- }
1651
- issueSessionCookie(user, {
1652
- auth,
1653
- request: req,
1654
- response: res
1655
- });
1656
- res.status(302);
1657
- res.setHeader("Location", returnTo);
1658
- return "";
1659
- }
1660
- logout(req, res) {
1661
- clearSessionCookie({
1662
- request: req,
1663
- response: res
1664
- });
1665
- res.status(302);
1666
- res.setHeader("Location", this.auth && !this.auth.modes.includes("login") ? `${this.basePath}/auth/session-required` : `${this.basePath}/auth/login`);
1667
- return "";
1668
- }
1669
- // Mode A: the host frontend (carrying its own auth) POSTs here; the host hook validates the raw
1670
- // request and returns the session user, or `null` to deny. No credential reaches this library.
1671
- async session(request, response) {
1672
- const auth = this.requireAuth();
1673
- if (!auth.modes.includes("session")) throw new import_common7.NotFoundException();
1674
- const user = await this.runHook("session", () => auth.session?.(request) ?? null);
1675
- if (!user) throw new import_common7.UnauthorizedException();
1676
- issueSessionCookie(user, {
1677
- auth,
1678
- request,
1679
- response
1680
- });
1681
- }
1682
- // Mode-A-only landing: the host mints the session, so there is nothing to submit here. Serves
1683
- // as the redirect target `DashboardAuthPageGuard` bounces to instead of `/auth/login`, which
1684
- // 404s under Mode A (see `loginPage` above).
1685
- //
1686
- // Non-passthrough `@Res()` (unlike its sibling routes) because `dashboardAuth.unauthenticatedPage`
1687
- // hands the response to the HOST, which writes and ends it itself — there is no return value for
1688
- // Nest to send, and letting Nest also send one would double-write. The `Content-Type` /
1689
- // `Cache-Control` this route used to carry as decorators move into `sendHtml` for the built-in
1690
- // path; the host owns its own headers on the hook path.
1691
- async sessionRequiredPage(req, res) {
1692
- const auth = this.requireAuth();
1693
- if (auth.modes.includes("login")) throw new import_common7.NotFoundException();
1694
- const hook = auth.unauthenticatedPage;
1695
- if (hook) {
1696
- try {
1697
- await hook({
1698
- request: req,
1699
- response: res,
1700
- basePath: this.basePath
1701
- });
1702
- if (responseAlreadyWritten(res)) return;
1703
- this.warnHookOnce("unauthenticatedPage", "dashboardAuth.unauthenticatedPage returned without writing a response; falling back to the built-in page. The hook must write AND end the response it is given.");
1704
- } catch (error) {
1705
- this.warnHookOnce("unauthenticatedPage", `dashboardAuth.unauthenticatedPage threw; falling back to the built-in page. ${String(error)}`);
1706
- if (responseAlreadyWritten(res)) return;
1707
- }
1708
- }
1709
- sendHtml(res, 200, renderSessionRequiredPage());
1710
- }
1711
- /** Uniform failure: same redirect (generic error flag) whether the user is unknown or the password is wrong. */
1712
- redirectToLoginError(res, returnTo) {
1713
- res.status(303);
1714
- res.setHeader("Location", `${this.basePath}/auth/login?error=1&returnTo=${encodeURIComponent(returnTo)}`);
1715
- }
1716
- currentSession(req) {
1717
- const auth = this.auth;
1718
- if (!auth) return false;
1719
- const cookieValue = parseCookieHeader(readCookieHeader(req))[SESSION_COOKIE_NAME];
1720
- if (cookieValue === void 0) return false;
1721
- return verifySessionCookie(cookieValue, {
1722
- secret: auth.secret
1723
- }) !== null;
1724
- }
1725
- /**
1726
- * Run a host hook (`login` or `session`) defensively: a throw (sync or async) is treated as a
1727
- * denial (`null`) and warn-logged ONCE PER KIND, so a buggy/unreachable hook never 500s the
1728
- * endpoint into a stack-trace leak nor floods the logs on repeated bad attempts.
1729
- */
1730
- async runHook(kind, run) {
1731
- try {
1732
- return await run() ?? null;
1733
- } catch (error) {
1734
- this.warnHookOnce(kind, `AgentDashboardModule dashboardAuth ${kind} hook threw; treating as denial. ${error instanceof Error ? error.message : String(error)}`);
1735
- return null;
1736
- }
1737
- }
1738
- /**
1739
- * Warn once per hook kind for the life of the process, not once per request: a broken hook fires
1740
- * on every denied navigation and would otherwise flood the logs.
1741
- */
1742
- warnHookOnce(kind, message) {
1743
- if (this.warnedHooks.has(kind)) return;
1744
- this.warnedHooks.add(kind);
1745
- this.logger.warn(message);
1746
- }
1747
- requireAuth() {
1748
- if (!this.auth) throw new import_common7.NotFoundException();
1749
- return this.auth;
1750
- }
1751
- };
1752
- _ts_decorate4([
1753
- (0, import_common7.Get)("login"),
1754
- (0, import_common7.Header)("Content-Type", "text/html; charset=utf-8"),
1755
- (0, import_common7.Header)("Cache-Control", "no-store"),
1756
- _ts_param4(0, (0, import_common7.Req)()),
1757
- _ts_param4(1, (0, import_common7.Res)({
1758
- passthrough: true
1759
- })),
1760
- _ts_param4(2, (0, import_common7.Query)("returnTo")),
1761
- _ts_param4(3, (0, import_common7.Query)("error")),
1762
- _ts_metadata4("design:type", Function),
1763
- _ts_metadata4("design:paramtypes", [
1764
- typeof AuthPageRequest === "undefined" ? Object : AuthPageRequest,
1765
- typeof AuthPageResponse === "undefined" ? Object : AuthPageResponse,
1766
- String,
1767
- String
1768
- ]),
1769
- _ts_metadata4("design:returntype", String)
1770
- ], AgentDashboardAuthController.prototype, "loginPage", null);
1771
- _ts_decorate4([
1772
- (0, import_common7.Post)("login"),
1773
- _ts_param4(0, (0, import_common7.Body)()),
1774
- _ts_param4(1, (0, import_common7.Req)()),
1775
- _ts_param4(2, (0, import_common7.Res)({
1776
- passthrough: true
1777
- })),
1778
- _ts_metadata4("design:type", Function),
1779
- _ts_metadata4("design:paramtypes", [
1780
- typeof LoginFormBody === "undefined" ? Object : LoginFormBody,
1781
- Object,
1782
- typeof AuthPageResponse === "undefined" ? Object : AuthPageResponse
1783
- ]),
1784
- _ts_metadata4("design:returntype", Promise)
1785
- ], AgentDashboardAuthController.prototype, "login", null);
1786
- _ts_decorate4([
1787
- (0, import_common7.Post)("logout"),
1788
- _ts_param4(0, (0, import_common7.Req)()),
1789
- _ts_param4(1, (0, import_common7.Res)({
1790
- passthrough: true
1791
- })),
1792
- _ts_metadata4("design:type", Function),
1793
- _ts_metadata4("design:paramtypes", [
1794
- Object,
1795
- typeof AuthPageResponse === "undefined" ? Object : AuthPageResponse
1796
- ]),
1797
- _ts_metadata4("design:returntype", String)
1798
- ], AgentDashboardAuthController.prototype, "logout", null);
1799
- _ts_decorate4([
1800
- (0, import_common7.Post)("session"),
1801
- (0, import_common7.HttpCode)(204),
1802
- _ts_param4(0, (0, import_common7.Req)()),
1803
- _ts_param4(1, (0, import_common7.Res)({
1804
- passthrough: true
1805
- })),
1806
- _ts_metadata4("design:type", Function),
1807
- _ts_metadata4("design:paramtypes", [
1808
- Object,
1809
- Object
1810
- ]),
1811
- _ts_metadata4("design:returntype", Promise)
1812
- ], AgentDashboardAuthController.prototype, "session", null);
1813
- _ts_decorate4([
1814
- (0, import_common7.Get)("session-required"),
1815
- _ts_param4(0, (0, import_common7.Req)()),
1816
- _ts_param4(1, (0, import_common7.Res)()),
1817
- _ts_metadata4("design:type", Function),
1818
- _ts_metadata4("design:paramtypes", [
1819
- typeof AuthPageRequest === "undefined" ? Object : AuthPageRequest,
1820
- Object
1821
- ]),
1822
- _ts_metadata4("design:returntype", Promise)
1823
- ], AgentDashboardAuthController.prototype, "sessionRequiredPage", null);
1824
- AgentDashboardAuthController = _ts_decorate4([
1825
- (0, import_common7.Controller)("auth"),
1826
- _ts_param4(0, (0, import_common7.Optional)()),
1827
- _ts_param4(0, (0, import_common7.Inject)(DASHBOARD_AUTH)),
1828
- _ts_param4(1, (0, import_common7.Inject)(DASHBOARD_BASE_PATH)),
1829
- _ts_metadata4("design:type", Function),
1830
- _ts_metadata4("design:paramtypes", [
1831
- Object,
1832
- String
1833
- ])
1834
- ], AgentDashboardAuthController);
1835
-
1836
1057
  // src/server/normalize-path.ts
1837
1058
  function normalizeDashboardPath(path) {
1838
1059
  return `/${path.replace(/^\/+|\/+$/g, "")}`;
@@ -1859,153 +1080,18 @@ function agentDashboardMountPaths(options) {
1859
1080
  __name(agentDashboardMountPaths, "agentDashboardMountPaths");
1860
1081
 
1861
1082
  // src/server/agent-dashboard.module.ts
1862
- var import_reflect_metadata2 = require("reflect-metadata");
1863
- var import_common11 = require("@nestjs/common");
1083
+ var import_nestjs_agent_core3 = require("@dudousxd/nestjs-agent-core");
1084
+ var import_reflect_metadata = require("reflect-metadata");
1085
+ var import_common7 = require("@nestjs/common");
1864
1086
  var import_core = require("@nestjs/core");
1865
1087
 
1866
1088
  // src/server/agent-ui.controller.ts
1867
1089
  var import_node_fs = require("fs");
1868
1090
  var import_node_path = require("path");
1869
1091
  var import_node_url = require("url");
1870
- var import_common10 = require("@nestjs/common");
1871
-
1872
- // src/server/auth/dashboard-auth-page.guard.ts
1873
- var import_common9 = require("@nestjs/common");
1874
-
1875
- // src/server/auth/dashboard-auth-redirect.ts
1876
- var import_common8 = require("@nestjs/common");
1877
- function _ts_decorate5(decorators, target, key, desc) {
1878
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1879
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1880
- r = Reflect.decorate(decorators, target, key, desc);
1881
- } else {
1882
- for (var i = decorators.length - 1; i >= 0; i--) {
1883
- if (d = decorators[i]) {
1884
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1885
- }
1886
- }
1887
- }
1888
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1889
- }
1890
- __name(_ts_decorate5, "_ts_decorate");
1891
- var DashboardAuthRedirect = class extends Error {
1892
- static {
1893
- __name(this, "DashboardAuthRedirect");
1894
- }
1895
- redirectTo;
1896
- constructor(redirectTo) {
1897
- super(`Redirect to ${redirectTo}`), this.redirectTo = redirectTo;
1898
- this.name = "DashboardAuthRedirect";
1899
- }
1900
- };
1901
- var DashboardAuthRedirectFilter = class {
1902
- static {
1903
- __name(this, "DashboardAuthRedirectFilter");
1904
- }
1905
- catch(exception, host) {
1906
- const response = host.switchToHttp().getResponse();
1907
- sendRedirect(response, 302, exception.redirectTo);
1908
- }
1909
- };
1910
- DashboardAuthRedirectFilter = _ts_decorate5([
1911
- (0, import_common8.Injectable)(),
1912
- (0, import_common8.Catch)(DashboardAuthRedirect)
1913
- ], DashboardAuthRedirectFilter);
1914
-
1915
- // src/server/auth/dashboard-auth-page.guard.ts
1916
- function _ts_decorate6(decorators, target, key, desc) {
1917
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1918
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1919
- r = Reflect.decorate(decorators, target, key, desc);
1920
- } else {
1921
- for (var i = decorators.length - 1; i >= 0; i--) {
1922
- if (d = decorators[i]) {
1923
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1924
- }
1925
- }
1926
- }
1927
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1928
- }
1929
- __name(_ts_decorate6, "_ts_decorate");
1930
- function _ts_metadata5(metadataKey, metadataValue) {
1931
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1932
- return Reflect.metadata(metadataKey, metadataValue);
1933
- }
1934
- }
1935
- __name(_ts_metadata5, "_ts_metadata");
1936
- function _ts_param5(paramIndex, decorator) {
1937
- return function(target, key) {
1938
- decorator(target, key, paramIndex);
1939
- };
1940
- }
1941
- __name(_ts_param5, "_ts_param");
1942
- var DashboardAuthPageGuard = class {
1943
- static {
1944
- __name(this, "DashboardAuthPageGuard");
1945
- }
1946
- auth;
1947
- basePath;
1948
- constructor(auth, basePath) {
1949
- this.auth = auth;
1950
- this.basePath = basePath;
1951
- }
1952
- async canActivate(context) {
1953
- if (!this.auth) return true;
1954
- const auth = this.auth;
1955
- const http = context.switchToHttp();
1956
- const request = http.getRequest();
1957
- const session = this.verifyRequestSession(request);
1958
- if (!session) this.deny(auth, request);
1959
- attachSession(request, session);
1960
- if (!await maybeRenewSession(auth, session, request, http.getResponse())) {
1961
- this.deny(auth, request);
1962
- }
1963
- return true;
1964
- }
1965
- /**
1966
- * No valid session: bounce the browser navigation onward. Under Mode B (`login` configured)
1967
- * that's the built-in login screen, carrying `returnTo` back to the page that was requested.
1968
- * Under Mode-A-only there is no login screen to redirect to — the host mints the session
1969
- * itself — so this instead serves the instruction page rather than redirecting into a 404.
1970
- * Pulled out of `canActivate` so both the "no session at all" and the "revalidate revoked a
1971
- * renewable session" paths reuse the exact same mode-aware deny logic.
1972
- *
1973
- * Takes `auth` explicitly rather than reading `this.auth`: `canActivate`'s `!this.auth` early
1974
- * return narrows the field within that method only — TS doesn't carry it across a method call —
1975
- * so the caller passes the already-narrowed value instead of this method re-deriving (or
1976
- * asserting away) the nullability.
1977
- */
1978
- deny(auth, request) {
1979
- if (!auth.modes.includes("login")) {
1980
- throw new DashboardAuthRedirect(`${this.basePath}/auth/session-required`);
1981
- }
1982
- const returnTo = readOriginalUrl(request);
1983
- throw new DashboardAuthRedirect(`${this.basePath}/auth/login?returnTo=${encodeURIComponent(returnTo)}`);
1984
- }
1985
- verifyRequestSession(request) {
1986
- const auth = this.auth;
1987
- if (!auth) return null;
1988
- const cookieValue = parseCookieHeader(readCookieHeader(request))[SESSION_COOKIE_NAME];
1989
- if (cookieValue === void 0) return null;
1990
- return verifySessionCookie(cookieValue, {
1991
- secret: auth.secret
1992
- });
1993
- }
1994
- };
1995
- DashboardAuthPageGuard = _ts_decorate6([
1996
- (0, import_common9.Injectable)(),
1997
- _ts_param5(0, (0, import_common9.Optional)()),
1998
- _ts_param5(0, (0, import_common9.Inject)(DASHBOARD_AUTH)),
1999
- _ts_param5(1, (0, import_common9.Inject)(DASHBOARD_BASE_PATH)),
2000
- _ts_metadata5("design:type", Function),
2001
- _ts_metadata5("design:paramtypes", [
2002
- Object,
2003
- String
2004
- ])
2005
- ], DashboardAuthPageGuard);
2006
-
2007
- // src/server/agent-ui.controller.ts
2008
- function _ts_decorate7(decorators, target, key, desc) {
1092
+ var import_nestjs_agent_core2 = require("@dudousxd/nestjs-agent-core");
1093
+ var import_common6 = require("@nestjs/common");
1094
+ function _ts_decorate3(decorators, target, key, desc) {
2009
1095
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2010
1096
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2011
1097
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2018,19 +1104,19 @@ function _ts_decorate7(decorators, target, key, desc) {
2018
1104
  }
2019
1105
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2020
1106
  }
2021
- __name(_ts_decorate7, "_ts_decorate");
2022
- function _ts_metadata6(metadataKey, metadataValue) {
1107
+ __name(_ts_decorate3, "_ts_decorate");
1108
+ function _ts_metadata3(metadataKey, metadataValue) {
2023
1109
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2024
1110
  return Reflect.metadata(metadataKey, metadataValue);
2025
1111
  }
2026
1112
  }
2027
- __name(_ts_metadata6, "_ts_metadata");
2028
- function _ts_param6(paramIndex, decorator) {
1113
+ __name(_ts_metadata3, "_ts_metadata");
1114
+ function _ts_param3(paramIndex, decorator) {
2029
1115
  return function(target, key) {
2030
1116
  decorator(target, key, paramIndex);
2031
1117
  };
2032
1118
  }
2033
- __name(_ts_param6, "_ts_param");
1119
+ __name(_ts_param3, "_ts_param");
2034
1120
  var BUILD_BASE = "/ai-gateway";
2035
1121
  function spaDir() {
2036
1122
  return (0, import_node_url.fileURLToPath)(new URL("../spa", __importMetaUrl));
@@ -2066,7 +1152,7 @@ var AgentUiController = class {
2066
1152
  }
2067
1153
  const indexPath = (0, import_node_path.join)(this.dir, "index.html");
2068
1154
  if (!(0, import_node_fs.existsSync)(indexPath)) {
2069
- throw new import_common10.NotFoundException("Dashboard is not built. Run the package build.");
1155
+ throw new import_common6.NotFoundException("Dashboard is not built. Run the package build.");
2070
1156
  }
2071
1157
  const html = (0, import_node_fs.readFileSync)(indexPath, "utf8").replaceAll(`="${BUILD_BASE}/`, `="${this.basePath}/`);
2072
1158
  const inject = `<script>window.__AGENT_BASE__='${this.basePath}';window.__AGENT_API__='${this.apiBasePath}';</script>`;
@@ -2074,155 +1160,57 @@ var AgentUiController = class {
2074
1160
  }
2075
1161
  asset(file) {
2076
1162
  const safe = (0, import_node_path.basename)(file);
2077
- if (safe !== file) throw new import_common10.NotFoundException();
1163
+ if (safe !== file) throw new import_common6.NotFoundException();
2078
1164
  const root = (0, import_node_path.resolve)(this.dir, "assets");
2079
1165
  const assetPath = (0, import_node_path.resolve)(root, safe);
2080
1166
  if (!assetPath.startsWith(root + import_node_path.sep) || !(0, import_node_fs.existsSync)(assetPath)) {
2081
- throw new import_common10.NotFoundException();
1167
+ throw new import_common6.NotFoundException();
2082
1168
  }
2083
1169
  const type = CONTENT_TYPES[(0, import_node_path.extname)(safe)] ?? "application/octet-stream";
2084
- return new import_common10.StreamableFile((0, import_node_fs.readFileSync)(assetPath), {
1170
+ return new import_common6.StreamableFile((0, import_node_fs.readFileSync)(assetPath), {
2085
1171
  type
2086
1172
  });
2087
1173
  }
2088
1174
  };
2089
- _ts_decorate7([
2090
- (0, import_common10.Get)(),
2091
- (0, import_common10.Header)("Content-Type", "text/html; charset=utf-8"),
2092
- (0, import_common10.Header)("Cache-Control", "no-store, must-revalidate"),
2093
- _ts_param6(0, (0, import_common10.Req)()),
2094
- _ts_param6(1, (0, import_common10.Res)({
1175
+ _ts_decorate3([
1176
+ (0, import_common6.Get)(),
1177
+ (0, import_common6.Header)("Content-Type", "text/html; charset=utf-8"),
1178
+ (0, import_common6.Header)("Cache-Control", "no-store, must-revalidate"),
1179
+ _ts_param3(0, (0, import_common6.Req)()),
1180
+ _ts_param3(1, (0, import_common6.Res)({
2095
1181
  passthrough: true
2096
1182
  })),
2097
- _ts_metadata6("design:type", Function),
2098
- _ts_metadata6("design:paramtypes", [
1183
+ _ts_metadata3("design:type", Function),
1184
+ _ts_metadata3("design:paramtypes", [
2099
1185
  typeof UiPageRequest === "undefined" ? Object : UiPageRequest,
2100
1186
  typeof UiPageResponse === "undefined" ? Object : UiPageResponse
2101
1187
  ]),
2102
- _ts_metadata6("design:returntype", String)
1188
+ _ts_metadata3("design:returntype", String)
2103
1189
  ], AgentUiController.prototype, "index", null);
2104
- _ts_decorate7([
2105
- (0, import_common10.Get)("assets/:file"),
2106
- (0, import_common10.Header)("Cache-Control", "public, max-age=31536000, immutable"),
2107
- _ts_param6(0, (0, import_common10.Param)("file")),
2108
- _ts_metadata6("design:type", Function),
2109
- _ts_metadata6("design:paramtypes", [
1190
+ _ts_decorate3([
1191
+ (0, import_common6.Get)("assets/:file"),
1192
+ (0, import_common6.Header)("Cache-Control", "public, max-age=31536000, immutable"),
1193
+ _ts_param3(0, (0, import_common6.Param)("file")),
1194
+ _ts_metadata3("design:type", Function),
1195
+ _ts_metadata3("design:paramtypes", [
2110
1196
  String
2111
1197
  ]),
2112
- _ts_metadata6("design:returntype", typeof import_common10.StreamableFile === "undefined" ? Object : import_common10.StreamableFile)
1198
+ _ts_metadata3("design:returntype", typeof import_common6.StreamableFile === "undefined" ? Object : import_common6.StreamableFile)
2113
1199
  ], AgentUiController.prototype, "asset", null);
2114
- AgentUiController = _ts_decorate7([
2115
- (0, import_common10.Controller)(),
2116
- (0, import_common10.UseGuards)(DashboardAuthPageGuard),
2117
- (0, import_common10.UseFilters)(new DashboardAuthRedirectFilter()),
2118
- _ts_param6(0, (0, import_common10.Inject)(DASHBOARD_BASE_PATH)),
2119
- _ts_param6(1, (0, import_common10.Inject)(DASHBOARD_API_PATH)),
2120
- _ts_metadata6("design:type", Function),
2121
- _ts_metadata6("design:paramtypes", [
1200
+ AgentUiController = _ts_decorate3([
1201
+ (0, import_nestjs_agent_core2.CanAnyone)(),
1202
+ (0, import_common6.Controller)(),
1203
+ _ts_param3(0, (0, import_common6.Inject)(DASHBOARD_BASE_PATH)),
1204
+ _ts_param3(1, (0, import_common6.Inject)(DASHBOARD_API_PATH)),
1205
+ _ts_metadata3("design:type", Function),
1206
+ _ts_metadata3("design:paramtypes", [
2122
1207
  String,
2123
1208
  String
2124
1209
  ])
2125
1210
  ], AgentUiController);
2126
1211
 
2127
- // src/server/auth/dashboard-auth-config.ts
2128
- var DEFAULT_TTL = "8h";
2129
- function unitToMs(unit) {
2130
- switch (unit) {
2131
- case "ms":
2132
- return 1;
2133
- case "s":
2134
- return 1e3;
2135
- case "m":
2136
- return 6e4;
2137
- case "h":
2138
- return 36e5;
2139
- case "d":
2140
- return 864e5;
2141
- default:
2142
- return void 0;
2143
- }
2144
- }
2145
- __name(unitToMs, "unitToMs");
2146
- function durationToMs(duration) {
2147
- const match = /^(\d+)(ms|s|m|h|d)$/.exec(duration.trim());
2148
- const amount = match?.[1];
2149
- const unit = match?.[2] !== void 0 ? unitToMs(match[2]) : void 0;
2150
- if (amount === void 0 || unit === void 0) {
2151
- throw new Error(`AgentDashboardModule dashboardAuth: invalid \`ttl\` duration: ${duration}`);
2152
- }
2153
- return Number(amount) * unit;
2154
- }
2155
- __name(durationToMs, "durationToMs");
2156
- function resolveDashboardAuth(options) {
2157
- if (options === void 0) return null;
2158
- if (typeof options.secret !== "string" || options.secret === "") {
2159
- throw new Error("AgentDashboardModule dashboardAuth: `secret` is required and must be a non-empty string (HMAC-SHA256 signing key, 32+ bytes recommended). Failing closed.");
2160
- }
2161
- const modes = [];
2162
- if (options.session !== void 0) {
2163
- if (typeof options.session !== "function") {
2164
- throw new Error("AgentDashboardModule dashboardAuth: `session` must be a function.");
2165
- }
2166
- modes.push("session");
2167
- }
2168
- if (options.login !== void 0) {
2169
- if (typeof options.login !== "function") {
2170
- throw new Error("AgentDashboardModule dashboardAuth: `login` must be a function.");
2171
- }
2172
- modes.push("login");
2173
- }
2174
- if (options.revalidate !== void 0 && typeof options.revalidate !== "function") {
2175
- throw new Error("AgentDashboardModule dashboardAuth: `revalidate` must be a function.");
2176
- }
2177
- if (options.unauthenticatedPage !== void 0 && typeof options.unauthenticatedPage !== "function") {
2178
- throw new Error("AgentDashboardModule dashboardAuth: `unauthenticatedPage` must be a function.");
2179
- }
2180
- if (modes.length === 0) {
2181
- throw new Error("AgentDashboardModule dashboardAuth: at least one of `session` (the host mints the session from its own auth) or `login` (the built-in login screen) is required \u2014 otherwise the cookie can never be minted. Failing closed.");
2182
- }
2183
- return {
2184
- secret: options.secret,
2185
- ttlMs: durationToMs(options.ttl ?? DEFAULT_TTL),
2186
- modes,
2187
- ...options.session !== void 0 ? {
2188
- session: options.session
2189
- } : {},
2190
- ...options.login !== void 0 ? {
2191
- login: options.login
2192
- } : {},
2193
- ...options.revalidate !== void 0 ? {
2194
- revalidate: options.revalidate
2195
- } : {},
2196
- ...options.unauthenticatedPage !== void 0 ? {
2197
- unauthenticatedPage: options.unauthenticatedPage
2198
- } : {}
2199
- };
2200
- }
2201
- __name(resolveDashboardAuth, "resolveDashboardAuth");
2202
-
2203
- // src/server/guards.ts
2204
- var import_reflect_metadata = require("reflect-metadata");
2205
- var GUARDS_METADATA = "__guards__";
2206
- function isGuardClass(guard) {
2207
- return typeof guard === "function";
2208
- }
2209
- __name(isGuardClass, "isGuardClass");
2210
- function baseGuards(controller) {
2211
- return Reflect.getOwnMetadata(GUARDS_METADATA, controller) ?? [];
2212
- }
2213
- __name(baseGuards, "baseGuards");
2214
- function stampGuards(guards, entries) {
2215
- for (const [controller, base] of entries) {
2216
- Reflect.defineMetadata(GUARDS_METADATA, [
2217
- ...base,
2218
- ...guards ?? []
2219
- ], controller);
2220
- }
2221
- }
2222
- __name(stampGuards, "stampGuards");
2223
-
2224
1212
  // src/server/agent-dashboard.module.ts
2225
- function _ts_decorate8(decorators, target, key, desc) {
1213
+ function _ts_decorate4(decorators, target, key, desc) {
2226
1214
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2227
1215
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2228
1216
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2235,37 +1223,33 @@ function _ts_decorate8(decorators, target, key, desc) {
2235
1223
  }
2236
1224
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2237
1225
  }
2238
- __name(_ts_decorate8, "_ts_decorate");
2239
- var API_BASE_GUARDS = baseGuards(AgentApiController);
2240
- var UI_BASE_GUARDS = baseGuards(AgentUiController);
1226
+ __name(_ts_decorate4, "_ts_decorate");
2241
1227
  function normalize(path) {
2242
1228
  return normalizeDashboardPath(path);
2243
1229
  }
2244
1230
  __name(normalize, "normalize");
1231
+ function assertProtected(options) {
1232
+ if (process.env.NODE_ENV !== "production") return;
1233
+ if (options.routes === false) return;
1234
+ if ((options.decorators ?? []).length > 0) return;
1235
+ throw new Error("AgentDashboardModule: the AI-gateway console would be served open in production. Say who reaches it, with `decorators: [UseGuards(AuthenticationGuard), Can(ConsolePolicy, 'view')]`, or mount its routes yourself with `routes: false` and extend `AgentApiController` / `AgentUiController` under your own guards.");
1236
+ }
1237
+ __name(assertProtected, "assertProtected");
2245
1238
  var AgentApiModule = class _AgentApiModule {
2246
1239
  static {
2247
1240
  __name(this, "AgentApiModule");
2248
1241
  }
2249
1242
  static register(options) {
2250
- stampGuards(options.guards, [
2251
- [
2252
- AgentApiController,
2253
- API_BASE_GUARDS
2254
- ]
2255
- ]);
2256
1243
  return {
2257
1244
  module: _AgentApiModule,
2258
1245
  imports: [
2259
1246
  ...options.imports ?? []
2260
1247
  ],
2261
- controllers: [
1248
+ controllers: options.routes === false ? [] : (0, import_nestjs_agent_core3.withControllerDecorators)([
2262
1249
  AgentApiController
2263
- ],
1250
+ ], options.decorators),
2264
1251
  providers: [
2265
1252
  DashboardService,
2266
- DashboardAuthGuard,
2267
- options.dashboardAuth,
2268
- ...(options.guards ?? []).filter(isGuardClass),
2269
1253
  // `useValue` even when `options.approvalActorRef` is `undefined` — AgentApiController
2270
1254
  // injects this WITHOUT `@Optional()`.
2271
1255
  {
@@ -2273,134 +1257,60 @@ var AgentApiModule = class _AgentApiModule {
2273
1257
  useValue: options.approvalActorRef
2274
1258
  }
2275
1259
  ],
2276
- // DASHBOARD_AUTH re-exported so AgentUiController/AgentDashboardAuthController (hosted
2277
- // directly by AgentDashboardModule, which imports this module) resolve the SAME instance
2278
- // instead of re-running a host's async factory a second time.
1260
+ // What a self-mounted `AgentApiController` subclass injects, too (`routes: false`).
2279
1261
  exports: [
2280
1262
  DashboardService,
2281
- DASHBOARD_AUTH
1263
+ DASHBOARD_APPROVAL_ACTOR_REF
2282
1264
  ]
2283
1265
  };
2284
1266
  }
2285
1267
  };
2286
- AgentApiModule = _ts_decorate8([
2287
- (0, import_common11.Module)({})
1268
+ AgentApiModule = _ts_decorate4([
1269
+ (0, import_common7.Module)({})
2288
1270
  ], AgentApiModule);
2289
1271
  var AgentDashboardModule = class _AgentDashboardModule {
2290
1272
  static {
2291
1273
  __name(this, "AgentDashboardModule");
2292
1274
  }
2293
1275
  static forRoot(options = {}) {
1276
+ assertProtected(options);
2294
1277
  const basePath = normalize(options.basePath ?? "/ai-gateway");
2295
1278
  const apiBasePath = normalize(options.apiBasePath ?? `${basePath}/api`);
2296
- stampGuards(options.guards, [
2297
- [
2298
- AgentUiController,
2299
- UI_BASE_GUARDS
2300
- ]
2301
- ]);
2302
- const dashboardAuthProvider = {
2303
- provide: DASHBOARD_AUTH,
2304
- useValue: resolveDashboardAuth(options.dashboardAuth)
2305
- };
2306
1279
  return {
2307
1280
  module: _AgentDashboardModule,
2308
1281
  imports: [
2309
1282
  ...options.imports ?? [],
2310
- // Guards + host imports must reach the API controller's HOST module — enhancers resolve
2311
- // from their controller's own module, never from a parent (see AgentApiModule.register).
2312
1283
  // Spread-only-when-set: exactOptionalPropertyTypes rejects an explicit `undefined`.
2313
1284
  AgentApiModule.register({
2314
1285
  ...options.imports ? {
2315
1286
  imports: options.imports
2316
1287
  } : {},
2317
- ...options.guards ? {
2318
- guards: options.guards
1288
+ ...options.decorators ? {
1289
+ decorators: options.decorators
2319
1290
  } : {},
2320
- ...options.approvalActorRef ? {
2321
- approvalActorRef: options.approvalActorRef
2322
- } : {},
2323
- dashboardAuth: dashboardAuthProvider
2324
- }),
2325
- import_core.RouterModule.register([
2326
- {
2327
- path: basePath,
2328
- module: _AgentDashboardModule
2329
- },
2330
- {
2331
- path: apiBasePath,
2332
- module: AgentApiModule
2333
- }
2334
- ])
2335
- ],
2336
- controllers: [
2337
- AgentUiController,
2338
- AgentDashboardAuthController
2339
- ],
2340
- providers: [
2341
- {
2342
- provide: DASHBOARD_BASE_PATH,
2343
- useValue: basePath
2344
- },
2345
- {
2346
- provide: DASHBOARD_API_PATH,
2347
- useValue: apiBasePath
2348
- },
2349
- DashboardAuthPageGuard,
2350
- // AgentUiController is hosted HERE, so its guards DI-instantiate from this module.
2351
- ...(options.guards ?? []).filter(isGuardClass)
2352
- ],
2353
- // Re-export the API module so its DashboardService reaches importers (e.g. the host's own controllers).
2354
- exports: [
2355
- AgentApiModule
2356
- ]
2357
- };
2358
- }
2359
- static forRootAsync(options) {
2360
- const basePath = normalize(options.basePath ?? "/ai-gateway");
2361
- const apiBasePath = normalize(options.apiBasePath ?? `${basePath}/api`);
2362
- stampGuards(options.guards, [
2363
- [
2364
- AgentUiController,
2365
- UI_BASE_GUARDS
2366
- ]
2367
- ]);
2368
- const dashboardAuthProvider = {
2369
- provide: DASHBOARD_AUTH,
2370
- inject: options.inject ?? [],
2371
- useFactory: /* @__PURE__ */ __name(async (...deps) => resolveDashboardAuth(await options.useDashboardAuth(...deps)), "useFactory")
2372
- };
2373
- return {
2374
- module: _AgentDashboardModule,
2375
- imports: [
2376
- ...options.imports ?? [],
2377
- AgentApiModule.register({
2378
- ...options.imports ? {
2379
- imports: options.imports
2380
- } : {},
2381
- ...options.guards ? {
2382
- guards: options.guards
1291
+ ...options.routes === false ? {
1292
+ routes: false
2383
1293
  } : {},
2384
1294
  ...options.approvalActorRef ? {
2385
1295
  approvalActorRef: options.approvalActorRef
2386
- } : {},
2387
- dashboardAuth: dashboardAuthProvider
1296
+ } : {}
2388
1297
  }),
2389
- import_core.RouterModule.register([
2390
- {
2391
- path: basePath,
2392
- module: _AgentDashboardModule
2393
- },
2394
- {
2395
- path: apiBasePath,
2396
- module: AgentApiModule
2397
- }
2398
- ])
2399
- ],
2400
- controllers: [
2401
- AgentUiController,
2402
- AgentDashboardAuthController
1298
+ ...options.routes === false ? [] : [
1299
+ import_core.RouterModule.register([
1300
+ {
1301
+ path: basePath,
1302
+ module: _AgentDashboardModule
1303
+ },
1304
+ {
1305
+ path: apiBasePath,
1306
+ module: AgentApiModule
1307
+ }
1308
+ ])
1309
+ ]
2403
1310
  ],
1311
+ controllers: options.routes === false ? [] : (0, import_nestjs_agent_core3.withControllerDecorators)([
1312
+ AgentUiController
1313
+ ], options.decorators),
2404
1314
  providers: [
2405
1315
  {
2406
1316
  provide: DASHBOARD_BASE_PATH,
@@ -2409,18 +1319,20 @@ var AgentDashboardModule = class _AgentDashboardModule {
2409
1319
  {
2410
1320
  provide: DASHBOARD_API_PATH,
2411
1321
  useValue: apiBasePath
2412
- },
2413
- DashboardAuthPageGuard,
2414
- ...(options.guards ?? []).filter(isGuardClass)
1322
+ }
2415
1323
  ],
1324
+ // Re-export the API module so its DashboardService reaches importers (e.g. the host's own
1325
+ // controllers), and the paths a self-mounted `AgentUiController` subclass injects.
2416
1326
  exports: [
2417
- AgentApiModule
1327
+ AgentApiModule,
1328
+ DASHBOARD_BASE_PATH,
1329
+ DASHBOARD_API_PATH
2418
1330
  ]
2419
1331
  };
2420
1332
  }
2421
1333
  };
2422
- AgentDashboardModule = _ts_decorate8([
2423
- (0, import_common11.Module)({})
1334
+ AgentDashboardModule = _ts_decorate4([
1335
+ (0, import_common7.Module)({})
2424
1336
  ], AgentDashboardModule);
2425
1337
  // Annotate the CommonJS export names for ESM import in node:
2426
1338
  0 && (module.exports = {
@@ -2431,16 +1343,13 @@ AgentDashboardModule = _ts_decorate8([
2431
1343
  AGENT_PRICING_STORE,
2432
1344
  AgentApiController,
2433
1345
  AgentApiModule,
2434
- AgentDashboardAuthController,
2435
1346
  AgentDashboardModule,
2436
1347
  AgentUiController,
2437
1348
  DASHBOARD_API_PATH,
2438
1349
  DASHBOARD_APPROVAL_ACTOR_REF,
2439
- DASHBOARD_AUTH,
2440
1350
  DASHBOARD_BASE_PATH,
2441
1351
  DashboardService,
2442
1352
  agentDashboardMountPaths,
2443
- parsePriceInput,
2444
- resolveDashboardAuth
1353
+ parsePriceInput
2445
1354
  });
2446
1355
  //# sourceMappingURL=index.cjs.map