@k9o/extension-manifest 1.5.0 → 1.7.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k9o/extension-manifest",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/builder.ts CHANGED
@@ -5,8 +5,8 @@
5
5
  * a camelCase author input shape (SDK casing rules) and emits
6
6
  * the snake_case wire shape the validator + platform consume:
7
7
  *
8
- * - `surfaces.runtimeApi` → `surfaces.runtime_api` (with `prefix` derived
9
- * from `slug` so authors don't have to repeat the slug-coupled URL)
8
+ * - `surfaces.runtimeApi` → `surfaces.runtime_api` (no `prefix`: the mount is
9
+ * fixed at `…/extensions/<slug>/api/`)
10
10
  * - `surfaces.backgroundLogic` → `surfaces.background_logic`
11
11
  * - `hooks.<event>` accepts a bare URL string (e.g. `"POST /hooks/enable"`)
12
12
  * and the builder wraps it into the wire-shape `{ url }`
@@ -52,9 +52,16 @@ import {
52
52
  type AnalyticsReadSurface,
53
53
  type AnalyticsWriteSurface,
54
54
  type EventBridgeSurface,
55
+ type PersonalDataDeclaration,
56
+ type DependsOnEntry,
57
+ type InstallConfigEntry,
58
+ type MessagingProviderDeclaration,
59
+ type WorkflowTemplateEntry,
60
+ type EventSubscriptionEntry,
61
+ type ErasureHookDeclaration,
55
62
  } from "./manifest.ts";
56
63
 
57
- /** runtime_api author input — `prefix` is derived from `slug` and omitted here. */
64
+ /** runtime_api author input — there is no `prefix`; the mount is fixed. */
58
65
  export type RuntimeApiAuthor = {
59
66
  /** Required only when `externalEndpoints` is non-empty. */
60
67
  spec?: string;
@@ -99,6 +106,8 @@ export type ExternalEndpointAuthor = {
99
106
  minRole?: ExternalEndpointMinRole;
100
107
  /** Required on (and only valid on) `anonymous` endpoints. */
101
108
  publicCapability?: ExternalEndpointPublicCapability;
109
+ /** Only valid on `extension` endpoints: the extension slugs admitted as callers. */
110
+ allowedCallers?: readonly string[];
102
111
  description: string;
103
112
  };
104
113
 
@@ -170,6 +179,19 @@ export type ManifestAuthor = {
170
179
  * `checker_role`: the project IAM role, by name, that must approve a proposal.
171
180
  */
172
181
  proposeOnly?: readonly { collection: string; checkerRole: string }[];
182
+ /** Personal-data declarations; the wire shape is the same snake_case shape, so entries pass through. */
183
+ personalData?: readonly PersonalDataDeclaration[];
184
+ /** Install settings; the wire shape is the same snake_case shape, so entries pass through (copied). */
185
+ /** Extensions this one needs installed and enabled; wire-shaped entries `{ slug, version_range, reason }`. */
186
+ dependsOn?: readonly DependsOnEntry[];
187
+ /** Ready-made workflows a workflow-template extension ships; wire-shaped entries, copied through verbatim (inner keys stay camelCase). */
188
+ workflowTemplates?: readonly WorkflowTemplateEntry[];
189
+ installConfig?: readonly InstallConfigEntry[];
190
+ messagingProvider?: MessagingProviderDeclaration;
191
+ /** Event subscriptions; same wire shape, entries pass through (copied). Each `invokes` names an `auth: "event"` endpoint. */
192
+ eventSubscriptions?: readonly EventSubscriptionEntry[];
193
+ /** The subject-erasure hook; same wire shape. `invokes` names an `auth: "erasure"` endpoint. */
194
+ erasureHook?: ErasureHookDeclaration;
173
195
  /**
174
196
  * Compatibility declarations (tokenset versioning + shadcn version pin).
175
197
  * Builder maps camelCase
@@ -190,7 +212,6 @@ export function defineManifest(input: ManifestAuthor): Manifest {
190
212
  const runtimeApi: RuntimeApiSurface | null =
191
213
  input.surfaces.runtimeApi
192
214
  ? {
193
- prefix: `/api/${input.slug}`,
194
215
  ...(input.surfaces.runtimeApi.spec !== undefined
195
216
  ? { spec: input.surfaces.runtimeApi.spec }
196
217
  : {}),
@@ -257,8 +278,8 @@ export function defineManifest(input: ManifestAuthor): Manifest {
257
278
  ? { dependencies: input.dependencies }
258
279
  : {}),
259
280
  // BFF endpoints. Author
260
- // camelCase `externalEndpoints[].{versionAttribute,minRole,publicCapability}` map to wire snake_case
261
- // `external_endpoints[].{version_attribute,min_role,public_capability}`.
281
+ // camelCase `externalEndpoints[].{versionAttribute,minRole,publicCapability,allowedCallers}` map to wire snake_case
282
+ // `external_endpoints[].{version_attribute,min_role,public_capability,allowed_callers}`.
262
283
  ...(input.externalEndpoints !== undefined
263
284
  ? {
264
285
  external_endpoints: input.externalEndpoints.map(
@@ -273,6 +294,7 @@ export function defineManifest(input: ManifestAuthor): Manifest {
273
294
  ...(e.publicCapability !== undefined
274
295
  ? { public_capability: e.publicCapability }
275
296
  : {}),
297
+ ...(e.allowedCallers !== undefined ? { allowed_callers: [...e.allowedCallers] } : {}),
276
298
  description: e.description,
277
299
  }),
278
300
  ),
@@ -291,6 +313,15 @@ export function defineManifest(input: ManifestAuthor): Manifest {
291
313
  ...(input.proposeOnly !== undefined
292
314
  ? { propose_only: input.proposeOnly.map((d) => ({ collection: d.collection, checker_role: d.checkerRole })) }
293
315
  : {}),
316
+ ...(input.personalData !== undefined
317
+ ? { personal_data: input.personalData.map((d) => ({ ...d, ...(d.columns ? { columns: d.columns.map((c) => ({ ...c })) } : {}) })) }
318
+ : {}),
319
+ ...(input.dependsOn !== undefined ? { depends_on: input.dependsOn.map((d) => structuredClone(d)) } : {}),
320
+ ...(input.workflowTemplates !== undefined ? { workflow_templates: input.workflowTemplates.map((t) => structuredClone(t)) } : {}),
321
+ ...(input.messagingProvider !== undefined ? { messaging_provider: structuredClone(input.messagingProvider) } : {}),
322
+ ...(input.installConfig !== undefined ? { install_config: input.installConfig.map((d) => structuredClone(d)) } : {}),
323
+ ...(input.eventSubscriptions !== undefined ? { event_subscriptions: input.eventSubscriptions.map((d) => structuredClone(d)) } : {}),
324
+ ...(input.erasureHook !== undefined ? { erasure_hook: { ...input.erasureHook } } : {}),
294
325
  // Design-system declarations. Author camelCase `compatibility.tokensetVersionMin` / `shadcnVersionMin`
295
326
  // map to wire snake_case `compatibility.tokenset_version_min` /
296
327
  // `shadcn_version_min`. `customTokens` is single-word camelCase-already-
package/src/index.ts CHANGED
@@ -30,6 +30,17 @@ export {
30
30
  PROPOSE_ONLY_CHECKER_ROLE_MAX_LENGTH,
31
31
  PROPOSE_ONLY_COLLECTION_PATTERN,
32
32
  PROPOSE_ONLY_MAX_PER_EXTENSION,
33
+ PERSONAL_DATA_COLUMN_CLASSES,
34
+ PERSONAL_DATA_COLUMNS_MAX_PER_ENTRY,
35
+ PERSONAL_DATA_ERASE_ROUTE_MAX_LENGTH,
36
+ PERSONAL_DATA_IDENTIFIER_MAX_LENGTH,
37
+ PERSONAL_DATA_IDENTIFIER_PATTERN,
38
+ PERSONAL_DATA_MAX_PER_EXTENSION,
39
+ PERSONAL_DATA_REVIEWED_COLUMNS_MAX_PER_ENTRY,
40
+ PERSONAL_DATA_REVIEWED_REASON_MAX_LENGTH,
41
+ USER_TABLE_MIN_ROLES,
42
+ USER_TABLES_MAX_PER_EXTENSION,
43
+ PERSONAL_DATA_SUBJECT_KINDS,
33
44
  WEBHOOK_REPLAY_WINDOW_MAX_SECS,
34
45
  WEBHOOK_REPLAY_WINDOW_MIN_SECS,
35
46
  MCP_TOOLS_MAX_PER_EXTENSION,
@@ -70,11 +81,59 @@ export {
70
81
  type ExternalEndpointPublicCapability,
71
82
  type FeatureFlagDeclaration,
72
83
  type ProposeOnlyDeclaration,
84
+ type PersonalDataColumnClass,
85
+ type PersonalDataDeclaration,
86
+ type DependsOnEntry,
87
+ type InstallConfigEntry,
88
+ type MessagingProviderDeclaration,
89
+ type MessagingPermission,
90
+ type MessagingChannel,
91
+ MESSAGING_CHANNELS,
92
+ type InstallConfigObjectField,
93
+ type InstallConfigType,
94
+ type EventSubscriptionEntry,
95
+ type ErasureHookDeclaration,
96
+ INSTALL_CONFIG_MAX_KEYS,
97
+ INSTALL_CONFIG_MAX_STORED_BYTES,
98
+ INSTALL_CONFIG_KEY_PATTERN,
99
+ INSTALL_CONFIG_TYPES,
100
+ INSTALL_CONFIG_MAX_STRING_LENGTH,
101
+ INSTALL_CONFIG_MAX_LIST_ITEMS,
102
+ INSTALL_CONFIG_MAX_OPEN_ITEM_LENGTH,
103
+ INSTALL_CONFIG_MAX_PATTERN_LENGTH,
104
+ INSTALL_CONFIG_SINKS,
105
+ INSTALL_CONFIG_EMAIL_FROM_SINK,
106
+ INSTALL_CONFIG_EMAIL_ADDRESS_MAX_LENGTH,
107
+ EVENT_SUBSCRIPTIONS_MAX_PER_EXTENSION,
108
+ EVENT_SUBSCRIPTION_TARGETS_MAX,
109
+ SUBSCRIPTION_COLLECTION_EVENTS,
110
+ SUBSCRIPTION_BUCKET_EVENTS,
111
+ SYSTEM_BUCKET_PREFIX,
112
+ type WorkflowTemplateEntry,
113
+ type WorkflowTemplateStep,
114
+ DEPENDS_ON_MAX_PER_EXTENSION,
115
+ WORKFLOW_TEMPLATES_MAX_PER_EXTENSION,
116
+ WORKFLOW_TEMPLATE_MAX_STEPS,
117
+ WORKFLOW_TEMPLATE_KEY_PATTERN,
118
+ WORKFLOW_TEMPLATE_TRIGGER_TYPES,
119
+ WORKFLOW_TEMPLATE_APPROVER_RESOLVERS,
120
+ WORKFLOW_TEMPLATE_APPROVER_SLOT_CONFIG_KEY,
121
+ WORKFLOW_TEMPLATE_APPROVER_SLOT_KEY_PATTERN,
122
+ WORKFLOW_TEMPLATE_APPROVER_SLOT_LABEL_MAX,
123
+ WORKFLOW_TEMPLATE_CREDENTIAL_KEYS,
124
+ WORKFLOW_TEMPLATE_SETTINGS_REFERENCE,
125
+ WORKFLOW_TEMPLATE_MAX_TOP_LEVEL_STEPS,
126
+ WORKFLOW_TEMPLATE_MAX_BRANCH_DEPTH,
127
+ WORKFLOW_TEMPLATE_EXTENSION_ACTION_PATTERN,
128
+ WORKFLOW_TRIGGER_TYPES,
129
+ WORKFLOW_ACTION_TYPES,
130
+ type PersonalDataSubjectKind,
73
131
  type FeatureFlagScope,
74
132
  type McpToolManifestEntry,
75
133
  type FilesPermission,
76
134
  type FlatRateConfig,
77
135
  type FunctionDescriptor,
136
+ type ExtensionsPermission,
78
137
  type FunctionsPermission,
79
138
  type GroupsPermission,
80
139
  type HookEvent,
@@ -96,6 +155,8 @@ export {
96
155
  type RuntimeApiSurface,
97
156
  type RuntimeRoute,
98
157
  type SchemaDeclaration,
158
+ type UserTableDeclaration,
159
+ type UserTableMinRole,
99
160
  type SurfaceCliArg,
100
161
  type SurfaceCliVerb,
101
162
  type Surfaces,
package/src/manifest.ts CHANGED
@@ -63,6 +63,16 @@ export type WebhooksPermission = {
63
63
  qualifier: readonly string[];
64
64
  };
65
65
 
66
+ /**
67
+ * Extension-to-extension invocation. The qualifier is a non-empty list of the exact slugs of OTHER extensions this one may
68
+ * call (never `"*"`, never its own slug). The callee must also declare an `auth: "extension"` endpoint for the call to land.
69
+ */
70
+ export type ExtensionsPermission = {
71
+ domain: "extensions";
72
+ action: "invoke";
73
+ qualifier: readonly string[];
74
+ };
75
+
66
76
  export type FunctionsPermission = {
67
77
  domain: "functions";
68
78
  action: "invoke";
@@ -225,11 +235,14 @@ export type AiPermission = {
225
235
  * compliance extensions only (`…/audit/project-events`); the catalogue refuses to sign it for any other extension and
226
236
  * the platform refuses to enable or serve it.
227
237
  */
228
- export type AuditPermission = {
229
- domain: "audit";
230
- action: "read";
231
- qualifier: "_self" | "project";
232
- };
238
+ export type AuditPermission =
239
+ | { domain: "audit"; action: "read"; qualifier: "_self" | "project" }
240
+ /**
241
+ * Write the extension's own audit events (`k9o.audit.emit()`, `POST /@<project>/extensions/<slug>/audit/events`).
242
+ * `"_self"` only: the platform stamps the event type with the extension's slug, and the row is marked as the
243
+ * extension's own statement.
244
+ */
245
+ | { domain: "audit"; action: "write"; qualifier: "_self" };
233
246
 
234
247
  export type Permission =
235
248
  | DocumentsPermission
@@ -240,6 +253,7 @@ export type Permission =
240
253
  | FilesPermission
241
254
  | WebhooksPermission
242
255
  | FunctionsPermission
256
+ | ExtensionsPermission
243
257
  | TablesPermission
244
258
  | ViewsPermission
245
259
  | IdentitiesPermission
@@ -253,7 +267,20 @@ export type Permission =
253
267
  | EgressMcpPermission
254
268
  | KiboPermission
255
269
  | AiPermission
256
- | AuditPermission;
270
+ | AuditPermission
271
+ | MessagingPermission;
272
+
273
+ /** The channels a messaging grant or provider names. Closed. */
274
+ export const MESSAGING_CHANNELS = ["chat", "sms", "whatsapp", "email", "voice", "push"] as const;
275
+ export type MessagingChannel = (typeof MESSAGING_CHANNELS)[number];
276
+
277
+ /**
278
+ * Messaging. `send` is qualified by the channels the extension may send on (one, or a list), never `"*"`.
279
+ * `request_approval` asks a person to approve something and takes `"*"`.
280
+ */
281
+ export type MessagingPermission =
282
+ | { domain: "messaging"; action: "send"; qualifier: MessagingChannel | readonly MessagingChannel[] }
283
+ | { domain: "messaging"; action: "request_approval"; qualifier: "*" };
257
284
 
258
285
  export type PermissionDomain = Permission["domain"];
259
286
 
@@ -285,8 +312,12 @@ export type PublicSurface = {
285
312
  };
286
313
 
287
314
  export type RuntimeApiSurface = {
288
- /** Must equal `/api/<slug>`; validator enforces. */
289
- prefix: string;
315
+ /**
316
+ * REMOVED: the mount is fixed at `…/extensions/<slug>/api/`. The gateway still
317
+ * accepts a declared value, which must equal `/api/<slug>`, while its transition switch is off, and refuses one once
318
+ * it is on. `defineManifest` no longer emits it; new manifests omit it.
319
+ */
320
+ prefix?: string;
290
321
  /** Path within the shipped bundle to the OpenAPI spec; spec-as-documentation Required only when `external_endpoints[]` is non-empty. */
291
322
  spec?: string;
292
323
  /**
@@ -524,8 +555,33 @@ export type SchemaDeclaration = {
524
555
  * conventions.
525
556
  */
526
557
  migrations: string;
558
+ /**
559
+ * Tables a signed-in operator may read and write through the gateway's
560
+ * user-facing tables route (, provisional), one entry per table.
561
+ * A table not named here is unreachable by users. Each entry's table must be
562
+ * in `tables`, appear once, and have a `personal_data[]` entry that declares
563
+ * `created_by` as class `identifier`. At most `USER_TABLES_MAX_PER_EXTENSION`.
564
+ */
565
+ user_tables?: readonly UserTableDeclaration[];
566
+ };
567
+
568
+ /** `schema.user_tables[]` entry. One `min_role` per table, for reads and writes. */
569
+ export type UserTableDeclaration = {
570
+ table: string;
571
+ min_role: UserTableMinRole;
527
572
  };
528
573
 
574
+ /** Closed sets of project roles, not a ladder. */
575
+ export const USER_TABLE_MIN_ROLES = [
576
+ "PROJECT_VIEWER",
577
+ "PROJECT_MEMBER",
578
+ "PROJECT_ANALYST",
579
+ "PROJECT_EDITOR",
580
+ "PROJECT_ADMIN",
581
+ ] as const;
582
+ export type UserTableMinRole = (typeof USER_TABLE_MIN_ROLES)[number];
583
+ export const USER_TABLES_MAX_PER_EXTENSION = 25;
584
+
529
585
  // --- Hooks declaration (+) -----------------------------------
530
586
 
531
587
  /**
@@ -808,12 +864,22 @@ export type ExternalEndpointPublicCapability = (typeof EXTERNAL_ENDPOINT_PUBLIC_
808
864
  * `EXTENSION_INVOCATION_DENIED` for external requests)
809
865
  * - `schedule`: called only by the platform's scheduler, for one of the extension's
810
866
  * `schedules`. Every other caller gets the 404 an undeclared path gets. Takes no `min_role`.
867
+ * - `event`: called only by the platform's event drain, delivering one of the extension's `event_subscriptions`. Takes no `min_role`.
868
+ * - `erasure`: called only by the platform's subject-erasure saga, for the extension's `erasure_hook`. Takes no `min_role`.
869
+ * - `extension`: reachable only by another extension holding `(extensions, invoke, [<this slug>])`; an operator cannot
870
+ * reach it. `min_role` is optional, and `allowed_callers` is required: the slugs of the extensions admitted as callers.
871
+ * - `platform`: called only by a request the platform builds for a named purpose: the breached-password range lookup, or an
872
+ * install setting's `verify`. Takes no `min_role`; the caller arrives as `{ kind: "platform", purpose }`.
811
873
  */
812
874
  export const EXTERNAL_ENDPOINT_AUTH_KINDS = [
813
875
  "operator-jwt",
814
876
  "anonymous",
815
877
  "plugin-token",
816
878
  "schedule",
879
+ "event",
880
+ "erasure",
881
+ "extension",
882
+ "platform",
817
883
  ] as const;
818
884
  export type ExternalEndpointAuthKind =
819
885
  (typeof EXTERNAL_ENDPOINT_AUTH_KINDS)[number];
@@ -861,6 +927,46 @@ export type ProposeOnlyDeclaration = {
861
927
  checker_role: string;
862
928
  };
863
929
 
930
+ /** Cap on `personal_data` entries per extension. */
931
+ export const PERSONAL_DATA_MAX_PER_EXTENSION = 500;
932
+ /** Who a table or collection's personal data is about; decides which erasure path reaches it. */
933
+ export const PERSONAL_DATA_SUBJECT_KINDS = ["end_user", "member", "contact", "external"] as const;
934
+ export type PersonalDataSubjectKind = (typeof PERSONAL_DATA_SUBJECT_KINDS)[number];
935
+ /** What a column holds. */
936
+ export const PERSONAL_DATA_COLUMN_CLASSES = ["contact", "content", "identifier", "health", "financial"] as const;
937
+ export type PersonalDataColumnClass = (typeof PERSONAL_DATA_COLUMN_CLASSES)[number];
938
+ /** A table, collection, subject-column or column name. */
939
+ export const PERSONAL_DATA_IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
940
+ export const PERSONAL_DATA_IDENTIFIER_MAX_LENGTH = 63;
941
+ export const PERSONAL_DATA_COLUMNS_MAX_PER_ENTRY = 200;
942
+ export const PERSONAL_DATA_ERASE_ROUTE_MAX_LENGTH = 256;
943
+ /** `reviewed_columns` on a table entry: at most this many, each with a reason of 1 to the second constant's length. */
944
+ export const PERSONAL_DATA_REVIEWED_COLUMNS_MAX_PER_ENTRY = 200;
945
+ export const PERSONAL_DATA_REVIEWED_REASON_MAX_LENGTH = 200;
946
+
947
+ /**
948
+ * One table or collection's personal-data declaration (; the gateway's `ManifestPersonalDataEntry`).
949
+ * Name exactly one of `table` and `collection`. Either `no_personal_data: true` alone, or a subject kind with its columns:
950
+ * `subject_column` is required for `end_user`, `member` and `contact`. An `external` entry is erased through the manifest's
951
+ * `erasure_hook`, which it then requires; `erase_route` is retired and refused.
952
+ */
953
+ export type PersonalDataDeclaration = {
954
+ table?: string;
955
+ collection?: string;
956
+ no_personal_data?: true;
957
+ subject_kind?: PersonalDataSubjectKind;
958
+ columns?: readonly { name: string; class: PersonalDataColumnClass }[];
959
+ subject_column?: string;
960
+ /** Retired: an `external` entry is erased through `erasure_hook`. The signer refuses it (`erase_route_retired`). */
961
+ erase_route?: string;
962
+ /**
963
+ * On a table entry only: columns of a type the platform treats as personal-data-bearing (email, phone, json, network address, money) that
964
+ * hold no data about a subject, each with the reason. A covered-type column must be in `columns` or here, or the bundle is refused at upload.
965
+ * Allowed beside `no_personal_data`.
966
+ */
967
+ reviewed_columns?: readonly { name: string; reason: string }[];
968
+ };
969
+
864
970
  /**
865
971
  * BFF endpoint declaration.
866
972
  *
@@ -889,6 +995,11 @@ export type ExternalEndpointDeclaration = {
889
995
  min_role?: ExternalEndpointMinRole;
890
996
  /** Required on (and only valid on) an `anonymous` endpoint. */
891
997
  public_capability?: ExternalEndpointPublicCapability;
998
+ /**
999
+ * Required on an `extension` endpoint and valid on no other: the slugs of the extensions admitted as callers (1 to 25, no repeats,
1000
+ * never this extension's own slug). A caller outside the list is refused even when it holds the `extensions` `invoke` grant.
1001
+ */
1002
+ allowed_callers?: readonly string[];
892
1003
  /** Human-readable, 1-280 chars; surfaces in Console extension-inspector + Hub listing. */
893
1004
  description: string;
894
1005
  };
@@ -1100,8 +1211,8 @@ export type FeatureFlagDeclaration = {
1100
1211
  * Three hard rules:
1101
1212
  * 1. `requiredGrants` = byte-identical/ (resource, action, qualifier)
1102
1213
  * triples; validated against the closed vocabulary.
1103
- * 2. `waypointClass` = billing meter metadata only — never a gate or enforcement
1104
- * branch (anti-downgrade; escalate-only).
1214
+ * 2. `governedOpClass` is an optional capability declaration, never the emitted
1215
+ * class: the gateway derives that at the gate and ignores this field there.
1105
1216
  * 3. Agent scope bounds (sub:U ceiling + scopeConstraints) are enforced
1106
1217
  * by the gateway, not here.
1107
1218
  */
@@ -1117,10 +1228,10 @@ export type McpToolManifestEntry = {
1117
1228
  */
1118
1229
  inputSchema: Record<string, unknown>;
1119
1230
  /**
1120
- * Billing meter-class tag. Meter metadata only — NEVER used as a gate or
1121
- * enforcement branch. Anti-downgrade: escalate-only.
1231
+ * Optional capability declaration ("brokered" = brokerage-eligible). Never the
1232
+ * emitted class: the gateway derives that at the gate and never reads this.
1122
1233
  */
1123
- waypointClass: string;
1234
+ governedOpClass?: "standard" | "semantic" | "brokered";
1124
1235
  /**
1125
1236
  * (resource, action, qualifier) grant triples required by this tool.
1126
1237
  * Byte-identical to the/ Permission shape; validated against
@@ -1128,8 +1239,10 @@ export type McpToolManifestEntry = {
1128
1239
  * the extension's top-level permissions.
1129
1240
  */
1130
1241
  requiredGrants: readonly Permission[];
1131
- /** Whether a human must attest before this tool's output is acted upon. */
1132
- requiresHumanAttestation: boolean;
1242
+ /** Whether every call is held for attestation before it runs. */
1243
+ requiresAttestation: boolean;
1244
+ /** Opt into advisory classification on invoke. Advisory only: it never gates. */
1245
+ advisoryClassification?: boolean;
1133
1246
  /** Idempotency contract for this tool. */
1134
1247
  idempotency?: {
1135
1248
  /** Whether callers MUST supply an idempotency key. */
@@ -1210,6 +1323,11 @@ export type CredentialRequirement = {
1210
1323
  destination_path_prefix?: string;
1211
1324
  /** `issuer: "operator-endpoint"` only (custody model item 8). */
1212
1325
  purpose?: string;
1326
+ /**
1327
+ * `issuer: "operator-endpoint"` only: the shapes the operator may pick when binding the role, 1 to 8 distinct launch shapes with `shape`
1328
+ * among them. The binding records the one the operator chose.
1329
+ */
1330
+ shapes?: readonly string[];
1213
1331
  dimensions?: readonly number[];
1214
1332
  protocols?: readonly string[];
1215
1333
  suggestedModels?: readonly { id: string; version: string; widths: readonly number[]; matryoshka?: boolean }[];
@@ -1288,6 +1406,41 @@ export type Manifest = {
1288
1406
  * `/propose` routes; an approval by a holder of `checker_role` (a project IAM role, by name) applies it.
1289
1407
  */
1290
1408
  propose_only?: readonly ProposeOnlyDeclaration[];
1409
+ /**
1410
+ * Personal-data declarations: one entry per table and per written collection, naming whose data it holds
1411
+ * and which columns carry it, or `no_personal_data`. Up to `PERSONAL_DATA_MAX_PER_EXTENSION`.
1412
+ */
1413
+ personal_data?: readonly PersonalDataDeclaration[];
1414
+ /**
1415
+ * Extensions this one needs installed and enabled, each at a version in range. At most `DEPENDS_ON_MAX_PER_EXTENSION`, never the
1416
+ * extension itself, no duplicate slug. The gateway declares and validates it; its install-time check is a later item there.
1417
+ */
1418
+ depends_on?: readonly DependsOnEntry[];
1419
+ /**
1420
+ * Ready-made workflows a `workflow-template` extension ships (provisional): each a seed for one `_sys.workflows` row, data and never code.
1421
+ * Allowed only when `attribution.function_category` is `workflow-template`. At most `WORKFLOW_TEMPLATES_MAX_PER_EXTENSION`.
1422
+ */
1423
+ workflow_templates?: readonly WorkflowTemplateEntry[];
1424
+ /**
1425
+ * Install settings: non-secret values an installer provides, each with a closed type, a bound and a required default.
1426
+ * Never a host, a URL or a secret. At most `INSTALL_CONFIG_MAX_KEYS`.
1427
+ */
1428
+ install_config?: readonly InstallConfigEntry[];
1429
+ /**
1430
+ * The channels this extension serves as a messaging provider. `send_function` names a sandbox-tier function the manifest
1431
+ * declares and `inbound_path` a declared `webhookIngress` path. A push provider also names `platforms` and `push_service`.
1432
+ */
1433
+ messaging_provider?: MessagingProviderDeclaration;
1434
+ /**
1435
+ * Event subscriptions: the platform delivers each matching record or object event to `invokes`, a declared
1436
+ * `auth: "event"` endpoint. At most `EVENT_SUBSCRIPTIONS_MAX_PER_EXTENSION`.
1437
+ */
1438
+ event_subscriptions?: readonly EventSubscriptionEntry[];
1439
+ /**
1440
+ * The subject-erasure hook: `invokes` names a declared `auth: "erasure"` endpoint the platform calls when a subject is
1441
+ * erased. Required when any `personal_data` entry is `external`.
1442
+ */
1443
+ erasure_hook?: ErasureHookDeclaration;
1291
1444
  /**
1292
1445
  * Webhook ingress declarations. 21-value scheme registry
1293
1446
  * (20 first-class + `"custom"` escape) per `WEBHOOK_INGRESS_SCHEMES`. The key is
@@ -1330,3 +1483,196 @@ export type Manifest = {
1330
1483
  */
1331
1484
  mcp_tools?: readonly McpToolManifestEntry[];
1332
1485
  };
1486
+
1487
+ /** One `depends_on[]` entry: another extension this one needs, at a version in range. */
1488
+ export type DependsOnEntry = {
1489
+ /** The other extension's catalogue slug; never this extension's own. 2 to 63 characters. */
1490
+ slug: string;
1491
+ /** A semver range in the npm form, such as `^2.1.0`. 1 to 64 characters. */
1492
+ version_range: string;
1493
+ /** Why the extension needs it, shown to the installer. 1 to 200 characters. */
1494
+ reason: string;
1495
+ };
1496
+
1497
+ export const DEPENDS_ON_MAX_PER_EXTENSION = 20;
1498
+ export const WORKFLOW_TEMPLATES_MAX_PER_EXTENSION = 20;
1499
+ /** The longest chain a template may carry: the workflow routes' own step cap. */
1500
+ export const WORKFLOW_TEMPLATE_MAX_STEPS = 100;
1501
+ export const WORKFLOW_TEMPLATE_KEY_PATTERN = /^[a-z][a-z0-9_]{0,62}$/;
1502
+ /** What a template's trigger may be: the other two trigger types need ids of one project. */
1503
+ export const WORKFLOW_TEMPLATE_TRIGGER_TYPES = ["manual", "scheduled", "webhook"] as const;
1504
+ /** A template's approval step resolves by role only; a group or named users are ids of one project. */
1505
+ export const WORKFLOW_TEMPLATE_APPROVER_RESOLVERS = ["role"] as const;
1506
+ /** The `approval_step.config` key that declares an approver slot, `{ key, label }`, which the operator maps to a role. */
1507
+ export const WORKFLOW_TEMPLATE_APPROVER_SLOT_CONFIG_KEY = "approverSlot";
1508
+ export const WORKFLOW_TEMPLATE_APPROVER_SLOT_KEY_PATTERN = /^[a-z][a-z0-9_]{0,62}$/;
1509
+ export const WORKFLOW_TEMPLATE_APPROVER_SLOT_LABEL_MAX = 120;
1510
+ /** Keys that name a credential: anywhere in a template they are refused. */
1511
+ export const WORKFLOW_TEMPLATE_CREDENTIAL_KEYS = ["credentialRef", "credential_ref", "credentialRole", "credential_role"] as const;
1512
+ /** A template holds literal defaults: a string that contains this reference form is refused. */
1513
+ export const WORKFLOW_TEMPLATE_SETTINGS_REFERENCE = "${settings.";
1514
+ /** The most steps at the top level of a template, and how deep its branches nest. */
1515
+ export const WORKFLOW_TEMPLATE_MAX_TOP_LEVEL_STEPS = 50;
1516
+ export const WORKFLOW_TEMPLATE_MAX_BRANCH_DEPTH = 3;
1517
+ /** An `invoke_extension` step's `config.action`: `<extension slug>:<action name>`. */
1518
+ export const WORKFLOW_TEMPLATE_EXTENSION_ACTION_PATTERN = /^[a-z][a-z0-9-]*:[a-z][a-z0-9_-]*$/;
1519
+ export const WORKFLOW_TRIGGER_TYPES = ["view_row_event", "form_submission", "scheduled", "manual", "webhook"] as const;
1520
+ export const WORKFLOW_ACTION_TYPES = [
1521
+ "write_collection",
1522
+ "read_collection",
1523
+ "invoke_function",
1524
+ "invoke_extension",
1525
+ "llm_inference",
1526
+ "send_notification",
1527
+ "http_request",
1528
+ "approval_step",
1529
+ "branch",
1530
+ "wait",
1531
+ "start_workflow",
1532
+ ] as const;
1533
+
1534
+ /** One step of a workflow template: an action type and its config. */
1535
+ export type WorkflowTemplateStep = {
1536
+ action_type: string;
1537
+ config?: Record<string, unknown>;
1538
+ retry?: unknown;
1539
+ condition?: unknown;
1540
+ parallel?: boolean;
1541
+ };
1542
+
1543
+ /** One `workflow_templates[]` entry: a seed for one workflow row in the installing project. */
1544
+ export type WorkflowTemplateEntry = {
1545
+ /** The template's identity across versions, `^[a-z][a-z0-9_]{0,62}$`, unique within the extension. */
1546
+ key: string;
1547
+ name: string;
1548
+ description: string;
1549
+ /** A template uses one of `WORKFLOW_TEMPLATE_TRIGGER_TYPES`; the other trigger types need ids of one project. */
1550
+ trigger_type: (typeof WORKFLOW_TRIGGER_TYPES)[number];
1551
+ trigger_config: Record<string, unknown>;
1552
+ actions: readonly WorkflowTemplateStep[];
1553
+ rbac_binding?: Record<string, unknown>;
1554
+ /** Slugs of the extensions the actions call; each must also be in `depends_on`. */
1555
+ requires_extensions?: readonly string[];
1556
+ };
1557
+
1558
+ /** At most this many `install_config[]` entries. */
1559
+ export const INSTALL_CONFIG_MAX_KEYS = 64;
1560
+ /** At most this many bytes of stored values per install (key plus JSON value, UTF-8), checked on the declared maxima at publish. */
1561
+ export const INSTALL_CONFIG_MAX_STORED_BYTES = 64 * 1024;
1562
+ /** A setting's name, and an object field's name. */
1563
+ export const INSTALL_CONFIG_KEY_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
1564
+ export const INSTALL_CONFIG_TYPES = ["boolean", "integer", "enum", "string", "list", "object", "email_address"] as const;
1565
+ export type InstallConfigType = (typeof INSTALL_CONFIG_TYPES)[number];
1566
+ /** A `string` setting is at most this many characters. */
1567
+ export const INSTALL_CONFIG_MAX_STRING_LENGTH = 1024;
1568
+ /** A `list` setting holds at most this many items. */
1569
+ export const INSTALL_CONFIG_MAX_LIST_ITEMS = 100;
1570
+ /** An open `list` (one with `item_pattern`) holds items of at most this many characters. */
1571
+ export const INSTALL_CONFIG_MAX_OPEN_ITEM_LENGTH = 255;
1572
+ /** The longest `pattern` or `item_pattern`. */
1573
+ export const INSTALL_CONFIG_MAX_PATTERN_LENGTH = 512;
1574
+ /**
1575
+ * Where the platform may use a setting's value. `header_value`: each item of an open list goes into a request header value, never a URL,
1576
+ * host or path. `email_from`: an `email_address` setting's only sink, the sender of an email sent through this provider.
1577
+ */
1578
+ export const INSTALL_CONFIG_SINKS = ["header_value", "email_from"] as const;
1579
+ /** An `email_address` setting's only sink. */
1580
+ export const INSTALL_CONFIG_EMAIL_FROM_SINK = "email_from";
1581
+ /** The longest address an `email_address` value may be. */
1582
+ export const INSTALL_CONFIG_EMAIL_ADDRESS_MAX_LENGTH = 254;
1583
+
1584
+ /** One field of an `object` setting: a scalar form with no label, default, fields or rules of its own. */
1585
+ export type InstallConfigObjectField = {
1586
+ type: "boolean" | "integer" | "enum" | "string";
1587
+ min?: number;
1588
+ max?: number;
1589
+ sentinels?: readonly number[];
1590
+ values?: readonly string[];
1591
+ max_length?: number;
1592
+ /** An anchored regular expression (`^...$`) every value must match. */
1593
+ pattern?: string;
1594
+ };
1595
+
1596
+ /**
1597
+ * One `install_config[]` entry. `integer` needs `min` and `max`; `enum` needs `values`; `string` needs `max_length` and an anchored
1598
+ * `pattern`; `list` needs `max_items` and either a closed `values` set or an open `item_pattern` with `item_max_length` and `sink`; `object` needs
1599
+ * `fields`, scalar forms only, and may carry `sum_equals` rules.
1600
+ */
1601
+ export type InstallConfigEntry = {
1602
+ /** `^[a-z][a-z0-9_]{0,63}$`, unique within the extension. */
1603
+ key: string;
1604
+ label: string;
1605
+ description: string;
1606
+ type: InstallConfigType;
1607
+ /** The value an install reads until an admin sets one. It must satisfy the entry's own type and bounds. */
1608
+ default: unknown;
1609
+ min?: number;
1610
+ max?: number;
1611
+ sentinels?: readonly number[];
1612
+ values?: readonly string[];
1613
+ max_items?: number;
1614
+ max_length?: number;
1615
+ pattern?: string;
1616
+ fields?: Readonly<Record<string, InstallConfigObjectField>>;
1617
+ rules?: readonly { rule: "sum_equals"; keys: readonly string[]; value: number }[];
1618
+ item_pattern?: string;
1619
+ item_max_length?: number;
1620
+ sink?: (typeof INSTALL_CONFIG_SINKS)[number];
1621
+ /** True when a change to the setting needs a fresh step-up, because it guards a control. */
1622
+ protected?: boolean;
1623
+ /** True when an admin must write a value at install: the install is refused without one, and a later write cannot clear it. The `default` does not satisfy it. */
1624
+ required?: boolean;
1625
+ /**
1626
+ * The extension's own check of this setting's value, run only when an admin presses Verify: `"<METHOD>:<path>"`, exactly a declared
1627
+ * `external_endpoints` entry with `auth: "platform"`. The platform calls it with `{ value, installId }` and nothing else; it answers
1628
+ * `{ "result": "verified" }` or `{ "result": "not_verified" }`. The value reads as verified only after a Verify that answers `verified`
1629
+ * for the value now stored.
1630
+ */
1631
+ verify?: string;
1632
+ };
1633
+
1634
+ /** At most this many `event_subscriptions[]` entries. */
1635
+ export const EVENT_SUBSCRIPTIONS_MAX_PER_EXTENSION = 8;
1636
+ /** A subscription names at most this many targets. */
1637
+ export const EVENT_SUBSCRIPTION_TARGETS_MAX = 25;
1638
+ /** The record events a `collections` subscription may name. */
1639
+ export const SUBSCRIPTION_COLLECTION_EVENTS = ["insert", "update", "delete", "upsert"] as const;
1640
+ /** The object events a `buckets` subscription may name. */
1641
+ export const SUBSCRIPTION_BUCKET_EVENTS = ["object.created", "object.deleted", "object.expired"] as const;
1642
+ /** A system bucket's name prefix: only the platform writes one, so nothing may subscribe to it. */
1643
+ export const SYSTEM_BUCKET_PREFIX = "k9o-";
1644
+
1645
+ /** One `event_subscriptions[]` entry. */
1646
+ export type EventSubscriptionEntry = {
1647
+ /** 1 to 64 characters of `[a-z0-9-]`, unique within the extension. */
1648
+ name: string;
1649
+ source: "collections" | "buckets";
1650
+ /** `granted`: every collection in the install's `documents read` grant (or every bucket in its `files read` grant). Else 1 to 25 names, each inside the extension's own read grant. */
1651
+ targets: "granted" | readonly string[];
1652
+ /** The source's events: one to seven, no repeats. */
1653
+ events: readonly string[];
1654
+ /** A record filter for `collections`; `pathPrefix`, `contentType` and `sizeBytes` for `buckets`. */
1655
+ filter?: unknown;
1656
+ /** `"<METHOD>:<path>"`, exactly a declared `auth: "event"` endpoint's method and literal path. */
1657
+ invokes: string;
1658
+ };
1659
+
1660
+ /** The `erasure_hook` declaration. */
1661
+ export type ErasureHookDeclaration = {
1662
+ /** `"<METHOD>:<path>"`, exactly a declared `auth: "erasure"` endpoint's method and literal path. */
1663
+ invokes: string;
1664
+ };
1665
+
1666
+ /** `messaging_provider`: the channels an extension serves as a messaging provider. */
1667
+ export type MessagingProviderDeclaration = {
1668
+ channels: readonly MessagingChannel[];
1669
+ /** Required with `push`, refused otherwise. */
1670
+ platforms?: readonly ("ios" | "android")[];
1671
+ /** Required with `push`, refused otherwise. `apns` reaches ios only. */
1672
+ push_service?: "apns" | "fcm";
1673
+ /** A sandbox-tier `surfaces.background_logic.functions[]` entry. */
1674
+ send_function: string;
1675
+ /** A declared `webhookIngress` path. */
1676
+ inbound_path?: string;
1677
+ limits?: { templates?: boolean; read_receipts?: boolean; max_recipients?: number };
1678
+ };
@@ -24,6 +24,7 @@ import type {
24
24
  SchemaPermission,
25
25
  DocumentsPermission,
26
26
  EgressPermission,
27
+ ExtensionsPermission,
27
28
  EgressAuthenticatedSendPermission,
28
29
  EgressMcpPermission,
29
30
  FilesPermission,
@@ -149,6 +150,18 @@ export const p = {
149
150
  qualifier: [...events],
150
151
  }),
151
152
  },
153
+ extensions: {
154
+ /** Call other extensions: the exact slugs of the callees (never `"*"`, never this extension's own slug). */
155
+ invoke: (...slugs: string[]): ExtensionsPermission => {
156
+ if (slugs.length === 0) {
157
+ throw new Error("empty qualifier: name the extensions to call (an empty list grants nothing)");
158
+ }
159
+ if (slugs.includes("*")) {
160
+ throw new Error('the extensions domain names exact slugs; "*" is not accepted');
161
+ }
162
+ return { domain: "extensions", action: "invoke", qualifier: [...slugs] };
163
+ },
164
+ },
152
165
  functions: {
153
166
  invoke: (...q: string[]): FunctionsPermission => ({
154
167
  domain: "functions",