@sixb/server 0.1.17 → 0.1.19

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 (110) hide show
  1. package/README.md +3 -3
  2. package/dist/actions/serialize.d.ts +7 -0
  3. package/dist/actions/serialize.d.ts.map +1 -0
  4. package/dist/auth/experience.d.ts +5 -1
  5. package/dist/auth/experience.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 +812 -769
  9. package/dist/index.js.map +32 -31
  10. package/dist/routes/action-runs.d.ts +11 -13
  11. package/dist/routes/action-runs.d.ts.map +1 -1
  12. package/dist/routes/actions.d.ts +44 -13
  13. package/dist/routes/actions.d.ts.map +1 -1
  14. package/dist/routes/agent-api-gateway.d.ts.map +1 -1
  15. package/dist/routes/agents.d.ts +67 -47
  16. package/dist/routes/agents.d.ts.map +1 -1
  17. package/dist/routes/auth.d.ts +3 -2
  18. package/dist/routes/auth.d.ts.map +1 -1
  19. package/dist/routes/connector-connection-runs.d.ts +21 -21
  20. package/dist/routes/connector-connections.d.ts +8 -8
  21. package/dist/routes/connectors.d.ts +2 -2
  22. package/dist/routes/datasets.d.ts +9 -6
  23. package/dist/routes/datasets.d.ts.map +1 -1
  24. package/dist/routes/events.d.ts +4 -4
  25. package/dist/routes/files.d.ts +15 -12
  26. package/dist/routes/files.d.ts.map +1 -1
  27. package/dist/routes/models.d.ts +1 -0
  28. package/dist/routes/models.d.ts.map +1 -1
  29. package/dist/routes/objects.d.ts +21 -4
  30. package/dist/routes/objects.d.ts.map +1 -1
  31. package/dist/routes/ontology.d.ts +6 -6
  32. package/dist/routes/pipelines.d.ts +16 -16
  33. package/dist/routes/project.d.ts +2 -0
  34. package/dist/routes/project.d.ts.map +1 -1
  35. package/dist/routes/projections.d.ts +49 -49
  36. package/dist/routes/syncs.d.ts +10 -10
  37. package/dist/routes/webhook-runs.d.ts +2 -2
  38. package/dist/routes/workflows.d.ts +51 -48
  39. package/dist/routes/workflows.d.ts.map +1 -1
  40. package/dist/routes/ws/events.d.ts +6 -9
  41. package/dist/routes/ws/events.d.ts.map +1 -1
  42. package/dist/routes/ws/subscription-hub.d.ts +5 -0
  43. package/dist/routes/ws/subscription-hub.d.ts.map +1 -1
  44. package/dist/schemas/actions.d.ts +100 -84
  45. package/dist/schemas/actions.d.ts.map +1 -1
  46. package/dist/schemas/agents.d.ts +242 -143
  47. package/dist/schemas/agents.d.ts.map +1 -1
  48. package/dist/schemas/ai-accounting.d.ts +10 -10
  49. package/dist/schemas/ai-limits.d.ts +10 -10
  50. package/dist/schemas/auth.d.ts +7 -0
  51. package/dist/schemas/auth.d.ts.map +1 -1
  52. package/dist/schemas/common.d.ts +8 -0
  53. package/dist/schemas/common.d.ts.map +1 -1
  54. package/dist/schemas/connectors.d.ts +8 -8
  55. package/dist/schemas/datasets.d.ts +58 -43
  56. package/dist/schemas/datasets.d.ts.map +1 -1
  57. package/dist/schemas/event-payloads.d.ts +39 -0
  58. package/dist/schemas/event-payloads.d.ts.map +1 -1
  59. package/dist/schemas/events.d.ts +24 -24
  60. package/dist/schemas/events.d.ts.map +1 -1
  61. package/dist/schemas/files.d.ts +5 -5
  62. package/dist/schemas/files.d.ts.map +1 -1
  63. package/dist/schemas/models.d.ts +10 -0
  64. package/dist/schemas/models.d.ts.map +1 -1
  65. package/dist/schemas/objects.d.ts +32 -0
  66. package/dist/schemas/objects.d.ts.map +1 -1
  67. package/dist/schemas/ontology.d.ts +40 -40
  68. package/dist/schemas/pipelines.d.ts +92 -92
  69. package/dist/schemas/project.d.ts +8 -0
  70. package/dist/schemas/project.d.ts.map +1 -1
  71. package/dist/schemas/projections.d.ts +290 -290
  72. package/dist/schemas/syncs.d.ts +34 -34
  73. package/dist/schemas/webhook-runs.d.ts +8 -8
  74. package/dist/schemas/workflows.d.ts +177 -160
  75. package/dist/schemas/workflows.d.ts.map +1 -1
  76. package/dist/server.d.ts +1 -0
  77. package/dist/server.d.ts.map +1 -1
  78. package/dist/utils/http.d.ts.map +1 -1
  79. package/dist/utils/request-body.d.ts +20 -6
  80. package/dist/utils/request-body.d.ts.map +1 -1
  81. package/package.json +6 -5
  82. package/src/actions/serialize.ts +55 -0
  83. package/src/auth/experience.ts +20 -2
  84. package/src/files/content.ts +43 -88
  85. package/src/routes/action-runs.ts +1 -54
  86. package/src/routes/actions.ts +26 -8
  87. package/src/routes/agent-api-gateway.ts +18 -42
  88. package/src/routes/agents.ts +29 -9
  89. package/src/routes/auth.ts +84 -19
  90. package/src/routes/datasets.ts +12 -43
  91. package/src/routes/files.ts +18 -64
  92. package/src/routes/models.ts +3 -0
  93. package/src/routes/objects.ts +12 -2
  94. package/src/routes/project.ts +2 -1
  95. package/src/routes/workflows.ts +5 -0
  96. package/src/routes/ws/events.ts +7 -15
  97. package/src/routes/ws/subscription-hub.ts +20 -5
  98. package/src/schemas/actions.ts +21 -18
  99. package/src/schemas/agents.ts +28 -3
  100. package/src/schemas/auth.ts +5 -0
  101. package/src/schemas/common.ts +3 -0
  102. package/src/schemas/datasets.ts +23 -1
  103. package/src/schemas/event-payloads.ts +3 -1
  104. package/src/schemas/files.ts +7 -1
  105. package/src/schemas/models.ts +2 -0
  106. package/src/schemas/objects.ts +13 -0
  107. package/src/schemas/project.ts +4 -0
  108. package/src/server.ts +23 -4
  109. package/src/utils/http.ts +2 -0
  110. package/src/utils/request-body.ts +55 -6
@@ -1 +1 @@
1
- {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/schemas/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,wBAAwB,+GAA4B,CAAA;AAMjE,eAAO,MAAM,oBAAoB;;;;;;EAE/B,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAA;AAEF,eAAO,MA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEnD,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;EAK3C,CAAA"}
package/dist/server.d.ts CHANGED
@@ -3,6 +3,7 @@ import { Elysia } from "elysia";
3
3
  import { type AuthInvitationDestinationOptions, type AuthInvitationRedirectContext, type AuthInvitationRedirectInput, type RequestAuthContext, type ResolveAuthRedirectContext, type ResolvedSixbApiBrowserPolicy, type SixbApiBrowserPolicy } from "./auth/browser-origin";
4
4
  import type { SixbAuthExperienceOptions } from "./auth/experience";
5
5
  import { type SixbSharedAccessOptions } from "./auth/shared-access";
6
+ export declare const MAX_WEBSOCKET_MESSAGE_BYTES: number;
6
7
  export interface SixbServerOptions {
7
8
  host: SixbHostView;
8
9
  port?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,YAAY,EAAE,MAAM,YAAY,CAAA;AAKzE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAMhC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAKjC,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAA;AAO9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAKlE,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAA;AAoB7B,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE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,EAAE,aAAa,CAAA;IACpB,OAAO,CAAC,EAAE,iBAAiB,CAAA;CAC5B,CA6CA"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAA;AA+BnB,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,CAE/C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAWrE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAW9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACjC,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAGnB;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,GACpB;IACD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,OAAO,CAAC,EAAE,iBAAiB,CAAA;CAC5B,CA6CA"}
@@ -1,15 +1,29 @@
1
1
  /**
2
- * Reads a request body fully into memory while enforcing a hard byte ceiling.
2
+ * Request body limits for the API.
3
3
  *
4
- * The cap is applied DURING streaming (not after buffering), so an oversized or
5
- * chunked/unknown-length body is rejected before it is fully read — the
6
- * `content-length` header, when present, only provides an early fast-path. This
7
- * is the single bounded-reader used by request handlers that need the raw bytes.
4
+ * Elysia parses a JSON or form body before the auth guard runs, so the server caps every body it
5
+ * receives at `DEFAULT_REQUEST_BODY_LIMIT_BYTES` (`limitRequestBody`). A route that takes more,
6
+ * such as a file upload, reads its own body with `readRequestBodyWithLimit`, whose limit replaces
7
+ * that cap. Both apply the limit DURING streaming (not after buffering), so an oversized or
8
+ * chunked/unknown-length body is rejected before it is fully read.
8
9
  */
10
+ /** The most a request body may be, unless the route reading it allows more. */
11
+ export declare const DEFAULT_REQUEST_BODY_LIMIT_BYTES: number;
9
12
  export declare class RequestBodyTooLargeError extends Error {
10
13
  readonly limitBytes: number;
11
14
  readonly name = "RequestBodyTooLargeError";
12
15
  constructor(limitBytes: number, message?: string);
13
16
  }
14
- export declare function readRequestBodyWithLimit(request: Request, limitBytes: number, tooLargeMessage?: string): Promise<Uint8Array>;
17
+ /**
18
+ * Returns `request` with its body capped at `DEFAULT_REQUEST_BODY_LIMIT_BYTES`. Reading past the
19
+ * cap fails with `RequestBodyTooLargeError`, which Elysia surfaces as a parse error.
20
+ */
21
+ export declare function limitRequestBody(request: Request): Request;
22
+ /**
23
+ * Reads a request body fully into memory, failing once it passes `limitBytes`. That limit
24
+ * replaces the server's default cap for this request, so a route reading more than the default
25
+ * must authenticate the caller first. The `content-length` header, when present, only provides an
26
+ * early fast-path.
27
+ */
28
+ export declare function readRequestBodyWithLimit(request: Request, limitBytes: number, tooLargeMessage?: string): Promise<Uint8Array<ArrayBuffer>>;
15
29
  //# sourceMappingURL=request-body.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-body.d.ts","sourceRoot":"","sources":["../../src/utils/request-body.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAI/C,QAAQ,CAAC,UAAU,EAAE,MAAM;IAH7B,QAAQ,CAAC,IAAI,8BAA6B;gBAG/B,UAAU,EAAE,MAAM,EAC3B,OAAO,SAAuD;CAIjE;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,UAAU,CAAC,CAsCrB"}
1
+ {"version":3,"file":"request-body.d.ts","sourceRoot":"","sources":["../../src/utils/request-body.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,gCAAgC,QAAc,CAAA;AAE3D,qBAAa,wBAAyB,SAAQ,KAAK;IAI/C,QAAQ,CAAC,UAAU,EAAE,MAAM;IAH7B,QAAQ,CAAC,IAAI,8BAA6B;gBAG/B,UAAU,EAAE,MAAM,EAC3B,OAAO,SAAuD;CAIjE;AAID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAwB1D;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CA4ClC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/server",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "HTTP and WebSocket API server for Sixb",
5
5
  "keywords": [
6
6
  "sixb",
@@ -38,13 +38,14 @@
38
38
  "zod-to-json-schema": "^3.24.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@sixb/core": "0.1.17"
41
+ "@sixb/core": "0.1.19"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@sixb/auth-magic-link": "0.1.5",
45
- "@sixb/auth-oidc": "0.1.4",
46
- "@sixb/core": "0.1.17",
47
- "@sixb/sqlite": "0.1.17",
45
+ "@sixb/auth-oidc": "0.1.5",
46
+ "@sixb/cli-core": "0.1.8",
47
+ "@sixb/core": "0.1.19",
48
+ "@sixb/sqlite": "0.1.19",
48
49
  "@types/bun": "latest",
49
50
  "typescript": "^5.7.0"
50
51
  },
@@ -0,0 +1,55 @@
1
+ import type { ActionRunRecord } from "@sixb/core/storage"
2
+ import { ActionRunDetailSchema, ActionRunSummarySchema } from "../schemas/actions"
3
+ import { toIsoString } from "../utils/http"
4
+
5
+ /** The run summary run listings answer with. */
6
+ export function serializeActionRunSummary(
7
+ run: ActionRunRecord
8
+ ): ReturnType<typeof ActionRunSummarySchema.parse> {
9
+ return ActionRunSummarySchema.parse({
10
+ id: run.id,
11
+ projectId: run.projectId,
12
+ actionId: run.actionId,
13
+ subject: run.subject,
14
+ status: run.status,
15
+ phase: run.phase,
16
+ startedAt: toIsoString(run.startedAt),
17
+ finishedAt: toIsoString(run.finishedAt),
18
+ error: run.error,
19
+ })
20
+ }
21
+
22
+ /** The run detail every route that returns one run answers with. */
23
+ export function serializeActionRunDetail(
24
+ run: ActionRunRecord
25
+ ): ReturnType<typeof ActionRunDetailSchema.parse> {
26
+ return ActionRunDetailSchema.parse({
27
+ ...serializeActionRunSummary(run),
28
+ params: run.params,
29
+ writeback: run.writeback
30
+ ? run.writeback.status === "succeeded"
31
+ ? {
32
+ status: "succeeded",
33
+ completedAt: toIsoString(run.writeback.completedAt),
34
+ result: run.writeback.result,
35
+ }
36
+ : {
37
+ status: "failed",
38
+ completedAt: toIsoString(run.writeback.completedAt),
39
+ error: run.writeback.error,
40
+ }
41
+ : undefined,
42
+ effects: run.effects
43
+ ? run.effects.status === "succeeded"
44
+ ? {
45
+ status: "succeeded",
46
+ completedAt: toIsoString(run.effects.completedAt),
47
+ }
48
+ : {
49
+ status: "failed",
50
+ completedAt: toIsoString(run.effects.completedAt),
51
+ error: run.effects.error,
52
+ }
53
+ : undefined,
54
+ })
55
+ }
@@ -9,6 +9,11 @@ export interface SixbAuthExperienceOptions {
9
9
  readonly audience?: AuthSessionAudience
10
10
  }
11
11
 
12
+ /** The configured experience with the project's language, which its pages declare. */
13
+ export interface ProjectAuthExperience extends SixbAuthExperienceOptions {
14
+ readonly locale: string
15
+ }
16
+
12
17
  export type AuthExperiencePageState =
13
18
  | { readonly kind: "signIn" }
14
19
  | { readonly kind: "checkEmail" }
@@ -23,7 +28,7 @@ export interface AuthExperienceSubmission {
23
28
  }
24
29
 
25
30
  export async function customAuthExperienceResponse(
26
- options: SixbAuthExperienceOptions | undefined,
31
+ options: ProjectAuthExperience | undefined,
27
32
  input: {
28
33
  readonly audience: AuthSessionAudience
29
34
  readonly state: AuthExperiencePageState
@@ -62,7 +67,11 @@ export async function customAuthExperienceResponse(
62
67
  " "
63
68
  )
64
69
 
65
- return new Response(html.replace(AUTH_BOOTSTRAP_PLACEHOLDER, bootstrap), {
70
+ const page = withDocumentLanguage(
71
+ html.replace(AUTH_BOOTSTRAP_PLACEHOLDER, bootstrap),
72
+ options.locale
73
+ )
74
+ return new Response(page, {
66
75
  status: input.status ?? 200,
67
76
  headers: {
68
77
  "content-type": "text/html; charset=utf-8",
@@ -83,6 +92,15 @@ export async function customAuthExperienceResponse(
83
92
  })
84
93
  }
85
94
 
95
+ // The page is built without loading the project, so its language is set when it is served.
96
+ function withDocumentLanguage(html: string, locale: string): string {
97
+ return html.replace(
98
+ /<html\b([^>]*)>/i,
99
+ (_tag, attributes: string) =>
100
+ `<html${attributes.replace(/\s+lang\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/i, "")} lang="${locale}">`
101
+ )
102
+ }
103
+
86
104
  function normalizeCspOrigin(value: string): string {
87
105
  let url: URL
88
106
  try {
@@ -1,6 +1,11 @@
1
1
  import { createHash } from "node:crypto"
2
- import { type BlobInfo, type BlobStorage, type FileRef, isFileRef } from "@sixb/core"
2
+ import { type BlobInfo, type BlobStorage, type FileRef, fileNameFor } from "@sixb/core"
3
3
  import { BlobStorageError, supportsRangeRead } from "@sixb/core/blob-storage/server"
4
+ import {
5
+ canonicalMediaType,
6
+ resolveFileRefAtPath,
7
+ statFileRef,
8
+ } from "@sixb/core/internal/blob-storage"
4
9
  import { ZodError } from "zod"
5
10
 
6
11
  export type FileContentDisposition = "inline" | "attachment"
@@ -148,8 +153,8 @@ export function fileContentHeadResponses(options: FileContentResponsesOptions =
148
153
  export async function createFileContentResponse(
149
154
  input: FileContentResponseInput
150
155
  ): Promise<Response | null> {
151
- const stat = await input.blobStorage.stat(input.fileRef.blobId)
152
- if (!stat || !blobMatchesFileRef(stat, input.fileRef)) {
156
+ const stat = await statFileRef(input.blobStorage, input.fileRef)
157
+ if (!stat) {
153
158
  return null
154
159
  }
155
160
 
@@ -255,11 +260,6 @@ export async function createContextualFileContentResponse<TQuery extends FileCon
255
260
  }
256
261
  }
257
262
 
258
- export function resolveFileRefAtPath(root: unknown, path: string): FileRef | null {
259
- const value = resolveJsonPointer(root, path)
260
- return isFileRef(value) ? value : null
261
- }
262
-
263
263
  function fileContentNotFound(
264
264
  set: { status?: number | string },
265
265
  message: string
@@ -268,14 +268,6 @@ function fileContentNotFound(
268
268
  return { error: message }
269
269
  }
270
270
 
271
- function blobMatchesFileRef(stat: BlobInfo, fileRef: FileRef): boolean {
272
- return (
273
- stat.blobId === fileRef.blobId &&
274
- stat.digest === fileRef.digest &&
275
- stat.sizeBytes === fileRef.sizeBytes
276
- )
277
- }
278
-
279
271
  function matchesIfNoneMatch(header: string | null | undefined, etag: string): boolean {
280
272
  return (
281
273
  header?.trim() === "*" ||
@@ -283,43 +275,32 @@ function matchesIfNoneMatch(header: string | null | undefined, etag: string): bo
283
275
  )
284
276
  }
285
277
 
286
- function resolveJsonPointer(root: unknown, pointer: string): unknown {
287
- if (pointer === "") {
288
- return root
289
- }
290
-
291
- if (!pointer.startsWith("/")) {
292
- return undefined
293
- }
294
-
295
- let current = root
296
- for (const rawSegment of pointer.slice(1).split("/")) {
297
- const segment = decodeJsonPointerSegment(rawSegment)
298
- if (Array.isArray(current)) {
299
- const index = Number.parseInt(segment, 10)
300
- if (!Number.isInteger(index) || index < 0 || index.toString() !== segment) {
301
- return undefined
302
- }
303
- if (!Object.hasOwn(current, segment)) {
304
- return undefined
305
- }
306
- current = current[index]
307
- continue
308
- }
309
-
310
- if (typeof current !== "object" || current === null || !Object.hasOwn(current, segment)) {
311
- return undefined
312
- }
313
-
314
- current = (current as Record<string, unknown>)[segment]
315
- }
316
-
317
- return current
318
- }
319
-
320
- function decodeJsonPointerSegment(segment: string): string {
321
- return segment.replaceAll("~1", "/").replaceAll("~0", "~")
322
- }
278
+ /**
279
+ * The only types a browser displays instead of downloading: raster images, PDF, and plain-text
280
+ * formats. Everything else, including HTML, SVG, and XML, downloads.
281
+ */
282
+ const INLINE_MEDIA_TYPES: ReadonlySet<string> = new Set([
283
+ "application/json",
284
+ "application/pdf",
285
+ "image/avif",
286
+ "image/bmp",
287
+ "image/gif",
288
+ "image/jpeg",
289
+ "image/png",
290
+ "image/webp",
291
+ "text/markdown",
292
+ "text/plain",
293
+ ])
294
+
295
+ // Keeps any file from running script on the API origin, even when a browser renders it as a page.
296
+ // A sandboxed page cannot run script, but Chrome's PDF viewer does not render in one, so PDFs go
297
+ // without `sandbox`: `default-src 'none'` still blocks script, and `object-src 'self'` lets
298
+ // browsers that show a PDF as an embedded object load it. `style-src 'unsafe-inline'` lets
299
+ // browsers keep the styling of their built-in viewers. Video and audio play in media elements,
300
+ // which ignore the policy of the file they load.
301
+ const FILE_CONTENT_SECURITY_POLICY = "default-src 'none'; style-src 'unsafe-inline'; sandbox"
302
+ const PDF_CONTENT_SECURITY_POLICY =
303
+ "default-src 'none'; style-src 'unsafe-inline'; object-src 'self'"
323
304
 
324
305
  function fileContentHeaders(
325
306
  fileRef: FileRef,
@@ -327,15 +308,22 @@ function fileContentHeaders(
327
308
  requestedDisposition: FileContentDisposition | undefined,
328
309
  canReadRange: boolean
329
310
  ): Headers {
330
- const mediaType = fileRef.mediaType?.trim() || "application/octet-stream"
311
+ // Parsed again rather than trusted: stored references may predate media type validation.
312
+ const mediaType = canonicalMediaType(fileRef.mediaType) ?? "application/octet-stream"
313
+ // Canonical, so everything before the first ";" is the lowercased type/subtype.
314
+ const baseType = mediaType.split(";", 1)[0]
331
315
  const disposition =
332
- (requestedDisposition ?? "inline") === "inline" && canRenderInline(mediaType)
316
+ (requestedDisposition ?? "inline") === "inline" && INLINE_MEDIA_TYPES.has(baseType)
333
317
  ? "inline"
334
318
  : "attachment"
335
319
  const headers = new Headers()
336
320
  headers.set("content-type", mediaType)
337
321
  headers.set("content-length", stat.sizeBytes.toString())
338
322
  headers.set("content-disposition", contentDispositionHeader(disposition, fileNameFor(fileRef)))
323
+ headers.set(
324
+ "content-security-policy",
325
+ baseType === "application/pdf" ? PDF_CONTENT_SECURITY_POLICY : FILE_CONTENT_SECURITY_POLICY
326
+ )
339
327
  // Metadata belongs to the reference, not the blob; changing it must also invalidate caches.
340
328
  const representation = JSON.stringify([
341
329
  fileRef.digest,
@@ -424,39 +412,6 @@ function rangeNotSatisfiableResponse(sizeBytes: number): Response {
424
412
  return new Response(null, { status: 416, headers })
425
413
  }
426
414
 
427
- function canRenderInline(mediaType: string): boolean {
428
- const baseType = mediaType.split(";")[0]?.trim().toLowerCase()
429
- if (!baseType) {
430
- return false
431
- }
432
-
433
- if (
434
- baseType === "text/html" ||
435
- baseType === "image/svg+xml" ||
436
- baseType === "application/xhtml+xml"
437
- ) {
438
- return false
439
- }
440
-
441
- return (
442
- baseType === "application/pdf" ||
443
- baseType === "text/plain" ||
444
- baseType === "text/markdown" ||
445
- baseType === "application/json" ||
446
- baseType.startsWith("image/")
447
- )
448
- }
449
-
450
- function fileNameFor(fileRef: FileRef): string {
451
- const fromFileName = fileRef.fileName?.split(/[\\/]/).filter(Boolean).at(-1)
452
- if (fromFileName) {
453
- return fromFileName
454
- }
455
-
456
- const fromLogicalPath = fileRef.logicalPath?.split(/[\\/]/).filter(Boolean).at(-1)
457
- return fromLogicalPath || `${fileRef.blobId}.bin`
458
- }
459
-
460
415
  function contentDispositionHeader(disposition: FileContentDisposition, fileName: string): string {
461
416
  const asciiFileName = fileName.replace(/[^\x20-\x7e]/g, "_").replaceAll('"', "'")
462
417
  return `${disposition}; filename="${asciiFileName}"; filename*=UTF-8''${encodeURIComponent(fileName)}`
@@ -1,7 +1,7 @@
1
1
  import type { SixbHostView } from "@sixb/core"
2
- import type { ActionRunRecord } from "@sixb/core/storage"
3
2
  import type { Elysia } from "elysia"
4
3
  import { z } from "zod"
4
+ import { serializeActionRunDetail, serializeActionRunSummary } from "../actions/serialize"
5
5
  import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
6
6
  import { requireRequestSixb } from "../auth/scope"
7
7
  import {
@@ -15,7 +15,6 @@ import {
15
15
  ActionRunDetailSchema,
16
16
  ActionRunIdParamsSchema,
17
17
  ActionRunListResponseSchema,
18
- ActionRunSummarySchema,
19
18
  ActionRunsQuerySchema,
20
19
  } from "../schemas/actions"
21
20
  import { ErrorResponseSchema } from "../schemas/common"
@@ -24,7 +23,6 @@ import {
24
23
  handleRouteError,
25
24
  parseDate,
26
25
  parseOptionalInt,
27
- toIsoString,
28
26
  unconfiguredStorageResponse,
29
27
  } from "../utils/http"
30
28
 
@@ -38,57 +36,6 @@ const ActionRunFileContentQuerySchema = FileContentQuerySchema.extend({
38
36
  ),
39
37
  })
40
38
 
41
- function serializeActionRunSummary(
42
- run: ActionRunRecord
43
- ): ReturnType<typeof ActionRunSummarySchema.parse> {
44
- return ActionRunSummarySchema.parse({
45
- id: run.id,
46
- projectId: run.projectId,
47
- actionId: run.actionId,
48
- subject: run.subject,
49
- status: run.status,
50
- phase: run.phase,
51
- queuedAt: toIsoString(run.queuedAt),
52
- startedAt: run.startedAt ? toIsoString(run.startedAt) : undefined,
53
- finishedAt: run.finishedAt ? toIsoString(run.finishedAt) : undefined,
54
- error: run.error,
55
- })
56
- }
57
-
58
- function serializeActionRunDetail(
59
- run: ActionRunRecord
60
- ): ReturnType<typeof ActionRunDetailSchema.parse> {
61
- return ActionRunDetailSchema.parse({
62
- ...serializeActionRunSummary(run),
63
- params: run.params,
64
- writeback: run.writeback
65
- ? run.writeback.status === "succeeded"
66
- ? {
67
- status: "succeeded",
68
- completedAt: toIsoString(run.writeback.completedAt),
69
- result: run.writeback.result,
70
- }
71
- : {
72
- status: "failed",
73
- completedAt: toIsoString(run.writeback.completedAt),
74
- error: run.writeback.error,
75
- }
76
- : undefined,
77
- effects: run.effects
78
- ? run.effects.status === "succeeded"
79
- ? {
80
- status: "succeeded",
81
- completedAt: toIsoString(run.effects.completedAt),
82
- }
83
- : {
84
- status: "failed",
85
- completedAt: toIsoString(run.effects.completedAt),
86
- error: run.effects.error,
87
- }
88
- : undefined,
89
- })
90
- }
91
-
92
39
  async function actionRunFileContentResponse(
93
40
  host: SixbHostView,
94
41
  context: {
@@ -1,6 +1,7 @@
1
1
  import type { ActionDescriptor, SixbHostView } from "@sixb/core"
2
2
  import { schemaFieldsToJsonSchema } from "@sixb/core/internal/ontology"
3
3
  import type { Elysia } from "elysia"
4
+ import { serializeActionRunDetail } from "../actions/serialize"
4
5
  import { accessTokenSecurityRequirement } from "../auth/access-token-boundary"
5
6
  import { requireRequestSixb } from "../auth/scope"
6
7
  import { OPENAPI_TAGS } from "../openapi/tags"
@@ -8,8 +9,11 @@ import {
8
9
  ActionCatalogItemSchema,
9
10
  ActionDetailSchema,
10
11
  ActionIdParamsSchema,
12
+ ActionRequestFailedResponseSchema,
13
+ ActionRunDetailSchema,
14
+ ActionRunInProgressResponseSchema,
11
15
  RequestActionBodySchema,
12
- RequestActionResponseSchema,
16
+ RuntimeStoppingResponseSchema,
13
17
  } from "../schemas/actions"
14
18
  import { ErrorResponseSchema } from "../schemas/common"
15
19
  import { handleRouteError } from "../utils/http"
@@ -92,20 +96,24 @@ export function registerActionRoutes(app: Elysia, host: SixbHostView) {
92
96
  .post(
93
97
  "/api/actions/:actionId",
94
98
  async (context) => {
95
- const { params, body, set } = context
99
+ const { params, body, set, request, server } = context
100
+ // An Action can outlast Bun's 10-second idle timeout: it has 30 seconds to reach its
101
+ // boundary, then edits that nothing interrupts, then up to 30 seconds of effects.
102
+ server?.timeout(request, 0)
103
+
96
104
  const sixb = requireRequestSixb(context)
97
105
  try {
98
106
  const parsedBody = RequestActionBodySchema.parse(body)
99
- const input = {
107
+ // No `request.signal`: a client that disconnects never cancels the run. Retrying with
108
+ // the same `runId` returns its record once it is terminal.
109
+ const run = await sixb.actions.request({
100
110
  actionId: params.actionId,
101
111
  subject: parsedBody.subject,
102
112
  params: parsedBody.params,
103
113
  runId: parsedBody.runId,
104
- }
105
- const result = await sixb.actions.request(input)
114
+ })
106
115
 
107
- set.status = 202
108
- return RequestActionResponseSchema.parse(result)
116
+ return serializeActionRunDetail(run)
109
117
  } catch (error) {
110
118
  return handleRouteError(error, set)
111
119
  }
@@ -114,13 +122,23 @@ export function registerActionRoutes(app: Elysia, host: SixbHostView) {
114
122
  params: ActionIdParamsSchema,
115
123
  body: RequestActionBodySchema,
116
124
  response: {
117
- 202: RequestActionResponseSchema,
125
+ 200: ActionRunDetailSchema,
118
126
  400: ErrorResponseSchema,
119
127
  403: ErrorResponseSchema,
120
128
  404: ErrorResponseSchema,
129
+ 409: ActionRunInProgressResponseSchema,
130
+ 500: ActionRequestFailedResponseSchema,
131
+ 503: RuntimeStoppingResponseSchema,
121
132
  },
122
133
  detail: {
123
134
  summary: "Request an action",
135
+ description:
136
+ "Runs the action and returns its terminal run. A run that fails is returned with " +
137
+ "status `failed`. Its effects run after the response, which does not wait for them. " +
138
+ "An error response usually means no run was requested, but a 500 can follow a run " +
139
+ "that started: request again with the same `runId` to get its record if it was " +
140
+ "written. A `runId` that was already recorded returns that run, and 409 while this " +
141
+ "server still runs it. 503 means the server is stopping and started nothing.",
124
142
  tags: [OPENAPI_TAGS.actions.name],
125
143
  operationId: "requestAction",
126
144
  security: accessTokenSecurityRequirement("requestAction"),
@@ -20,6 +20,7 @@ import type {
20
20
  } from "@sixb/core/storage"
21
21
  import type { Elysia } from "elysia"
22
22
  import { type InternalRequestAuthState, registerInternalRequestAuthState } from "../auth/scope"
23
+ import { RequestBodyTooLargeError, readRequestBodyWithLimit } from "../utils/request-body"
23
24
  import { DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES } from "./files"
24
25
 
25
26
  const MAX_AGENT_API_BODY_BYTES = 1_000_000
@@ -100,16 +101,11 @@ async function handleAgentApiGatewayRequest(input: {
100
101
  )
101
102
  }
102
103
 
103
- let body: ArrayBuffer | undefined
104
+ let body: Uint8Array<ArrayBuffer> | undefined
104
105
  try {
105
- body = await readRequestBody(
106
- input.request,
107
- isSimpleFileUpload(input.request.method, upstreamPath)
108
- ? DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES
109
- : MAX_AGENT_API_BODY_BYTES
110
- )
106
+ body = await readGatewayRequestBody(input.request, upstreamPath)
111
107
  } catch (error) {
112
- if (error instanceof PayloadTooLargeError) {
108
+ if (error instanceof RequestBodyTooLargeError) {
113
109
  return jsonError(413, error.message)
114
110
  }
115
111
  throw error
@@ -343,33 +339,26 @@ function copyHeader(source: Headers, target: Headers, name: string): void {
343
339
  }
344
340
  }
345
341
 
346
- async function readRequestBody(
342
+ async function readGatewayRequestBody(
347
343
  request: Request,
348
- maxBytes: number
349
- ): Promise<ArrayBuffer | undefined> {
344
+ upstreamPath: string
345
+ ): Promise<Uint8Array<ArrayBuffer> | undefined> {
350
346
  if (!request.body || request.method === "GET" || request.method === "HEAD") {
351
347
  return undefined
352
348
  }
353
349
 
354
- const reader = request.body.getReader()
355
- const chunks: Uint8Array[] = []
356
- let total = 0
357
-
358
- while (true) {
359
- const { done, value } = await reader.read()
360
- if (done) break
361
- total += value.byteLength
362
- if (total > maxBytes) {
363
- throw new PayloadTooLargeError(
364
- maxBytes === MAX_AGENT_API_BODY_BYTES
365
- ? "Agent API gateway request body exceeds 1MB."
366
- : `Agent API gateway file upload request body exceeds the ${maxBytes} byte limit.`
367
- )
368
- }
369
- chunks.push(value)
350
+ if (isSimpleFileUpload(request.method, upstreamPath)) {
351
+ return readRequestBodyWithLimit(
352
+ request,
353
+ DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES,
354
+ `Agent API gateway file upload request body exceeds the ${DEFAULT_SIMPLE_FILE_UPLOAD_BODY_BYTES} byte limit.`
355
+ )
370
356
  }
371
-
372
- return concatChunks(chunks, total)
357
+ return readRequestBodyWithLimit(
358
+ request,
359
+ MAX_AGENT_API_BODY_BYTES,
360
+ "Agent API gateway request body exceeds 1MB."
361
+ )
373
362
  }
374
363
 
375
364
  function isSimpleFileUpload(method: string, pathname: string): boolean {
@@ -386,19 +375,6 @@ function matchesWorkflowRunStart(pathname: string): boolean {
386
375
  )
387
376
  }
388
377
 
389
- function concatChunks(chunks: readonly Uint8Array[], total: number): ArrayBuffer {
390
- const buffer = new ArrayBuffer(total)
391
- const result = new Uint8Array(buffer)
392
- let offset = 0
393
- for (const chunk of chunks) {
394
- result.set(chunk, offset)
395
- offset += chunk.byteLength
396
- }
397
- return buffer
398
- }
399
-
400
378
  function jsonError(status: number, message: string): Response {
401
379
  return Response.json({ error: message }, { status })
402
380
  }
403
-
404
- class PayloadTooLargeError extends Error {}