@sixb/server 0.1.11 → 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 (38) hide show
  1. package/dist/index.js +147 -27
  2. package/dist/index.js.map +11 -11
  3. package/dist/routes/agents.d.ts +121 -34
  4. package/dist/routes/agents.d.ts.map +1 -1
  5. package/dist/routes/ai-accounting.d.ts.map +1 -1
  6. package/dist/routes/datasets.d.ts +8 -8
  7. package/dist/routes/models.d.ts +1 -1
  8. package/dist/routes/objects.d.ts +16 -5
  9. package/dist/routes/objects.d.ts.map +1 -1
  10. package/dist/routes/ontology.d.ts +24 -12
  11. package/dist/routes/ontology.d.ts.map +1 -1
  12. package/dist/routes/syncs.d.ts +5 -5
  13. package/dist/routes/workflows.d.ts +6 -6
  14. package/dist/schemas/agents.d.ts +205 -100
  15. package/dist/schemas/agents.d.ts.map +1 -1
  16. package/dist/schemas/ai-accounting.d.ts +692 -104
  17. package/dist/schemas/ai-accounting.d.ts.map +1 -1
  18. package/dist/schemas/ai-usage.d.ts +2 -2
  19. package/dist/schemas/common.d.ts +15 -0
  20. package/dist/schemas/common.d.ts.map +1 -1
  21. package/dist/schemas/datasets.d.ts +22 -22
  22. package/dist/schemas/models.d.ts +8 -8
  23. package/dist/schemas/objects.d.ts +8 -0
  24. package/dist/schemas/objects.d.ts.map +1 -1
  25. package/dist/schemas/ontology.d.ts +99 -49
  26. package/dist/schemas/ontology.d.ts.map +1 -1
  27. package/dist/schemas/syncs.d.ts +12 -12
  28. package/dist/schemas/workflows.d.ts +50 -50
  29. package/package.json +5 -5
  30. package/src/routes/agents.ts +48 -6
  31. package/src/routes/ai-accounting.ts +1 -0
  32. package/src/routes/objects.ts +46 -2
  33. package/src/routes/ontology.ts +15 -5
  34. package/src/schemas/agents.ts +9 -0
  35. package/src/schemas/ai-accounting.ts +19 -1
  36. package/src/schemas/common.ts +5 -0
  37. package/src/schemas/objects.ts +18 -6
  38. package/src/schemas/ontology.ts +15 -6
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 {
@@ -1468,6 +1468,10 @@ var jsonValueOpenApiOverride = (def) => {
1468
1468
  }
1469
1469
  return ignoreOverride;
1470
1470
  };
1471
+ var AiUsageLimitErrorResponseSchema = codedErrorResponseSchema([
1472
+ "ai.usage_limit_exceeded",
1473
+ "ai.usage_limit_unavailable"
1474
+ ]).extend({ details: JsonValueSchema.optional() });
1471
1475
 
1472
1476
  // src/schemas/ontology.ts
1473
1477
  import { z as z2 } from "zod";
@@ -1489,7 +1493,6 @@ var PropertyDefinitionSchema = z2.object({
1489
1493
  text: z2.boolean().optional(),
1490
1494
  exact: z2.boolean().optional(),
1491
1495
  facet: z2.boolean().optional(),
1492
- vector: z2.boolean().optional(),
1493
1496
  weight: z2.number().optional()
1494
1497
  }).optional()
1495
1498
  });
@@ -1527,10 +1530,15 @@ var ObjectTypeSchema = z2.object({
1527
1530
  title: z2.string().optional(),
1528
1531
  defaultText: z2.array(z2.string()).optional(),
1529
1532
  exact: z2.array(z2.string()).optional(),
1530
- vector: z2.object({
1531
- property: z2.string(),
1532
- source: z2.array(z2.string())
1533
- }).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()
1534
1542
  }).optional(),
1535
1543
  links: z2.array(LinkDefinitionSchema),
1536
1544
  actions: z2.array(ActionSchema)
@@ -3015,7 +3023,19 @@ var AiCostSummarySchema = z8.object({
3015
3023
  });
3016
3024
  var AiAccountingAggregateSchema = z8.object({
3017
3025
  modelCallCount: z8.number().int().nonnegative(),
3018
- 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
+ }),
3019
3039
  costs: AiCostSummarySchema
3020
3040
  });
3021
3041
  var AiAccountingOverviewResponseSchema = z8.object({
@@ -3257,13 +3277,20 @@ var AgentThreadListQuerySchema = z9.object({
3257
3277
  }).strict();
3258
3278
  var CreateAgentThreadBodySchema = z9.object({
3259
3279
  title: z9.string().trim().min(1).optional(),
3260
- threadId: z9.string().trim().min(1).optional()
3280
+ threadId: z9.string().trim().min(1).optional(),
3281
+ sandbox: z9.record(z9.string(), JsonValueSchema).optional()
3261
3282
  }).strict();
3262
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(),
3263
3289
  id: z9.string(),
3264
3290
  projectId: z9.string(),
3265
3291
  ownerPrincipal: AgentPrincipalSchema,
3266
3292
  title: z9.string().optional(),
3293
+ sandboxParams: z9.record(z9.string(), JsonValueSchema).optional(),
3267
3294
  status: AgentThreadStatusSchema,
3268
3295
  activeRunId: z9.string().nullable(),
3269
3296
  lastMessageAt: z9.string().optional(),
@@ -3434,16 +3461,18 @@ var AgentRunListResponseSchema = z9.object({
3434
3461
  var AgentMessageFileContentQuerySchema = FileContentQuerySchema.extend({
3435
3462
  path: z10.string().min(1).regex(/^\/parts(?:\/|$)/, "Agent message file content paths must start with /parts/")
3436
3463
  });
3437
- var AiUsageLimitErrorResponseSchema = codedErrorResponseSchema([
3438
- "ai.usage_limit_exceeded",
3439
- "ai.usage_limit_unavailable"
3440
- ]).extend({ details: JsonValueSchema.optional() });
3441
3464
  function serializeThread(thread) {
3442
3465
  return AgentThreadSchema.parse({
3443
3466
  id: thread.id,
3444
3467
  projectId: thread.projectId,
3445
3468
  ownerPrincipal: thread.ownerPrincipal,
3446
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
+ },
3447
3476
  status: thread.status,
3448
3477
  activeRunId: thread.activeRunId,
3449
3478
  lastMessageAt: thread.lastMessageAt ? toIsoString(thread.lastMessageAt) : undefined,
@@ -3535,12 +3564,15 @@ function handleAgentRouteError(error, set) {
3535
3564
  break;
3536
3565
  case "active_run_exists":
3537
3566
  case "run_not_retryable":
3567
+ case "sandbox_execution_unavailable":
3538
3568
  set.status = 409;
3539
3569
  break;
3540
3570
  case "authority_not_inheritable":
3541
3571
  set.status = 403;
3542
3572
  break;
3543
3573
  case "storage_unavailable":
3574
+ case "sandbox_not_configured":
3575
+ case "invalid_sandbox_params":
3544
3576
  case "agent_selector_removed":
3545
3577
  case "invalid_context":
3546
3578
  case "invalid_model_selection":
@@ -3668,7 +3700,8 @@ function registerAgentRoutes(app, host) {
3668
3700
  }
3669
3701
  const thread = await sixb.agent.threads.create({
3670
3702
  ...parsed.threadId === undefined ? {} : { id: parsed.threadId },
3671
- ...parsed.title === undefined ? {} : { title: parsed.title }
3703
+ ...parsed.title === undefined ? {} : { title: parsed.title },
3704
+ ...parsed.sandbox === undefined ? {} : { sandbox: parsed.sandbox }
3672
3705
  });
3673
3706
  set.status = 201;
3674
3707
  return CreateAgentThreadResponseSchema.parse({ thread: serializeThread(thread) });
@@ -3720,6 +3753,33 @@ function registerAgentRoutes(app, host) {
3720
3753
  tags: [OPENAPI_TAGS.agentThreads.name],
3721
3754
  operationId: "getAgentThread"
3722
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
+ }
3723
3783
  }).get("/api/agent-threads/:threadId/messages", async (context) => {
3724
3784
  const { params, query, set } = context;
3725
3785
  const sixb = requireRequestSixb(context);
@@ -4145,6 +4205,7 @@ function serializeAggregate(aggregate) {
4145
4205
  return {
4146
4206
  modelCallCount: aggregate.modelCallCount,
4147
4207
  usage: aggregate.usage,
4208
+ usageCoverage: aggregate.usageCoverage,
4148
4209
  costs: aggregate.costs
4149
4210
  };
4150
4211
  }
@@ -6159,6 +6220,7 @@ import { ZodError as ZodError3, z as z19 } from "zod";
6159
6220
 
6160
6221
  // src/schemas/objects.ts
6161
6222
  import { z as z18 } from "zod";
6223
+ import { zodToJsonSchema } from "zod-to-json-schema";
6162
6224
  var ObjectParamsSchema = z18.object({
6163
6225
  objectTypeId: z18.string().min(1),
6164
6226
  objectId: z18.string().min(1)
@@ -6309,8 +6371,8 @@ var ObjectQuerySchema = z18.lazy(() => z18.discriminatedUnion("kind", [
6309
6371
  z18.object({
6310
6372
  kind: z18.literal("vector"),
6311
6373
  input: ObjectQuerySchema,
6312
- vector: z18.array(z18.number().finite()),
6313
- propertyId: z18.string().min(1),
6374
+ vector: z18.string().min(1).max(8000),
6375
+ profile: z18.string().min(1),
6314
6376
  k: z18.number().int().positive()
6315
6377
  }).strict(),
6316
6378
  z18.object({
@@ -6379,6 +6441,7 @@ var ObjectQueryLinksRequestSchema = z18.object({
6379
6441
  pageToken: z18.string().min(1).optional()
6380
6442
  }).strict();
6381
6443
  var TwinObjectSchema = z18.object({
6444
+ score: z18.number().finite().optional(),
6382
6445
  primaryId: z18.string(),
6383
6446
  objectTypeId: z18.string(),
6384
6447
  properties: z18.record(z18.unknown()),
@@ -6414,6 +6477,7 @@ var ObjectQueryOpenApiSchemas = {
6414
6477
  required: ["primaryId", "objectTypeId", "properties", "createdAt", "updatedAt"],
6415
6478
  additionalProperties: false,
6416
6479
  properties: {
6480
+ score: { type: "number" },
6417
6481
  primaryId: { type: "string" },
6418
6482
  objectTypeId: { type: "string" },
6419
6483
  properties: { type: "object", additionalProperties: true },
@@ -6570,6 +6634,11 @@ var ObjectQueryOpenApiSchemas = {
6570
6634
  nextPageToken: { type: "string" }
6571
6635
  }
6572
6636
  },
6637
+ AiUsageLimitErrorResponse: zodToJsonSchema(AiUsageLimitErrorResponseSchema, {
6638
+ target: "openApi3",
6639
+ $refStrategy: "none",
6640
+ override: jsonValueOpenApiOverride
6641
+ }),
6573
6642
  ObjectQueryErrorResponse: {
6574
6643
  type: "object",
6575
6644
  required: ["error"],
@@ -6708,13 +6777,13 @@ var ObjectQueryOpenApiSchemas = {
6708
6777
  },
6709
6778
  {
6710
6779
  type: "object",
6711
- required: ["kind", "input", "vector", "propertyId", "k"],
6780
+ required: ["kind", "input", "vector", "profile", "k"],
6712
6781
  additionalProperties: false,
6713
6782
  properties: {
6714
6783
  kind: { type: "string", enum: ["vector"] },
6715
6784
  input: objectQueryRef,
6716
- vector: { type: "array", items: { type: "number" } },
6717
- propertyId: { type: "string", minLength: 1 },
6785
+ vector: { type: "string", minLength: 1, maxLength: 8000 },
6786
+ profile: { type: "string", minLength: 1 },
6718
6787
  k: { type: "integer", minimum: 1 }
6719
6788
  }
6720
6789
  },
@@ -6902,6 +6971,7 @@ var ObjectFileContentQuerySchema = FileContentQuerySchema.extend({
6902
6971
  });
6903
6972
  function serializeObject(row) {
6904
6973
  return {
6974
+ ...row.score === undefined ? {} : { score: row.score },
6905
6975
  primaryId: row.primaryId,
6906
6976
  objectTypeId: row.objectTypeId,
6907
6977
  properties: row.properties,
@@ -6992,8 +7062,7 @@ function handleObjectQueryError(error, set) {
6992
7062
  ]
6993
7063
  };
6994
7064
  }
6995
- set.status = 500;
6996
- return { error: error instanceof Error ? error.message : String(error) };
7065
+ return handleRouteError(error, set);
6997
7066
  }
6998
7067
  function formatZodIssuePath(path) {
6999
7068
  if (path.length === 0)
@@ -7150,7 +7219,8 @@ function registerObjectRoutes(app, host) {
7150
7219
  const parsed = ObjectQueryRequestSchema.parse(body);
7151
7220
  const result = await requireRequestSixb(context).objects.executeQuery({
7152
7221
  query: parsed.query,
7153
- includeTotal: parsed.includeTotal
7222
+ includeTotal: parsed.includeTotal,
7223
+ signal: context.request.signal
7154
7224
  });
7155
7225
  return {
7156
7226
  objects: result.objects.map(serializeExpandedObject),
@@ -7201,6 +7271,20 @@ function registerObjectRoutes(app, host) {
7201
7271
  }
7202
7272
  }
7203
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
+ },
7204
7288
  500: {
7205
7289
  description: "Response for status 500",
7206
7290
  content: {
@@ -7325,6 +7409,20 @@ function registerObjectRoutes(app, host) {
7325
7409
  }
7326
7410
  }
7327
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
+ },
7328
7426
  500: {
7329
7427
  description: "Response for status 500",
7330
7428
  content: {
@@ -7386,6 +7484,20 @@ function registerObjectRoutes(app, host) {
7386
7484
  }
7387
7485
  }
7388
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
+ },
7389
7501
  500: {
7390
7502
  description: "Response for status 500",
7391
7503
  content: {
@@ -7558,10 +7670,18 @@ function serializeSearch(search) {
7558
7670
  title: search.title,
7559
7671
  defaultText: search.defaultText ? [...search.defaultText] : undefined,
7560
7672
  exact: search.exact ? [...search.exact] : undefined,
7561
- vector: search.vector ? {
7562
- property: search.vector.property,
7563
- source: [...search.vector.source]
7564
- } : 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
7565
7685
  };
7566
7686
  }
7567
7687
  function serializeObjectType(execution, objectType) {
@@ -14578,7 +14698,7 @@ function createSixbApi(server) {
14578
14698
  withCredentials: true
14579
14699
  },
14580
14700
  mapJsonSchema: {
14581
- zod: (schema) => zodToJsonSchema(schema, {
14701
+ zod: (schema) => zodToJsonSchema2(schema, {
14582
14702
  $refStrategy: "none",
14583
14703
  target: "openApi3",
14584
14704
  override: jsonValueOpenApiOverride
@@ -14683,4 +14803,4 @@ export {
14683
14803
  createSixbServer
14684
14804
  };
14685
14805
 
14686
- //# debugId=6D4551964DA2E95864756E2164756E21
14806
+ //# debugId=F9832BC92C38240664756E2164756E21