@substrat-run/engine-protocol 0.7.3 → 0.9.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.
@@ -0,0 +1,795 @@
1
+ /**
2
+ * The protocol engine's declared operation surface (#707/#738).
3
+ *
4
+ * An engine declaring its operations is what lets a VERTICAL bind them to its
5
+ * own URLs without restating them. Before this, a vertical mounting
6
+ * `protocol/get` wrote its own `z.object({ instanceId })` — a second
7
+ * description of a shape this engine already owned — and the operation NAME was
8
+ * an unchecked string, because `ModuleRegistration` erases its keys.
9
+ *
10
+ * What is deliberately NOT here:
11
+ *
12
+ * - **`http`.** This engine is entity-agnostic and owns no URL shape: Callout
13
+ * hangs protocols off work orders and Handlebar off bikes, and both are right.
14
+ * The path is the composing vertical's decision, declared with
15
+ * `defineEngineRoutes` against these names.
16
+ * - **`emits`.** The manifest still declares the nine event types by hand, as
17
+ * engine-workorder's does. Deriving them needs `entityIdFrom` to name an
18
+ * OUTPUT field carrying the protocol's id, and three of these operations
19
+ * answer with a composite whose instance sits one level down
20
+ * (`{ instance, signature }`). Declaring the events would mean either
21
+ * flattening returns to suit the declaration or guessing the id — and #695's
22
+ * eighteen `entityId: undefined` events are what guessing that field looks
23
+ * like. It stays hand-declared until the model can say `instance.id`.
24
+ * - **The in-scope functions.** `defineTemplate`, `instantiateProtocol`,
25
+ * `fillProtocol` and the rest are composed by call, inside a vertical's own
26
+ * transaction. These fourteen names are their default HTTP-reachable
27
+ * bindings, not a second way in.
28
+ *
29
+ * ## Inputs are the handler's own schemas, with three deliberate exceptions
30
+ *
31
+ * Every `input` below is the same Zod object the in-scope function parses —
32
+ * that identity is the reason the model is TypeScript, and it is what makes a
33
+ * transcribed argument name impossible. The exceptions are the operations whose
34
+ * REGISTERED shape has always differed from the function's: `instantiate`
35
+ * takes a flattened `entityType`/`entityId` pair where `instantiateProtocol`
36
+ * takes an `EntityRef`, and `sign`/`countersign`/`get`/`void` take an id where
37
+ * the functions take richer arguments. Those shapes are declared here because
38
+ * here is where they are true.
39
+ */
40
+ import { z } from '@substrat-run/contracts';
41
+ /** The keys these operations check. Mirrors `PROTOCOL_PERM` in index.ts. */
42
+ export declare const PROTOCOL_PERMISSIONS: readonly ['protocol:create', 'protocol:fill', 'protocol:bind', 'protocol:request-signature', 'protocol:record-signature', 'protocol:sign', 'protocol:countersign', 'protocol:read', 'protocol:attach', 'protocol:void'];
43
+ export declare const protocolOperations: {
44
+ readonly 'protocol/define-template': {
45
+ readonly summary: "Define a protocol template, or version an existing one";
46
+ readonly permission: "protocol:create";
47
+ readonly input: z.ZodObject<{
48
+ key: z.ZodString;
49
+ title: z.ZodString;
50
+ content: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
51
+ kind: z.ZodLiteral<"checklist">;
52
+ sections: z.ZodArray<z.ZodObject<{
53
+ title: z.ZodString;
54
+ items: z.ZodArray<z.ZodObject<{
55
+ key: z.ZodString;
56
+ label: z.ZodString;
57
+ type: z.ZodEnum<{
58
+ check: "check";
59
+ text: "text";
60
+ value: "value";
61
+ }>;
62
+ unit: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>>;
64
+ }, z.core.$strip>>;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ kind: z.ZodLiteral<"document">;
67
+ documentType: z.ZodString;
68
+ hashRecipe: z.ZodString;
69
+ description: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$strip>], "kind">>;
71
+ }, z.core.$strip>;
72
+ readonly output: z.ZodObject<{
73
+ id: z.ZodString;
74
+ key: z.ZodString;
75
+ version: z.ZodNumber;
76
+ title: z.ZodString;
77
+ content_json: z.ZodString;
78
+ created_at: z.ZodString;
79
+ }, z.core.$strip>;
80
+ };
81
+ readonly 'protocol/list-templates': {
82
+ readonly summary: "The latest version of every template — the instantiation picker";
83
+ readonly permission: "protocol:read";
84
+ readonly output: z.ZodArray<z.ZodObject<{
85
+ id: z.ZodString;
86
+ key: z.ZodString;
87
+ version: z.ZodNumber;
88
+ title: z.ZodString;
89
+ content_json: z.ZodString;
90
+ created_at: z.ZodString;
91
+ }, z.core.$strip>>;
92
+ };
93
+ readonly 'protocol/instantiate': {
94
+ readonly summary: "Start a protocol instance on an entity, pinning the template version";
95
+ readonly permission: "protocol:create";
96
+ readonly input: z.ZodObject<{
97
+ templateKey: z.ZodString;
98
+ entityType: z.ZodString;
99
+ entityId: z.ZodString;
100
+ }, z.core.$strip>;
101
+ readonly output: z.ZodObject<{
102
+ id: z.ZodString;
103
+ template_key: z.ZodString;
104
+ template_version: z.ZodNumber;
105
+ entity_type: z.ZodString;
106
+ entity_id: z.ZodString;
107
+ status: z.ZodEnum<{
108
+ open: "open";
109
+ pending_signature: "pending_signature";
110
+ signed: "signed";
111
+ voided: "voided";
112
+ }>;
113
+ created_by: z.ZodString;
114
+ created_at: z.ZodString;
115
+ voided_by: z.ZodNullable<z.ZodString>;
116
+ voided_reason: z.ZodNullable<z.ZodString>;
117
+ voided_at: z.ZodNullable<z.ZodString>;
118
+ content_ref_type: z.ZodNullable<z.ZodString>;
119
+ content_ref_id: z.ZodNullable<z.ZodString>;
120
+ bound_hash: z.ZodNullable<z.ZodString>;
121
+ document_attachment_id: z.ZodNullable<z.ZodString>;
122
+ frozen_hash: z.ZodNullable<z.ZodString>;
123
+ frozen_at: z.ZodNullable<z.ZodString>;
124
+ }, z.core.$strip>;
125
+ };
126
+ readonly 'protocol/fill': {
127
+ readonly summary: "Record a response on an open checklist protocol (append-only)";
128
+ readonly permission: {
129
+ readonly key: "protocol:fill";
130
+ readonly entity: "protocol";
131
+ readonly idFrom: "instanceId";
132
+ };
133
+ readonly input: z.ZodObject<{
134
+ instanceId: z.ZodString;
135
+ itemKey: z.ZodString;
136
+ value: z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>;
137
+ note: z.ZodOptional<z.ZodString>;
138
+ }, z.core.$strip>;
139
+ readonly output: z.ZodObject<{
140
+ id: z.ZodString;
141
+ instance_id: z.ZodString;
142
+ item_key: z.ZodString;
143
+ value_json: z.ZodString;
144
+ note: z.ZodNullable<z.ZodString>;
145
+ responded_by: z.ZodString;
146
+ responded_at: z.ZodString;
147
+ }, z.core.$strip>;
148
+ };
149
+ readonly 'protocol/bind-document': {
150
+ readonly summary: "Bind vertical-owned document content and its hash to an open document protocol";
151
+ readonly permission: {
152
+ readonly key: "protocol:bind";
153
+ readonly entity: "protocol";
154
+ readonly idFrom: "instanceId";
155
+ };
156
+ readonly input: z.ZodObject<{
157
+ instanceId: z.ZodString;
158
+ contentRef: z.ZodObject<{
159
+ entityType: z.ZodString;
160
+ entityId: z.ZodString;
161
+ }, z.core.$strip>;
162
+ contentHash: z.ZodString;
163
+ documentAttachmentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
164
+ }, z.core.$strip>;
165
+ readonly output: z.ZodObject<{
166
+ id: z.ZodString;
167
+ template_key: z.ZodString;
168
+ template_version: z.ZodNumber;
169
+ entity_type: z.ZodString;
170
+ entity_id: z.ZodString;
171
+ status: z.ZodEnum<{
172
+ open: "open";
173
+ pending_signature: "pending_signature";
174
+ signed: "signed";
175
+ voided: "voided";
176
+ }>;
177
+ created_by: z.ZodString;
178
+ created_at: z.ZodString;
179
+ voided_by: z.ZodNullable<z.ZodString>;
180
+ voided_reason: z.ZodNullable<z.ZodString>;
181
+ voided_at: z.ZodNullable<z.ZodString>;
182
+ content_ref_type: z.ZodNullable<z.ZodString>;
183
+ content_ref_id: z.ZodNullable<z.ZodString>;
184
+ bound_hash: z.ZodNullable<z.ZodString>;
185
+ document_attachment_id: z.ZodNullable<z.ZodString>;
186
+ frozen_hash: z.ZodNullable<z.ZodString>;
187
+ frozen_at: z.ZodNullable<z.ZodString>;
188
+ }, z.core.$strip>;
189
+ };
190
+ readonly 'protocol/request-signatures': {
191
+ readonly summary: "Freeze the content and request signatures from named parties";
192
+ readonly permission: {
193
+ readonly key: "protocol:request-signature";
194
+ readonly entity: "protocol";
195
+ readonly idFrom: "instanceId";
196
+ };
197
+ readonly input: z.ZodObject<{
198
+ instanceId: z.ZodString;
199
+ method: z.ZodString;
200
+ parties: z.ZodArray<z.ZodObject<{
201
+ label: z.ZodString;
202
+ kind: z.ZodEnum<{
203
+ external: "external";
204
+ principal: "principal";
205
+ }>;
206
+ ref: z.ZodOptional<z.ZodString>;
207
+ signatureKind: z.ZodOptional<z.ZodEnum<{
208
+ counter: "counter";
209
+ primary: "primary";
210
+ }>>;
211
+ authLevel: z.ZodOptional<z.ZodEnum<{
212
+ basic: "basic";
213
+ strong: "strong";
214
+ }>>;
215
+ contact: z.ZodOptional<z.ZodObject<{
216
+ email: z.ZodOptional<z.ZodString>;
217
+ mobile: z.ZodOptional<z.ZodString>;
218
+ }, z.core.$strip>>;
219
+ }, z.core.$strip>>;
220
+ }, z.core.$strip>;
221
+ readonly output: z.ZodObject<{
222
+ instance: z.ZodObject<{
223
+ id: z.ZodString;
224
+ template_key: z.ZodString;
225
+ template_version: z.ZodNumber;
226
+ entity_type: z.ZodString;
227
+ entity_id: z.ZodString;
228
+ status: z.ZodEnum<{
229
+ open: "open";
230
+ pending_signature: "pending_signature";
231
+ signed: "signed";
232
+ voided: "voided";
233
+ }>;
234
+ created_by: z.ZodString;
235
+ created_at: z.ZodString;
236
+ voided_by: z.ZodNullable<z.ZodString>;
237
+ voided_reason: z.ZodNullable<z.ZodString>;
238
+ voided_at: z.ZodNullable<z.ZodString>;
239
+ content_ref_type: z.ZodNullable<z.ZodString>;
240
+ content_ref_id: z.ZodNullable<z.ZodString>;
241
+ bound_hash: z.ZodNullable<z.ZodString>;
242
+ document_attachment_id: z.ZodNullable<z.ZodString>;
243
+ frozen_hash: z.ZodNullable<z.ZodString>;
244
+ frozen_at: z.ZodNullable<z.ZodString>;
245
+ }, z.core.$strip>;
246
+ contentHash: z.ZodString;
247
+ requests: z.ZodArray<z.ZodObject<{
248
+ id: z.ZodString;
249
+ instance_id: z.ZodString;
250
+ party_label: z.ZodString;
251
+ party_kind: z.ZodEnum<{
252
+ external: "external";
253
+ principal: "principal";
254
+ }>;
255
+ party_ref: z.ZodNullable<z.ZodString>;
256
+ signature_kind: z.ZodEnum<{
257
+ counter: "counter";
258
+ primary: "primary";
259
+ }>;
260
+ method: z.ZodString;
261
+ auth_level: z.ZodNullable<z.ZodEnum<{
262
+ basic: "basic";
263
+ strong: "strong";
264
+ }>>;
265
+ contact_key_id: z.ZodNullable<z.ZodString>;
266
+ contact_ciphertext: z.ZodNullable<z.ZodString>;
267
+ status: z.ZodEnum<{
268
+ cancelled: "cancelled";
269
+ declined: "declined";
270
+ expired: "expired";
271
+ pending: "pending";
272
+ signed: "signed";
273
+ }>;
274
+ content_hash: z.ZodString;
275
+ external_ref: z.ZodNullable<z.ZodString>;
276
+ resolved_note: z.ZodNullable<z.ZodString>;
277
+ requested_by: z.ZodString;
278
+ requested_at: z.ZodString;
279
+ resolved_at: z.ZodNullable<z.ZodString>;
280
+ }, z.core.$strip>>;
281
+ }, z.core.$strip>;
282
+ };
283
+ readonly 'protocol/cancel-signatures': {
284
+ readonly summary: "Withdraw an outstanding request set and thaw the instance";
285
+ readonly permission: {
286
+ readonly key: "protocol:request-signature";
287
+ readonly entity: "protocol";
288
+ readonly idFrom: "instanceId";
289
+ };
290
+ readonly input: z.ZodObject<{
291
+ instanceId: z.ZodString;
292
+ reason: z.ZodString;
293
+ }, z.core.$strip>;
294
+ readonly output: z.ZodObject<{
295
+ id: z.ZodString;
296
+ template_key: z.ZodString;
297
+ template_version: z.ZodNumber;
298
+ entity_type: z.ZodString;
299
+ entity_id: z.ZodString;
300
+ status: z.ZodEnum<{
301
+ open: "open";
302
+ pending_signature: "pending_signature";
303
+ signed: "signed";
304
+ voided: "voided";
305
+ }>;
306
+ created_by: z.ZodString;
307
+ created_at: z.ZodString;
308
+ voided_by: z.ZodNullable<z.ZodString>;
309
+ voided_reason: z.ZodNullable<z.ZodString>;
310
+ voided_at: z.ZodNullable<z.ZodString>;
311
+ content_ref_type: z.ZodNullable<z.ZodString>;
312
+ content_ref_id: z.ZodNullable<z.ZodString>;
313
+ bound_hash: z.ZodNullable<z.ZodString>;
314
+ document_attachment_id: z.ZodNullable<z.ZodString>;
315
+ frozen_hash: z.ZodNullable<z.ZodString>;
316
+ frozen_at: z.ZodNullable<z.ZodString>;
317
+ }, z.core.$strip>;
318
+ };
319
+ readonly 'protocol/record-signature': {
320
+ readonly summary: "Record a signature reported by an external signing provider";
321
+ readonly permission: "protocol:record-signature";
322
+ readonly input: z.ZodObject<{
323
+ requestId: z.ZodString;
324
+ signatory: z.ZodDiscriminatedUnion<[z.ZodObject<{
325
+ kind: z.ZodLiteral<"principal">;
326
+ ref: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
327
+ label: z.ZodOptional<z.ZodString>;
328
+ }, z.core.$strip>, z.ZodObject<{
329
+ kind: z.ZodLiteral<"external">;
330
+ ref: z.core.$ZodBranded<z.ZodString, "DataSubjectId", "out">;
331
+ label: z.ZodOptional<z.ZodString>;
332
+ }, z.core.$strip>], "kind">;
333
+ signedAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
334
+ contentHash: z.ZodString;
335
+ evidenceRef: z.ZodOptional<z.ZodString>;
336
+ }, z.core.$strip>;
337
+ readonly output: z.ZodObject<{
338
+ instance: z.ZodObject<{
339
+ id: z.ZodString;
340
+ template_key: z.ZodString;
341
+ template_version: z.ZodNumber;
342
+ entity_type: z.ZodString;
343
+ entity_id: z.ZodString;
344
+ status: z.ZodEnum<{
345
+ open: "open";
346
+ pending_signature: "pending_signature";
347
+ signed: "signed";
348
+ voided: "voided";
349
+ }>;
350
+ created_by: z.ZodString;
351
+ created_at: z.ZodString;
352
+ voided_by: z.ZodNullable<z.ZodString>;
353
+ voided_reason: z.ZodNullable<z.ZodString>;
354
+ voided_at: z.ZodNullable<z.ZodString>;
355
+ content_ref_type: z.ZodNullable<z.ZodString>;
356
+ content_ref_id: z.ZodNullable<z.ZodString>;
357
+ bound_hash: z.ZodNullable<z.ZodString>;
358
+ document_attachment_id: z.ZodNullable<z.ZodString>;
359
+ frozen_hash: z.ZodNullable<z.ZodString>;
360
+ frozen_at: z.ZodNullable<z.ZodString>;
361
+ }, z.core.$strip>;
362
+ signature: z.ZodObject<{
363
+ id: z.ZodString;
364
+ instance_id: z.ZodString;
365
+ signed_by: z.ZodString;
366
+ kind: z.ZodEnum<{
367
+ counter: "counter";
368
+ primary: "primary";
369
+ }>;
370
+ method: z.ZodString;
371
+ content_hash: z.ZodString;
372
+ evidence_ref: z.ZodNullable<z.ZodString>;
373
+ signed_at: z.ZodString;
374
+ request_id: z.ZodNullable<z.ZodString>;
375
+ signatory_kind: z.ZodEnum<{
376
+ external: "external";
377
+ principal: "principal";
378
+ }>;
379
+ signatory_label: z.ZodNullable<z.ZodString>;
380
+ }, z.core.$strip>;
381
+ }, z.core.$strip>;
382
+ };
383
+ readonly 'protocol/decline-signature': {
384
+ readonly summary: "Record that a party declined, or that the provider’s window expired";
385
+ readonly permission: "protocol:record-signature";
386
+ readonly input: z.ZodObject<{
387
+ requestId: z.ZodString;
388
+ reason: z.ZodString;
389
+ outcome: z.ZodDefault<z.ZodEnum<{
390
+ declined: "declined";
391
+ expired: "expired";
392
+ }>>;
393
+ }, z.core.$strip>;
394
+ readonly output: z.ZodObject<{
395
+ id: z.ZodString;
396
+ instance_id: z.ZodString;
397
+ party_label: z.ZodString;
398
+ party_kind: z.ZodEnum<{
399
+ external: "external";
400
+ principal: "principal";
401
+ }>;
402
+ party_ref: z.ZodNullable<z.ZodString>;
403
+ signature_kind: z.ZodEnum<{
404
+ counter: "counter";
405
+ primary: "primary";
406
+ }>;
407
+ method: z.ZodString;
408
+ auth_level: z.ZodNullable<z.ZodEnum<{
409
+ basic: "basic";
410
+ strong: "strong";
411
+ }>>;
412
+ contact_key_id: z.ZodNullable<z.ZodString>;
413
+ contact_ciphertext: z.ZodNullable<z.ZodString>;
414
+ status: z.ZodEnum<{
415
+ cancelled: "cancelled";
416
+ declined: "declined";
417
+ expired: "expired";
418
+ pending: "pending";
419
+ signed: "signed";
420
+ }>;
421
+ content_hash: z.ZodString;
422
+ external_ref: z.ZodNullable<z.ZodString>;
423
+ resolved_note: z.ZodNullable<z.ZodString>;
424
+ requested_by: z.ZodString;
425
+ requested_at: z.ZodString;
426
+ resolved_at: z.ZodNullable<z.ZodString>;
427
+ }, z.core.$strip>;
428
+ };
429
+ readonly 'protocol/sign': {
430
+ readonly summary: "Sign a protocol in-app — freezes its content forever";
431
+ readonly permission: {
432
+ readonly key: "protocol:sign";
433
+ readonly entity: "protocol";
434
+ readonly idFrom: "instanceId";
435
+ };
436
+ readonly input: z.ZodObject<{
437
+ instanceId: z.ZodString;
438
+ }, z.core.$strip>;
439
+ readonly output: z.ZodObject<{
440
+ instance: z.ZodObject<{
441
+ id: z.ZodString;
442
+ template_key: z.ZodString;
443
+ template_version: z.ZodNumber;
444
+ entity_type: z.ZodString;
445
+ entity_id: z.ZodString;
446
+ status: z.ZodEnum<{
447
+ open: "open";
448
+ pending_signature: "pending_signature";
449
+ signed: "signed";
450
+ voided: "voided";
451
+ }>;
452
+ created_by: z.ZodString;
453
+ created_at: z.ZodString;
454
+ voided_by: z.ZodNullable<z.ZodString>;
455
+ voided_reason: z.ZodNullable<z.ZodString>;
456
+ voided_at: z.ZodNullable<z.ZodString>;
457
+ content_ref_type: z.ZodNullable<z.ZodString>;
458
+ content_ref_id: z.ZodNullable<z.ZodString>;
459
+ bound_hash: z.ZodNullable<z.ZodString>;
460
+ document_attachment_id: z.ZodNullable<z.ZodString>;
461
+ frozen_hash: z.ZodNullable<z.ZodString>;
462
+ frozen_at: z.ZodNullable<z.ZodString>;
463
+ }, z.core.$strip>;
464
+ signature: z.ZodObject<{
465
+ id: z.ZodString;
466
+ instance_id: z.ZodString;
467
+ signed_by: z.ZodString;
468
+ kind: z.ZodEnum<{
469
+ counter: "counter";
470
+ primary: "primary";
471
+ }>;
472
+ method: z.ZodString;
473
+ content_hash: z.ZodString;
474
+ evidence_ref: z.ZodNullable<z.ZodString>;
475
+ signed_at: z.ZodString;
476
+ request_id: z.ZodNullable<z.ZodString>;
477
+ signatory_kind: z.ZodEnum<{
478
+ external: "external";
479
+ principal: "principal";
480
+ }>;
481
+ signatory_label: z.ZodNullable<z.ZodString>;
482
+ }, z.core.$strip>;
483
+ }, z.core.$strip>;
484
+ };
485
+ readonly 'protocol/countersign': {
486
+ readonly summary: "Counter-sign an already-signed protocol, on the same frozen content";
487
+ readonly permission: {
488
+ readonly key: "protocol:countersign";
489
+ readonly entity: "protocol";
490
+ readonly idFrom: "instanceId";
491
+ };
492
+ readonly input: z.ZodObject<{
493
+ instanceId: z.ZodString;
494
+ }, z.core.$strip>;
495
+ readonly output: z.ZodObject<{
496
+ instance: z.ZodObject<{
497
+ id: z.ZodString;
498
+ template_key: z.ZodString;
499
+ template_version: z.ZodNumber;
500
+ entity_type: z.ZodString;
501
+ entity_id: z.ZodString;
502
+ status: z.ZodEnum<{
503
+ open: "open";
504
+ pending_signature: "pending_signature";
505
+ signed: "signed";
506
+ voided: "voided";
507
+ }>;
508
+ created_by: z.ZodString;
509
+ created_at: z.ZodString;
510
+ voided_by: z.ZodNullable<z.ZodString>;
511
+ voided_reason: z.ZodNullable<z.ZodString>;
512
+ voided_at: z.ZodNullable<z.ZodString>;
513
+ content_ref_type: z.ZodNullable<z.ZodString>;
514
+ content_ref_id: z.ZodNullable<z.ZodString>;
515
+ bound_hash: z.ZodNullable<z.ZodString>;
516
+ document_attachment_id: z.ZodNullable<z.ZodString>;
517
+ frozen_hash: z.ZodNullable<z.ZodString>;
518
+ frozen_at: z.ZodNullable<z.ZodString>;
519
+ }, z.core.$strip>;
520
+ signature: z.ZodObject<{
521
+ id: z.ZodString;
522
+ instance_id: z.ZodString;
523
+ signed_by: z.ZodString;
524
+ kind: z.ZodEnum<{
525
+ counter: "counter";
526
+ primary: "primary";
527
+ }>;
528
+ method: z.ZodString;
529
+ content_hash: z.ZodString;
530
+ evidence_ref: z.ZodNullable<z.ZodString>;
531
+ signed_at: z.ZodString;
532
+ request_id: z.ZodNullable<z.ZodString>;
533
+ signatory_kind: z.ZodEnum<{
534
+ external: "external";
535
+ principal: "principal";
536
+ }>;
537
+ signatory_label: z.ZodNullable<z.ZodString>;
538
+ }, z.core.$strip>;
539
+ }, z.core.$strip>;
540
+ };
541
+ readonly 'protocol/void': {
542
+ readonly summary: "Void (supersede) a protocol — never deletes";
543
+ readonly permission: {
544
+ readonly key: "protocol:void";
545
+ readonly entity: "protocol";
546
+ readonly idFrom: "instanceId";
547
+ };
548
+ readonly input: z.ZodObject<{
549
+ instanceId: z.ZodString;
550
+ reason: z.ZodString;
551
+ }, z.core.$strip>;
552
+ readonly output: z.ZodObject<{
553
+ id: z.ZodString;
554
+ template_key: z.ZodString;
555
+ template_version: z.ZodNumber;
556
+ entity_type: z.ZodString;
557
+ entity_id: z.ZodString;
558
+ status: z.ZodEnum<{
559
+ open: "open";
560
+ pending_signature: "pending_signature";
561
+ signed: "signed";
562
+ voided: "voided";
563
+ }>;
564
+ created_by: z.ZodString;
565
+ created_at: z.ZodString;
566
+ voided_by: z.ZodNullable<z.ZodString>;
567
+ voided_reason: z.ZodNullable<z.ZodString>;
568
+ voided_at: z.ZodNullable<z.ZodString>;
569
+ content_ref_type: z.ZodNullable<z.ZodString>;
570
+ content_ref_id: z.ZodNullable<z.ZodString>;
571
+ bound_hash: z.ZodNullable<z.ZodString>;
572
+ document_attachment_id: z.ZodNullable<z.ZodString>;
573
+ frozen_hash: z.ZodNullable<z.ZodString>;
574
+ frozen_at: z.ZodNullable<z.ZodString>;
575
+ }, z.core.$strip>;
576
+ };
577
+ readonly 'protocol/get': {
578
+ readonly summary: "One protocol with its template, responses, signatures and requests";
579
+ readonly permission: {
580
+ readonly key: "protocol:read";
581
+ readonly entity: "protocol";
582
+ readonly idFrom: "instanceId";
583
+ };
584
+ readonly input: z.ZodObject<{
585
+ instanceId: z.ZodString;
586
+ }, z.core.$strip>;
587
+ readonly output: z.ZodObject<{
588
+ instance: z.ZodObject<{
589
+ id: z.ZodString;
590
+ template_key: z.ZodString;
591
+ template_version: z.ZodNumber;
592
+ entity_type: z.ZodString;
593
+ entity_id: z.ZodString;
594
+ status: z.ZodEnum<{
595
+ open: "open";
596
+ pending_signature: "pending_signature";
597
+ signed: "signed";
598
+ voided: "voided";
599
+ }>;
600
+ created_by: z.ZodString;
601
+ created_at: z.ZodString;
602
+ voided_by: z.ZodNullable<z.ZodString>;
603
+ voided_reason: z.ZodNullable<z.ZodString>;
604
+ voided_at: z.ZodNullable<z.ZodString>;
605
+ content_ref_type: z.ZodNullable<z.ZodString>;
606
+ content_ref_id: z.ZodNullable<z.ZodString>;
607
+ bound_hash: z.ZodNullable<z.ZodString>;
608
+ document_attachment_id: z.ZodNullable<z.ZodString>;
609
+ frozen_hash: z.ZodNullable<z.ZodString>;
610
+ frozen_at: z.ZodNullable<z.ZodString>;
611
+ }, z.core.$strip>;
612
+ template: z.ZodObject<{
613
+ key: z.ZodString;
614
+ version: z.ZodNumber;
615
+ title: z.ZodString;
616
+ content: z.ZodDiscriminatedUnion<[z.ZodObject<{
617
+ kind: z.ZodLiteral<"checklist">;
618
+ sections: z.ZodArray<z.ZodObject<{
619
+ title: z.ZodString;
620
+ items: z.ZodArray<z.ZodObject<{
621
+ key: z.ZodString;
622
+ label: z.ZodString;
623
+ type: z.ZodEnum<{
624
+ check: "check";
625
+ text: "text";
626
+ value: "value";
627
+ }>;
628
+ unit: z.ZodOptional<z.ZodString>;
629
+ }, z.core.$strip>>;
630
+ }, z.core.$strip>>;
631
+ }, z.core.$strip>, z.ZodObject<{
632
+ kind: z.ZodLiteral<"document">;
633
+ documentType: z.ZodString;
634
+ hashRecipe: z.ZodString;
635
+ description: z.ZodOptional<z.ZodString>;
636
+ }, z.core.$strip>], "kind">;
637
+ }, z.core.$strip>;
638
+ responses: z.ZodArray<z.ZodObject<{
639
+ id: z.ZodString;
640
+ instance_id: z.ZodString;
641
+ item_key: z.ZodString;
642
+ value_json: z.ZodString;
643
+ note: z.ZodNullable<z.ZodString>;
644
+ responded_by: z.ZodString;
645
+ responded_at: z.ZodString;
646
+ }, z.core.$strip>>;
647
+ latest: z.ZodRecord<z.ZodString, z.ZodObject<{
648
+ id: z.ZodString;
649
+ instance_id: z.ZodString;
650
+ item_key: z.ZodString;
651
+ value_json: z.ZodString;
652
+ note: z.ZodNullable<z.ZodString>;
653
+ responded_by: z.ZodString;
654
+ responded_at: z.ZodString;
655
+ }, z.core.$strip>>;
656
+ signature: z.ZodNullable<z.ZodObject<{
657
+ id: z.ZodString;
658
+ instance_id: z.ZodString;
659
+ signed_by: z.ZodString;
660
+ kind: z.ZodEnum<{
661
+ counter: "counter";
662
+ primary: "primary";
663
+ }>;
664
+ method: z.ZodString;
665
+ content_hash: z.ZodString;
666
+ evidence_ref: z.ZodNullable<z.ZodString>;
667
+ signed_at: z.ZodString;
668
+ request_id: z.ZodNullable<z.ZodString>;
669
+ signatory_kind: z.ZodEnum<{
670
+ external: "external";
671
+ principal: "principal";
672
+ }>;
673
+ signatory_label: z.ZodNullable<z.ZodString>;
674
+ }, z.core.$strip>>;
675
+ signatures: z.ZodArray<z.ZodObject<{
676
+ id: z.ZodString;
677
+ instance_id: z.ZodString;
678
+ signed_by: z.ZodString;
679
+ kind: z.ZodEnum<{
680
+ counter: "counter";
681
+ primary: "primary";
682
+ }>;
683
+ method: z.ZodString;
684
+ content_hash: z.ZodString;
685
+ evidence_ref: z.ZodNullable<z.ZodString>;
686
+ signed_at: z.ZodString;
687
+ request_id: z.ZodNullable<z.ZodString>;
688
+ signatory_kind: z.ZodEnum<{
689
+ external: "external";
690
+ principal: "principal";
691
+ }>;
692
+ signatory_label: z.ZodNullable<z.ZodString>;
693
+ }, z.core.$strip>>;
694
+ requests: z.ZodArray<z.ZodObject<{
695
+ id: z.ZodString;
696
+ instance_id: z.ZodString;
697
+ party_label: z.ZodString;
698
+ party_kind: z.ZodEnum<{
699
+ external: "external";
700
+ principal: "principal";
701
+ }>;
702
+ party_ref: z.ZodNullable<z.ZodString>;
703
+ signature_kind: z.ZodEnum<{
704
+ counter: "counter";
705
+ primary: "primary";
706
+ }>;
707
+ method: z.ZodString;
708
+ auth_level: z.ZodNullable<z.ZodEnum<{
709
+ basic: "basic";
710
+ strong: "strong";
711
+ }>>;
712
+ contact_key_id: z.ZodNullable<z.ZodString>;
713
+ contact_ciphertext: z.ZodNullable<z.ZodString>;
714
+ status: z.ZodEnum<{
715
+ cancelled: "cancelled";
716
+ declined: "declined";
717
+ expired: "expired";
718
+ pending: "pending";
719
+ signed: "signed";
720
+ }>;
721
+ content_hash: z.ZodString;
722
+ external_ref: z.ZodNullable<z.ZodString>;
723
+ resolved_note: z.ZodNullable<z.ZodString>;
724
+ requested_by: z.ZodString;
725
+ requested_at: z.ZodString;
726
+ resolved_at: z.ZodNullable<z.ZodString>;
727
+ }, z.core.$strip>>;
728
+ }, z.core.$strip>;
729
+ };
730
+ /**
731
+ * The one operation here whose authority cannot be stated as a leading
732
+ * `permission`, and the reason is this engine's defining property.
733
+ *
734
+ * The check is `protocol:read` against the entity the protocols hang on — a
735
+ * work order in Callout, a bike in Handlebar — so the entity's TYPE arrives as
736
+ * data. `PermissionCheck.entity` must name a type known at declaration time,
737
+ * and there is no honest value to put there: `'protocol'` would be false,
738
+ * because what is checked is the PARENT, not any protocol.
739
+ *
740
+ * So it declares `narrows` instead, which records the fact that actually
741
+ * protects anything — this is not a node check — and names the key the walk
742
+ * evaluates, so `protocol:read` still reaches the permission review. What is
743
+ * lost is the entity type, which was never available to lose.
744
+ */
745
+ readonly 'protocol/list-for-entity': {
746
+ readonly summary: "Every protocol on one entity, with its progress and signatures";
747
+ readonly narrows: {
748
+ readonly reason: "checked against the entity the protocols hang on, whose type is the caller’s";
749
+ readonly checks: readonly ["protocol:read"];
750
+ };
751
+ readonly input: z.ZodObject<{
752
+ entityType: z.ZodString;
753
+ entityId: z.ZodString;
754
+ }, z.core.$strip>;
755
+ readonly output: z.ZodArray<z.ZodObject<{
756
+ instance: z.ZodObject<{
757
+ id: z.ZodString;
758
+ template_key: z.ZodString;
759
+ template_version: z.ZodNumber;
760
+ entity_type: z.ZodString;
761
+ entity_id: z.ZodString;
762
+ status: z.ZodEnum<{
763
+ open: "open";
764
+ pending_signature: "pending_signature";
765
+ signed: "signed";
766
+ voided: "voided";
767
+ }>;
768
+ created_by: z.ZodString;
769
+ created_at: z.ZodString;
770
+ voided_by: z.ZodNullable<z.ZodString>;
771
+ voided_reason: z.ZodNullable<z.ZodString>;
772
+ voided_at: z.ZodNullable<z.ZodString>;
773
+ content_ref_type: z.ZodNullable<z.ZodString>;
774
+ content_ref_id: z.ZodNullable<z.ZodString>;
775
+ bound_hash: z.ZodNullable<z.ZodString>;
776
+ document_attachment_id: z.ZodNullable<z.ZodString>;
777
+ frozen_hash: z.ZodNullable<z.ZodString>;
778
+ frozen_at: z.ZodNullable<z.ZodString>;
779
+ }, z.core.$strip>;
780
+ title: z.ZodString;
781
+ contentKind: z.ZodEnum<{
782
+ checklist: "checklist";
783
+ document: "document";
784
+ }>;
785
+ answered: z.ZodNumber;
786
+ total: z.ZodNumber;
787
+ signedBy: z.ZodNullable<z.ZodString>;
788
+ signedAt: z.ZodNullable<z.ZodString>;
789
+ countersignedBy: z.ZodNullable<z.ZodString>;
790
+ countersignedAt: z.ZodNullable<z.ZodString>;
791
+ pendingSignatures: z.ZodNumber;
792
+ }, z.core.$strip>>;
793
+ };
794
+ };
795
+ //# sourceMappingURL=operations.d.ts.map