@sixb/server 0.1.16 → 0.1.18

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 (99) hide show
  1. package/README.md +6 -0
  2. package/dist/auth/experience.d.ts +5 -1
  3. package/dist/auth/experience.d.ts.map +1 -1
  4. package/dist/auth/public-routes.d.ts.map +1 -1
  5. package/dist/auth/shared-access.d.ts.map +1 -1
  6. package/dist/files/content.d.ts +0 -1
  7. package/dist/files/content.d.ts.map +1 -1
  8. package/dist/index.js +603 -456
  9. package/dist/index.js.map +34 -33
  10. package/dist/registerRoutes.d.ts.map +1 -1
  11. package/dist/routes/agents.d.ts +56 -28
  12. package/dist/routes/agents.d.ts.map +1 -1
  13. package/dist/routes/ai-accounting.d.ts.map +1 -1
  14. package/dist/routes/auth.d.ts +4 -3
  15. package/dist/routes/auth.d.ts.map +1 -1
  16. package/dist/routes/datasets.d.ts +4 -1
  17. package/dist/routes/datasets.d.ts.map +1 -1
  18. package/dist/routes/file-downloads.d.ts +98 -0
  19. package/dist/routes/file-downloads.d.ts.map +1 -0
  20. package/dist/routes/files.d.ts.map +1 -1
  21. package/dist/routes/models.d.ts +1 -0
  22. package/dist/routes/models.d.ts.map +1 -1
  23. package/dist/routes/objects.d.ts +24 -4
  24. package/dist/routes/objects.d.ts.map +1 -1
  25. package/dist/routes/ontology.d.ts +4 -4
  26. package/dist/routes/project.d.ts +2 -0
  27. package/dist/routes/project.d.ts.map +1 -1
  28. package/dist/routes/status.d.ts +0 -4
  29. package/dist/routes/status.d.ts.map +1 -1
  30. package/dist/routes/workflows.d.ts +6 -0
  31. package/dist/routes/workflows.d.ts.map +1 -1
  32. package/dist/routes/ws/events.d.ts.map +1 -1
  33. package/dist/routes/ws/logs.d.ts +11 -0
  34. package/dist/routes/ws/logs.d.ts.map +1 -1
  35. package/dist/routes/ws/subscription-hub.d.ts +71 -0
  36. package/dist/routes/ws/subscription-hub.d.ts.map +1 -0
  37. package/dist/schemas/agents.d.ts +255 -123
  38. package/dist/schemas/agents.d.ts.map +1 -1
  39. package/dist/schemas/ai-accounting.d.ts +234 -110
  40. package/dist/schemas/ai-accounting.d.ts.map +1 -1
  41. package/dist/schemas/ai-usage.d.ts +3 -0
  42. package/dist/schemas/ai-usage.d.ts.map +1 -1
  43. package/dist/schemas/auth.d.ts +9 -2
  44. package/dist/schemas/auth.d.ts.map +1 -1
  45. package/dist/schemas/common.d.ts +8 -0
  46. package/dist/schemas/common.d.ts.map +1 -1
  47. package/dist/schemas/datasets.d.ts +18 -3
  48. package/dist/schemas/datasets.d.ts.map +1 -1
  49. package/dist/schemas/event-payloads.d.ts +39 -0
  50. package/dist/schemas/event-payloads.d.ts.map +1 -1
  51. package/dist/schemas/files.d.ts +1 -1
  52. package/dist/schemas/files.d.ts.map +1 -1
  53. package/dist/schemas/models.d.ts +10 -0
  54. package/dist/schemas/models.d.ts.map +1 -1
  55. package/dist/schemas/objects.d.ts +32 -0
  56. package/dist/schemas/objects.d.ts.map +1 -1
  57. package/dist/schemas/ontology.d.ts +18 -18
  58. package/dist/schemas/project.d.ts +8 -0
  59. package/dist/schemas/project.d.ts.map +1 -1
  60. package/dist/schemas/status.d.ts +0 -26
  61. package/dist/schemas/status.d.ts.map +1 -1
  62. package/dist/schemas/workflows.d.ts +52 -0
  63. package/dist/schemas/workflows.d.ts.map +1 -1
  64. package/dist/server.d.ts.map +1 -1
  65. package/package.json +6 -5
  66. package/src/auth/experience.ts +20 -2
  67. package/src/auth/public-routes.ts +10 -0
  68. package/src/auth/shared-access.ts +48 -6
  69. package/src/files/content.ts +43 -88
  70. package/src/registerRoutes.ts +2 -0
  71. package/src/routes/agents.ts +29 -9
  72. package/src/routes/ai-accounting.ts +1 -0
  73. package/src/routes/auth.ts +84 -19
  74. package/src/routes/datasets.ts +12 -43
  75. package/src/routes/file-downloads.ts +48 -0
  76. package/src/routes/files.ts +3 -1
  77. package/src/routes/models.ts +3 -0
  78. package/src/routes/objects.ts +25 -5
  79. package/src/routes/project.ts +2 -1
  80. package/src/routes/workflows.ts +5 -0
  81. package/src/routes/ws/events.ts +98 -133
  82. package/src/routes/ws/logs.ts +67 -5
  83. package/src/routes/ws/subscription-hub.ts +394 -0
  84. package/src/schemas/agents.ts +28 -3
  85. package/src/schemas/ai-accounting.ts +5 -0
  86. package/src/schemas/ai-usage.ts +3 -0
  87. package/src/schemas/auth.ts +5 -0
  88. package/src/schemas/common.ts +3 -0
  89. package/src/schemas/datasets.ts +23 -1
  90. package/src/schemas/event-payloads.ts +3 -1
  91. package/src/schemas/files.ts +7 -1
  92. package/src/schemas/models.ts +2 -0
  93. package/src/schemas/objects.ts +41 -2
  94. package/src/schemas/project.ts +4 -0
  95. package/src/schemas/status.ts +0 -6
  96. package/src/server.ts +7 -1
  97. package/dist/routes/ws/log-subscription-hub.d.ts +0 -50
  98. package/dist/routes/ws/log-subscription-hub.d.ts.map +0 -1
  99. package/src/routes/ws/log-subscription-hub.ts +0 -369
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { cors } from "@elysiajs/cors";
4
4
  import { openapi } from "@elysiajs/openapi";
5
5
  import { CSRF_HEADER_NAME as CSRF_HEADER_NAME2, setRequestClientAddress } from "@sixb/core/internal/auth";
6
6
  import { bindRequestExecution } from "@sixb/core/internal/request-execution";
7
+ import { setApiPublicOrigin } from "@sixb/core/internal/runtime";
7
8
  import { Elysia } from "elysia";
8
9
  import { websocket as elysiaWebSocket } from "elysia/ws";
9
10
  import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
@@ -317,11 +318,13 @@ function isSessionTerminationRequest(request) {
317
318
 
318
319
  // src/auth/shared-access.ts
319
320
  var SHARED_ACCESS_GRANT_HEADER_NAME = "x-sixb-share-grant";
321
+ var SHARED_ACCESS_GRANT_QUERY_PARAM = "shareGrant";
320
322
  var SHARED_SESSION_COOKIE_PREFIX = "sixb_share_session_";
321
323
  var SHARED_CSRF_COOKIE_PREFIX = "sixb_share_csrf_";
322
324
  var SHARED_COOKIE_PATH = "/api";
323
325
  var STORED_IDENTIFIER_MAX_LENGTH = 128;
324
326
  var SHARED_SESSION_ROUTES = SIXB_API_ROUTES2.filter((route) => route.sharedSession);
327
+ var SHARED_FILE_CONTENT_ROUTES = SHARED_SESSION_ROUTES.filter((route) => (route.method === "GET" || route.method === "HEAD") && route.path.endsWith("/files/content"));
325
328
 
326
329
  class SharedAccessBoundary {
327
330
  host;
@@ -334,24 +337,28 @@ class SharedAccessBoundary {
334
337
  preflightResponse(request) {
335
338
  if (isSharedAccessPublicRoute(request))
336
339
  return;
337
- const selectedGrantId = request.headers.get(SHARED_ACCESS_GRANT_HEADER_NAME);
338
- if (selectedGrantId === null)
340
+ const selection = selectSharedAccessGrant(request);
341
+ if (selection.kind === "absent")
339
342
  return;
340
- if (request.headers.has("authorization") || !isSharedSessionRoute(request)) {
343
+ if (selection.kind === "conflict" || request.headers.has("authorization") || !isSharedSessionRoute(request)) {
341
344
  return sharedAccessForbiddenResponse();
342
345
  }
343
- if (!isStoredIdentifier(selectedGrantId))
346
+ if (!isStoredIdentifier(selection.grantId))
344
347
  return sharedAccessUnauthenticatedResponse();
345
348
  }
346
349
  async resolveRequest(request) {
347
350
  if (isSharedAccessPublicRoute(request))
348
351
  return { kind: "absent" };
349
- const selectedGrantId = request.headers.get(SHARED_ACCESS_GRANT_HEADER_NAME);
350
- if (selectedGrantId === null)
352
+ const selection = selectSharedAccessGrant(request);
353
+ if (selection.kind === "absent")
351
354
  return { kind: "absent" };
355
+ if (selection.kind === "conflict") {
356
+ return { kind: "deny", response: sharedAccessForbiddenResponse() };
357
+ }
352
358
  const preflight = this.preflightResponse(request);
353
359
  if (preflight)
354
360
  return { kind: "deny", response: preflight };
361
+ const selectedGrantId = selection.grantId;
355
362
  let resolved;
356
363
  try {
357
364
  resolved = await this.resolveSession(request, selectedGrantId);
@@ -510,6 +517,20 @@ function isSharedAccessPublicPath(pathname, requestMethod) {
510
517
  return false;
511
518
  return matchesPathPattern2(normalizedPathname, `/api/shared-access/:grantId/${suffix}`);
512
519
  }
520
+ function selectSharedAccessGrant(request) {
521
+ const header = request.headers.get(SHARED_ACCESS_GRANT_HEADER_NAME);
522
+ const url = new URL(request.url);
523
+ const method = request.method.toUpperCase();
524
+ const pathname = normalizeRoutePath2(url.pathname);
525
+ const queryValues = SHARED_FILE_CONTENT_ROUTES.some((route) => route.method === method && matchesPathPattern2(pathname, route.path)) ? url.searchParams.getAll(SHARED_ACCESS_GRANT_QUERY_PARAM) : [];
526
+ const [query, ...extra] = queryValues;
527
+ if (query === undefined) {
528
+ return header === null ? { kind: "absent" } : { kind: "selected", grantId: header };
529
+ }
530
+ if (extra.length > 0 || header !== null && header !== query)
531
+ return { kind: "conflict" };
532
+ return { kind: "selected", grantId: query };
533
+ }
513
534
  function isSharedSessionRoute(request) {
514
535
  const method = request.method.toUpperCase();
515
536
  const pathname = normalizeRoutePath2(new URL(request.url).pathname);
@@ -664,6 +685,7 @@ function sessionCanAccessApplication(host, session, audience) {
664
685
  // src/auth/public-routes.ts
665
686
  import { AGENT_API_GATEWAY_PREFIX } from "@sixb/core/internal/agents";
666
687
  import { isCsrfExemptMethod as isCsrfExemptMethod3 } from "@sixb/core/internal/auth";
688
+ import { FILE_DOWNLOAD_ROUTE_PREFIX } from "@sixb/core/internal/blob-storage";
667
689
  var CONNECTOR_OAUTH_CALLBACK_PATH = "/auth/connectors/callback";
668
690
  function classifyRoute(request) {
669
691
  const url = new URL(request.url);
@@ -702,6 +724,9 @@ function isPublicRoute(pathname, method) {
702
724
  if (pathname.startsWith(`${AGENT_API_GATEWAY_PREFIX}/`)) {
703
725
  return true;
704
726
  }
727
+ if (pathname.startsWith(FILE_DOWNLOAD_ROUTE_PREFIX) && (normalizedMethod === "GET" || normalizedMethod === "HEAD")) {
728
+ return true;
729
+ }
705
730
  if (pathname.startsWith("/api/webhooks/") && normalizedMethod === "POST") {
706
731
  return true;
707
732
  }
@@ -1145,8 +1170,13 @@ import { z as z5 } from "zod";
1145
1170
 
1146
1171
  // src/files/content.ts
1147
1172
  import { createHash as createHash2 } from "crypto";
1148
- import { isFileRef } from "@sixb/core";
1173
+ import { fileNameFor } from "@sixb/core";
1149
1174
  import { BlobStorageError, supportsRangeRead } from "@sixb/core/blob-storage/server";
1175
+ import {
1176
+ canonicalMediaType,
1177
+ resolveFileRefAtPath,
1178
+ statFileRef
1179
+ } from "@sixb/core/internal/blob-storage";
1150
1180
  import { ZodError } from "zod";
1151
1181
  var unconfiguredStorageResponse = {
1152
1182
  501: {
@@ -1241,8 +1271,8 @@ function fileContentHeadResponses(options = {}) {
1241
1271
  };
1242
1272
  }
1243
1273
  async function createFileContentResponse(input) {
1244
- const stat = await input.blobStorage.stat(input.fileRef.blobId);
1245
- if (!stat || !blobMatchesFileRef(stat, input.fileRef)) {
1274
+ const stat = await statFileRef(input.blobStorage, input.fileRef);
1275
+ if (!stat) {
1246
1276
  return null;
1247
1277
  }
1248
1278
  const canReadRange = supportsRangeRead(input.blobStorage);
@@ -1321,58 +1351,36 @@ async function createContextualFileContentResponse(input) {
1321
1351
  throw error;
1322
1352
  }
1323
1353
  }
1324
- function resolveFileRefAtPath(root, path) {
1325
- const value = resolveJsonPointer(root, path);
1326
- return isFileRef(value) ? value : null;
1327
- }
1328
1354
  function fileContentNotFound(set, message) {
1329
1355
  set.status = 404;
1330
1356
  return { error: message };
1331
1357
  }
1332
- function blobMatchesFileRef(stat, fileRef) {
1333
- return stat.blobId === fileRef.blobId && stat.digest === fileRef.digest && stat.sizeBytes === fileRef.sizeBytes;
1334
- }
1335
1358
  function matchesIfNoneMatch(header, etag) {
1336
1359
  return header?.trim() === "*" || (header?.split(",").some((value) => value.trim().replace(/^W\//, "") === etag) ?? false);
1337
1360
  }
1338
- function resolveJsonPointer(root, pointer) {
1339
- if (pointer === "") {
1340
- return root;
1341
- }
1342
- if (!pointer.startsWith("/")) {
1343
- return;
1344
- }
1345
- let current = root;
1346
- for (const rawSegment of pointer.slice(1).split("/")) {
1347
- const segment = decodeJsonPointerSegment(rawSegment);
1348
- if (Array.isArray(current)) {
1349
- const index = Number.parseInt(segment, 10);
1350
- if (!Number.isInteger(index) || index < 0 || index.toString() !== segment) {
1351
- return;
1352
- }
1353
- if (!Object.hasOwn(current, segment)) {
1354
- return;
1355
- }
1356
- current = current[index];
1357
- continue;
1358
- }
1359
- if (typeof current !== "object" || current === null || !Object.hasOwn(current, segment)) {
1360
- return;
1361
- }
1362
- current = current[segment];
1363
- }
1364
- return current;
1365
- }
1366
- function decodeJsonPointerSegment(segment) {
1367
- return segment.replaceAll("~1", "/").replaceAll("~0", "~");
1368
- }
1361
+ var INLINE_MEDIA_TYPES = new Set([
1362
+ "application/json",
1363
+ "application/pdf",
1364
+ "image/avif",
1365
+ "image/bmp",
1366
+ "image/gif",
1367
+ "image/jpeg",
1368
+ "image/png",
1369
+ "image/webp",
1370
+ "text/markdown",
1371
+ "text/plain"
1372
+ ]);
1373
+ var FILE_CONTENT_SECURITY_POLICY = "default-src 'none'; style-src 'unsafe-inline'; sandbox";
1374
+ var PDF_CONTENT_SECURITY_POLICY = "default-src 'none'; style-src 'unsafe-inline'; object-src 'self'";
1369
1375
  function fileContentHeaders(fileRef, stat, requestedDisposition, canReadRange) {
1370
- const mediaType = fileRef.mediaType?.trim() || "application/octet-stream";
1371
- const disposition = (requestedDisposition ?? "inline") === "inline" && canRenderInline(mediaType) ? "inline" : "attachment";
1376
+ const mediaType = canonicalMediaType(fileRef.mediaType) ?? "application/octet-stream";
1377
+ const baseType = mediaType.split(";", 1)[0];
1378
+ const disposition = (requestedDisposition ?? "inline") === "inline" && INLINE_MEDIA_TYPES.has(baseType) ? "inline" : "attachment";
1372
1379
  const headers = new Headers;
1373
1380
  headers.set("content-type", mediaType);
1374
1381
  headers.set("content-length", stat.sizeBytes.toString());
1375
1382
  headers.set("content-disposition", contentDispositionHeader(disposition, fileNameFor(fileRef)));
1383
+ headers.set("content-security-policy", baseType === "application/pdf" ? PDF_CONTENT_SECURITY_POLICY : FILE_CONTENT_SECURITY_POLICY);
1376
1384
  const representation = JSON.stringify([
1377
1385
  fileRef.digest,
1378
1386
  mediaType,
@@ -1438,24 +1446,6 @@ function rangeNotSatisfiableResponse(sizeBytes) {
1438
1446
  headers.set("content-range", `bytes */${sizeBytes}`);
1439
1447
  return new Response(null, { status: 416, headers });
1440
1448
  }
1441
- function canRenderInline(mediaType) {
1442
- const baseType = mediaType.split(";")[0]?.trim().toLowerCase();
1443
- if (!baseType) {
1444
- return false;
1445
- }
1446
- if (baseType === "text/html" || baseType === "image/svg+xml" || baseType === "application/xhtml+xml") {
1447
- return false;
1448
- }
1449
- return baseType === "application/pdf" || baseType === "text/plain" || baseType === "text/markdown" || baseType === "application/json" || baseType.startsWith("image/");
1450
- }
1451
- function fileNameFor(fileRef) {
1452
- const fromFileName = fileRef.fileName?.split(/[\\/]/).filter(Boolean).at(-1);
1453
- if (fromFileName) {
1454
- return fromFileName;
1455
- }
1456
- const fromLogicalPath = fileRef.logicalPath?.split(/[\\/]/).filter(Boolean).at(-1);
1457
- return fromLogicalPath || `${fileRef.blobId}.bin`;
1458
- }
1459
1449
  function contentDispositionHeader(disposition, fileName) {
1460
1450
  const asciiFileName = fileName.replace(/[^\x20-\x7e]/g, "_").replaceAll('"', "'");
1461
1451
  return `${disposition}; filename="${asciiFileName}"; filename*=UTF-8''${encodeURIComponent(fileName)}`;
@@ -1478,6 +1468,7 @@ function codedErrorResponseSchema(codes) {
1478
1468
  code: z.enum(codes).describe("Stable machine-readable failure code for programmatic handling.")
1479
1469
  });
1480
1470
  }
1471
+ var RedactionsSchema = z.record(z.object({ reason: z.literal("missing_clearance") }));
1481
1472
  var SuccessResponseSchema = z.object({ success: z.boolean() });
1482
1473
  var PrincipalSchema = z.object({
1483
1474
  type: z.enum(["user", "serviceAccount", "system"]),
@@ -1743,6 +1734,7 @@ var ActionRunListResponseSchema = z3.object({
1743
1734
  });
1744
1735
 
1745
1736
  // src/schemas/files.ts
1737
+ import { canonicalMediaType as canonicalMediaType2 } from "@sixb/core/internal/blob-storage";
1746
1738
  import { z as z4 } from "zod";
1747
1739
  var BlobDigestSchema = z4.string().regex(/^sha256:[a-f0-9]{64}$/);
1748
1740
  var FileRefSchema = z4.object({
@@ -1755,7 +1747,9 @@ var FileRefSchema = z4.object({
1755
1747
  });
1756
1748
  var CreateFileUploadBodySchema = z4.object({
1757
1749
  fileName: z4.string().optional(),
1758
- mediaType: z4.string().optional(),
1750
+ mediaType: z4.string().refine((value) => canonicalMediaType2(value) !== null, {
1751
+ message: 'Expected a single media type, such as "application/pdf"'
1752
+ }).optional(),
1759
1753
  sizeBytes: z4.number().int().nonnegative().optional(),
1760
1754
  digest: BlobDigestSchema.optional(),
1761
1755
  logicalPath: z4.string().optional()
@@ -2251,6 +2245,7 @@ import {
2251
2245
  SYSTEM_PRINCIPAL
2252
2246
  } from "@sixb/core";
2253
2247
  import { computeBlobDigest, supportsDirectUpload } from "@sixb/core/blob-storage/server";
2248
+ import { canonicalMediaType as canonicalMediaType3 } from "@sixb/core/internal/blob-storage";
2254
2249
  import { createFileUploadId, createUploadExpiresAt } from "@sixb/core/internal/storage";
2255
2250
  import { FileUploadSessionError as FileUploadSessionError2 } from "@sixb/core/storage";
2256
2251
  var DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES = DEFAULT_SIMPLE_FILE_UPLOAD_BYTES + 1024 * 1024;
@@ -2283,7 +2278,7 @@ function registerFileRoutes(app, host) {
2283
2278
  const fileRef = await host.blobStorage.put({
2284
2279
  body: file,
2285
2280
  fileName: file.name || undefined,
2286
- mediaType: file.type || undefined,
2281
+ mediaType: canonicalMediaType3(file.type) ?? undefined,
2287
2282
  logicalPath: logicalPath ?? undefined
2288
2283
  });
2289
2284
  return FileRefSchema.parse(fileRef);
@@ -3006,9 +3001,16 @@ class PayloadTooLargeError extends Error {
3006
3001
  }
3007
3002
 
3008
3003
  // src/routes/agents.ts
3009
- import { AgentRequestError } from "@sixb/core";
3010
- import { publishAgentRunCancel, publishAgentRunFinished } from "@sixb/core/internal/agents";
3004
+ import {
3005
+ AgentRequestError
3006
+ } from "@sixb/core";
3007
+ import {
3008
+ isRetryableAgentRun,
3009
+ publishAgentRunCancel,
3010
+ publishAgentRunFinished
3011
+ } from "@sixb/core/internal/agents";
3011
3012
  import { agentRunStreamId } from "@sixb/core/internal/agents/streams";
3013
+ import { resolveFileRefAtPath as resolveFileRefAtPath2 } from "@sixb/core/internal/blob-storage";
3012
3014
  import {
3013
3015
  AgentStorageError
3014
3016
  } from "@sixb/core/storage";
@@ -3016,6 +3018,7 @@ import { ZodError as ZodError2, z as z10 } from "zod";
3016
3018
 
3017
3019
  // src/schemas/agents.ts
3018
3020
  import { MAX_AGENT_CONTEXT_ENTRIES } from "@sixb/core";
3021
+ import { MAX_AGENT_CONTEXT_LABEL_LENGTH } from "@sixb/core/agents/context";
3019
3022
  import {
3020
3023
  AGENT_RUN_DIAGNOSTIC_CODES,
3021
3024
  AGENT_RUN_FAILURE_CODES,
@@ -3038,6 +3041,7 @@ var AiUsageSummarySchema = z6.object({
3038
3041
  cacheWriteInputTokens: TokenCountSchema.optional(),
3039
3042
  textOutputTokens: TokenCountSchema.optional(),
3040
3043
  reasoningOutputTokens: TokenCountSchema.optional(),
3044
+ audioDurationMs: TokenCountSchema.optional().describe("Audio content duration in milliseconds; not billed duration."),
3041
3045
  reportingStatus: z6.enum(["complete", "partial", "unavailable"])
3042
3046
  });
3043
3047
 
@@ -3066,7 +3070,8 @@ var LanguageModelSchema = LanguageModelRefSchema.extend({
3066
3070
  structuredOutput: z7.boolean().optional(),
3067
3071
  contextWindowTokens: z7.number().int().positive().optional()
3068
3072
  }),
3069
- reasoningLevels: z7.array(z7.enum(MODEL_REASONING_LEVELS))
3073
+ reasoningLevels: z7.array(z7.enum(MODEL_REASONING_LEVELS)),
3074
+ defaultReasoning: z7.enum(MODEL_REASONING_LEVELS).optional()
3070
3075
  });
3071
3076
  var ModelCatalogSchema = z7.object({
3072
3077
  language: z7.array(LanguageModelSchema)
@@ -3120,7 +3125,8 @@ var AiAccountingAggregateSchema = z8.object({
3120
3125
  cacheReadInputTokens: z8.number().int().nonnegative(),
3121
3126
  cacheWriteInputTokens: z8.number().int().nonnegative(),
3122
3127
  textOutputTokens: z8.number().int().nonnegative(),
3123
- reasoningOutputTokens: z8.number().int().nonnegative()
3128
+ reasoningOutputTokens: z8.number().int().nonnegative(),
3129
+ audioDurationMs: z8.number().int().nonnegative()
3124
3130
  })
3125
3131
  }),
3126
3132
  costs: AiCostSummarySchema
@@ -3171,7 +3177,8 @@ var AiCostComponentSchema = z8.object({
3171
3177
  "tokens.input.cacheWrite1h",
3172
3178
  "tokens.output.total",
3173
3179
  "tokens.output.text",
3174
- "tokens.output.reasoning"
3180
+ "tokens.output.reasoning",
3181
+ "audio.input.milliseconds"
3175
3182
  ]),
3176
3183
  quantity: IntegerStringSchema,
3177
3184
  rateAmountNanosPerMillion: IntegerStringSchema,
@@ -3239,6 +3246,7 @@ var AiModelCallUsageRecordSchema = z8.object({
3239
3246
  callId: z8.string(),
3240
3247
  providerId: z8.string(),
3241
3248
  requestedModelId: z8.string(),
3249
+ modelKind: z8.enum(["language", "image", "video", "embedding", "decision", "transcription", "reranking"]).optional(),
3242
3250
  requestedReasoning: ModelReasoningSchema.optional(),
3243
3251
  responseModelId: z8.string().optional(),
3244
3252
  responseId: z8.string(),
@@ -3330,7 +3338,8 @@ var AgentObjectContextSchema = z9.object({
3330
3338
  ref: z9.object({
3331
3339
  objectTypeId: z9.string().min(1),
3332
3340
  primaryId: z9.string().min(1)
3333
- })
3341
+ }),
3342
+ label: z9.string().min(1).max(MAX_AGENT_CONTEXT_LABEL_LENGTH).optional().describe("Shown in the chat instead of the object's title. Never sent to the model.")
3334
3343
  });
3335
3344
  var AgentAppStateContextSchema = z9.object({
3336
3345
  kind: z9.literal("app-state"),
@@ -3434,8 +3443,12 @@ var AgentToolCallErrorSchema = AgentToolCallBaseSchema.extend({
3434
3443
  state: z9.literal("output-error"),
3435
3444
  errorText: z9.string()
3436
3445
  });
3446
+ var AgentContinuationPartSchema = z9.object({
3447
+ type: z9.literal("continuation")
3448
+ });
3437
3449
  var AgentMessagePartSchema = z9.union([
3438
3450
  AgentTextPartSchema,
3451
+ AgentContinuationPartSchema,
3439
3452
  AgentReasoningPartSchema,
3440
3453
  AgentStepStartPartSchema,
3441
3454
  AgentFilePartSchema,
@@ -3447,7 +3460,7 @@ var AgentMessagePartSchema = z9.union([
3447
3460
  var AgentRunDiagnosticSchema = z9.object({
3448
3461
  code: z9.enum(AGENT_RUN_DIAGNOSTIC_CODES),
3449
3462
  severity: z9.enum(["warning", "error"]),
3450
- scope: z9.literal("output"),
3463
+ scope: z9.enum(["output", "run"]),
3451
3464
  path: z9.string().optional(),
3452
3465
  message: z9.string()
3453
3466
  });
@@ -3484,13 +3497,19 @@ var AgentMessageListResponseSchema = z9.object({
3484
3497
  total: z9.number()
3485
3498
  });
3486
3499
  var PostAgentMessageBodySchema = z9.object({
3487
- text: z9.string().trim().min(1),
3500
+ text: z9.string().trim().min(1).optional(),
3501
+ continue: z9.literal(true).optional(),
3488
3502
  model: LanguageModelRefSchema.optional(),
3489
3503
  reasoning: ModelReasoningSchema.optional(),
3504
+ timeZone: z9.string().trim().min(1).max(100).optional(),
3505
+ locale: z9.string().trim().min(1).max(100).optional(),
3490
3506
  attachments: z9.array(FileRefSchema).optional(),
3491
3507
  context: z9.array(AgentContextEntryInputSchema).max(MAX_AGENT_CONTEXT_ENTRIES).optional(),
3492
3508
  messageId: z9.string().trim().min(1).optional()
3493
3509
  }).strict();
3510
+ var AgentRequestErrorResponseSchema = ErrorResponseSchema.extend({
3511
+ code: z9.string().optional()
3512
+ });
3494
3513
  var CancelAgentRunBodySchema = z9.object({
3495
3514
  runId: z9.string().trim().min(1)
3496
3515
  });
@@ -3662,12 +3681,15 @@ function handleAgentRouteError(error, set) {
3662
3681
  case "invalid_sandbox_params":
3663
3682
  case "agent_selector_removed":
3664
3683
  case "invalid_context":
3684
+ case "invalid_attachment":
3665
3685
  case "invalid_model_selection":
3686
+ case "invalid_locale":
3687
+ case "invalid_message":
3666
3688
  case "model_not_found":
3667
3689
  set.status = 400;
3668
3690
  break;
3669
3691
  }
3670
- return { error: error.message };
3692
+ return { error: error.message, code: error.code };
3671
3693
  }
3672
3694
  return handleRouteError(error, set);
3673
3695
  }
@@ -3700,7 +3722,7 @@ async function agentMessageFileContentResponse(host, context, options = {}) {
3700
3722
  context.set.status = 404;
3701
3723
  return { error: "File not found" };
3702
3724
  }
3703
- const fileRef = resolveFileRefAtPath(serializeMessage(message), parsed.path);
3725
+ const fileRef = resolveFileRefAtPath2(serializeMessage(message), parsed.path);
3704
3726
  if (!fileRef) {
3705
3727
  context.set.status = 404;
3706
3728
  return { error: "File not found" };
@@ -3957,8 +3979,11 @@ function registerAgentRoutes(app, host) {
3957
3979
  const requestInput = {
3958
3980
  threadId: thread.id,
3959
3981
  text: parsed.text,
3982
+ continue: parsed.continue,
3960
3983
  model: parsed.model,
3961
3984
  reasoning: parsed.reasoning,
3985
+ timeZone: parsed.timeZone,
3986
+ locale: parsed.locale,
3962
3987
  attachments: parsed.attachments,
3963
3988
  context: parsed.context,
3964
3989
  messageId: parsed.messageId
@@ -3976,7 +4001,7 @@ function registerAgentRoutes(app, host) {
3976
4001
  body: PostAgentMessageBodySchema,
3977
4002
  response: {
3978
4003
  202: PostAgentMessageResponseSchema,
3979
- 400: ErrorResponseSchema,
4004
+ 400: AgentRequestErrorResponseSchema,
3980
4005
  403: ErrorResponseSchema,
3981
4006
  404: ErrorResponseSchema,
3982
4007
  409: ErrorResponseSchema,
@@ -4088,9 +4113,9 @@ function registerAgentRoutes(app, host) {
4088
4113
  set.status = 404;
4089
4114
  return { error: "Agent run not found" };
4090
4115
  }
4091
- if (failedRun.status !== "failed") {
4116
+ if (!isRetryableAgentRun(failedRun)) {
4092
4117
  set.status = 409;
4093
- return { error: "Only failed agent runs can be retried" };
4118
+ return { error: "Only failed or interrupted agent runs can be retried" };
4094
4119
  }
4095
4120
  const { run } = await sixb.agent.runs.retry(failedRun.id);
4096
4121
  set.status = 202;
@@ -4111,7 +4136,7 @@ function registerAgentRoutes(app, host) {
4111
4136
  501: ErrorResponseSchema
4112
4137
  },
4113
4138
  detail: {
4114
- summary: "Retry a failed agent run",
4139
+ summary: "Retry a failed or interrupted agent run",
4115
4140
  tags: [OPENAPI_TAGS.agentRuns.name],
4116
4141
  operationId: "retryAgentRun",
4117
4142
  security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT
@@ -4347,6 +4372,7 @@ function serializeModelCall(item) {
4347
4372
  callId: item.usage.callId,
4348
4373
  providerId: item.usage.providerId,
4349
4374
  requestedModelId: item.usage.requestedModelId,
4375
+ modelKind: item.usage.modelKind,
4350
4376
  providerIds: item.usage.providerIds ?? null,
4351
4377
  requestedReasoning: item.usage.requestedReasoning,
4352
4378
  responseModelId: item.usage.responseModelId,
@@ -5432,9 +5458,18 @@ var DatasetVersionParamsSchema = DatasetParamsSchema.extend({
5432
5458
  var DatasetVersionsQuerySchema = z13.object({
5433
5459
  limit: z13.string().optional()
5434
5460
  });
5461
+ var QueryStringListSchema = z13.preprocess(flattenQueryStringList, z13.array(z13.string()));
5462
+ function flattenQueryStringList(value) {
5463
+ if (typeof value !== "string" && !Array.isArray(value))
5464
+ return value;
5465
+ const items = [value].flat(Number.POSITIVE_INFINITY);
5466
+ if (!items.every((item) => typeof item === "string"))
5467
+ return value;
5468
+ return items.flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
5469
+ }
5435
5470
  var DatasetRowsQuerySchema = z13.object({
5436
5471
  versionId: z13.string().optional(),
5437
- columns: z13.string().optional(),
5472
+ columns: QueryStringListSchema.optional(),
5438
5473
  limit: z13.string().optional(),
5439
5474
  offset: z13.string().optional()
5440
5475
  });
@@ -5510,6 +5545,7 @@ var DatasetRowsResponseSchema = z13.object({
5510
5545
  versionId: z13.string(),
5511
5546
  version: DatasetVersionSchema,
5512
5547
  columns: z13.array(z13.string()),
5548
+ redactions: RedactionsSchema.optional(),
5513
5549
  rows: z13.array(z13.record(z13.unknown())),
5514
5550
  count: z13.number(),
5515
5551
  limit: z13.number(),
@@ -5638,22 +5674,6 @@ function datasetVersionNotFound(datasetId, versionId) {
5638
5674
  details: { datasetId, ...versionId === undefined ? {} : { versionId } }
5639
5675
  });
5640
5676
  }
5641
- function parseColumns(value) {
5642
- if (!value)
5643
- return;
5644
- const columns = value.split(",").map((column) => column.trim()).filter(Boolean);
5645
- return columns.length > 0 ? columns : undefined;
5646
- }
5647
- function resolveColumns(version, requested) {
5648
- const available = new Set(version.schema.columns.map((column) => column.name));
5649
- const selected = requested ?? version.schema.columns.map((column) => column.name);
5650
- for (const column of selected) {
5651
- if (!available.has(column)) {
5652
- throw new Error(`Dataset '${version.datasetId}' does not have column '${column}' at version '${version.versionId}'`);
5653
- }
5654
- }
5655
- return selected;
5656
- }
5657
5677
  async function collectRows(rows) {
5658
5678
  const collected = [];
5659
5679
  for await (const row of rows) {
@@ -5759,29 +5779,28 @@ function registerDatasetRoutes(app, host) {
5759
5779
  const { params, query, set } = context;
5760
5780
  const sixb = requireRequestSixb(context);
5761
5781
  try {
5762
- requireDataset(sixb, params.datasetId);
5782
+ const dataset = requireDataset(sixb, params.datasetId);
5763
5783
  const parsed = DatasetRowsQuerySchema.parse(query);
5764
5784
  const limit = parseLimit(parsed.limit, DEFAULT_ROW_LIMIT, MAX_ROW_LIMIT);
5765
5785
  const offset = parseOffset(parsed.offset);
5766
- const version = parsed.versionId ? await host.lakeStorage.getVersion(params.datasetId, parsed.versionId) : await host.lakeStorage.getLatestVersion(params.datasetId);
5767
- if (!version) {
5768
- throw datasetVersionNotFound(params.datasetId, parsed.versionId);
5769
- }
5770
- const requestedColumns = parseColumns(parsed.columns);
5771
- const columns = resolveColumns(version, requestedColumns);
5772
- const rows = await collectRows(host.lakeStorage.readRows({
5773
- datasetId: params.datasetId,
5774
- versionId: version.versionId,
5775
- columns: requestedColumns,
5786
+ const page = await sixb.datasets.readRows(dataset, {
5787
+ versionId: parsed.versionId,
5788
+ columns: parsed.columns?.length ? parsed.columns : undefined,
5776
5789
  limit,
5777
5790
  offset
5778
- }));
5791
+ });
5792
+ if (!page) {
5793
+ throw datasetVersionNotFound(params.datasetId, parsed.versionId);
5794
+ }
5795
+ const { version, columns, redactions } = page;
5796
+ const rows = await collectRows(page.rows);
5779
5797
  const hasMore = version.rowCount === undefined ? rows.length === limit : offset + rows.length < version.rowCount;
5780
5798
  return DatasetRowsResponseSchema.parse({
5781
5799
  datasetId: params.datasetId,
5782
5800
  versionId: version.versionId,
5783
5801
  version: serializeDatasetVersion(version),
5784
5802
  columns: [...columns],
5803
+ ...redactions === undefined ? {} : { redactions },
5785
5804
  rows,
5786
5805
  count: rows.length,
5787
5806
  limit,
@@ -5840,12 +5859,14 @@ var ObjectMutationPayloadSchema = z14.object({
5840
5859
  objectTypeId: z14.string(),
5841
5860
  primaryId: z14.string(),
5842
5861
  properties: z14.record(JsonValueSchema),
5843
- propertyChanges: PropertyChangesSchema
5862
+ propertyChanges: PropertyChangesSchema,
5863
+ redactions: RedactionsSchema.optional()
5844
5864
  });
5845
5865
  var ObjectDeletedPayloadSchema = z14.object({
5846
5866
  objectTypeId: z14.string(),
5847
5867
  primaryId: z14.string(),
5848
- propertyChanges: PropertyChangesSchema
5868
+ propertyChanges: PropertyChangesSchema,
5869
+ redactions: RedactionsSchema.optional()
5849
5870
  });
5850
5871
  var LinkSubjectSchema = z14.object({
5851
5872
  sourceTypeId: z14.string(),
@@ -6021,6 +6042,31 @@ function registerEventRoutes(app, _host) {
6021
6042
  });
6022
6043
  }
6023
6044
 
6045
+ // src/routes/file-downloads.ts
6046
+ import { FILE_DOWNLOAD_ROUTE_PREFIX as FILE_DOWNLOAD_ROUTE_PREFIX2, resolveFileDownload } from "@sixb/core/internal/blob-storage";
6047
+ function registerFileDownloadRoutes(app, host) {
6048
+ const path = `${FILE_DOWNLOAD_ROUTE_PREFIX2}:token`;
6049
+ return app.get(path, (context) => fileDownloadResponse(host, context), { detail: { hide: true } }).head(path, (context) => fileDownloadResponse(host, context, { head: true }), {
6050
+ detail: { hide: true }
6051
+ });
6052
+ }
6053
+ async function fileDownloadResponse(host, { params, request, set }, options = {}) {
6054
+ const fileRef = await resolveFileDownload(host, params.token);
6055
+ const response = fileRef && await createFileContentResponse({
6056
+ blobStorage: host.blobStorage,
6057
+ fileRef,
6058
+ head: options.head,
6059
+ rangeHeader: request.headers.get("range"),
6060
+ ifNoneMatchHeader: request.headers.get("if-none-match"),
6061
+ ifRangeHeader: request.headers.get("if-range")
6062
+ });
6063
+ if (!response) {
6064
+ set.status = 404;
6065
+ return { error: "File not found" };
6066
+ }
6067
+ return response;
6068
+ }
6069
+
6024
6070
  // src/schemas/links.ts
6025
6071
  import { z as z16 } from "zod";
6026
6072
  var LinkSourceParamsSchema = z16.object({
@@ -6301,7 +6347,8 @@ async function serializeLanguageModel(entry, defaultEntry) {
6301
6347
  ...await languageModelDisplay(entry),
6302
6348
  provider: entry.provider,
6303
6349
  modelId: entry.modelId,
6304
- isDefault: entry.provider === defaultEntry.provider && entry.modelId === defaultEntry.modelId
6350
+ isDefault: entry.provider === defaultEntry.provider && entry.modelId === defaultEntry.modelId,
6351
+ ...entry.model.defaultReasoning === undefined ? {} : { defaultReasoning: entry.model.defaultReasoning }
6305
6352
  };
6306
6353
  }
6307
6354
  function registerModelRoutes(app, host) {
@@ -6486,6 +6533,11 @@ var ObjectQuerySchema = z18.lazy(() => z18.discriminatedUnion("kind", [
6486
6533
  profile: z18.string().min(1),
6487
6534
  k: z18.number().int().positive()
6488
6535
  }).strict(),
6536
+ z18.object({
6537
+ kind: z18.literal("rerank"),
6538
+ input: ObjectQuerySchema,
6539
+ model: z18.object({ provider: z18.string().min(1), modelId: z18.string().min(1) }).strict()
6540
+ }).strict(),
6489
6541
  z18.object({
6490
6542
  kind: z18.literal("traverse"),
6491
6543
  input: ObjectQuerySchema,
@@ -6556,6 +6608,7 @@ var TwinObjectSchema = z18.object({
6556
6608
  primaryId: z18.string(),
6557
6609
  objectTypeId: z18.string(),
6558
6610
  properties: z18.record(z18.unknown()),
6611
+ redactions: RedactionsSchema.optional(),
6559
6612
  createdAt: z18.string(),
6560
6613
  updatedAt: z18.string()
6561
6614
  });
@@ -6583,6 +6636,15 @@ var ObjectQueryOpenApiSchemas = {
6583
6636
  error: { type: "string" }
6584
6637
  }
6585
6638
  },
6639
+ Redactions: {
6640
+ type: "object",
6641
+ additionalProperties: {
6642
+ type: "object",
6643
+ required: ["reason"],
6644
+ additionalProperties: false,
6645
+ properties: { reason: { type: "string", enum: ["missing_clearance"] } }
6646
+ }
6647
+ },
6586
6648
  ObjectQueryObject: {
6587
6649
  type: "object",
6588
6650
  required: ["primaryId", "objectTypeId", "properties", "createdAt", "updatedAt"],
@@ -6592,6 +6654,7 @@ var ObjectQueryOpenApiSchemas = {
6592
6654
  primaryId: { type: "string" },
6593
6655
  objectTypeId: { type: "string" },
6594
6656
  properties: { type: "object", additionalProperties: true },
6657
+ redactions: { $ref: "#/components/schemas/Redactions" },
6595
6658
  createdAt: { type: "string" },
6596
6659
  updatedAt: { type: "string" },
6597
6660
  links: {
@@ -6623,7 +6686,7 @@ var ObjectQueryOpenApiSchemas = {
6623
6686
  required: ["mode", "providerIssues", "fallbackIssues", "issues"],
6624
6687
  additionalProperties: false,
6625
6688
  properties: {
6626
- mode: { type: "string", enum: ["pushdown", "fallback", "rejected"] },
6689
+ mode: { type: "string", enum: ["pushdown", "fallback", "pipeline", "rejected"] },
6627
6690
  providerIssues: {
6628
6691
  type: "array",
6629
6692
  items: { $ref: "#/components/schemas/ObjectQueryIssue" }
@@ -6703,9 +6766,10 @@ var ObjectQueryOpenApiSchemas = {
6703
6766
  },
6704
6767
  ObjectQueryFacetsResponse: {
6705
6768
  type: "object",
6706
- required: ["facets", "plan"],
6769
+ required: ["total", "facets", "plan"],
6707
6770
  additionalProperties: false,
6708
6771
  properties: {
6772
+ total: { type: "number" },
6709
6773
  facets: {
6710
6774
  type: "array",
6711
6775
  items: { $ref: "#/components/schemas/ObjectQueryFacetResult" }
@@ -6898,6 +6962,24 @@ var ObjectQueryOpenApiSchemas = {
6898
6962
  k: { type: "integer", minimum: 1 }
6899
6963
  }
6900
6964
  },
6965
+ {
6966
+ type: "object",
6967
+ required: ["kind", "input", "model"],
6968
+ additionalProperties: false,
6969
+ properties: {
6970
+ kind: { type: "string", enum: ["rerank"] },
6971
+ input: objectQueryRef,
6972
+ model: {
6973
+ type: "object",
6974
+ required: ["provider", "modelId"],
6975
+ additionalProperties: false,
6976
+ properties: {
6977
+ provider: { type: "string", minLength: 1 },
6978
+ modelId: { type: "string", minLength: 1 }
6979
+ }
6980
+ }
6981
+ }
6982
+ },
6901
6983
  {
6902
6984
  type: "object",
6903
6985
  required: ["kind", "input", "linkId", "direction"],
@@ -7077,7 +7159,10 @@ var ObjectQueryOpenApiSchemas = {
7077
7159
  };
7078
7160
 
7079
7161
  // src/routes/objects.ts
7080
- var ObjectFileContentQuerySchema = FileContentQuerySchema.extend({
7162
+ var ObjectFileContentRouteQuerySchema = FileContentQuerySchema.extend({
7163
+ shareGrant: z19.string().optional().describe("Share grant selector for elements that cannot send the x-sixb-share-grant header")
7164
+ });
7165
+ var ObjectFileContentQuerySchema = ObjectFileContentRouteQuerySchema.extend({
7081
7166
  path: z19.string().min(1).regex(/^\/properties(?:\/|$)/, "Object file content paths must start with /properties/")
7082
7167
  });
7083
7168
  function serializeObject(row) {
@@ -7086,6 +7171,7 @@ function serializeObject(row) {
7086
7171
  primaryId: row.primaryId,
7087
7172
  objectTypeId: row.objectTypeId,
7088
7173
  properties: row.properties,
7174
+ ...row.redactions === undefined ? {} : { redactions: row.redactions },
7089
7175
  createdAt: toIsoString(row.createdAt),
7090
7176
  updatedAt: toIsoString(row.updatedAt)
7091
7177
  };
@@ -7202,8 +7288,14 @@ async function searchObjects(host, sixb, query, limit) {
7202
7288
  input: { kind: "start", objectTypeId: objectType.id }
7203
7289
  }
7204
7290
  };
7205
- const result = await sixb.objects.executeQuery({ query: objectQuery });
7206
- return result.objects;
7291
+ try {
7292
+ const result = await sixb.objects.executeQuery({ query: objectQuery });
7293
+ return result.objects;
7294
+ } catch (error) {
7295
+ if (error instanceof AuthorizationError3)
7296
+ return [];
7297
+ throw error;
7298
+ }
7207
7299
  }));
7208
7300
  const items = new Map;
7209
7301
  for (const row of [...primaryMatches.objects, ...textMatches.flat()]) {
@@ -7628,6 +7720,7 @@ function registerObjectRoutes(app, host) {
7628
7720
  facets: parsed.facets
7629
7721
  });
7630
7722
  return {
7723
+ total: result.total,
7631
7724
  facets: result.facets,
7632
7725
  plan: serializePlan(result.plan)
7633
7726
  };
@@ -7685,7 +7778,7 @@ function registerObjectRoutes(app, host) {
7685
7778
  }
7686
7779
  }).get("/api/objects/:objectTypeId/:objectId/files/content", (context) => objectFileContentResponse(host, context), {
7687
7780
  params: ObjectParamsSchema,
7688
- query: FileContentQuerySchema,
7781
+ query: ObjectFileContentRouteQuerySchema,
7689
7782
  detail: {
7690
7783
  summary: "Get object file content",
7691
7784
  tags: [OPENAPI_TAGS.objectFiles.name],
@@ -7695,7 +7788,7 @@ function registerObjectRoutes(app, host) {
7695
7788
  }
7696
7789
  }).head("/api/objects/:objectTypeId/:objectId/files/content", (context) => objectFileContentResponse(host, context, { head: true }), {
7697
7790
  params: ObjectParamsSchema,
7698
- query: FileContentQuerySchema,
7791
+ query: ObjectFileContentRouteQuerySchema,
7699
7792
  detail: {
7700
7793
  summary: "Head object file content",
7701
7794
  tags: [OPENAPI_TAGS.objectFiles.name],
@@ -8203,12 +8296,15 @@ function registerPipelineRoutes(app, host) {
8203
8296
  // src/schemas/project.ts
8204
8297
  import { z as z21 } from "zod";
8205
8298
  var ProjectInfoResponseSchema = z21.object({
8206
- id: z21.string()
8299
+ id: z21.string(),
8300
+ locale: z21.string(),
8301
+ timeZone: z21.string()
8207
8302
  });
8208
8303
 
8209
8304
  // src/routes/project.ts
8210
8305
  function registerProjectRoutes(app, host) {
8211
- return app.get("/api/project", async () => ({ id: host.id }), {
8306
+ const project = { id: host.id, locale: host.locale, timeZone: host.timeZone };
8307
+ return app.get("/api/project", async () => project, {
8212
8308
  response: { 200: ProjectInfoResponseSchema },
8213
8309
  detail: {
8214
8310
  summary: "Get current project metadata",
@@ -9138,10 +9234,6 @@ var MaintenanceSummarySchema = z26.object({
9138
9234
  retryingCount: z26.number().int().nonnegative(),
9139
9235
  maxAttempts: z26.number().int().nonnegative()
9140
9236
  }).nullable(),
9141
- terminalSources: z26.object({
9142
- count: z26.number().int().nonnegative(),
9143
- oldestTerminalAt: z26.string().nullable()
9144
- }).nullable(),
9145
9237
  cleanup: z26.object({
9146
9238
  publishedOutboxRowsDeleted: z26.number().int().nonnegative(),
9147
9239
  terminalSourceRowsDeleted: z26.number().int().nonnegative(),
@@ -9724,6 +9816,7 @@ import {
9724
9816
  } from "@sixb/core";
9725
9817
  import { publishAgentRunCancel as publishAgentRunCancel2 } from "@sixb/core/internal/agents";
9726
9818
  import { createSixbError as createSixbError4, toSixbFailure } from "@sixb/core/internal/errors";
9819
+ import { assertValidFileRefs } from "@sixb/core/internal/ontology";
9727
9820
  import {
9728
9821
  snapshotWorkflowInterventionResponse
9729
9822
  } from "@sixb/core/internal/workflows";
@@ -10437,6 +10530,7 @@ function registerWorkflowRoutes(app, host) {
10437
10530
  value: parsedBody.response,
10438
10531
  valueTypesById: host.definitions.ontology.getValueTypesById()
10439
10532
  });
10533
+ assertValidFileRefs(parsedBody.response, `Workflow "${workflow.id}" intervention "${node.intervention.id}" response`);
10440
10534
  const submitted = await storage.submit({
10441
10535
  projectId: host.id,
10442
10536
  id: intervention.id,
@@ -10984,6 +11078,7 @@ function registerHttpRoutes(app, host, options) {
10984
11078
  registerObjectRoutes(app, host);
10985
11079
  registerActionRoutes(app, host);
10986
11080
  registerFileRoutes(app, host);
11081
+ registerFileDownloadRoutes(app, host);
10987
11082
  registerActionRunRoutes(app, host);
10988
11083
  registerAgentRoutes(app, host);
10989
11084
  registerModelRoutes(app, host);
@@ -11046,7 +11141,8 @@ async function customAuthExperienceResponse(options, input) {
11046
11141
  ...input.submission ? { submission: input.submission } : {}
11047
11142
  })).toString("base64url");
11048
11143
  const formAction = ["'self'", ...(input.formActionOrigins ?? []).map(normalizeCspOrigin)].join(" ");
11049
- return new Response(html.replace(AUTH_BOOTSTRAP_PLACEHOLDER, bootstrap), {
11144
+ const page = withDocumentLanguage(html.replace(AUTH_BOOTSTRAP_PLACEHOLDER, bootstrap), options.locale);
11145
+ return new Response(page, {
11050
11146
  status: input.status ?? 200,
11051
11147
  headers: {
11052
11148
  "content-type": "text/html; charset=utf-8",
@@ -11066,6 +11162,9 @@ async function customAuthExperienceResponse(options, input) {
11066
11162
  }
11067
11163
  });
11068
11164
  }
11165
+ function withDocumentLanguage(html, locale) {
11166
+ return html.replace(/<html\b([^>]*)>/i, (_tag, attributes) => `<html${attributes.replace(/\s+lang\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/i, "")} lang="${locale}">`);
11167
+ }
11069
11168
  function normalizeCspOrigin(value) {
11070
11169
  let url;
11071
11170
  try {
@@ -11417,7 +11516,8 @@ var RevokeAuthInvitationResponseSchema = z32.object({
11417
11516
  });
11418
11517
  var AuthSessionResponseSchema = z32.union([
11419
11518
  z32.object({
11420
- authenticated: z32.literal(false)
11519
+ authenticated: z32.literal(false),
11520
+ authEnabled: z32.boolean()
11421
11521
  }),
11422
11522
  z32.object({
11423
11523
  authenticated: z32.literal(true),
@@ -11722,14 +11822,14 @@ function registerAuthRoutes(app, host, options) {
11722
11822
  credentialSource: "any"
11723
11823
  });
11724
11824
  if (!caller.authenticated || caller.credentialSource !== "session") {
11725
- return jsonResponse2({ authenticated: false }, 200);
11825
+ return signedOutSessionResponse(host);
11726
11826
  }
11727
11827
  if (caller.session.bearer) {
11728
11828
  return jsonResponse2(authSessionBody(host, caller, DEFAULT_AUTH_SESSION_AUDIENCE2), 200);
11729
11829
  }
11730
11830
  const session = hasForegroundSessionActivity(request) && sessionCanAccessApplication(host, caller, authOptions.audience) ? await host.auth.getSession(request, { ...authOptions, sessionActivity: "foreground" }) : caller;
11731
11831
  if (!session.authenticated) {
11732
- return jsonResponse2({ authenticated: false }, 200);
11832
+ return signedOutSessionResponse(host);
11733
11833
  }
11734
11834
  const cookieOptions = host.auth.getCookieOptions(authOptions);
11735
11835
  const csrf = resolveSessionCsrfToken({
@@ -11933,7 +12033,7 @@ function registerAuthRoutes(app, host, options) {
11933
12033
  summary: "Create a personal access token",
11934
12034
  tags: [OPENAPI_TAGS.authAccessTokens.name],
11935
12035
  operationId: "createAuthPersonalAccessToken",
11936
- security: accessTokenSecurityRequirement("createAuthPersonalAccessToken")
12036
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT
11937
12037
  }
11938
12038
  }).post("/api/auth/access-tokens/:tokenId/revoke", async ({ params, ...context }) => {
11939
12039
  try {
@@ -12105,7 +12205,7 @@ function registerAuthRoutes(app, host, options) {
12105
12205
  summary: "Create an access token for an auth service account",
12106
12206
  tags: [OPENAPI_TAGS.authServiceAccounts.name],
12107
12207
  operationId: "createAuthServiceAccountAccessToken",
12108
- security: accessTokenSecurityRequirement("createAuthServiceAccountAccessToken")
12208
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT
12109
12209
  }
12110
12210
  }).post("/api/auth/service-accounts/:serviceAccountId/access-tokens/:tokenId/revoke", async ({ params, ...context }) => {
12111
12211
  try {
@@ -12412,9 +12512,10 @@ function registerAuthRoutes(app, host, options) {
12412
12512
  });
12413
12513
  const response = await magicLinkRequestedResponse(options, authRedirect);
12414
12514
  const existingPending = getCookie4(request, MAGIC_LINK_PENDING_COOKIE_NAME)?.trim();
12415
- response.headers.append("set-cookie", magicLinkPendingCookieHeader({
12515
+ response.headers.append("set-cookie", callbackCookieHeader({
12416
12516
  request,
12417
12517
  host,
12518
+ name: MAGIC_LINK_PENDING_COOKIE_NAME,
12418
12519
  value: result.status === "sent" ? pending.secret : existingPending || pending.secret,
12419
12520
  maxAgeSeconds: magicLinkPendingCookieMaxAgeSeconds(strategy)
12420
12521
  }));
@@ -12428,7 +12529,7 @@ function registerAuthRoutes(app, host, options) {
12428
12529
  returnTo: authRedirect.returnTo,
12429
12530
  requestOrigin: authRedirect.requestOrigin
12430
12531
  });
12431
- return redirectResponse(result.redirectTo);
12532
+ return oidcSignInRedirect(request, host, result);
12432
12533
  }
12433
12534
  return strategyNotImplementedResponse("Sign-in is not implemented yet.");
12434
12535
  }, {
@@ -12460,7 +12561,7 @@ function registerAuthRoutes(app, host, options) {
12460
12561
  returnTo: authRedirect.returnTo,
12461
12562
  requestOrigin: authRedirect.requestOrigin
12462
12563
  });
12463
- return redirectResponse(result.redirectTo);
12564
+ return oidcSignInRedirect(request, host, result);
12464
12565
  }
12465
12566
  return strategyNotImplementedResponse("Sign-in is not implemented yet.");
12466
12567
  }, { detail: { hide: true } }).get("/auth/callback", async ({ request }) => {
@@ -12516,7 +12617,12 @@ function registerAuthRoutes(app, host, options) {
12516
12617
  const now = new Date;
12517
12618
  const sessionCredential = createSessionCredential();
12518
12619
  const device = resolveSessionDevice(request);
12620
+ const state = new URL(request.url).searchParams.get("state");
12621
+ let response;
12519
12622
  try {
12623
+ if (!state || !matchesOidcStateCookie(request, state)) {
12624
+ throw new Error("[SixbServer] OIDC callback reached a browser that did not start this sign-in.");
12625
+ }
12520
12626
  const authOptions = resolveAuthOptions(options, request);
12521
12627
  const result = await strategy.completeOidcSignIn({
12522
12628
  projectId: host.id,
@@ -12532,7 +12638,7 @@ function registerAuthRoutes(app, host, options) {
12532
12638
  ...device
12533
12639
  }
12534
12640
  });
12535
- return sessionCallbackCompletionResponse({
12641
+ response = sessionCallbackCompletionResponse({
12536
12642
  host,
12537
12643
  request,
12538
12644
  apiOrigin: options.resolveAuthRequestOrigin(request),
@@ -12543,11 +12649,18 @@ function registerAuthRoutes(app, host, options) {
12543
12649
  });
12544
12650
  } catch (error) {
12545
12651
  logAuthCallbackError("OIDC", error);
12546
- if (error instanceof SignInRefusedError) {
12547
- return htmlMessageResponse(signInRefusalMessage(error), 403, "You can't sign in");
12548
- }
12549
- return htmlMessageResponse("This sign-in attempt could not be completed.", 400);
12652
+ response = error instanceof SignInRefusedError ? htmlMessageResponse(signInRefusalMessage(error), 403, "You can't sign in") : htmlMessageResponse("This sign-in attempt could not be completed.", 400);
12550
12653
  }
12654
+ if (state) {
12655
+ response.headers.append("set-cookie", callbackCookieHeader({
12656
+ request,
12657
+ host,
12658
+ name: oidcStateCookieName(state),
12659
+ value: "",
12660
+ maxAgeSeconds: 0
12661
+ }));
12662
+ }
12663
+ return response;
12551
12664
  }
12552
12665
  return strategyNotImplementedResponse("Auth callback is not implemented yet.");
12553
12666
  }, { detail: { hide: true } }).post("/auth/callback", async ({ body, request }) => {
@@ -12622,9 +12735,9 @@ function matchesMagicLinkRequester(pendingSecret, requesterHash) {
12622
12735
  const provided = Buffer.from(requesterHash);
12623
12736
  return expected.length === provided.length && timingSafeEqual(expected, provided);
12624
12737
  }
12625
- function magicLinkPendingCookieHeader(params) {
12738
+ function callbackCookieHeader(params) {
12626
12739
  const parts = [
12627
- `${MAGIC_LINK_PENDING_COOKIE_NAME}=${params.value}`,
12740
+ `${params.name}=${params.value}`,
12628
12741
  "Path=/auth/callback",
12629
12742
  "SameSite=Lax",
12630
12743
  "HttpOnly",
@@ -12665,9 +12778,10 @@ async function completeMagicLinkCallback(input) {
12665
12778
  returnTo: result.returnTo
12666
12779
  });
12667
12780
  if (input.clearPendingCookie) {
12668
- response.headers.append("set-cookie", magicLinkPendingCookieHeader({
12781
+ response.headers.append("set-cookie", callbackCookieHeader({
12669
12782
  request: input.request,
12670
12783
  host: input.host,
12784
+ name: MAGIC_LINK_PENDING_COOKIE_NAME,
12671
12785
  value: "",
12672
12786
  maxAgeSeconds: 0
12673
12787
  }));
@@ -12677,6 +12791,28 @@ async function completeMagicLinkCallback(input) {
12677
12791
  return await invalidMagicLinkResponse(input.options, input.authRedirectHint);
12678
12792
  }
12679
12793
  }
12794
+ function oidcStateCookieName(state) {
12795
+ return `sixb_oidc_${createHash3("sha256").update(state).digest("base64url").slice(0, 22)}`;
12796
+ }
12797
+ function oidcSignInRedirect(request, host, result) {
12798
+ const response = redirectResponse(result.redirectTo);
12799
+ response.headers.append("set-cookie", callbackCookieHeader({
12800
+ request,
12801
+ host,
12802
+ name: oidcStateCookieName(result.state),
12803
+ value: encodeURIComponent(result.state),
12804
+ maxAgeSeconds: Math.max(0, Math.floor((result.expiresAt.getTime() - Date.now()) / 1000))
12805
+ }));
12806
+ return response;
12807
+ }
12808
+ function matchesOidcStateCookie(request, state) {
12809
+ const held = getCookie4(request, oidcStateCookieName(state));
12810
+ if (!held)
12811
+ return false;
12812
+ const expected = Buffer.from(encodeURIComponent(state));
12813
+ const provided = Buffer.from(held);
12814
+ return expected.length === provided.length && timingSafeEqual(expected, provided);
12815
+ }
12680
12816
  function bearerTokensBody(tokens, bearer, issuedAt) {
12681
12817
  return {
12682
12818
  accessToken: tokens.accessToken,
@@ -12792,6 +12928,9 @@ function authSessionBody(host, session, audience) {
12792
12928
  session: { id: session.session.id, expiresAt: toIsoString(session.session.expiresAt) }
12793
12929
  };
12794
12930
  }
12931
+ function signedOutSessionResponse(host) {
12932
+ return jsonResponse2({ authenticated: false, authEnabled: host.auth.isEnabled() }, 200);
12933
+ }
12795
12934
  function authSessionJsonResponse(body, setCookies) {
12796
12935
  const headers = new Headers({
12797
12936
  "content-type": "application/json; charset=utf-8",
@@ -13952,248 +14091,45 @@ function errorMessage(error) {
13952
14091
  // src/routes/ws/events.ts
13953
14092
  import { scopeKeysForEvent } from "@sixb/core/internal/event-scope";
13954
14093
  import { z as z34 } from "zod";
13955
- var SubscribeSchema2 = z34.object({
13956
- type: z34.literal("subscribe"),
13957
- topic: z34.enum(EVENT_TOPICS).optional(),
13958
- types: z34.array(z34.enum(EVENT_TYPES)).optional(),
13959
- objectTypeId: z34.string().optional(),
13960
- primaryId: z34.string().optional(),
13961
- actionId: z34.string().optional(),
13962
- runId: z34.string().optional(),
13963
- afterCursor: z34.string().optional(),
13964
- limit: z34.number().int().positive().max(500).optional()
13965
- });
13966
- var UnsubscribeSchema2 = z34.object({
13967
- type: z34.literal("unsubscribe")
13968
- });
13969
- var SubscriptionMessageSchema = z34.union([SubscribeSchema2, UnsubscribeSchema2]);
13970
- function parseSubscriptionMessage(payload) {
13971
- if (!payload || typeof payload !== "object") {
13972
- return { ok: false, error: "Message must be a JSON object." };
13973
- }
13974
- const parsed = SubscriptionMessageSchema.safeParse(payload);
13975
- if (!parsed.success) {
13976
- return {
13977
- ok: false,
13978
- error: parsed.error.issues[0]?.message ?? "Invalid websocket message."
13979
- };
13980
- }
13981
- return { ok: true, data: parsed.data };
13982
- }
13983
- async function resolveLatestCursor(server) {
13984
- return server.getHost().events.latestCursor();
13985
- }
13986
- function createDefaultState() {
13987
- return {
13988
- topics: undefined,
13989
- types: undefined,
13990
- objectTypeId: undefined,
13991
- primaryId: undefined,
13992
- actionId: undefined,
13993
- runId: undefined,
13994
- afterCursor: undefined,
13995
- limit: 200,
13996
- polling: false,
13997
- timer: null,
13998
- initialized: Promise.resolve(),
13999
- initializationFailureHandled: false
14000
- };
14001
- }
14002
- function registerEventStreamRoutes(app, server) {
14003
- const states = new WeakMap;
14004
- const awaitInitialization = async (ws, state) => {
14005
- try {
14006
- await state.initialized;
14007
- return true;
14008
- } catch (error) {
14009
- if (state.initializationFailureHandled)
14010
- return false;
14011
- state.initializationFailureHandled = true;
14012
- const message = error instanceof Error ? error.message : String(error);
14013
- safeSend(ws, {
14014
- type: "error",
14015
- message: `[SixbServer] Failed to initialize event websocket: ${message}`
14016
- });
14017
- ws.close();
14018
- return false;
14019
- }
14020
- };
14021
- const stopPolling = (ws) => {
14022
- const state = states.get(wsStateKey(ws));
14023
- if (!state) {
14024
- return;
14025
- }
14026
- if (state.timer) {
14027
- clearInterval(state.timer);
14028
- state.timer = null;
14029
- }
14030
- };
14031
- const startPolling = (ws) => {
14032
- const state = states.get(wsStateKey(ws));
14033
- if (!state || state.timer) {
14034
- return;
14035
- }
14036
- const sixb = wsRequestSixb(ws);
14037
- if (!sixb) {
14038
- safeSend(ws, { type: "error", message: "Execution scope is not available." });
14039
- return;
14040
- }
14041
- const tick = async () => {
14042
- if (state.polling) {
14043
- return;
14044
- }
14045
- state.polling = true;
14046
- try {
14047
- const p = server.getHost();
14048
- const events = await p.events.read({
14049
- afterCursor: state.afterCursor,
14050
- limit: state.limit,
14051
- topics: state.topics,
14052
- types: state.types
14053
- });
14054
- for (const event of events) {
14055
- if (!eventMatchesScope(event, state)) {
14056
- continue;
14057
- }
14058
- if (sixb.events.canRead(event)) {
14059
- safeSend(ws, { type: "event", event });
14060
- }
14061
- }
14062
- const last = events[events.length - 1];
14063
- if (last) {
14064
- state.afterCursor = last.cursor;
14065
- }
14066
- } catch (error) {
14067
- const message = error instanceof Error ? error.message : String(error);
14068
- safeSend(ws, { type: "error", message });
14069
- } finally {
14070
- state.polling = false;
14071
- }
14072
- };
14073
- state.timer = setInterval(() => {
14074
- tick();
14075
- }, 500);
14076
- tick();
14077
- };
14078
- return app.ws("/ws/events", {
14079
- async open(ws) {
14080
- const state = createDefaultState();
14081
- states.set(wsStateKey(ws), state);
14082
- state.initialized = resolveLatestCursor(server).then((cursor) => {
14083
- state.afterCursor = cursor;
14084
- });
14085
- if (!await awaitInitialization(ws, state))
14086
- return;
14087
- safeSend(ws, { type: "connected", channel: "events" });
14088
- },
14089
- async message(ws, message) {
14090
- const decoded = await decodeWsMessage(message);
14091
- const parsed = parseSubscriptionMessage(decoded);
14092
- if (!parsed.ok) {
14093
- safeSend(ws, { type: "error", message: parsed.error });
14094
- return;
14095
- }
14096
- const state = states.get(wsStateKey(ws));
14097
- if (!state) {
14098
- safeSend(ws, { type: "error", message: "Subscription state not found." });
14099
- return;
14100
- }
14101
- if (!await awaitInitialization(ws, state))
14102
- return;
14103
- if (parsed.data.type === "unsubscribe") {
14104
- stopPolling(ws);
14105
- state.topics = undefined;
14106
- state.types = undefined;
14107
- state.objectTypeId = undefined;
14108
- state.primaryId = undefined;
14109
- state.actionId = undefined;
14110
- state.runId = undefined;
14111
- state.afterCursor = await resolveLatestCursor(server);
14112
- safeSend(ws, { type: "unsubscribed" });
14113
- return;
14114
- }
14115
- state.topics = parsed.data.topic ? [parsed.data.topic] : undefined;
14116
- state.types = parsed.data.types;
14117
- state.objectTypeId = parsed.data.objectTypeId;
14118
- state.primaryId = parsed.data.primaryId;
14119
- state.actionId = parsed.data.actionId;
14120
- state.runId = parsed.data.runId;
14121
- state.limit = parsed.data.limit ?? state.limit;
14122
- state.afterCursor = parsed.data.afterCursor ?? state.afterCursor;
14123
- startPolling(ws);
14124
- safeSend(ws, {
14125
- type: "subscribed",
14126
- topic: state.topics?.[0] ?? null,
14127
- types: state.types ?? null,
14128
- afterCursor: state.afterCursor ?? null
14129
- });
14130
- },
14131
- close(ws) {
14132
- stopPolling(ws);
14133
- states.delete(wsStateKey(ws));
14134
- }
14135
- });
14136
- }
14137
- function eventMatchesScope(event, filter) {
14138
- const { objectTypeId, primaryId, actionId, runId } = filter;
14139
- if (objectTypeId === undefined && primaryId === undefined && actionId === undefined && runId === undefined) {
14140
- return true;
14141
- }
14142
- const scope = scopeKeysForEvent(event);
14143
- if (objectTypeId !== undefined && scope.objectTypeId !== objectTypeId) {
14144
- return false;
14145
- }
14146
- if (primaryId !== undefined && scope.primaryId !== primaryId) {
14147
- return false;
14148
- }
14149
- if (actionId !== undefined && scope.actionId !== actionId) {
14150
- return false;
14151
- }
14152
- if (runId !== undefined && scope.runId !== runId) {
14153
- return false;
14154
- }
14155
- return true;
14156
- }
14157
14094
 
14158
- // src/routes/ws/logs.ts
14159
- import { z as z35 } from "zod";
14160
-
14161
- // src/routes/ws/log-subscription-hub.ts
14095
+ // src/routes/ws/subscription-hub.ts
14162
14096
  import { BrokerCursorExpiredError as BrokerCursorExpiredError2 } from "@sixb/core/broker";
14163
14097
  var MAX_CLIENT_RECORDS = 1000;
14164
14098
  var MAX_CLIENT_BYTES = 1048576;
14165
14099
  var MAX_SOCKET_BUFFERED_BYTES = 1048576;
14166
14100
  var MAX_BATCH_RECORDS = 100;
14167
14101
  var FLUSH_DELAY_MS = 10;
14168
- var READ_PAGE_SIZE = 500;
14169
14102
 
14170
- class LogSubscriptionHub {
14171
- host;
14103
+ class SubscriptionHub {
14104
+ source;
14172
14105
  clients = new Map;
14173
14106
  subscriptionGenerations = new WeakMap;
14174
- startPromise = null;
14175
- unsubscribeBroker = null;
14107
+ started = null;
14176
14108
  closed = false;
14177
- constructor(host) {
14178
- this.host = host;
14109
+ constructor(source) {
14110
+ this.source = source;
14179
14111
  }
14180
- async subscribe(key, ws, filter, onSubscribed) {
14112
+ async subscribe(key, ws, subscription, onSubscribed) {
14181
14113
  if (this.closed)
14182
- throw new Error("Log subscription hub is closed");
14114
+ throw new Error("Subscription hub is closed");
14183
14115
  const generation = this.nextSubscriptionGeneration(key);
14184
14116
  this.removeClient(key);
14185
- try {
14186
- await this.ensureStarted();
14187
- } catch (error) {
14117
+ let started;
14118
+ do {
14119
+ started = this.start();
14120
+ try {
14121
+ await started;
14122
+ } catch (error) {
14123
+ if (this.closed || !this.isCurrentSubscription(key, generation))
14124
+ return;
14125
+ throw error;
14126
+ }
14188
14127
  if (this.closed || !this.isCurrentSubscription(key, generation))
14189
14128
  return;
14190
- throw error;
14191
- }
14192
- if (this.closed || !this.isCurrentSubscription(key, generation))
14193
- return;
14129
+ } while (started !== this.started);
14194
14130
  const state = {
14195
14131
  ws,
14196
- filter,
14132
+ subscription,
14197
14133
  queue: [],
14198
14134
  queuedCursors: new Set,
14199
14135
  pendingLive: [],
@@ -14203,13 +14139,13 @@ class LogSubscriptionHub {
14203
14139
  pendingBytes: 0,
14204
14140
  flushTimer: null,
14205
14141
  queueProgressWaiters: new Set,
14206
- catchingUp: filter.afterCursor !== undefined,
14142
+ catchingUp: subscription.replay !== undefined,
14207
14143
  closed: false
14208
14144
  };
14209
14145
  this.clients.set(key, state);
14210
14146
  onSubscribed();
14211
- if (state.catchingUp) {
14212
- this.catchUp(key, state);
14147
+ if (subscription.replay) {
14148
+ this.catchUp(key, state, subscription.replay);
14213
14149
  }
14214
14150
  }
14215
14151
  unsubscribe(key) {
@@ -14224,7 +14160,12 @@ class LogSubscriptionHub {
14224
14160
  if (state.flushTimer)
14225
14161
  clearTimeout(state.flushTimer);
14226
14162
  this.notifyQueueProgress(state);
14163
+ this.deleteClient(key);
14164
+ }
14165
+ deleteClient(key) {
14227
14166
  this.clients.delete(key);
14167
+ if (this.clients.size === 0)
14168
+ this.release();
14228
14169
  }
14229
14170
  nextSubscriptionGeneration(key) {
14230
14171
  const generation = (this.subscriptionGenerations.get(key) ?? 0) + 1;
@@ -14236,58 +14177,59 @@ class LogSubscriptionHub {
14236
14177
  }
14237
14178
  async close() {
14238
14179
  this.closed = true;
14239
- this.unsubscribeBroker?.();
14240
- this.unsubscribeBroker = null;
14241
14180
  for (const key of this.clients.keys())
14242
14181
  this.unsubscribe(key);
14182
+ this.release();
14243
14183
  }
14244
- async ensureStarted() {
14184
+ start() {
14245
14185
  if (this.closed)
14246
- throw new Error("Log subscription hub is closed");
14247
- if (!this.startPromise) {
14248
- this.startPromise = this.host.logging.subscribe({ from: "latest" }, (lines) => this.deliverLive(lines)).then((unsubscribe) => {
14249
- if (this.closed)
14250
- unsubscribe();
14251
- else
14252
- this.unsubscribeBroker = unsubscribe;
14253
- }).catch((error) => {
14254
- this.startPromise = null;
14255
- throw error;
14186
+ return Promise.reject(new Error("Subscription hub is closed"));
14187
+ if (!this.started) {
14188
+ const started = this.source.subscribe((records) => this.deliverLive(records));
14189
+ started.catch(() => {
14190
+ if (this.started === started)
14191
+ this.started = null;
14256
14192
  });
14193
+ this.started = started;
14257
14194
  }
14258
- await this.startPromise;
14195
+ return this.started;
14259
14196
  }
14260
- deliverLive(lines) {
14197
+ release() {
14198
+ const started = this.started;
14199
+ this.started = null;
14200
+ started?.then((unsubscribe) => unsubscribe(), () => {
14201
+ return;
14202
+ });
14203
+ }
14204
+ deliverLive(records) {
14261
14205
  for (const state of this.clients.values()) {
14262
- for (const line of lines) {
14263
- if (!matches(line, state.filter))
14206
+ for (const record of records) {
14207
+ const visible = visibleRecord(state.subscription, record);
14208
+ if (!visible)
14264
14209
  continue;
14265
14210
  if (state.catchingUp)
14266
- this.enqueuePendingLive(state, line);
14211
+ this.enqueuePendingLive(state, visible);
14267
14212
  else
14268
- this.enqueue(state, line);
14213
+ this.enqueue(state, visible);
14269
14214
  }
14270
14215
  }
14271
14216
  }
14272
- async catchUp(key, state) {
14273
- let afterCursor = state.filter.afterCursor;
14217
+ async catchUp(key, state, replay) {
14218
+ let afterCursor = replay.afterCursor;
14274
14219
  try {
14275
14220
  let hasMore = true;
14276
14221
  while (hasMore) {
14277
- const page = await this.host.logging.read({
14278
- afterCursor,
14279
- limit: READ_PAGE_SIZE,
14280
- kinds: state.filter.kinds,
14281
- levels: state.filter.levels,
14282
- run: state.filter.run
14283
- });
14222
+ const page = await replay.read(afterCursor);
14284
14223
  if (state.closed || this.clients.get(key) !== state)
14285
14224
  return;
14286
- for (const line of page.lines) {
14287
- if (state.pendingCursors.has(line.cursor)) {
14288
- state.replayedPendingCursors.add(line.cursor);
14225
+ for (const record of page.records) {
14226
+ if (state.pendingCursors.has(record.cursor)) {
14227
+ state.replayedPendingCursors.add(record.cursor);
14289
14228
  }
14290
- if (!await this.enqueueReplay(state, line))
14229
+ const visible = visibleRecord(state.subscription, record);
14230
+ if (!visible)
14231
+ continue;
14232
+ if (!await this.enqueueReplay(state, visible))
14291
14233
  return;
14292
14234
  }
14293
14235
  if (state.closed)
@@ -14295,7 +14237,7 @@ class LogSubscriptionHub {
14295
14237
  afterCursor = page.cursor ?? afterCursor;
14296
14238
  hasMore = page.hasMore;
14297
14239
  if (hasMore && !page.cursor) {
14298
- throw new Error("Log broker returned hasMore without a cursor");
14240
+ throw new Error("Broker returned hasMore without a cursor");
14299
14241
  }
14300
14242
  }
14301
14243
  state.catchingUp = false;
@@ -14305,9 +14247,9 @@ class LogSubscriptionHub {
14305
14247
  state.pendingCursors.clear();
14306
14248
  state.replayedPendingCursors.clear();
14307
14249
  state.pendingBytes = 0;
14308
- for (const line of pendingLive) {
14309
- if (!replayedPendingCursors.has(line.cursor))
14310
- this.enqueue(state, line);
14250
+ for (const record of pendingLive) {
14251
+ if (!replayedPendingCursors.has(record.cursor))
14252
+ this.enqueue(state, record);
14311
14253
  }
14312
14254
  } catch (error) {
14313
14255
  if (state.closed || this.clients.get(key) !== state)
@@ -14319,12 +14261,7 @@ class LogSubscriptionHub {
14319
14261
  state.pendingBytes = 0;
14320
14262
  if (error instanceof BrokerCursorExpiredError2) {
14321
14263
  try {
14322
- const latest = await this.host.logging.tail({ limit: 1 });
14323
- this.send(state, {
14324
- type: "reset",
14325
- reason: "cursor_expired",
14326
- cursor: latest.lines.at(-1)?.cursor ?? latest.cursor
14327
- });
14264
+ this.send(state, await this.source.expired());
14328
14265
  } catch (resetError) {
14329
14266
  this.fail(state, resetError instanceof Error ? resetError.message : String(resetError), 1011);
14330
14267
  }
@@ -14333,25 +14270,25 @@ class LogSubscriptionHub {
14333
14270
  this.fail(state, error instanceof Error ? error.message : String(error), 1011);
14334
14271
  }
14335
14272
  }
14336
- enqueue(state, line) {
14337
- if (state.closed || state.queuedCursors.has(line.cursor))
14273
+ enqueue(state, record) {
14274
+ if (state.closed || state.queuedCursors.has(record.cursor))
14338
14275
  return;
14339
- const bytes = encodedBytes(line);
14276
+ const bytes = encodedBytes(record);
14340
14277
  if (!hasQueueCapacity(state, bytes)) {
14341
- this.fail(state, "Log stream client is too slow; reconnect from the last cursor.", 1013);
14278
+ this.fail(state, "Stream client is too slow; reconnect from the last cursor.", 1013);
14342
14279
  return;
14343
14280
  }
14344
- this.pushQueuedLine(state, line, bytes);
14281
+ this.pushQueuedRecord(state, record, bytes);
14345
14282
  }
14346
- async enqueueReplay(state, line) {
14283
+ async enqueueReplay(state, record) {
14347
14284
  if (state.closed)
14348
14285
  return false;
14349
- if (state.queuedCursors.has(line.cursor))
14286
+ if (state.queuedCursors.has(record.cursor))
14350
14287
  return true;
14351
- const bytes = encodedBytes(line);
14288
+ const bytes = encodedBytes(record);
14352
14289
  while (!hasQueueCapacity(state, bytes)) {
14353
14290
  if (state.queue.length === 0 || socketBufferedAmount(state.ws) > MAX_SOCKET_BUFFERED_BYTES) {
14354
- this.fail(state, "Log stream client is too slow; reconnect from the last cursor.", 1013);
14291
+ this.fail(state, "Stream client is too slow; reconnect from the last cursor.", 1013);
14355
14292
  return false;
14356
14293
  }
14357
14294
  this.scheduleFlush(state);
@@ -14359,25 +14296,25 @@ class LogSubscriptionHub {
14359
14296
  if (state.closed)
14360
14297
  return false;
14361
14298
  }
14362
- this.pushQueuedLine(state, line, bytes);
14299
+ this.pushQueuedRecord(state, record, bytes);
14363
14300
  return !state.closed;
14364
14301
  }
14365
- pushQueuedLine(state, line, bytes) {
14366
- state.queue.push(line);
14367
- state.queuedCursors.add(line.cursor);
14302
+ pushQueuedRecord(state, record, bytes) {
14303
+ state.queue.push(record);
14304
+ state.queuedCursors.add(record.cursor);
14368
14305
  state.queuedBytes += bytes;
14369
14306
  this.scheduleFlush(state);
14370
14307
  }
14371
- enqueuePendingLive(state, line) {
14372
- if (state.closed || state.pendingCursors.has(line.cursor))
14308
+ enqueuePendingLive(state, record) {
14309
+ if (state.closed || state.pendingCursors.has(record.cursor))
14373
14310
  return;
14374
- const bytes = encodedBytes(line);
14311
+ const bytes = encodedBytes(record);
14375
14312
  if (!hasQueueCapacity(state, bytes)) {
14376
- this.fail(state, "Log stream client is too slow; reconnect from the last cursor.", 1013);
14313
+ this.fail(state, "Stream client is too slow; reconnect from the last cursor.", 1013);
14377
14314
  return;
14378
14315
  }
14379
- state.pendingLive.push(line);
14380
- state.pendingCursors.add(line.cursor);
14316
+ state.pendingLive.push(record);
14317
+ state.pendingCursors.add(record.cursor);
14381
14318
  state.pendingBytes += bytes;
14382
14319
  }
14383
14320
  scheduleFlush(state) {
@@ -14395,13 +14332,14 @@ class LogSubscriptionHub {
14395
14332
  this.scheduleFlush(state);
14396
14333
  return;
14397
14334
  }
14398
- const lines = state.queue.splice(0, MAX_BATCH_RECORDS);
14399
- for (const line of lines) {
14400
- state.queuedCursors.delete(line.cursor);
14401
- state.queuedBytes -= encodedBytes(line);
14335
+ const records = state.queue.splice(0, MAX_BATCH_RECORDS);
14336
+ for (const record of records) {
14337
+ state.queuedCursors.delete(record.cursor);
14338
+ state.queuedBytes -= encodedBytes(record);
14402
14339
  }
14403
14340
  this.notifyQueueProgress(state);
14404
- this.send(state, { type: "logs", logs: lines });
14341
+ for (const frame of this.source.frames(records))
14342
+ this.send(state, frame);
14405
14343
  if (state.queue.length > 0)
14406
14344
  this.scheduleFlush(state);
14407
14345
  }
@@ -14435,28 +14373,21 @@ class LogSubscriptionHub {
14435
14373
  this.notifyQueueProgress(state);
14436
14374
  for (const [key, candidate] of this.clients) {
14437
14375
  if (candidate === state)
14438
- this.clients.delete(key);
14376
+ this.deleteClient(key);
14439
14377
  }
14440
14378
  try {
14441
- state.ws.close(closeCode, closeCode === 1013 ? "Log stream backpressure" : "Log stream failure");
14379
+ state.ws.close(closeCode, closeCode === 1013 ? "Stream backpressure" : "Stream failure");
14442
14380
  } catch {}
14443
14381
  }
14444
14382
  }
14383
+ function visibleRecord(subscription, record) {
14384
+ if (!subscription.matches(record))
14385
+ return;
14386
+ return subscription.view ? subscription.view(record) : record;
14387
+ }
14445
14388
  function hasQueueCapacity(state, bytes) {
14446
14389
  return state.queue.length + state.pendingLive.length < MAX_CLIENT_RECORDS && state.queuedBytes + state.pendingBytes + bytes <= MAX_CLIENT_BYTES;
14447
14390
  }
14448
- function matches(line, filter) {
14449
- if (filter.run) {
14450
- if (line.context.run.kind !== filter.run.kind || line.context.run.id !== filter.run.id) {
14451
- return false;
14452
- }
14453
- }
14454
- if (filter.kinds && !filter.kinds.includes(line.context.run.kind))
14455
- return false;
14456
- if (filter.levels && !filter.levels.includes(line.level))
14457
- return false;
14458
- return true;
14459
- }
14460
14391
  function encodedBytes(value) {
14461
14392
  return new TextEncoder().encode(JSON.stringify(value)).byteLength;
14462
14393
  }
@@ -14468,7 +14399,174 @@ function socketBufferedAmount(ws) {
14468
14399
  return typeof bufferedAmount === "number" ? bufferedAmount : 0;
14469
14400
  }
14470
14401
 
14402
+ // src/routes/ws/events.ts
14403
+ var DEFAULT_READ_LIMIT = 200;
14404
+ var SubscribeSchema2 = z34.object({
14405
+ type: z34.literal("subscribe"),
14406
+ topic: z34.enum(EVENT_TOPICS).optional(),
14407
+ types: z34.array(z34.enum(EVENT_TYPES)).optional(),
14408
+ objectTypeId: z34.string().optional(),
14409
+ primaryId: z34.string().optional(),
14410
+ actionId: z34.string().optional(),
14411
+ runId: z34.string().optional(),
14412
+ afterCursor: z34.string().optional(),
14413
+ limit: z34.number().int().positive().max(500).optional()
14414
+ });
14415
+ var UnsubscribeSchema2 = z34.object({
14416
+ type: z34.literal("unsubscribe")
14417
+ });
14418
+ var SubscriptionMessageSchema = z34.union([SubscribeSchema2, UnsubscribeSchema2]);
14419
+ function parseSubscriptionMessage(payload) {
14420
+ if (!payload || typeof payload !== "object") {
14421
+ return { ok: false, error: "Message must be a JSON object." };
14422
+ }
14423
+ const parsed = SubscriptionMessageSchema.safeParse(payload);
14424
+ if (!parsed.success) {
14425
+ return {
14426
+ ok: false,
14427
+ error: parsed.error.issues[0]?.message ?? "Invalid websocket message."
14428
+ };
14429
+ }
14430
+ return { ok: true, data: parsed.data };
14431
+ }
14432
+ function registerEventStreamRoutes(app, server) {
14433
+ const events = server.getHost().events;
14434
+ const states = new WeakMap;
14435
+ const hub = new SubscriptionHub({
14436
+ subscribe: (deliver) => events.subscribe({ from: "latest" }, deliver),
14437
+ frames: (batch) => batch.map((event) => ({ type: "event", event })),
14438
+ expired: async () => ({
14439
+ type: "error",
14440
+ message: "[SixbServer] Event cursor expired; refetch current state. Live events continue."
14441
+ })
14442
+ });
14443
+ const awaitInitialization = async (ws, state) => {
14444
+ try {
14445
+ await state.initialized;
14446
+ return true;
14447
+ } catch (error) {
14448
+ if (state.initializationFailureHandled)
14449
+ return false;
14450
+ state.initializationFailureHandled = true;
14451
+ const message = error instanceof Error ? error.message : String(error);
14452
+ safeSend(ws, {
14453
+ type: "error",
14454
+ message: `[SixbServer] Failed to initialize event websocket: ${message}`
14455
+ });
14456
+ ws.close();
14457
+ return false;
14458
+ }
14459
+ };
14460
+ app.onStop(() => hub.close());
14461
+ return app.ws("/ws/events", {
14462
+ async open(ws) {
14463
+ const state = {
14464
+ replayFrom: null,
14465
+ initialized: Promise.resolve(),
14466
+ initializationFailureHandled: false
14467
+ };
14468
+ states.set(wsStateKey(ws), state);
14469
+ state.initialized = events.latestCursor().then((afterCursor) => {
14470
+ state.replayFrom = { afterCursor };
14471
+ });
14472
+ if (!await awaitInitialization(ws, state))
14473
+ return;
14474
+ safeSend(ws, { type: "connected", channel: "events" });
14475
+ },
14476
+ async message(ws, message) {
14477
+ const decoded = await decodeWsMessage(message);
14478
+ const parsed = parseSubscriptionMessage(decoded);
14479
+ if (!parsed.ok) {
14480
+ safeSend(ws, { type: "error", message: parsed.error });
14481
+ return;
14482
+ }
14483
+ const key = wsStateKey(ws);
14484
+ const state = states.get(key);
14485
+ if (!state) {
14486
+ safeSend(ws, { type: "error", message: "Subscription state not found." });
14487
+ return;
14488
+ }
14489
+ if (!await awaitInitialization(ws, state))
14490
+ return;
14491
+ if (parsed.data.type === "unsubscribe") {
14492
+ hub.unsubscribe(key);
14493
+ safeSend(ws, { type: "unsubscribed" });
14494
+ return;
14495
+ }
14496
+ const sixb = wsRequestSixb(ws);
14497
+ if (!sixb) {
14498
+ safeSend(ws, { type: "error", message: "Execution scope is not available." });
14499
+ return;
14500
+ }
14501
+ const filter = parsed.data;
14502
+ const topics = filter.topic ? [filter.topic] : undefined;
14503
+ const limit = filter.limit ?? DEFAULT_READ_LIMIT;
14504
+ const replayFrom = filter.afterCursor === undefined ? state.replayFrom : { afterCursor: filter.afterCursor };
14505
+ state.replayFrom = null;
14506
+ try {
14507
+ await hub.subscribe(key, ws, {
14508
+ matches: (event) => (!filter.topic || event.topic === filter.topic) && (!filter.types?.length || filter.types.includes(event.type)) && eventMatchesScope(event, filter),
14509
+ view: (event) => sixb.events.readable(event),
14510
+ replay: replayFrom ? {
14511
+ afterCursor: replayFrom.afterCursor,
14512
+ read: async (afterCursor) => {
14513
+ const records = await events.read({
14514
+ afterCursor,
14515
+ limit,
14516
+ topics,
14517
+ types: filter.types
14518
+ });
14519
+ return {
14520
+ records,
14521
+ cursor: records.at(-1)?.cursor,
14522
+ hasMore: records.length === limit
14523
+ };
14524
+ }
14525
+ } : undefined
14526
+ }, () => safeSend(ws, {
14527
+ type: "subscribed",
14528
+ topic: filter.topic ?? null,
14529
+ types: filter.types ?? null,
14530
+ afterCursor: replayFrom?.afterCursor ?? null
14531
+ }));
14532
+ } catch (error) {
14533
+ safeSend(ws, {
14534
+ type: "error",
14535
+ message: error instanceof Error ? error.message : String(error)
14536
+ });
14537
+ ws.close(1011, "Event stream setup failed");
14538
+ }
14539
+ },
14540
+ close(ws) {
14541
+ hub.unsubscribe(wsStateKey(ws));
14542
+ states.delete(wsStateKey(ws));
14543
+ }
14544
+ });
14545
+ }
14546
+ function eventMatchesScope(event, filter) {
14547
+ const { objectTypeId, primaryId, actionId, runId } = filter;
14548
+ if (objectTypeId === undefined && primaryId === undefined && actionId === undefined && runId === undefined) {
14549
+ return true;
14550
+ }
14551
+ const scope = scopeKeysForEvent(event);
14552
+ if (objectTypeId !== undefined && scope.objectTypeId !== objectTypeId) {
14553
+ return false;
14554
+ }
14555
+ if (primaryId !== undefined && scope.primaryId !== primaryId) {
14556
+ return false;
14557
+ }
14558
+ if (actionId !== undefined && scope.actionId !== actionId) {
14559
+ return false;
14560
+ }
14561
+ if (runId !== undefined && scope.runId !== runId) {
14562
+ return false;
14563
+ }
14564
+ return true;
14565
+ }
14566
+
14471
14567
  // src/routes/ws/logs.ts
14568
+ import { z as z35 } from "zod";
14569
+ var READ_PAGE_SIZE = 500;
14472
14570
  var SubscribeSchema3 = z35.object({
14473
14571
  type: z35.literal("subscribe"),
14474
14572
  kinds: z35.array(z35.enum(SIXB_RUN_KINDS)).min(1).optional(),
@@ -14502,8 +14600,41 @@ function parseLogSubscriptionMessage(payload) {
14502
14600
  }
14503
14601
  return { ok: true, data: parsed.data };
14504
14602
  }
14603
+ function createLogSubscriptionHub(logging) {
14604
+ return new SubscriptionHub({
14605
+ subscribe: (deliver) => logging.subscribe({ from: "latest" }, deliver),
14606
+ frames: (logs) => [{ type: "logs", logs }],
14607
+ expired: async () => {
14608
+ const latest = await logging.tail({ limit: 1 });
14609
+ return {
14610
+ type: "reset",
14611
+ reason: "cursor_expired",
14612
+ cursor: latest.lines.at(-1)?.cursor ?? latest.cursor
14613
+ };
14614
+ }
14615
+ });
14616
+ }
14617
+ function logSubscription(logging, filter) {
14618
+ return {
14619
+ matches: (line) => matchesLogFilter(line, filter),
14620
+ replay: filter.afterCursor === undefined ? undefined : {
14621
+ afterCursor: filter.afterCursor,
14622
+ read: async (afterCursor) => {
14623
+ const page = await logging.read({
14624
+ afterCursor,
14625
+ limit: READ_PAGE_SIZE,
14626
+ kinds: filter.kinds,
14627
+ levels: filter.levels,
14628
+ run: filter.run
14629
+ });
14630
+ return { records: page.lines, cursor: page.cursor, hasMore: page.hasMore };
14631
+ }
14632
+ }
14633
+ };
14634
+ }
14505
14635
  function registerLogStreamRoutes(app, server) {
14506
- const hub = new LogSubscriptionHub(server.getHost());
14636
+ const logging = server.getHost().logging;
14637
+ const hub = createLogSubscriptionHub(logging);
14507
14638
  app.onStop(() => hub.close());
14508
14639
  return app.ws("/ws/logs", {
14509
14640
  open(ws) {
@@ -14542,12 +14673,12 @@ function registerLogStreamRoutes(app, server) {
14542
14673
  const subscription = parsed.data;
14543
14674
  const levels = subscription.levels;
14544
14675
  try {
14545
- await hub.subscribe(key, ws, {
14676
+ await hub.subscribe(key, ws, logSubscription(logging, {
14546
14677
  kinds: subscription.kinds,
14547
14678
  levels,
14548
14679
  run: subscription.run,
14549
14680
  afterCursor: subscription.afterCursor
14550
- }, () => safeSend(ws, {
14681
+ }), () => safeSend(ws, {
14551
14682
  type: "subscribed",
14552
14683
  kinds: subscription.kinds ?? null,
14553
14684
  levels: levels ?? null,
@@ -14567,6 +14698,18 @@ function registerLogStreamRoutes(app, server) {
14567
14698
  }
14568
14699
  });
14569
14700
  }
14701
+ function matchesLogFilter(line, filter) {
14702
+ if (filter.run) {
14703
+ if (line.context.run.kind !== filter.run.kind || line.context.run.id !== filter.run.id) {
14704
+ return false;
14705
+ }
14706
+ }
14707
+ if (filter.kinds && !filter.kinds.includes(line.context.run.kind))
14708
+ return false;
14709
+ if (filter.levels && !filter.levels.includes(line.level))
14710
+ return false;
14711
+ return true;
14712
+ }
14570
14713
 
14571
14714
  // src/routes/ws/index.ts
14572
14715
  function registerWebSocketRoutes(app, server) {
@@ -14601,6 +14744,9 @@ class SixbServer {
14601
14744
  this.hostname = options.hostname ?? "0.0.0.0";
14602
14745
  this.quiet = options.quiet ?? false;
14603
14746
  this.apiBrowserPolicy = resolveApiBrowserPolicy(options.browser);
14747
+ if (this.apiBrowserPolicy.publicOrigin) {
14748
+ setApiPublicOrigin(this.hostRuntime, this.apiBrowserPolicy.publicOrigin);
14749
+ }
14604
14750
  this.authContextResolver = createApiBrowserAuthContextResolver(this.apiBrowserPolicy);
14605
14751
  this.authRedirectContextResolver = createApiBrowserAuthRedirectContextResolver(this.apiBrowserPolicy);
14606
14752
  this.authExperience = options.authExperience;
@@ -14844,12 +14990,13 @@ function createSixbApi(server) {
14844
14990
  })
14845
14991
  }
14846
14992
  }));
14993
+ const authExperience = server.getAuthExperience();
14847
14994
  registerAuthRoutes(app, host, {
14848
14995
  resolveAuthContext: (request) => server.resolveAuthContext(request),
14849
14996
  resolveAuthRedirectContext: (request, input) => server.resolveAuthRedirectContext(request, input),
14850
14997
  getInvitationDestinationOptions: (request) => server.getInvitationDestinationOptions(request),
14851
14998
  resolveAuthRequestOrigin: (request) => server.resolveAuthRequestOrigin(request),
14852
- authExperience: server.getAuthExperience(),
14999
+ authExperience: authExperience && { ...authExperience, locale: host.locale },
14853
15000
  resolveInvitationRedirectContext: (request, input) => server.resolveInvitationRedirectContext(request, input)
14854
15001
  });
14855
15002
  registerHttpRoutes(app, host, {
@@ -14949,4 +15096,4 @@ export {
14949
15096
  createSixbServer
14950
15097
  };
14951
15098
 
14952
- //# debugId=824CB18A06D7DB0564756E2164756E21
15099
+ //# debugId=D65B0A82168FF4ED64756E2164756E21