@sixb/server 0.1.10 → 0.1.12

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 (65) hide show
  1. package/README.md +19 -0
  2. package/dist/auth/browser-origin.d.ts.map +1 -1
  3. package/dist/connectors/http.d.ts.map +1 -1
  4. package/dist/index.js +224 -51
  5. package/dist/index.js.map +19 -19
  6. package/dist/models/display.d.ts +2 -2
  7. package/dist/models/display.d.ts.map +1 -1
  8. package/dist/routes/action-runs.d.ts +2 -0
  9. package/dist/routes/action-runs.d.ts.map +1 -1
  10. package/dist/routes/agents.d.ts +123 -34
  11. package/dist/routes/agents.d.ts.map +1 -1
  12. package/dist/routes/ai-accounting.d.ts.map +1 -1
  13. package/dist/routes/auth.d.ts +2 -2
  14. package/dist/routes/connector-connection-runs.d.ts +138 -4
  15. package/dist/routes/connector-connection-runs.d.ts.map +1 -1
  16. package/dist/routes/datasets.d.ts +8 -8
  17. package/dist/routes/files.d.ts +3 -1
  18. package/dist/routes/files.d.ts.map +1 -1
  19. package/dist/routes/models.d.ts +1 -1
  20. package/dist/routes/objects.d.ts +18 -5
  21. package/dist/routes/objects.d.ts.map +1 -1
  22. package/dist/routes/ontology.d.ts +24 -12
  23. package/dist/routes/ontology.d.ts.map +1 -1
  24. package/dist/routes/syncs.d.ts +5 -5
  25. package/dist/routes/workflows.d.ts +10 -6
  26. package/dist/routes/workflows.d.ts.map +1 -1
  27. package/dist/schemas/agents.d.ts +205 -100
  28. package/dist/schemas/agents.d.ts.map +1 -1
  29. package/dist/schemas/ai-accounting.d.ts +692 -104
  30. package/dist/schemas/ai-accounting.d.ts.map +1 -1
  31. package/dist/schemas/ai-usage.d.ts +2 -2
  32. package/dist/schemas/auth.d.ts +6 -6
  33. package/dist/schemas/common.d.ts +15 -0
  34. package/dist/schemas/common.d.ts.map +1 -1
  35. package/dist/schemas/connectors.d.ts +0 -3
  36. package/dist/schemas/connectors.d.ts.map +1 -1
  37. package/dist/schemas/datasets.d.ts +22 -22
  38. package/dist/schemas/files.d.ts +17 -8
  39. package/dist/schemas/files.d.ts.map +1 -1
  40. package/dist/schemas/models.d.ts +8 -8
  41. package/dist/schemas/objects.d.ts +13 -1
  42. package/dist/schemas/objects.d.ts.map +1 -1
  43. package/dist/schemas/ontology.d.ts +99 -49
  44. package/dist/schemas/ontology.d.ts.map +1 -1
  45. package/dist/schemas/syncs.d.ts +12 -12
  46. package/dist/schemas/workflows.d.ts +50 -50
  47. package/dist/server.d.ts.map +1 -1
  48. package/package.json +6 -5
  49. package/src/auth/browser-origin.ts +50 -1
  50. package/src/connectors/http.ts +0 -1
  51. package/src/models/display.ts +3 -2
  52. package/src/routes/agents.ts +48 -6
  53. package/src/routes/ai-accounting.ts +1 -0
  54. package/src/routes/connector-connection-runs.ts +37 -1
  55. package/src/routes/files.ts +2 -1
  56. package/src/routes/objects.ts +46 -2
  57. package/src/routes/ontology.ts +15 -5
  58. package/src/schemas/agents.ts +9 -0
  59. package/src/schemas/ai-accounting.ts +19 -1
  60. package/src/schemas/common.ts +5 -0
  61. package/src/schemas/connectors.ts +0 -1
  62. package/src/schemas/files.ts +8 -1
  63. package/src/schemas/objects.ts +30 -12
  64. package/src/schemas/ontology.ts +15 -6
  65. package/src/server.ts +2 -0
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { CSRF_HEADER_NAME as CSRF_HEADER_NAME3 } from "@sixb/core/internal/auth"
6
6
  import { bindRequestExecution } from "@sixb/core/internal/request-execution";
7
7
  import { Elysia } from "elysia";
8
8
  import { websocket as elysiaWebSocket } from "elysia/ws";
9
- import { zodToJsonSchema } from "zod-to-json-schema";
9
+ import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
10
10
 
11
11
  // src/auth/browser-origin.ts
12
12
  import {
@@ -15,6 +15,8 @@ import {
15
15
  isValidAuthSessionAudience,
16
16
  resolveAuthSessionAudience
17
17
  } from "@sixb/core";
18
+ import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http";
19
+ var fileNavigationRoutes = SIXB_API_ROUTES.filter((route) => (route.method === "GET" || route.method === "HEAD") && route.path.endsWith("/files/content"));
18
20
 
19
21
  class BrowserOriginError extends Error {
20
22
  name = "BrowserOriginError";
@@ -57,11 +59,13 @@ function createApiBrowserAuthRedirectContextResolver(policy) {
57
59
  }
58
60
  function resolveApiBrowserAuthContext(policy, request) {
59
61
  const origin = normalizeRequestOrigin(request);
62
+ const fileAudience = resolveFileNavigationAudience(policy, request);
60
63
  if (!origin) {
61
- return { audience: policy.apiOriginAudience, absoluteReturnTo: true };
64
+ return { audience: fileAudience ?? policy.apiOriginAudience, absoluteReturnTo: true };
62
65
  }
63
66
  const allowed = findAllowedBrowserOrigin(policy, origin);
64
67
  if (allowed) {
68
+ assertFileAudienceMatchesOrigin(fileAudience, allowed.audience);
65
69
  return {
66
70
  audience: allowed.audience,
67
71
  browserOrigin: allowed.origin,
@@ -69,10 +73,30 @@ function resolveApiBrowserAuthContext(policy, request) {
69
73
  };
70
74
  }
71
75
  if (isSameOriginApiRequest(policy, origin, request)) {
76
+ assertFileAudienceMatchesOrigin(fileAudience, policy.apiOriginAudience);
72
77
  return { audience: policy.apiOriginAudience, browserOrigin: origin, absoluteReturnTo: true };
73
78
  }
74
79
  throw new BrowserOriginError(`[SixbServer] Browser origin '${origin}' is not allowed.`);
75
80
  }
81
+ function resolveFileNavigationAudience(policy, request) {
82
+ const url = new URL(request.url);
83
+ if (!fileNavigationRoutes.some((route) => route.method === request.method && matchesPathPattern(normalizeRoutePath(url.pathname), route.path))) {
84
+ return;
85
+ }
86
+ const values = url.searchParams.getAll("audience");
87
+ if (values.length === 0)
88
+ return;
89
+ const audience = values[0];
90
+ if (values.length !== 1 || !audience || !isValidAuthSessionAudience(audience) || audience !== policy.apiOriginAudience && !policy.allowedOrigins.some((entry) => entry.audience === audience)) {
91
+ throw new BrowserOriginError("[SixbServer] File navigation audience is not allowed.");
92
+ }
93
+ return audience;
94
+ }
95
+ function assertFileAudienceMatchesOrigin(audience, originAudience) {
96
+ if (audience !== undefined && audience !== originAudience) {
97
+ throw new BrowserOriginError("[SixbServer] File navigation audience conflicts with Origin.");
98
+ }
99
+ }
76
100
  function isAllowedApiBrowserOrigin(policy, request) {
77
101
  const origin = normalizeRequestOrigin(request);
78
102
  if (!origin) {
@@ -214,7 +238,7 @@ import {
214
238
 
215
239
  // src/auth/access-token-boundary.ts
216
240
  import { isCsrfExemptMethod as isCsrfExemptMethod2 } from "@sixb/core/internal/auth";
217
- import { matchesPathPattern as matchesPathPattern2, normalizeRoutePath as normalizeRoutePath2, SIXB_API_ROUTES as SIXB_API_ROUTES2 } from "@sixb/core/internal/http";
241
+ import { matchesPathPattern as matchesPathPattern3, normalizeRoutePath as normalizeRoutePath3, SIXB_API_ROUTES as SIXB_API_ROUTES3 } from "@sixb/core/internal/http";
218
242
 
219
243
  // src/openapi/security.ts
220
244
  import { CSRF_HEADER_NAME as CSRF_HEADER_NAME2 } from "@sixb/core/internal/auth";
@@ -228,7 +252,7 @@ import {
228
252
  isCsrfExemptMethod,
229
253
  verifyDoubleSubmitCsrf
230
254
  } from "@sixb/core/internal/auth";
231
- import { matchesPathPattern, normalizeRoutePath, SIXB_API_ROUTES } from "@sixb/core/internal/http";
255
+ import { matchesPathPattern as matchesPathPattern2, normalizeRoutePath as normalizeRoutePath2, SIXB_API_ROUTES as SIXB_API_ROUTES2 } from "@sixb/core/internal/http";
232
256
  import { SharedSessionProtocol } from "@sixb/core/internal/shares";
233
257
 
234
258
  // src/auth/session-activity.ts
@@ -251,7 +275,7 @@ var SHARED_SESSION_COOKIE_PREFIX = "sixb_share_session_";
251
275
  var SHARED_CSRF_COOKIE_PREFIX = "sixb_share_csrf_";
252
276
  var SHARED_COOKIE_PATH = "/api";
253
277
  var STORED_IDENTIFIER_MAX_LENGTH = 128;
254
- var SHARED_SESSION_ROUTES = SIXB_API_ROUTES.filter((route) => route.sharedSession);
278
+ var SHARED_SESSION_ROUTES = SIXB_API_ROUTES2.filter((route) => route.sharedSession);
255
279
 
256
280
  class SharedAccessBoundary {
257
281
  host;
@@ -436,16 +460,16 @@ function isSharedAccessPublicRoute(request) {
436
460
  }
437
461
  function isSharedAccessPublicPath(pathname, requestMethod) {
438
462
  const method = requestMethod.toUpperCase();
439
- const normalizedPathname = normalizeRoutePath(pathname);
463
+ const normalizedPathname = normalizeRoutePath2(pathname);
440
464
  const suffix = method === "POST" && normalizedPathname.endsWith("/exchange") ? "exchange" : method === "GET" && normalizedPathname.endsWith("/session") ? "session" : method === "POST" && normalizedPathname.endsWith("/sign-out") ? "sign-out" : null;
441
465
  if (!suffix)
442
466
  return false;
443
- return matchesPathPattern(normalizedPathname, `/api/shared-access/:grantId/${suffix}`);
467
+ return matchesPathPattern2(normalizedPathname, `/api/shared-access/:grantId/${suffix}`);
444
468
  }
445
469
  function isSharedSessionRoute(request) {
446
470
  const method = request.method.toUpperCase();
447
- const pathname = normalizeRoutePath(new URL(request.url).pathname);
448
- return SHARED_SESSION_ROUTES.some((route) => route.method === method && matchesPathPattern(pathname, route.path));
471
+ const pathname = normalizeRoutePath2(new URL(request.url).pathname);
472
+ return SHARED_SESSION_ROUTES.some((route) => route.method === method && matchesPathPattern2(pathname, route.path));
449
473
  }
450
474
  function sharedAccessUnauthenticatedResponse() {
451
475
  return sharedBoundaryJsonResponse({ error: "Shared access session is invalid" }, 401);
@@ -552,7 +576,7 @@ var SIXB_SHARED_GRANT_SECURITY_SCHEME = {
552
576
  };
553
577
 
554
578
  // src/auth/access-token-boundary.ts
555
- var ACCESS_TOKEN_ROUTES = SIXB_API_ROUTES2.filter((route) => route.accessToken).map((route) => ({
579
+ var ACCESS_TOKEN_ROUTES = SIXB_API_ROUTES3.filter((route) => route.accessToken).map((route) => ({
556
580
  operationId: route.operationId,
557
581
  method: route.method,
558
582
  path: route.path,
@@ -574,8 +598,8 @@ function bearerSecurityRequirement(operationId) {
574
598
  function isAccessTokenRoute(request) {
575
599
  const url = new URL(request.url);
576
600
  const method = request.method.toUpperCase();
577
- const pathname = normalizeRoutePath2(url.pathname);
578
- return ACCESS_TOKEN_ROUTES.some((route) => route.method === method && matchesPathPattern2(pathname, route.path));
601
+ const pathname = normalizeRoutePath3(url.pathname);
602
+ return ACCESS_TOKEN_ROUTES.some((route) => route.method === method && matchesPathPattern3(pathname, route.path));
579
603
  }
580
604
  function shouldVerifyCsrfForAuthSource(route, source) {
581
605
  return route.csrfProtected && source === "session";
@@ -1444,6 +1468,10 @@ var jsonValueOpenApiOverride = (def) => {
1444
1468
  }
1445
1469
  return ignoreOverride;
1446
1470
  };
1471
+ var AiUsageLimitErrorResponseSchema = codedErrorResponseSchema([
1472
+ "ai.usage_limit_exceeded",
1473
+ "ai.usage_limit_unavailable"
1474
+ ]).extend({ details: JsonValueSchema.optional() });
1447
1475
 
1448
1476
  // src/schemas/ontology.ts
1449
1477
  import { z as z2 } from "zod";
@@ -1465,7 +1493,6 @@ var PropertyDefinitionSchema = z2.object({
1465
1493
  text: z2.boolean().optional(),
1466
1494
  exact: z2.boolean().optional(),
1467
1495
  facet: z2.boolean().optional(),
1468
- vector: z2.boolean().optional(),
1469
1496
  weight: z2.number().optional()
1470
1497
  }).optional()
1471
1498
  });
@@ -1503,10 +1530,15 @@ var ObjectTypeSchema = z2.object({
1503
1530
  title: z2.string().optional(),
1504
1531
  defaultText: z2.array(z2.string()).optional(),
1505
1532
  exact: z2.array(z2.string()).optional(),
1506
- vector: z2.object({
1507
- property: z2.string(),
1508
- source: z2.array(z2.string())
1509
- }).optional()
1533
+ vectors: z2.record(z2.string(), z2.object({
1534
+ source: z2.array(z2.string()),
1535
+ model: z2.object({
1536
+ providerId: z2.string(),
1537
+ modelId: z2.string(),
1538
+ dimensions: z2.number().int().positive(),
1539
+ representation: z2.object({ name: z2.string(), version: z2.string().optional() }).optional()
1540
+ })
1541
+ })).optional()
1510
1542
  }).optional(),
1511
1543
  links: z2.array(LinkDefinitionSchema),
1512
1544
  actions: z2.array(ActionSchema)
@@ -1683,6 +1715,7 @@ var DirectPutFileUploadSchema = z4.object({
1683
1715
  });
1684
1716
  var MultipartFileUploadSchema = z4.object({
1685
1717
  strategy: z4.literal("multipart"),
1718
+ partReceipt: z4.enum(["etag", "none"]),
1686
1719
  uploadId: z4.string(),
1687
1720
  partSizeBytes: z4.number().int().positive(),
1688
1721
  expiresAt: z4.string()
@@ -1701,7 +1734,7 @@ var SignedFileUploadPartSchema = z4.object({
1701
1734
  });
1702
1735
  var FileUploadPartSchema = z4.object({
1703
1736
  partNumber: z4.number().int().positive(),
1704
- etag: z4.string()
1737
+ etag: z4.string().min(1).optional()
1705
1738
  });
1706
1739
  var CompleteFileUploadBodySchema = z4.object({
1707
1740
  sizeBytes: z4.number().int().nonnegative().optional(),
@@ -1709,6 +1742,7 @@ var CompleteFileUploadBodySchema = z4.object({
1709
1742
  parts: z4.array(FileUploadPartSchema).optional()
1710
1743
  });
1711
1744
  var FileContentQuerySchema = z4.object({
1745
+ audience: z4.enum(["atlas", "app"]).optional().describe("Session audience for file navigation without Origin; must match Origin when present"),
1712
1746
  path: z4.string().min(1),
1713
1747
  disposition: z4.enum(["inline", "attachment"]).optional(),
1714
1748
  v: z4.string().optional().describe("Client cache key; the route still resolves the current file")
@@ -2141,7 +2175,7 @@ import {
2141
2175
  resolveAgentExecutionAuthorization,
2142
2176
  resolveInheritedAgentExecutionAuthorization
2143
2177
  } from "@sixb/core/internal/agents";
2144
- import { normalizeRoutePath as normalizeRoutePath3, pathSegmentsFor } from "@sixb/core/internal/http";
2178
+ import { normalizeRoutePath as normalizeRoutePath4, pathSegmentsFor } from "@sixb/core/internal/http";
2145
2179
 
2146
2180
  // src/routes/files.ts
2147
2181
  import {
@@ -2497,6 +2531,7 @@ function fileUploadResponse(session) {
2497
2531
  strategy: "multipart",
2498
2532
  uploadId: session.id,
2499
2533
  partSizeBytes: session.providerUpload.partSizeBytes,
2534
+ partReceipt: session.providerUpload.partReceipt ?? "etag",
2500
2535
  expiresAt: session.providerUpload.expiresAt.toISOString()
2501
2536
  };
2502
2537
  }
@@ -2815,7 +2850,7 @@ function gatewayUpstreamPath(pathname) {
2815
2850
  const prefixLength = pathSegmentsFor(AGENT_API_GATEWAY_PREFIX2).length;
2816
2851
  const segments = pathSegmentsFor(pathname);
2817
2852
  const upstreamSegments = segments.slice(prefixLength + 2);
2818
- return normalizeRoutePath3(`/${upstreamSegments.join("/")}`);
2853
+ return normalizeRoutePath4(`/${upstreamSegments.join("/")}`);
2819
2854
  }
2820
2855
  function forwardedRequestHeaders(source) {
2821
2856
  const headers = new Headers;
@@ -2860,7 +2895,7 @@ async function readRequestBody(request, maxBytes) {
2860
2895
  return concatChunks(chunks, total);
2861
2896
  }
2862
2897
  function isSimpleFileUpload(method, pathname) {
2863
- return method === "POST" && normalizeRoutePath3(pathname) === "/api/files";
2898
+ return method === "POST" && normalizeRoutePath4(pathname) === "/api/files";
2864
2899
  }
2865
2900
  function matchesWorkflowRunStart(pathname) {
2866
2901
  const segments = pathSegmentsFor(pathname);
@@ -2988,7 +3023,19 @@ var AiCostSummarySchema = z8.object({
2988
3023
  });
2989
3024
  var AiAccountingAggregateSchema = z8.object({
2990
3025
  modelCallCount: z8.number().int().nonnegative(),
2991
- usage: AiUsageSummarySchema,
3026
+ usage: AiUsageSummarySchema.describe("Sums of reported meters; unreported meters are absent. totalTokens sums available input and output counts and is a lower bound when coverage is incomplete."),
3027
+ usageCoverage: z8.object({
3028
+ completeCallCount: z8.number().int().nonnegative().describe("Calls reporting both inputTokens and outputTokens."),
3029
+ fieldCallCounts: z8.object({
3030
+ inputTokens: z8.number().int().nonnegative(),
3031
+ outputTokens: z8.number().int().nonnegative(),
3032
+ uncachedInputTokens: z8.number().int().nonnegative(),
3033
+ cacheReadInputTokens: z8.number().int().nonnegative(),
3034
+ cacheWriteInputTokens: z8.number().int().nonnegative(),
3035
+ textOutputTokens: z8.number().int().nonnegative(),
3036
+ reasoningOutputTokens: z8.number().int().nonnegative()
3037
+ })
3038
+ }),
2992
3039
  costs: AiCostSummarySchema
2993
3040
  });
2994
3041
  var AiAccountingOverviewResponseSchema = z8.object({
@@ -3230,13 +3277,20 @@ var AgentThreadListQuerySchema = z9.object({
3230
3277
  }).strict();
3231
3278
  var CreateAgentThreadBodySchema = z9.object({
3232
3279
  title: z9.string().trim().min(1).optional(),
3233
- threadId: z9.string().trim().min(1).optional()
3280
+ threadId: z9.string().trim().min(1).optional(),
3281
+ sandbox: z9.record(z9.string(), JsonValueSchema).optional()
3234
3282
  }).strict();
3235
3283
  var AgentThreadSchema = z9.object({
3284
+ sandboxState: z9.object({
3285
+ name: z9.string(),
3286
+ status: z9.enum(["new", "busy", "ready", "blocked", "unavailable"]),
3287
+ initialized: z9.boolean()
3288
+ }).optional(),
3236
3289
  id: z9.string(),
3237
3290
  projectId: z9.string(),
3238
3291
  ownerPrincipal: AgentPrincipalSchema,
3239
3292
  title: z9.string().optional(),
3293
+ sandboxParams: z9.record(z9.string(), JsonValueSchema).optional(),
3240
3294
  status: AgentThreadStatusSchema,
3241
3295
  activeRunId: z9.string().nullable(),
3242
3296
  lastMessageAt: z9.string().optional(),
@@ -3407,16 +3461,18 @@ var AgentRunListResponseSchema = z9.object({
3407
3461
  var AgentMessageFileContentQuerySchema = FileContentQuerySchema.extend({
3408
3462
  path: z10.string().min(1).regex(/^\/parts(?:\/|$)/, "Agent message file content paths must start with /parts/")
3409
3463
  });
3410
- var AiUsageLimitErrorResponseSchema = codedErrorResponseSchema([
3411
- "ai.usage_limit_exceeded",
3412
- "ai.usage_limit_unavailable"
3413
- ]).extend({ details: JsonValueSchema.optional() });
3414
3464
  function serializeThread(thread) {
3415
3465
  return AgentThreadSchema.parse({
3416
3466
  id: thread.id,
3417
3467
  projectId: thread.projectId,
3418
3468
  ownerPrincipal: thread.ownerPrincipal,
3419
3469
  title: thread.title,
3470
+ sandboxParams: thread.sandboxParams,
3471
+ sandboxState: thread.sandboxState && {
3472
+ name: thread.sandboxState.name,
3473
+ status: thread.sandboxState.status,
3474
+ initialized: thread.sandboxState.initialized
3475
+ },
3420
3476
  status: thread.status,
3421
3477
  activeRunId: thread.activeRunId,
3422
3478
  lastMessageAt: thread.lastMessageAt ? toIsoString(thread.lastMessageAt) : undefined,
@@ -3508,12 +3564,15 @@ function handleAgentRouteError(error, set) {
3508
3564
  break;
3509
3565
  case "active_run_exists":
3510
3566
  case "run_not_retryable":
3567
+ case "sandbox_execution_unavailable":
3511
3568
  set.status = 409;
3512
3569
  break;
3513
3570
  case "authority_not_inheritable":
3514
3571
  set.status = 403;
3515
3572
  break;
3516
3573
  case "storage_unavailable":
3574
+ case "sandbox_not_configured":
3575
+ case "invalid_sandbox_params":
3517
3576
  case "agent_selector_removed":
3518
3577
  case "invalid_context":
3519
3578
  case "invalid_model_selection":
@@ -3641,7 +3700,8 @@ function registerAgentRoutes(app, host) {
3641
3700
  }
3642
3701
  const thread = await sixb.agent.threads.create({
3643
3702
  ...parsed.threadId === undefined ? {} : { id: parsed.threadId },
3644
- ...parsed.title === undefined ? {} : { title: parsed.title }
3703
+ ...parsed.title === undefined ? {} : { title: parsed.title },
3704
+ ...parsed.sandbox === undefined ? {} : { sandbox: parsed.sandbox }
3645
3705
  });
3646
3706
  set.status = 201;
3647
3707
  return CreateAgentThreadResponseSchema.parse({ thread: serializeThread(thread) });
@@ -3693,6 +3753,33 @@ function registerAgentRoutes(app, host) {
3693
3753
  tags: [OPENAPI_TAGS.agentThreads.name],
3694
3754
  operationId: "getAgentThread"
3695
3755
  }
3756
+ }).post("/api/agent-threads/:threadId/sandbox/recreate", async (context) => {
3757
+ try {
3758
+ const sixb = requireRequestSixb(context);
3759
+ const thread = await sixb.agent.threads.recreateSandbox(context.params.threadId, context.body);
3760
+ return serializeThread(thread);
3761
+ } catch (error) {
3762
+ if (error instanceof AgentStorageError && error.code === "invalid_state") {
3763
+ context.set.status = 409;
3764
+ return { error: "Sandbox state changed or a run is active. Reload and try again." };
3765
+ }
3766
+ return handleAgentRouteError(error, context.set);
3767
+ }
3768
+ }, {
3769
+ params: AgentThreadParamsSchema,
3770
+ body: z10.object({ expectedSandboxName: z10.string().min(1) }).strict(),
3771
+ response: {
3772
+ 200: AgentThreadSchema,
3773
+ 400: ErrorResponseSchema,
3774
+ 404: ErrorResponseSchema,
3775
+ 409: ErrorResponseSchema
3776
+ },
3777
+ detail: {
3778
+ summary: "Explicitly recreate an unavailable or uncertain workspace without deleting its previous state",
3779
+ operationId: "recreateAgentThreadSandbox",
3780
+ tags: [OPENAPI_TAGS.agentThreads.name],
3781
+ security: SIXB_CSRF_SECURITY_REQUIREMENT
3782
+ }
3696
3783
  }).get("/api/agent-threads/:threadId/messages", async (context) => {
3697
3784
  const { params, query, set } = context;
3698
3785
  const sixb = requireRequestSixb(context);
@@ -4118,6 +4205,7 @@ function serializeAggregate(aggregate) {
4118
4205
  return {
4119
4206
  modelCallCount: aggregate.modelCallCount,
4120
4207
  usage: aggregate.usage,
4208
+ usageCoverage: aggregate.usageCoverage,
4121
4209
  costs: aggregate.costs
4122
4210
  };
4123
4211
  }
@@ -4728,8 +4816,7 @@ var ConnectorConnectionRunSchema = z12.union([
4728
4816
  ConnectorConnectionRunBaseSchema.extend({
4729
4817
  status: z12.literal("waiting"),
4730
4818
  waitingFor: z12.literal("account_selection"),
4731
- accounts: z12.array(ConnectorAccountSchema),
4732
- expiresAt: z12.string().datetime()
4819
+ accounts: z12.array(ConnectorAccountSchema)
4733
4820
  }),
4734
4821
  ConnectorConnectionRunBaseSchema.extend({
4735
4822
  status: z12.literal("succeeded"),
@@ -4827,8 +4914,7 @@ function serializeConnectorConnectionRun(run) {
4827
4914
  ...base,
4828
4915
  status: "waiting",
4829
4916
  waitingFor: "account_selection",
4830
- accounts: [...run.accounts],
4831
- expiresAt: toIsoString(run.expiresAt)
4917
+ accounts: [...run.accounts]
4832
4918
  };
4833
4919
  }
4834
4920
  if (run.status === "succeeded") {
@@ -4859,7 +4945,29 @@ function handleConnectorRouteError(error, set) {
4859
4945
 
4860
4946
  // src/routes/connector-connection-runs.ts
4861
4947
  function registerConnectorConnectionRunRoutes(app, host, options) {
4862
- return app.post("/api/connectors/:connectorId/connection-runs", async (context) => {
4948
+ return app.get("/api/connectors/:connectorId/connection-runs", async (context) => {
4949
+ const { params, set } = context;
4950
+ try {
4951
+ const runtime = connectorRouteRuntime(host, requireRequestSixb(context), params.connectorId);
4952
+ return (await runtime.listPendingConnectionRuns(params.connectorId)).map(serializeConnectorConnectionRun);
4953
+ } catch (error) {
4954
+ return handleConnectorRouteError(error, set);
4955
+ }
4956
+ }, {
4957
+ params: ConnectorConnectionParamsSchema.pick({ connectorId: true }),
4958
+ response: {
4959
+ 200: ConnectorConnectionRunSchema.array(),
4960
+ 400: ConnectorBadRequestResponseSchema,
4961
+ 403: ErrorResponseSchema,
4962
+ 404: ConnectorNotFoundResponseSchema,
4963
+ 500: ConnectorInternalErrorResponseSchema
4964
+ },
4965
+ detail: {
4966
+ summary: "List the initiating user's pending connector connection runs",
4967
+ tags: [OPENAPI_TAGS.connectorConnectionRuns.name],
4968
+ operationId: "listPendingConnectorConnectionRuns"
4969
+ }
4970
+ }).post("/api/connectors/:connectorId/connection-runs", async (context) => {
4863
4971
  const { params, body, request, set } = context;
4864
4972
  try {
4865
4973
  const runtime = connectorRouteRuntime(host, requireRequestSixb(context), params.connectorId);
@@ -5037,7 +5145,8 @@ function registerConnectorConnectionRunRoutes(app, host, options) {
5037
5145
  operationId: "reauthorizeConnectorConnection",
5038
5146
  security: SIXB_CSRF_SECURITY_REQUIREMENT
5039
5147
  }
5040
- }).get("/auth/connectors/callback", async ({ request, set }) => {
5148
+ }).get("/auth/connectors/callback", async ({ request, set, server }) => {
5149
+ server?.timeout(request, 0);
5041
5150
  let callbackCookie;
5042
5151
  try {
5043
5152
  const parameters = new URL(request.url).searchParams;
@@ -6019,6 +6128,7 @@ async function languageModelDisplay(entry) {
6019
6128
  }
6020
6129
  const gateway = entry.provider === "vercel-ai-gateway";
6021
6130
  const publisherId = gateway ? entry.modelId.split("/")[0] : entry.provider;
6131
+ const via = definition.via ?? (gateway ? "AI Gateway" : undefined);
6022
6132
  const capabilities = definition.capabilities;
6023
6133
  const media = capabilities.inputMediaTypes;
6024
6134
  const input = ["text"];
@@ -6034,8 +6144,8 @@ async function languageModelDisplay(entry) {
6034
6144
  return {
6035
6145
  name: definition.name ?? entry.modelId,
6036
6146
  ...definition.description === undefined ? {} : { description: definition.description },
6037
- publisher: { id: publisherId, name: publisherName(publisherId) },
6038
- ...gateway ? { via: "AI Gateway" } : {},
6147
+ publisher: definition.publisher ?? { id: publisherId, name: publisherName(publisherId) },
6148
+ ...via === undefined ? {} : { via },
6039
6149
  capabilities: {
6040
6150
  input,
6041
6151
  output: ["text"],
@@ -6110,6 +6220,7 @@ import { ZodError as ZodError3, z as z19 } from "zod";
6110
6220
 
6111
6221
  // src/schemas/objects.ts
6112
6222
  import { z as z18 } from "zod";
6223
+ import { zodToJsonSchema } from "zod-to-json-schema";
6113
6224
  var ObjectParamsSchema = z18.object({
6114
6225
  objectTypeId: z18.string().min(1),
6115
6226
  objectId: z18.string().min(1)
@@ -6260,8 +6371,8 @@ var ObjectQuerySchema = z18.lazy(() => z18.discriminatedUnion("kind", [
6260
6371
  z18.object({
6261
6372
  kind: z18.literal("vector"),
6262
6373
  input: ObjectQuerySchema,
6263
- vector: z18.array(z18.number().finite()),
6264
- propertyId: z18.string().min(1),
6374
+ vector: z18.string().min(1).max(8000),
6375
+ profile: z18.string().min(1),
6265
6376
  k: z18.number().int().positive()
6266
6377
  }).strict(),
6267
6378
  z18.object({
@@ -6330,6 +6441,7 @@ var ObjectQueryLinksRequestSchema = z18.object({
6330
6441
  pageToken: z18.string().min(1).optional()
6331
6442
  }).strict();
6332
6443
  var TwinObjectSchema = z18.object({
6444
+ score: z18.number().finite().optional(),
6333
6445
  primaryId: z18.string(),
6334
6446
  objectTypeId: z18.string(),
6335
6447
  properties: z18.record(z18.unknown()),
@@ -6342,7 +6454,10 @@ var ObjectListResponseSchema = z18.object({
6342
6454
  total: z18.number()
6343
6455
  });
6344
6456
  var anyJsonValueSchema = {};
6345
- var stringArraySchema = { type: "array", items: { type: "string", minLength: 1 } };
6457
+ var stringArraySchema = {
6458
+ type: "array",
6459
+ items: { type: "string", minLength: 1 }
6460
+ };
6346
6461
  var objectQueryRef = { $ref: "#/components/schemas/ObjectQuery" };
6347
6462
  var objectQueryPredicateRef = { $ref: "#/components/schemas/ObjectQueryPredicate" };
6348
6463
  var objectQuerySortFieldRef = { $ref: "#/components/schemas/ObjectQuerySortField" };
@@ -6362,6 +6477,7 @@ var ObjectQueryOpenApiSchemas = {
6362
6477
  required: ["primaryId", "objectTypeId", "properties", "createdAt", "updatedAt"],
6363
6478
  additionalProperties: false,
6364
6479
  properties: {
6480
+ score: { type: "number" },
6365
6481
  primaryId: { type: "string" },
6366
6482
  objectTypeId: { type: "string" },
6367
6483
  properties: { type: "object", additionalProperties: true },
@@ -6518,6 +6634,11 @@ var ObjectQueryOpenApiSchemas = {
6518
6634
  nextPageToken: { type: "string" }
6519
6635
  }
6520
6636
  },
6637
+ AiUsageLimitErrorResponse: zodToJsonSchema(AiUsageLimitErrorResponseSchema, {
6638
+ target: "openApi3",
6639
+ $refStrategy: "none",
6640
+ override: jsonValueOpenApiOverride
6641
+ }),
6521
6642
  ObjectQueryErrorResponse: {
6522
6643
  type: "object",
6523
6644
  required: ["error"],
@@ -6656,13 +6777,13 @@ var ObjectQueryOpenApiSchemas = {
6656
6777
  },
6657
6778
  {
6658
6779
  type: "object",
6659
- required: ["kind", "input", "vector", "propertyId", "k"],
6780
+ required: ["kind", "input", "vector", "profile", "k"],
6660
6781
  additionalProperties: false,
6661
6782
  properties: {
6662
6783
  kind: { type: "string", enum: ["vector"] },
6663
6784
  input: objectQueryRef,
6664
- vector: { type: "array", items: { type: "number" } },
6665
- propertyId: { type: "string", minLength: 1 },
6785
+ vector: { type: "string", minLength: 1, maxLength: 8000 },
6786
+ profile: { type: "string", minLength: 1 },
6666
6787
  k: { type: "integer", minimum: 1 }
6667
6788
  }
6668
6789
  },
@@ -6850,6 +6971,7 @@ var ObjectFileContentQuerySchema = FileContentQuerySchema.extend({
6850
6971
  });
6851
6972
  function serializeObject(row) {
6852
6973
  return {
6974
+ ...row.score === undefined ? {} : { score: row.score },
6853
6975
  primaryId: row.primaryId,
6854
6976
  objectTypeId: row.objectTypeId,
6855
6977
  properties: row.properties,
@@ -6940,8 +7062,7 @@ function handleObjectQueryError(error, set) {
6940
7062
  ]
6941
7063
  };
6942
7064
  }
6943
- set.status = 500;
6944
- return { error: error instanceof Error ? error.message : String(error) };
7065
+ return handleRouteError(error, set);
6945
7066
  }
6946
7067
  function formatZodIssuePath(path) {
6947
7068
  if (path.length === 0)
@@ -7098,7 +7219,8 @@ function registerObjectRoutes(app, host) {
7098
7219
  const parsed = ObjectQueryRequestSchema.parse(body);
7099
7220
  const result = await requireRequestSixb(context).objects.executeQuery({
7100
7221
  query: parsed.query,
7101
- includeTotal: parsed.includeTotal
7222
+ includeTotal: parsed.includeTotal,
7223
+ signal: context.request.signal
7102
7224
  });
7103
7225
  return {
7104
7226
  objects: result.objects.map(serializeExpandedObject),
@@ -7149,6 +7271,20 @@ function registerObjectRoutes(app, host) {
7149
7271
  }
7150
7272
  }
7151
7273
  },
7274
+ 429: {
7275
+ description: "AI usage limit exceeded or unavailable",
7276
+ headers: {
7277
+ "Retry-After": {
7278
+ description: "Seconds until the budget period resets, when known",
7279
+ schema: { type: "integer" }
7280
+ }
7281
+ },
7282
+ content: {
7283
+ "application/json": {
7284
+ schema: { $ref: "#/components/schemas/AiUsageLimitErrorResponse" }
7285
+ }
7286
+ }
7287
+ },
7152
7288
  500: {
7153
7289
  description: "Response for status 500",
7154
7290
  content: {
@@ -7273,6 +7409,20 @@ function registerObjectRoutes(app, host) {
7273
7409
  }
7274
7410
  }
7275
7411
  },
7412
+ 429: {
7413
+ description: "AI usage limit exceeded or unavailable",
7414
+ headers: {
7415
+ "Retry-After": {
7416
+ description: "Seconds until the budget period resets, when known",
7417
+ schema: { type: "integer" }
7418
+ }
7419
+ },
7420
+ content: {
7421
+ "application/json": {
7422
+ schema: { $ref: "#/components/schemas/AiUsageLimitErrorResponse" }
7423
+ }
7424
+ }
7425
+ },
7276
7426
  500: {
7277
7427
  description: "Response for status 500",
7278
7428
  content: {
@@ -7334,6 +7484,20 @@ function registerObjectRoutes(app, host) {
7334
7484
  }
7335
7485
  }
7336
7486
  },
7487
+ 429: {
7488
+ description: "AI usage limit exceeded or unavailable",
7489
+ headers: {
7490
+ "Retry-After": {
7491
+ description: "Seconds until the budget period resets, when known",
7492
+ schema: { type: "integer" }
7493
+ }
7494
+ },
7495
+ content: {
7496
+ "application/json": {
7497
+ schema: { $ref: "#/components/schemas/AiUsageLimitErrorResponse" }
7498
+ }
7499
+ }
7500
+ },
7337
7501
  500: {
7338
7502
  description: "Response for status 500",
7339
7503
  content: {
@@ -7506,10 +7670,18 @@ function serializeSearch(search) {
7506
7670
  title: search.title,
7507
7671
  defaultText: search.defaultText ? [...search.defaultText] : undefined,
7508
7672
  exact: search.exact ? [...search.exact] : undefined,
7509
- vector: search.vector ? {
7510
- property: search.vector.property,
7511
- source: [...search.vector.source]
7512
- } : undefined
7673
+ vectors: search.vectors ? Object.fromEntries(Object.entries(search.vectors).map(([name, profile]) => [
7674
+ name,
7675
+ {
7676
+ source: [...profile.source],
7677
+ model: {
7678
+ providerId: profile.model.providerId,
7679
+ modelId: profile.model.modelId,
7680
+ dimensions: profile.model.definition.dimensions,
7681
+ representation: profile.model.definition.representation
7682
+ }
7683
+ }
7684
+ ])) : undefined
7513
7685
  };
7514
7686
  }
7515
7687
  function serializeObjectType(execution, objectType) {
@@ -14505,6 +14677,7 @@ function createSixbApi(server) {
14505
14677
  app.use(openapi({
14506
14678
  path: "/docs",
14507
14679
  provider: "swagger-ui",
14680
+ openapiVersion: "3.0.3",
14508
14681
  documentation: {
14509
14682
  info: {
14510
14683
  title: "Sixb API",
@@ -14525,7 +14698,7 @@ function createSixbApi(server) {
14525
14698
  withCredentials: true
14526
14699
  },
14527
14700
  mapJsonSchema: {
14528
- zod: (schema) => zodToJsonSchema(schema, {
14701
+ zod: (schema) => zodToJsonSchema2(schema, {
14529
14702
  $refStrategy: "none",
14530
14703
  target: "openApi3",
14531
14704
  override: jsonValueOpenApiOverride
@@ -14630,4 +14803,4 @@ export {
14630
14803
  createSixbServer
14631
14804
  };
14632
14805
 
14633
- //# debugId=168374855DD168B264756E2164756E21
14806
+ //# debugId=F9832BC92C38240664756E2164756E21