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.
| * |
| 6 | * One app can mix models — UI/actions/normal tools Coline-hosted while a |
| 7 | * Salesforce sync stays on developer infrastructure. Override keys name |
| 8 | * declared capabilities: a tool name (`crm.sync_salesforce`), a file type |
| 9 | * key (`crm.contact`, covering its render handlers), or `"home"` for the |
| 10 | * home surface. Key membership is validated at the manifest level. |
| 11 | */ |
| 12 |
| 13 | export const EXECUTION_MODELS = ["coline", "external"] as const; |
| 14 | export const executionModelSchema = z.enum(EXECUTION_MODELS); |
| 15 | export type ExecutionModel = z.infer<typeof executionModelSchema>; |
| 16 |
| 17 | export const appHostingV2Schema = z |
| 18 | .strictObject({ |
| 19 | default: executionModelSchema.default("coline"), |
| 20 | overrides: z.record(z.string().trim().min(1).max(200), executionModelSchema).default({}), |
| 21 | external: z |
| 22 | .strictObject({ |
| 23 | baseUrl: z.url().max(2000), |
| 24 | }) |
| 25 | .optional(), |
| 26 | }) |
| 27 | .superRefine((hosting, ctx) => { |
| 28 | const usesExternal = |
| 29 | hosting.default === "external" || |
| 30 | Object.values(hosting.overrides).includes("external"); |
| 31 | if (usesExternal && !hosting.external) { |
| 32 | ctx.addIssue({ |
| 33 | code: "custom", |
| 34 | path: ["external"], |
| 35 | message: |
| 36 | "hosting.external.baseUrl is required when any capability executes externally.", |
| 37 | }); |
| 38 | } |
| 39 | }) |
| 40 | .prefault({}); |
| 41 |
| 42 | export type AppHostingV2 = z.infer<typeof appHostingV2Schema>; |
| 43 | export type AppHostingV2Input = z.input<typeof appHostingV2Schema>; |
| 44 |
| 45 | /** |
| 46 | * Outbound network policy for Coline-hosted logic and tier-2 sandboxes |
| 47 | * (plan §6.2, §12.3). Default: no outbound network at all. |
| 48 | */ |
| 49 | const allowedHostSchema = z |
| 50 | .string() |
| 51 | .trim() |
| 52 | .toLowerCase() |
| 53 | .regex( |
| 54 | /^(\*\.)?([a-z0-9-]+\.)+[a-z]{2,}$/, |
| 55 | "Allowed hosts are domains, optionally with a leading `*.` wildcard.", |
| 56 | ) |
| 57 | .max(253); |
| 58 |
| 59 | export const appNetworkPolicySchema = z |
| 60 | .strictObject({ |
| 61 | allowedHosts: z.array(allowedHostSchema).max(50).default([]), |
| 62 | }) |
| 63 | .default({ allowedHosts: [] }); |
| 64 |
| 65 | export type AppNetworkPolicy = z.infer<typeof appNetworkPolicySchema>; |
| 66 |