@sixb/server 0.1.23 → 0.1.25

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.
@@ -138,6 +138,10 @@ export const ModelCatalogSchema = z.object({
138
138
  speech: z.array(SpeechModelSchema),
139
139
  transcription: z.array(TranscriptionModelSchema),
140
140
  }),
141
+ capabilities: z.object({
142
+ /** The requester may call these models, through the generation routes or the agent's chat. */
143
+ run: z.boolean(),
144
+ }),
141
145
  })
142
146
 
143
147
  export const ModelReasoningLevelSchema = z.enum(MODEL_REASONING_LEVELS)
@@ -231,9 +235,22 @@ export const FileGenerationSchema = GenerationResultBase.extend({
231
235
  warnings: z.array(z.string()),
232
236
  })
233
237
 
238
+ // One character class and no group: zod's base64() backtracks, and refused minutes of audio.
239
+ const BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/
240
+
241
+ /** Audio sent with the request, base64-encoded: it reaches the model without being stored. */
242
+ export const InlineAudioSchema = z.object({
243
+ data: z
244
+ .string()
245
+ .min(1)
246
+ .regex(BASE64_PATTERN, "Invalid base64")
247
+ .refine((data) => data.length % 4 === 0, "Invalid base64"),
248
+ mediaType: z.string().min(1),
249
+ })
250
+
234
251
  export const TranscriptionBodySchema = GenerationBodyBase.extend({
235
- /** Audio uploaded through /api/files. */
236
- audio: FileRefSchema,
252
+ /** Audio uploaded through /api/files, or sent inline, such as a dictation. */
253
+ audio: z.union([FileRefSchema, InlineAudioSchema]),
237
254
  })
238
255
 
239
256
  export const TranscriptionSchema = GenerationResultBase.extend({
package/src/server.ts CHANGED
@@ -10,7 +10,6 @@ import { checkPipelineMarkings, warmAppliedMarkings } from "@sixb/core/internal/
10
10
  import type { Server } from "bun"
11
11
  import { Elysia, ParseError } from "elysia"
12
12
  import { websocket as elysiaWebSocket } from "elysia/ws"
13
- import { zodToJsonSchema } from "zod-to-json-schema"
14
13
  import {
15
14
  type AuthInvitationRedirectContext,
16
15
  type AuthInvitationRedirectInput,
@@ -42,7 +41,7 @@ import {
42
41
  SharedAccessBoundary,
43
42
  type SixbSharedAccessOptions,
44
43
  } from "./auth/shared-access"
45
- import { NamedOpenApiSchemas, openApiOverride } from "./openapi/components"
44
+ import { NamedOpenApiSchemas, openApiJsonSchema } from "./openapi/components"
46
45
  import {
47
46
  SIXB_ACCESS_TOKEN_SECURITY_SCHEME,
48
47
  SIXB_ACCESS_TOKEN_SECURITY_SCHEME_ID,
@@ -406,7 +405,7 @@ export function createSixbApi(server: SixbServer) {
406
405
  openapi({
407
406
  path: "/docs",
408
407
  provider: "swagger-ui",
409
- // zodToJsonSchema below emits OpenAPI 3.0 nullable schemas.
408
+ // openApiJsonSchema below emits OpenAPI 3.0 nullable schemas.
410
409
  openapiVersion: "3.0.3",
411
410
  documentation: {
412
411
  info: {
@@ -431,12 +430,7 @@ export function createSixbApi(server: SixbServer) {
431
430
  withCredentials: true,
432
431
  },
433
432
  mapJsonSchema: {
434
- zod: (schema: Parameters<typeof zodToJsonSchema>[0]) =>
435
- zodToJsonSchema(schema, {
436
- $refStrategy: "none",
437
- target: "openApi3",
438
- override: openApiOverride(),
439
- }),
433
+ zod: openApiJsonSchema,
440
434
  },
441
435
  })
442
436
  )