@sixb/server 0.1.11 → 0.1.13

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 (104) hide show
  1. package/README.md +5 -4
  2. package/dist/auth/access-token-boundary.d.ts +13 -9
  3. package/dist/auth/access-token-boundary.d.ts.map +1 -1
  4. package/dist/auth/client-address.d.ts +12 -0
  5. package/dist/auth/client-address.d.ts.map +1 -0
  6. package/dist/auth/guard.d.ts.map +1 -1
  7. package/dist/auth/public-routes.d.ts +5 -0
  8. package/dist/auth/public-routes.d.ts.map +1 -1
  9. package/dist/auth/rate-limit.d.ts +15 -0
  10. package/dist/auth/rate-limit.d.ts.map +1 -0
  11. package/dist/auth/scope.d.ts +8 -3
  12. package/dist/auth/scope.d.ts.map +1 -1
  13. package/dist/auth/shared-access.d.ts.map +1 -1
  14. package/dist/index.js +723 -480
  15. package/dist/index.js.map +43 -41
  16. package/dist/openapi/security.d.ts +34 -10
  17. package/dist/openapi/security.d.ts.map +1 -1
  18. package/dist/routes/agents.d.ts +121 -34
  19. package/dist/routes/agents.d.ts.map +1 -1
  20. package/dist/routes/ai-accounting.d.ts.map +1 -1
  21. package/dist/routes/auth.d.ts +64 -17
  22. package/dist/routes/auth.d.ts.map +1 -1
  23. package/dist/routes/connectors.d.ts.map +1 -1
  24. package/dist/routes/datasets.d.ts +8 -8
  25. package/dist/routes/events.d.ts +0 -4
  26. package/dist/routes/events.d.ts.map +1 -1
  27. package/dist/routes/files.d.ts +15 -2
  28. package/dist/routes/files.d.ts.map +1 -1
  29. package/dist/routes/models.d.ts +7 -7
  30. package/dist/routes/objects.d.ts +16 -5
  31. package/dist/routes/objects.d.ts.map +1 -1
  32. package/dist/routes/ontology.d.ts +37 -13
  33. package/dist/routes/ontology.d.ts.map +1 -1
  34. package/dist/routes/shared-access.d.ts.map +1 -1
  35. package/dist/routes/syncs.d.ts +5 -5
  36. package/dist/routes/workflows.d.ts +36 -36
  37. package/dist/routes/workflows.d.ts.map +1 -1
  38. package/dist/routes/ws/agents.d.ts +2 -3
  39. package/dist/routes/ws/agents.d.ts.map +1 -1
  40. package/dist/schemas/agents.d.ts +205 -100
  41. package/dist/schemas/agents.d.ts.map +1 -1
  42. package/dist/schemas/ai-accounting.d.ts +692 -104
  43. package/dist/schemas/ai-accounting.d.ts.map +1 -1
  44. package/dist/schemas/ai-usage.d.ts +2 -2
  45. package/dist/schemas/auth.d.ts +241 -85
  46. package/dist/schemas/auth.d.ts.map +1 -1
  47. package/dist/schemas/common.d.ts +26 -0
  48. package/dist/schemas/common.d.ts.map +1 -1
  49. package/dist/schemas/datasets.d.ts +22 -22
  50. package/dist/schemas/events.d.ts +74 -44
  51. package/dist/schemas/events.d.ts.map +1 -1
  52. package/dist/schemas/models.d.ts +42 -42
  53. package/dist/schemas/objects.d.ts +8 -0
  54. package/dist/schemas/objects.d.ts.map +1 -1
  55. package/dist/schemas/ontology.d.ts +259 -49
  56. package/dist/schemas/ontology.d.ts.map +1 -1
  57. package/dist/schemas/syncs.d.ts +12 -12
  58. package/dist/schemas/workflows.d.ts +230 -240
  59. package/dist/schemas/workflows.d.ts.map +1 -1
  60. package/dist/server.d.ts +6 -0
  61. package/dist/server.d.ts.map +1 -1
  62. package/dist/utils/ws.d.ts +1 -2
  63. package/dist/utils/ws.d.ts.map +1 -1
  64. package/package.json +5 -5
  65. package/src/auth/access-token-boundary.ts +31 -30
  66. package/src/auth/client-address.ts +67 -0
  67. package/src/auth/guard.ts +13 -4
  68. package/src/auth/public-routes.ts +9 -2
  69. package/src/auth/rate-limit.ts +43 -0
  70. package/src/auth/scope.ts +13 -3
  71. package/src/auth/shared-access.ts +0 -3
  72. package/src/openapi/security.ts +37 -17
  73. package/src/routes/action-runs.ts +5 -5
  74. package/src/routes/actions.ts +4 -4
  75. package/src/routes/agents.ts +56 -14
  76. package/src/routes/ai-accounting.ts +11 -10
  77. package/src/routes/auth.ts +331 -432
  78. package/src/routes/connector-connection-runs.ts +5 -5
  79. package/src/routes/connector-connections.ts +3 -3
  80. package/src/routes/connectors.ts +2 -2
  81. package/src/routes/events.ts +2 -2
  82. package/src/routes/files.ts +30 -15
  83. package/src/routes/links.ts +3 -3
  84. package/src/routes/logs.ts +2 -2
  85. package/src/routes/objects.ts +58 -14
  86. package/src/routes/ontology.ts +42 -14
  87. package/src/routes/pipelines.ts +2 -2
  88. package/src/routes/project.ts +2 -2
  89. package/src/routes/share-grants.ts +4 -4
  90. package/src/routes/shared-access.ts +3 -2
  91. package/src/routes/syncs.ts +2 -2
  92. package/src/routes/telemetry.ts +5 -5
  93. package/src/routes/workflows.ts +18 -19
  94. package/src/routes/ws/agents.ts +4 -5
  95. package/src/schemas/agents.ts +9 -0
  96. package/src/schemas/ai-accounting.ts +19 -1
  97. package/src/schemas/auth.ts +27 -8
  98. package/src/schemas/common.ts +11 -0
  99. package/src/schemas/events.ts +35 -7
  100. package/src/schemas/objects.ts +18 -6
  101. package/src/schemas/ontology.ts +31 -7
  102. package/src/schemas/workflows.ts +4 -9
  103. package/src/server.ts +35 -5
  104. package/src/utils/ws.ts +2 -3
@@ -13,7 +13,7 @@ import {
13
13
  serializeConnectorConnection,
14
14
  serializeConnectorConnectionRun,
15
15
  } from "../connectors/http"
16
- import { SIXB_CSRF_SECURITY_REQUIREMENT } from "../openapi/security"
16
+ import { SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT } from "../openapi/security"
17
17
  import { OPENAPI_TAGS } from "../openapi/tags"
18
18
  import { ErrorResponseSchema } from "../schemas/common"
19
19
  import {
@@ -132,7 +132,7 @@ export function registerConnectorConnectionRunRoutes(
132
132
  summary: "Start a connector connection run",
133
133
  tags: [OPENAPI_TAGS.connectorConnectionRuns.name],
134
134
  operationId: "startConnectorConnectionRun",
135
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
135
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
136
136
  },
137
137
  }
138
138
  )
@@ -209,7 +209,7 @@ export function registerConnectorConnectionRunRoutes(
209
209
  summary: "Add a connector connection from an existing authorization",
210
210
  tags: [OPENAPI_TAGS.connectorConnectionRuns.name],
211
211
  operationId: "addConnectorConnection",
212
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
212
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
213
213
  },
214
214
  }
215
215
  )
@@ -249,7 +249,7 @@ export function registerConnectorConnectionRunRoutes(
249
249
  summary: "Select a connector account",
250
250
  tags: [OPENAPI_TAGS.connectorConnectionRuns.name],
251
251
  operationId: "selectConnectorConnectionRunAccount",
252
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
252
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
253
253
  },
254
254
  }
255
255
  )
@@ -309,7 +309,7 @@ export function registerConnectorConnectionRunRoutes(
309
309
  summary: "Reauthorize a connector connection",
310
310
  tags: [OPENAPI_TAGS.connectorConnectionRuns.name],
311
311
  operationId: "reauthorizeConnectorConnection",
312
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
312
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
313
313
  },
314
314
  }
315
315
  )
@@ -6,7 +6,7 @@ import {
6
6
  handleConnectorRouteError,
7
7
  serializeConnectorConnection,
8
8
  } from "../connectors/http"
9
- import { SIXB_CSRF_SECURITY_REQUIREMENT } from "../openapi/security"
9
+ import { SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT } from "../openapi/security"
10
10
  import { OPENAPI_TAGS } from "../openapi/tags"
11
11
  import { ErrorResponseSchema, SuccessResponseSchema } from "../schemas/common"
12
12
  import {
@@ -90,7 +90,7 @@ export function registerConnectorConnectionRoutes(app: Elysia, host: SixbHostVie
90
90
  summary: "Disconnect a connector account",
91
91
  tags: [OPENAPI_TAGS.connectorConnections.name],
92
92
  operationId: "disconnectConnectorConnection",
93
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
93
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
94
94
  },
95
95
  }
96
96
  )
@@ -128,7 +128,7 @@ export function registerConnectorConnectionRoutes(app: Elysia, host: SixbHostVie
128
128
  summary: "Revoke a connector authorization",
129
129
  tags: [OPENAPI_TAGS.connectorConnections.name],
130
130
  operationId: "revokeConnectorConnection",
131
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
131
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
132
132
  },
133
133
  }
134
134
  )
@@ -1,4 +1,4 @@
1
- import type { OntologySource, SixbHostView } from "@sixb/core"
1
+ import type { SixbHostView } from "@sixb/core"
2
2
  import { isOAuthConnectorDefinition } from "@sixb/core/internal/connector-connections"
3
3
  import type { Sixb } from "@sixb/core/internal/request-execution"
4
4
  import type { Elysia } from "elysia"
@@ -10,7 +10,7 @@ import { ConnectorParamsSchema, ConnectorSchema } from "../schemas/connectors"
10
10
  function serializeConnector(
11
11
  connector: ReturnType<SixbHostView["definitions"]["connectors"]["list"]>[number],
12
12
  host: SixbHostView,
13
- execution: Sixb<readonly OntologySource[]>
13
+ execution: Sixb
14
14
  ) {
15
15
  return {
16
16
  id: connector.id,
@@ -1,6 +1,6 @@
1
1
  import { AuthorizationError, type SixbHostView } from "@sixb/core"
2
2
  import type { Elysia } from "elysia"
3
- import { bearerSecurityRequirement } from "../auth/access-token-boundary"
3
+ import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
4
4
  import { requireRequestSixb } from "../auth/scope"
5
5
  import { OPENAPI_TAGS } from "../openapi/tags"
6
6
  import { ErrorResponseSchema } from "../schemas/common"
@@ -48,7 +48,7 @@ export function registerEventRoutes(app: Elysia, _host: SixbHostView) {
48
48
  summary: "Read domain events",
49
49
  tags: [OPENAPI_TAGS.events.name],
50
50
  operationId: "listEvents",
51
- security: bearerSecurityRequirement("listEvents"),
51
+ security: accessTokenSecurityRequirement("listEvents"),
52
52
  },
53
53
  }
54
54
  )
@@ -2,7 +2,6 @@ import {
2
2
  type BlobDigest,
3
3
  DEFAULT_SIMPLE_FILE_UPLOAD_BYTES,
4
4
  type FileRef,
5
- InMemoryFileUploadSessions,
6
5
  type SixbHostView,
7
6
  SYSTEM_PRINCIPAL,
8
7
  } from "@sixb/core"
@@ -10,9 +9,9 @@ import { computeBlobDigest, supportsDirectUpload } from "@sixb/core/blob-storage
10
9
  import { createFileUploadId, createUploadExpiresAt } from "@sixb/core/internal/storage"
11
10
  import { type FileUploadSession, FileUploadSessionError } from "@sixb/core/storage"
12
11
  import type { Elysia } from "elysia"
13
- import { bearerSecurityRequirement } from "../auth/access-token-boundary"
12
+ import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
14
13
  import { requireRequestSixb } from "../auth/scope"
15
- import { SIXB_CSRF_SECURITY_REQUIREMENT } from "../openapi/security"
14
+ import { SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT } from "../openapi/security"
16
15
  import { OPENAPI_TAGS } from "../openapi/tags"
17
16
  import { ErrorResponseSchema, SuccessResponseSchema } from "../schemas/common"
18
17
  import {
@@ -24,7 +23,7 @@ import {
24
23
  FileUploadPartParamsSchema,
25
24
  SignedFileUploadPartSchema,
26
25
  } from "../schemas/files"
27
- import { handleRouteError } from "../utils/http"
26
+ import { handleRouteError, unconfiguredStorageResponse } from "../utils/http"
28
27
  import { RequestBodyTooLargeError, readRequestBodyWithLimit } from "../utils/request-body"
29
28
  // The simple-upload ceiling lives in @sixb/core so the client staged-switch
30
29
  // threshold and this server limit stay a single source of truth. The body limit
@@ -33,11 +32,7 @@ import { RequestBodyTooLargeError, readRequestBodyWithLimit } from "../utils/req
33
32
  export const DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES = DEFAULT_SIMPLE_FILE_UPLOAD_BYTES + 1024 * 1024
34
33
 
35
34
  export function registerFileRoutes(app: Elysia, host: SixbHostView) {
36
- // Staged/direct-put upload sessions default to an in-memory store: they are NOT
37
- // durable across restart and NOT shared across instances. A durable Pg/Sqlite
38
- // store is a follow-up; deployments needing durability supply their own via
39
- // `host.storage.fileUploadSessions`.
40
- const uploadSessions = host.storage.fileUploadSessions ?? new InMemoryFileUploadSessions()
35
+ const uploadSessions = host.storage.fileUploadSessions
41
36
 
42
37
  return app
43
38
  .post(
@@ -96,7 +91,7 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
96
91
  summary: "Upload a file",
97
92
  tags: [OPENAPI_TAGS.files.name],
98
93
  operationId: "uploadFileRaw",
99
- security: bearerSecurityRequirement("uploadFileRaw"),
94
+ security: accessTokenSecurityRequirement("uploadFileRaw"),
100
95
  requestBody: {
101
96
  required: true,
102
97
  content: {
@@ -125,6 +120,9 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
125
120
  async (context) => {
126
121
  const { body, set } = context
127
122
  try {
123
+ if (!uploadSessions) {
124
+ return unconfiguredStorageResponse(set, "File upload session storage")
125
+ }
128
126
  const parsed = CreateFileUploadBodySchema.parse(body)
129
127
  const principal = requireRequestSixb(context).execution.requestedBy ?? SYSTEM_PRINCIPAL
130
128
  const uploadId = createFileUploadId()
@@ -170,12 +168,13 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
170
168
  response: {
171
169
  201: CreateFileUploadResponseSchema,
172
170
  400: ErrorResponseSchema,
171
+ 501: ErrorResponseSchema,
173
172
  },
174
173
  detail: {
175
174
  summary: "Create a staged file upload",
176
175
  tags: [OPENAPI_TAGS.files.name],
177
176
  operationId: "createFileUpload",
178
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
177
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
179
178
  },
180
179
  }
181
180
  )
@@ -184,6 +183,9 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
184
183
  async (context) => {
185
184
  const { params, request, set } = context
186
185
  try {
186
+ if (!uploadSessions) {
187
+ return unconfiguredStorageResponse(set, "File upload session storage")
188
+ }
187
189
  const principal = requireRequestSixb(context).execution.requestedBy ?? SYSTEM_PRINCIPAL
188
190
  const session = await uploadSessions.getForPrincipal(params.uploadId, principal)
189
191
  if (session.status !== "pending") {
@@ -247,12 +249,13 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
247
249
  404: ErrorResponseSchema,
248
250
  409: ErrorResponseSchema,
249
251
  410: ErrorResponseSchema,
252
+ 501: ErrorResponseSchema,
250
253
  },
251
254
  detail: {
252
255
  summary: "Upload staged file content through Sixb",
253
256
  tags: [OPENAPI_TAGS.files.name],
254
257
  operationId: "uploadFileContent",
255
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
258
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
256
259
  requestBody: {
257
260
  required: true,
258
261
  content: {
@@ -272,6 +275,9 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
272
275
  async (context) => {
273
276
  const { params, set } = context
274
277
  try {
278
+ if (!uploadSessions) {
279
+ return unconfiguredStorageResponse(set, "File upload session storage")
280
+ }
275
281
  const principal = requireRequestSixb(context).execution.requestedBy ?? SYSTEM_PRINCIPAL
276
282
  const session = await uploadSessions.getForPrincipal(params.uploadId, principal)
277
283
  if (session.status !== "pending") {
@@ -316,12 +322,13 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
316
322
  404: ErrorResponseSchema,
317
323
  409: ErrorResponseSchema,
318
324
  410: ErrorResponseSchema,
325
+ 501: ErrorResponseSchema,
319
326
  },
320
327
  detail: {
321
328
  summary: "Sign a staged multipart upload part",
322
329
  tags: [OPENAPI_TAGS.files.name],
323
330
  operationId: "signFileUploadPart",
324
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
331
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
325
332
  },
326
333
  }
327
334
  )
@@ -330,6 +337,9 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
330
337
  async (context) => {
331
338
  const { body, params, set } = context
332
339
  try {
340
+ if (!uploadSessions) {
341
+ return unconfiguredStorageResponse(set, "File upload session storage")
342
+ }
333
343
  const principal = requireRequestSixb(context).execution.requestedBy ?? SYSTEM_PRINCIPAL
334
344
  const parsed = CompleteFileUploadBodySchema.parse(body ?? {})
335
345
  const session = await uploadSessions.getForPrincipal(params.uploadId, principal)
@@ -385,12 +395,13 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
385
395
  404: ErrorResponseSchema,
386
396
  409: ErrorResponseSchema,
387
397
  410: ErrorResponseSchema,
398
+ 501: ErrorResponseSchema,
388
399
  },
389
400
  detail: {
390
401
  summary: "Complete a staged file upload",
391
402
  tags: [OPENAPI_TAGS.files.name],
392
403
  operationId: "completeFileUpload",
393
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
404
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
394
405
  },
395
406
  }
396
407
  )
@@ -399,6 +410,9 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
399
410
  async (context) => {
400
411
  const { params, set } = context
401
412
  try {
413
+ if (!uploadSessions) {
414
+ return unconfiguredStorageResponse(set, "File upload session storage")
415
+ }
402
416
  const principal = requireRequestSixb(context).execution.requestedBy ?? SYSTEM_PRINCIPAL
403
417
  const session = await uploadSessions.getForPrincipal(params.uploadId, principal)
404
418
 
@@ -439,12 +453,13 @@ export function registerFileRoutes(app: Elysia, host: SixbHostView) {
439
453
  404: ErrorResponseSchema,
440
454
  409: ErrorResponseSchema,
441
455
  410: ErrorResponseSchema,
456
+ 501: ErrorResponseSchema,
442
457
  },
443
458
  detail: {
444
459
  summary: "Abort a staged file upload",
445
460
  tags: [OPENAPI_TAGS.files.name],
446
461
  operationId: "abortFileUpload",
447
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
462
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
448
463
  },
449
464
  }
450
465
  )
@@ -1,6 +1,6 @@
1
1
  import type { SixbHostView } from "@sixb/core"
2
2
  import type { Elysia } from "elysia"
3
- import { bearerSecurityRequirement } from "../auth/access-token-boundary"
3
+ import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
4
4
  import { requireRequestSixb } from "../auth/scope"
5
5
  import { OPENAPI_TAGS } from "../openapi/tags"
6
6
  import { ErrorResponseSchema, SuccessResponseSchema } from "../schemas/common"
@@ -44,7 +44,7 @@ export function registerLinkRoutes(app: Elysia, _host: SixbHostView) {
44
44
  summary: "Create or update object link",
45
45
  tags: [OPENAPI_TAGS.links.name],
46
46
  operationId: "upsertObjectLink",
47
- security: bearerSecurityRequirement("upsertObjectLink"),
47
+ security: accessTokenSecurityRequirement("upsertObjectLink"),
48
48
  },
49
49
  }
50
50
  )
@@ -82,7 +82,7 @@ export function registerLinkRoutes(app: Elysia, _host: SixbHostView) {
82
82
  summary: "Remove object link",
83
83
  tags: [OPENAPI_TAGS.links.name],
84
84
  operationId: "removeObjectLink",
85
- security: bearerSecurityRequirement("removeObjectLink"),
85
+ security: accessTokenSecurityRequirement("removeObjectLink"),
86
86
  },
87
87
  }
88
88
  )
@@ -1,6 +1,6 @@
1
1
  import { logLevelsAtOrAbove, type SixbHostView } from "@sixb/core"
2
2
  import type { Elysia } from "elysia"
3
- import { bearerSecurityRequirement } from "../auth/access-token-boundary"
3
+ import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
4
4
  import { requireRequestSixb } from "../auth/scope"
5
5
  import { OPENAPI_TAGS } from "../openapi/tags"
6
6
  import { ErrorResponseSchema } from "../schemas/common"
@@ -53,7 +53,7 @@ export function registerLogRoutes(app: Elysia, _host: SixbHostView) {
53
53
  summary: "Read run logs",
54
54
  tags: [OPENAPI_TAGS.logs.name],
55
55
  operationId: "listLogs",
56
- security: bearerSecurityRequirement("listLogs"),
56
+ security: accessTokenSecurityRequirement("listLogs"),
57
57
  },
58
58
  }
59
59
  )
@@ -15,7 +15,7 @@ import type {
15
15
  } from "@sixb/core/storage"
16
16
  import type { Elysia } from "elysia"
17
17
  import { ZodError, z } from "zod"
18
- import { bearerSecurityRequirement } from "../auth/access-token-boundary"
18
+ import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
19
19
  import { requireRequestSixb } from "../auth/scope"
20
20
  import {
21
21
  createContextualFileContentResponse,
@@ -49,6 +49,7 @@ const ObjectFileContentQuerySchema = FileContentQuerySchema.extend({
49
49
  })
50
50
 
51
51
  function serializeObject(row: {
52
+ score?: number
52
53
  primaryId: string
53
54
  objectTypeId: string
54
55
  properties: Record<string, unknown>
@@ -56,6 +57,7 @@ function serializeObject(row: {
56
57
  updatedAt: Date
57
58
  }) {
58
59
  return {
60
+ ...(row.score === undefined ? {} : { score: row.score }),
59
61
  primaryId: row.primaryId,
60
62
  objectTypeId: row.objectTypeId,
61
63
  properties: row.properties,
@@ -181,8 +183,7 @@ function handleObjectQueryError(error: unknown, set: { status?: number | string
181
183
  }
182
184
  }
183
185
 
184
- set.status = 500
185
- return { error: error instanceof Error ? error.message : String(error) }
186
+ return handleRouteError(error, set)
186
187
  }
187
188
 
188
189
  function formatZodIssuePath(path: readonly (string | number)[]): string {
@@ -334,7 +335,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
334
335
  summary: "Search objects",
335
336
  tags: [OPENAPI_TAGS.objects.name],
336
337
  operationId: "searchObjects",
337
- security: bearerSecurityRequirement("searchObjects"),
338
+ security: accessTokenSecurityRequirement("searchObjects"),
338
339
  },
339
340
  }
340
341
  )
@@ -392,7 +393,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
392
393
  summary: "List objects",
393
394
  tags: [OPENAPI_TAGS.objects.name],
394
395
  operationId: "listObjects",
395
- security: bearerSecurityRequirement("listObjects"),
396
+ security: accessTokenSecurityRequirement("listObjects"),
396
397
  },
397
398
  }
398
399
  )
@@ -408,6 +409,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
408
409
  const result = await requireRequestSixb(context).objects.executeQuery({
409
410
  query: parsed.query,
410
411
  includeTotal: parsed.includeTotal,
412
+ signal: context.request.signal,
411
413
  })
412
414
 
413
415
  return {
@@ -426,7 +428,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
426
428
  summary: "Query objects",
427
429
  tags: [OPENAPI_TAGS.objects.name],
428
430
  operationId: "queryObjects",
429
- security: bearerSecurityRequirement("queryObjects"),
431
+ security: accessTokenSecurityRequirement("queryObjects"),
430
432
  requestBody: {
431
433
  required: true,
432
434
  content: {
@@ -460,6 +462,20 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
460
462
  },
461
463
  },
462
464
  },
465
+ 429: {
466
+ description: "AI usage limit exceeded or unavailable",
467
+ headers: {
468
+ "Retry-After": {
469
+ description: "Seconds until the budget period resets, when known",
470
+ schema: { type: "integer" },
471
+ },
472
+ },
473
+ content: {
474
+ "application/json": {
475
+ schema: { $ref: "#/components/schemas/AiUsageLimitErrorResponse" },
476
+ },
477
+ },
478
+ },
463
479
  500: {
464
480
  description: "Response for status 500",
465
481
  content: {
@@ -502,7 +518,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
502
518
  summary: "Query object links",
503
519
  tags: [OPENAPI_TAGS.links.name],
504
520
  operationId: "queryObjectLinks",
505
- security: bearerSecurityRequirement("queryObjectLinks"),
521
+ security: accessTokenSecurityRequirement("queryObjectLinks"),
506
522
  requestBody: {
507
523
  required: true,
508
524
  content: {
@@ -571,7 +587,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
571
587
  summary: "Count objects",
572
588
  tags: [OPENAPI_TAGS.objects.name],
573
589
  operationId: "countObjects",
574
- security: bearerSecurityRequirement("countObjects"),
590
+ security: accessTokenSecurityRequirement("countObjects"),
575
591
  requestBody: {
576
592
  required: true,
577
593
  content: {
@@ -605,6 +621,20 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
605
621
  },
606
622
  },
607
623
  },
624
+ 429: {
625
+ description: "AI usage limit exceeded or unavailable",
626
+ headers: {
627
+ "Retry-After": {
628
+ description: "Seconds until the budget period resets, when known",
629
+ schema: { type: "integer" },
630
+ },
631
+ },
632
+ content: {
633
+ "application/json": {
634
+ schema: { $ref: "#/components/schemas/AiUsageLimitErrorResponse" },
635
+ },
636
+ },
637
+ },
608
638
  500: {
609
639
  description: "Response for status 500",
610
640
  content: {
@@ -640,7 +670,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
640
670
  summary: "Check object existence",
641
671
  tags: [OPENAPI_TAGS.objects.name],
642
672
  operationId: "existsObjects",
643
- security: bearerSecurityRequirement("existsObjects"),
673
+ security: accessTokenSecurityRequirement("existsObjects"),
644
674
  requestBody: {
645
675
  required: true,
646
676
  content: {
@@ -674,6 +704,20 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
674
704
  },
675
705
  },
676
706
  },
707
+ 429: {
708
+ description: "AI usage limit exceeded or unavailable",
709
+ headers: {
710
+ "Retry-After": {
711
+ description: "Seconds until the budget period resets, when known",
712
+ schema: { type: "integer" },
713
+ },
714
+ },
715
+ content: {
716
+ "application/json": {
717
+ schema: { $ref: "#/components/schemas/AiUsageLimitErrorResponse" },
718
+ },
719
+ },
720
+ },
677
721
  500: {
678
722
  description: "Response for status 500",
679
723
  content: {
@@ -713,7 +757,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
713
757
  summary: "Facet objects",
714
758
  tags: [OPENAPI_TAGS.objects.name],
715
759
  operationId: "facetObjects",
716
- security: bearerSecurityRequirement("facetObjects"),
760
+ security: accessTokenSecurityRequirement("facetObjects"),
717
761
  requestBody: {
718
762
  required: true,
719
763
  content: {
@@ -777,7 +821,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
777
821
  summary: "Get object file content",
778
822
  tags: [OPENAPI_TAGS.objectFiles.name],
779
823
  operationId: "getObjectFileContent",
780
- security: bearerSecurityRequirement("getObjectFileContent"),
824
+ security: accessTokenSecurityRequirement("getObjectFileContent"),
781
825
  responses: fileContentGetResponses(),
782
826
  },
783
827
  }
@@ -796,7 +840,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
796
840
  summary: "Head object file content",
797
841
  tags: [OPENAPI_TAGS.objectFiles.name],
798
842
  operationId: "headObjectFileContent",
799
- security: bearerSecurityRequirement("headObjectFileContent"),
843
+ security: accessTokenSecurityRequirement("headObjectFileContent"),
800
844
  responses: fileContentHeadResponses(),
801
845
  },
802
846
  }
@@ -832,7 +876,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
832
876
  summary: "Get object by id",
833
877
  tags: [OPENAPI_TAGS.objects.name],
834
878
  operationId: "getObject",
835
- security: bearerSecurityRequirement("getObject"),
879
+ security: accessTokenSecurityRequirement("getObject"),
836
880
  },
837
881
  }
838
882
  )
@@ -871,7 +915,7 @@ export function registerObjectRoutes(app: Elysia, host: SixbHostView) {
871
915
  summary: "Create or update object",
872
916
  tags: [OPENAPI_TAGS.objects.name],
873
917
  operationId: "upsertObject",
874
- security: bearerSecurityRequirement("upsertObject"),
918
+ security: accessTokenSecurityRequirement("upsertObject"),
875
919
  },
876
920
  }
877
921
  )
@@ -1,7 +1,8 @@
1
- import type { OntologySource, SixbHostView } from "@sixb/core"
1
+ import type { Property, SixbHostView, ValueType } from "@sixb/core"
2
+ import { resolvePropertyQueryCapabilities } from "@sixb/core/internal/ontology"
2
3
  import type { Sixb } from "@sixb/core/internal/request-execution"
3
4
  import type { Elysia } from "elysia"
4
- import { bearerSecurityRequirement } from "../auth/access-token-boundary"
5
+ import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
5
6
  import { requireRequestSixb } from "../auth/scope"
6
7
  import { OPENAPI_TAGS } from "../openapi/tags"
7
8
  import { ErrorResponseSchema } from "../schemas/common"
@@ -26,6 +27,17 @@ function serializeProperty(
26
27
  }
27
28
  }
28
29
 
30
+ function serializeObjectProperty(
31
+ property: Property,
32
+ valueTypesById: ReadonlyMap<string, ValueType>
33
+ ) {
34
+ const capabilities = resolvePropertyQueryCapabilities(property, valueTypesById)
35
+ return {
36
+ ...serializeProperty(property),
37
+ capabilities: { ...capabilities, operators: [...capabilities.operators] },
38
+ }
39
+ }
40
+
29
41
  function serializeSearch(
30
42
  search: ReturnType<SixbHostView["definitions"]["ontology"]["listObjectTypes"]>[number]["search"]
31
43
  ) {
@@ -34,17 +46,28 @@ function serializeSearch(
34
46
  title: search.title,
35
47
  defaultText: search.defaultText ? [...search.defaultText] : undefined,
36
48
  exact: search.exact ? [...search.exact] : undefined,
37
- vector: search.vector
38
- ? {
39
- property: search.vector.property,
40
- source: [...search.vector.source],
41
- }
49
+ vectors: search.vectors
50
+ ? Object.fromEntries(
51
+ Object.entries(search.vectors).map(([name, profile]) => [
52
+ name,
53
+ {
54
+ source: [...profile.source],
55
+ model: {
56
+ providerId: profile.model.providerId,
57
+ modelId: profile.model.modelId,
58
+ dimensions: profile.model.definition.dimensions,
59
+ representation: profile.model.definition.representation,
60
+ },
61
+ },
62
+ ])
63
+ )
42
64
  : undefined,
43
65
  }
44
66
  }
45
67
 
46
68
  function serializeObjectType(
47
- execution: Sixb<readonly OntologySource[]>,
69
+ execution: Sixb,
70
+ valueTypesById: ReadonlyMap<string, ValueType>,
48
71
  objectType: ReturnType<SixbHostView["definitions"]["ontology"]["listObjectTypes"]>[number]
49
72
  ) {
50
73
  return {
@@ -53,7 +76,9 @@ function serializeObjectType(
53
76
  description: objectType.description,
54
77
  extends: objectType.extends,
55
78
  implements: objectType.implements ? [...objectType.implements] : undefined,
56
- properties: objectType.properties.map(serializeProperty),
79
+ properties: objectType.properties.map((property) =>
80
+ serializeObjectProperty(property, valueTypesById)
81
+ ),
57
82
  search: serializeSearch(objectType.search),
58
83
  links: objectType.links.map((link) => ({
59
84
  id: link.id,
@@ -82,13 +107,16 @@ function serializeObjectType(
82
107
  }
83
108
  }
84
109
 
85
- export function registerOntologyRoutes(app: Elysia, _host: SixbHostView) {
110
+ export function registerOntologyRoutes(app: Elysia, host: SixbHostView) {
86
111
  return app
87
112
  .get(
88
113
  "/api/object-types",
89
114
  async (context) => {
90
115
  const sixb = requireRequestSixb(context)
91
- return sixb.objects.listTypes().map((objectType) => serializeObjectType(sixb, objectType))
116
+ const valueTypesById = host.definitions.ontology.getValueTypesById()
117
+ return sixb.objects
118
+ .listTypes()
119
+ .map((objectType) => serializeObjectType(sixb, valueTypesById, objectType))
92
120
  },
93
121
  {
94
122
  response: { 200: ObjectTypeSchema.array() },
@@ -96,7 +124,7 @@ export function registerOntologyRoutes(app: Elysia, _host: SixbHostView) {
96
124
  summary: "List registered object types",
97
125
  tags: [OPENAPI_TAGS.ontology.name],
98
126
  operationId: "listObjectTypes",
99
- security: bearerSecurityRequirement("listObjectTypes"),
127
+ security: accessTokenSecurityRequirement("listObjectTypes"),
100
128
  },
101
129
  }
102
130
  )
@@ -111,7 +139,7 @@ export function registerOntologyRoutes(app: Elysia, _host: SixbHostView) {
111
139
  return { error: "Object type not found" }
112
140
  }
113
141
 
114
- return serializeObjectType(sixb, objectType)
142
+ return serializeObjectType(sixb, host.definitions.ontology.getValueTypesById(), objectType)
115
143
  },
116
144
  {
117
145
  params: ObjectTypeParamsSchema,
@@ -120,7 +148,7 @@ export function registerOntologyRoutes(app: Elysia, _host: SixbHostView) {
120
148
  summary: "Get object type definition",
121
149
  tags: [OPENAPI_TAGS.ontology.name],
122
150
  operationId: "getObjectType",
123
- security: bearerSecurityRequirement("getObjectType"),
151
+ security: accessTokenSecurityRequirement("getObjectType"),
124
152
  },
125
153
  }
126
154
  )
@@ -2,7 +2,7 @@ import type { PipelineDefinition, PipelineStepExecutor, SixbHostView } from "@si
2
2
  import type { PipelineRunRecord, PipelineStepRunRecord } from "@sixb/core/storage"
3
3
  import type { Elysia } from "elysia"
4
4
  import { requireRequestSixb } from "../auth/scope"
5
- import { SIXB_CSRF_SECURITY_REQUIREMENT } from "../openapi/security"
5
+ import { SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT } from "../openapi/security"
6
6
  import { OPENAPI_TAGS } from "../openapi/tags"
7
7
  import { ErrorResponseSchema } from "../schemas/common"
8
8
  import {
@@ -291,7 +291,7 @@ export function registerPipelineRoutes(app: Elysia, host: SixbHostView) {
291
291
  summary: "Request a pipeline run",
292
292
  tags: [OPENAPI_TAGS.pipelineRuns.name],
293
293
  operationId: "requestPipelineRun",
294
- security: SIXB_CSRF_SECURITY_REQUIREMENT,
294
+ security: SIXB_SESSION_MUTATION_SECURITY_REQUIREMENT,
295
295
  },
296
296
  }
297
297
  )