@casimesh/sdk 0.1.0 → 0.2.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.
Files changed (4) hide show
  1. package/index.d.ts +1490 -30
  2. package/index.js +300 -15
  3. package/index.js.map +1 -1
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -68,6 +68,74 @@ declare const UpdateAgentRequest: z.ZodObject<{
68
68
  }, z.core.$strip>;
69
69
  type UpdateAgentRequest = z.infer<typeof UpdateAgentRequest>;
70
70
 
71
+ /**
72
+ * The node's audit log (ADR-0024): append-only, hash-chained and signed with the node key. Each entry records a
73
+ * security-relevant decision or event on this node; it is local, never replicated.
74
+ */
75
+ declare const AuditKind: z.ZodEnum<{
76
+ principal: "principal";
77
+ authorization: "authorization";
78
+ authentication: "authentication";
79
+ credential: "credential";
80
+ policy: "policy";
81
+ replication: "replication";
82
+ }>;
83
+ type AuditKind = z.infer<typeof AuditKind>;
84
+ /** `allowed` / `denied` for decisions; `done` for changes that simply happened (a token issued). */
85
+ declare const AuditOutcome: z.ZodEnum<{
86
+ allowed: "allowed";
87
+ denied: "denied";
88
+ done: "done";
89
+ }>;
90
+ type AuditOutcome = z.infer<typeof AuditOutcome>;
91
+ declare const AuditTarget: z.ZodObject<{
92
+ nodeId: z.ZodOptional<z.ZodString>;
93
+ organizationId: z.ZodOptional<z.ZodString>;
94
+ id: z.ZodOptional<z.ZodString>;
95
+ }, z.core.$strip>;
96
+ type AuditTarget = z.infer<typeof AuditTarget>;
97
+ declare const AuditEntry: z.ZodObject<{
98
+ seq: z.ZodInt;
99
+ id: z.ZodString;
100
+ at: z.ZodISODateTime;
101
+ kind: z.ZodEnum<{
102
+ principal: "principal";
103
+ authorization: "authorization";
104
+ authentication: "authentication";
105
+ credential: "credential";
106
+ policy: "policy";
107
+ replication: "replication";
108
+ }>;
109
+ action: z.ZodString;
110
+ outcome: z.ZodEnum<{
111
+ allowed: "allowed";
112
+ denied: "denied";
113
+ done: "done";
114
+ }>;
115
+ principalId: z.ZodNullable<z.ZodString>;
116
+ credentialId: z.ZodNullable<z.ZodString>;
117
+ target: z.ZodObject<{
118
+ nodeId: z.ZodOptional<z.ZodString>;
119
+ organizationId: z.ZodOptional<z.ZodString>;
120
+ id: z.ZodOptional<z.ZodString>;
121
+ }, z.core.$strip>;
122
+ detail: z.ZodString;
123
+ prevHash: z.ZodString;
124
+ hash: z.ZodString;
125
+ sig: z.ZodString;
126
+ signer: z.ZodNullable<z.ZodString>;
127
+ }, z.core.$strip>;
128
+ type AuditEntry = z.infer<typeof AuditEntry>;
129
+ declare const AuditVerification: z.ZodObject<{
130
+ valid: z.ZodBoolean;
131
+ entries: z.ZodInt;
132
+ brokenAt: z.ZodNullable<z.ZodInt>;
133
+ reason: z.ZodNullable<z.ZodString>;
134
+ publicKey: z.ZodString;
135
+ }, z.core.$strip>;
136
+ type AuditVerification = z.infer<typeof AuditVerification>;
137
+ declare const GENESIS_HASH: string;
138
+
71
139
  declare const PrincipalKind: z.ZodEnum<{
72
140
  user: "user";
73
141
  service: "service";
@@ -84,12 +152,31 @@ declare const Principal: z.ZodObject<{
84
152
  createdAt: z.ZodISODateTime;
85
153
  }, z.core.$strip>;
86
154
  type Principal = z.infer<typeof Principal>;
87
- /** Ownership roles (ADR-0010). */
155
+ /**
156
+ * Roles (ADR-0010, ADR-0022). Node-scoped: `node_owner` manages the node; `viewer` reads the mesh; `auditor` reads the
157
+ * mesh and the audit log. Organization-scoped: `org_owner` manages the organization; `agent_operator` starts and stops
158
+ * its agents and requests capabilities for them, without creating or removing anything.
159
+ */
88
160
  declare const Role: z.ZodEnum<{
89
161
  node_owner: "node_owner";
90
162
  org_owner: "org_owner";
163
+ viewer: "viewer";
164
+ auditor: "auditor";
165
+ agent_operator: "agent_operator";
91
166
  }>;
92
167
  type Role = z.infer<typeof Role>;
168
+ declare const NODE_ROLES: readonly Role[];
169
+ declare const ORGANIZATION_ROLES: readonly Role[];
170
+ /** Roles whose last holder cannot be removed, so every node and organization stays manageable. */
171
+ declare const OWNER_ROLES: readonly Role[];
172
+ /** What a credential may be used for (ADR-0022). A token can never do more than its principal's roles allow. */
173
+ declare const TokenScope: z.ZodEnum<{
174
+ read: "read";
175
+ write: "write";
176
+ admin: "admin";
177
+ }>;
178
+ type TokenScope = z.infer<typeof TokenScope>;
179
+ declare const ALL_SCOPES: readonly TokenScope[];
93
180
  declare const RoleScope: z.ZodDiscriminatedUnion<[z.ZodObject<{
94
181
  type: z.ZodLiteral<"node">;
95
182
  nodeId: z.ZodString;
@@ -105,6 +192,9 @@ declare const RoleBinding: z.ZodObject<{
105
192
  role: z.ZodEnum<{
106
193
  node_owner: "node_owner";
107
194
  org_owner: "org_owner";
195
+ viewer: "viewer";
196
+ auditor: "auditor";
197
+ agent_operator: "agent_operator";
108
198
  }>;
109
199
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
110
200
  type: z.ZodLiteral<"node">;
@@ -121,6 +211,33 @@ declare const GrantOwnerRequest: z.ZodObject<{
121
211
  principalId: z.ZodString;
122
212
  }, z.core.$strip>;
123
213
  type GrantOwnerRequest = z.infer<typeof GrantOwnerRequest>;
214
+ /** Where a role applies, as callers name it; the server fills in the node of an organization. */
215
+ declare const RoleTarget: z.ZodDiscriminatedUnion<[z.ZodObject<{
216
+ type: z.ZodLiteral<"node">;
217
+ nodeId: z.ZodString;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ type: z.ZodLiteral<"organization">;
220
+ organizationId: z.ZodString;
221
+ }, z.core.$strip>], "type">;
222
+ type RoleTarget = z.infer<typeof RoleTarget>;
223
+ declare const GrantRoleRequest: z.ZodObject<{
224
+ principalId: z.ZodString;
225
+ role: z.ZodEnum<{
226
+ node_owner: "node_owner";
227
+ org_owner: "org_owner";
228
+ viewer: "viewer";
229
+ auditor: "auditor";
230
+ agent_operator: "agent_operator";
231
+ }>;
232
+ target: z.ZodDiscriminatedUnion<[z.ZodObject<{
233
+ type: z.ZodLiteral<"node">;
234
+ nodeId: z.ZodString;
235
+ }, z.core.$strip>, z.ZodObject<{
236
+ type: z.ZodLiteral<"organization">;
237
+ organizationId: z.ZodString;
238
+ }, z.core.$strip>], "type">;
239
+ }, z.core.$strip>;
240
+ type GrantRoleRequest = z.infer<typeof GrantRoleRequest>;
124
241
 
125
242
  /** Dotted, lowercase capability name, e.g. `vision` or `terrain.analysis` (deck slide 07). */
126
243
  declare const CapabilityName: z.ZodString;
@@ -176,6 +293,15 @@ declare const NodeCreated: z.ZodObject<{
176
293
  }>;
177
294
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
178
295
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
296
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
297
+ v: z.ZodLiteral<1>;
298
+ nodeId: z.ZodString;
299
+ publicKey: z.ZodString;
300
+ issuedAt: z.ZodISODateTime;
301
+ expiresAt: z.ZodISODateTime;
302
+ rootKey: z.ZodString;
303
+ sig: z.ZodString;
304
+ }, z.core.$strip>>>;
179
305
  }, z.core.$strip>;
180
306
  }, z.core.$strip>;
181
307
  }, z.core.$strip>;
@@ -202,6 +328,15 @@ declare const NodeUpdated: z.ZodObject<{
202
328
  }>;
203
329
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
204
330
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
331
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
332
+ v: z.ZodLiteral<1>;
333
+ nodeId: z.ZodString;
334
+ publicKey: z.ZodString;
335
+ issuedAt: z.ZodISODateTime;
336
+ expiresAt: z.ZodISODateTime;
337
+ rootKey: z.ZodString;
338
+ sig: z.ZodString;
339
+ }, z.core.$strip>>>;
205
340
  }, z.core.$strip>;
206
341
  }, z.core.$strip>;
207
342
  }, z.core.$strip>;
@@ -269,6 +404,52 @@ declare const OrganizationCreated: z.ZodObject<{
269
404
  name: z.ZodString;
270
405
  slug: z.ZodString;
271
406
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
407
+ policy: z.ZodDefault<z.ZodObject<{
408
+ inbound: z.ZodDefault<z.ZodObject<{
409
+ default: z.ZodDefault<z.ZodEnum<{
410
+ allow: "allow";
411
+ deny: "deny";
412
+ }>>;
413
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
414
+ effect: z.ZodEnum<{
415
+ allow: "allow";
416
+ deny: "deny";
417
+ }>;
418
+ capability: z.ZodString;
419
+ organizationId: z.ZodOptional<z.ZodString>;
420
+ nodeId: z.ZodOptional<z.ZodString>;
421
+ }, z.core.$strip>>>;
422
+ }, z.core.$strip>>;
423
+ outbound: z.ZodDefault<z.ZodObject<{
424
+ default: z.ZodDefault<z.ZodEnum<{
425
+ allow: "allow";
426
+ deny: "deny";
427
+ }>>;
428
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
429
+ effect: z.ZodEnum<{
430
+ allow: "allow";
431
+ deny: "deny";
432
+ }>;
433
+ capability: z.ZodString;
434
+ organizationId: z.ZodOptional<z.ZodString>;
435
+ nodeId: z.ZodOptional<z.ZodString>;
436
+ }, z.core.$strip>>>;
437
+ }, z.core.$strip>>;
438
+ tools: z.ZodDefault<z.ZodObject<{
439
+ default: z.ZodDefault<z.ZodEnum<{
440
+ allow: "allow";
441
+ deny: "deny";
442
+ }>>;
443
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
444
+ effect: z.ZodEnum<{
445
+ allow: "allow";
446
+ deny: "deny";
447
+ }>;
448
+ tool: z.ZodString;
449
+ agentId: z.ZodOptional<z.ZodString>;
450
+ }, z.core.$strip>>>;
451
+ }, z.core.$strip>>;
452
+ }, z.core.$strip>>;
272
453
  }, z.core.$strip>;
273
454
  }, z.core.$strip>;
274
455
  }, z.core.$strip>;
@@ -289,6 +470,52 @@ declare const OrganizationUpdated: z.ZodObject<{
289
470
  name: z.ZodString;
290
471
  slug: z.ZodString;
291
472
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
473
+ policy: z.ZodDefault<z.ZodObject<{
474
+ inbound: z.ZodDefault<z.ZodObject<{
475
+ default: z.ZodDefault<z.ZodEnum<{
476
+ allow: "allow";
477
+ deny: "deny";
478
+ }>>;
479
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
480
+ effect: z.ZodEnum<{
481
+ allow: "allow";
482
+ deny: "deny";
483
+ }>;
484
+ capability: z.ZodString;
485
+ organizationId: z.ZodOptional<z.ZodString>;
486
+ nodeId: z.ZodOptional<z.ZodString>;
487
+ }, z.core.$strip>>>;
488
+ }, z.core.$strip>>;
489
+ outbound: z.ZodDefault<z.ZodObject<{
490
+ default: z.ZodDefault<z.ZodEnum<{
491
+ allow: "allow";
492
+ deny: "deny";
493
+ }>>;
494
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
495
+ effect: z.ZodEnum<{
496
+ allow: "allow";
497
+ deny: "deny";
498
+ }>;
499
+ capability: z.ZodString;
500
+ organizationId: z.ZodOptional<z.ZodString>;
501
+ nodeId: z.ZodOptional<z.ZodString>;
502
+ }, z.core.$strip>>>;
503
+ }, z.core.$strip>>;
504
+ tools: z.ZodDefault<z.ZodObject<{
505
+ default: z.ZodDefault<z.ZodEnum<{
506
+ allow: "allow";
507
+ deny: "deny";
508
+ }>>;
509
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
510
+ effect: z.ZodEnum<{
511
+ allow: "allow";
512
+ deny: "deny";
513
+ }>;
514
+ tool: z.ZodString;
515
+ agentId: z.ZodOptional<z.ZodString>;
516
+ }, z.core.$strip>>>;
517
+ }, z.core.$strip>>;
518
+ }, z.core.$strip>>;
292
519
  }, z.core.$strip>;
293
520
  }, z.core.$strip>;
294
521
  }, z.core.$strip>;
@@ -632,6 +859,9 @@ declare const RoleGranted: z.ZodObject<{
632
859
  role: z.ZodEnum<{
633
860
  node_owner: "node_owner";
634
861
  org_owner: "org_owner";
862
+ viewer: "viewer";
863
+ auditor: "auditor";
864
+ agent_operator: "agent_operator";
635
865
  }>;
636
866
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
637
867
  type: z.ZodLiteral<"node">;
@@ -659,6 +889,9 @@ declare const RoleRevoked: z.ZodObject<{
659
889
  role: z.ZodEnum<{
660
890
  node_owner: "node_owner";
661
891
  org_owner: "org_owner";
892
+ viewer: "viewer";
893
+ auditor: "auditor";
894
+ agent_operator: "agent_operator";
662
895
  }>;
663
896
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
664
897
  type: z.ZodLiteral<"node">;
@@ -714,8 +947,8 @@ declare const TaskRequested: z.ZodObject<{
714
947
  }, z.core.$strip>>;
715
948
  steps: z.ZodArray<z.ZodObject<{
716
949
  name: z.ZodEnum<{
717
- observe: "observe";
718
950
  reason: "reason";
951
+ observe: "observe";
719
952
  act: "act";
720
953
  verify: "verify";
721
954
  }>;
@@ -770,8 +1003,8 @@ declare const TaskAccepted: z.ZodObject<{
770
1003
  }, z.core.$strip>>;
771
1004
  steps: z.ZodArray<z.ZodObject<{
772
1005
  name: z.ZodEnum<{
773
- observe: "observe";
774
1006
  reason: "reason";
1007
+ observe: "observe";
775
1008
  act: "act";
776
1009
  verify: "verify";
777
1010
  }>;
@@ -826,8 +1059,8 @@ declare const TaskCompleted: z.ZodObject<{
826
1059
  }, z.core.$strip>>;
827
1060
  steps: z.ZodArray<z.ZodObject<{
828
1061
  name: z.ZodEnum<{
829
- observe: "observe";
830
1062
  reason: "reason";
1063
+ observe: "observe";
831
1064
  act: "act";
832
1065
  verify: "verify";
833
1066
  }>;
@@ -882,8 +1115,8 @@ declare const TaskFailed: z.ZodObject<{
882
1115
  }, z.core.$strip>>;
883
1116
  steps: z.ZodArray<z.ZodObject<{
884
1117
  name: z.ZodEnum<{
885
- observe: "observe";
886
1118
  reason: "reason";
1119
+ observe: "observe";
887
1120
  act: "act";
888
1121
  verify: "verify";
889
1122
  }>;
@@ -897,6 +1130,29 @@ declare const TaskFailed: z.ZodObject<{
897
1130
  }, z.core.$strip>;
898
1131
  }, z.core.$strip>;
899
1132
  }, z.core.$strip>;
1133
+ /**
1134
+ * A mesh-root revocation, published through any node so it gossips (ADR-0025). Its authority is the root's signature
1135
+ * inside, not the publishing node: any node may publish one, and every node checks it against its own root key.
1136
+ */
1137
+ declare const MeshKeyRevoked: z.ZodObject<{
1138
+ type: z.ZodLiteral<"mesh.key_revoked">;
1139
+ subject: z.ZodObject<{
1140
+ kind: z.ZodLiteral<"revocation">;
1141
+ id: z.ZodString;
1142
+ version: z.ZodInt;
1143
+ }, z.core.$strip>;
1144
+ payload: z.ZodObject<{
1145
+ revocation: z.ZodObject<{
1146
+ v: z.ZodLiteral<1>;
1147
+ publicKey: z.ZodString;
1148
+ nodeId: z.ZodString;
1149
+ revokedAt: z.ZodISODateTime;
1150
+ reason: z.ZodString;
1151
+ rootKey: z.ZodString;
1152
+ sig: z.ZodString;
1153
+ }, z.core.$strip>;
1154
+ }, z.core.$strip>;
1155
+ }, z.core.$strip>;
900
1156
  declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
901
1157
  type: z.ZodLiteral<"node.created">;
902
1158
  subject: z.ZodObject<{
@@ -920,6 +1176,15 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
920
1176
  }>;
921
1177
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
922
1178
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
1179
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
1180
+ v: z.ZodLiteral<1>;
1181
+ nodeId: z.ZodString;
1182
+ publicKey: z.ZodString;
1183
+ issuedAt: z.ZodISODateTime;
1184
+ expiresAt: z.ZodISODateTime;
1185
+ rootKey: z.ZodString;
1186
+ sig: z.ZodString;
1187
+ }, z.core.$strip>>>;
923
1188
  }, z.core.$strip>;
924
1189
  }, z.core.$strip>;
925
1190
  }, z.core.$strip>, z.ZodObject<{
@@ -945,6 +1210,15 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
945
1210
  }>;
946
1211
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
947
1212
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
1213
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
1214
+ v: z.ZodLiteral<1>;
1215
+ nodeId: z.ZodString;
1216
+ publicKey: z.ZodString;
1217
+ issuedAt: z.ZodISODateTime;
1218
+ expiresAt: z.ZodISODateTime;
1219
+ rootKey: z.ZodString;
1220
+ sig: z.ZodString;
1221
+ }, z.core.$strip>>>;
948
1222
  }, z.core.$strip>;
949
1223
  }, z.core.$strip>;
950
1224
  }, z.core.$strip>, z.ZodObject<{
@@ -1006,6 +1280,52 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1006
1280
  name: z.ZodString;
1007
1281
  slug: z.ZodString;
1008
1282
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1283
+ policy: z.ZodDefault<z.ZodObject<{
1284
+ inbound: z.ZodDefault<z.ZodObject<{
1285
+ default: z.ZodDefault<z.ZodEnum<{
1286
+ allow: "allow";
1287
+ deny: "deny";
1288
+ }>>;
1289
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
1290
+ effect: z.ZodEnum<{
1291
+ allow: "allow";
1292
+ deny: "deny";
1293
+ }>;
1294
+ capability: z.ZodString;
1295
+ organizationId: z.ZodOptional<z.ZodString>;
1296
+ nodeId: z.ZodOptional<z.ZodString>;
1297
+ }, z.core.$strip>>>;
1298
+ }, z.core.$strip>>;
1299
+ outbound: z.ZodDefault<z.ZodObject<{
1300
+ default: z.ZodDefault<z.ZodEnum<{
1301
+ allow: "allow";
1302
+ deny: "deny";
1303
+ }>>;
1304
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
1305
+ effect: z.ZodEnum<{
1306
+ allow: "allow";
1307
+ deny: "deny";
1308
+ }>;
1309
+ capability: z.ZodString;
1310
+ organizationId: z.ZodOptional<z.ZodString>;
1311
+ nodeId: z.ZodOptional<z.ZodString>;
1312
+ }, z.core.$strip>>>;
1313
+ }, z.core.$strip>>;
1314
+ tools: z.ZodDefault<z.ZodObject<{
1315
+ default: z.ZodDefault<z.ZodEnum<{
1316
+ allow: "allow";
1317
+ deny: "deny";
1318
+ }>>;
1319
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
1320
+ effect: z.ZodEnum<{
1321
+ allow: "allow";
1322
+ deny: "deny";
1323
+ }>;
1324
+ tool: z.ZodString;
1325
+ agentId: z.ZodOptional<z.ZodString>;
1326
+ }, z.core.$strip>>>;
1327
+ }, z.core.$strip>>;
1328
+ }, z.core.$strip>>;
1009
1329
  }, z.core.$strip>;
1010
1330
  }, z.core.$strip>;
1011
1331
  }, z.core.$strip>, z.ZodObject<{
@@ -1025,6 +1345,52 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1025
1345
  name: z.ZodString;
1026
1346
  slug: z.ZodString;
1027
1347
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1348
+ policy: z.ZodDefault<z.ZodObject<{
1349
+ inbound: z.ZodDefault<z.ZodObject<{
1350
+ default: z.ZodDefault<z.ZodEnum<{
1351
+ allow: "allow";
1352
+ deny: "deny";
1353
+ }>>;
1354
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
1355
+ effect: z.ZodEnum<{
1356
+ allow: "allow";
1357
+ deny: "deny";
1358
+ }>;
1359
+ capability: z.ZodString;
1360
+ organizationId: z.ZodOptional<z.ZodString>;
1361
+ nodeId: z.ZodOptional<z.ZodString>;
1362
+ }, z.core.$strip>>>;
1363
+ }, z.core.$strip>>;
1364
+ outbound: z.ZodDefault<z.ZodObject<{
1365
+ default: z.ZodDefault<z.ZodEnum<{
1366
+ allow: "allow";
1367
+ deny: "deny";
1368
+ }>>;
1369
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
1370
+ effect: z.ZodEnum<{
1371
+ allow: "allow";
1372
+ deny: "deny";
1373
+ }>;
1374
+ capability: z.ZodString;
1375
+ organizationId: z.ZodOptional<z.ZodString>;
1376
+ nodeId: z.ZodOptional<z.ZodString>;
1377
+ }, z.core.$strip>>>;
1378
+ }, z.core.$strip>>;
1379
+ tools: z.ZodDefault<z.ZodObject<{
1380
+ default: z.ZodDefault<z.ZodEnum<{
1381
+ allow: "allow";
1382
+ deny: "deny";
1383
+ }>>;
1384
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
1385
+ effect: z.ZodEnum<{
1386
+ allow: "allow";
1387
+ deny: "deny";
1388
+ }>;
1389
+ tool: z.ZodString;
1390
+ agentId: z.ZodOptional<z.ZodString>;
1391
+ }, z.core.$strip>>>;
1392
+ }, z.core.$strip>>;
1393
+ }, z.core.$strip>>;
1028
1394
  }, z.core.$strip>;
1029
1395
  }, z.core.$strip>;
1030
1396
  }, z.core.$strip>, z.ZodObject<{
@@ -1355,6 +1721,9 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1355
1721
  role: z.ZodEnum<{
1356
1722
  node_owner: "node_owner";
1357
1723
  org_owner: "org_owner";
1724
+ viewer: "viewer";
1725
+ auditor: "auditor";
1726
+ agent_operator: "agent_operator";
1358
1727
  }>;
1359
1728
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
1360
1729
  type: z.ZodLiteral<"node">;
@@ -1381,6 +1750,9 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1381
1750
  role: z.ZodEnum<{
1382
1751
  node_owner: "node_owner";
1383
1752
  org_owner: "org_owner";
1753
+ viewer: "viewer";
1754
+ auditor: "auditor";
1755
+ agent_operator: "agent_operator";
1384
1756
  }>;
1385
1757
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
1386
1758
  type: z.ZodLiteral<"node">;
@@ -1434,8 +1806,8 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1434
1806
  }, z.core.$strip>>;
1435
1807
  steps: z.ZodArray<z.ZodObject<{
1436
1808
  name: z.ZodEnum<{
1437
- observe: "observe";
1438
1809
  reason: "reason";
1810
+ observe: "observe";
1439
1811
  act: "act";
1440
1812
  verify: "verify";
1441
1813
  }>;
@@ -1489,8 +1861,8 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1489
1861
  }, z.core.$strip>>;
1490
1862
  steps: z.ZodArray<z.ZodObject<{
1491
1863
  name: z.ZodEnum<{
1492
- observe: "observe";
1493
1864
  reason: "reason";
1865
+ observe: "observe";
1494
1866
  act: "act";
1495
1867
  verify: "verify";
1496
1868
  }>;
@@ -1544,8 +1916,8 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1544
1916
  }, z.core.$strip>>;
1545
1917
  steps: z.ZodArray<z.ZodObject<{
1546
1918
  name: z.ZodEnum<{
1547
- observe: "observe";
1548
1919
  reason: "reason";
1920
+ observe: "observe";
1549
1921
  act: "act";
1550
1922
  verify: "verify";
1551
1923
  }>;
@@ -1599,8 +1971,8 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1599
1971
  }, z.core.$strip>>;
1600
1972
  steps: z.ZodArray<z.ZodObject<{
1601
1973
  name: z.ZodEnum<{
1602
- observe: "observe";
1603
1974
  reason: "reason";
1975
+ observe: "observe";
1604
1976
  act: "act";
1605
1977
  verify: "verify";
1606
1978
  }>;
@@ -1613,6 +1985,24 @@ declare const DomainEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1613
1985
  updatedAt: z.ZodISODateTime;
1614
1986
  }, z.core.$strip>;
1615
1987
  }, z.core.$strip>;
1988
+ }, z.core.$strip>, z.ZodObject<{
1989
+ type: z.ZodLiteral<"mesh.key_revoked">;
1990
+ subject: z.ZodObject<{
1991
+ kind: z.ZodLiteral<"revocation">;
1992
+ id: z.ZodString;
1993
+ version: z.ZodInt;
1994
+ }, z.core.$strip>;
1995
+ payload: z.ZodObject<{
1996
+ revocation: z.ZodObject<{
1997
+ v: z.ZodLiteral<1>;
1998
+ publicKey: z.ZodString;
1999
+ nodeId: z.ZodString;
2000
+ revokedAt: z.ZodISODateTime;
2001
+ reason: z.ZodString;
2002
+ rootKey: z.ZodString;
2003
+ sig: z.ZodString;
2004
+ }, z.core.$strip>;
2005
+ }, z.core.$strip>;
1616
2006
  }, z.core.$strip>], "type">;
1617
2007
  type DomainEvent = z.infer<typeof DomainEvent>;
1618
2008
  type DomainEventType = DomainEvent["type"];
@@ -1669,6 +2059,15 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
1669
2059
  }>;
1670
2060
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1671
2061
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
2062
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
2063
+ v: z.ZodLiteral<1>;
2064
+ nodeId: z.ZodString;
2065
+ publicKey: z.ZodString;
2066
+ issuedAt: z.ZodISODateTime;
2067
+ expiresAt: z.ZodISODateTime;
2068
+ rootKey: z.ZodString;
2069
+ sig: z.ZodString;
2070
+ }, z.core.$strip>>>;
1672
2071
  }, z.core.$strip>;
1673
2072
  }, z.core.$strip>;
1674
2073
  }, z.core.$strip>, z.ZodObject<{
@@ -1694,6 +2093,15 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
1694
2093
  }>;
1695
2094
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1696
2095
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
2096
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
2097
+ v: z.ZodLiteral<1>;
2098
+ nodeId: z.ZodString;
2099
+ publicKey: z.ZodString;
2100
+ issuedAt: z.ZodISODateTime;
2101
+ expiresAt: z.ZodISODateTime;
2102
+ rootKey: z.ZodString;
2103
+ sig: z.ZodString;
2104
+ }, z.core.$strip>>>;
1697
2105
  }, z.core.$strip>;
1698
2106
  }, z.core.$strip>;
1699
2107
  }, z.core.$strip>, z.ZodObject<{
@@ -1755,6 +2163,52 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
1755
2163
  name: z.ZodString;
1756
2164
  slug: z.ZodString;
1757
2165
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2166
+ policy: z.ZodDefault<z.ZodObject<{
2167
+ inbound: z.ZodDefault<z.ZodObject<{
2168
+ default: z.ZodDefault<z.ZodEnum<{
2169
+ allow: "allow";
2170
+ deny: "deny";
2171
+ }>>;
2172
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
2173
+ effect: z.ZodEnum<{
2174
+ allow: "allow";
2175
+ deny: "deny";
2176
+ }>;
2177
+ capability: z.ZodString;
2178
+ organizationId: z.ZodOptional<z.ZodString>;
2179
+ nodeId: z.ZodOptional<z.ZodString>;
2180
+ }, z.core.$strip>>>;
2181
+ }, z.core.$strip>>;
2182
+ outbound: z.ZodDefault<z.ZodObject<{
2183
+ default: z.ZodDefault<z.ZodEnum<{
2184
+ allow: "allow";
2185
+ deny: "deny";
2186
+ }>>;
2187
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
2188
+ effect: z.ZodEnum<{
2189
+ allow: "allow";
2190
+ deny: "deny";
2191
+ }>;
2192
+ capability: z.ZodString;
2193
+ organizationId: z.ZodOptional<z.ZodString>;
2194
+ nodeId: z.ZodOptional<z.ZodString>;
2195
+ }, z.core.$strip>>>;
2196
+ }, z.core.$strip>>;
2197
+ tools: z.ZodDefault<z.ZodObject<{
2198
+ default: z.ZodDefault<z.ZodEnum<{
2199
+ allow: "allow";
2200
+ deny: "deny";
2201
+ }>>;
2202
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
2203
+ effect: z.ZodEnum<{
2204
+ allow: "allow";
2205
+ deny: "deny";
2206
+ }>;
2207
+ tool: z.ZodString;
2208
+ agentId: z.ZodOptional<z.ZodString>;
2209
+ }, z.core.$strip>>>;
2210
+ }, z.core.$strip>>;
2211
+ }, z.core.$strip>>;
1758
2212
  }, z.core.$strip>;
1759
2213
  }, z.core.$strip>;
1760
2214
  }, z.core.$strip>, z.ZodObject<{
@@ -1774,6 +2228,52 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
1774
2228
  name: z.ZodString;
1775
2229
  slug: z.ZodString;
1776
2230
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2231
+ policy: z.ZodDefault<z.ZodObject<{
2232
+ inbound: z.ZodDefault<z.ZodObject<{
2233
+ default: z.ZodDefault<z.ZodEnum<{
2234
+ allow: "allow";
2235
+ deny: "deny";
2236
+ }>>;
2237
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
2238
+ effect: z.ZodEnum<{
2239
+ allow: "allow";
2240
+ deny: "deny";
2241
+ }>;
2242
+ capability: z.ZodString;
2243
+ organizationId: z.ZodOptional<z.ZodString>;
2244
+ nodeId: z.ZodOptional<z.ZodString>;
2245
+ }, z.core.$strip>>>;
2246
+ }, z.core.$strip>>;
2247
+ outbound: z.ZodDefault<z.ZodObject<{
2248
+ default: z.ZodDefault<z.ZodEnum<{
2249
+ allow: "allow";
2250
+ deny: "deny";
2251
+ }>>;
2252
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
2253
+ effect: z.ZodEnum<{
2254
+ allow: "allow";
2255
+ deny: "deny";
2256
+ }>;
2257
+ capability: z.ZodString;
2258
+ organizationId: z.ZodOptional<z.ZodString>;
2259
+ nodeId: z.ZodOptional<z.ZodString>;
2260
+ }, z.core.$strip>>>;
2261
+ }, z.core.$strip>>;
2262
+ tools: z.ZodDefault<z.ZodObject<{
2263
+ default: z.ZodDefault<z.ZodEnum<{
2264
+ allow: "allow";
2265
+ deny: "deny";
2266
+ }>>;
2267
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
2268
+ effect: z.ZodEnum<{
2269
+ allow: "allow";
2270
+ deny: "deny";
2271
+ }>;
2272
+ tool: z.ZodString;
2273
+ agentId: z.ZodOptional<z.ZodString>;
2274
+ }, z.core.$strip>>>;
2275
+ }, z.core.$strip>>;
2276
+ }, z.core.$strip>>;
1777
2277
  }, z.core.$strip>;
1778
2278
  }, z.core.$strip>;
1779
2279
  }, z.core.$strip>, z.ZodObject<{
@@ -2104,6 +2604,9 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
2104
2604
  role: z.ZodEnum<{
2105
2605
  node_owner: "node_owner";
2106
2606
  org_owner: "org_owner";
2607
+ viewer: "viewer";
2608
+ auditor: "auditor";
2609
+ agent_operator: "agent_operator";
2107
2610
  }>;
2108
2611
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
2109
2612
  type: z.ZodLiteral<"node">;
@@ -2130,6 +2633,9 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
2130
2633
  role: z.ZodEnum<{
2131
2634
  node_owner: "node_owner";
2132
2635
  org_owner: "org_owner";
2636
+ viewer: "viewer";
2637
+ auditor: "auditor";
2638
+ agent_operator: "agent_operator";
2133
2639
  }>;
2134
2640
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
2135
2641
  type: z.ZodLiteral<"node">;
@@ -2183,8 +2689,8 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
2183
2689
  }, z.core.$strip>>;
2184
2690
  steps: z.ZodArray<z.ZodObject<{
2185
2691
  name: z.ZodEnum<{
2186
- observe: "observe";
2187
2692
  reason: "reason";
2693
+ observe: "observe";
2188
2694
  act: "act";
2189
2695
  verify: "verify";
2190
2696
  }>;
@@ -2238,8 +2744,8 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
2238
2744
  }, z.core.$strip>>;
2239
2745
  steps: z.ZodArray<z.ZodObject<{
2240
2746
  name: z.ZodEnum<{
2241
- observe: "observe";
2242
2747
  reason: "reason";
2748
+ observe: "observe";
2243
2749
  act: "act";
2244
2750
  verify: "verify";
2245
2751
  }>;
@@ -2293,8 +2799,8 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
2293
2799
  }, z.core.$strip>>;
2294
2800
  steps: z.ZodArray<z.ZodObject<{
2295
2801
  name: z.ZodEnum<{
2296
- observe: "observe";
2297
2802
  reason: "reason";
2803
+ observe: "observe";
2298
2804
  act: "act";
2299
2805
  verify: "verify";
2300
2806
  }>;
@@ -2348,8 +2854,8 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
2348
2854
  }, z.core.$strip>>;
2349
2855
  steps: z.ZodArray<z.ZodObject<{
2350
2856
  name: z.ZodEnum<{
2351
- observe: "observe";
2352
2857
  reason: "reason";
2858
+ observe: "observe";
2353
2859
  act: "act";
2354
2860
  verify: "verify";
2355
2861
  }>;
@@ -2362,6 +2868,24 @@ declare const MeshEvent: z.ZodIntersection<z.ZodObject<{
2362
2868
  updatedAt: z.ZodISODateTime;
2363
2869
  }, z.core.$strip>;
2364
2870
  }, z.core.$strip>;
2871
+ }, z.core.$strip>, z.ZodObject<{
2872
+ type: z.ZodLiteral<"mesh.key_revoked">;
2873
+ subject: z.ZodObject<{
2874
+ kind: z.ZodLiteral<"revocation">;
2875
+ id: z.ZodString;
2876
+ version: z.ZodInt;
2877
+ }, z.core.$strip>;
2878
+ payload: z.ZodObject<{
2879
+ revocation: z.ZodObject<{
2880
+ v: z.ZodLiteral<1>;
2881
+ publicKey: z.ZodString;
2882
+ nodeId: z.ZodString;
2883
+ revokedAt: z.ZodISODateTime;
2884
+ reason: z.ZodString;
2885
+ rootKey: z.ZodString;
2886
+ sig: z.ZodString;
2887
+ }, z.core.$strip>;
2888
+ }, z.core.$strip>;
2365
2889
  }, z.core.$strip>], "type">>;
2366
2890
  type MeshEvent = z.infer<typeof MeshEvent>;
2367
2891
 
@@ -2396,6 +2920,9 @@ declare const Me: z.ZodObject<{
2396
2920
  role: z.ZodEnum<{
2397
2921
  node_owner: "node_owner";
2398
2922
  org_owner: "org_owner";
2923
+ viewer: "viewer";
2924
+ auditor: "auditor";
2925
+ agent_operator: "agent_operator";
2399
2926
  }>;
2400
2927
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
2401
2928
  type: z.ZodLiteral<"node">;
@@ -2407,6 +2934,11 @@ declare const Me: z.ZodObject<{
2407
2934
  }, z.core.$strip>], "type">;
2408
2935
  createdAt: z.ZodISODateTime;
2409
2936
  }, z.core.$strip>>;
2937
+ scopes: z.ZodArray<z.ZodEnum<{
2938
+ read: "read";
2939
+ write: "write";
2940
+ admin: "admin";
2941
+ }>>;
2410
2942
  }, z.core.$strip>;
2411
2943
  type Me = z.infer<typeof Me>;
2412
2944
  declare const CreatePrincipalRequest: z.ZodObject<{
@@ -2448,6 +2980,51 @@ declare const CreatePrincipalResponse: z.ZodObject<{
2448
2980
  }, z.core.$strip>], "type">;
2449
2981
  }, z.core.$strip>;
2450
2982
  type CreatePrincipalResponse = z.infer<typeof CreatePrincipalResponse>;
2983
+ /** Longest lifetime a bearer token may be issued for. */
2984
+ declare const MAX_TOKEN_TTL_SECONDS: number;
2985
+ declare const IssueTokenRequest: z.ZodObject<{
2986
+ scopes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
2987
+ read: "read";
2988
+ write: "write";
2989
+ admin: "admin";
2990
+ }>>>;
2991
+ ttlSeconds: z.ZodDefault<z.ZodInt>;
2992
+ label: z.ZodOptional<z.ZodString>;
2993
+ }, z.core.$strip>;
2994
+ type IssueTokenRequest = z.infer<typeof IssueTokenRequest>;
2995
+ type IssueTokenRequestInput = z.input<typeof IssueTokenRequest>;
2996
+ /** A new bearer token, shown exactly once. */
2997
+ declare const IssuedToken: z.ZodObject<{
2998
+ id: z.ZodString;
2999
+ token: z.ZodString;
3000
+ scopes: z.ZodArray<z.ZodEnum<{
3001
+ read: "read";
3002
+ write: "write";
3003
+ admin: "admin";
3004
+ }>>;
3005
+ expiresAt: z.ZodISODateTime;
3006
+ }, z.core.$strip>;
3007
+ type IssuedToken = z.infer<typeof IssuedToken>;
3008
+ /** A credential's metadata — never its secret. */
3009
+ declare const CredentialInfo: z.ZodObject<{
3010
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
3011
+ type: z.ZodEnum<{
3012
+ apiKey: "apiKey";
3013
+ token: "token";
3014
+ }>;
3015
+ principalId: z.ZodString;
3016
+ scopes: z.ZodArray<z.ZodEnum<{
3017
+ read: "read";
3018
+ write: "write";
3019
+ admin: "admin";
3020
+ }>>;
3021
+ label: z.ZodNullable<z.ZodString>;
3022
+ createdAt: z.ZodISODateTime;
3023
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
3024
+ revokedAt: z.ZodNullable<z.ZodISODateTime>;
3025
+ lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
3026
+ }, z.core.$strip>;
3027
+ type CredentialInfo = z.infer<typeof CredentialInfo>;
2451
3028
 
2452
3029
  /** Prefixes for time-sortable ULID identifiers (ROADMAP §2.3). */
2453
3030
  declare const ID_PREFIX: {
@@ -2461,12 +3038,19 @@ declare const ID_PREFIX: {
2461
3038
  readonly roleBinding: "rol";
2462
3039
  readonly apiKey: "key";
2463
3040
  readonly task: "tsk";
3041
+ readonly token: "tok";
3042
+ readonly audit: "aud";
3043
+ readonly revocation: "rev";
2464
3044
  };
2465
3045
  type IdKind = keyof typeof ID_PREFIX;
2466
3046
  /** Crockford base32 ULID body (26 chars, no I, L, O, U). */
2467
3047
  declare const ULID_PATTERN = "[0-9A-HJKMNP-TV-Z]{26}";
2468
3048
  /** Builds a Zod schema that validates `<prefix>_<ULID>` identifiers. */
2469
3049
  declare const prefixedId: <K extends IdKind>(kind: K) => z.ZodString;
3050
+ declare const TokenId: z.ZodString;
3051
+ declare const AuditId: z.ZodString;
3052
+ declare const RevocationId: z.ZodString;
3053
+ declare const ApiKeyId: z.ZodString;
2470
3054
  declare const NodeId: z.ZodString;
2471
3055
  type NodeId = z.infer<typeof NodeId>;
2472
3056
  declare const OrganizationId: z.ZodString;
@@ -2567,6 +3151,15 @@ declare const MeshSnapshot: z.ZodObject<{
2567
3151
  }>;
2568
3152
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2569
3153
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
3154
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
3155
+ v: z.ZodLiteral<1>;
3156
+ nodeId: z.ZodString;
3157
+ publicKey: z.ZodString;
3158
+ issuedAt: z.ZodISODateTime;
3159
+ expiresAt: z.ZodISODateTime;
3160
+ rootKey: z.ZodString;
3161
+ sig: z.ZodString;
3162
+ }, z.core.$strip>>>;
2570
3163
  }, z.core.$strip>>;
2571
3164
  organizations: z.ZodArray<z.ZodObject<{
2572
3165
  version: z.ZodInt;
@@ -2577,6 +3170,52 @@ declare const MeshSnapshot: z.ZodObject<{
2577
3170
  name: z.ZodString;
2578
3171
  slug: z.ZodString;
2579
3172
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3173
+ policy: z.ZodDefault<z.ZodObject<{
3174
+ inbound: z.ZodDefault<z.ZodObject<{
3175
+ default: z.ZodDefault<z.ZodEnum<{
3176
+ allow: "allow";
3177
+ deny: "deny";
3178
+ }>>;
3179
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3180
+ effect: z.ZodEnum<{
3181
+ allow: "allow";
3182
+ deny: "deny";
3183
+ }>;
3184
+ capability: z.ZodString;
3185
+ organizationId: z.ZodOptional<z.ZodString>;
3186
+ nodeId: z.ZodOptional<z.ZodString>;
3187
+ }, z.core.$strip>>>;
3188
+ }, z.core.$strip>>;
3189
+ outbound: z.ZodDefault<z.ZodObject<{
3190
+ default: z.ZodDefault<z.ZodEnum<{
3191
+ allow: "allow";
3192
+ deny: "deny";
3193
+ }>>;
3194
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3195
+ effect: z.ZodEnum<{
3196
+ allow: "allow";
3197
+ deny: "deny";
3198
+ }>;
3199
+ capability: z.ZodString;
3200
+ organizationId: z.ZodOptional<z.ZodString>;
3201
+ nodeId: z.ZodOptional<z.ZodString>;
3202
+ }, z.core.$strip>>>;
3203
+ }, z.core.$strip>>;
3204
+ tools: z.ZodDefault<z.ZodObject<{
3205
+ default: z.ZodDefault<z.ZodEnum<{
3206
+ allow: "allow";
3207
+ deny: "deny";
3208
+ }>>;
3209
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3210
+ effect: z.ZodEnum<{
3211
+ allow: "allow";
3212
+ deny: "deny";
3213
+ }>;
3214
+ tool: z.ZodString;
3215
+ agentId: z.ZodOptional<z.ZodString>;
3216
+ }, z.core.$strip>>>;
3217
+ }, z.core.$strip>>;
3218
+ }, z.core.$strip>>;
2580
3219
  }, z.core.$strip>>;
2581
3220
  agents: z.ZodArray<z.ZodObject<{
2582
3221
  version: z.ZodInt;
@@ -2664,8 +3303,8 @@ declare const MeshSnapshot: z.ZodObject<{
2664
3303
  }, z.core.$strip>>;
2665
3304
  steps: z.ZodArray<z.ZodObject<{
2666
3305
  name: z.ZodEnum<{
2667
- observe: "observe";
2668
3306
  reason: "reason";
3307
+ observe: "observe";
2669
3308
  act: "act";
2670
3309
  verify: "verify";
2671
3310
  }>;
@@ -2705,6 +3344,15 @@ declare const NodeDetail: z.ZodObject<{
2705
3344
  }>;
2706
3345
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2707
3346
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
3347
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
3348
+ v: z.ZodLiteral<1>;
3349
+ nodeId: z.ZodString;
3350
+ publicKey: z.ZodString;
3351
+ issuedAt: z.ZodISODateTime;
3352
+ expiresAt: z.ZodISODateTime;
3353
+ rootKey: z.ZodString;
3354
+ sig: z.ZodString;
3355
+ }, z.core.$strip>>>;
2708
3356
  }, z.core.$strip>;
2709
3357
  organizations: z.ZodArray<z.ZodObject<{
2710
3358
  version: z.ZodInt;
@@ -2715,6 +3363,52 @@ declare const NodeDetail: z.ZodObject<{
2715
3363
  name: z.ZodString;
2716
3364
  slug: z.ZodString;
2717
3365
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3366
+ policy: z.ZodDefault<z.ZodObject<{
3367
+ inbound: z.ZodDefault<z.ZodObject<{
3368
+ default: z.ZodDefault<z.ZodEnum<{
3369
+ allow: "allow";
3370
+ deny: "deny";
3371
+ }>>;
3372
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3373
+ effect: z.ZodEnum<{
3374
+ allow: "allow";
3375
+ deny: "deny";
3376
+ }>;
3377
+ capability: z.ZodString;
3378
+ organizationId: z.ZodOptional<z.ZodString>;
3379
+ nodeId: z.ZodOptional<z.ZodString>;
3380
+ }, z.core.$strip>>>;
3381
+ }, z.core.$strip>>;
3382
+ outbound: z.ZodDefault<z.ZodObject<{
3383
+ default: z.ZodDefault<z.ZodEnum<{
3384
+ allow: "allow";
3385
+ deny: "deny";
3386
+ }>>;
3387
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3388
+ effect: z.ZodEnum<{
3389
+ allow: "allow";
3390
+ deny: "deny";
3391
+ }>;
3392
+ capability: z.ZodString;
3393
+ organizationId: z.ZodOptional<z.ZodString>;
3394
+ nodeId: z.ZodOptional<z.ZodString>;
3395
+ }, z.core.$strip>>>;
3396
+ }, z.core.$strip>>;
3397
+ tools: z.ZodDefault<z.ZodObject<{
3398
+ default: z.ZodDefault<z.ZodEnum<{
3399
+ allow: "allow";
3400
+ deny: "deny";
3401
+ }>>;
3402
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3403
+ effect: z.ZodEnum<{
3404
+ allow: "allow";
3405
+ deny: "deny";
3406
+ }>;
3407
+ tool: z.ZodString;
3408
+ agentId: z.ZodOptional<z.ZodString>;
3409
+ }, z.core.$strip>>>;
3410
+ }, z.core.$strip>>;
3411
+ }, z.core.$strip>>;
2718
3412
  }, z.core.$strip>>;
2719
3413
  agents: z.ZodArray<z.ZodObject<{
2720
3414
  version: z.ZodInt;
@@ -2776,6 +3470,15 @@ declare const Node: z.ZodObject<{
2776
3470
  }>;
2777
3471
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2778
3472
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
3473
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
3474
+ v: z.ZodLiteral<1>;
3475
+ nodeId: z.ZodString;
3476
+ publicKey: z.ZodString;
3477
+ issuedAt: z.ZodISODateTime;
3478
+ expiresAt: z.ZodISODateTime;
3479
+ rootKey: z.ZodString;
3480
+ sig: z.ZodString;
3481
+ }, z.core.$strip>>>;
2779
3482
  }, z.core.$strip>;
2780
3483
  type Node = z.infer<typeof Node>;
2781
3484
  declare const UpdateNodeRequest: z.ZodObject<{
@@ -2794,6 +3497,52 @@ declare const Organization: z.ZodObject<{
2794
3497
  name: z.ZodString;
2795
3498
  slug: z.ZodString;
2796
3499
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3500
+ policy: z.ZodDefault<z.ZodObject<{
3501
+ inbound: z.ZodDefault<z.ZodObject<{
3502
+ default: z.ZodDefault<z.ZodEnum<{
3503
+ allow: "allow";
3504
+ deny: "deny";
3505
+ }>>;
3506
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3507
+ effect: z.ZodEnum<{
3508
+ allow: "allow";
3509
+ deny: "deny";
3510
+ }>;
3511
+ capability: z.ZodString;
3512
+ organizationId: z.ZodOptional<z.ZodString>;
3513
+ nodeId: z.ZodOptional<z.ZodString>;
3514
+ }, z.core.$strip>>>;
3515
+ }, z.core.$strip>>;
3516
+ outbound: z.ZodDefault<z.ZodObject<{
3517
+ default: z.ZodDefault<z.ZodEnum<{
3518
+ allow: "allow";
3519
+ deny: "deny";
3520
+ }>>;
3521
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3522
+ effect: z.ZodEnum<{
3523
+ allow: "allow";
3524
+ deny: "deny";
3525
+ }>;
3526
+ capability: z.ZodString;
3527
+ organizationId: z.ZodOptional<z.ZodString>;
3528
+ nodeId: z.ZodOptional<z.ZodString>;
3529
+ }, z.core.$strip>>>;
3530
+ }, z.core.$strip>>;
3531
+ tools: z.ZodDefault<z.ZodObject<{
3532
+ default: z.ZodDefault<z.ZodEnum<{
3533
+ allow: "allow";
3534
+ deny: "deny";
3535
+ }>>;
3536
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3537
+ effect: z.ZodEnum<{
3538
+ allow: "allow";
3539
+ deny: "deny";
3540
+ }>;
3541
+ tool: z.ZodString;
3542
+ agentId: z.ZodOptional<z.ZodString>;
3543
+ }, z.core.$strip>>>;
3544
+ }, z.core.$strip>>;
3545
+ }, z.core.$strip>>;
2797
3546
  }, z.core.$strip>;
2798
3547
  type Organization = z.infer<typeof Organization>;
2799
3548
  declare const CreateOrganizationRequest: z.ZodObject<{
@@ -2806,6 +3555,52 @@ type CreateOrganizationRequest = z.infer<typeof CreateOrganizationRequest>;
2806
3555
  declare const UpdateOrganizationRequest: z.ZodObject<{
2807
3556
  name: z.ZodOptional<z.ZodString>;
2808
3557
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3558
+ policy: z.ZodOptional<z.ZodObject<{
3559
+ inbound: z.ZodDefault<z.ZodObject<{
3560
+ default: z.ZodDefault<z.ZodEnum<{
3561
+ allow: "allow";
3562
+ deny: "deny";
3563
+ }>>;
3564
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3565
+ effect: z.ZodEnum<{
3566
+ allow: "allow";
3567
+ deny: "deny";
3568
+ }>;
3569
+ capability: z.ZodString;
3570
+ organizationId: z.ZodOptional<z.ZodString>;
3571
+ nodeId: z.ZodOptional<z.ZodString>;
3572
+ }, z.core.$strip>>>;
3573
+ }, z.core.$strip>>;
3574
+ outbound: z.ZodDefault<z.ZodObject<{
3575
+ default: z.ZodDefault<z.ZodEnum<{
3576
+ allow: "allow";
3577
+ deny: "deny";
3578
+ }>>;
3579
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3580
+ effect: z.ZodEnum<{
3581
+ allow: "allow";
3582
+ deny: "deny";
3583
+ }>;
3584
+ capability: z.ZodString;
3585
+ organizationId: z.ZodOptional<z.ZodString>;
3586
+ nodeId: z.ZodOptional<z.ZodString>;
3587
+ }, z.core.$strip>>>;
3588
+ }, z.core.$strip>>;
3589
+ tools: z.ZodDefault<z.ZodObject<{
3590
+ default: z.ZodDefault<z.ZodEnum<{
3591
+ allow: "allow";
3592
+ deny: "deny";
3593
+ }>>;
3594
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3595
+ effect: z.ZodEnum<{
3596
+ allow: "allow";
3597
+ deny: "deny";
3598
+ }>;
3599
+ tool: z.ZodString;
3600
+ agentId: z.ZodOptional<z.ZodString>;
3601
+ }, z.core.$strip>>>;
3602
+ }, z.core.$strip>>;
3603
+ }, z.core.$strip>>;
2809
3604
  }, z.core.$strip>;
2810
3605
  type UpdateOrganizationRequest = z.infer<typeof UpdateOrganizationRequest>;
2811
3606
 
@@ -2838,8 +3633,8 @@ type TaskAssignee = z.infer<typeof TaskAssignee>;
2838
3633
  /** One stage of the observe → reason → act → verify pipeline (deck slide 05). */
2839
3634
  declare const TaskStep: z.ZodObject<{
2840
3635
  name: z.ZodEnum<{
2841
- observe: "observe";
2842
3636
  reason: "reason";
3637
+ observe: "observe";
2843
3638
  act: "act";
2844
3639
  verify: "verify";
2845
3640
  }>;
@@ -2885,8 +3680,8 @@ declare const Task: z.ZodObject<{
2885
3680
  }, z.core.$strip>>;
2886
3681
  steps: z.ZodArray<z.ZodObject<{
2887
3682
  name: z.ZodEnum<{
2888
- observe: "observe";
2889
3683
  reason: "reason";
3684
+ observe: "observe";
2890
3685
  act: "act";
2891
3686
  verify: "verify";
2892
3687
  }>;
@@ -2913,6 +3708,7 @@ declare const CapabilityProvider: z.ZodObject<{
2913
3708
  organizationName: z.ZodString;
2914
3709
  nodeId: z.ZodString;
2915
3710
  available: z.ZodBoolean;
3711
+ permitted: z.ZodNullable<z.ZodBoolean>;
2916
3712
  }, z.core.$strip>;
2917
3713
  type CapabilityProvider = z.infer<typeof CapabilityProvider>;
2918
3714
 
@@ -2948,6 +3744,118 @@ interface PageOf<T> {
2948
3744
  readonly nextCursor: string | null;
2949
3745
  }
2950
3746
 
3747
+ /**
3748
+ * Organization policies (ADR-0023): declarative rules on who may ask the organization for which capabilities
3749
+ * (`inbound`), whom its agents may ask (`outbound`), and which tools its agents may use (`tools`). A policy is part of
3750
+ * its organization, so it replicates with it and every node evaluates it the same way.
3751
+ *
3752
+ * Evaluation: among the rules that match, a `deny` wins over an `allow`; with no matching rule the section's default
3753
+ * applies. Patterns are an exact name, a dotted prefix ending in `.*` (`terrain.*` matches `terrain.analysis`), or `*`.
3754
+ */
3755
+ declare const Effect: z.ZodEnum<{
3756
+ allow: "allow";
3757
+ deny: "deny";
3758
+ }>;
3759
+ type Effect = z.infer<typeof Effect>;
3760
+ declare const NamePattern: z.ZodString;
3761
+ type NamePattern = z.infer<typeof NamePattern>;
3762
+ /** A capability rule. `organizationId` / `nodeId` name the other side: the requester (inbound) or provider (outbound). */
3763
+ declare const CapabilityRule: z.ZodObject<{
3764
+ effect: z.ZodEnum<{
3765
+ allow: "allow";
3766
+ deny: "deny";
3767
+ }>;
3768
+ capability: z.ZodString;
3769
+ organizationId: z.ZodOptional<z.ZodString>;
3770
+ nodeId: z.ZodOptional<z.ZodString>;
3771
+ }, z.core.$strip>;
3772
+ type CapabilityRule = z.infer<typeof CapabilityRule>;
3773
+ declare const ToolRule: z.ZodObject<{
3774
+ effect: z.ZodEnum<{
3775
+ allow: "allow";
3776
+ deny: "deny";
3777
+ }>;
3778
+ tool: z.ZodString;
3779
+ agentId: z.ZodOptional<z.ZodString>;
3780
+ }, z.core.$strip>;
3781
+ type ToolRule = z.infer<typeof ToolRule>;
3782
+ declare const OrganizationPolicy: z.ZodObject<{
3783
+ inbound: z.ZodDefault<z.ZodObject<{
3784
+ default: z.ZodDefault<z.ZodEnum<{
3785
+ allow: "allow";
3786
+ deny: "deny";
3787
+ }>>;
3788
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3789
+ effect: z.ZodEnum<{
3790
+ allow: "allow";
3791
+ deny: "deny";
3792
+ }>;
3793
+ capability: z.ZodString;
3794
+ organizationId: z.ZodOptional<z.ZodString>;
3795
+ nodeId: z.ZodOptional<z.ZodString>;
3796
+ }, z.core.$strip>>>;
3797
+ }, z.core.$strip>>;
3798
+ outbound: z.ZodDefault<z.ZodObject<{
3799
+ default: z.ZodDefault<z.ZodEnum<{
3800
+ allow: "allow";
3801
+ deny: "deny";
3802
+ }>>;
3803
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3804
+ effect: z.ZodEnum<{
3805
+ allow: "allow";
3806
+ deny: "deny";
3807
+ }>;
3808
+ capability: z.ZodString;
3809
+ organizationId: z.ZodOptional<z.ZodString>;
3810
+ nodeId: z.ZodOptional<z.ZodString>;
3811
+ }, z.core.$strip>>>;
3812
+ }, z.core.$strip>>;
3813
+ tools: z.ZodDefault<z.ZodObject<{
3814
+ default: z.ZodDefault<z.ZodEnum<{
3815
+ allow: "allow";
3816
+ deny: "deny";
3817
+ }>>;
3818
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
3819
+ effect: z.ZodEnum<{
3820
+ allow: "allow";
3821
+ deny: "deny";
3822
+ }>;
3823
+ tool: z.ZodString;
3824
+ agentId: z.ZodOptional<z.ZodString>;
3825
+ }, z.core.$strip>>>;
3826
+ }, z.core.$strip>>;
3827
+ }, z.core.$strip>;
3828
+ type OrganizationPolicy = z.infer<typeof OrganizationPolicy>;
3829
+ /** Allows everything: the policy of every organization until its owners set one. */
3830
+ declare const OPEN_POLICY: OrganizationPolicy;
3831
+ declare function matchesPattern(pattern: string, name: string): boolean;
3832
+ interface PolicyDecision {
3833
+ readonly allowed: boolean;
3834
+ /** The rule that decided, or undefined when the section's default did. */
3835
+ readonly rule: CapabilityRule | ToolRule | undefined;
3836
+ }
3837
+ /** Minimal organization shape the evaluators need (a contracts `Organization` satisfies it). */
3838
+ interface PolicyHolder {
3839
+ readonly id: string;
3840
+ readonly nodeId: string;
3841
+ readonly policy: OrganizationPolicy;
3842
+ }
3843
+ /**
3844
+ * May `requester`'s agents ask `provider` for `capability`? Both sides must agree: the requester's outbound policy and
3845
+ * the provider's inbound policy. Within one organization, policy never applies (internal collaboration).
3846
+ */
3847
+ declare function mayRequest(requester: PolicyHolder, provider: PolicyHolder, capability: string): PolicyDecision;
3848
+ /**
3849
+ * The provider's side alone: does its inbound policy let `requester` ask for `capability`? The assignee's node checks
3850
+ * this again on acceptance — it has the final say over its own organization (ADR-0023).
3851
+ */
3852
+ declare function inboundAllows(provider: PolicyHolder, requester: {
3853
+ readonly organizationId: string;
3854
+ readonly nodeId: string;
3855
+ }, capability: string): PolicyDecision;
3856
+ /** May this agent of the organization use the tool? */
3857
+ declare function mayUseTool(organization: PolicyHolder, agentId: string, tool: string): PolicyDecision;
3858
+
2951
3859
  /** RFC 9457 problem details — every API error uses this shape. */
2952
3860
  declare const ProblemDetails: z.ZodObject<{
2953
3861
  type: z.ZodString;
@@ -2963,6 +3871,29 @@ declare const ProblemDetails: z.ZodObject<{
2963
3871
  }, z.core.$strip>;
2964
3872
  type ProblemDetails = z.infer<typeof ProblemDetails>;
2965
3873
 
3874
+ /** "This node id owns this key until `expiresAt`", signed by the mesh root. */
3875
+ declare const NodeCertificate: z.ZodObject<{
3876
+ v: z.ZodLiteral<1>;
3877
+ nodeId: z.ZodString;
3878
+ publicKey: z.ZodString;
3879
+ issuedAt: z.ZodISODateTime;
3880
+ expiresAt: z.ZodISODateTime;
3881
+ rootKey: z.ZodString;
3882
+ sig: z.ZodString;
3883
+ }, z.core.$strip>;
3884
+ type NodeCertificate = z.infer<typeof NodeCertificate>;
3885
+ /** "Stop trusting this key", signed by the mesh root. */
3886
+ declare const KeyRevocation: z.ZodObject<{
3887
+ v: z.ZodLiteral<1>;
3888
+ publicKey: z.ZodString;
3889
+ nodeId: z.ZodString;
3890
+ revokedAt: z.ZodISODateTime;
3891
+ reason: z.ZodString;
3892
+ rootKey: z.ZodString;
3893
+ sig: z.ZodString;
3894
+ }, z.core.$strip>;
3895
+ type KeyRevocation = z.infer<typeof KeyRevocation>;
3896
+
2966
3897
  /**
2967
3898
  * Translates an event into the state change it implies. The node server's persistence applies these operations
2968
3899
  * atomically with the event append, replication (Phase 5) applies them for remote events, and clients (the SDK's
@@ -2994,6 +3925,14 @@ type ProjectionOp = {
2994
3925
  readonly op: "upsert";
2995
3926
  readonly kind: "task";
2996
3927
  readonly entity: Task;
3928
+ }
3929
+ /** Stored as published; each node decides whether it is genuine against its own mesh root (ADR-0025). */
3930
+ | {
3931
+ readonly op: "upsert";
3932
+ readonly kind: "revocation";
3933
+ readonly entity: KeyRevocation & {
3934
+ readonly id: string;
3935
+ };
2997
3936
  } | {
2998
3937
  readonly op: "delete";
2999
3938
  readonly kind: "node" | "organization" | "agent" | "link" | "roleBinding";
@@ -3025,6 +3964,7 @@ declare const Topic: z.ZodEnum<{
3025
3964
  link: "link";
3026
3965
  roleBinding: "roleBinding";
3027
3966
  task: "task";
3967
+ revocation: "revocation";
3028
3968
  }>;
3029
3969
  type Topic = z.infer<typeof Topic>;
3030
3970
  declare const ClientMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -3038,6 +3978,7 @@ declare const ClientMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3038
3978
  link: "link";
3039
3979
  roleBinding: "roleBinding";
3040
3980
  task: "task";
3981
+ revocation: "revocation";
3041
3982
  }>>>;
3042
3983
  }, z.core.$strip>, z.ZodObject<{
3043
3984
  type: z.ZodLiteral<"subscribe">;
@@ -3048,6 +3989,7 @@ declare const ClientMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3048
3989
  link: "link";
3049
3990
  roleBinding: "roleBinding";
3050
3991
  task: "task";
3992
+ revocation: "revocation";
3051
3993
  }>>;
3052
3994
  }, z.core.$strip>], "type">;
3053
3995
  type ClientMessage = z.infer<typeof ClientMessage>;
@@ -3091,6 +4033,15 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3091
4033
  }>;
3092
4034
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3093
4035
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
4036
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
4037
+ v: z.ZodLiteral<1>;
4038
+ nodeId: z.ZodString;
4039
+ publicKey: z.ZodString;
4040
+ issuedAt: z.ZodISODateTime;
4041
+ expiresAt: z.ZodISODateTime;
4042
+ rootKey: z.ZodString;
4043
+ sig: z.ZodString;
4044
+ }, z.core.$strip>>>;
3094
4045
  }, z.core.$strip>;
3095
4046
  }, z.core.$strip>;
3096
4047
  }, z.core.$strip>, z.ZodObject<{
@@ -3116,6 +4067,15 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3116
4067
  }>;
3117
4068
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3118
4069
  lastSeenAt: z.ZodNullable<z.ZodISODateTime>;
4070
+ certificate: z.ZodDefault<z.ZodNullable<z.ZodObject<{
4071
+ v: z.ZodLiteral<1>;
4072
+ nodeId: z.ZodString;
4073
+ publicKey: z.ZodString;
4074
+ issuedAt: z.ZodISODateTime;
4075
+ expiresAt: z.ZodISODateTime;
4076
+ rootKey: z.ZodString;
4077
+ sig: z.ZodString;
4078
+ }, z.core.$strip>>>;
3119
4079
  }, z.core.$strip>;
3120
4080
  }, z.core.$strip>;
3121
4081
  }, z.core.$strip>, z.ZodObject<{
@@ -3177,6 +4137,52 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3177
4137
  name: z.ZodString;
3178
4138
  slug: z.ZodString;
3179
4139
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4140
+ policy: z.ZodDefault<z.ZodObject<{
4141
+ inbound: z.ZodDefault<z.ZodObject<{
4142
+ default: z.ZodDefault<z.ZodEnum<{
4143
+ allow: "allow";
4144
+ deny: "deny";
4145
+ }>>;
4146
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
4147
+ effect: z.ZodEnum<{
4148
+ allow: "allow";
4149
+ deny: "deny";
4150
+ }>;
4151
+ capability: z.ZodString;
4152
+ organizationId: z.ZodOptional<z.ZodString>;
4153
+ nodeId: z.ZodOptional<z.ZodString>;
4154
+ }, z.core.$strip>>>;
4155
+ }, z.core.$strip>>;
4156
+ outbound: z.ZodDefault<z.ZodObject<{
4157
+ default: z.ZodDefault<z.ZodEnum<{
4158
+ allow: "allow";
4159
+ deny: "deny";
4160
+ }>>;
4161
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
4162
+ effect: z.ZodEnum<{
4163
+ allow: "allow";
4164
+ deny: "deny";
4165
+ }>;
4166
+ capability: z.ZodString;
4167
+ organizationId: z.ZodOptional<z.ZodString>;
4168
+ nodeId: z.ZodOptional<z.ZodString>;
4169
+ }, z.core.$strip>>>;
4170
+ }, z.core.$strip>>;
4171
+ tools: z.ZodDefault<z.ZodObject<{
4172
+ default: z.ZodDefault<z.ZodEnum<{
4173
+ allow: "allow";
4174
+ deny: "deny";
4175
+ }>>;
4176
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
4177
+ effect: z.ZodEnum<{
4178
+ allow: "allow";
4179
+ deny: "deny";
4180
+ }>;
4181
+ tool: z.ZodString;
4182
+ agentId: z.ZodOptional<z.ZodString>;
4183
+ }, z.core.$strip>>>;
4184
+ }, z.core.$strip>>;
4185
+ }, z.core.$strip>>;
3180
4186
  }, z.core.$strip>;
3181
4187
  }, z.core.$strip>;
3182
4188
  }, z.core.$strip>, z.ZodObject<{
@@ -3196,6 +4202,52 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3196
4202
  name: z.ZodString;
3197
4203
  slug: z.ZodString;
3198
4204
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4205
+ policy: z.ZodDefault<z.ZodObject<{
4206
+ inbound: z.ZodDefault<z.ZodObject<{
4207
+ default: z.ZodDefault<z.ZodEnum<{
4208
+ allow: "allow";
4209
+ deny: "deny";
4210
+ }>>;
4211
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
4212
+ effect: z.ZodEnum<{
4213
+ allow: "allow";
4214
+ deny: "deny";
4215
+ }>;
4216
+ capability: z.ZodString;
4217
+ organizationId: z.ZodOptional<z.ZodString>;
4218
+ nodeId: z.ZodOptional<z.ZodString>;
4219
+ }, z.core.$strip>>>;
4220
+ }, z.core.$strip>>;
4221
+ outbound: z.ZodDefault<z.ZodObject<{
4222
+ default: z.ZodDefault<z.ZodEnum<{
4223
+ allow: "allow";
4224
+ deny: "deny";
4225
+ }>>;
4226
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
4227
+ effect: z.ZodEnum<{
4228
+ allow: "allow";
4229
+ deny: "deny";
4230
+ }>;
4231
+ capability: z.ZodString;
4232
+ organizationId: z.ZodOptional<z.ZodString>;
4233
+ nodeId: z.ZodOptional<z.ZodString>;
4234
+ }, z.core.$strip>>>;
4235
+ }, z.core.$strip>>;
4236
+ tools: z.ZodDefault<z.ZodObject<{
4237
+ default: z.ZodDefault<z.ZodEnum<{
4238
+ allow: "allow";
4239
+ deny: "deny";
4240
+ }>>;
4241
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
4242
+ effect: z.ZodEnum<{
4243
+ allow: "allow";
4244
+ deny: "deny";
4245
+ }>;
4246
+ tool: z.ZodString;
4247
+ agentId: z.ZodOptional<z.ZodString>;
4248
+ }, z.core.$strip>>>;
4249
+ }, z.core.$strip>>;
4250
+ }, z.core.$strip>>;
3199
4251
  }, z.core.$strip>;
3200
4252
  }, z.core.$strip>;
3201
4253
  }, z.core.$strip>, z.ZodObject<{
@@ -3526,6 +4578,9 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3526
4578
  role: z.ZodEnum<{
3527
4579
  node_owner: "node_owner";
3528
4580
  org_owner: "org_owner";
4581
+ viewer: "viewer";
4582
+ auditor: "auditor";
4583
+ agent_operator: "agent_operator";
3529
4584
  }>;
3530
4585
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
3531
4586
  type: z.ZodLiteral<"node">;
@@ -3552,6 +4607,9 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3552
4607
  role: z.ZodEnum<{
3553
4608
  node_owner: "node_owner";
3554
4609
  org_owner: "org_owner";
4610
+ viewer: "viewer";
4611
+ auditor: "auditor";
4612
+ agent_operator: "agent_operator";
3555
4613
  }>;
3556
4614
  scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
3557
4615
  type: z.ZodLiteral<"node">;
@@ -3605,8 +4663,8 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3605
4663
  }, z.core.$strip>>;
3606
4664
  steps: z.ZodArray<z.ZodObject<{
3607
4665
  name: z.ZodEnum<{
3608
- observe: "observe";
3609
4666
  reason: "reason";
4667
+ observe: "observe";
3610
4668
  act: "act";
3611
4669
  verify: "verify";
3612
4670
  }>;
@@ -3660,8 +4718,8 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3660
4718
  }, z.core.$strip>>;
3661
4719
  steps: z.ZodArray<z.ZodObject<{
3662
4720
  name: z.ZodEnum<{
3663
- observe: "observe";
3664
4721
  reason: "reason";
4722
+ observe: "observe";
3665
4723
  act: "act";
3666
4724
  verify: "verify";
3667
4725
  }>;
@@ -3715,8 +4773,8 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3715
4773
  }, z.core.$strip>>;
3716
4774
  steps: z.ZodArray<z.ZodObject<{
3717
4775
  name: z.ZodEnum<{
3718
- observe: "observe";
3719
4776
  reason: "reason";
4777
+ observe: "observe";
3720
4778
  act: "act";
3721
4779
  verify: "verify";
3722
4780
  }>;
@@ -3770,8 +4828,8 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3770
4828
  }, z.core.$strip>>;
3771
4829
  steps: z.ZodArray<z.ZodObject<{
3772
4830
  name: z.ZodEnum<{
3773
- observe: "observe";
3774
4831
  reason: "reason";
4832
+ observe: "observe";
3775
4833
  act: "act";
3776
4834
  verify: "verify";
3777
4835
  }>;
@@ -3784,6 +4842,24 @@ declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
3784
4842
  updatedAt: z.ZodISODateTime;
3785
4843
  }, z.core.$strip>;
3786
4844
  }, z.core.$strip>;
4845
+ }, z.core.$strip>, z.ZodObject<{
4846
+ type: z.ZodLiteral<"mesh.key_revoked">;
4847
+ subject: z.ZodObject<{
4848
+ kind: z.ZodLiteral<"revocation">;
4849
+ id: z.ZodString;
4850
+ version: z.ZodInt;
4851
+ }, z.core.$strip>;
4852
+ payload: z.ZodObject<{
4853
+ revocation: z.ZodObject<{
4854
+ v: z.ZodLiteral<1>;
4855
+ publicKey: z.ZodString;
4856
+ nodeId: z.ZodString;
4857
+ revokedAt: z.ZodISODateTime;
4858
+ reason: z.ZodString;
4859
+ rootKey: z.ZodString;
4860
+ sig: z.ZodString;
4861
+ }, z.core.$strip>;
4862
+ }, z.core.$strip>;
3787
4863
  }, z.core.$strip>], "type">>;
3788
4864
  }, z.core.$strip>, z.ZodObject<{
3789
4865
  type: z.ZodLiteral<"resync.required">;
@@ -3800,10 +4876,33 @@ declare const RealtimeCloseCode: {
3800
4876
  readonly goingAway: 1001;
3801
4877
  readonly badMessage: 4400;
3802
4878
  readonly unauthenticated: 4401;
4879
+ /** Authenticated, but without a role on this node (ADR-0022). */
4880
+ readonly forbidden: 4403;
3803
4881
  readonly helloTimeout: 4408;
3804
4882
  readonly resyncRequired: 4409;
3805
4883
  };
3806
4884
 
4885
+ /**
4886
+ * Who may commit an event (ADR-0021): the single writer of the entity it creates or changes (ADR-0004), read from the
4887
+ * event itself so every replica — server or client — decides the same way without extra state.
4888
+ *
4889
+ * - Creations and updates come only from the owning node: a node for itself, an organization's or agent's node, the
4890
+ * lower node id for links (ADR-0017), the scope's node for role grants, and for tasks the requester's node
4891
+ * (`task.requested`) then the assignee's node (ADR-0020).
4892
+ * - Removals may come from any node: forgetting an offline node (ADR-0017) removes its organizations, agents, links
4893
+ * and bindings under the forgetting node's signature. Revocable trust for that comes with mesh-root certificates.
4894
+ * - Presence observations (`node.status_changed`) are each node's own and never applied by replicas (ADR-0018).
4895
+ */
4896
+ type Writers = {
4897
+ readonly kind: "owner";
4898
+ readonly nodeIds: readonly string[];
4899
+ } | {
4900
+ readonly kind: "any";
4901
+ };
4902
+ declare function writersOf(event: DomainEvent): Writers;
4903
+ /** True when `originNodeId` may have committed `event`. Events that fail are kept in the log but never applied. */
4904
+ declare function isAuthorizedWriter(event: DomainEvent, originNodeId: string): boolean;
4905
+
3807
4906
  /** A static credential, or a function for callers that refresh tokens. */
3808
4907
  type TokenSource = string | (() => string | Promise<string>);
3809
4908
 
@@ -3967,7 +5066,7 @@ declare function createMeshClient(options: MeshClientOptions): {
3967
5066
  roles: {
3968
5067
  id: string;
3969
5068
  principalId: string;
3970
- role: "node_owner" | "org_owner";
5069
+ role: "node_owner" | "org_owner" | "viewer" | "auditor" | "agent_operator";
3971
5070
  scope: {
3972
5071
  type: "node";
3973
5072
  nodeId: string;
@@ -3978,6 +5077,7 @@ declare function createMeshClient(options: MeshClientOptions): {
3978
5077
  };
3979
5078
  createdAt: string;
3980
5079
  }[];
5080
+ scopes: ("read" | "write" | "admin")[];
3981
5081
  }>;
3982
5082
  snapshot: () => Promise<{
3983
5083
  nodes: {
@@ -3991,6 +5091,15 @@ declare function createMeshClient(options: MeshClientOptions): {
3991
5091
  status: "online" | "degraded" | "offline";
3992
5092
  metadata: Record<string, unknown>;
3993
5093
  lastSeenAt: string | null;
5094
+ certificate: {
5095
+ v: 1;
5096
+ nodeId: string;
5097
+ publicKey: string;
5098
+ issuedAt: string;
5099
+ expiresAt: string;
5100
+ rootKey: string;
5101
+ sig: string;
5102
+ } | null;
3994
5103
  }[];
3995
5104
  organizations: {
3996
5105
  version: number;
@@ -4001,6 +5110,34 @@ declare function createMeshClient(options: MeshClientOptions): {
4001
5110
  name: string;
4002
5111
  slug: string;
4003
5112
  metadata: Record<string, unknown>;
5113
+ policy: {
5114
+ inbound: {
5115
+ default: "allow" | "deny";
5116
+ rules: {
5117
+ effect: "allow" | "deny";
5118
+ capability: string;
5119
+ organizationId?: string | undefined;
5120
+ nodeId?: string | undefined;
5121
+ }[];
5122
+ };
5123
+ outbound: {
5124
+ default: "allow" | "deny";
5125
+ rules: {
5126
+ effect: "allow" | "deny";
5127
+ capability: string;
5128
+ organizationId?: string | undefined;
5129
+ nodeId?: string | undefined;
5130
+ }[];
5131
+ };
5132
+ tools: {
5133
+ default: "allow" | "deny";
5134
+ rules: {
5135
+ effect: "allow" | "deny";
5136
+ tool: string;
5137
+ agentId?: string | undefined;
5138
+ }[];
5139
+ };
5140
+ };
4004
5141
  }[];
4005
5142
  agents: {
4006
5143
  version: number;
@@ -4062,7 +5199,7 @@ declare function createMeshClient(options: MeshClientOptions): {
4062
5199
  message: string;
4063
5200
  } | null;
4064
5201
  steps: {
4065
- name: "observe" | "reason" | "act" | "verify";
5202
+ name: "reason" | "observe" | "act" | "verify";
4066
5203
  at: string;
4067
5204
  summary: string;
4068
5205
  }[];
@@ -4083,7 +5220,21 @@ declare function createMeshClient(options: MeshClientOptions): {
4083
5220
  }>;
4084
5221
  capabilities: (search?: string) => Promise<Capability[]>;
4085
5222
  /** Agents offering a capability, available ones first (ADR-0020). */
4086
- capabilityProviders: (name: string) => Promise<CapabilityProvider[]>;
5223
+ revocations: {
5224
+ /** Revocations published to the mesh, each with whether it holds under the node's root (ADR-0025). */
5225
+ list: () => Promise<(KeyRevocation & {
5226
+ id: string;
5227
+ effective: boolean;
5228
+ })[]>;
5229
+ /** Publishes a root-signed revocation through this node (node owners). */
5230
+ publish: (revocation: KeyRevocation) => Promise<{
5231
+ id: string;
5232
+ }>;
5233
+ };
5234
+ /** With `forAgent`, each provider also says whether policy lets that agent ask it (ADR-0023). */
5235
+ capabilityProviders: (name: string, options?: {
5236
+ forAgent?: string;
5237
+ }) => Promise<CapabilityProvider[]>;
4087
5238
  principals: {
4088
5239
  /** Node owners only. The credential is returned exactly once. */
4089
5240
  create: (input: {
@@ -4106,6 +5257,74 @@ declare function createMeshClient(options: MeshClientOptions): {
4106
5257
  apiKey: string;
4107
5258
  };
4108
5259
  }>;
5260
+ /** This node's principals (node owners only). */
5261
+ list: () => Promise<Principal[]>;
5262
+ /** Deletes a principal and its credentials; revoke its roles first (node owners only). */
5263
+ remove: (principalId: string) => Promise<void>;
5264
+ /**
5265
+ * Issues a bearer token with scopes and an expiry (ADR-0022): for yourself, never with more scopes than the
5266
+ * credential you use, or — node owners — for anyone. The token is returned exactly once.
5267
+ */
5268
+ issueToken: (principalId: string, input?: IssueTokenRequestInput, options?: CreateOptions) => Promise<{
5269
+ id: string;
5270
+ token: string;
5271
+ scopes: ("read" | "write" | "admin")[];
5272
+ expiresAt: string;
5273
+ }>;
5274
+ /** A principal's tokens and API keys, metadata only (yourself, or node owners for anyone). */
5275
+ credentials: (principalId: string) => Promise<CredentialInfo[]>;
5276
+ /** Revokes every credential of the principal, including the one this client may be using. */
5277
+ revokeAllCredentials: (principalId: string) => Promise<void>;
5278
+ };
5279
+ credentials: {
5280
+ /** Revokes one token (`tok_…`) or API key (`key_…`). */
5281
+ revoke: (credentialId: string) => Promise<void>;
5282
+ };
5283
+ audit: {
5284
+ /** Newest first; page backwards with `before` (node owners and auditors; ADR-0024). */
5285
+ list: (filter?: {
5286
+ before?: number;
5287
+ limit?: number;
5288
+ kind?: AuditKind;
5289
+ outcome?: AuditOutcome;
5290
+ principalId?: string;
5291
+ action?: string;
5292
+ }) => Promise<{
5293
+ items: AuditEntry[];
5294
+ nextBefore: number | null;
5295
+ }>;
5296
+ /** Recomputes the whole chain on the node: gaps, hashes and signatures. */
5297
+ verify: () => Promise<{
5298
+ valid: boolean;
5299
+ entries: number;
5300
+ brokenAt: number | null;
5301
+ reason: string | null;
5302
+ publicKey: string;
5303
+ }>;
5304
+ };
5305
+ roles: {
5306
+ /** A principal's bindings, or those of a node or organization; by default this node's and its organizations'. */
5307
+ list: (filter?: {
5308
+ principalId?: string;
5309
+ nodeId?: string;
5310
+ organizationId?: string;
5311
+ }) => Promise<RoleBinding[]>;
5312
+ /** Grants node_owner, viewer or auditor on a node, or org_owner or agent_operator on an organization. */
5313
+ grant: (request: GrantRoleRequest, options?: CreateOptions) => Promise<{
5314
+ id: string;
5315
+ principalId: string;
5316
+ role: "node_owner" | "org_owner" | "viewer" | "auditor" | "agent_operator";
5317
+ scope: {
5318
+ type: "node";
5319
+ nodeId: string;
5320
+ } | {
5321
+ type: "organization";
5322
+ organizationId: string;
5323
+ nodeId: string;
5324
+ };
5325
+ createdAt: string;
5326
+ }>;
5327
+ revoke: (bindingId: string) => Promise<void>;
4109
5328
  };
4110
5329
  nodes: {
4111
5330
  list: (page?: PageParams) => Promise<PageOf<{
@@ -4119,6 +5338,15 @@ declare function createMeshClient(options: MeshClientOptions): {
4119
5338
  status: "online" | "degraded" | "offline";
4120
5339
  metadata: Record<string, unknown>;
4121
5340
  lastSeenAt: string | null;
5341
+ certificate: {
5342
+ v: 1;
5343
+ nodeId: string;
5344
+ publicKey: string;
5345
+ issuedAt: string;
5346
+ expiresAt: string;
5347
+ rootKey: string;
5348
+ sig: string;
5349
+ } | null;
4122
5350
  }>>;
4123
5351
  all: () => AsyncGenerator<{
4124
5352
  version: number;
@@ -4131,6 +5359,15 @@ declare function createMeshClient(options: MeshClientOptions): {
4131
5359
  status: "online" | "degraded" | "offline";
4132
5360
  metadata: Record<string, unknown>;
4133
5361
  lastSeenAt: string | null;
5362
+ certificate: {
5363
+ v: 1;
5364
+ nodeId: string;
5365
+ publicKey: string;
5366
+ issuedAt: string;
5367
+ expiresAt: string;
5368
+ rootKey: string;
5369
+ sig: string;
5370
+ } | null;
4134
5371
  }, any, any>;
4135
5372
  get: (nodeId: string) => Promise<{
4136
5373
  version: number;
@@ -4143,6 +5380,15 @@ declare function createMeshClient(options: MeshClientOptions): {
4143
5380
  status: "online" | "degraded" | "offline";
4144
5381
  metadata: Record<string, unknown>;
4145
5382
  lastSeenAt: string | null;
5383
+ certificate: {
5384
+ v: 1;
5385
+ nodeId: string;
5386
+ publicKey: string;
5387
+ issuedAt: string;
5388
+ expiresAt: string;
5389
+ rootKey: string;
5390
+ sig: string;
5391
+ } | null;
4146
5392
  }>;
4147
5393
  detail: (nodeId: string) => Promise<{
4148
5394
  node: {
@@ -4156,6 +5402,15 @@ declare function createMeshClient(options: MeshClientOptions): {
4156
5402
  status: "online" | "degraded" | "offline";
4157
5403
  metadata: Record<string, unknown>;
4158
5404
  lastSeenAt: string | null;
5405
+ certificate: {
5406
+ v: 1;
5407
+ nodeId: string;
5408
+ publicKey: string;
5409
+ issuedAt: string;
5410
+ expiresAt: string;
5411
+ rootKey: string;
5412
+ sig: string;
5413
+ } | null;
4159
5414
  };
4160
5415
  organizations: {
4161
5416
  version: number;
@@ -4166,6 +5421,34 @@ declare function createMeshClient(options: MeshClientOptions): {
4166
5421
  name: string;
4167
5422
  slug: string;
4168
5423
  metadata: Record<string, unknown>;
5424
+ policy: {
5425
+ inbound: {
5426
+ default: "allow" | "deny";
5427
+ rules: {
5428
+ effect: "allow" | "deny";
5429
+ capability: string;
5430
+ organizationId?: string | undefined;
5431
+ nodeId?: string | undefined;
5432
+ }[];
5433
+ };
5434
+ outbound: {
5435
+ default: "allow" | "deny";
5436
+ rules: {
5437
+ effect: "allow" | "deny";
5438
+ capability: string;
5439
+ organizationId?: string | undefined;
5440
+ nodeId?: string | undefined;
5441
+ }[];
5442
+ };
5443
+ tools: {
5444
+ default: "allow" | "deny";
5445
+ rules: {
5446
+ effect: "allow" | "deny";
5447
+ tool: string;
5448
+ agentId?: string | undefined;
5449
+ }[];
5450
+ };
5451
+ };
4169
5452
  }[];
4170
5453
  agents: {
4171
5454
  version: number;
@@ -4200,6 +5483,34 @@ declare function createMeshClient(options: MeshClientOptions): {
4200
5483
  name: string;
4201
5484
  slug: string;
4202
5485
  metadata: Record<string, unknown>;
5486
+ policy: {
5487
+ inbound: {
5488
+ default: "allow" | "deny";
5489
+ rules: {
5490
+ effect: "allow" | "deny";
5491
+ capability: string;
5492
+ organizationId?: string | undefined;
5493
+ nodeId?: string | undefined;
5494
+ }[];
5495
+ };
5496
+ outbound: {
5497
+ default: "allow" | "deny";
5498
+ rules: {
5499
+ effect: "allow" | "deny";
5500
+ capability: string;
5501
+ organizationId?: string | undefined;
5502
+ nodeId?: string | undefined;
5503
+ }[];
5504
+ };
5505
+ tools: {
5506
+ default: "allow" | "deny";
5507
+ rules: {
5508
+ effect: "allow" | "deny";
5509
+ tool: string;
5510
+ agentId?: string | undefined;
5511
+ }[];
5512
+ };
5513
+ };
4203
5514
  }>>;
4204
5515
  update: (nodeId: string, changes: UpdateNodeRequest, options?: WriteOptions) => Promise<{
4205
5516
  version: number;
@@ -4212,6 +5523,15 @@ declare function createMeshClient(options: MeshClientOptions): {
4212
5523
  status: "online" | "degraded" | "offline";
4213
5524
  metadata: Record<string, unknown>;
4214
5525
  lastSeenAt: string | null;
5526
+ certificate: {
5527
+ v: 1;
5528
+ nodeId: string;
5529
+ publicKey: string;
5530
+ issuedAt: string;
5531
+ expiresAt: string;
5532
+ rootKey: string;
5533
+ sig: string;
5534
+ } | null;
4215
5535
  }>;
4216
5536
  /** Removes the node and, children first, everything on it. */
4217
5537
  remove: (nodeId: string, options?: WriteOptions) => Promise<void>;
@@ -4220,7 +5540,7 @@ declare function createMeshClient(options: MeshClientOptions): {
4220
5540
  grant: (principalId: string, options?: CreateOptions) => Promise<{
4221
5541
  id: string;
4222
5542
  principalId: string;
4223
- role: "node_owner" | "org_owner";
5543
+ role: "node_owner" | "org_owner" | "viewer" | "auditor" | "agent_operator";
4224
5544
  scope: {
4225
5545
  type: "node";
4226
5546
  nodeId: string;
@@ -4260,6 +5580,34 @@ declare function createMeshClient(options: MeshClientOptions): {
4260
5580
  name: string;
4261
5581
  slug: string;
4262
5582
  metadata: Record<string, unknown>;
5583
+ policy: {
5584
+ inbound: {
5585
+ default: "allow" | "deny";
5586
+ rules: {
5587
+ effect: "allow" | "deny";
5588
+ capability: string;
5589
+ organizationId?: string | undefined;
5590
+ nodeId?: string | undefined;
5591
+ }[];
5592
+ };
5593
+ outbound: {
5594
+ default: "allow" | "deny";
5595
+ rules: {
5596
+ effect: "allow" | "deny";
5597
+ capability: string;
5598
+ organizationId?: string | undefined;
5599
+ nodeId?: string | undefined;
5600
+ }[];
5601
+ };
5602
+ tools: {
5603
+ default: "allow" | "deny";
5604
+ rules: {
5605
+ effect: "allow" | "deny";
5606
+ tool: string;
5607
+ agentId?: string | undefined;
5608
+ }[];
5609
+ };
5610
+ };
4263
5611
  }>;
4264
5612
  list: (filter?: PageParams & {
4265
5613
  nodeId?: string | undefined;
@@ -4272,6 +5620,34 @@ declare function createMeshClient(options: MeshClientOptions): {
4272
5620
  name: string;
4273
5621
  slug: string;
4274
5622
  metadata: Record<string, unknown>;
5623
+ policy: {
5624
+ inbound: {
5625
+ default: "allow" | "deny";
5626
+ rules: {
5627
+ effect: "allow" | "deny";
5628
+ capability: string;
5629
+ organizationId?: string | undefined;
5630
+ nodeId?: string | undefined;
5631
+ }[];
5632
+ };
5633
+ outbound: {
5634
+ default: "allow" | "deny";
5635
+ rules: {
5636
+ effect: "allow" | "deny";
5637
+ capability: string;
5638
+ organizationId?: string | undefined;
5639
+ nodeId?: string | undefined;
5640
+ }[];
5641
+ };
5642
+ tools: {
5643
+ default: "allow" | "deny";
5644
+ rules: {
5645
+ effect: "allow" | "deny";
5646
+ tool: string;
5647
+ agentId?: string | undefined;
5648
+ }[];
5649
+ };
5650
+ };
4275
5651
  }>>;
4276
5652
  all: (filter?: {
4277
5653
  nodeId?: string | undefined;
@@ -4284,6 +5660,34 @@ declare function createMeshClient(options: MeshClientOptions): {
4284
5660
  name: string;
4285
5661
  slug: string;
4286
5662
  metadata: Record<string, unknown>;
5663
+ policy: {
5664
+ inbound: {
5665
+ default: "allow" | "deny";
5666
+ rules: {
5667
+ effect: "allow" | "deny";
5668
+ capability: string;
5669
+ organizationId?: string | undefined;
5670
+ nodeId?: string | undefined;
5671
+ }[];
5672
+ };
5673
+ outbound: {
5674
+ default: "allow" | "deny";
5675
+ rules: {
5676
+ effect: "allow" | "deny";
5677
+ capability: string;
5678
+ organizationId?: string | undefined;
5679
+ nodeId?: string | undefined;
5680
+ }[];
5681
+ };
5682
+ tools: {
5683
+ default: "allow" | "deny";
5684
+ rules: {
5685
+ effect: "allow" | "deny";
5686
+ tool: string;
5687
+ agentId?: string | undefined;
5688
+ }[];
5689
+ };
5690
+ };
4287
5691
  }, any, any>;
4288
5692
  get: (organizationId: string) => Promise<{
4289
5693
  version: number;
@@ -4294,6 +5698,34 @@ declare function createMeshClient(options: MeshClientOptions): {
4294
5698
  name: string;
4295
5699
  slug: string;
4296
5700
  metadata: Record<string, unknown>;
5701
+ policy: {
5702
+ inbound: {
5703
+ default: "allow" | "deny";
5704
+ rules: {
5705
+ effect: "allow" | "deny";
5706
+ capability: string;
5707
+ organizationId?: string | undefined;
5708
+ nodeId?: string | undefined;
5709
+ }[];
5710
+ };
5711
+ outbound: {
5712
+ default: "allow" | "deny";
5713
+ rules: {
5714
+ effect: "allow" | "deny";
5715
+ capability: string;
5716
+ organizationId?: string | undefined;
5717
+ nodeId?: string | undefined;
5718
+ }[];
5719
+ };
5720
+ tools: {
5721
+ default: "allow" | "deny";
5722
+ rules: {
5723
+ effect: "allow" | "deny";
5724
+ tool: string;
5725
+ agentId?: string | undefined;
5726
+ }[];
5727
+ };
5728
+ };
4297
5729
  }>;
4298
5730
  update: (organizationId: string, changes: UpdateOrganizationRequest, options?: WriteOptions) => Promise<{
4299
5731
  version: number;
@@ -4304,6 +5736,34 @@ declare function createMeshClient(options: MeshClientOptions): {
4304
5736
  name: string;
4305
5737
  slug: string;
4306
5738
  metadata: Record<string, unknown>;
5739
+ policy: {
5740
+ inbound: {
5741
+ default: "allow" | "deny";
5742
+ rules: {
5743
+ effect: "allow" | "deny";
5744
+ capability: string;
5745
+ organizationId?: string | undefined;
5746
+ nodeId?: string | undefined;
5747
+ }[];
5748
+ };
5749
+ outbound: {
5750
+ default: "allow" | "deny";
5751
+ rules: {
5752
+ effect: "allow" | "deny";
5753
+ capability: string;
5754
+ organizationId?: string | undefined;
5755
+ nodeId?: string | undefined;
5756
+ }[];
5757
+ };
5758
+ tools: {
5759
+ default: "allow" | "deny";
5760
+ rules: {
5761
+ effect: "allow" | "deny";
5762
+ tool: string;
5763
+ agentId?: string | undefined;
5764
+ }[];
5765
+ };
5766
+ };
4307
5767
  }>;
4308
5768
  /** Removes the organization and all of its agents. */
4309
5769
  remove: (organizationId: string, options?: WriteOptions) => Promise<void>;
@@ -4312,7 +5772,7 @@ declare function createMeshClient(options: MeshClientOptions): {
4312
5772
  grant: (principalId: string, options?: CreateOptions) => Promise<{
4313
5773
  id: string;
4314
5774
  principalId: string;
4315
- role: "node_owner" | "org_owner";
5775
+ role: "node_owner" | "org_owner" | "viewer" | "auditor" | "agent_operator";
4316
5776
  scope: {
4317
5777
  type: "node";
4318
5778
  nodeId: string;
@@ -4489,7 +5949,7 @@ declare function createMeshClient(options: MeshClientOptions): {
4489
5949
  message: string;
4490
5950
  } | null;
4491
5951
  steps: {
4492
- name: "observe" | "reason" | "act" | "verify";
5952
+ name: "reason" | "observe" | "act" | "verify";
4493
5953
  at: string;
4494
5954
  summary: string;
4495
5955
  }[];
@@ -4526,7 +5986,7 @@ declare function createMeshClient(options: MeshClientOptions): {
4526
5986
  message: string;
4527
5987
  } | null;
4528
5988
  steps: {
4529
- name: "observe" | "reason" | "act" | "verify";
5989
+ name: "reason" | "observe" | "act" | "verify";
4530
5990
  at: string;
4531
5991
  summary: string;
4532
5992
  }[];
@@ -4562,7 +6022,7 @@ declare function createMeshClient(options: MeshClientOptions): {
4562
6022
  message: string;
4563
6023
  } | null;
4564
6024
  steps: {
4565
- name: "observe" | "reason" | "act" | "verify";
6025
+ name: "reason" | "observe" | "act" | "verify";
4566
6026
  at: string;
4567
6027
  summary: string;
4568
6028
  }[];
@@ -4598,7 +6058,7 @@ declare function createMeshClient(options: MeshClientOptions): {
4598
6058
  message: string;
4599
6059
  } | null;
4600
6060
  steps: {
4601
- name: "observe" | "reason" | "act" | "verify";
6061
+ name: "reason" | "observe" | "act" | "verify";
4602
6062
  at: string;
4603
6063
  summary: string;
4604
6064
  }[];
@@ -4629,4 +6089,4 @@ declare class MeshApiError extends Error {
4629
6089
  get code(): string;
4630
6090
  }
4631
6091
 
4632
- export { Agent, AgentCreated, type AgentFilter, AgentId, AgentKind, AgentRemoved, AgentStatus, AgentStatusChanged, AgentUpdated, Capability, CapabilityName, CapabilityProvider, ClientMessage, CommandId, CreateAgentRequest, type CreateAgentRequestInput, CreateLinkRequest, type CreateOptions, CreateOrganizationRequest, CreatePrincipalRequest, CreatePrincipalResponse, Credential, DOMAIN_EVENT_TYPES, DisplayName, DomainEvent, type DomainEventOf, type DomainEventType, ENVELOPE_VERSION, EntityAudit, EnvelopeMeta, EventId, GrantOwnerRequest, HealthResponse, ID_PREFIX, type IdKind, Link, LinkDown, LinkId, LinkQuality, LinkRemoved, LinkRequested, LinkState, LinkUp, LinkUpdated, Me, MeshAgentAgentDeregistered, MeshAgentAgentRegistered, MeshApiError, type MeshClient, type MeshClientOptions, MeshCursor, MeshEvent, MeshRealtime, MeshSnapshot, type MeshState, MeshStats, Metadata, Node, NodeCreated, NodeDetail, NodeHeartbeat, NodeId, NodeRemoved, NodeStatus, NodeStatusChanged, NodeUpdated, Organization, OrganizationCreated, OrganizationId, OrganizationRemoved, OrganizationUpdated, Page, type PageOf, type PageParams, PageQuery, Principal, PrincipalId, PrincipalKind, ProblemDetails, type ProjectionOp, RealtimeCloseCode, RealtimeError, type RealtimeOptions, type RealtimeStatus, RequestTaskRequest, type RequestTaskRequestInput, Role, RoleBinding, RoleBindingId, RoleGranted, RoleRevoked, RoleScope, ServerMessage, Slug, TERMINAL_TASK_STATUSES, Task, TaskAccepted, TaskAssignee, TaskCompleted, TaskError, TaskFailed, type TaskFilter, TaskId, TaskParty, TaskRequested, TaskStatus, TaskStep, Timestamp, type TokenSource, Topic, TransportKind, ULID_PATTERN, UpdateAgentRequest, UpdateNodeRequest, UpdateOrganizationRequest, Version, type WaitOptions, type WebSocketFactory, type WebSocketLike, type WriteOptions, applyMeshEvent, createMeshClient, decodeCursor, encodeCursor, meshStateFromSnapshot, prefixedId, project };
6092
+ export { ALL_SCOPES, Agent, AgentCreated, type AgentFilter, AgentId, AgentKind, AgentRemoved, AgentStatus, AgentStatusChanged, AgentUpdated, ApiKeyId, AuditEntry, AuditId, AuditKind, AuditOutcome, AuditTarget, AuditVerification, Capability, CapabilityName, CapabilityProvider, CapabilityRule, ClientMessage, CommandId, CreateAgentRequest, type CreateAgentRequestInput, CreateLinkRequest, type CreateOptions, CreateOrganizationRequest, CreatePrincipalRequest, CreatePrincipalResponse, Credential, CredentialInfo, DOMAIN_EVENT_TYPES, DisplayName, DomainEvent, type DomainEventOf, type DomainEventType, ENVELOPE_VERSION, Effect, EntityAudit, EnvelopeMeta, EventId, GENESIS_HASH, GrantOwnerRequest, GrantRoleRequest, HealthResponse, ID_PREFIX, type IdKind, IssueTokenRequest, type IssueTokenRequestInput, IssuedToken, KeyRevocation, Link, LinkDown, LinkId, LinkQuality, LinkRemoved, LinkRequested, LinkState, LinkUp, LinkUpdated, MAX_TOKEN_TTL_SECONDS, Me, MeshAgentAgentDeregistered, MeshAgentAgentRegistered, MeshApiError, type MeshClient, type MeshClientOptions, MeshCursor, MeshEvent, MeshKeyRevoked, MeshRealtime, MeshSnapshot, type MeshState, MeshStats, Metadata, NODE_ROLES, NamePattern, Node, NodeCertificate, NodeCreated, NodeDetail, NodeHeartbeat, NodeId, NodeRemoved, NodeStatus, NodeStatusChanged, NodeUpdated, OPEN_POLICY, ORGANIZATION_ROLES, OWNER_ROLES, Organization, OrganizationCreated, OrganizationId, OrganizationPolicy, OrganizationRemoved, OrganizationUpdated, Page, type PageOf, type PageParams, PageQuery, type PolicyDecision, type PolicyHolder, Principal, PrincipalId, PrincipalKind, ProblemDetails, type ProjectionOp, RealtimeCloseCode, RealtimeError, type RealtimeOptions, type RealtimeStatus, RequestTaskRequest, type RequestTaskRequestInput, RevocationId, Role, RoleBinding, RoleBindingId, RoleGranted, RoleRevoked, RoleScope, RoleTarget, ServerMessage, Slug, TERMINAL_TASK_STATUSES, Task, TaskAccepted, TaskAssignee, TaskCompleted, TaskError, TaskFailed, type TaskFilter, TaskId, TaskParty, TaskRequested, TaskStatus, TaskStep, Timestamp, TokenId, TokenScope, type TokenSource, ToolRule, Topic, TransportKind, ULID_PATTERN, UpdateAgentRequest, UpdateNodeRequest, UpdateOrganizationRequest, Version, type WaitOptions, type WebSocketFactory, type WebSocketLike, type WriteOptions, type Writers, applyMeshEvent, createMeshClient, decodeCursor, encodeCursor, inboundAllows, isAuthorizedWriter, matchesPattern, mayRequest, mayUseTool, meshStateFromSnapshot, prefixedId, project, writersOf };