@stryke/capnp 0.8.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.
package/schemas/rpc.js ADDED
@@ -0,0 +1,2563 @@
1
+ import {
2
+ CompositeList,
3
+ ObjectSize,
4
+ Struct,
5
+ getBitMask,
6
+ getUint8Mask,
7
+ utils
8
+ } from "./chunk-BQI46ZE5.js";
9
+ import {
10
+ __name
11
+ } from "./chunk-SHUYVCID.js";
12
+
13
+ // schemas/rpc.ts
14
+ var _capnpFileId = BigInt("0xb312981b2552a250");
15
+ var Message_Which = {
16
+ /**
17
+ * The sender previously received this message from the peer but didn't understand it or doesn't
18
+ * yet implement the functionality that was requested. So, the sender is echoing the message
19
+ * back. In some cases, the receiver may be able to recover from this by pretending the sender
20
+ * had taken some appropriate "null" action.
21
+ *
22
+ * For example, say `resolve` is received by a level 0 implementation (because a previous call
23
+ * or return happened to contain a promise). The level 0 implementation will echo it back as
24
+ * `unimplemented`. The original sender can then simply release the cap to which the promise
25
+ * had resolved, thus avoiding a leak.
26
+ *
27
+ * For any message type that introduces a question, if the message comes back unimplemented,
28
+ * the original sender may simply treat it as if the question failed with an exception.
29
+ *
30
+ * In cases where there is no sensible way to react to an `unimplemented` message (without
31
+ * resource leaks or other serious problems), the connection may need to be aborted. This is
32
+ * a gray area; different implementations may take different approaches.
33
+ *
34
+ */
35
+ UNIMPLEMENTED: 0,
36
+ /**
37
+ * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
38
+ * because the sender received an invalid or nonsensical message or because the sender had an
39
+ * internal error. The sender will shut down the outgoing half of the connection after `abort`
40
+ * and will completely close the connection shortly thereafter (it's up to the sender how much
41
+ * of a time buffer they want to offer for the client to receive the `abort` before the
42
+ * connection is reset).
43
+ *
44
+ */
45
+ ABORT: 1,
46
+ /**
47
+ * Request the peer's bootstrap interface.
48
+ *
49
+ */
50
+ BOOTSTRAP: 8,
51
+ /**
52
+ * Begin a method call.
53
+ *
54
+ */
55
+ CALL: 2,
56
+ /**
57
+ * Complete a method call.
58
+ *
59
+ */
60
+ RETURN: 3,
61
+ /**
62
+ * Release a returned answer / cancel a call.
63
+ *
64
+ */
65
+ FINISH: 4,
66
+ /**
67
+ * Resolve a previously-sent promise.
68
+ *
69
+ */
70
+ RESOLVE: 5,
71
+ /**
72
+ * Release a capability so that the remote object can be deallocated.
73
+ *
74
+ */
75
+ RELEASE: 6,
76
+ /**
77
+ * Lift an embargo used to enforce E-order over promise resolution.
78
+ *
79
+ */
80
+ DISEMBARGO: 13,
81
+ /**
82
+ * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
83
+ * by the `Persistent` interface defined in `persistent.capnp`. This operation was never
84
+ * implemented.
85
+ *
86
+ */
87
+ OBSOLETE_SAVE: 7,
88
+ /**
89
+ * Obsolete way to delete a SturdyRef. This operation was never implemented.
90
+ *
91
+ */
92
+ OBSOLETE_DELETE: 9,
93
+ /**
94
+ * Provide a capability to a third party.
95
+ *
96
+ */
97
+ PROVIDE: 10,
98
+ /**
99
+ * Accept a capability provided by a third party.
100
+ *
101
+ */
102
+ ACCEPT: 11,
103
+ /**
104
+ * Directly connect to the common root of two or more proxied caps.
105
+ *
106
+ */
107
+ JOIN: 12
108
+ };
109
+ var Message = class _Message extends Struct {
110
+ static {
111
+ __name(this, "Message");
112
+ }
113
+ static UNIMPLEMENTED = Message_Which.UNIMPLEMENTED;
114
+ static ABORT = Message_Which.ABORT;
115
+ static BOOTSTRAP = Message_Which.BOOTSTRAP;
116
+ static CALL = Message_Which.CALL;
117
+ static RETURN = Message_Which.RETURN;
118
+ static FINISH = Message_Which.FINISH;
119
+ static RESOLVE = Message_Which.RESOLVE;
120
+ static RELEASE = Message_Which.RELEASE;
121
+ static DISEMBARGO = Message_Which.DISEMBARGO;
122
+ static OBSOLETE_SAVE = Message_Which.OBSOLETE_SAVE;
123
+ static OBSOLETE_DELETE = Message_Which.OBSOLETE_DELETE;
124
+ static PROVIDE = Message_Which.PROVIDE;
125
+ static ACCEPT = Message_Which.ACCEPT;
126
+ static JOIN = Message_Which.JOIN;
127
+ static _capnp = {
128
+ displayName: "Message",
129
+ id: "91b79f1f808db032",
130
+ size: new ObjectSize(8, 1)
131
+ };
132
+ _adoptUnimplemented(value) {
133
+ utils.setUint16(0, 0, this);
134
+ utils.adopt(value, utils.getPointer(0, this));
135
+ }
136
+ _disownUnimplemented() {
137
+ return utils.disown(this.unimplemented);
138
+ }
139
+ /**
140
+ * The sender previously received this message from the peer but didn't understand it or doesn't
141
+ * yet implement the functionality that was requested. So, the sender is echoing the message
142
+ * back. In some cases, the receiver may be able to recover from this by pretending the sender
143
+ * had taken some appropriate "null" action.
144
+ *
145
+ * For example, say `resolve` is received by a level 0 implementation (because a previous call
146
+ * or return happened to contain a promise). The level 0 implementation will echo it back as
147
+ * `unimplemented`. The original sender can then simply release the cap to which the promise
148
+ * had resolved, thus avoiding a leak.
149
+ *
150
+ * For any message type that introduces a question, if the message comes back unimplemented,
151
+ * the original sender may simply treat it as if the question failed with an exception.
152
+ *
153
+ * In cases where there is no sensible way to react to an `unimplemented` message (without
154
+ * resource leaks or other serious problems), the connection may need to be aborted. This is
155
+ * a gray area; different implementations may take different approaches.
156
+ *
157
+ */
158
+ get unimplemented() {
159
+ utils.testWhich("unimplemented", utils.getUint16(0, this), 0, this);
160
+ return utils.getStruct(0, _Message, this);
161
+ }
162
+ _hasUnimplemented() {
163
+ return !utils.isNull(utils.getPointer(0, this));
164
+ }
165
+ _initUnimplemented() {
166
+ utils.setUint16(0, 0, this);
167
+ return utils.initStructAt(0, _Message, this);
168
+ }
169
+ get _isUnimplemented() {
170
+ return utils.getUint16(0, this) === 0;
171
+ }
172
+ set unimplemented(value) {
173
+ utils.setUint16(0, 0, this);
174
+ utils.copyFrom(value, utils.getPointer(0, this));
175
+ }
176
+ _adoptAbort(value) {
177
+ utils.setUint16(0, 1, this);
178
+ utils.adopt(value, utils.getPointer(0, this));
179
+ }
180
+ _disownAbort() {
181
+ return utils.disown(this.abort);
182
+ }
183
+ /**
184
+ * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
185
+ * because the sender received an invalid or nonsensical message or because the sender had an
186
+ * internal error. The sender will shut down the outgoing half of the connection after `abort`
187
+ * and will completely close the connection shortly thereafter (it's up to the sender how much
188
+ * of a time buffer they want to offer for the client to receive the `abort` before the
189
+ * connection is reset).
190
+ *
191
+ */
192
+ get abort() {
193
+ utils.testWhich("abort", utils.getUint16(0, this), 1, this);
194
+ return utils.getStruct(0, Exception, this);
195
+ }
196
+ _hasAbort() {
197
+ return !utils.isNull(utils.getPointer(0, this));
198
+ }
199
+ _initAbort() {
200
+ utils.setUint16(0, 1, this);
201
+ return utils.initStructAt(0, Exception, this);
202
+ }
203
+ get _isAbort() {
204
+ return utils.getUint16(0, this) === 1;
205
+ }
206
+ set abort(value) {
207
+ utils.setUint16(0, 1, this);
208
+ utils.copyFrom(value, utils.getPointer(0, this));
209
+ }
210
+ _adoptBootstrap(value) {
211
+ utils.setUint16(0, 8, this);
212
+ utils.adopt(value, utils.getPointer(0, this));
213
+ }
214
+ _disownBootstrap() {
215
+ return utils.disown(this.bootstrap);
216
+ }
217
+ /**
218
+ * Request the peer's bootstrap interface.
219
+ *
220
+ */
221
+ get bootstrap() {
222
+ utils.testWhich("bootstrap", utils.getUint16(0, this), 8, this);
223
+ return utils.getStruct(0, Bootstrap, this);
224
+ }
225
+ _hasBootstrap() {
226
+ return !utils.isNull(utils.getPointer(0, this));
227
+ }
228
+ _initBootstrap() {
229
+ utils.setUint16(0, 8, this);
230
+ return utils.initStructAt(0, Bootstrap, this);
231
+ }
232
+ get _isBootstrap() {
233
+ return utils.getUint16(0, this) === 8;
234
+ }
235
+ set bootstrap(value) {
236
+ utils.setUint16(0, 8, this);
237
+ utils.copyFrom(value, utils.getPointer(0, this));
238
+ }
239
+ _adoptCall(value) {
240
+ utils.setUint16(0, 2, this);
241
+ utils.adopt(value, utils.getPointer(0, this));
242
+ }
243
+ _disownCall() {
244
+ return utils.disown(this.call);
245
+ }
246
+ /**
247
+ * Begin a method call.
248
+ *
249
+ */
250
+ get call() {
251
+ utils.testWhich("call", utils.getUint16(0, this), 2, this);
252
+ return utils.getStruct(0, Call, this);
253
+ }
254
+ _hasCall() {
255
+ return !utils.isNull(utils.getPointer(0, this));
256
+ }
257
+ _initCall() {
258
+ utils.setUint16(0, 2, this);
259
+ return utils.initStructAt(0, Call, this);
260
+ }
261
+ get _isCall() {
262
+ return utils.getUint16(0, this) === 2;
263
+ }
264
+ set call(value) {
265
+ utils.setUint16(0, 2, this);
266
+ utils.copyFrom(value, utils.getPointer(0, this));
267
+ }
268
+ _adoptReturn(value) {
269
+ utils.setUint16(0, 3, this);
270
+ utils.adopt(value, utils.getPointer(0, this));
271
+ }
272
+ _disownReturn() {
273
+ return utils.disown(this.return);
274
+ }
275
+ /**
276
+ * Complete a method call.
277
+ *
278
+ */
279
+ get return() {
280
+ utils.testWhich("return", utils.getUint16(0, this), 3, this);
281
+ return utils.getStruct(0, Return, this);
282
+ }
283
+ _hasReturn() {
284
+ return !utils.isNull(utils.getPointer(0, this));
285
+ }
286
+ _initReturn() {
287
+ utils.setUint16(0, 3, this);
288
+ return utils.initStructAt(0, Return, this);
289
+ }
290
+ get _isReturn() {
291
+ return utils.getUint16(0, this) === 3;
292
+ }
293
+ set return(value) {
294
+ utils.setUint16(0, 3, this);
295
+ utils.copyFrom(value, utils.getPointer(0, this));
296
+ }
297
+ _adoptFinish(value) {
298
+ utils.setUint16(0, 4, this);
299
+ utils.adopt(value, utils.getPointer(0, this));
300
+ }
301
+ _disownFinish() {
302
+ return utils.disown(this.finish);
303
+ }
304
+ /**
305
+ * Release a returned answer / cancel a call.
306
+ *
307
+ */
308
+ get finish() {
309
+ utils.testWhich("finish", utils.getUint16(0, this), 4, this);
310
+ return utils.getStruct(0, Finish, this);
311
+ }
312
+ _hasFinish() {
313
+ return !utils.isNull(utils.getPointer(0, this));
314
+ }
315
+ _initFinish() {
316
+ utils.setUint16(0, 4, this);
317
+ return utils.initStructAt(0, Finish, this);
318
+ }
319
+ get _isFinish() {
320
+ return utils.getUint16(0, this) === 4;
321
+ }
322
+ set finish(value) {
323
+ utils.setUint16(0, 4, this);
324
+ utils.copyFrom(value, utils.getPointer(0, this));
325
+ }
326
+ _adoptResolve(value) {
327
+ utils.setUint16(0, 5, this);
328
+ utils.adopt(value, utils.getPointer(0, this));
329
+ }
330
+ _disownResolve() {
331
+ return utils.disown(this.resolve);
332
+ }
333
+ /**
334
+ * Resolve a previously-sent promise.
335
+ *
336
+ */
337
+ get resolve() {
338
+ utils.testWhich("resolve", utils.getUint16(0, this), 5, this);
339
+ return utils.getStruct(0, Resolve, this);
340
+ }
341
+ _hasResolve() {
342
+ return !utils.isNull(utils.getPointer(0, this));
343
+ }
344
+ _initResolve() {
345
+ utils.setUint16(0, 5, this);
346
+ return utils.initStructAt(0, Resolve, this);
347
+ }
348
+ get _isResolve() {
349
+ return utils.getUint16(0, this) === 5;
350
+ }
351
+ set resolve(value) {
352
+ utils.setUint16(0, 5, this);
353
+ utils.copyFrom(value, utils.getPointer(0, this));
354
+ }
355
+ _adoptRelease(value) {
356
+ utils.setUint16(0, 6, this);
357
+ utils.adopt(value, utils.getPointer(0, this));
358
+ }
359
+ _disownRelease() {
360
+ return utils.disown(this.release);
361
+ }
362
+ /**
363
+ * Release a capability so that the remote object can be deallocated.
364
+ *
365
+ */
366
+ get release() {
367
+ utils.testWhich("release", utils.getUint16(0, this), 6, this);
368
+ return utils.getStruct(0, Release, this);
369
+ }
370
+ _hasRelease() {
371
+ return !utils.isNull(utils.getPointer(0, this));
372
+ }
373
+ _initRelease() {
374
+ utils.setUint16(0, 6, this);
375
+ return utils.initStructAt(0, Release, this);
376
+ }
377
+ get _isRelease() {
378
+ return utils.getUint16(0, this) === 6;
379
+ }
380
+ set release(value) {
381
+ utils.setUint16(0, 6, this);
382
+ utils.copyFrom(value, utils.getPointer(0, this));
383
+ }
384
+ _adoptDisembargo(value) {
385
+ utils.setUint16(0, 13, this);
386
+ utils.adopt(value, utils.getPointer(0, this));
387
+ }
388
+ _disownDisembargo() {
389
+ return utils.disown(this.disembargo);
390
+ }
391
+ /**
392
+ * Lift an embargo used to enforce E-order over promise resolution.
393
+ *
394
+ */
395
+ get disembargo() {
396
+ utils.testWhich("disembargo", utils.getUint16(0, this), 13, this);
397
+ return utils.getStruct(0, Disembargo, this);
398
+ }
399
+ _hasDisembargo() {
400
+ return !utils.isNull(utils.getPointer(0, this));
401
+ }
402
+ _initDisembargo() {
403
+ utils.setUint16(0, 13, this);
404
+ return utils.initStructAt(0, Disembargo, this);
405
+ }
406
+ get _isDisembargo() {
407
+ return utils.getUint16(0, this) === 13;
408
+ }
409
+ set disembargo(value) {
410
+ utils.setUint16(0, 13, this);
411
+ utils.copyFrom(value, utils.getPointer(0, this));
412
+ }
413
+ _adoptObsoleteSave(value) {
414
+ utils.setUint16(0, 7, this);
415
+ utils.adopt(value, utils.getPointer(0, this));
416
+ }
417
+ _disownObsoleteSave() {
418
+ return utils.disown(this.obsoleteSave);
419
+ }
420
+ /**
421
+ * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
422
+ * by the `Persistent` interface defined in `persistent.capnp`. This operation was never
423
+ * implemented.
424
+ *
425
+ */
426
+ get obsoleteSave() {
427
+ utils.testWhich("obsoleteSave", utils.getUint16(0, this), 7, this);
428
+ return utils.getPointer(0, this);
429
+ }
430
+ _hasObsoleteSave() {
431
+ return !utils.isNull(utils.getPointer(0, this));
432
+ }
433
+ get _isObsoleteSave() {
434
+ return utils.getUint16(0, this) === 7;
435
+ }
436
+ set obsoleteSave(value) {
437
+ utils.setUint16(0, 7, this);
438
+ utils.copyFrom(value, utils.getPointer(0, this));
439
+ }
440
+ _adoptObsoleteDelete(value) {
441
+ utils.setUint16(0, 9, this);
442
+ utils.adopt(value, utils.getPointer(0, this));
443
+ }
444
+ _disownObsoleteDelete() {
445
+ return utils.disown(this.obsoleteDelete);
446
+ }
447
+ /**
448
+ * Obsolete way to delete a SturdyRef. This operation was never implemented.
449
+ *
450
+ */
451
+ get obsoleteDelete() {
452
+ utils.testWhich("obsoleteDelete", utils.getUint16(0, this), 9, this);
453
+ return utils.getPointer(0, this);
454
+ }
455
+ _hasObsoleteDelete() {
456
+ return !utils.isNull(utils.getPointer(0, this));
457
+ }
458
+ get _isObsoleteDelete() {
459
+ return utils.getUint16(0, this) === 9;
460
+ }
461
+ set obsoleteDelete(value) {
462
+ utils.setUint16(0, 9, this);
463
+ utils.copyFrom(value, utils.getPointer(0, this));
464
+ }
465
+ _adoptProvide(value) {
466
+ utils.setUint16(0, 10, this);
467
+ utils.adopt(value, utils.getPointer(0, this));
468
+ }
469
+ _disownProvide() {
470
+ return utils.disown(this.provide);
471
+ }
472
+ /**
473
+ * Provide a capability to a third party.
474
+ *
475
+ */
476
+ get provide() {
477
+ utils.testWhich("provide", utils.getUint16(0, this), 10, this);
478
+ return utils.getStruct(0, Provide, this);
479
+ }
480
+ _hasProvide() {
481
+ return !utils.isNull(utils.getPointer(0, this));
482
+ }
483
+ _initProvide() {
484
+ utils.setUint16(0, 10, this);
485
+ return utils.initStructAt(0, Provide, this);
486
+ }
487
+ get _isProvide() {
488
+ return utils.getUint16(0, this) === 10;
489
+ }
490
+ set provide(value) {
491
+ utils.setUint16(0, 10, this);
492
+ utils.copyFrom(value, utils.getPointer(0, this));
493
+ }
494
+ _adoptAccept(value) {
495
+ utils.setUint16(0, 11, this);
496
+ utils.adopt(value, utils.getPointer(0, this));
497
+ }
498
+ _disownAccept() {
499
+ return utils.disown(this.accept);
500
+ }
501
+ /**
502
+ * Accept a capability provided by a third party.
503
+ *
504
+ */
505
+ get accept() {
506
+ utils.testWhich("accept", utils.getUint16(0, this), 11, this);
507
+ return utils.getStruct(0, Accept, this);
508
+ }
509
+ _hasAccept() {
510
+ return !utils.isNull(utils.getPointer(0, this));
511
+ }
512
+ _initAccept() {
513
+ utils.setUint16(0, 11, this);
514
+ return utils.initStructAt(0, Accept, this);
515
+ }
516
+ get _isAccept() {
517
+ return utils.getUint16(0, this) === 11;
518
+ }
519
+ set accept(value) {
520
+ utils.setUint16(0, 11, this);
521
+ utils.copyFrom(value, utils.getPointer(0, this));
522
+ }
523
+ _adoptJoin(value) {
524
+ utils.setUint16(0, 12, this);
525
+ utils.adopt(value, utils.getPointer(0, this));
526
+ }
527
+ _disownJoin() {
528
+ return utils.disown(this.join);
529
+ }
530
+ /**
531
+ * Directly connect to the common root of two or more proxied caps.
532
+ *
533
+ */
534
+ get join() {
535
+ utils.testWhich("join", utils.getUint16(0, this), 12, this);
536
+ return utils.getStruct(0, Join, this);
537
+ }
538
+ _hasJoin() {
539
+ return !utils.isNull(utils.getPointer(0, this));
540
+ }
541
+ _initJoin() {
542
+ utils.setUint16(0, 12, this);
543
+ return utils.initStructAt(0, Join, this);
544
+ }
545
+ get _isJoin() {
546
+ return utils.getUint16(0, this) === 12;
547
+ }
548
+ set join(value) {
549
+ utils.setUint16(0, 12, this);
550
+ utils.copyFrom(value, utils.getPointer(0, this));
551
+ }
552
+ toString() {
553
+ return "Message_" + super.toString();
554
+ }
555
+ which() {
556
+ return utils.getUint16(0, this);
557
+ }
558
+ };
559
+ var Bootstrap = class extends Struct {
560
+ static {
561
+ __name(this, "Bootstrap");
562
+ }
563
+ static _capnp = {
564
+ displayName: "Bootstrap",
565
+ id: "e94ccf8031176ec4",
566
+ size: new ObjectSize(8, 1)
567
+ };
568
+ /**
569
+ * A new question ID identifying this request, which will eventually receive a Return message
570
+ * containing the restored capability.
571
+ *
572
+ */
573
+ get questionId() {
574
+ return utils.getUint32(0, this);
575
+ }
576
+ set questionId(value) {
577
+ utils.setUint32(0, value, this);
578
+ }
579
+ _adoptDeprecatedObjectId(value) {
580
+ utils.adopt(value, utils.getPointer(0, this));
581
+ }
582
+ _disownDeprecatedObjectId() {
583
+ return utils.disown(this.deprecatedObjectId);
584
+ }
585
+ /**
586
+ * ** DEPRECATED **
587
+ *
588
+ * A Vat may export multiple bootstrap interfaces. In this case, `deprecatedObjectId` specifies
589
+ * which one to return. If this pointer is null, then the default bootstrap interface is returned.
590
+ *
591
+ * As of version 0.5, use of this field is deprecated. If a service wants to export multiple
592
+ * bootstrap interfaces, it should instead define a single bootstrap interface that has methods
593
+ * that return each of the other interfaces.
594
+ *
595
+ * **History**
596
+ *
597
+ * In the first version of Cap'n Proto RPC (0.4.x) the `Bootstrap` message was called `Restore`.
598
+ * At the time, it was thought that this would eventually serve as the way to restore SturdyRefs
599
+ * (level 2). Meanwhile, an application could offer its "main" interface on a well-known
600
+ * (non-secret) SturdyRef.
601
+ *
602
+ * Since level 2 RPC was not implemented at the time, the `Restore` message was in practice only
603
+ * used to obtain the main interface. Since most applications had only one main interface that
604
+ * they wanted to restore, they tended to designate this with a null `objectId`.
605
+ *
606
+ * Unfortunately, the earliest version of the EZ RPC interfaces set a precedent of exporting
607
+ * multiple main interfaces by allowing them to be exported under string names. In this case,
608
+ * `objectId` was a Text value specifying the name.
609
+ *
610
+ * All of this proved problematic for several reasons:
611
+ *
612
+ * - The arrangement assumed that a client wishing to restore a SturdyRef would know exactly what
613
+ * machine to connect to and would be able to immediately restore a SturdyRef on connection.
614
+ * However, in practice, the ability to restore SturdyRefs is itself a capability that may
615
+ * require going through an authentication process to obtain. Thus, it makes more sense to
616
+ * define a "restorer service" as a full Cap'n Proto interface. If this restorer interface is
617
+ * offered as the vat's bootstrap interface, then this is equivalent to the old arrangement.
618
+ *
619
+ * - Overloading "Restore" for the purpose of obtaining well-known capabilities encouraged the
620
+ * practice of exporting singleton services with string names. If singleton services are desired,
621
+ * it is better to have one main interface that has methods that can be used to obtain each
622
+ * service, in order to get all the usual benefits of schemas and type checking.
623
+ *
624
+ * - Overloading "Restore" also had a security problem: Often, "main" or "well-known"
625
+ * capabilities exported by a vat are in fact not public: they are intended to be accessed only
626
+ * by clients who are capable of forming a connection to the vat. This can lead to trouble if
627
+ * the client itself has other clients and wishes to forward some `Restore` requests from those
628
+ * external clients -- it has to be very careful not to allow through `Restore` requests
629
+ * addressing the default capability.
630
+ *
631
+ * For example, consider the case of a sandboxed Sandstorm application and its supervisor. The
632
+ * application exports a default capability to its supervisor that provides access to
633
+ * functionality that only the supervisor is supposed to access. Meanwhile, though, applications
634
+ * may publish other capabilities that may be persistent, in which case the application needs
635
+ * to field `Restore` requests that could come from anywhere. These requests of course have to
636
+ * pass through the supervisor, as all communications with the outside world must. But, the
637
+ * supervisor has to be careful not to honor an external request addressing the application's
638
+ * default capability, since this capability is privileged. Unfortunately, the default
639
+ * capability cannot be given an unguessable name, because then the supervisor itself would not
640
+ * be able to address it!
641
+ *
642
+ * As of Cap'n Proto 0.5, `Restore` has been renamed to `Bootstrap` and is no longer planned for
643
+ * use in restoring SturdyRefs.
644
+ *
645
+ * Note that 0.4 also defined a message type called `Delete` that, like `Restore`, addressed a
646
+ * SturdyRef, but indicated that the client would not restore the ref again in the future. This
647
+ * operation was never implemented, so it was removed entirely. If a "delete" operation is desired,
648
+ * it should exist as a method on the same interface that handles restoring SturdyRefs. However,
649
+ * the utility of such an operation is questionable. You wouldn't be able to rely on it for
650
+ * garbage collection since a client could always disappear permanently without remembering to
651
+ * delete all its SturdyRefs, thus leaving them dangling forever. Therefore, it is advisable to
652
+ * design systems such that SturdyRefs never represent "owned" pointers.
653
+ *
654
+ * For example, say a SturdyRef points to an image file hosted on some server. That image file
655
+ * should also live inside a collection (a gallery, perhaps) hosted on the same server, owned by
656
+ * a user who can delete the image at any time. If the user deletes the image, the SturdyRef
657
+ * stops working. On the other hand, if the SturdyRef is discarded, this has no effect on the
658
+ * existence of the image in its collection.
659
+ *
660
+ */
661
+ get deprecatedObjectId() {
662
+ return utils.getPointer(0, this);
663
+ }
664
+ _hasDeprecatedObjectId() {
665
+ return !utils.isNull(utils.getPointer(0, this));
666
+ }
667
+ set deprecatedObjectId(value) {
668
+ utils.copyFrom(value, utils.getPointer(0, this));
669
+ }
670
+ toString() {
671
+ return "Bootstrap_" + super.toString();
672
+ }
673
+ };
674
+ var Call_SendResultsTo_Which = {
675
+ /**
676
+ * Send the return message back to the caller (the usual).
677
+ *
678
+ */
679
+ CALLER: 0,
680
+ /**
681
+ * **(level 1)**
682
+ *
683
+ * Don't actually return the results to the sender. Instead, hold on to them and await
684
+ * instructions from the sender regarding what to do with them. In particular, the sender
685
+ * may subsequently send a `Return` for some other call (which the receiver had previously made
686
+ * to the sender) with `takeFromOtherQuestion` set. The results from this call are then used
687
+ * as the results of the other call.
688
+ *
689
+ * When `yourself` is used, the receiver must still send a `Return` for the call, but sets the
690
+ * field `resultsSentElsewhere` in that `Return` rather than including the results.
691
+ *
692
+ * This feature can be used to implement tail calls in which a call from Vat A to Vat B ends up
693
+ * returning the result of a call from Vat B back to Vat A.
694
+ *
695
+ * In particular, the most common use case for this feature is when Vat A makes a call to a
696
+ * promise in Vat B, and then that promise ends up resolving to a capability back in Vat A.
697
+ * Vat B must forward all the queued calls on that promise back to Vat A, but can set `yourself`
698
+ * in the calls so that the results need not pass back through Vat B.
699
+ *
700
+ * For example:
701
+ * - Alice, in Vat A, calls foo() on Bob in Vat B.
702
+ * - Alice makes a pipelined call bar() on the promise returned by foo().
703
+ * - Later on, Bob resolves the promise from foo() to point at Carol, who lives in Vat A (next
704
+ * to Alice).
705
+ * - Vat B dutifully forwards the bar() call to Carol. Let us call this forwarded call bar'().
706
+ * Notice that bar() and bar'() are travelling in opposite directions on the same network
707
+ * link.
708
+ * - The `Call` for bar'() has `sendResultsTo` set to `yourself`.
709
+ * - Vat B sends a `Return` for bar() with `takeFromOtherQuestion` set in place of the results,
710
+ * with the value set to the question ID of bar'(). Vat B does not wait for bar'() to return,
711
+ * as doing so would introduce unnecessary round trip latency.
712
+ * - Vat A receives bar'() and delivers it to Carol.
713
+ * - When bar'() returns, Vat A sends a `Return` for bar'() to Vat B, with `resultsSentElsewhere`
714
+ * set in place of results.
715
+ * - Vat A sends a `Finish` for the bar() call to Vat B.
716
+ * - Vat B receives the `Finish` for bar() and sends a `Finish` for bar'().
717
+ *
718
+ */
719
+ YOURSELF: 1,
720
+ /**
721
+ * **(level 3)**
722
+ *
723
+ * The call's result should be returned to a different vat. The receiver (the callee) expects
724
+ * to receive an `Accept` message from the indicated vat, and should return the call's result
725
+ * to it, rather than to the sender of the `Call`.
726
+ *
727
+ * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
728
+ * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
729
+ * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
730
+ * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
731
+ * also sends a `Return` to Vat B with `resultsSentElsewhere`.
732
+ *
733
+ */
734
+ THIRD_PARTY: 2
735
+ };
736
+ var Call_SendResultsTo = class extends Struct {
737
+ static {
738
+ __name(this, "Call_SendResultsTo");
739
+ }
740
+ static CALLER = Call_SendResultsTo_Which.CALLER;
741
+ static YOURSELF = Call_SendResultsTo_Which.YOURSELF;
742
+ static THIRD_PARTY = Call_SendResultsTo_Which.THIRD_PARTY;
743
+ static _capnp = {
744
+ displayName: "sendResultsTo",
745
+ id: "dae8b0f61aab5f99",
746
+ size: new ObjectSize(24, 3)
747
+ };
748
+ get _isCaller() {
749
+ return utils.getUint16(6, this) === 0;
750
+ }
751
+ set caller(_) {
752
+ utils.setUint16(6, 0, this);
753
+ }
754
+ get _isYourself() {
755
+ return utils.getUint16(6, this) === 1;
756
+ }
757
+ set yourself(_) {
758
+ utils.setUint16(6, 1, this);
759
+ }
760
+ _adoptThirdParty(value) {
761
+ utils.setUint16(6, 2, this);
762
+ utils.adopt(value, utils.getPointer(2, this));
763
+ }
764
+ _disownThirdParty() {
765
+ return utils.disown(this.thirdParty);
766
+ }
767
+ /**
768
+ * **(level 3)**
769
+ *
770
+ * The call's result should be returned to a different vat. The receiver (the callee) expects
771
+ * to receive an `Accept` message from the indicated vat, and should return the call's result
772
+ * to it, rather than to the sender of the `Call`.
773
+ *
774
+ * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
775
+ * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
776
+ * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
777
+ * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
778
+ * also sends a `Return` to Vat B with `resultsSentElsewhere`.
779
+ *
780
+ */
781
+ get thirdParty() {
782
+ utils.testWhich("thirdParty", utils.getUint16(6, this), 2, this);
783
+ return utils.getPointer(2, this);
784
+ }
785
+ _hasThirdParty() {
786
+ return !utils.isNull(utils.getPointer(2, this));
787
+ }
788
+ get _isThirdParty() {
789
+ return utils.getUint16(6, this) === 2;
790
+ }
791
+ set thirdParty(value) {
792
+ utils.setUint16(6, 2, this);
793
+ utils.copyFrom(value, utils.getPointer(2, this));
794
+ }
795
+ toString() {
796
+ return "Call_SendResultsTo_" + super.toString();
797
+ }
798
+ which() {
799
+ return utils.getUint16(6, this);
800
+ }
801
+ };
802
+ var Call = class _Call extends Struct {
803
+ static {
804
+ __name(this, "Call");
805
+ }
806
+ static _capnp = {
807
+ displayName: "Call",
808
+ id: "836a53ce789d4cd4",
809
+ size: new ObjectSize(24, 3),
810
+ defaultAllowThirdPartyTailCall: getBitMask(false, 0),
811
+ defaultNoPromisePipelining: getBitMask(false, 1),
812
+ defaultOnlyPromisePipeline: getBitMask(false, 2)
813
+ };
814
+ /**
815
+ * A number, chosen by the caller, that identifies this call in future messages. This number
816
+ * must be different from all other calls originating from the same end of the connection (but
817
+ * may overlap with question IDs originating from the opposite end). A fine strategy is to use
818
+ * sequential question IDs, but the recipient should not assume this.
819
+ *
820
+ * A question ID can be reused once both:
821
+ * - A matching Return has been received from the callee.
822
+ * - A matching Finish has been sent from the caller.
823
+ *
824
+ */
825
+ get questionId() {
826
+ return utils.getUint32(0, this);
827
+ }
828
+ set questionId(value) {
829
+ utils.setUint32(0, value, this);
830
+ }
831
+ _adoptTarget(value) {
832
+ utils.adopt(value, utils.getPointer(0, this));
833
+ }
834
+ _disownTarget() {
835
+ return utils.disown(this.target);
836
+ }
837
+ /**
838
+ * The object that should receive this call.
839
+ *
840
+ */
841
+ get target() {
842
+ return utils.getStruct(0, MessageTarget, this);
843
+ }
844
+ _hasTarget() {
845
+ return !utils.isNull(utils.getPointer(0, this));
846
+ }
847
+ _initTarget() {
848
+ return utils.initStructAt(0, MessageTarget, this);
849
+ }
850
+ set target(value) {
851
+ utils.copyFrom(value, utils.getPointer(0, this));
852
+ }
853
+ /**
854
+ * The type ID of the interface being called. Each capability may implement multiple interfaces.
855
+ *
856
+ */
857
+ get interfaceId() {
858
+ return utils.getUint64(8, this);
859
+ }
860
+ set interfaceId(value) {
861
+ utils.setUint64(8, value, this);
862
+ }
863
+ /**
864
+ * The ordinal number of the method to call within the requested interface.
865
+ *
866
+ */
867
+ get methodId() {
868
+ return utils.getUint16(4, this);
869
+ }
870
+ set methodId(value) {
871
+ utils.setUint16(4, value, this);
872
+ }
873
+ /**
874
+ * Indicates whether or not the receiver is allowed to send a `Return` containing
875
+ * `acceptFromThirdParty`. Level 3 implementations should set this true. Otherwise, the callee
876
+ * will have to proxy the return in the case of a tail call to a third-party vat.
877
+ *
878
+ */
879
+ get allowThirdPartyTailCall() {
880
+ return utils.getBit(128, this, _Call._capnp.defaultAllowThirdPartyTailCall);
881
+ }
882
+ set allowThirdPartyTailCall(value) {
883
+ utils.setBit(128, value, this, _Call._capnp.defaultAllowThirdPartyTailCall);
884
+ }
885
+ /**
886
+ * If true, the sender promises that it won't make any promise-pipelined calls on the results of
887
+ * this call. If it breaks this promise, the receiver may throw an arbitrary error from such
888
+ * calls.
889
+ *
890
+ * The receiver may use this as an optimization, by skipping the bookkeeping needed for pipelining
891
+ * when no pipelined calls are expected. The sender typically sets this to false when the method's
892
+ * schema does not specify any return capabilities.
893
+ *
894
+ */
895
+ get noPromisePipelining() {
896
+ return utils.getBit(129, this, _Call._capnp.defaultNoPromisePipelining);
897
+ }
898
+ set noPromisePipelining(value) {
899
+ utils.setBit(129, value, this, _Call._capnp.defaultNoPromisePipelining);
900
+ }
901
+ /**
902
+ * If true, the sender only plans to use this call to make pipelined calls. The receiver need not
903
+ * send a `Return` message (but is still allowed to do so).
904
+ *
905
+ * Since the sender does not know whether a `Return` will be sent, it must release all state
906
+ * related to the call when it sends `Finish`. However, in the case that the callee does not
907
+ * recognize this hint and chooses to send a `Return`, then technically the caller is not allowed
908
+ * to reuse the question ID until it receives said `Return`. This creates a conundrum: How does
909
+ * the caller decide when it's OK to reuse the ID? To sidestep the problem, the C++ implementation
910
+ * uses high-numbered IDs (with the high-order bit set) for such calls, and cycles through the
911
+ * IDs in order. If all 2^31 IDs in this space are used without ever seeing a `Return`, then the
912
+ * implementation assumes that the other end is in fact honoring the hint, and the ID counter is
913
+ * allowed to loop around. If a `Return` is ever seen when `onlyPromisePipeline` was set, then
914
+ * the implementation stops using this hint.
915
+ *
916
+ */
917
+ get onlyPromisePipeline() {
918
+ return utils.getBit(130, this, _Call._capnp.defaultOnlyPromisePipeline);
919
+ }
920
+ set onlyPromisePipeline(value) {
921
+ utils.setBit(130, value, this, _Call._capnp.defaultOnlyPromisePipeline);
922
+ }
923
+ _adoptParams(value) {
924
+ utils.adopt(value, utils.getPointer(1, this));
925
+ }
926
+ _disownParams() {
927
+ return utils.disown(this.params);
928
+ }
929
+ /**
930
+ * The call parameters. `params.content` is a struct whose fields correspond to the parameters of
931
+ * the method.
932
+ *
933
+ */
934
+ get params() {
935
+ return utils.getStruct(1, Payload, this);
936
+ }
937
+ _hasParams() {
938
+ return !utils.isNull(utils.getPointer(1, this));
939
+ }
940
+ _initParams() {
941
+ return utils.initStructAt(1, Payload, this);
942
+ }
943
+ set params(value) {
944
+ utils.copyFrom(value, utils.getPointer(1, this));
945
+ }
946
+ /**
947
+ * Where should the return message be sent?
948
+ *
949
+ */
950
+ get sendResultsTo() {
951
+ return utils.getAs(Call_SendResultsTo, this);
952
+ }
953
+ _initSendResultsTo() {
954
+ return utils.getAs(Call_SendResultsTo, this);
955
+ }
956
+ toString() {
957
+ return "Call_" + super.toString();
958
+ }
959
+ };
960
+ var Return_Which = {
961
+ /**
962
+ * Equal to the QuestionId of the corresponding `Call` message.
963
+ *
964
+ */
965
+ RESULTS: 0,
966
+ /**
967
+ * If true, all capabilities that were in the params should be considered released. The sender
968
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
969
+ * should always set this true. This defaults true because if level 0 implementations forget to
970
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
971
+ * to set it to false they'll quickly get errors.
972
+ *
973
+ * The receiver should act as if the sender had sent a release message with count=1 for each
974
+ * CapDescriptor in the original Call message.
975
+ *
976
+ */
977
+ EXCEPTION: 1,
978
+ /**
979
+ * The result.
980
+ *
981
+ * For regular method calls, `results.content` points to the result struct.
982
+ *
983
+ * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
984
+ * capability (rather than a struct), and `results.content` is just a capability pointer with
985
+ * index 0. A `Finish` is still required in this case.
986
+ *
987
+ */
988
+ CANCELED: 2,
989
+ /**
990
+ * Indicates that the call failed and explains why.
991
+ *
992
+ */
993
+ RESULTS_SENT_ELSEWHERE: 3,
994
+ /**
995
+ * Indicates that the call was canceled due to the caller sending a Finish message
996
+ * before the call had completed.
997
+ *
998
+ */
999
+ TAKE_FROM_OTHER_QUESTION: 4,
1000
+ /**
1001
+ * This is set when returning from a `Call` that had `sendResultsTo` set to something other
1002
+ * than `caller`.
1003
+ *
1004
+ * It doesn't matter too much when this is sent, as the receiver doesn't need to do anything
1005
+ * with it, but the C++ implementation appears to wait for the call to finish before sending
1006
+ * this.
1007
+ *
1008
+ */
1009
+ ACCEPT_FROM_THIRD_PARTY: 5
1010
+ };
1011
+ var Return = class _Return extends Struct {
1012
+ static {
1013
+ __name(this, "Return");
1014
+ }
1015
+ static RESULTS = Return_Which.RESULTS;
1016
+ static EXCEPTION = Return_Which.EXCEPTION;
1017
+ static CANCELED = Return_Which.CANCELED;
1018
+ static RESULTS_SENT_ELSEWHERE = Return_Which.RESULTS_SENT_ELSEWHERE;
1019
+ static TAKE_FROM_OTHER_QUESTION = Return_Which.TAKE_FROM_OTHER_QUESTION;
1020
+ static ACCEPT_FROM_THIRD_PARTY = Return_Which.ACCEPT_FROM_THIRD_PARTY;
1021
+ static _capnp = {
1022
+ displayName: "Return",
1023
+ id: "9e19b28d3db3573a",
1024
+ size: new ObjectSize(16, 1),
1025
+ defaultReleaseParamCaps: getBitMask(true, 0),
1026
+ defaultNoFinishNeeded: getBitMask(false, 1)
1027
+ };
1028
+ /**
1029
+ * Equal to the QuestionId of the corresponding `Call` message.
1030
+ *
1031
+ */
1032
+ get answerId() {
1033
+ return utils.getUint32(0, this);
1034
+ }
1035
+ set answerId(value) {
1036
+ utils.setUint32(0, value, this);
1037
+ }
1038
+ /**
1039
+ * If true, all capabilities that were in the params should be considered released. The sender
1040
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
1041
+ * should always set this true. This defaults true because if level 0 implementations forget to
1042
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
1043
+ * to set it to false they'll quickly get errors.
1044
+ *
1045
+ * The receiver should act as if the sender had sent a release message with count=1 for each
1046
+ * CapDescriptor in the original Call message.
1047
+ *
1048
+ */
1049
+ get releaseParamCaps() {
1050
+ return utils.getBit(32, this, _Return._capnp.defaultReleaseParamCaps);
1051
+ }
1052
+ set releaseParamCaps(value) {
1053
+ utils.setBit(32, value, this, _Return._capnp.defaultReleaseParamCaps);
1054
+ }
1055
+ /**
1056
+ * If true, the sender does not need the receiver to send a `Finish` message; its answer table
1057
+ * entry has already been cleaned up. This implies that the results do not contain any
1058
+ * capabilities, since the `Finish` message would normally release those capabilities from
1059
+ * promise pipelining responsibility. The caller may still send a `Finish` message if it wants,
1060
+ * which will be silently ignored by the callee.
1061
+ *
1062
+ */
1063
+ get noFinishNeeded() {
1064
+ return utils.getBit(33, this, _Return._capnp.defaultNoFinishNeeded);
1065
+ }
1066
+ set noFinishNeeded(value) {
1067
+ utils.setBit(33, value, this, _Return._capnp.defaultNoFinishNeeded);
1068
+ }
1069
+ _adoptResults(value) {
1070
+ utils.setUint16(6, 0, this);
1071
+ utils.adopt(value, utils.getPointer(0, this));
1072
+ }
1073
+ _disownResults() {
1074
+ return utils.disown(this.results);
1075
+ }
1076
+ /**
1077
+ * The result.
1078
+ *
1079
+ * For regular method calls, `results.content` points to the result struct.
1080
+ *
1081
+ * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
1082
+ * capability (rather than a struct), and `results.content` is just a capability pointer with
1083
+ * index 0. A `Finish` is still required in this case.
1084
+ *
1085
+ */
1086
+ get results() {
1087
+ utils.testWhich("results", utils.getUint16(6, this), 0, this);
1088
+ return utils.getStruct(0, Payload, this);
1089
+ }
1090
+ _hasResults() {
1091
+ return !utils.isNull(utils.getPointer(0, this));
1092
+ }
1093
+ _initResults() {
1094
+ utils.setUint16(6, 0, this);
1095
+ return utils.initStructAt(0, Payload, this);
1096
+ }
1097
+ get _isResults() {
1098
+ return utils.getUint16(6, this) === 0;
1099
+ }
1100
+ set results(value) {
1101
+ utils.setUint16(6, 0, this);
1102
+ utils.copyFrom(value, utils.getPointer(0, this));
1103
+ }
1104
+ _adoptException(value) {
1105
+ utils.setUint16(6, 1, this);
1106
+ utils.adopt(value, utils.getPointer(0, this));
1107
+ }
1108
+ _disownException() {
1109
+ return utils.disown(this.exception);
1110
+ }
1111
+ /**
1112
+ * Indicates that the call failed and explains why.
1113
+ *
1114
+ */
1115
+ get exception() {
1116
+ utils.testWhich("exception", utils.getUint16(6, this), 1, this);
1117
+ return utils.getStruct(0, Exception, this);
1118
+ }
1119
+ _hasException() {
1120
+ return !utils.isNull(utils.getPointer(0, this));
1121
+ }
1122
+ _initException() {
1123
+ utils.setUint16(6, 1, this);
1124
+ return utils.initStructAt(0, Exception, this);
1125
+ }
1126
+ get _isException() {
1127
+ return utils.getUint16(6, this) === 1;
1128
+ }
1129
+ set exception(value) {
1130
+ utils.setUint16(6, 1, this);
1131
+ utils.copyFrom(value, utils.getPointer(0, this));
1132
+ }
1133
+ get _isCanceled() {
1134
+ return utils.getUint16(6, this) === 2;
1135
+ }
1136
+ set canceled(_) {
1137
+ utils.setUint16(6, 2, this);
1138
+ }
1139
+ get _isResultsSentElsewhere() {
1140
+ return utils.getUint16(6, this) === 3;
1141
+ }
1142
+ set resultsSentElsewhere(_) {
1143
+ utils.setUint16(6, 3, this);
1144
+ }
1145
+ /**
1146
+ * The sender has also sent (before this message) a `Call` with the given question ID and with
1147
+ * `sendResultsTo.yourself` set, and the results of that other call should be used as the
1148
+ * results here. `takeFromOtherQuestion` can only used once per question.
1149
+ *
1150
+ */
1151
+ get takeFromOtherQuestion() {
1152
+ utils.testWhich("takeFromOtherQuestion", utils.getUint16(6, this), 4, this);
1153
+ return utils.getUint32(8, this);
1154
+ }
1155
+ get _isTakeFromOtherQuestion() {
1156
+ return utils.getUint16(6, this) === 4;
1157
+ }
1158
+ set takeFromOtherQuestion(value) {
1159
+ utils.setUint16(6, 4, this);
1160
+ utils.setUint32(8, value, this);
1161
+ }
1162
+ _adoptAcceptFromThirdParty(value) {
1163
+ utils.setUint16(6, 5, this);
1164
+ utils.adopt(value, utils.getPointer(0, this));
1165
+ }
1166
+ _disownAcceptFromThirdParty() {
1167
+ return utils.disown(this.acceptFromThirdParty);
1168
+ }
1169
+ /**
1170
+ * **(level 3)**
1171
+ *
1172
+ * The caller should contact a third-party vat to pick up the results. An `Accept` message
1173
+ * sent to the vat will return the result. This pairs with `Call.sendResultsTo.thirdParty`.
1174
+ * It should only be used if the corresponding `Call` had `allowThirdPartyTailCall` set.
1175
+ *
1176
+ */
1177
+ get acceptFromThirdParty() {
1178
+ utils.testWhich("acceptFromThirdParty", utils.getUint16(6, this), 5, this);
1179
+ return utils.getPointer(0, this);
1180
+ }
1181
+ _hasAcceptFromThirdParty() {
1182
+ return !utils.isNull(utils.getPointer(0, this));
1183
+ }
1184
+ get _isAcceptFromThirdParty() {
1185
+ return utils.getUint16(6, this) === 5;
1186
+ }
1187
+ set acceptFromThirdParty(value) {
1188
+ utils.setUint16(6, 5, this);
1189
+ utils.copyFrom(value, utils.getPointer(0, this));
1190
+ }
1191
+ toString() {
1192
+ return "Return_" + super.toString();
1193
+ }
1194
+ which() {
1195
+ return utils.getUint16(6, this);
1196
+ }
1197
+ };
1198
+ var Finish = class _Finish extends Struct {
1199
+ static {
1200
+ __name(this, "Finish");
1201
+ }
1202
+ static _capnp = {
1203
+ displayName: "Finish",
1204
+ id: "d37d2eb2c2f80e63",
1205
+ size: new ObjectSize(8, 0),
1206
+ defaultReleaseResultCaps: getBitMask(true, 0),
1207
+ defaultRequireEarlyCancellationWorkaround: getBitMask(true, 1)
1208
+ };
1209
+ /**
1210
+ * ID of the call whose result is to be released.
1211
+ *
1212
+ */
1213
+ get questionId() {
1214
+ return utils.getUint32(0, this);
1215
+ }
1216
+ set questionId(value) {
1217
+ utils.setUint32(0, value, this);
1218
+ }
1219
+ /**
1220
+ * If true, all capabilities that were in the results should be considered released. The sender
1221
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
1222
+ * should always set this true. This defaults true because if level 0 implementations forget to
1223
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
1224
+ * set it false they'll quickly get errors.
1225
+ *
1226
+ */
1227
+ get releaseResultCaps() {
1228
+ return utils.getBit(32, this, _Finish._capnp.defaultReleaseResultCaps);
1229
+ }
1230
+ set releaseResultCaps(value) {
1231
+ utils.setBit(32, value, this, _Finish._capnp.defaultReleaseResultCaps);
1232
+ }
1233
+ /**
1234
+ * If true, if the RPC system receives this Finish message before the original call has even been
1235
+ * delivered, it should defer cancellation util after delivery. In particular, this gives the
1236
+ * destination object a chance to opt out of cancellation, e.g. as controlled by the
1237
+ * `allowCancellation` annotation defined in `c++.capnp`.
1238
+ *
1239
+ * This is a work-around. Versions 1.0 and up of Cap'n Proto always set this to false. However,
1240
+ * older versions of Cap'n Proto unintentionally exhibited this errant behavior by default, and
1241
+ * as a result programs built with older versions could be inadvertently relying on their peers
1242
+ * to implement the behavior. The purpose of this flag is to let newer versions know when the
1243
+ * peer is an older version, so that it can attempt to work around the issue.
1244
+ *
1245
+ * See also comments in handleFinish() in rpc.c++ for more details.
1246
+ *
1247
+ */
1248
+ get requireEarlyCancellationWorkaround() {
1249
+ return utils.getBit(33, this, _Finish._capnp.defaultRequireEarlyCancellationWorkaround);
1250
+ }
1251
+ set requireEarlyCancellationWorkaround(value) {
1252
+ utils.setBit(33, value, this, _Finish._capnp.defaultRequireEarlyCancellationWorkaround);
1253
+ }
1254
+ toString() {
1255
+ return "Finish_" + super.toString();
1256
+ }
1257
+ };
1258
+ var Resolve_Which = {
1259
+ /**
1260
+ * The ID of the promise to be resolved.
1261
+ *
1262
+ * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
1263
+ * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
1264
+ * will release the export soon after receiving `Resolve`, and the sender will not send this
1265
+ * `ExportId` again until it has been released and recycled.
1266
+ *
1267
+ * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
1268
+ * this indicates that the sender will follow up at some point with a `Resolve` message. If the
1269
+ * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
1270
+ * same ID is sent again later _after_ a `Resolve`, it can only be because the export's
1271
+ * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
1272
+ * this later promise does _not_ correspond to the earlier `Resolve`.
1273
+ *
1274
+ * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
1275
+ * message may or may not still be sent (the `Resolve` may have already been in-flight when
1276
+ * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
1277
+ * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
1278
+ * the receiver has no knowledge, because it already released it earlier. In this case, the
1279
+ * receiver should simply release the capability to which the promise resolved.
1280
+ *
1281
+ */
1282
+ CAP: 0,
1283
+ /**
1284
+ * The object to which the promise resolved.
1285
+ *
1286
+ * The sender promises that from this point forth, until `promiseId` is released, it shall
1287
+ * simply forward all messages to the capability designated by `cap`. This is true even if
1288
+ * `cap` itself happens to designate another promise, and that other promise later resolves --
1289
+ * messages sent to `promiseId` shall still go to that other promise, not to its resolution.
1290
+ * This is important in the case that the receiver of the `Resolve` ends up sending a
1291
+ * `Disembargo` message towards `promiseId` in order to control message ordering -- that
1292
+ * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
1293
+ * if that object is itself a promise.
1294
+ *
1295
+ */
1296
+ EXCEPTION: 1
1297
+ };
1298
+ var Resolve = class extends Struct {
1299
+ static {
1300
+ __name(this, "Resolve");
1301
+ }
1302
+ static CAP = Resolve_Which.CAP;
1303
+ static EXCEPTION = Resolve_Which.EXCEPTION;
1304
+ static _capnp = {
1305
+ displayName: "Resolve",
1306
+ id: "bbc29655fa89086e",
1307
+ size: new ObjectSize(8, 1)
1308
+ };
1309
+ /**
1310
+ * The ID of the promise to be resolved.
1311
+ *
1312
+ * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
1313
+ * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
1314
+ * will release the export soon after receiving `Resolve`, and the sender will not send this
1315
+ * `ExportId` again until it has been released and recycled.
1316
+ *
1317
+ * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
1318
+ * this indicates that the sender will follow up at some point with a `Resolve` message. If the
1319
+ * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
1320
+ * same ID is sent again later _after_ a `Resolve`, it can only be because the export's
1321
+ * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
1322
+ * this later promise does _not_ correspond to the earlier `Resolve`.
1323
+ *
1324
+ * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
1325
+ * message may or may not still be sent (the `Resolve` may have already been in-flight when
1326
+ * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
1327
+ * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
1328
+ * the receiver has no knowledge, because it already released it earlier. In this case, the
1329
+ * receiver should simply release the capability to which the promise resolved.
1330
+ *
1331
+ */
1332
+ get promiseId() {
1333
+ return utils.getUint32(0, this);
1334
+ }
1335
+ set promiseId(value) {
1336
+ utils.setUint32(0, value, this);
1337
+ }
1338
+ _adoptCap(value) {
1339
+ utils.setUint16(4, 0, this);
1340
+ utils.adopt(value, utils.getPointer(0, this));
1341
+ }
1342
+ _disownCap() {
1343
+ return utils.disown(this.cap);
1344
+ }
1345
+ /**
1346
+ * The object to which the promise resolved.
1347
+ *
1348
+ * The sender promises that from this point forth, until `promiseId` is released, it shall
1349
+ * simply forward all messages to the capability designated by `cap`. This is true even if
1350
+ * `cap` itself happens to designate another promise, and that other promise later resolves --
1351
+ * messages sent to `promiseId` shall still go to that other promise, not to its resolution.
1352
+ * This is important in the case that the receiver of the `Resolve` ends up sending a
1353
+ * `Disembargo` message towards `promiseId` in order to control message ordering -- that
1354
+ * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
1355
+ * if that object is itself a promise.
1356
+ *
1357
+ */
1358
+ get cap() {
1359
+ utils.testWhich("cap", utils.getUint16(4, this), 0, this);
1360
+ return utils.getStruct(0, CapDescriptor, this);
1361
+ }
1362
+ _hasCap() {
1363
+ return !utils.isNull(utils.getPointer(0, this));
1364
+ }
1365
+ _initCap() {
1366
+ utils.setUint16(4, 0, this);
1367
+ return utils.initStructAt(0, CapDescriptor, this);
1368
+ }
1369
+ get _isCap() {
1370
+ return utils.getUint16(4, this) === 0;
1371
+ }
1372
+ set cap(value) {
1373
+ utils.setUint16(4, 0, this);
1374
+ utils.copyFrom(value, utils.getPointer(0, this));
1375
+ }
1376
+ _adoptException(value) {
1377
+ utils.setUint16(4, 1, this);
1378
+ utils.adopt(value, utils.getPointer(0, this));
1379
+ }
1380
+ _disownException() {
1381
+ return utils.disown(this.exception);
1382
+ }
1383
+ /**
1384
+ * Indicates that the promise was broken.
1385
+ *
1386
+ */
1387
+ get exception() {
1388
+ utils.testWhich("exception", utils.getUint16(4, this), 1, this);
1389
+ return utils.getStruct(0, Exception, this);
1390
+ }
1391
+ _hasException() {
1392
+ return !utils.isNull(utils.getPointer(0, this));
1393
+ }
1394
+ _initException() {
1395
+ utils.setUint16(4, 1, this);
1396
+ return utils.initStructAt(0, Exception, this);
1397
+ }
1398
+ get _isException() {
1399
+ return utils.getUint16(4, this) === 1;
1400
+ }
1401
+ set exception(value) {
1402
+ utils.setUint16(4, 1, this);
1403
+ utils.copyFrom(value, utils.getPointer(0, this));
1404
+ }
1405
+ toString() {
1406
+ return "Resolve_" + super.toString();
1407
+ }
1408
+ which() {
1409
+ return utils.getUint16(4, this);
1410
+ }
1411
+ };
1412
+ var Release = class extends Struct {
1413
+ static {
1414
+ __name(this, "Release");
1415
+ }
1416
+ static _capnp = {
1417
+ displayName: "Release",
1418
+ id: "ad1a6c0d7dd07497",
1419
+ size: new ObjectSize(8, 0)
1420
+ };
1421
+ /**
1422
+ * What to release.
1423
+ *
1424
+ */
1425
+ get id() {
1426
+ return utils.getUint32(0, this);
1427
+ }
1428
+ set id(value) {
1429
+ utils.setUint32(0, value, this);
1430
+ }
1431
+ /**
1432
+ * The amount by which to decrement the reference count. The export is only actually released
1433
+ * when the reference count reaches zero.
1434
+ *
1435
+ */
1436
+ get referenceCount() {
1437
+ return utils.getUint32(4, this);
1438
+ }
1439
+ set referenceCount(value) {
1440
+ utils.setUint32(4, value, this);
1441
+ }
1442
+ toString() {
1443
+ return "Release_" + super.toString();
1444
+ }
1445
+ };
1446
+ var Disembargo_Context_Which = {
1447
+ /**
1448
+ * The sender is requesting a disembargo on a promise that is known to resolve back to a
1449
+ * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
1450
+ * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
1451
+ * set to the same value as `senderLoopback`. This value is chosen by the sender, and since
1452
+ * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
1453
+ * the value is unambiguous.
1454
+ *
1455
+ * The receiver must verify that the target capability actually resolves back to the sender's
1456
+ * vat. Otherwise, the sender has committed a protocol error and should be disconnected.
1457
+ *
1458
+ */
1459
+ SENDER_LOOPBACK: 0,
1460
+ /**
1461
+ * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
1462
+ * this capability, and that Disembargo is now being echoed back.
1463
+ *
1464
+ */
1465
+ RECEIVER_LOOPBACK: 1,
1466
+ /**
1467
+ * **(level 3)**
1468
+ *
1469
+ * The sender is requesting a disembargo on a promise that is known to resolve to a third-party
1470
+ * capability that the sender is currently in the process of accepting (using `Accept`).
1471
+ * The receiver of this `Disembargo` has an outstanding `Provide` on said capability. The
1472
+ * receiver should now send a `Disembargo` with `provide` set to the question ID of that
1473
+ * `Provide` message.
1474
+ *
1475
+ * See `Accept.embargo` for an example.
1476
+ *
1477
+ */
1478
+ ACCEPT: 2,
1479
+ /**
1480
+ * **(level 3)**
1481
+ *
1482
+ * The sender is requesting a disembargo on a capability currently being provided to a third
1483
+ * party. The question ID identifies the `Provide` message previously sent by the sender to
1484
+ * this capability. On receipt, the receiver (the capability host) shall release the embargo
1485
+ * on the `Accept` message that it has received from the third party. See `Accept.embargo` for
1486
+ * an example.
1487
+ *
1488
+ */
1489
+ PROVIDE: 3
1490
+ };
1491
+ var Disembargo_Context = class extends Struct {
1492
+ static {
1493
+ __name(this, "Disembargo_Context");
1494
+ }
1495
+ static SENDER_LOOPBACK = Disembargo_Context_Which.SENDER_LOOPBACK;
1496
+ static RECEIVER_LOOPBACK = Disembargo_Context_Which.RECEIVER_LOOPBACK;
1497
+ static ACCEPT = Disembargo_Context_Which.ACCEPT;
1498
+ static PROVIDE = Disembargo_Context_Which.PROVIDE;
1499
+ static _capnp = {
1500
+ displayName: "context",
1501
+ id: "d562b4df655bdd4d",
1502
+ size: new ObjectSize(8, 1)
1503
+ };
1504
+ /**
1505
+ * The sender is requesting a disembargo on a promise that is known to resolve back to a
1506
+ * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
1507
+ * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
1508
+ * set to the same value as `senderLoopback`. This value is chosen by the sender, and since
1509
+ * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
1510
+ * the value is unambiguous.
1511
+ *
1512
+ * The receiver must verify that the target capability actually resolves back to the sender's
1513
+ * vat. Otherwise, the sender has committed a protocol error and should be disconnected.
1514
+ *
1515
+ */
1516
+ get senderLoopback() {
1517
+ utils.testWhich("senderLoopback", utils.getUint16(4, this), 0, this);
1518
+ return utils.getUint32(0, this);
1519
+ }
1520
+ get _isSenderLoopback() {
1521
+ return utils.getUint16(4, this) === 0;
1522
+ }
1523
+ set senderLoopback(value) {
1524
+ utils.setUint16(4, 0, this);
1525
+ utils.setUint32(0, value, this);
1526
+ }
1527
+ /**
1528
+ * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
1529
+ * this capability, and that Disembargo is now being echoed back.
1530
+ *
1531
+ */
1532
+ get receiverLoopback() {
1533
+ utils.testWhich("receiverLoopback", utils.getUint16(4, this), 1, this);
1534
+ return utils.getUint32(0, this);
1535
+ }
1536
+ get _isReceiverLoopback() {
1537
+ return utils.getUint16(4, this) === 1;
1538
+ }
1539
+ set receiverLoopback(value) {
1540
+ utils.setUint16(4, 1, this);
1541
+ utils.setUint32(0, value, this);
1542
+ }
1543
+ get _isAccept() {
1544
+ return utils.getUint16(4, this) === 2;
1545
+ }
1546
+ set accept(_) {
1547
+ utils.setUint16(4, 2, this);
1548
+ }
1549
+ /**
1550
+ * **(level 3)**
1551
+ *
1552
+ * The sender is requesting a disembargo on a capability currently being provided to a third
1553
+ * party. The question ID identifies the `Provide` message previously sent by the sender to
1554
+ * this capability. On receipt, the receiver (the capability host) shall release the embargo
1555
+ * on the `Accept` message that it has received from the third party. See `Accept.embargo` for
1556
+ * an example.
1557
+ *
1558
+ */
1559
+ get provide() {
1560
+ utils.testWhich("provide", utils.getUint16(4, this), 3, this);
1561
+ return utils.getUint32(0, this);
1562
+ }
1563
+ get _isProvide() {
1564
+ return utils.getUint16(4, this) === 3;
1565
+ }
1566
+ set provide(value) {
1567
+ utils.setUint16(4, 3, this);
1568
+ utils.setUint32(0, value, this);
1569
+ }
1570
+ toString() {
1571
+ return "Disembargo_Context_" + super.toString();
1572
+ }
1573
+ which() {
1574
+ return utils.getUint16(4, this);
1575
+ }
1576
+ };
1577
+ var Disembargo = class extends Struct {
1578
+ static {
1579
+ __name(this, "Disembargo");
1580
+ }
1581
+ static _capnp = {
1582
+ displayName: "Disembargo",
1583
+ id: "f964368b0fbd3711",
1584
+ size: new ObjectSize(8, 1)
1585
+ };
1586
+ _adoptTarget(value) {
1587
+ utils.adopt(value, utils.getPointer(0, this));
1588
+ }
1589
+ _disownTarget() {
1590
+ return utils.disown(this.target);
1591
+ }
1592
+ /**
1593
+ * What is to be disembargoed.
1594
+ *
1595
+ */
1596
+ get target() {
1597
+ return utils.getStruct(0, MessageTarget, this);
1598
+ }
1599
+ _hasTarget() {
1600
+ return !utils.isNull(utils.getPointer(0, this));
1601
+ }
1602
+ _initTarget() {
1603
+ return utils.initStructAt(0, MessageTarget, this);
1604
+ }
1605
+ set target(value) {
1606
+ utils.copyFrom(value, utils.getPointer(0, this));
1607
+ }
1608
+ get context() {
1609
+ return utils.getAs(Disembargo_Context, this);
1610
+ }
1611
+ _initContext() {
1612
+ return utils.getAs(Disembargo_Context, this);
1613
+ }
1614
+ toString() {
1615
+ return "Disembargo_" + super.toString();
1616
+ }
1617
+ };
1618
+ var Provide = class extends Struct {
1619
+ static {
1620
+ __name(this, "Provide");
1621
+ }
1622
+ static _capnp = {
1623
+ displayName: "Provide",
1624
+ id: "9c6a046bfbc1ac5a",
1625
+ size: new ObjectSize(8, 2)
1626
+ };
1627
+ /**
1628
+ * Question ID to be held open until the recipient has received the capability. A result will be
1629
+ * returned once the third party has successfully received the capability. The sender must at some
1630
+ * point send a `Finish` message as with any other call, and that message can be used to cancel the
1631
+ * whole operation.
1632
+ *
1633
+ */
1634
+ get questionId() {
1635
+ return utils.getUint32(0, this);
1636
+ }
1637
+ set questionId(value) {
1638
+ utils.setUint32(0, value, this);
1639
+ }
1640
+ _adoptTarget(value) {
1641
+ utils.adopt(value, utils.getPointer(0, this));
1642
+ }
1643
+ _disownTarget() {
1644
+ return utils.disown(this.target);
1645
+ }
1646
+ /**
1647
+ * What is to be provided to the third party.
1648
+ *
1649
+ */
1650
+ get target() {
1651
+ return utils.getStruct(0, MessageTarget, this);
1652
+ }
1653
+ _hasTarget() {
1654
+ return !utils.isNull(utils.getPointer(0, this));
1655
+ }
1656
+ _initTarget() {
1657
+ return utils.initStructAt(0, MessageTarget, this);
1658
+ }
1659
+ set target(value) {
1660
+ utils.copyFrom(value, utils.getPointer(0, this));
1661
+ }
1662
+ _adoptRecipient(value) {
1663
+ utils.adopt(value, utils.getPointer(1, this));
1664
+ }
1665
+ _disownRecipient() {
1666
+ return utils.disown(this.recipient);
1667
+ }
1668
+ /**
1669
+ * Identity of the third party that is expected to pick up the capability.
1670
+ *
1671
+ */
1672
+ get recipient() {
1673
+ return utils.getPointer(1, this);
1674
+ }
1675
+ _hasRecipient() {
1676
+ return !utils.isNull(utils.getPointer(1, this));
1677
+ }
1678
+ set recipient(value) {
1679
+ utils.copyFrom(value, utils.getPointer(1, this));
1680
+ }
1681
+ toString() {
1682
+ return "Provide_" + super.toString();
1683
+ }
1684
+ };
1685
+ var Accept = class extends Struct {
1686
+ static {
1687
+ __name(this, "Accept");
1688
+ }
1689
+ static _capnp = {
1690
+ displayName: "Accept",
1691
+ id: "d4c9b56290554016",
1692
+ size: new ObjectSize(8, 1)
1693
+ };
1694
+ /**
1695
+ * A new question ID identifying this accept message, which will eventually receive a Return
1696
+ * message containing the provided capability (or the call result in the case of a redirected
1697
+ * return).
1698
+ *
1699
+ */
1700
+ get questionId() {
1701
+ return utils.getUint32(0, this);
1702
+ }
1703
+ set questionId(value) {
1704
+ utils.setUint32(0, value, this);
1705
+ }
1706
+ _adoptProvision(value) {
1707
+ utils.adopt(value, utils.getPointer(0, this));
1708
+ }
1709
+ _disownProvision() {
1710
+ return utils.disown(this.provision);
1711
+ }
1712
+ /**
1713
+ * Identifies the provided object to be picked up.
1714
+ *
1715
+ */
1716
+ get provision() {
1717
+ return utils.getPointer(0, this);
1718
+ }
1719
+ _hasProvision() {
1720
+ return !utils.isNull(utils.getPointer(0, this));
1721
+ }
1722
+ set provision(value) {
1723
+ utils.copyFrom(value, utils.getPointer(0, this));
1724
+ }
1725
+ /**
1726
+ * If true, this accept shall be temporarily embargoed. The resulting `Return` will not be sent,
1727
+ * and any pipelined calls will not be delivered, until the embargo is released. The receiver
1728
+ * (the capability host) will expect the provider (the vat that sent the `Provide` message) to
1729
+ * eventually send a `Disembargo` message with the field `context.provide` set to the question ID
1730
+ * of the original `Provide` message. At that point, the embargo is released and the queued
1731
+ * messages are delivered.
1732
+ *
1733
+ * For example:
1734
+ * - Alice, in Vat A, holds a promise P, which currently points toward Vat B.
1735
+ * - Alice calls foo() on P. The `Call` message is sent to Vat B.
1736
+ * - The promise P in Vat B ends up resolving to Carol, in Vat C.
1737
+ * - Vat B sends a `Provide` message to Vat C, identifying Vat A as the recipient.
1738
+ * - Vat B sends a `Resolve` message to Vat A, indicating that the promise has resolved to a
1739
+ * `ThirdPartyCapId` identifying Carol in Vat C.
1740
+ * - Vat A sends an `Accept` message to Vat C to pick up the capability. Since Vat A knows that
1741
+ * it has an outstanding call to the promise, it sets `embargo` to `true` in the `Accept`
1742
+ * message.
1743
+ * - Vat A sends a `Disembargo` message to Vat B on promise P, with `context.accept` set.
1744
+ * - Alice makes a call bar() to promise P, which is now pointing towards Vat C. Alice doesn't
1745
+ * know anything about the mechanics of promise resolution happening under the hood, but she
1746
+ * expects that bar() will be delivered after foo() because that is the order in which she
1747
+ * initiated the calls.
1748
+ * - Vat A sends the bar() call to Vat C, as a pipelined call on the result of the `Accept` (which
1749
+ * hasn't returned yet, due to the embargo). Since calls to the newly-accepted capability
1750
+ * are embargoed, Vat C does not deliver the call yet.
1751
+ * - At some point, Vat B forwards the foo() call from the beginning of this example on to Vat C.
1752
+ * - Vat B forwards the `Disembargo` from Vat A on to vat C. It sets `context.provide` to the
1753
+ * question ID of the `Provide` message it had sent previously.
1754
+ * - Vat C receives foo() before `Disembargo`, thus allowing it to correctly deliver foo()
1755
+ * before delivering bar().
1756
+ * - Vat C receives `Disembargo` from Vat B. It can now send a `Return` for the `Accept` from
1757
+ * Vat A, as well as deliver bar().
1758
+ *
1759
+ */
1760
+ get embargo() {
1761
+ return utils.getBit(32, this);
1762
+ }
1763
+ set embargo(value) {
1764
+ utils.setBit(32, value, this);
1765
+ }
1766
+ toString() {
1767
+ return "Accept_" + super.toString();
1768
+ }
1769
+ };
1770
+ var Join = class extends Struct {
1771
+ static {
1772
+ __name(this, "Join");
1773
+ }
1774
+ static _capnp = {
1775
+ displayName: "Join",
1776
+ id: "fbe1980490e001af",
1777
+ size: new ObjectSize(8, 2)
1778
+ };
1779
+ /**
1780
+ * Question ID used to respond to this Join. (Note that this ID only identifies one part of the
1781
+ * request for one hop; each part has a different ID and relayed copies of the request have
1782
+ * (probably) different IDs still.)
1783
+ *
1784
+ * The receiver will reply with a `Return` whose `results` is a JoinResult. This `JoinResult`
1785
+ * is relayed from the joined object's host, possibly with transformation applied as needed
1786
+ * by the network.
1787
+ *
1788
+ * Like any return, the result must be released using a `Finish`. However, this release
1789
+ * should not occur until the joiner has either successfully connected to the joined object.
1790
+ * Vats relaying a `Join` message similarly must not release the result they receive until the
1791
+ * return they relayed back towards the joiner has itself been released. This allows the
1792
+ * joined object's host to detect when the Join operation is canceled before completing -- if
1793
+ * it receives a `Finish` for one of the join results before the joiner successfully
1794
+ * connects. It can then free any resources it had allocated as part of the join.
1795
+ *
1796
+ */
1797
+ get questionId() {
1798
+ return utils.getUint32(0, this);
1799
+ }
1800
+ set questionId(value) {
1801
+ utils.setUint32(0, value, this);
1802
+ }
1803
+ _adoptTarget(value) {
1804
+ utils.adopt(value, utils.getPointer(0, this));
1805
+ }
1806
+ _disownTarget() {
1807
+ return utils.disown(this.target);
1808
+ }
1809
+ /**
1810
+ * The capability to join.
1811
+ *
1812
+ */
1813
+ get target() {
1814
+ return utils.getStruct(0, MessageTarget, this);
1815
+ }
1816
+ _hasTarget() {
1817
+ return !utils.isNull(utils.getPointer(0, this));
1818
+ }
1819
+ _initTarget() {
1820
+ return utils.initStructAt(0, MessageTarget, this);
1821
+ }
1822
+ set target(value) {
1823
+ utils.copyFrom(value, utils.getPointer(0, this));
1824
+ }
1825
+ _adoptKeyPart(value) {
1826
+ utils.adopt(value, utils.getPointer(1, this));
1827
+ }
1828
+ _disownKeyPart() {
1829
+ return utils.disown(this.keyPart);
1830
+ }
1831
+ /**
1832
+ * A part of the join key. These combine to form the complete join key, which is used to establish
1833
+ * a direct connection.
1834
+ *
1835
+ */
1836
+ get keyPart() {
1837
+ return utils.getPointer(1, this);
1838
+ }
1839
+ _hasKeyPart() {
1840
+ return !utils.isNull(utils.getPointer(1, this));
1841
+ }
1842
+ set keyPart(value) {
1843
+ utils.copyFrom(value, utils.getPointer(1, this));
1844
+ }
1845
+ toString() {
1846
+ return "Join_" + super.toString();
1847
+ }
1848
+ };
1849
+ var MessageTarget_Which = {
1850
+ /**
1851
+ * This message is to a capability or promise previously imported by the caller (exported by
1852
+ * the receiver).
1853
+ *
1854
+ */
1855
+ IMPORTED_CAP: 0,
1856
+ /**
1857
+ * This message is to a capability that is expected to be returned by another call that has not
1858
+ * yet been completed.
1859
+ *
1860
+ * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
1861
+ * that initial startup doesn't require a round trip.
1862
+ *
1863
+ */
1864
+ PROMISED_ANSWER: 1
1865
+ };
1866
+ var MessageTarget = class extends Struct {
1867
+ static {
1868
+ __name(this, "MessageTarget");
1869
+ }
1870
+ static IMPORTED_CAP = MessageTarget_Which.IMPORTED_CAP;
1871
+ static PROMISED_ANSWER = MessageTarget_Which.PROMISED_ANSWER;
1872
+ static _capnp = {
1873
+ displayName: "MessageTarget",
1874
+ id: "95bc14545813fbc1",
1875
+ size: new ObjectSize(8, 1)
1876
+ };
1877
+ /**
1878
+ * This message is to a capability or promise previously imported by the caller (exported by
1879
+ * the receiver).
1880
+ *
1881
+ */
1882
+ get importedCap() {
1883
+ utils.testWhich("importedCap", utils.getUint16(4, this), 0, this);
1884
+ return utils.getUint32(0, this);
1885
+ }
1886
+ get _isImportedCap() {
1887
+ return utils.getUint16(4, this) === 0;
1888
+ }
1889
+ set importedCap(value) {
1890
+ utils.setUint16(4, 0, this);
1891
+ utils.setUint32(0, value, this);
1892
+ }
1893
+ _adoptPromisedAnswer(value) {
1894
+ utils.setUint16(4, 1, this);
1895
+ utils.adopt(value, utils.getPointer(0, this));
1896
+ }
1897
+ _disownPromisedAnswer() {
1898
+ return utils.disown(this.promisedAnswer);
1899
+ }
1900
+ /**
1901
+ * This message is to a capability that is expected to be returned by another call that has not
1902
+ * yet been completed.
1903
+ *
1904
+ * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
1905
+ * that initial startup doesn't require a round trip.
1906
+ *
1907
+ */
1908
+ get promisedAnswer() {
1909
+ utils.testWhich("promisedAnswer", utils.getUint16(4, this), 1, this);
1910
+ return utils.getStruct(0, PromisedAnswer, this);
1911
+ }
1912
+ _hasPromisedAnswer() {
1913
+ return !utils.isNull(utils.getPointer(0, this));
1914
+ }
1915
+ _initPromisedAnswer() {
1916
+ utils.setUint16(4, 1, this);
1917
+ return utils.initStructAt(0, PromisedAnswer, this);
1918
+ }
1919
+ get _isPromisedAnswer() {
1920
+ return utils.getUint16(4, this) === 1;
1921
+ }
1922
+ set promisedAnswer(value) {
1923
+ utils.setUint16(4, 1, this);
1924
+ utils.copyFrom(value, utils.getPointer(0, this));
1925
+ }
1926
+ toString() {
1927
+ return "MessageTarget_" + super.toString();
1928
+ }
1929
+ which() {
1930
+ return utils.getUint16(4, this);
1931
+ }
1932
+ };
1933
+ var Payload = class _Payload extends Struct {
1934
+ static {
1935
+ __name(this, "Payload");
1936
+ }
1937
+ static _capnp = {
1938
+ displayName: "Payload",
1939
+ id: "9a0e61223d96743b",
1940
+ size: new ObjectSize(0, 2)
1941
+ };
1942
+ static _CapTable;
1943
+ _adoptContent(value) {
1944
+ utils.adopt(value, utils.getPointer(0, this));
1945
+ }
1946
+ _disownContent() {
1947
+ return utils.disown(this.content);
1948
+ }
1949
+ /**
1950
+ * Some Cap'n Proto data structure. Capability pointers embedded in this structure index into
1951
+ * `capTable`.
1952
+ *
1953
+ */
1954
+ get content() {
1955
+ return utils.getPointer(0, this);
1956
+ }
1957
+ _hasContent() {
1958
+ return !utils.isNull(utils.getPointer(0, this));
1959
+ }
1960
+ set content(value) {
1961
+ utils.copyFrom(value, utils.getPointer(0, this));
1962
+ }
1963
+ _adoptCapTable(value) {
1964
+ utils.adopt(value, utils.getPointer(1, this));
1965
+ }
1966
+ _disownCapTable() {
1967
+ return utils.disown(this.capTable);
1968
+ }
1969
+ /**
1970
+ * Descriptors corresponding to the cap pointers in `content`.
1971
+ *
1972
+ */
1973
+ get capTable() {
1974
+ return utils.getList(1, _Payload._CapTable, this);
1975
+ }
1976
+ _hasCapTable() {
1977
+ return !utils.isNull(utils.getPointer(1, this));
1978
+ }
1979
+ _initCapTable(length) {
1980
+ return utils.initList(1, _Payload._CapTable, length, this);
1981
+ }
1982
+ set capTable(value) {
1983
+ utils.copyFrom(value, utils.getPointer(1, this));
1984
+ }
1985
+ toString() {
1986
+ return "Payload_" + super.toString();
1987
+ }
1988
+ };
1989
+ var CapDescriptor_Which = {
1990
+ /**
1991
+ * There is no capability here. This `CapDescriptor` should not appear in the payload content.
1992
+ * A `none` CapDescriptor can be generated when an application inserts a capability into a
1993
+ * message and then later changes its mind and removes it -- rewriting all of the other
1994
+ * capability pointers may be hard, so instead a tombstone is left, similar to the way a removed
1995
+ * struct or list instance is zeroed out of the message but the space is not reclaimed.
1996
+ * Hopefully this is unusual.
1997
+ *
1998
+ */
1999
+ NONE: 0,
2000
+ /**
2001
+ * The ID of a capability in the sender's export table (receiver's import table). It may be a
2002
+ * newly allocated table entry, or an existing entry (increments the reference count).
2003
+ *
2004
+ */
2005
+ SENDER_HOSTED: 1,
2006
+ /**
2007
+ * A promise that the sender will resolve later. The sender will send exactly one Resolve
2008
+ * message at a future point in time to replace this promise. Note that even if the same
2009
+ * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
2010
+ * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
2011
+ * `CapDescriptor`) may choose not to send the `Resolve` at all.
2012
+ *
2013
+ */
2014
+ SENDER_PROMISE: 2,
2015
+ /**
2016
+ * A capability (or promise) previously exported by the receiver (imported by the sender).
2017
+ *
2018
+ */
2019
+ RECEIVER_HOSTED: 3,
2020
+ /**
2021
+ * A capability expected to be returned in the results of a currently-outstanding call posed
2022
+ * by the sender.
2023
+ *
2024
+ */
2025
+ RECEIVER_ANSWER: 4,
2026
+ /**
2027
+ * **(level 3)**
2028
+ *
2029
+ * A capability that lives in neither the sender's nor the receiver's vat. The sender needs
2030
+ * to form a direct connection to a third party to pick up the capability.
2031
+ *
2032
+ * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
2033
+ * `vine` instead.
2034
+ *
2035
+ */
2036
+ THIRD_PARTY_HOSTED: 5
2037
+ };
2038
+ var CapDescriptor = class _CapDescriptor extends Struct {
2039
+ static {
2040
+ __name(this, "CapDescriptor");
2041
+ }
2042
+ static NONE = CapDescriptor_Which.NONE;
2043
+ static SENDER_HOSTED = CapDescriptor_Which.SENDER_HOSTED;
2044
+ static SENDER_PROMISE = CapDescriptor_Which.SENDER_PROMISE;
2045
+ static RECEIVER_HOSTED = CapDescriptor_Which.RECEIVER_HOSTED;
2046
+ static RECEIVER_ANSWER = CapDescriptor_Which.RECEIVER_ANSWER;
2047
+ static THIRD_PARTY_HOSTED = CapDescriptor_Which.THIRD_PARTY_HOSTED;
2048
+ static _capnp = {
2049
+ displayName: "CapDescriptor",
2050
+ id: "8523ddc40b86b8b0",
2051
+ size: new ObjectSize(8, 1),
2052
+ defaultAttachedFd: getUint8Mask(255)
2053
+ };
2054
+ get _isNone() {
2055
+ return utils.getUint16(0, this) === 0;
2056
+ }
2057
+ set none(_) {
2058
+ utils.setUint16(0, 0, this);
2059
+ }
2060
+ /**
2061
+ * The ID of a capability in the sender's export table (receiver's import table). It may be a
2062
+ * newly allocated table entry, or an existing entry (increments the reference count).
2063
+ *
2064
+ */
2065
+ get senderHosted() {
2066
+ utils.testWhich("senderHosted", utils.getUint16(0, this), 1, this);
2067
+ return utils.getUint32(4, this);
2068
+ }
2069
+ get _isSenderHosted() {
2070
+ return utils.getUint16(0, this) === 1;
2071
+ }
2072
+ set senderHosted(value) {
2073
+ utils.setUint16(0, 1, this);
2074
+ utils.setUint32(4, value, this);
2075
+ }
2076
+ /**
2077
+ * A promise that the sender will resolve later. The sender will send exactly one Resolve
2078
+ * message at a future point in time to replace this promise. Note that even if the same
2079
+ * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
2080
+ * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
2081
+ * `CapDescriptor`) may choose not to send the `Resolve` at all.
2082
+ *
2083
+ */
2084
+ get senderPromise() {
2085
+ utils.testWhich("senderPromise", utils.getUint16(0, this), 2, this);
2086
+ return utils.getUint32(4, this);
2087
+ }
2088
+ get _isSenderPromise() {
2089
+ return utils.getUint16(0, this) === 2;
2090
+ }
2091
+ set senderPromise(value) {
2092
+ utils.setUint16(0, 2, this);
2093
+ utils.setUint32(4, value, this);
2094
+ }
2095
+ /**
2096
+ * A capability (or promise) previously exported by the receiver (imported by the sender).
2097
+ *
2098
+ */
2099
+ get receiverHosted() {
2100
+ utils.testWhich("receiverHosted", utils.getUint16(0, this), 3, this);
2101
+ return utils.getUint32(4, this);
2102
+ }
2103
+ get _isReceiverHosted() {
2104
+ return utils.getUint16(0, this) === 3;
2105
+ }
2106
+ set receiverHosted(value) {
2107
+ utils.setUint16(0, 3, this);
2108
+ utils.setUint32(4, value, this);
2109
+ }
2110
+ _adoptReceiverAnswer(value) {
2111
+ utils.setUint16(0, 4, this);
2112
+ utils.adopt(value, utils.getPointer(0, this));
2113
+ }
2114
+ _disownReceiverAnswer() {
2115
+ return utils.disown(this.receiverAnswer);
2116
+ }
2117
+ /**
2118
+ * A capability expected to be returned in the results of a currently-outstanding call posed
2119
+ * by the sender.
2120
+ *
2121
+ */
2122
+ get receiverAnswer() {
2123
+ utils.testWhich("receiverAnswer", utils.getUint16(0, this), 4, this);
2124
+ return utils.getStruct(0, PromisedAnswer, this);
2125
+ }
2126
+ _hasReceiverAnswer() {
2127
+ return !utils.isNull(utils.getPointer(0, this));
2128
+ }
2129
+ _initReceiverAnswer() {
2130
+ utils.setUint16(0, 4, this);
2131
+ return utils.initStructAt(0, PromisedAnswer, this);
2132
+ }
2133
+ get _isReceiverAnswer() {
2134
+ return utils.getUint16(0, this) === 4;
2135
+ }
2136
+ set receiverAnswer(value) {
2137
+ utils.setUint16(0, 4, this);
2138
+ utils.copyFrom(value, utils.getPointer(0, this));
2139
+ }
2140
+ _adoptThirdPartyHosted(value) {
2141
+ utils.setUint16(0, 5, this);
2142
+ utils.adopt(value, utils.getPointer(0, this));
2143
+ }
2144
+ _disownThirdPartyHosted() {
2145
+ return utils.disown(this.thirdPartyHosted);
2146
+ }
2147
+ /**
2148
+ * **(level 3)**
2149
+ *
2150
+ * A capability that lives in neither the sender's nor the receiver's vat. The sender needs
2151
+ * to form a direct connection to a third party to pick up the capability.
2152
+ *
2153
+ * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
2154
+ * `vine` instead.
2155
+ *
2156
+ */
2157
+ get thirdPartyHosted() {
2158
+ utils.testWhich("thirdPartyHosted", utils.getUint16(0, this), 5, this);
2159
+ return utils.getStruct(0, ThirdPartyCapDescriptor, this);
2160
+ }
2161
+ _hasThirdPartyHosted() {
2162
+ return !utils.isNull(utils.getPointer(0, this));
2163
+ }
2164
+ _initThirdPartyHosted() {
2165
+ utils.setUint16(0, 5, this);
2166
+ return utils.initStructAt(0, ThirdPartyCapDescriptor, this);
2167
+ }
2168
+ get _isThirdPartyHosted() {
2169
+ return utils.getUint16(0, this) === 5;
2170
+ }
2171
+ set thirdPartyHosted(value) {
2172
+ utils.setUint16(0, 5, this);
2173
+ utils.copyFrom(value, utils.getPointer(0, this));
2174
+ }
2175
+ /**
2176
+ * If the RPC message in which this CapDescriptor was delivered also had file descriptors
2177
+ * attached, and `fd` is a valid index into the list of attached file descriptors, then
2178
+ * that file descriptor should be attached to this capability. If `attachedFd` is out-of-bounds
2179
+ * for said list, then no FD is attached.
2180
+ *
2181
+ * For example, if the RPC message arrived over a Unix socket, then file descriptors may be
2182
+ * attached by sending an SCM_RIGHTS ancillary message attached to the data bytes making up the
2183
+ * raw message. Receivers who wish to opt into FD passing should arrange to receive SCM_RIGHTS
2184
+ * whenever receiving an RPC message. Senders who wish to send FDs need not verify whether the
2185
+ * receiver knows how to receive them, because the operating system will automatically discard
2186
+ * ancillary messages like SCM_RIGHTS if the receiver doesn't ask to receive them, including
2187
+ * automatically closing any FDs.
2188
+ *
2189
+ * It is up to the application protocol to define what capabilities are expected to have file
2190
+ * descriptors attached, and what those FDs mean. But, for example, an application could use this
2191
+ * to open a file on disk and then transmit the open file descriptor to a sandboxed process that
2192
+ * does not otherwise have permission to access the filesystem directly. This is usually an
2193
+ * optimization: the sending process could instead provide an RPC interface supporting all the
2194
+ * operations needed (such as reading and writing a file), but by passing the file descriptor
2195
+ * directly, the recipient can often perform operations much more efficiently. Application
2196
+ * designers are encouraged to provide such RPC interfaces and automatically fall back to them
2197
+ * when FD passing is not available, so that the application can still work when the parties are
2198
+ * remote over a network.
2199
+ *
2200
+ * An attached FD is most often associated with a `senderHosted` descriptor. It could also make
2201
+ * sense in the case of `thirdPartyHosted`: in this case, the sender is forwarding the FD that
2202
+ * they received from the third party, so that the receiver can start using it without first
2203
+ * interacting with the third party. This is an optional optimization -- the middleman may choose
2204
+ * not to forward capabilities, in which case the receiver will need to complete the handshake
2205
+ * with the third party directly before receiving the FD. If an implementation receives a second
2206
+ * attached FD after having already received one previously (e.g. both in a `thirdPartyHosted`
2207
+ * CapDescriptor and then later again when receiving the final capability directly from the
2208
+ * third party), the implementation should discard the later FD and stick with the original. At
2209
+ * present, there is no known reason why other capability types (e.g. `receiverHosted`) would want
2210
+ * to carry an attached FD, but we reserve the right to define a meaning for this in the future.
2211
+ *
2212
+ * Each file descriptor attached to the message must be used in no more than one CapDescriptor,
2213
+ * so that the receiver does not need to use dup() or refcounting to handle the possibility of
2214
+ * multiple capabilities using the same descriptor. If multiple CapDescriptors do point to the
2215
+ * same FD index, then the receiver can arbitrarily choose which capability ends up having the
2216
+ * FD attached.
2217
+ *
2218
+ * To mitigate DoS attacks, RPC implementations should limit the number of FDs they are willing to
2219
+ * receive in a single message to a small value. If a message happens to contain more than that,
2220
+ * the list is truncated. Moreover, in some cases, FD passing needs to be blocked entirely for
2221
+ * security or implementation reasons, in which case the list may be truncated to zero. Hence,
2222
+ * `attachedFd` might point past the end of the list, which the implementation should treat as if
2223
+ * no FD was attached at all.
2224
+ *
2225
+ * The type of this field was chosen to be UInt8 because Linux supports sending only a maximum
2226
+ * of 253 file descriptors in an SCM_RIGHTS message anyway, and CapDescriptor had two bytes of
2227
+ * padding left -- so after adding this, there is still one byte for a future feature.
2228
+ * Conveniently, this also means we're able to use 0xff as the default value, which will always
2229
+ * be out-of-range (of course, the implementation should explicitly enforce that 255 descriptors
2230
+ * cannot be sent at once, rather than relying on Linux to do so).
2231
+ *
2232
+ */
2233
+ get attachedFd() {
2234
+ return utils.getUint8(2, this, _CapDescriptor._capnp.defaultAttachedFd);
2235
+ }
2236
+ set attachedFd(value) {
2237
+ utils.setUint8(2, value, this, _CapDescriptor._capnp.defaultAttachedFd);
2238
+ }
2239
+ toString() {
2240
+ return "CapDescriptor_" + super.toString();
2241
+ }
2242
+ which() {
2243
+ return utils.getUint16(0, this);
2244
+ }
2245
+ };
2246
+ var PromisedAnswer_Op_Which = {
2247
+ /**
2248
+ * Does nothing. This member is mostly defined so that we can make `Op` a union even
2249
+ * though (as of this writing) only one real operation is defined.
2250
+ *
2251
+ */
2252
+ NOOP: 0,
2253
+ /**
2254
+ * Get a pointer field within a struct. The number is an index into the pointer section, NOT
2255
+ * a field ordinal, so that the receiver does not need to understand the schema.
2256
+ *
2257
+ */
2258
+ GET_POINTER_FIELD: 1
2259
+ };
2260
+ var PromisedAnswer_Op = class extends Struct {
2261
+ static {
2262
+ __name(this, "PromisedAnswer_Op");
2263
+ }
2264
+ static NOOP = PromisedAnswer_Op_Which.NOOP;
2265
+ static GET_POINTER_FIELD = PromisedAnswer_Op_Which.GET_POINTER_FIELD;
2266
+ static _capnp = {
2267
+ displayName: "Op",
2268
+ id: "f316944415569081",
2269
+ size: new ObjectSize(8, 0)
2270
+ };
2271
+ get _isNoop() {
2272
+ return utils.getUint16(0, this) === 0;
2273
+ }
2274
+ set noop(_) {
2275
+ utils.setUint16(0, 0, this);
2276
+ }
2277
+ /**
2278
+ * Get a pointer field within a struct. The number is an index into the pointer section, NOT
2279
+ * a field ordinal, so that the receiver does not need to understand the schema.
2280
+ *
2281
+ */
2282
+ get getPointerField() {
2283
+ utils.testWhich("getPointerField", utils.getUint16(0, this), 1, this);
2284
+ return utils.getUint16(2, this);
2285
+ }
2286
+ get _isGetPointerField() {
2287
+ return utils.getUint16(0, this) === 1;
2288
+ }
2289
+ set getPointerField(value) {
2290
+ utils.setUint16(0, 1, this);
2291
+ utils.setUint16(2, value, this);
2292
+ }
2293
+ toString() {
2294
+ return "PromisedAnswer_Op_" + super.toString();
2295
+ }
2296
+ which() {
2297
+ return utils.getUint16(0, this);
2298
+ }
2299
+ };
2300
+ var PromisedAnswer = class _PromisedAnswer extends Struct {
2301
+ static {
2302
+ __name(this, "PromisedAnswer");
2303
+ }
2304
+ static Op = PromisedAnswer_Op;
2305
+ static _capnp = {
2306
+ displayName: "PromisedAnswer",
2307
+ id: "d800b1d6cd6f1ca0",
2308
+ size: new ObjectSize(8, 1)
2309
+ };
2310
+ static _Transform;
2311
+ /**
2312
+ * ID of the question (in the sender's question table / receiver's answer table) whose answer is
2313
+ * expected to contain the capability.
2314
+ *
2315
+ */
2316
+ get questionId() {
2317
+ return utils.getUint32(0, this);
2318
+ }
2319
+ set questionId(value) {
2320
+ utils.setUint32(0, value, this);
2321
+ }
2322
+ _adoptTransform(value) {
2323
+ utils.adopt(value, utils.getPointer(0, this));
2324
+ }
2325
+ _disownTransform() {
2326
+ return utils.disown(this.transform);
2327
+ }
2328
+ /**
2329
+ * Operations / transformations to apply to the result in order to get the capability actually
2330
+ * being addressed. E.g. if the result is a struct and you want to call a method on a capability
2331
+ * pointed to by a field of the struct, you need a `getPointerField` op.
2332
+ *
2333
+ */
2334
+ get transform() {
2335
+ return utils.getList(0, _PromisedAnswer._Transform, this);
2336
+ }
2337
+ _hasTransform() {
2338
+ return !utils.isNull(utils.getPointer(0, this));
2339
+ }
2340
+ _initTransform(length) {
2341
+ return utils.initList(0, _PromisedAnswer._Transform, length, this);
2342
+ }
2343
+ set transform(value) {
2344
+ utils.copyFrom(value, utils.getPointer(0, this));
2345
+ }
2346
+ toString() {
2347
+ return "PromisedAnswer_" + super.toString();
2348
+ }
2349
+ };
2350
+ var ThirdPartyCapDescriptor = class extends Struct {
2351
+ static {
2352
+ __name(this, "ThirdPartyCapDescriptor");
2353
+ }
2354
+ static _capnp = {
2355
+ displayName: "ThirdPartyCapDescriptor",
2356
+ id: "d37007fde1f0027d",
2357
+ size: new ObjectSize(8, 1)
2358
+ };
2359
+ _adoptId(value) {
2360
+ utils.adopt(value, utils.getPointer(0, this));
2361
+ }
2362
+ _disownId() {
2363
+ return utils.disown(this.id);
2364
+ }
2365
+ /**
2366
+ * Identifies the third-party host and the specific capability to accept from it.
2367
+ *
2368
+ */
2369
+ get id() {
2370
+ return utils.getPointer(0, this);
2371
+ }
2372
+ _hasId() {
2373
+ return !utils.isNull(utils.getPointer(0, this));
2374
+ }
2375
+ set id(value) {
2376
+ utils.copyFrom(value, utils.getPointer(0, this));
2377
+ }
2378
+ /**
2379
+ * A proxy for the third-party object exported by the sender. In CapTP terminology this is called
2380
+ * a "vine", because it is an indirect reference to the third-party object that snakes through the
2381
+ * sender vat. This serves two purposes:
2382
+ *
2383
+ * * Level 1 and 2 implementations that don't understand how to connect to a third party may
2384
+ * simply send calls to the vine. Such calls will be forwarded to the third-party by the
2385
+ * sender.
2386
+ *
2387
+ * * Level 3 implementations must release the vine only once they have successfully picked up the
2388
+ * object from the third party. This ensures that the capability is not released by the sender
2389
+ * prematurely.
2390
+ *
2391
+ * The sender will close the `Provide` request that it has sent to the third party as soon as
2392
+ * it receives either a `Call` or a `Release` message directed at the vine.
2393
+ *
2394
+ */
2395
+ get vineId() {
2396
+ return utils.getUint32(0, this);
2397
+ }
2398
+ set vineId(value) {
2399
+ utils.setUint32(0, value, this);
2400
+ }
2401
+ toString() {
2402
+ return "ThirdPartyCapDescriptor_" + super.toString();
2403
+ }
2404
+ };
2405
+ var Exception_Type = {
2406
+ /**
2407
+ * A generic problem occurred, and it is believed that if the operation were repeated without
2408
+ * any change in the state of the world, the problem would occur again.
2409
+ *
2410
+ * A client might respond to this error by logging it for investigation by the developer and/or
2411
+ * displaying it to the user.
2412
+ *
2413
+ */
2414
+ FAILED: 0,
2415
+ /**
2416
+ * The request was rejected due to a temporary lack of resources.
2417
+ *
2418
+ * Examples include:
2419
+ * - There's not enough CPU time to keep up with incoming requests, so some are rejected.
2420
+ * - The server ran out of RAM or disk space during the request.
2421
+ * - The operation timed out (took significantly longer than it should have).
2422
+ *
2423
+ * A client might respond to this error by scheduling to retry the operation much later. The
2424
+ * client should NOT retry again immediately since this would likely exacerbate the problem.
2425
+ *
2426
+ */
2427
+ OVERLOADED: 1,
2428
+ /**
2429
+ * The method failed because a connection to some necessary capability was lost.
2430
+ *
2431
+ * Examples include:
2432
+ * - The client introduced the server to a third-party capability, the connection to that third
2433
+ * party was subsequently lost, and then the client requested that the server use the dead
2434
+ * capability for something.
2435
+ * - The client previously requested that the server obtain a capability from some third party.
2436
+ * The server returned a capability to an object wrapping the third-party capability. Later,
2437
+ * the server's connection to the third party was lost.
2438
+ * - The capability has been revoked. Revocation does not necessarily mean that the client is
2439
+ * no longer authorized to use the capability; it is often used simply as a way to force the
2440
+ * client to repeat the setup process, perhaps to efficiently move them to a new back-end or
2441
+ * get them to recognize some other change that has occurred.
2442
+ *
2443
+ * A client should normally respond to this error by releasing all capabilities it is currently
2444
+ * holding related to the one it called and then re-creating them by restoring SturdyRefs and/or
2445
+ * repeating the method calls used to create them originally. In other words, disconnect and
2446
+ * start over. This should in turn cause the server to obtain a new copy of the capability that
2447
+ * it lost, thus making everything work.
2448
+ *
2449
+ * If the client receives another `disconnected` error in the process of rebuilding the
2450
+ * capability and retrying the call, it should treat this as an `overloaded` error: the network
2451
+ * is currently unreliable, possibly due to load or other temporary issues.
2452
+ *
2453
+ */
2454
+ DISCONNECTED: 2,
2455
+ /**
2456
+ * The server doesn't implement the requested method. If there is some other method that the
2457
+ * client could call (perhaps an older and/or slower interface), it should try that instead.
2458
+ * Otherwise, this should be treated like `failed`.
2459
+ *
2460
+ */
2461
+ UNIMPLEMENTED: 3
2462
+ };
2463
+ var Exception = class extends Struct {
2464
+ static {
2465
+ __name(this, "Exception");
2466
+ }
2467
+ static Type = Exception_Type;
2468
+ static _capnp = {
2469
+ displayName: "Exception",
2470
+ id: "d625b7063acf691a",
2471
+ size: new ObjectSize(8, 2)
2472
+ };
2473
+ /**
2474
+ * Human-readable failure description.
2475
+ *
2476
+ */
2477
+ get reason() {
2478
+ return utils.getText(0, this);
2479
+ }
2480
+ set reason(value) {
2481
+ utils.setText(0, value, this);
2482
+ }
2483
+ /**
2484
+ * The type of the error. The purpose of this enum is not to describe the error itself, but
2485
+ * rather to describe how the client might want to respond to the error.
2486
+ *
2487
+ */
2488
+ get type() {
2489
+ return utils.getUint16(4, this);
2490
+ }
2491
+ set type(value) {
2492
+ utils.setUint16(4, value, this);
2493
+ }
2494
+ /**
2495
+ * OBSOLETE. Ignore.
2496
+ *
2497
+ */
2498
+ get obsoleteIsCallersFault() {
2499
+ return utils.getBit(0, this);
2500
+ }
2501
+ set obsoleteIsCallersFault(value) {
2502
+ utils.setBit(0, value, this);
2503
+ }
2504
+ /**
2505
+ * OBSOLETE. See `type` instead.
2506
+ *
2507
+ */
2508
+ get obsoleteDurability() {
2509
+ return utils.getUint16(2, this);
2510
+ }
2511
+ set obsoleteDurability(value) {
2512
+ utils.setUint16(2, value, this);
2513
+ }
2514
+ /**
2515
+ * Stack trace text from the remote server. The format is not specified. By default,
2516
+ * implementations do not provide stack traces; the application must explicitly enable them
2517
+ * when desired.
2518
+ *
2519
+ */
2520
+ get trace() {
2521
+ return utils.getText(1, this);
2522
+ }
2523
+ set trace(value) {
2524
+ utils.setText(1, value, this);
2525
+ }
2526
+ toString() {
2527
+ return "Exception_" + super.toString();
2528
+ }
2529
+ };
2530
+ Payload._CapTable = CompositeList(CapDescriptor);
2531
+ PromisedAnswer._Transform = CompositeList(PromisedAnswer_Op);
2532
+ export {
2533
+ Accept,
2534
+ Bootstrap,
2535
+ Call,
2536
+ Call_SendResultsTo,
2537
+ Call_SendResultsTo_Which,
2538
+ CapDescriptor,
2539
+ CapDescriptor_Which,
2540
+ Disembargo,
2541
+ Disembargo_Context,
2542
+ Disembargo_Context_Which,
2543
+ Exception,
2544
+ Exception_Type,
2545
+ Finish,
2546
+ Join,
2547
+ Message,
2548
+ MessageTarget,
2549
+ MessageTarget_Which,
2550
+ Message_Which,
2551
+ Payload,
2552
+ PromisedAnswer,
2553
+ PromisedAnswer_Op,
2554
+ PromisedAnswer_Op_Which,
2555
+ Provide,
2556
+ Release,
2557
+ Resolve,
2558
+ Resolve_Which,
2559
+ Return,
2560
+ Return_Which,
2561
+ ThirdPartyCapDescriptor,
2562
+ _capnpFileId
2563
+ };