openclaw-nostr 2026.7.30

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 (72) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/README.md +845 -0
  3. package/api.ts +6 -0
  4. package/index.ts +69 -0
  5. package/node_modules/cascadia-ts/cascadia.ts +1187 -0
  6. package/node_modules/cascadia-ts/dist/cascadia.d.ts +607 -0
  7. package/node_modules/cascadia-ts/dist/cascadia.js +705 -0
  8. package/node_modules/cascadia-ts/package.json +21 -0
  9. package/openclaw.plugin.json +153 -0
  10. package/package.json +81 -0
  11. package/runtime-api.ts +12 -0
  12. package/setup-api.ts +1 -0
  13. package/setup-entry.ts +4 -0
  14. package/src/channel-actions.test.ts +304 -0
  15. package/src/channel-actions.ts +199 -0
  16. package/src/channel.dm-access.test.ts +387 -0
  17. package/src/channel.inbound.test.ts +476 -0
  18. package/src/channel.lifecycle.test.ts +768 -0
  19. package/src/channel.outbound.test.ts +1143 -0
  20. package/src/channel.test.ts +175 -0
  21. package/src/channel.ts +2827 -0
  22. package/src/config-schema.test.ts +486 -0
  23. package/src/config-schema.ts +356 -0
  24. package/src/default-relays.ts +1 -0
  25. package/src/fleet-agent.test.ts +423 -0
  26. package/src/fleet-agent.ts +549 -0
  27. package/src/metrics.ts +466 -0
  28. package/src/nip46-cutover.test.ts +324 -0
  29. package/src/nip46-cutover.ts +461 -0
  30. package/src/nip46-doctor.test.ts +191 -0
  31. package/src/nip46-doctor.ts +329 -0
  32. package/src/nip46-enroll.test.ts +346 -0
  33. package/src/nip46-enroll.ts +567 -0
  34. package/src/nip46-signer.test.ts +809 -0
  35. package/src/nip46-signer.ts +1263 -0
  36. package/src/nip46-status.test.ts +186 -0
  37. package/src/nip46-status.ts +250 -0
  38. package/src/nip51-lists.test.ts +404 -0
  39. package/src/nip51-lists.ts +777 -0
  40. package/src/nostr-access.test.ts +175 -0
  41. package/src/nostr-access.ts +134 -0
  42. package/src/nostr-bus-nip29.ts +998 -0
  43. package/src/nostr-bus-relay.ts +477 -0
  44. package/src/nostr-bus-types.ts +392 -0
  45. package/src/nostr-bus.fuzz.test.ts +533 -0
  46. package/src/nostr-bus.integration.test.ts +505 -0
  47. package/src/nostr-bus.protocol.test.ts +2057 -0
  48. package/src/nostr-bus.test.ts +235 -0
  49. package/src/nostr-bus.ts +1868 -0
  50. package/src/nostr-capabilities-extended.test.ts +612 -0
  51. package/src/nostr-capabilities.ts +719 -0
  52. package/src/nostr-discovery.test.ts +568 -0
  53. package/src/nostr-discovery.ts +336 -0
  54. package/src/nostr-extras.test.ts +88 -0
  55. package/src/nostr-extras.ts +136 -0
  56. package/src/nostr-profile-http.test.ts +662 -0
  57. package/src/nostr-profile-http.ts +836 -0
  58. package/src/nostr-profile-import.test.ts +274 -0
  59. package/src/nostr-profile-import.ts +295 -0
  60. package/src/nostr-profile.fuzz.test.ts +480 -0
  61. package/src/nostr-profile.test.ts +410 -0
  62. package/src/nostr-profile.ts +320 -0
  63. package/src/nostr-pubkey.ts +56 -0
  64. package/src/nostr-state-store.test.ts +790 -0
  65. package/src/nostr-state-store.ts +1284 -0
  66. package/src/runtime.ts +9 -0
  67. package/src/seen-tracker.test.ts +25 -0
  68. package/src/seen-tracker.ts +292 -0
  69. package/src/session-route.ts +25 -0
  70. package/src/setup-surface.ts +320 -0
  71. package/src/types.test.ts +783 -0
  72. package/src/types.ts +508 -0
@@ -0,0 +1,1187 @@
1
+ // Code generated by cascadia generate — DO NOT EDIT.
2
+ // Source: registry/event-families.yaml, registry/tags.yaml
3
+ // Generated: 2026-07-11T07:50:45Z
4
+
5
+ // ─── Kind Constants ─────────────────────────────────────────────────────────
6
+
7
+ /** NIP59_GIFT_WRAP — NIP-59 gift wrap transport for encrypted ContextVM payloads. */
8
+ export const NIP59_GIFT_WRAP = 1059;
9
+
10
+ /** CAS_AUDIT — Audit trail event and attestation. Append-only, immutable record of auditable actions. Independent of request lifecycle — stands alone as observational record. Relays SHOULD enforce extended retention and reject deletion events for this kind. */
11
+ export const CAS_AUDIT = 4903;
12
+
13
+ /** CAS_WORKER_AD — Compute worker advertisement. Replaceable latest-wins record (one per pubkey) announcing hardware capabilities, availability, and pricing. Refreshes every 60-300 seconds. */
14
+ export const CAS_WORKER_AD = 10100;
15
+
16
+ /** CTXVM_SERVER_ANNOUNCEMENT — ContextVM server discovery announcement. */
17
+ export const CTXVM_SERVER_ANNOUNCEMENT = 11316;
18
+
19
+ /** CTXVM_TOOLS_ANNOUNCEMENT — ContextVM tools discovery announcement. */
20
+ export const CTXVM_TOOLS_ANNOUNCEMENT = 11317;
21
+
22
+ /** CTXVM_RESOURCES_ANNOUNCEMENT — ContextVM resources discovery announcement. */
23
+ export const CTXVM_RESOURCES_ANNOUNCEMENT = 11318;
24
+
25
+ /** CTXVM_RESOURCE_TEMPLATES_ANNOUNCEMENT — ContextVM resource templates discovery announcement. */
26
+ export const CTXVM_RESOURCE_TEMPLATES_ANNOUNCEMENT = 11319;
27
+
28
+ /** CTXVM_PROMPTS_ANNOUNCEMENT — ContextVM prompts discovery announcement. */
29
+ export const CTXVM_PROMPTS_ANNOUNCEMENT = 11320;
30
+
31
+ /** NIP59_EPHEMERAL_GIFT_WRAP — Ephemeral NIP-59 gift wrap transport for no-persistence ContextVM payloads. */
32
+ export const NIP59_EPHEMERAL_GIFT_WRAP = 21059;
33
+
34
+ /** CAS_INTENT — ContextVM JSON-RPC 2.0 intent message. Carries all Cascadia command requests, responses, and notifications; normally gift-wrapped via NIP-59. */
35
+ export const CAS_INTENT = 25910;
36
+
37
+ /** NIP51_TASK_COLLECTION — NIP-51 named list for Task Fabric collections. Uses d-tags prefixed with queue:<id> for work queues and epic:<id> for epic membership. */
38
+ export const NIP51_TASK_COLLECTION = 30000;
39
+
40
+ /** CAS_AGENT_HEARTBEAT — Agent lifecycle heartbeat. Addressable latest-wins record signaling agent liveness. Refreshes every 30-120 seconds. Consumers should consider an agent offline if no heartbeat within 3x expected interval. */
41
+ export const CAS_AGENT_HEARTBEAT = 30316;
42
+
43
+ /** CAS_AGENT_CAPABILITY — Agent capability descriptor. Addressable latest-wins record describing an agent's tools, models, and operational scope. Refreshes when capabilities change. Multiple capability records per agent, keyed by d-tag suffix. */
44
+ export const CAS_AGENT_CAPABILITY = 30317;
45
+
46
+ /** CAS_CP_STATE — Control-plane state projection. Addressable latest-wins record representing the current computed truth of an entity. Updated independently of individual requests. Content is always the complete current state, never a diff. */
47
+ export const CAS_CP_STATE = 30900;
48
+
49
+ /** All Cascadia canonical kinds. */
50
+ export const CascadiaKinds = {
51
+ NIP59_GIFT_WRAP: 1059,
52
+ CAS_AUDIT: 4903,
53
+ CAS_WORKER_AD: 10100,
54
+ CTXVM_SERVER_ANNOUNCEMENT: 11316,
55
+ CTXVM_TOOLS_ANNOUNCEMENT: 11317,
56
+ CTXVM_RESOURCES_ANNOUNCEMENT: 11318,
57
+ CTXVM_RESOURCE_TEMPLATES_ANNOUNCEMENT: 11319,
58
+ CTXVM_PROMPTS_ANNOUNCEMENT: 11320,
59
+ NIP59_EPHEMERAL_GIFT_WRAP: 21059,
60
+ CAS_INTENT: 25910,
61
+ NIP51_TASK_COLLECTION: 30000,
62
+ CAS_AGENT_HEARTBEAT: 30316,
63
+ CAS_AGENT_CAPABILITY: 30317,
64
+ CAS_CP_STATE: 30900,
65
+ } as const;
66
+
67
+ export type CascadiaKind = typeof CascadiaKinds[keyof typeof CascadiaKinds];
68
+
69
+ /** Kind metadata for runtime validation. */
70
+ export const KindMeta: Record<number, {
71
+ symbol: string;
72
+ family: string;
73
+ eventForm: 'regular' | 'replaceable' | 'addressable' | 'ephemeral';
74
+ requiredTags: string[];
75
+ }> = {
76
+ [NIP59_GIFT_WRAP]: {
77
+ symbol: "NIP59_GIFT_WRAP",
78
+ family: "NIP-59",
79
+ eventForm: "regular",
80
+ requiredTags: ["p"],
81
+ },
82
+ [CAS_AUDIT]: {
83
+ symbol: "CAS_AUDIT",
84
+ family: "CF-10",
85
+ eventForm: "regular",
86
+ requiredTags: ["domain", "type", "schema"],
87
+ },
88
+ [CAS_WORKER_AD]: {
89
+ symbol: "CAS_WORKER_AD",
90
+ family: "CF-8",
91
+ eventForm: "replaceable",
92
+ requiredTags: ["cap", "status"],
93
+ },
94
+ [CTXVM_SERVER_ANNOUNCEMENT]: {
95
+ symbol: "CTXVM_SERVER_ANNOUNCEMENT",
96
+ family: "ContextVM",
97
+ eventForm: "regular",
98
+ requiredTags: ["p"],
99
+ },
100
+ [CTXVM_TOOLS_ANNOUNCEMENT]: {
101
+ symbol: "CTXVM_TOOLS_ANNOUNCEMENT",
102
+ family: "ContextVM",
103
+ eventForm: "regular",
104
+ requiredTags: ["p"],
105
+ },
106
+ [CTXVM_RESOURCES_ANNOUNCEMENT]: {
107
+ symbol: "CTXVM_RESOURCES_ANNOUNCEMENT",
108
+ family: "ContextVM",
109
+ eventForm: "regular",
110
+ requiredTags: ["p"],
111
+ },
112
+ [CTXVM_RESOURCE_TEMPLATES_ANNOUNCEMENT]: {
113
+ symbol: "CTXVM_RESOURCE_TEMPLATES_ANNOUNCEMENT",
114
+ family: "ContextVM",
115
+ eventForm: "regular",
116
+ requiredTags: ["p"],
117
+ },
118
+ [CTXVM_PROMPTS_ANNOUNCEMENT]: {
119
+ symbol: "CTXVM_PROMPTS_ANNOUNCEMENT",
120
+ family: "ContextVM",
121
+ eventForm: "regular",
122
+ requiredTags: ["p"],
123
+ },
124
+ [NIP59_EPHEMERAL_GIFT_WRAP]: {
125
+ symbol: "NIP59_EPHEMERAL_GIFT_WRAP",
126
+ family: "NIP-59",
127
+ eventForm: "ephemeral",
128
+ requiredTags: ["p"],
129
+ },
130
+ [CAS_INTENT]: {
131
+ symbol: "CAS_INTENT",
132
+ family: "CF-9",
133
+ eventForm: "ephemeral",
134
+ requiredTags: ["p"],
135
+ },
136
+ [NIP51_TASK_COLLECTION]: {
137
+ symbol: "NIP51_TASK_COLLECTION",
138
+ family: "NIP-51",
139
+ eventForm: "addressable",
140
+ requiredTags: ["d"],
141
+ },
142
+ [CAS_AGENT_HEARTBEAT]: {
143
+ symbol: "CAS_AGENT_HEARTBEAT",
144
+ family: "CF-8",
145
+ eventForm: "addressable",
146
+ requiredTags: ["d", "status", "agent"],
147
+ },
148
+ [CAS_AGENT_CAPABILITY]: {
149
+ symbol: "CAS_AGENT_CAPABILITY",
150
+ family: "CF-8",
151
+ eventForm: "addressable",
152
+ requiredTags: ["d", "agent", "cap"],
153
+ },
154
+ [CAS_CP_STATE]: {
155
+ symbol: "CAS_CP_STATE",
156
+ family: "CF-9",
157
+ eventForm: "addressable",
158
+ requiredTags: ["d", "domain", "schema"],
159
+ },
160
+ };
161
+
162
+ // ─── Tag Constants ──────────────────────────────────────────────────────────
163
+
164
+ export const TAG_TRIGGERED_BY = "triggered-by";
165
+ export const TAG_INTENT = "intent";
166
+ export const TAG_RUN = "run";
167
+ export const TAG_SESSION = "session";
168
+ export const TAG_ACP_VERSION = "acp_version";
169
+ export const TAG_BACKEND = "backend";
170
+ export const TAG_CAP = "cap";
171
+ export const TAG_DM_SCHEMES = "dm_schemes";
172
+ export const TAG_MODEL = "model";
173
+ export const TAG_RUNTIME = "runtime";
174
+ export const TAG_SCOPE = "scope";
175
+ export const TAG_TOOL = "tool";
176
+ export const TAG_TOOLS = "tools";
177
+ export const TAG_A = "a";
178
+ export const TAG_ARTIFACT = "artifact";
179
+ export const TAG_DOC = "doc";
180
+ export const TAG_PROJECT = "project";
181
+ export const TAG_SCHEMA = "schema";
182
+ export const TAG_SUPERSEDES = "supersedes";
183
+ export const TAG_TITLE = "title";
184
+ export const TAG_TYPE = "type";
185
+ export const TAG_V = "v";
186
+ export const TAG_WORKFLOW = "workflow";
187
+ export const TAG_AGENT = "agent";
188
+ export const TAG_DOMAIN = "domain";
189
+ export const TAG_ENVIRONMENT = "environment";
190
+ export const TAG_METHOD = "method";
191
+ export const TAG_OP = "op";
192
+ export const TAG_RELEASE = "release";
193
+ export const TAG_ROUTE = "route";
194
+ export const TAG_SERVICE = "service";
195
+ export const TAG_WORKER = "worker";
196
+ export const TAG_ASSIGNEE = "assignee";
197
+ export const TAG_DECISION = "decision";
198
+ export const TAG_DEPENDS_ON = "depends-on";
199
+ export const TAG_EPIC = "epic";
200
+ export const TAG_PRIORITY = "priority";
201
+ export const TAG_STAGE = "stage";
202
+ export const TAG_STATUS = "status";
203
+ export const TAG_STEP = "step";
204
+
205
+ /** Maps legacy tag names to canonical replacements. */
206
+ export const LEGACY_TAG_ALIASES: Record<string, string> = {
207
+ "s": "stage",
208
+ "r": "status",
209
+ "c": "op",
210
+ "g": "scope",
211
+ "command": "op",
212
+ "h": "project",
213
+ "f": "workflow",
214
+ "y": "artifact",
215
+ };
216
+
217
+ /** Maps legacy kind numbers to canonical targets. */
218
+ export const LEGACY_KIND_TARGET: Record<number, number> = {
219
+ 6000: 25910,
220
+ 6005: 25910,
221
+ 7978: 6000,
222
+ 31968: 30900,
223
+ 6003: 25910,
224
+ 7941: 6000,
225
+ 31974: 30900,
226
+ 5963: 25910,
227
+ 5989: 25910,
228
+ 6983: 7000,
229
+ 7991: 6000,
230
+ 38423: 6000,
231
+ 31972: 30900,
232
+ 5972: 25910,
233
+ 5996: 25910,
234
+ 6001: 25910,
235
+ 5971: 25910,
236
+ 5991: 25910,
237
+ 5944: 25910,
238
+ 1950: 25910,
239
+ 5968: 25910,
240
+ 5941: 25910,
241
+ 7961: 6000,
242
+ 6973: 7000,
243
+ 7950: 6000,
244
+ 32000: 30900,
245
+ 5992: 25910,
246
+ 5995: 25910,
247
+ 6991: 7000,
248
+ 6997: 7000,
249
+ 30100: 30900,
250
+ 5950: 25910,
251
+ 7979: 6000,
252
+ 31967: 30900,
253
+ 5961: 25910,
254
+ 5999: 25910,
255
+ 31973: 30900,
256
+ 31310: 4903,
257
+ 31964: 30900,
258
+ 38384: 25910,
259
+ 6961: 7000,
260
+ 5988: 25910,
261
+ 5401: 25910,
262
+ 6963: 7000,
263
+ 7963: 6000,
264
+ 7966: 6000,
265
+ 7971: 6000,
266
+ 32002: 30900,
267
+ 31969: 30900,
268
+ 5994: 25910,
269
+ 6982: 7000,
270
+ 7992: 6000,
271
+ 31966: 30900,
272
+ 5997: 25910,
273
+ 5998: 25910,
274
+ 5945: 25910,
275
+ 7964: 6000,
276
+ 7945: 6000,
277
+ 5987: 25910,
278
+ 6941: 7000,
279
+ 6981: 7000,
280
+ 38422: 7000,
281
+ 7973: 6000,
282
+ 31965: 30900,
283
+ 32003: 30900,
284
+ 5966: 25910,
285
+ 5975: 25910,
286
+ 5984: 25910,
287
+ 6002: 25910,
288
+ 5943: 25910,
289
+ 5983: 25910,
290
+ 5102: 25910,
291
+ 31970: 30900,
292
+ 5964: 25910,
293
+ 6950: 7000,
294
+ 7962: 6000,
295
+ 7944: 6000,
296
+ 5993: 25910,
297
+ 6004: 25910,
298
+ 7977: 6000,
299
+ 31311: 4903,
300
+ 5962: 25910,
301
+ 5976: 25910,
302
+ 5977: 25910,
303
+ 5942: 25910,
304
+ 6978: 7000,
305
+ 31963: 30900,
306
+ 6962: 7000,
307
+ 6976: 7000,
308
+ 7965: 6000,
309
+ 7972: 6000,
310
+ 31971: 30900,
311
+ 5985: 25910,
312
+ 6984: 7000,
313
+ 5967: 25910,
314
+ 5974: 25910,
315
+ 7942: 6000,
316
+ 5973: 25910,
317
+ 5981: 25910,
318
+ 5986: 25910,
319
+ 7943: 6000,
320
+ 5402: 6000,
321
+ 31962: 30900,
322
+ 5965: 25910,
323
+ 7976: 6000,
324
+ 7997: 6000,
325
+ 32001: 30900,
326
+ 31961: 30900,
327
+ 5978: 25910,
328
+ 5979: 25910,
329
+ 5982: 25910,
330
+ };
331
+
332
+ /** Resolve a legacy kind to its canonical target, or return the input. */
333
+ export function resolveLegacyKind(kind: number): number {
334
+ return LEGACY_KIND_TARGET[kind] ?? kind;
335
+ }
336
+
337
+ /** Resolve a legacy tag alias to its canonical name, or return the input. */
338
+ export function resolveTag(name: string): string {
339
+ return LEGACY_TAG_ALIASES[name] ?? name;
340
+ }
341
+
342
+ // ─── ContextVM Methods ──────────────────────────────────────────────────────
343
+
344
+ export type ContextVMEventForm = 'ephemeral';
345
+ export type ContextVMMethod = { name: string; kind: number; domain: string; op: string; schema: string };
346
+ export const CONTEXTVM_KIND = CAS_INTENT;
347
+ export const ContextVMMethods: Record<string, ContextVMMethod> = {
348
+ "agent/get-status": { name: "agent/get-status", kind: 25910, domain: "agent", op: "get-status", schema: "cascadia.agent.get-status.v1" },
349
+ "agent/persona-update": { name: "agent/persona-update", kind: 25910, domain: "agent", op: "persona-update", schema: "cascadia.agent.persona-update.v1" },
350
+ "agent/ping": { name: "agent/ping", kind: 25910, domain: "agent", op: "ping", schema: "cascadia.agent.ping.v1" },
351
+ "agent/provision": { name: "agent/provision", kind: 25910, domain: "agent", op: "provision", schema: "cascadia.agent.provision.v1" },
352
+ "agent/revoke": { name: "agent/revoke", kind: 25910, domain: "agent", op: "revoke", schema: "cascadia.agent.revoke.v1" },
353
+ "agent/rotate-key": { name: "agent/rotate-key", kind: 25910, domain: "agent", op: "rotate-key", schema: "cascadia.agent.rotate-key.v1" },
354
+ "agent/set-policy": { name: "agent/set-policy", kind: 25910, domain: "agent", op: "set-policy", schema: "cascadia.agent.set-policy.v1" },
355
+ "ci/workflow-run": { name: "ci/workflow-run", kind: 25910, domain: "ci", op: "workflow-run", schema: "hive.ci.workflow.v1" },
356
+ "compute/cancel": { name: "compute/cancel", kind: 25910, domain: "compute", op: "cancel", schema: "cascadia.loom.v1" },
357
+ "compute/run": { name: "compute/run", kind: 25910, domain: "compute", op: "run", schema: "cascadia.loom.v1" },
358
+ "loom/cancel": { name: "loom/cancel", kind: 25910, domain: "loom", op: "cancel", schema: "cascadia.loom.v1" },
359
+ "loom/submit": { name: "loom/submit", kind: 25910, domain: "loom", op: "submit", schema: "cascadia.loom.v1" },
360
+ "queue/dequeue": { name: "queue/dequeue", kind: 25910, domain: "queue", op: "dequeue", schema: "cascadia.queue.v1" },
361
+ "queue/enqueue": { name: "queue/enqueue", kind: 25910, domain: "queue", op: "enqueue", schema: "cascadia.queue.v1" },
362
+ "queue/list": { name: "queue/list", kind: 25910, domain: "queue", op: "list", schema: "cascadia.queue.v1" },
363
+ "service/delete": { name: "service/delete", kind: 25910, domain: "service", op: "delete", schema: "bahia.deploy.v2" },
364
+ "service/deploy": { name: "service/deploy", kind: 25910, domain: "service", op: "deploy", schema: "bahia.deploy.v2" },
365
+ "service/restart": { name: "service/restart", kind: 25910, domain: "service", op: "restart", schema: "bahia.deploy.v2" },
366
+ "service/rollback": { name: "service/rollback", kind: 25910, domain: "service", op: "rollback", schema: "bahia.deploy.v2" },
367
+ "service/scale": { name: "service/scale", kind: 25910, domain: "service", op: "scale", schema: "bahia.deploy.v2" },
368
+ "task/assign": { name: "task/assign", kind: 25910, domain: "task", op: "assign", schema: "cascadia.task.v1" },
369
+ "task/claim": { name: "task/claim", kind: 25910, domain: "task", op: "claim", schema: "cascadia.task.v1" },
370
+ "task/close": { name: "task/close", kind: 25910, domain: "task", op: "close", schema: "cascadia.task.v1" },
371
+ "task/update": { name: "task/update", kind: 25910, domain: "task", op: "update", schema: "cascadia.task.v1" },
372
+ "worker/cordon": { name: "worker/cordon", kind: 25910, domain: "worker", op: "cordon", schema: "bahia.worker.v1" },
373
+ "worker/drain": { name: "worker/drain", kind: 25910, domain: "worker", op: "drain", schema: "bahia.worker.v1" },
374
+ "worker/register": { name: "worker/register", kind: 25910, domain: "worker", op: "register", schema: "bahia.worker.v1" },
375
+ "worker/remove": { name: "worker/remove", kind: 25910, domain: "worker", op: "remove", schema: "bahia.worker.v1" },
376
+ "worker/uncordon": { name: "worker/uncordon", kind: 25910, domain: "worker", op: "uncordon", schema: "bahia.worker.v1" },
377
+ };
378
+
379
+ export type ProgressToken = string;
380
+ export type ContextVMParams<T = unknown> = T & { _meta?: { progressToken?: ProgressToken } };
381
+ export const JSON_RPC_ERROR_CODES = { PARSE_ERROR: -32700, INVALID_REQUEST: -32600, METHOD_NOT_FOUND: -32601, INVALID_PARAMS: -32602, INTERNAL_ERROR: -32603, PROGRESS_CANCELLED: -32800, REQUEST_TIMEOUT: -32001, PERMISSION_DENIED: -32002, RESOURCE_NOT_FOUND: -32004 } as const;
382
+
383
+ /** Validate that an event has all required tags for its kind. */
384
+ export function validateRequiredTags(
385
+ kind: number,
386
+ tags: string[][],
387
+ ): string[] {
388
+ const meta = KindMeta[kind];
389
+ if (!meta) return [];
390
+ const present = new Set(tags.map((t) => t[0]));
391
+ return meta.requiredTags.filter((r) => !present.has(r));
392
+ }
393
+
394
+ // ─── CUE-Derived Payload Types ─────────────────────────────────────────────
395
+
396
+ /** Adoption scan/import request payload
397
+ * Schema: bahia.adoption.v1
398
+ * CUE: schemas/control-plane/adoption.cue (Adoption)
399
+ */
400
+ export interface BahiaAdoptionV1Payload {
401
+ target: string;
402
+ scan_type?: string;
403
+ }
404
+
405
+ export function validateBahiaAdoptionV1Payload(payload: BahiaAdoptionV1Payload): string[] {
406
+ const errors: string[] = [];
407
+ if (payload.target === undefined || payload.target === null || payload.target === '') errors.push("bahia.adoption.v1.target is required");
408
+ return errors;
409
+ }
410
+
411
+ /** Backup attestation audit payload
412
+ * Schema: bahia.audit.backup.v1
413
+ * CUE: schemas/audit/backup.cue (BackupAttestation)
414
+ */
415
+ export interface BahiaAuditBackupV1Payload {
416
+ backup_id: string;
417
+ target: string;
418
+ size_bytes?: number;
419
+ integrity_hash: string;
420
+ encrypted?: boolean;
421
+ storage_location?: string;
422
+ retention_days?: number;
423
+ verified_at?: string;
424
+ }
425
+
426
+ export function validateBahiaAuditBackupV1Payload(payload: BahiaAuditBackupV1Payload): string[] {
427
+ const errors: string[] = [];
428
+ if (payload.backup_id === undefined || payload.backup_id === null || payload.backup_id === '') errors.push("bahia.audit.backup.v1.backup_id is required");
429
+ if (payload.target === undefined || payload.target === null || payload.target === '') errors.push("bahia.audit.backup.v1.target is required");
430
+ if (payload.integrity_hash === undefined || payload.integrity_hash === null || payload.integrity_hash === '') errors.push("bahia.audit.backup.v1.integrity_hash is required");
431
+ return errors;
432
+ }
433
+
434
+ /** Build change record audit payload
435
+ * Schema: bahia.audit.build.v1
436
+ * CUE: schemas/audit/build.cue (BuildChangeRecord)
437
+ */
438
+ export interface BahiaAuditBuildV1Payload {
439
+ build_id: string;
440
+ artifact_id: string;
441
+ source_commit: string;
442
+ source_repo?: string;
443
+ builder?: string;
444
+ duration_sec?: number;
445
+ digest?: string;
446
+ }
447
+
448
+ export function validateBahiaAuditBuildV1Payload(payload: BahiaAuditBuildV1Payload): string[] {
449
+ const errors: string[] = [];
450
+ if (payload.build_id === undefined || payload.build_id === null || payload.build_id === '') errors.push("bahia.audit.build.v1.build_id is required");
451
+ if (payload.artifact_id === undefined || payload.artifact_id === null || payload.artifact_id === '') errors.push("bahia.audit.build.v1.artifact_id is required");
452
+ if (payload.source_commit === undefined || payload.source_commit === null || payload.source_commit === '') errors.push("bahia.audit.build.v1.source_commit is required");
453
+ return errors;
454
+ }
455
+
456
+ /** Deployment change record audit payload
457
+ * Schema: bahia.audit.deployment.v1
458
+ * CUE: schemas/audit/deployment.cue (DeploymentChangeRecord)
459
+ */
460
+ export interface BahiaAuditDeploymentV1Payload {
461
+ service_id: string;
462
+ environment_id: string;
463
+ from_version: string;
464
+ to_version: string;
465
+ strategy?: string;
466
+ initiated_by?: string;
467
+ duration_sec?: number;
468
+ outcome: string;
469
+ }
470
+
471
+ export function validateBahiaAuditDeploymentV1Payload(payload: BahiaAuditDeploymentV1Payload): string[] {
472
+ const errors: string[] = [];
473
+ if (payload.service_id === undefined || payload.service_id === null || payload.service_id === '') errors.push("bahia.audit.deployment.v1.service_id is required");
474
+ if (payload.environment_id === undefined || payload.environment_id === null || payload.environment_id === '') errors.push("bahia.audit.deployment.v1.environment_id is required");
475
+ if (payload.from_version === undefined || payload.from_version === null || payload.from_version === '') errors.push("bahia.audit.deployment.v1.from_version is required");
476
+ if (payload.to_version === undefined || payload.to_version === null || payload.to_version === '') errors.push("bahia.audit.deployment.v1.to_version is required");
477
+ if (payload.outcome === undefined || payload.outcome === null || payload.outcome === '') errors.push("bahia.audit.deployment.v1.outcome is required");
478
+ return errors;
479
+ }
480
+
481
+ /** DNS change record audit payload
482
+ * Schema: bahia.audit.dns.v1
483
+ * CUE: schemas/audit/dns.cue (Dns)
484
+ */
485
+ export interface BahiaAuditDnsV1Payload {
486
+ zone: string;
487
+ record_type?: string;
488
+ record_name?: string;
489
+ old_value?: string;
490
+ new_value?: string;
491
+ }
492
+
493
+ export function validateBahiaAuditDnsV1Payload(payload: BahiaAuditDnsV1Payload): string[] {
494
+ const errors: string[] = [];
495
+ if (payload.zone === undefined || payload.zone === null || payload.zone === '') errors.push("bahia.audit.dns.v1.zone is required");
496
+ return errors;
497
+ }
498
+
499
+ /** LLM/ML model lifecycle audit payload
500
+ * Schema: bahia.audit.llm.v1
501
+ * CUE: schemas/audit/llm.cue (Llm)
502
+ */
503
+ export interface BahiaAuditLlmV1Payload {
504
+ model_id: string;
505
+ action: string;
506
+ route_id?: string;
507
+ }
508
+
509
+ export function validateBahiaAuditLlmV1Payload(payload: BahiaAuditLlmV1Payload): string[] {
510
+ const errors: string[] = [];
511
+ if (payload.model_id === undefined || payload.model_id === null || payload.model_id === '') errors.push("bahia.audit.llm.v1.model_id is required");
512
+ if (payload.action === undefined || payload.action === null || payload.action === '') errors.push("bahia.audit.llm.v1.action is required");
513
+ return errors;
514
+ }
515
+
516
+ /** Package lifecycle audit payload
517
+ * Schema: bahia.audit.package.v1
518
+ * CUE: schemas/audit/package.cue (Package)
519
+ */
520
+ export interface BahiaAuditPackageV1Payload {
521
+ package_id: string;
522
+ action: string;
523
+ version?: string;
524
+ }
525
+
526
+ export function validateBahiaAuditPackageV1Payload(payload: BahiaAuditPackageV1Payload): string[] {
527
+ const errors: string[] = [];
528
+ if (payload.package_id === undefined || payload.package_id === null || payload.package_id === '') errors.push("bahia.audit.package.v1.package_id is required");
529
+ if (payload.action === undefined || payload.action === null || payload.action === '') errors.push("bahia.audit.package.v1.action is required");
530
+ return errors;
531
+ }
532
+
533
+ /** Worker lifecycle audit payload
534
+ * Schema: bahia.audit.worker.v1
535
+ * CUE: schemas/audit/worker.cue (Worker)
536
+ */
537
+ export interface BahiaAuditWorkerV1Payload {
538
+ worker_id: string;
539
+ action: string;
540
+ reason?: string;
541
+ }
542
+
543
+ export function validateBahiaAuditWorkerV1Payload(payload: BahiaAuditWorkerV1Payload): string[] {
544
+ const errors: string[] = [];
545
+ if (payload.worker_id === undefined || payload.worker_id === null || payload.worker_id === '') errors.push("bahia.audit.worker.v1.worker_id is required");
546
+ if (payload.action === undefined || payload.action === null || payload.action === '') errors.push("bahia.audit.worker.v1.action is required");
547
+ return errors;
548
+ }
549
+
550
+ /** Backup state projection payload
551
+ * Schema: bahia.backup-state.v1
552
+ * CUE: schemas/control-plane/backup-state.cue (BackupState)
553
+ */
554
+ export interface BahiaBackupStateV1Payload {
555
+ target: string;
556
+ last_backup_at?: string;
557
+ status: string;
558
+ }
559
+
560
+ export function validateBahiaBackupStateV1Payload(payload: BahiaBackupStateV1Payload): string[] {
561
+ const errors: string[] = [];
562
+ if (payload.target === undefined || payload.target === null || payload.target === '') errors.push("bahia.backup-state.v1.target is required");
563
+ if (payload.status === undefined || payload.status === null || payload.status === '') errors.push("bahia.backup-state.v1.status is required");
564
+ return errors;
565
+ }
566
+
567
+ /** Backup operation request payload
568
+ * Schema: bahia.backup.v1
569
+ * CUE: schemas/control-plane/backup.cue (Backup)
570
+ */
571
+ export interface BahiaBackupV1Payload {
572
+ target: string;
573
+ retention_days?: number;
574
+ }
575
+
576
+ export function validateBahiaBackupV1Payload(payload: BahiaBackupV1Payload): string[] {
577
+ const errors: string[] = [];
578
+ if (payload.target === undefined || payload.target === null || payload.target === '') errors.push("bahia.backup.v1.target is required");
579
+ return errors;
580
+ }
581
+
582
+ /** Continuity state projection payload
583
+ * Schema: bahia.continuity-state.v1
584
+ * CUE: schemas/control-plane/continuity-state.cue (ContinuityState)
585
+ */
586
+ export interface BahiaContinuityStateV1Payload {
587
+ profile_id: string;
588
+ mode: string;
589
+ }
590
+
591
+ export function validateBahiaContinuityStateV1Payload(payload: BahiaContinuityStateV1Payload): string[] {
592
+ const errors: string[] = [];
593
+ if (payload.profile_id === undefined || payload.profile_id === null || payload.profile_id === '') errors.push("bahia.continuity-state.v1.profile_id is required");
594
+ if (payload.mode === undefined || payload.mode === null || payload.mode === '') errors.push("bahia.continuity-state.v1.mode is required");
595
+ return errors;
596
+ }
597
+
598
+ /** Continuity/failover request payload
599
+ * Schema: bahia.continuity.v1
600
+ * CUE: schemas/control-plane/continuity.cue (Continuity)
601
+ */
602
+ export interface BahiaContinuityV1Payload {
603
+ profile_id: string;
604
+ target?: string;
605
+ }
606
+
607
+ export function validateBahiaContinuityV1Payload(payload: BahiaContinuityV1Payload): string[] {
608
+ const errors: string[] = [];
609
+ if (payload.profile_id === undefined || payload.profile_id === null || payload.profile_id === '') errors.push("bahia.continuity.v1.profile_id is required");
610
+ return errors;
611
+ }
612
+
613
+ /** Service deployment request payload
614
+ * Schema: bahia.deploy.v2
615
+ * CUE: schemas/control-plane/deploy.cue (DeployRequest, DeployStatus, DeployResult)
616
+ */
617
+ export interface BahiaDeployV2Payload {
618
+ service_id: string;
619
+ environment_id: string;
620
+ artifact_id: string;
621
+ strategy?: "rolling" | "blue-green" | "canary" | "recreate";
622
+ parameters?: Record<string, unknown>;
623
+ }
624
+
625
+ export function validateBahiaDeployV2Payload(payload: BahiaDeployV2Payload): string[] {
626
+ const errors: string[] = [];
627
+ if (payload.service_id === undefined || payload.service_id === null || payload.service_id === '') errors.push("bahia.deploy.v2.service_id is required");
628
+ if (payload.environment_id === undefined || payload.environment_id === null || payload.environment_id === '') errors.push("bahia.deploy.v2.environment_id is required");
629
+ if (payload.artifact_id === undefined || payload.artifact_id === null || payload.artifact_id === '') errors.push("bahia.deploy.v2.artifact_id is required");
630
+ if (payload.strategy !== undefined && !["rolling", "blue-green", "canary", "recreate"].includes(payload.strategy as string)) errors.push("bahia.deploy.v2.strategy must be one of: rolling, blue-green, canary, recreate");
631
+ return errors;
632
+ }
633
+
634
+ /** DNS zone state projection payload
635
+ * Schema: bahia.dns-zone.v1
636
+ * CUE: schemas/control-plane/dns-zone.cue (DnsZone)
637
+ */
638
+ export interface BahiaDnsZoneV1Payload {
639
+ zone: string;
640
+ records?: string[];
641
+ }
642
+
643
+ export function validateBahiaDnsZoneV1Payload(payload: BahiaDnsZoneV1Payload): string[] {
644
+ const errors: string[] = [];
645
+ if (payload.zone === undefined || payload.zone === null || payload.zone === '') errors.push("bahia.dns-zone.v1.zone is required");
646
+ return errors;
647
+ }
648
+
649
+ /** DNS management request payload
650
+ * Schema: bahia.dns.v1
651
+ * CUE: schemas/control-plane/dns.cue (Dns)
652
+ */
653
+ export interface BahiaDnsV1Payload {
654
+ zone: string;
655
+ record_type?: string;
656
+ record_name?: string;
657
+ value?: string;
658
+ }
659
+
660
+ export function validateBahiaDnsV1Payload(payload: BahiaDnsV1Payload): string[] {
661
+ const errors: string[] = [];
662
+ if (payload.zone === undefined || payload.zone === null || payload.zone === '') errors.push("bahia.dns.v1.zone is required");
663
+ return errors;
664
+ }
665
+
666
+ /** Environment state projection payload
667
+ * Schema: bahia.environment-state.v1
668
+ * CUE: schemas/control-plane/environment-state.cue (EnvironmentState)
669
+ */
670
+ export interface BahiaEnvironmentStateV1Payload {
671
+ environment_id: string;
672
+ status: string;
673
+ }
674
+
675
+ export function validateBahiaEnvironmentStateV1Payload(payload: BahiaEnvironmentStateV1Payload): string[] {
676
+ const errors: string[] = [];
677
+ if (payload.environment_id === undefined || payload.environment_id === null || payload.environment_id === '') errors.push("bahia.environment-state.v1.environment_id is required");
678
+ if (payload.status === undefined || payload.status === null || payload.status === '') errors.push("bahia.environment-state.v1.status is required");
679
+ return errors;
680
+ }
681
+
682
+ /** ML model registry state projection payload
683
+ * Schema: bahia.ml-registry.v1
684
+ * CUE: schemas/control-plane/ml-registry.cue (MlRegistry)
685
+ */
686
+ export interface BahiaMlRegistryV1Payload {
687
+ model_id: string;
688
+ status: string;
689
+ }
690
+
691
+ export function validateBahiaMlRegistryV1Payload(payload: BahiaMlRegistryV1Payload): string[] {
692
+ const errors: string[] = [];
693
+ if (payload.model_id === undefined || payload.model_id === null || payload.model_id === '') errors.push("bahia.ml-registry.v1.model_id is required");
694
+ if (payload.status === undefined || payload.status === null || payload.status === '') errors.push("bahia.ml-registry.v1.status is required");
695
+ return errors;
696
+ }
697
+
698
+ /** ML/AI infrastructure request payload
699
+ * Schema: bahia.ml.v1
700
+ * CUE: schemas/control-plane/ml.cue (Ml)
701
+ */
702
+ export interface BahiaMlV1Payload {
703
+ route_id?: string;
704
+ model_id?: string;
705
+ action: string;
706
+ }
707
+
708
+ export function validateBahiaMlV1Payload(payload: BahiaMlV1Payload): string[] {
709
+ const errors: string[] = [];
710
+ if (payload.action === undefined || payload.action === null || payload.action === '') errors.push("bahia.ml.v1.action is required");
711
+ return errors;
712
+ }
713
+
714
+ /** Package state projection payload
715
+ * Schema: bahia.package-state.v1
716
+ * CUE: schemas/control-plane/package-state.cue (PackageState)
717
+ */
718
+ export interface BahiaPackageStateV1Payload {
719
+ package_id: string;
720
+ version?: string;
721
+ status: string;
722
+ }
723
+
724
+ export function validateBahiaPackageStateV1Payload(payload: BahiaPackageStateV1Payload): string[] {
725
+ const errors: string[] = [];
726
+ if (payload.package_id === undefined || payload.package_id === null || payload.package_id === '') errors.push("bahia.package-state.v1.package_id is required");
727
+ if (payload.status === undefined || payload.status === null || payload.status === '') errors.push("bahia.package-state.v1.status is required");
728
+ return errors;
729
+ }
730
+
731
+ /** Package lifecycle request payload
732
+ * Schema: bahia.package.v1
733
+ * CUE: schemas/control-plane/package.cue (Package)
734
+ */
735
+ export interface BahiaPackageV1Payload {
736
+ package_id: string;
737
+ version?: string;
738
+ }
739
+
740
+ export function validateBahiaPackageV1Payload(payload: BahiaPackageV1Payload): string[] {
741
+ const errors: string[] = [];
742
+ if (payload.package_id === undefined || payload.package_id === null || payload.package_id === '') errors.push("bahia.package.v1.package_id is required");
743
+ return errors;
744
+ }
745
+
746
+ /** Policy state projection payload
747
+ * Schema: bahia.policy-state.v1
748
+ * CUE: schemas/control-plane/policy-state.cue (PolicyState)
749
+ */
750
+ export interface BahiaPolicyStateV1Payload {
751
+ policy_id: string;
752
+ active: boolean;
753
+ }
754
+
755
+ export function validateBahiaPolicyStateV1Payload(payload: BahiaPolicyStateV1Payload): string[] {
756
+ const errors: string[] = [];
757
+ if (payload.policy_id === undefined || payload.policy_id === null || payload.policy_id === '') errors.push("bahia.policy-state.v1.policy_id is required");
758
+ if (payload.active === undefined || payload.active === null) errors.push("bahia.policy-state.v1.active is required");
759
+ return errors;
760
+ }
761
+
762
+ /** Deployment policy request payload
763
+ * Schema: bahia.policy.v1
764
+ * CUE: schemas/control-plane/policy.cue (Policy)
765
+ */
766
+ export interface BahiaPolicyV1Payload {
767
+ policy_id: string;
768
+ rules?: Record<string, unknown>;
769
+ }
770
+
771
+ export function validateBahiaPolicyV1Payload(payload: BahiaPolicyV1Payload): string[] {
772
+ const errors: string[] = [];
773
+ if (payload.policy_id === undefined || payload.policy_id === null || payload.policy_id === '') errors.push("bahia.policy.v1.policy_id is required");
774
+ return errors;
775
+ }
776
+
777
+ /** Service state projection payload
778
+ * Schema: bahia.service-state.v2
779
+ * CUE: schemas/control-plane/service-state.cue (ServiceState)
780
+ */
781
+ export interface BahiaServiceStateV2Payload {
782
+ service_id: string;
783
+ environment_id: string;
784
+ current_version: string;
785
+ replicas: number;
786
+ healthy_replicas: number;
787
+ last_deploy_at?: string;
788
+ status: string;
789
+ }
790
+
791
+ export function validateBahiaServiceStateV2Payload(payload: BahiaServiceStateV2Payload): string[] {
792
+ const errors: string[] = [];
793
+ if (payload.service_id === undefined || payload.service_id === null || payload.service_id === '') errors.push("bahia.service-state.v2.service_id is required");
794
+ if (payload.environment_id === undefined || payload.environment_id === null || payload.environment_id === '') errors.push("bahia.service-state.v2.environment_id is required");
795
+ if (payload.current_version === undefined || payload.current_version === null || payload.current_version === '') errors.push("bahia.service-state.v2.current_version is required");
796
+ if (payload.replicas === undefined || payload.replicas === null) errors.push("bahia.service-state.v2.replicas is required");
797
+ if (payload.healthy_replicas === undefined || payload.healthy_replicas === null) errors.push("bahia.service-state.v2.healthy_replicas is required");
798
+ if (payload.status === undefined || payload.status === null || payload.status === '') errors.push("bahia.service-state.v2.status is required");
799
+ return errors;
800
+ }
801
+
802
+ /** Worker state projection payload
803
+ * Schema: bahia.worker-state.v1
804
+ * CUE: schemas/control-plane/worker-state.cue (WorkerState)
805
+ */
806
+ export interface BahiaWorkerStateV1Payload {
807
+ worker_id: string;
808
+ status: string;
809
+ capacity?: Record<string, unknown>;
810
+ }
811
+
812
+ export function validateBahiaWorkerStateV1Payload(payload: BahiaWorkerStateV1Payload): string[] {
813
+ const errors: string[] = [];
814
+ if (payload.worker_id === undefined || payload.worker_id === null || payload.worker_id === '') errors.push("bahia.worker-state.v1.worker_id is required");
815
+ if (payload.status === undefined || payload.status === null || payload.status === '') errors.push("bahia.worker-state.v1.status is required");
816
+ return errors;
817
+ }
818
+
819
+ /** Worker management request payload
820
+ * Schema: bahia.worker.v1
821
+ * CUE: schemas/control-plane/worker.cue (Worker)
822
+ */
823
+ export interface BahiaWorkerV1Payload {
824
+ worker_id: string;
825
+ reason?: string;
826
+ }
827
+
828
+ export function validateBahiaWorkerV1Payload(payload: BahiaWorkerV1Payload): string[] {
829
+ const errors: string[] = [];
830
+ if (payload.worker_id === undefined || payload.worker_id === null || payload.worker_id === '') errors.push("bahia.worker.v1.worker_id is required");
831
+ return errors;
832
+ }
833
+
834
+ /** Agent capability descriptor payload
835
+ * Schema: cascadia.agent.capability.v1
836
+ * CUE: schemas/agent/capability.cue (Tool, Model, Limits, Capability)
837
+ */
838
+ export interface CascadiaAgentCapabilityV1Payload {
839
+ agent_id: string;
840
+ capability: string;
841
+ tools?: string[];
842
+ model?: Record<string, unknown>;
843
+ limits?: Record<string, unknown>;
844
+ }
845
+
846
+ export function validateCascadiaAgentCapabilityV1Payload(payload: CascadiaAgentCapabilityV1Payload): string[] {
847
+ const errors: string[] = [];
848
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.agent.capability.v1.agent_id is required");
849
+ if (payload.capability === undefined || payload.capability === null || payload.capability === '') errors.push("cascadia.agent.capability.v1.capability is required");
850
+ return errors;
851
+ }
852
+
853
+ /** Agent status query ContextVM payload
854
+ * Schema: cascadia.agent.get-status.v1
855
+ * CUE: schemas/control-plane/agent-get-status.cue (AgentGetStatus)
856
+ */
857
+ export interface CascadiaAgentGetStatusV1Payload {
858
+ agent_id: string;
859
+ }
860
+
861
+ export function validateCascadiaAgentGetStatusV1Payload(payload: CascadiaAgentGetStatusV1Payload): string[] {
862
+ const errors: string[] = [];
863
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.agent.get-status.v1.agent_id is required");
864
+ return errors;
865
+ }
866
+
867
+ /** Agent lifecycle heartbeat payload
868
+ * Schema: cascadia.agent.heartbeat.v1
869
+ * CUE: schemas/agent/heartbeat.cue (Heartbeat)
870
+ */
871
+ export interface CascadiaAgentHeartbeatV1Payload {
872
+ uptime_sec?: number;
873
+ active_tasks?: number;
874
+ load_avg?: number;
875
+ last_task_at?: string;
876
+ }
877
+
878
+ export function validateCascadiaAgentHeartbeatV1Payload(payload: CascadiaAgentHeartbeatV1Payload): string[] {
879
+ const errors: string[] = [];
880
+ return errors;
881
+ }
882
+
883
+ /** Agent persona update ContextVM payload
884
+ * Schema: cascadia.agent.persona-update.v1
885
+ * CUE: schemas/control-plane/agent-persona-update.cue (AgentPersonaUpdate)
886
+ */
887
+ export interface CascadiaAgentPersonaUpdateV1Payload {
888
+ agent_id: string;
889
+ persona: Record<string, unknown>;
890
+ }
891
+
892
+ export function validateCascadiaAgentPersonaUpdateV1Payload(payload: CascadiaAgentPersonaUpdateV1Payload): string[] {
893
+ const errors: string[] = [];
894
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.agent.persona-update.v1.agent_id is required");
895
+ if (payload.persona === undefined || payload.persona === null) errors.push("cascadia.agent.persona-update.v1.persona is required");
896
+ return errors;
897
+ }
898
+
899
+ /** Agent ping ContextVM payload
900
+ * Schema: cascadia.agent.ping.v1
901
+ * CUE: schemas/control-plane/agent-ping.cue (AgentPing)
902
+ */
903
+ export interface CascadiaAgentPingV1Payload {
904
+ agent_id: string;
905
+ }
906
+
907
+ export function validateCascadiaAgentPingV1Payload(payload: CascadiaAgentPingV1Payload): string[] {
908
+ const errors: string[] = [];
909
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.agent.ping.v1.agent_id is required");
910
+ return errors;
911
+ }
912
+
913
+ /** Agent provisioning ContextVM payload
914
+ * Schema: cascadia.agent.provision.v1
915
+ * CUE: schemas/control-plane/agent-provision.cue (AgentProvision)
916
+ */
917
+ export interface CascadiaAgentProvisionV1Payload {
918
+ agent_id: string;
919
+ template_id?: string;
920
+ policy_id?: string;
921
+ }
922
+
923
+ export function validateCascadiaAgentProvisionV1Payload(payload: CascadiaAgentProvisionV1Payload): string[] {
924
+ const errors: string[] = [];
925
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.agent.provision.v1.agent_id is required");
926
+ return errors;
927
+ }
928
+
929
+ /** Agent revocation ContextVM payload
930
+ * Schema: cascadia.agent.revoke.v1
931
+ * CUE: schemas/control-plane/agent-revoke.cue (AgentRevoke)
932
+ */
933
+ export interface CascadiaAgentRevokeV1Payload {
934
+ agent_id: string;
935
+ reason?: string;
936
+ }
937
+
938
+ export function validateCascadiaAgentRevokeV1Payload(payload: CascadiaAgentRevokeV1Payload): string[] {
939
+ const errors: string[] = [];
940
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.agent.revoke.v1.agent_id is required");
941
+ return errors;
942
+ }
943
+
944
+ /** Agent key rotation ContextVM payload
945
+ * Schema: cascadia.agent.rotate-key.v1
946
+ * CUE: schemas/control-plane/agent-rotate-key.cue (AgentRotateKey)
947
+ */
948
+ export interface CascadiaAgentRotateKeyV1Payload {
949
+ agent_id: string;
950
+ new_pubkey?: string;
951
+ }
952
+
953
+ export function validateCascadiaAgentRotateKeyV1Payload(payload: CascadiaAgentRotateKeyV1Payload): string[] {
954
+ const errors: string[] = [];
955
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.agent.rotate-key.v1.agent_id is required");
956
+ return errors;
957
+ }
958
+
959
+ /** Agent policy update ContextVM payload
960
+ * Schema: cascadia.agent.set-policy.v1
961
+ * CUE: schemas/control-plane/agent-set-policy.cue (AgentSetPolicy)
962
+ */
963
+ export interface CascadiaAgentSetPolicyV1Payload {
964
+ agent_id: string;
965
+ policy: Record<string, unknown>;
966
+ }
967
+
968
+ export function validateCascadiaAgentSetPolicyV1Payload(payload: CascadiaAgentSetPolicyV1Payload): string[] {
969
+ const errors: string[] = [];
970
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.agent.set-policy.v1.agent_id is required");
971
+ if (payload.policy === undefined || payload.policy === null) errors.push("cascadia.agent.set-policy.v1.policy is required");
972
+ return errors;
973
+ }
974
+
975
+ /** Code review audit payload
976
+ * Schema: cascadia.audit.review.v1
977
+ * CUE: schemas/audit/review.cue (CodeReviewAudit)
978
+ */
979
+ export interface CascadiaAuditReviewV1Payload {
980
+ review_id: string;
981
+ repository: string;
982
+ commit?: string;
983
+ outcome: string;
984
+ }
985
+
986
+ export function validateCascadiaAuditReviewV1Payload(payload: CascadiaAuditReviewV1Payload): string[] {
987
+ const errors: string[] = [];
988
+ if (payload.review_id === undefined || payload.review_id === null || payload.review_id === '') errors.push("cascadia.audit.review.v1.review_id is required");
989
+ if (payload.repository === undefined || payload.repository === null || payload.repository === '') errors.push("cascadia.audit.review.v1.repository is required");
990
+ if (payload.outcome === undefined || payload.outcome === null || payload.outcome === '') errors.push("cascadia.audit.review.v1.outcome is required");
991
+ return errors;
992
+ }
993
+
994
+ /** ContextVM JSON-RPC params envelope with _meta.progressToken
995
+ * Schema: cascadia.contextvm.envelope.v1
996
+ * CUE: schemas/control-plane/contextvm-envelope.cue (ContextVMParams, JSONRPCErrorCode)
997
+ */
998
+ export interface CascadiaContextvmEnvelopeV1Payload {
999
+ _meta?: Record<string, unknown>;
1000
+ }
1001
+
1002
+ export function validateCascadiaContextvmEnvelopeV1Payload(payload: CascadiaContextvmEnvelopeV1Payload): string[] {
1003
+ const errors: string[] = [];
1004
+ return errors;
1005
+ }
1006
+
1007
+ /** Loom compute job state projection payload
1008
+ * Schema: cascadia.loom-job.v1
1009
+ * CUE: schemas/control-plane/loom-job.cue (LoomJob)
1010
+ */
1011
+ export interface CascadiaLoomJobV1Payload {
1012
+ job_id: string;
1013
+ worker_id?: string;
1014
+ status: string;
1015
+ }
1016
+
1017
+ export function validateCascadiaLoomJobV1Payload(payload: CascadiaLoomJobV1Payload): string[] {
1018
+ const errors: string[] = [];
1019
+ if (payload.job_id === undefined || payload.job_id === null || payload.job_id === '') errors.push("cascadia.loom-job.v1.job_id is required");
1020
+ if (payload.status === undefined || payload.status === null || payload.status === '') errors.push("cascadia.loom-job.v1.status is required");
1021
+ return errors;
1022
+ }
1023
+
1024
+ /** Compute job lifecycle request payload
1025
+ * Schema: cascadia.loom.v1
1026
+ * CUE: schemas/control-plane/loom.cue (Loom)
1027
+ */
1028
+ export interface CascadiaLoomV1Payload {
1029
+ job_id: string;
1030
+ worker_id?: string;
1031
+ }
1032
+
1033
+ export function validateCascadiaLoomV1Payload(payload: CascadiaLoomV1Payload): string[] {
1034
+ const errors: string[] = [];
1035
+ if (payload.job_id === undefined || payload.job_id === null || payload.job_id === '') errors.push("cascadia.loom.v1.job_id is required");
1036
+ return errors;
1037
+ }
1038
+
1039
+ /** Compute worker advertisement payload
1040
+ * Schema: cascadia.loom.worker.v1
1041
+ * CUE: schemas/agent/worker-ad.cue (Hardware, WorkerCapacity, Pricing, WorkerAdvertisement)
1042
+ */
1043
+ export interface CascadiaLoomWorkerV1Payload {
1044
+ worker_id: string;
1045
+ hardware: Record<string, unknown>;
1046
+ capacity: Record<string, unknown>;
1047
+ supported_frameworks?: string[];
1048
+ pricing?: Record<string, unknown>;
1049
+ }
1050
+
1051
+ export function validateCascadiaLoomWorkerV1Payload(payload: CascadiaLoomWorkerV1Payload): string[] {
1052
+ const errors: string[] = [];
1053
+ if (payload.worker_id === undefined || payload.worker_id === null || payload.worker_id === '') errors.push("cascadia.loom.worker.v1.worker_id is required");
1054
+ if (payload.hardware === undefined || payload.hardware === null) errors.push("cascadia.loom.worker.v1.hardware is required");
1055
+ if (payload.capacity === undefined || payload.capacity === null) errors.push("cascadia.loom.worker.v1.capacity is required");
1056
+ return errors;
1057
+ }
1058
+
1059
+ /** Task Fabric ContextVM queue command payload
1060
+ * Schema: cascadia.queue.v1
1061
+ * CUE: schemas/control-plane/queue.cue (Queue)
1062
+ */
1063
+ export interface CascadiaQueueV1Payload {
1064
+ queue: string;
1065
+ task_id?: string;
1066
+ limit?: number;
1067
+ }
1068
+
1069
+ export function validateCascadiaQueueV1Payload(payload: CascadiaQueueV1Payload): string[] {
1070
+ const errors: string[] = [];
1071
+ if (payload.queue === undefined || payload.queue === null || payload.queue === '') errors.push("cascadia.queue.v1.queue is required");
1072
+ return errors;
1073
+ }
1074
+
1075
+ /** Agent provisioning (soul-factory) request payload
1076
+ * Schema: cascadia.soul-factory.v1
1077
+ * CUE: schemas/control-plane/soul-factory.cue (SoulFactory)
1078
+ */
1079
+ export interface CascadiaSoulFactoryV1Payload {
1080
+ template_id: string;
1081
+ agent_id?: string;
1082
+ }
1083
+
1084
+ export function validateCascadiaSoulFactoryV1Payload(payload: CascadiaSoulFactoryV1Payload): string[] {
1085
+ const errors: string[] = [];
1086
+ if (payload.template_id === undefined || payload.template_id === null || payload.template_id === '') errors.push("cascadia.soul-factory.v1.template_id is required");
1087
+ return errors;
1088
+ }
1089
+
1090
+ /** Soul/agent provisioning state projection payload
1091
+ * Schema: cascadia.soul-state.v1
1092
+ * CUE: schemas/control-plane/soul-state.cue (SoulState)
1093
+ */
1094
+ export interface CascadiaSoulStateV1Payload {
1095
+ agent_id: string;
1096
+ template_id?: string;
1097
+ status: string;
1098
+ }
1099
+
1100
+ export function validateCascadiaSoulStateV1Payload(payload: CascadiaSoulStateV1Payload): string[] {
1101
+ const errors: string[] = [];
1102
+ if (payload.agent_id === undefined || payload.agent_id === null || payload.agent_id === '') errors.push("cascadia.soul-state.v1.agent_id is required");
1103
+ if (payload.status === undefined || payload.status === null || payload.status === '') errors.push("cascadia.soul-state.v1.status is required");
1104
+ return errors;
1105
+ }
1106
+
1107
+ /** Task Fabric NIP-51 epic and queue collection payload
1108
+ * Schema: cascadia.task-collection.v1
1109
+ * CUE: schemas/control-plane/task-collection.cue (TaskCollection)
1110
+ */
1111
+ export interface CascadiaTaskCollectionV1Payload {
1112
+ id?: string;
1113
+ }
1114
+
1115
+ export function validateCascadiaTaskCollectionV1Payload(payload: CascadiaTaskCollectionV1Payload): string[] {
1116
+ const errors: string[] = [];
1117
+ return errors;
1118
+ }
1119
+
1120
+ /** Task Fabric 30900 task state projection payload
1121
+ * Schema: cascadia.task-state.v1
1122
+ * CUE: schemas/control-plane/task-state.cue (TaskState)
1123
+ */
1124
+ export interface CascadiaTaskStateV1Payload {
1125
+ id: string;
1126
+ title: string;
1127
+ description?: string;
1128
+ status: "open" | "in_progress" | "blocked" | "closed";
1129
+ priority?: "P0" | "P1" | "P2" | "P3" | "P4";
1130
+ epic?: string;
1131
+ assignee?: string;
1132
+ labels?: string[];
1133
+ depends_on?: string[];
1134
+ metadata?: Record<string, unknown>;
1135
+ }
1136
+
1137
+ export function validateCascadiaTaskStateV1Payload(payload: CascadiaTaskStateV1Payload): string[] {
1138
+ const errors: string[] = [];
1139
+ if (payload.id === undefined || payload.id === null || payload.id === '') errors.push("cascadia.task-state.v1.id is required");
1140
+ if (payload.title === undefined || payload.title === null || payload.title === '') errors.push("cascadia.task-state.v1.title is required");
1141
+ if (payload.status === undefined || payload.status === null) errors.push("cascadia.task-state.v1.status is required");
1142
+ if (payload.status !== undefined && !["open", "in_progress", "blocked", "closed"].includes(payload.status as string)) errors.push("cascadia.task-state.v1.status must be one of: open, in_progress, blocked, closed");
1143
+ if (payload.priority !== undefined && !["P0", "P1", "P2", "P3", "P4"].includes(payload.priority as string)) errors.push("cascadia.task-state.v1.priority must be one of: P0, P1, P2, P3, P4");
1144
+ return errors;
1145
+ }
1146
+
1147
+ /** Task Fabric ContextVM task command payload
1148
+ * Schema: cascadia.task.v1
1149
+ * CUE: schemas/control-plane/task.cue (Task)
1150
+ */
1151
+ export interface CascadiaTaskV1Payload {
1152
+ task_id: string;
1153
+ assignee?: string;
1154
+ claimer?: string;
1155
+ status?: "open" | "in_progress" | "blocked" | "closed";
1156
+ priority?: "P0" | "P1" | "P2" | "P3" | "P4";
1157
+ labels?: string[];
1158
+ depends_on?: string[];
1159
+ dispatch?: string;
1160
+ }
1161
+
1162
+ export function validateCascadiaTaskV1Payload(payload: CascadiaTaskV1Payload): string[] {
1163
+ const errors: string[] = [];
1164
+ if (payload.task_id === undefined || payload.task_id === null || payload.task_id === '') errors.push("cascadia.task.v1.task_id is required");
1165
+ if (payload.status !== undefined && !["open", "in_progress", "blocked", "closed"].includes(payload.status as string)) errors.push("cascadia.task.v1.status must be one of: open, in_progress, blocked, closed");
1166
+ if (payload.priority !== undefined && !["P0", "P1", "P2", "P3", "P4"].includes(payload.priority as string)) errors.push("cascadia.task.v1.priority must be one of: P0, P1, P2, P3, P4");
1167
+ return errors;
1168
+ }
1169
+
1170
+ /** CI workflow run request payload
1171
+ * Schema: hive.ci.workflow.v1
1172
+ * CUE: schemas/ci/workflow.cue (Workflow)
1173
+ */
1174
+ export interface HiveCiWorkflowV1Payload {
1175
+ workflow: string;
1176
+ commit: string;
1177
+ branch?: string;
1178
+ triggered_by?: string;
1179
+ }
1180
+
1181
+ export function validateHiveCiWorkflowV1Payload(payload: HiveCiWorkflowV1Payload): string[] {
1182
+ const errors: string[] = [];
1183
+ if (payload.workflow === undefined || payload.workflow === null || payload.workflow === '') errors.push("hive.ci.workflow.v1.workflow is required");
1184
+ if (payload.commit === undefined || payload.commit === null || payload.commit === '') errors.push("hive.ci.workflow.v1.commit is required");
1185
+ return errors;
1186
+ }
1187
+