The Coline App SDK: apps, tools, file types and surfaces that run inside Coline workspaces, and public websites with Coline Sites. TypeScript, with an in-memory test workspace. MIT.
| 4 |
| 5 | /** |
| 6 | * Wire payloads for surface rendering (plan §7.1, §9.3), carried inside |
| 7 | * the protocol v2 envelope with `kind: "render.surface"`. |
| 8 | * |
| 9 | * One render kind covers every tree-tier surface: the app home, and a |
| 10 | * file type's editor/preview/inline surfaces. Render contexts are |
| 11 | * read-only by construction — the invocation token carries effect "read", |
| 12 | * so a render handler that attempts a mutation fails at the capability |
| 13 | * gate (plan §12.2). |
| 14 | */ |
| 15 |
| 16 | export const RENDER_SURFACE_KIND = "render.surface" as const; |
| 17 |
| 18 | export const RENDER_SURFACES = ["home", "editor", "preview", "inline"] as const; |
| 19 | export const renderSurfaceSchema = z.enum(RENDER_SURFACES); |
| 20 | export type RenderSurface = z.infer<typeof renderSurfaceSchema>; |
| 21 |
| 22 | export const renderSurfacePayloadSchema = z.strictObject({ |
| 23 | surface: renderSurfaceSchema, |
| 24 | /** Present for file surfaces; absent for "home". */ |
| 25 | file: z |
| 26 | .strictObject({ |
| 27 | fileId: z.string().min(1).max(200), |
| 28 | name: z.string().max(300), |
| 29 | typeKey: z.string().min(1).max(160), |
| 30 | version: z.number().int().min(0), |
| 31 | }) |
| 32 | .optional(), |
| 33 | /** The file's JSON document, for file surfaces on stored types. */ |
| 34 | document: z.record(z.string(), z.unknown()).optional(), |
| 35 | capabilities: toolInvokeCapabilitiesSchema, |
| 36 | }); |
| 37 | export type RenderSurfacePayload = z.infer<typeof renderSurfacePayloadSchema>; |
| 38 |
| 39 | export const renderSurfaceResponseSchema = z.union([ |
| 40 | z.strictObject({ result: z.strictObject({ tree: colineUiNodeSchema }) }), |
| 41 | z.strictObject({ |
| 42 | error: z.strictObject({ |
| 43 | code: z.string().min(1).max(120), |
| 44 | message: z.string().min(1).max(2000), |
| 45 | }), |
| 46 | }), |
| 47 | ]); |
| 48 | export type RenderSurfaceResponse = z.infer<typeof renderSurfaceResponseSchema>; |
| 49 |