@stryke/capnp 0.12.96 → 0.12.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/bin/capnpc.cjs +405 -304
  2. package/bin/capnpc.d.cts +909 -4
  3. package/bin/capnpc.d.cts.map +1 -1
  4. package/bin/capnpc.d.mts +909 -4
  5. package/bin/capnpc.d.mts.map +1 -1
  6. package/bin/capnpc.mjs +368 -268
  7. package/bin/capnpc.mjs.map +1 -1
  8. package/dist/capnp-es.BHkXHvyK-B3-d8RNu.d.mts +2991 -0
  9. package/dist/capnp-es.BHkXHvyK-B3-d8RNu.d.mts.map +1 -0
  10. package/dist/capnp-es.BHkXHvyK-CQWXOqvU.d.cts +2991 -0
  11. package/dist/capnp-es.BHkXHvyK-CQWXOqvU.d.cts.map +1 -0
  12. package/dist/{capnp-es.GpvEvMIK-C4q8I6qy.mjs → capnp-es.GpvEvMIK-CH8kq1KS.mjs} +13 -6
  13. package/dist/{capnp-es.GpvEvMIK-C4q8I6qy.mjs.map → capnp-es.GpvEvMIK-CH8kq1KS.mjs.map} +1 -1
  14. package/dist/{capnp-es.GpvEvMIK-BcYm5JyH.cjs → capnp-es.GpvEvMIK-CZ5ZimCD.cjs} +12 -5
  15. package/dist/{compile-Cx88xgqJ.mjs → compile-D_BOc0dD.mjs} +109 -15
  16. package/dist/compile-D_BOc0dD.mjs.map +1 -0
  17. package/dist/{compile-SmxAaHxW.cjs → compile-Yq1zhccM.cjs} +113 -19
  18. package/dist/compile.cjs +2 -2
  19. package/dist/compile.d.cts +38 -3
  20. package/dist/compile.d.cts.map +1 -0
  21. package/dist/compile.d.mts +38 -3
  22. package/dist/compile.d.mts.map +1 -0
  23. package/dist/compile.mjs +1 -2
  24. package/dist/{dist-BlvFBzSi.mjs → dist-DQ7xmzRT.mjs} +385 -16
  25. package/dist/dist-DQ7xmzRT.mjs.map +1 -0
  26. package/dist/{dist-YywzZL3Q.cjs → dist-VMGxvENY.cjs} +381 -12
  27. package/dist/{helpers-BoYAadSB.mjs → helpers-2TldkyGG.mjs} +136 -137
  28. package/dist/helpers-2TldkyGG.mjs.map +1 -0
  29. package/dist/{helpers-gxlsFdP8.cjs → helpers-Dn4nWOb7.cjs} +164 -165
  30. package/dist/helpers.cjs +2 -1
  31. package/dist/helpers.d.cts +1 -2
  32. package/dist/helpers.d.cts.map +1 -1
  33. package/dist/helpers.d.mts +1 -2
  34. package/dist/helpers.d.mts.map +1 -1
  35. package/dist/helpers.mjs +1 -1
  36. package/dist/index-63Za7yNc.d.cts +736 -0
  37. package/dist/index-63Za7yNc.d.cts.map +1 -0
  38. package/dist/index-LYXu6eWz.d.mts +736 -0
  39. package/dist/index-LYXu6eWz.d.mts.map +1 -0
  40. package/dist/index.cjs +5 -5
  41. package/dist/index.d.cts +5 -4
  42. package/dist/index.d.mts +5 -4
  43. package/dist/index.mjs +4 -5
  44. package/dist/rpc-helpers.cjs +4 -3
  45. package/dist/rpc-helpers.d.cts +3 -4
  46. package/dist/rpc-helpers.d.cts.map +1 -1
  47. package/dist/rpc-helpers.d.mts +3 -4
  48. package/dist/rpc-helpers.d.mts.map +1 -1
  49. package/dist/rpc-helpers.mjs +2 -2
  50. package/dist/types-BjCOVfgj.d.cts +1506 -0
  51. package/dist/types-BjCOVfgj.d.cts.map +1 -0
  52. package/dist/types-CVzMn-TI.d.mts +1506 -0
  53. package/dist/types-CVzMn-TI.d.mts.map +1 -0
  54. package/dist/types.cjs +8 -2
  55. package/dist/types.d.cts +1 -1
  56. package/dist/types.d.mts +1 -1
  57. package/dist/types.mjs +7 -2
  58. package/dist/types.mjs.map +1 -0
  59. package/package.json +5 -5
  60. package/schemas/cpp.cjs +1 -0
  61. package/schemas/cpp.d.cts.map +1 -1
  62. package/schemas/cpp.d.mts.map +1 -1
  63. package/schemas/index-BB47pUzp.d.cts +742 -0
  64. package/schemas/index-BB47pUzp.d.cts.map +1 -0
  65. package/schemas/index-DprjZUdT.d.mts +742 -0
  66. package/schemas/index-DprjZUdT.d.mts.map +1 -0
  67. package/schemas/persistent.cjs +2 -1
  68. package/schemas/persistent.d.cts +48 -21
  69. package/schemas/persistent.d.cts.map +1 -1
  70. package/schemas/persistent.d.mts +48 -21
  71. package/schemas/persistent.d.mts.map +1 -1
  72. package/schemas/persistent.mjs +1 -1
  73. package/schemas/persistent.mjs.map +1 -1
  74. package/schemas/rpc-twoparty.cjs +20 -1
  75. package/schemas/rpc-twoparty.d.cts +17 -17
  76. package/schemas/rpc-twoparty.d.cts.map +1 -1
  77. package/schemas/rpc-twoparty.d.mts +17 -17
  78. package/schemas/rpc-twoparty.d.mts.map +1 -1
  79. package/schemas/rpc-twoparty.mjs +19 -1
  80. package/schemas/rpc-twoparty.mjs.map +1 -1
  81. package/schemas/rpc.cjs +371 -1
  82. package/schemas/rpc.d.cts +141 -141
  83. package/schemas/rpc.d.cts.map +1 -1
  84. package/schemas/rpc.d.mts +141 -141
  85. package/schemas/rpc.d.mts.map +1 -1
  86. package/schemas/rpc.mjs +370 -1
  87. package/schemas/rpc.mjs.map +1 -1
  88. package/schemas/schema.cjs +96 -1
  89. package/schemas/schema.d.cts +286 -228
  90. package/schemas/schema.d.cts.map +1 -1
  91. package/schemas/schema.d.mts +286 -228
  92. package/schemas/schema.d.mts.map +1 -1
  93. package/schemas/schema.mjs +95 -1
  94. package/schemas/schema.mjs.map +1 -1
  95. package/schemas/{src-2eLj6yCr.cjs → src-B6FhDNiV.cjs} +19 -12
  96. package/schemas/{src-s2pCu2mc.mjs → src-B97sIXSw.mjs} +19 -13
  97. package/schemas/src-B97sIXSw.mjs.map +1 -0
  98. package/schemas/ts.cjs +1 -0
  99. package/schemas/ts.d.cts.map +1 -1
  100. package/schemas/ts.d.mts.map +1 -1
  101. package/dist/compile-Cx88xgqJ.mjs.map +0 -1
  102. package/dist/compile-DccxA7WZ.d.cts +0 -40
  103. package/dist/compile-DccxA7WZ.d.cts.map +0 -1
  104. package/dist/compile-UkKIpqrK.d.mts +0 -40
  105. package/dist/compile-UkKIpqrK.d.mts.map +0 -1
  106. package/dist/dist-BlvFBzSi.mjs.map +0 -1
  107. package/dist/helpers-BoYAadSB.mjs.map +0 -1
  108. package/dist/types-Cuj2daUE.mjs +0 -8
  109. package/dist/types-Cuj2daUE.mjs.map +0 -1
  110. package/dist/types-D03SjfBL.d.mts +0 -55
  111. package/dist/types-D03SjfBL.d.mts.map +0 -1
  112. package/dist/types-D52qMMoK.d.cts +0 -55
  113. package/dist/types-D52qMMoK.d.cts.map +0 -1
  114. package/dist/types-DHrjS-69.cjs +0 -13
  115. package/schemas/index-BAJMwFip.d.mts +0 -96
  116. package/schemas/index-BAJMwFip.d.mts.map +0 -1
  117. package/schemas/index-b7dam4EA.d.cts +0 -96
  118. package/schemas/index-b7dam4EA.d.cts.map +0 -1
  119. package/schemas/src-s2pCu2mc.mjs.map +0 -1
@@ -0,0 +1,2991 @@
1
+ //#region ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=503a440bd2bef41c0cb22819bc4ced5a7f04993fb999f0d944e284220f14916b_typescript@6.0.3/node_modules/capnp-es/dist/shared/capnp-es.Dd0AvjKJ.d.mts
2
+ declare enum ListElementSize {
3
+ VOID = 0,
4
+ BIT = 1,
5
+ BYTE = 2,
6
+ BYTE_2 = 3,
7
+ BYTE_4 = 4,
8
+ BYTE_8 = 5,
9
+ POINTER = 6,
10
+ COMPOSITE = 7
11
+ }
12
+ /**
13
+ * A simple object that describes the size of a struct.
14
+ */
15
+ declare class ObjectSize {
16
+ readonly dataByteLength: number;
17
+ readonly pointerLength: number;
18
+ /**
19
+ * Creates a new ObjectSize instance.
20
+ *
21
+ * @param dataByteLength - The number of bytes in the data section of the struct
22
+ * @param pointerLength - The number of pointers in the pointer section of the struct
23
+ */
24
+ constructor(dataByteLength: number, pointerLength: number);
25
+ toString(): string;
26
+ }
27
+ interface _PointerCtor {
28
+ readonly displayName: string;
29
+ }
30
+ interface PointerCtor<T extends Pointer> {
31
+ readonly _capnp: _PointerCtor;
32
+ new (segment: Segment, byteOffset: number, depthLimit?: number): T;
33
+ }
34
+ declare enum PointerType {
35
+ STRUCT = 0,
36
+ LIST = 1,
37
+ FAR = 2,
38
+ OTHER = 3
39
+ }
40
+ interface _Pointer {
41
+ compositeIndex?: number;
42
+ compositeList: boolean;
43
+ /**
44
+ * A number that is decremented as nested pointers are traversed. When this hits zero errors will be thrown.
45
+ */
46
+ depthLimit: number;
47
+ }
48
+ /**
49
+ * A pointer referencing a single byte location in a segment. This is typically used for Cap'n Proto pointers, but is
50
+ * also sometimes used to reference an offset to a pointer's content or tag words.
51
+ */
52
+ declare class Pointer<T extends _Pointer = _Pointer> {
53
+ static readonly _capnp: _PointerCtor;
54
+ readonly _capnp: T;
55
+ /** Offset, in bytes, from the start of the segment to the beginning of this pointer. */
56
+ byteOffset: number;
57
+ /**
58
+ * The starting segment for this pointer's data. In the case of a far pointer, the actual content this pointer is
59
+ * referencing will be in another segment within the same message.
60
+ */
61
+ segment: Segment;
62
+ constructor(segment: Segment, byteOffset: number, depthLimit?: number);
63
+ [Symbol.toStringTag](): string;
64
+ toString(): string;
65
+ }
66
+ interface _ListCtor {
67
+ readonly compositeSize?: ObjectSize;
68
+ readonly displayName: string;
69
+ readonly size: ListElementSize;
70
+ }
71
+ interface ListCtor<T> {
72
+ readonly _capnp: _ListCtor;
73
+ new (segment: Segment, byteOffset: number, depthLimit?: number): List<T>;
74
+ }
75
+ type ArrayCb<T, RT = boolean> = (this: any, value: T, index: number, array: T[]) => RT;
76
+ /**
77
+ * A generic list class. Implements Filterable,
78
+ */
79
+ declare class List<T> extends Pointer implements Array<T> {
80
+ #private;
81
+ static readonly _capnp: _ListCtor;
82
+ [n: number]: T;
83
+ constructor(segment: Segment, byteOffset: number, depthLimit?: number);
84
+ get length(): number;
85
+ toArray(): T[];
86
+ get(_index: number): T;
87
+ set(_index: number, _value: T): void;
88
+ at(index: number): T;
89
+ concat(other: T[]): T[];
90
+ some(cb: ArrayCb<T>, _this?: any): boolean;
91
+ filter(cb: ArrayCb<T>, _this?: any): T[];
92
+ find(cb: ArrayCb<T>, _this?: any): T | undefined;
93
+ findIndex(cb: (v: T, i: number, arr: T[]) => boolean, _this?: any): number;
94
+ forEach(cb: ArrayCb<T, void>, _this?: any): void;
95
+ map<U>(cb: ArrayCb<T, U>, _this?: any): U[];
96
+ flatMap<U>(cb: ArrayCb<T, U | U[]>, _this?: any): U[];
97
+ every<S extends T>(cb: (v: T, i: number) => v is S, t?: any): this is S[];
98
+ reduce(cb: (p: T, c: T, i: number, a: T[]) => T, initialValue?: T): T;
99
+ reduceRight(cb: (p: T, c: T, i: number, a: T[]) => T, initialValue?: T): T;
100
+ slice(start?: number, end?: number): T[];
101
+ join(separator?: string): string;
102
+ toReversed(): T[];
103
+ toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[];
104
+ toSpliced(start: number, deleteCount: number, ...items: T[]): T[];
105
+ fill(value: T, start?: number, end?: number): this;
106
+ copyWithin(target: number, start: number, end?: number): this;
107
+ keys(): ArrayIterator<number>;
108
+ values(): ArrayIterator<T>;
109
+ entries(): ArrayIterator<[number, T]>;
110
+ flat<A, D extends number = 1>(this: A, depth?: D): FlatArray<A, D>[];
111
+ with(index: number, value: T): T[];
112
+ includes(_searchElement: T, _fromIndex?: number): boolean;
113
+ findLast(_cb: unknown, _thisArg?: unknown): T | undefined;
114
+ findLastIndex(_cb: (v: T, i: number, a: T[]) => unknown, _t?: any): number;
115
+ indexOf(_searchElement: T, _fromIndex?: number): number;
116
+ lastIndexOf(_searchElement: T, _fromIndex?: number): number;
117
+ pop(): T | undefined;
118
+ push(..._items: T[]): number;
119
+ reverse(): T[];
120
+ shift(): T | undefined;
121
+ unshift(..._items: T[]): number;
122
+ splice(_start: unknown, _deleteCount?: unknown, ..._rest: unknown[]): T[];
123
+ sort(_fn?: ((a: T, b: T) => number) | undefined): this;
124
+ get [Symbol.unscopables](): {
125
+ [x: number]: boolean | undefined;
126
+ length?: boolean | undefined;
127
+ toString?: boolean | undefined;
128
+ toLocaleString?: boolean | undefined;
129
+ pop?: boolean | undefined;
130
+ push?: boolean | undefined;
131
+ concat?: boolean | undefined;
132
+ join?: boolean | undefined;
133
+ reverse?: boolean | undefined;
134
+ shift?: boolean | undefined;
135
+ slice?: boolean | undefined;
136
+ sort?: boolean | undefined;
137
+ splice?: boolean | undefined;
138
+ unshift?: boolean | undefined;
139
+ indexOf?: boolean | undefined;
140
+ lastIndexOf?: boolean | undefined;
141
+ every?: boolean | undefined;
142
+ some?: boolean | undefined;
143
+ forEach?: boolean | undefined;
144
+ map?: boolean | undefined;
145
+ filter?: boolean | undefined;
146
+ reduce?: boolean | undefined;
147
+ reduceRight?: boolean | undefined;
148
+ find?: boolean | undefined;
149
+ findIndex?: boolean | undefined;
150
+ fill?: boolean | undefined;
151
+ copyWithin?: boolean | undefined;
152
+ entries?: boolean | undefined;
153
+ keys?: boolean | undefined;
154
+ values?: boolean | undefined;
155
+ includes?: boolean | undefined;
156
+ flatMap?: boolean | undefined;
157
+ flat?: boolean | undefined;
158
+ at?: boolean | undefined;
159
+ findLast?: boolean | undefined;
160
+ findLastIndex?: boolean | undefined;
161
+ toReversed?: boolean | undefined;
162
+ toSorted?: boolean | undefined;
163
+ toSpliced?: boolean | undefined;
164
+ with?: boolean | undefined;
165
+ [Symbol.iterator]?: boolean | undefined;
166
+ readonly [Symbol.unscopables]?: boolean | undefined;
167
+ };
168
+ [Symbol.iterator](): ArrayIterator<T>;
169
+ toJSON(): unknown;
170
+ toString(): string;
171
+ toLocaleString(_locales?: unknown, _options?: unknown): string;
172
+ [Symbol.toStringTag](): string;
173
+ static [Symbol.toStringTag](): string;
174
+ }
175
+ declare const Message_Which: {
176
+ /**
177
+ * The sender previously received this message from the peer but didn't understand it or doesn't
178
+ * yet implement the functionality that was requested. So, the sender is echoing the message
179
+ * back. In some cases, the receiver may be able to recover from this by pretending the sender
180
+ * had taken some appropriate "null" action.
181
+ *
182
+ * For example, say `resolve` is received by a level 0 implementation (because a previous call
183
+ * or return happened to contain a promise). The level 0 implementation will echo it back as
184
+ * `unimplemented`. The original sender can then simply release the cap to which the promise
185
+ * had resolved, thus avoiding a leak.
186
+ *
187
+ * For any message type that introduces a question, if the message comes back unimplemented,
188
+ * the original sender may simply treat it as if the question failed with an exception.
189
+ *
190
+ * In cases where there is no sensible way to react to an `unimplemented` message (without
191
+ * resource leaks or other serious problems), the connection may need to be aborted. This is
192
+ * a gray area; different implementations may take different approaches.
193
+ *
194
+ */
195
+ readonly UNIMPLEMENTED: 0;
196
+ /**
197
+ * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
198
+ * because the sender received an invalid or nonsensical message or because the sender had an
199
+ * internal error. The sender will shut down the outgoing half of the connection after `abort`
200
+ * and will completely close the connection shortly thereafter (it's up to the sender how much
201
+ * of a time buffer they want to offer for the client to receive the `abort` before the
202
+ * connection is reset).
203
+ *
204
+ */
205
+ readonly ABORT: 1;
206
+ /**
207
+ * Request the peer's bootstrap interface.
208
+ *
209
+ */
210
+ readonly BOOTSTRAP: 8;
211
+ /**
212
+ * Begin a method call.
213
+ *
214
+ */
215
+ readonly CALL: 2;
216
+ /**
217
+ * Complete a method call.
218
+ *
219
+ */
220
+ readonly RETURN: 3;
221
+ /**
222
+ * Release a returned answer / cancel a call.
223
+ *
224
+ */
225
+ readonly FINISH: 4;
226
+ /**
227
+ * Resolve a previously-sent promise.
228
+ *
229
+ */
230
+ readonly RESOLVE: 5;
231
+ /**
232
+ * Release a capability so that the remote object can be deallocated.
233
+ *
234
+ */
235
+ readonly RELEASE: 6;
236
+ /**
237
+ * Lift an embargo used to enforce E-order over promise resolution.
238
+ *
239
+ */
240
+ readonly DISEMBARGO: 13;
241
+ /**
242
+ * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
243
+ * by the `Persistent` interface defined in `persistent.capnp`. This operation was never
244
+ * implemented.
245
+ *
246
+ */
247
+ readonly OBSOLETE_SAVE: 7;
248
+ /**
249
+ * Obsolete way to delete a SturdyRef. This operation was never implemented.
250
+ *
251
+ */
252
+ readonly OBSOLETE_DELETE: 9;
253
+ /**
254
+ * Provide a capability to a third party.
255
+ *
256
+ */
257
+ readonly PROVIDE: 10;
258
+ /**
259
+ * Accept a capability provided by a third party.
260
+ *
261
+ */
262
+ readonly ACCEPT: 11;
263
+ /**
264
+ * Directly connect to the common root of two or more proxied caps.
265
+ *
266
+ */
267
+ readonly JOIN: 12;
268
+ };
269
+ type Message_Which = (typeof Message_Which)[keyof typeof Message_Which];
270
+ /**
271
+ * An RPC connection is a bi-directional stream of Messages.
272
+ *
273
+ */
274
+ declare class Message$1 extends Struct {
275
+ static readonly UNIMPLEMENTED: 0;
276
+ static readonly ABORT: 1;
277
+ static readonly BOOTSTRAP: 8;
278
+ static readonly CALL: 2;
279
+ static readonly RETURN: 3;
280
+ static readonly FINISH: 4;
281
+ static readonly RESOLVE: 5;
282
+ static readonly RELEASE: 6;
283
+ static readonly DISEMBARGO: 13;
284
+ static readonly OBSOLETE_SAVE: 7;
285
+ static readonly OBSOLETE_DELETE: 9;
286
+ static readonly PROVIDE: 10;
287
+ static readonly ACCEPT: 11;
288
+ static readonly JOIN: 12;
289
+ static readonly _capnp: {
290
+ displayName: string;
291
+ id: string;
292
+ size: ObjectSize;
293
+ };
294
+ _adoptUnimplemented(value: Orphan<Message$1>): void;
295
+ _disownUnimplemented(): Orphan<Message$1>;
296
+ /**
297
+ * The sender previously received this message from the peer but didn't understand it or doesn't
298
+ * yet implement the functionality that was requested. So, the sender is echoing the message
299
+ * back. In some cases, the receiver may be able to recover from this by pretending the sender
300
+ * had taken some appropriate "null" action.
301
+ *
302
+ * For example, say `resolve` is received by a level 0 implementation (because a previous call
303
+ * or return happened to contain a promise). The level 0 implementation will echo it back as
304
+ * `unimplemented`. The original sender can then simply release the cap to which the promise
305
+ * had resolved, thus avoiding a leak.
306
+ *
307
+ * For any message type that introduces a question, if the message comes back unimplemented,
308
+ * the original sender may simply treat it as if the question failed with an exception.
309
+ *
310
+ * In cases where there is no sensible way to react to an `unimplemented` message (without
311
+ * resource leaks or other serious problems), the connection may need to be aborted. This is
312
+ * a gray area; different implementations may take different approaches.
313
+ *
314
+ */
315
+ get unimplemented(): Message$1;
316
+ _hasUnimplemented(): boolean;
317
+ _initUnimplemented(): Message$1;
318
+ get _isUnimplemented(): boolean;
319
+ set unimplemented(value: Message$1);
320
+ _adoptAbort(value: Orphan<Exception>): void;
321
+ _disownAbort(): Orphan<Exception>;
322
+ /**
323
+ * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
324
+ * because the sender received an invalid or nonsensical message or because the sender had an
325
+ * internal error. The sender will shut down the outgoing half of the connection after `abort`
326
+ * and will completely close the connection shortly thereafter (it's up to the sender how much
327
+ * of a time buffer they want to offer for the client to receive the `abort` before the
328
+ * connection is reset).
329
+ *
330
+ */
331
+ get abort(): Exception;
332
+ _hasAbort(): boolean;
333
+ _initAbort(): Exception;
334
+ get _isAbort(): boolean;
335
+ set abort(value: Exception);
336
+ _adoptBootstrap(value: Orphan<Bootstrap>): void;
337
+ _disownBootstrap(): Orphan<Bootstrap>;
338
+ /**
339
+ * Request the peer's bootstrap interface.
340
+ *
341
+ */
342
+ get bootstrap(): Bootstrap;
343
+ _hasBootstrap(): boolean;
344
+ _initBootstrap(): Bootstrap;
345
+ get _isBootstrap(): boolean;
346
+ set bootstrap(value: Bootstrap);
347
+ _adoptCall(value: Orphan<Call$1>): void;
348
+ _disownCall(): Orphan<Call$1>;
349
+ /**
350
+ * Begin a method call.
351
+ *
352
+ */
353
+ get call(): Call$1;
354
+ _hasCall(): boolean;
355
+ _initCall(): Call$1;
356
+ get _isCall(): boolean;
357
+ set call(value: Call$1);
358
+ _adoptReturn(value: Orphan<Return>): void;
359
+ _disownReturn(): Orphan<Return>;
360
+ /**
361
+ * Complete a method call.
362
+ *
363
+ */
364
+ get return(): Return;
365
+ _hasReturn(): boolean;
366
+ _initReturn(): Return;
367
+ get _isReturn(): boolean;
368
+ set return(value: Return);
369
+ _adoptFinish(value: Orphan<Finish>): void;
370
+ _disownFinish(): Orphan<Finish>;
371
+ /**
372
+ * Release a returned answer / cancel a call.
373
+ *
374
+ */
375
+ get finish(): Finish;
376
+ _hasFinish(): boolean;
377
+ _initFinish(): Finish;
378
+ get _isFinish(): boolean;
379
+ set finish(value: Finish);
380
+ _adoptResolve(value: Orphan<Resolve>): void;
381
+ _disownResolve(): Orphan<Resolve>;
382
+ /**
383
+ * Resolve a previously-sent promise.
384
+ *
385
+ */
386
+ get resolve(): Resolve;
387
+ _hasResolve(): boolean;
388
+ _initResolve(): Resolve;
389
+ get _isResolve(): boolean;
390
+ set resolve(value: Resolve);
391
+ _adoptRelease(value: Orphan<Release>): void;
392
+ _disownRelease(): Orphan<Release>;
393
+ /**
394
+ * Release a capability so that the remote object can be deallocated.
395
+ *
396
+ */
397
+ get release(): Release;
398
+ _hasRelease(): boolean;
399
+ _initRelease(): Release;
400
+ get _isRelease(): boolean;
401
+ set release(value: Release);
402
+ _adoptDisembargo(value: Orphan<Disembargo>): void;
403
+ _disownDisembargo(): Orphan<Disembargo>;
404
+ /**
405
+ * Lift an embargo used to enforce E-order over promise resolution.
406
+ *
407
+ */
408
+ get disembargo(): Disembargo;
409
+ _hasDisembargo(): boolean;
410
+ _initDisembargo(): Disembargo;
411
+ get _isDisembargo(): boolean;
412
+ set disembargo(value: Disembargo);
413
+ _adoptObsoleteSave(value: Orphan<Pointer>): void;
414
+ _disownObsoleteSave(): Orphan<Pointer>;
415
+ /**
416
+ * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
417
+ * by the `Persistent` interface defined in `persistent.capnp`. This operation was never
418
+ * implemented.
419
+ *
420
+ */
421
+ get obsoleteSave(): Pointer;
422
+ _hasObsoleteSave(): boolean;
423
+ get _isObsoleteSave(): boolean;
424
+ set obsoleteSave(value: Pointer);
425
+ _adoptObsoleteDelete(value: Orphan<Pointer>): void;
426
+ _disownObsoleteDelete(): Orphan<Pointer>;
427
+ /**
428
+ * Obsolete way to delete a SturdyRef. This operation was never implemented.
429
+ *
430
+ */
431
+ get obsoleteDelete(): Pointer;
432
+ _hasObsoleteDelete(): boolean;
433
+ get _isObsoleteDelete(): boolean;
434
+ set obsoleteDelete(value: Pointer);
435
+ _adoptProvide(value: Orphan<Provide>): void;
436
+ _disownProvide(): Orphan<Provide>;
437
+ /**
438
+ * Provide a capability to a third party.
439
+ *
440
+ */
441
+ get provide(): Provide;
442
+ _hasProvide(): boolean;
443
+ _initProvide(): Provide;
444
+ get _isProvide(): boolean;
445
+ set provide(value: Provide);
446
+ _adoptAccept(value: Orphan<Accept>): void;
447
+ _disownAccept(): Orphan<Accept>;
448
+ /**
449
+ * Accept a capability provided by a third party.
450
+ *
451
+ */
452
+ get accept(): Accept;
453
+ _hasAccept(): boolean;
454
+ _initAccept(): Accept;
455
+ get _isAccept(): boolean;
456
+ set accept(value: Accept);
457
+ _adoptJoin(value: Orphan<Join>): void;
458
+ _disownJoin(): Orphan<Join>;
459
+ /**
460
+ * Directly connect to the common root of two or more proxied caps.
461
+ *
462
+ */
463
+ get join(): Join;
464
+ _hasJoin(): boolean;
465
+ _initJoin(): Join;
466
+ get _isJoin(): boolean;
467
+ set join(value: Join);
468
+ toString(): string;
469
+ which(): Message_Which;
470
+ }
471
+ /**
472
+ * **(level 0)**
473
+ *
474
+ * Get the "bootstrap" interface exported by the remote vat.
475
+ *
476
+ * For level 0, 1, and 2 implementations, the "bootstrap" interface is simply the main interface
477
+ * exported by a vat. If the vat acts as a server fielding connections from clients, then the
478
+ * bootstrap interface defines the basic functionality available to a client when it connects.
479
+ * The exact interface definition obviously depends on the application.
480
+ *
481
+ * We call this a "bootstrap" because in an ideal Cap'n Proto world, bootstrap interfaces would
482
+ * never be used. In such a world, any time you connect to a new vat, you do so because you
483
+ * received an introduction from some other vat (see `ThirdPartyCapId`). Thus, the first message
484
+ * you send is `Accept`, and further communications derive from there. `Bootstrap` is not used.
485
+ *
486
+ * In such an ideal world, DNS itself would support Cap'n Proto -- performing a DNS lookup would
487
+ * actually return a new Cap'n Proto capability, thus introducing you to the target system via
488
+ * level 3 RPC. Applications would receive the capability to talk to DNS in the first place as
489
+ * an initial endowment or part of a Powerbox interaction. Therefore, an app can form arbitrary
490
+ * connections without ever using `Bootstrap`.
491
+ *
492
+ * Of course, in the real world, DNS is not Cap'n-Proto-based, and we don't want Cap'n Proto to
493
+ * require a whole new internet infrastructure to be useful. Therefore, we offer bootstrap
494
+ * interfaces as a way to get up and running without a level 3 introduction. Thus, bootstrap
495
+ * interfaces are used to "bootstrap" from other, non-Cap'n-Proto-based means of service discovery,
496
+ * such as legacy DNS.
497
+ *
498
+ * Note that a vat need not provide a bootstrap interface, and in fact many vats (especially those
499
+ * acting as clients) do not. In this case, the vat should either reply to `Bootstrap` with a
500
+ * `Return` indicating an exception, or should return a dummy capability with no methods.
501
+ *
502
+ */
503
+ declare class Bootstrap extends Struct {
504
+ static readonly _capnp: {
505
+ displayName: string;
506
+ id: string;
507
+ size: ObjectSize;
508
+ };
509
+ /**
510
+ * A new question ID identifying this request, which will eventually receive a Return message
511
+ * containing the restored capability.
512
+ *
513
+ */
514
+ get questionId(): number;
515
+ set questionId(value: number);
516
+ _adoptDeprecatedObjectId(value: Orphan<Pointer>): void;
517
+ _disownDeprecatedObjectId(): Orphan<Pointer>;
518
+ /**
519
+ * ** DEPRECATED **
520
+ *
521
+ * A Vat may export multiple bootstrap interfaces. In this case, `deprecatedObjectId` specifies
522
+ * which one to return. If this pointer is null, then the default bootstrap interface is returned.
523
+ *
524
+ * As of version 0.5, use of this field is deprecated. If a service wants to export multiple
525
+ * bootstrap interfaces, it should instead define a single bootstrap interface that has methods
526
+ * that return each of the other interfaces.
527
+ *
528
+ * **History**
529
+ *
530
+ * In the first version of Cap'n Proto RPC (0.4.x) the `Bootstrap` message was called `Restore`.
531
+ * At the time, it was thought that this would eventually serve as the way to restore SturdyRefs
532
+ * (level 2). Meanwhile, an application could offer its "main" interface on a well-known
533
+ * (non-secret) SturdyRef.
534
+ *
535
+ * Since level 2 RPC was not implemented at the time, the `Restore` message was in practice only
536
+ * used to obtain the main interface. Since most applications had only one main interface that
537
+ * they wanted to restore, they tended to designate this with a null `objectId`.
538
+ *
539
+ * Unfortunately, the earliest version of the EZ RPC interfaces set a precedent of exporting
540
+ * multiple main interfaces by allowing them to be exported under string names. In this case,
541
+ * `objectId` was a Text value specifying the name.
542
+ *
543
+ * All of this proved problematic for several reasons:
544
+ *
545
+ * - The arrangement assumed that a client wishing to restore a SturdyRef would know exactly what
546
+ * machine to connect to and would be able to immediately restore a SturdyRef on connection.
547
+ * However, in practice, the ability to restore SturdyRefs is itself a capability that may
548
+ * require going through an authentication process to obtain. Thus, it makes more sense to
549
+ * define a "restorer service" as a full Cap'n Proto interface. If this restorer interface is
550
+ * offered as the vat's bootstrap interface, then this is equivalent to the old arrangement.
551
+ *
552
+ * - Overloading "Restore" for the purpose of obtaining well-known capabilities encouraged the
553
+ * practice of exporting singleton services with string names. If singleton services are desired,
554
+ * it is better to have one main interface that has methods that can be used to obtain each
555
+ * service, in order to get all the usual benefits of schemas and type checking.
556
+ *
557
+ * - Overloading "Restore" also had a security problem: Often, "main" or "well-known"
558
+ * capabilities exported by a vat are in fact not public: they are intended to be accessed only
559
+ * by clients who are capable of forming a connection to the vat. This can lead to trouble if
560
+ * the client itself has other clients and wishes to forward some `Restore` requests from those
561
+ * external clients -- it has to be very careful not to allow through `Restore` requests
562
+ * addressing the default capability.
563
+ *
564
+ * For example, consider the case of a sandboxed Sandstorm application and its supervisor. The
565
+ * application exports a default capability to its supervisor that provides access to
566
+ * functionality that only the supervisor is supposed to access. Meanwhile, though, applications
567
+ * may publish other capabilities that may be persistent, in which case the application needs
568
+ * to field `Restore` requests that could come from anywhere. These requests of course have to
569
+ * pass through the supervisor, as all communications with the outside world must. But, the
570
+ * supervisor has to be careful not to honor an external request addressing the application's
571
+ * default capability, since this capability is privileged. Unfortunately, the default
572
+ * capability cannot be given an unguessable name, because then the supervisor itself would not
573
+ * be able to address it!
574
+ *
575
+ * As of Cap'n Proto 0.5, `Restore` has been renamed to `Bootstrap` and is no longer planned for
576
+ * use in restoring SturdyRefs.
577
+ *
578
+ * Note that 0.4 also defined a message type called `Delete` that, like `Restore`, addressed a
579
+ * SturdyRef, but indicated that the client would not restore the ref again in the future. This
580
+ * operation was never implemented, so it was removed entirely. If a "delete" operation is desired,
581
+ * it should exist as a method on the same interface that handles restoring SturdyRefs. However,
582
+ * the utility of such an operation is questionable. You wouldn't be able to rely on it for
583
+ * garbage collection since a client could always disappear permanently without remembering to
584
+ * delete all its SturdyRefs, thus leaving them dangling forever. Therefore, it is advisable to
585
+ * design systems such that SturdyRefs never represent "owned" pointers.
586
+ *
587
+ * For example, say a SturdyRef points to an image file hosted on some server. That image file
588
+ * should also live inside a collection (a gallery, perhaps) hosted on the same server, owned by
589
+ * a user who can delete the image at any time. If the user deletes the image, the SturdyRef
590
+ * stops working. On the other hand, if the SturdyRef is discarded, this has no effect on the
591
+ * existence of the image in its collection.
592
+ *
593
+ */
594
+ get deprecatedObjectId(): Pointer;
595
+ _hasDeprecatedObjectId(): boolean;
596
+ set deprecatedObjectId(value: Pointer);
597
+ toString(): string;
598
+ }
599
+ declare const Call_SendResultsTo_Which: {
600
+ /**
601
+ * Send the return message back to the caller (the usual).
602
+ *
603
+ */
604
+ readonly CALLER: 0;
605
+ /**
606
+ * **(level 1)**
607
+ *
608
+ * Don't actually return the results to the sender. Instead, hold on to them and await
609
+ * instructions from the sender regarding what to do with them. In particular, the sender
610
+ * may subsequently send a `Return` for some other call (which the receiver had previously made
611
+ * to the sender) with `takeFromOtherQuestion` set. The results from this call are then used
612
+ * as the results of the other call.
613
+ *
614
+ * When `yourself` is used, the receiver must still send a `Return` for the call, but sets the
615
+ * field `resultsSentElsewhere` in that `Return` rather than including the results.
616
+ *
617
+ * This feature can be used to implement tail calls in which a call from Vat A to Vat B ends up
618
+ * returning the result of a call from Vat B back to Vat A.
619
+ *
620
+ * In particular, the most common use case for this feature is when Vat A makes a call to a
621
+ * promise in Vat B, and then that promise ends up resolving to a capability back in Vat A.
622
+ * Vat B must forward all the queued calls on that promise back to Vat A, but can set `yourself`
623
+ * in the calls so that the results need not pass back through Vat B.
624
+ *
625
+ * For example:
626
+ * - Alice, in Vat A, calls foo() on Bob in Vat B.
627
+ * - Alice makes a pipelined call bar() on the promise returned by foo().
628
+ * - Later on, Bob resolves the promise from foo() to point at Carol, who lives in Vat A (next
629
+ * to Alice).
630
+ * - Vat B dutifully forwards the bar() call to Carol. Let us call this forwarded call bar'().
631
+ * Notice that bar() and bar'() are travelling in opposite directions on the same network
632
+ * link.
633
+ * - The `Call` for bar'() has `sendResultsTo` set to `yourself`.
634
+ * - Vat B sends a `Return` for bar() with `takeFromOtherQuestion` set in place of the results,
635
+ * with the value set to the question ID of bar'(). Vat B does not wait for bar'() to return,
636
+ * as doing so would introduce unnecessary round trip latency.
637
+ * - Vat A receives bar'() and delivers it to Carol.
638
+ * - When bar'() returns, Vat A sends a `Return` for bar'() to Vat B, with `resultsSentElsewhere`
639
+ * set in place of results.
640
+ * - Vat A sends a `Finish` for the bar() call to Vat B.
641
+ * - Vat B receives the `Finish` for bar() and sends a `Finish` for bar'().
642
+ *
643
+ */
644
+ readonly YOURSELF: 1;
645
+ /**
646
+ * **(level 3)**
647
+ *
648
+ * The call's result should be returned to a different vat. The receiver (the callee) expects
649
+ * to receive an `Accept` message from the indicated vat, and should return the call's result
650
+ * to it, rather than to the sender of the `Call`.
651
+ *
652
+ * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
653
+ * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
654
+ * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
655
+ * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
656
+ * also sends a `Return` to Vat B with `resultsSentElsewhere`.
657
+ *
658
+ */
659
+ readonly THIRD_PARTY: 2;
660
+ };
661
+ type Call_SendResultsTo_Which = (typeof Call_SendResultsTo_Which)[keyof typeof Call_SendResultsTo_Which];
662
+ /**
663
+ * Where should the return message be sent?
664
+ *
665
+ */
666
+ declare class Call_SendResultsTo extends Struct {
667
+ static readonly CALLER: 0;
668
+ static readonly YOURSELF: 1;
669
+ static readonly THIRD_PARTY: 2;
670
+ static readonly _capnp: {
671
+ displayName: string;
672
+ id: string;
673
+ size: ObjectSize;
674
+ };
675
+ get _isCaller(): boolean;
676
+ set caller(_: true);
677
+ get _isYourself(): boolean;
678
+ set yourself(_: true);
679
+ _adoptThirdParty(value: Orphan<Pointer>): void;
680
+ _disownThirdParty(): Orphan<Pointer>;
681
+ /**
682
+ * **(level 3)**
683
+ *
684
+ * The call's result should be returned to a different vat. The receiver (the callee) expects
685
+ * to receive an `Accept` message from the indicated vat, and should return the call's result
686
+ * to it, rather than to the sender of the `Call`.
687
+ *
688
+ * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
689
+ * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
690
+ * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
691
+ * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
692
+ * also sends a `Return` to Vat B with `resultsSentElsewhere`.
693
+ *
694
+ */
695
+ get thirdParty(): Pointer;
696
+ _hasThirdParty(): boolean;
697
+ get _isThirdParty(): boolean;
698
+ set thirdParty(value: Pointer);
699
+ toString(): string;
700
+ which(): Call_SendResultsTo_Which;
701
+ }
702
+ /**
703
+ * **(level 0)**
704
+ *
705
+ * Message type initiating a method call on a capability.
706
+ *
707
+ */
708
+ declare class Call$1 extends Struct {
709
+ static readonly _capnp: {
710
+ displayName: string;
711
+ id: string;
712
+ size: ObjectSize;
713
+ defaultAllowThirdPartyTailCall: DataView<ArrayBufferLike>;
714
+ defaultNoPromisePipelining: DataView<ArrayBufferLike>;
715
+ defaultOnlyPromisePipeline: DataView<ArrayBufferLike>;
716
+ };
717
+ /**
718
+ * A number, chosen by the caller, that identifies this call in future messages. This number
719
+ * must be different from all other calls originating from the same end of the connection (but
720
+ * may overlap with question IDs originating from the opposite end). A fine strategy is to use
721
+ * sequential question IDs, but the recipient should not assume this.
722
+ *
723
+ * A question ID can be reused once both:
724
+ * - A matching Return has been received from the callee.
725
+ * - A matching Finish has been sent from the caller.
726
+ *
727
+ */
728
+ get questionId(): number;
729
+ set questionId(value: number);
730
+ _adoptTarget(value: Orphan<MessageTarget>): void;
731
+ _disownTarget(): Orphan<MessageTarget>;
732
+ /**
733
+ * The object that should receive this call.
734
+ *
735
+ */
736
+ get target(): MessageTarget;
737
+ _hasTarget(): boolean;
738
+ _initTarget(): MessageTarget;
739
+ set target(value: MessageTarget);
740
+ /**
741
+ * The type ID of the interface being called. Each capability may implement multiple interfaces.
742
+ *
743
+ */
744
+ get interfaceId(): bigint;
745
+ set interfaceId(value: bigint);
746
+ /**
747
+ * The ordinal number of the method to call within the requested interface.
748
+ *
749
+ */
750
+ get methodId(): number;
751
+ set methodId(value: number);
752
+ /**
753
+ * Indicates whether or not the receiver is allowed to send a `Return` containing
754
+ * `acceptFromThirdParty`. Level 3 implementations should set this true. Otherwise, the callee
755
+ * will have to proxy the return in the case of a tail call to a third-party vat.
756
+ *
757
+ */
758
+ get allowThirdPartyTailCall(): boolean;
759
+ set allowThirdPartyTailCall(value: boolean);
760
+ /**
761
+ * If true, the sender promises that it won't make any promise-pipelined calls on the results of
762
+ * this call. If it breaks this promise, the receiver may throw an arbitrary error from such
763
+ * calls.
764
+ *
765
+ * The receiver may use this as an optimization, by skipping the bookkeeping needed for pipelining
766
+ * when no pipelined calls are expected. The sender typically sets this to false when the method's
767
+ * schema does not specify any return capabilities.
768
+ *
769
+ */
770
+ get noPromisePipelining(): boolean;
771
+ set noPromisePipelining(value: boolean);
772
+ /**
773
+ * If true, the sender only plans to use this call to make pipelined calls. The receiver need not
774
+ * send a `Return` message (but is still allowed to do so).
775
+ *
776
+ * Since the sender does not know whether a `Return` will be sent, it must release all state
777
+ * related to the call when it sends `Finish`. However, in the case that the callee does not
778
+ * recognize this hint and chooses to send a `Return`, then technically the caller is not allowed
779
+ * to reuse the question ID until it receives said `Return`. This creates a conundrum: How does
780
+ * the caller decide when it's OK to reuse the ID? To sidestep the problem, the C++ implementation
781
+ * uses high-numbered IDs (with the high-order bit set) for such calls, and cycles through the
782
+ * IDs in order. If all 2^31 IDs in this space are used without ever seeing a `Return`, then the
783
+ * implementation assumes that the other end is in fact honoring the hint, and the ID counter is
784
+ * allowed to loop around. If a `Return` is ever seen when `onlyPromisePipeline` was set, then
785
+ * the implementation stops using this hint.
786
+ *
787
+ */
788
+ get onlyPromisePipeline(): boolean;
789
+ set onlyPromisePipeline(value: boolean);
790
+ _adoptParams(value: Orphan<Payload>): void;
791
+ _disownParams(): Orphan<Payload>;
792
+ /**
793
+ * The call parameters. `params.content` is a struct whose fields correspond to the parameters of
794
+ * the method.
795
+ *
796
+ */
797
+ get params(): Payload;
798
+ _hasParams(): boolean;
799
+ _initParams(): Payload;
800
+ set params(value: Payload);
801
+ /**
802
+ * Where should the return message be sent?
803
+ *
804
+ */
805
+ get sendResultsTo(): Call_SendResultsTo;
806
+ _initSendResultsTo(): Call_SendResultsTo;
807
+ toString(): string;
808
+ }
809
+ declare const Return_Which: {
810
+ /**
811
+ * Equal to the QuestionId of the corresponding `Call` message.
812
+ *
813
+ */
814
+ readonly RESULTS: 0;
815
+ /**
816
+ * If true, all capabilities that were in the params should be considered released. The sender
817
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
818
+ * should always set this true. This defaults true because if level 0 implementations forget to
819
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
820
+ * to set it to false they'll quickly get errors.
821
+ *
822
+ * The receiver should act as if the sender had sent a release message with count=1 for each
823
+ * CapDescriptor in the original Call message.
824
+ *
825
+ */
826
+ readonly EXCEPTION: 1;
827
+ /**
828
+ * The result.
829
+ *
830
+ * For regular method calls, `results.content` points to the result struct.
831
+ *
832
+ * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
833
+ * capability (rather than a struct), and `results.content` is just a capability pointer with
834
+ * index 0. A `Finish` is still required in this case.
835
+ *
836
+ */
837
+ readonly CANCELED: 2;
838
+ /**
839
+ * Indicates that the call failed and explains why.
840
+ *
841
+ */
842
+ readonly RESULTS_SENT_ELSEWHERE: 3;
843
+ /**
844
+ * Indicates that the call was canceled due to the caller sending a Finish message
845
+ * before the call had completed.
846
+ *
847
+ */
848
+ readonly TAKE_FROM_OTHER_QUESTION: 4;
849
+ /**
850
+ * This is set when returning from a `Call` that had `sendResultsTo` set to something other
851
+ * than `caller`.
852
+ *
853
+ * It doesn't matter too much when this is sent, as the receiver doesn't need to do anything
854
+ * with it, but the C++ implementation appears to wait for the call to finish before sending
855
+ * this.
856
+ *
857
+ */
858
+ readonly ACCEPT_FROM_THIRD_PARTY: 5;
859
+ };
860
+ type Return_Which = (typeof Return_Which)[keyof typeof Return_Which];
861
+ /**
862
+ * **(level 0)**
863
+ *
864
+ * Message type sent from callee to caller indicating that the call has completed.
865
+ *
866
+ */
867
+ declare class Return extends Struct {
868
+ static readonly RESULTS: 0;
869
+ static readonly EXCEPTION: 1;
870
+ static readonly CANCELED: 2;
871
+ static readonly RESULTS_SENT_ELSEWHERE: 3;
872
+ static readonly TAKE_FROM_OTHER_QUESTION: 4;
873
+ static readonly ACCEPT_FROM_THIRD_PARTY: 5;
874
+ static readonly _capnp: {
875
+ displayName: string;
876
+ id: string;
877
+ size: ObjectSize;
878
+ defaultReleaseParamCaps: DataView<ArrayBufferLike>;
879
+ defaultNoFinishNeeded: DataView<ArrayBufferLike>;
880
+ };
881
+ /**
882
+ * Equal to the QuestionId of the corresponding `Call` message.
883
+ *
884
+ */
885
+ get answerId(): number;
886
+ set answerId(value: number);
887
+ /**
888
+ * If true, all capabilities that were in the params should be considered released. The sender
889
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
890
+ * should always set this true. This defaults true because if level 0 implementations forget to
891
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
892
+ * to set it to false they'll quickly get errors.
893
+ *
894
+ * The receiver should act as if the sender had sent a release message with count=1 for each
895
+ * CapDescriptor in the original Call message.
896
+ *
897
+ */
898
+ get releaseParamCaps(): boolean;
899
+ set releaseParamCaps(value: boolean);
900
+ /**
901
+ * If true, the sender does not need the receiver to send a `Finish` message; its answer table
902
+ * entry has already been cleaned up. This implies that the results do not contain any
903
+ * capabilities, since the `Finish` message would normally release those capabilities from
904
+ * promise pipelining responsibility. The caller may still send a `Finish` message if it wants,
905
+ * which will be silently ignored by the callee.
906
+ *
907
+ */
908
+ get noFinishNeeded(): boolean;
909
+ set noFinishNeeded(value: boolean);
910
+ _adoptResults(value: Orphan<Payload>): void;
911
+ _disownResults(): Orphan<Payload>;
912
+ /**
913
+ * The result.
914
+ *
915
+ * For regular method calls, `results.content` points to the result struct.
916
+ *
917
+ * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
918
+ * capability (rather than a struct), and `results.content` is just a capability pointer with
919
+ * index 0. A `Finish` is still required in this case.
920
+ *
921
+ */
922
+ get results(): Payload;
923
+ _hasResults(): boolean;
924
+ _initResults(): Payload;
925
+ get _isResults(): boolean;
926
+ set results(value: Payload);
927
+ _adoptException(value: Orphan<Exception>): void;
928
+ _disownException(): Orphan<Exception>;
929
+ /**
930
+ * Indicates that the call failed and explains why.
931
+ *
932
+ */
933
+ get exception(): Exception;
934
+ _hasException(): boolean;
935
+ _initException(): Exception;
936
+ get _isException(): boolean;
937
+ set exception(value: Exception);
938
+ get _isCanceled(): boolean;
939
+ set canceled(_: true);
940
+ get _isResultsSentElsewhere(): boolean;
941
+ set resultsSentElsewhere(_: true);
942
+ /**
943
+ * The sender has also sent (before this message) a `Call` with the given question ID and with
944
+ * `sendResultsTo.yourself` set, and the results of that other call should be used as the
945
+ * results here. `takeFromOtherQuestion` can only used once per question.
946
+ *
947
+ */
948
+ get takeFromOtherQuestion(): number;
949
+ get _isTakeFromOtherQuestion(): boolean;
950
+ set takeFromOtherQuestion(value: number);
951
+ _adoptAcceptFromThirdParty(value: Orphan<Pointer>): void;
952
+ _disownAcceptFromThirdParty(): Orphan<Pointer>;
953
+ /**
954
+ * **(level 3)**
955
+ *
956
+ * The caller should contact a third-party vat to pick up the results. An `Accept` message
957
+ * sent to the vat will return the result. This pairs with `Call.sendResultsTo.thirdParty`.
958
+ * It should only be used if the corresponding `Call` had `allowThirdPartyTailCall` set.
959
+ *
960
+ */
961
+ get acceptFromThirdParty(): Pointer;
962
+ _hasAcceptFromThirdParty(): boolean;
963
+ get _isAcceptFromThirdParty(): boolean;
964
+ set acceptFromThirdParty(value: Pointer);
965
+ toString(): string;
966
+ which(): Return_Which;
967
+ }
968
+ /**
969
+ * **(level 0)**
970
+ *
971
+ * Message type sent from the caller to the callee to indicate:
972
+ * 1) The questionId will no longer be used in any messages sent by the callee (no further
973
+ * pipelined requests).
974
+ * 2) If the call has not returned yet, the caller no longer cares about the result. If nothing
975
+ * else cares about the result either (e.g. there are no other outstanding calls pipelined on
976
+ * the result of this one) then the callee may wish to immediately cancel the operation and
977
+ * send back a Return message with "canceled" set. However, implementations are not required
978
+ * to support premature cancellation -- instead, the implementation may wait until the call
979
+ * actually completes and send a normal `Return` message.
980
+ *
981
+ * TODO(someday): Should we separate (1) and implicitly releasing result capabilities? It would be
982
+ * possible and useful to notify the server that it doesn't need to keep around the response to
983
+ * service pipeline requests even though the caller still wants to receive it / hasn't yet
984
+ * finished processing it. It could also be useful to notify the server that it need not marshal
985
+ * the results because the caller doesn't want them anyway, even if the caller is still sending
986
+ * pipelined calls, although this seems less useful (just saving some bytes on the wire).
987
+ *
988
+ */
989
+ declare class Finish extends Struct {
990
+ static readonly _capnp: {
991
+ displayName: string;
992
+ id: string;
993
+ size: ObjectSize;
994
+ defaultReleaseResultCaps: DataView<ArrayBufferLike>;
995
+ defaultRequireEarlyCancellationWorkaround: DataView<ArrayBufferLike>;
996
+ };
997
+ /**
998
+ * ID of the call whose result is to be released.
999
+ *
1000
+ */
1001
+ get questionId(): number;
1002
+ set questionId(value: number);
1003
+ /**
1004
+ * If true, all capabilities that were in the results should be considered released. The sender
1005
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
1006
+ * should always set this true. This defaults true because if level 0 implementations forget to
1007
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
1008
+ * set it false they'll quickly get errors.
1009
+ *
1010
+ */
1011
+ get releaseResultCaps(): boolean;
1012
+ set releaseResultCaps(value: boolean);
1013
+ /**
1014
+ * If true, if the RPC system receives this Finish message before the original call has even been
1015
+ * delivered, it should defer cancellation util after delivery. In particular, this gives the
1016
+ * destination object a chance to opt out of cancellation, e.g. as controlled by the
1017
+ * `allowCancellation` annotation defined in `c++.capnp`.
1018
+ *
1019
+ * This is a work-around. Versions 1.0 and up of Cap'n Proto always set this to false. However,
1020
+ * older versions of Cap'n Proto unintentionally exhibited this errant behavior by default, and
1021
+ * as a result programs built with older versions could be inadvertently relying on their peers
1022
+ * to implement the behavior. The purpose of this flag is to let newer versions know when the
1023
+ * peer is an older version, so that it can attempt to work around the issue.
1024
+ *
1025
+ * See also comments in handleFinish() in rpc.c++ for more details.
1026
+ *
1027
+ */
1028
+ get requireEarlyCancellationWorkaround(): boolean;
1029
+ set requireEarlyCancellationWorkaround(value: boolean);
1030
+ toString(): string;
1031
+ }
1032
+ declare const Resolve_Which: {
1033
+ /**
1034
+ * The ID of the promise to be resolved.
1035
+ *
1036
+ * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
1037
+ * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
1038
+ * will release the export soon after receiving `Resolve`, and the sender will not send this
1039
+ * `ExportId` again until it has been released and recycled.
1040
+ *
1041
+ * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
1042
+ * this indicates that the sender will follow up at some point with a `Resolve` message. If the
1043
+ * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
1044
+ * same ID is sent again later _after_ a `Resolve`, it can only be because the export's
1045
+ * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
1046
+ * this later promise does _not_ correspond to the earlier `Resolve`.
1047
+ *
1048
+ * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
1049
+ * message may or may not still be sent (the `Resolve` may have already been in-flight when
1050
+ * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
1051
+ * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
1052
+ * the receiver has no knowledge, because it already released it earlier. In this case, the
1053
+ * receiver should simply release the capability to which the promise resolved.
1054
+ *
1055
+ */
1056
+ readonly CAP: 0;
1057
+ /**
1058
+ * The object to which the promise resolved.
1059
+ *
1060
+ * The sender promises that from this point forth, until `promiseId` is released, it shall
1061
+ * simply forward all messages to the capability designated by `cap`. This is true even if
1062
+ * `cap` itself happens to designate another promise, and that other promise later resolves --
1063
+ * messages sent to `promiseId` shall still go to that other promise, not to its resolution.
1064
+ * This is important in the case that the receiver of the `Resolve` ends up sending a
1065
+ * `Disembargo` message towards `promiseId` in order to control message ordering -- that
1066
+ * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
1067
+ * if that object is itself a promise.
1068
+ *
1069
+ */
1070
+ readonly EXCEPTION: 1;
1071
+ };
1072
+ type Resolve_Which = (typeof Resolve_Which)[keyof typeof Resolve_Which];
1073
+ /**
1074
+ * **(level 1)**
1075
+ *
1076
+ * Message type sent to indicate that a previously-sent promise has now been resolved to some other
1077
+ * object (possibly another promise) -- or broken, or canceled.
1078
+ *
1079
+ * Keep in mind that it's possible for a `Resolve` to be sent to a level 0 implementation that
1080
+ * doesn't implement it. For example, a method call or return might contain a capability in the
1081
+ * payload. Normally this is fine even if the receiver is level 0, because they will implicitly
1082
+ * release all such capabilities on return / finish. But if the cap happens to be a promise, then
1083
+ * a follow-up `Resolve` may be sent regardless of this release. The level 0 receiver will reply
1084
+ * with an `unimplemented` message, and the sender (of the `Resolve`) can respond to this as if the
1085
+ * receiver had immediately released any capability to which the promise resolved.
1086
+ *
1087
+ * When implementing promise resolution, it's important to understand how embargos work and the
1088
+ * tricky case of the Tribble 4-way race condition. See the comments for the Disembargo message,
1089
+ * below.
1090
+ *
1091
+ */
1092
+ declare class Resolve extends Struct {
1093
+ static readonly CAP: 0;
1094
+ static readonly EXCEPTION: 1;
1095
+ static readonly _capnp: {
1096
+ displayName: string;
1097
+ id: string;
1098
+ size: ObjectSize;
1099
+ };
1100
+ /**
1101
+ * The ID of the promise to be resolved.
1102
+ *
1103
+ * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
1104
+ * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
1105
+ * will release the export soon after receiving `Resolve`, and the sender will not send this
1106
+ * `ExportId` again until it has been released and recycled.
1107
+ *
1108
+ * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
1109
+ * this indicates that the sender will follow up at some point with a `Resolve` message. If the
1110
+ * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
1111
+ * same ID is sent again later _after_ a `Resolve`, it can only be because the export's
1112
+ * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
1113
+ * this later promise does _not_ correspond to the earlier `Resolve`.
1114
+ *
1115
+ * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
1116
+ * message may or may not still be sent (the `Resolve` may have already been in-flight when
1117
+ * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
1118
+ * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
1119
+ * the receiver has no knowledge, because it already released it earlier. In this case, the
1120
+ * receiver should simply release the capability to which the promise resolved.
1121
+ *
1122
+ */
1123
+ get promiseId(): number;
1124
+ set promiseId(value: number);
1125
+ _adoptCap(value: Orphan<CapDescriptor>): void;
1126
+ _disownCap(): Orphan<CapDescriptor>;
1127
+ /**
1128
+ * The object to which the promise resolved.
1129
+ *
1130
+ * The sender promises that from this point forth, until `promiseId` is released, it shall
1131
+ * simply forward all messages to the capability designated by `cap`. This is true even if
1132
+ * `cap` itself happens to designate another promise, and that other promise later resolves --
1133
+ * messages sent to `promiseId` shall still go to that other promise, not to its resolution.
1134
+ * This is important in the case that the receiver of the `Resolve` ends up sending a
1135
+ * `Disembargo` message towards `promiseId` in order to control message ordering -- that
1136
+ * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
1137
+ * if that object is itself a promise.
1138
+ *
1139
+ */
1140
+ get cap(): CapDescriptor;
1141
+ _hasCap(): boolean;
1142
+ _initCap(): CapDescriptor;
1143
+ get _isCap(): boolean;
1144
+ set cap(value: CapDescriptor);
1145
+ _adoptException(value: Orphan<Exception>): void;
1146
+ _disownException(): Orphan<Exception>;
1147
+ /**
1148
+ * Indicates that the promise was broken.
1149
+ *
1150
+ */
1151
+ get exception(): Exception;
1152
+ _hasException(): boolean;
1153
+ _initException(): Exception;
1154
+ get _isException(): boolean;
1155
+ set exception(value: Exception);
1156
+ toString(): string;
1157
+ which(): Resolve_Which;
1158
+ }
1159
+ /**
1160
+ * **(level 1)**
1161
+ *
1162
+ * Message type sent to indicate that the sender is done with the given capability and the receiver
1163
+ * can free resources allocated to it.
1164
+ *
1165
+ */
1166
+ declare class Release extends Struct {
1167
+ static readonly _capnp: {
1168
+ displayName: string;
1169
+ id: string;
1170
+ size: ObjectSize;
1171
+ };
1172
+ /**
1173
+ * What to release.
1174
+ *
1175
+ */
1176
+ get id(): number;
1177
+ set id(value: number);
1178
+ /**
1179
+ * The amount by which to decrement the reference count. The export is only actually released
1180
+ * when the reference count reaches zero.
1181
+ *
1182
+ */
1183
+ get referenceCount(): number;
1184
+ set referenceCount(value: number);
1185
+ toString(): string;
1186
+ }
1187
+ declare const Disembargo_Context_Which: {
1188
+ /**
1189
+ * The sender is requesting a disembargo on a promise that is known to resolve back to a
1190
+ * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
1191
+ * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
1192
+ * set to the same value as `senderLoopback`. This value is chosen by the sender, and since
1193
+ * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
1194
+ * the value is unambiguous.
1195
+ *
1196
+ * The receiver must verify that the target capability actually resolves back to the sender's
1197
+ * vat. Otherwise, the sender has committed a protocol error and should be disconnected.
1198
+ *
1199
+ */
1200
+ readonly SENDER_LOOPBACK: 0;
1201
+ /**
1202
+ * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
1203
+ * this capability, and that Disembargo is now being echoed back.
1204
+ *
1205
+ */
1206
+ readonly RECEIVER_LOOPBACK: 1;
1207
+ /**
1208
+ * **(level 3)**
1209
+ *
1210
+ * The sender is requesting a disembargo on a promise that is known to resolve to a third-party
1211
+ * capability that the sender is currently in the process of accepting (using `Accept`).
1212
+ * The receiver of this `Disembargo` has an outstanding `Provide` on said capability. The
1213
+ * receiver should now send a `Disembargo` with `provide` set to the question ID of that
1214
+ * `Provide` message.
1215
+ *
1216
+ * See `Accept.embargo` for an example.
1217
+ *
1218
+ */
1219
+ readonly ACCEPT: 2;
1220
+ /**
1221
+ * **(level 3)**
1222
+ *
1223
+ * The sender is requesting a disembargo on a capability currently being provided to a third
1224
+ * party. The question ID identifies the `Provide` message previously sent by the sender to
1225
+ * this capability. On receipt, the receiver (the capability host) shall release the embargo
1226
+ * on the `Accept` message that it has received from the third party. See `Accept.embargo` for
1227
+ * an example.
1228
+ *
1229
+ */
1230
+ readonly PROVIDE: 3;
1231
+ };
1232
+ type Disembargo_Context_Which = (typeof Disembargo_Context_Which)[keyof typeof Disembargo_Context_Which];
1233
+ declare class Disembargo_Context extends Struct {
1234
+ static readonly SENDER_LOOPBACK: 0;
1235
+ static readonly RECEIVER_LOOPBACK: 1;
1236
+ static readonly ACCEPT: 2;
1237
+ static readonly PROVIDE: 3;
1238
+ static readonly _capnp: {
1239
+ displayName: string;
1240
+ id: string;
1241
+ size: ObjectSize;
1242
+ };
1243
+ /**
1244
+ * The sender is requesting a disembargo on a promise that is known to resolve back to a
1245
+ * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
1246
+ * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
1247
+ * set to the same value as `senderLoopback`. This value is chosen by the sender, and since
1248
+ * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
1249
+ * the value is unambiguous.
1250
+ *
1251
+ * The receiver must verify that the target capability actually resolves back to the sender's
1252
+ * vat. Otherwise, the sender has committed a protocol error and should be disconnected.
1253
+ *
1254
+ */
1255
+ get senderLoopback(): number;
1256
+ get _isSenderLoopback(): boolean;
1257
+ set senderLoopback(value: number);
1258
+ /**
1259
+ * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
1260
+ * this capability, and that Disembargo is now being echoed back.
1261
+ *
1262
+ */
1263
+ get receiverLoopback(): number;
1264
+ get _isReceiverLoopback(): boolean;
1265
+ set receiverLoopback(value: number);
1266
+ get _isAccept(): boolean;
1267
+ set accept(_: true);
1268
+ /**
1269
+ * **(level 3)**
1270
+ *
1271
+ * The sender is requesting a disembargo on a capability currently being provided to a third
1272
+ * party. The question ID identifies the `Provide` message previously sent by the sender to
1273
+ * this capability. On receipt, the receiver (the capability host) shall release the embargo
1274
+ * on the `Accept` message that it has received from the third party. See `Accept.embargo` for
1275
+ * an example.
1276
+ *
1277
+ */
1278
+ get provide(): number;
1279
+ get _isProvide(): boolean;
1280
+ set provide(value: number);
1281
+ toString(): string;
1282
+ which(): Disembargo_Context_Which;
1283
+ }
1284
+ /**
1285
+ * **(level 1)**
1286
+ *
1287
+ * Message sent to indicate that an embargo on a recently-resolved promise may now be lifted.
1288
+ *
1289
+ * Embargos are used to enforce E-order in the presence of promise resolution. That is, if an
1290
+ * application makes two calls foo() and bar() on the same capability reference, in that order,
1291
+ * the calls should be delivered in the order in which they were made. But if foo() is called
1292
+ * on a promise, and that promise happens to resolve before bar() is called, then the two calls
1293
+ * may travel different paths over the network, and thus could arrive in the wrong order. In
1294
+ * this case, the call to `bar()` must be embargoed, and a `Disembargo` message must be sent along
1295
+ * the same path as `foo()` to ensure that the `Disembargo` arrives after `foo()`. Once the
1296
+ * `Disembargo` arrives, `bar()` can then be delivered.
1297
+ *
1298
+ * There are two particular cases where embargos are important. Consider object Alice, in Vat A,
1299
+ * who holds a promise P, pointing towards Vat B, that eventually resolves to Carol. The two
1300
+ * cases are:
1301
+ * - Carol lives in Vat A, i.e. next to Alice. In this case, Vat A needs to send a `Disembargo`
1302
+ * message that echos through Vat B and back, to ensure that all pipelined calls on the promise
1303
+ * have been delivered.
1304
+ * - Carol lives in a different Vat C. When the promise resolves, a three-party handoff occurs
1305
+ * (see `Provide` and `Accept`, which constitute level 3 of the protocol). In this case, we
1306
+ * piggyback on the state that has already been set up to handle the handoff: the `Accept`
1307
+ * message (from Vat A to Vat C) is embargoed, as are all pipelined messages sent to it, while
1308
+ * a `Disembargo` message is sent from Vat A through Vat B to Vat C. See `Accept.embargo` for
1309
+ * an example.
1310
+ *
1311
+ * Note that in the case where Carol actually lives in Vat B (i.e., the same vat that the promise
1312
+ * already pointed at), no embargo is needed, because the pipelined calls are delivered over the
1313
+ * same path as the later direct calls.
1314
+ *
1315
+ * Keep in mind that promise resolution happens both in the form of Resolve messages as well as
1316
+ * Return messages (which resolve PromisedAnswers). Embargos apply in both cases.
1317
+ *
1318
+ * An alternative strategy for enforcing E-order over promise resolution could be for Vat A to
1319
+ * implement the embargo internally. When Vat A is notified of promise resolution, it could
1320
+ * send a dummy no-op call to promise P and wait for it to complete. Until that call completes,
1321
+ * all calls to the capability are queued locally. This strategy works, but is pessimistic:
1322
+ * in the three-party case, it requires an A -> B -> C -> B -> A round trip before calls can start
1323
+ * being delivered directly to from Vat A to Vat C. The `Disembargo` message allows latency to be
1324
+ * reduced. (In the two-party loopback case, the `Disembargo` message is just a more explicit way
1325
+ * of accomplishing the same thing as a no-op call, but isn't any faster.)
1326
+ *
1327
+ * *The Tribble 4-way Race Condition*
1328
+ *
1329
+ * Any implementation of promise resolution and embargos must be aware of what we call the
1330
+ * "Tribble 4-way race condition", after Dean Tribble, who explained the problem in a lively
1331
+ * Friam meeting.
1332
+ *
1333
+ * Embargos are designed to work in the case where a two-hop path is being shortened to one hop.
1334
+ * But sometimes there are more hops. Imagine that Alice has a reference to a remote promise P1
1335
+ * that eventually resolves to _another_ remote promise P2 (in a third vat), which _at the same
1336
+ * time_ happens to resolve to Bob (in a fourth vat). In this case, we're shortening from a 3-hop
1337
+ * path (with four parties) to a 1-hop path (Alice -> Bob).
1338
+ *
1339
+ * Extending the embargo/disembargo protocol to be able to shorted multiple hops at once seems
1340
+ * difficult. Instead, we make a rule that prevents this case from coming up:
1341
+ *
1342
+ * One a promise P has been resolved to a remote object reference R, then all further messages
1343
+ * received addressed to P will be forwarded strictly to R. Even if it turns out later that R is
1344
+ * itself a promise, and has resolved to some other object Q, messages sent to P will still be
1345
+ * forwarded to R, not directly to Q (R will of course further forward the messages to Q).
1346
+ *
1347
+ * This rule does not cause a significant performance burden because once P has resolved to R, it
1348
+ * is expected that people sending messages to P will shortly start sending them to R instead and
1349
+ * drop P. P is at end-of-life anyway, so it doesn't matter if it ignores chances to further
1350
+ * optimize its path.
1351
+ *
1352
+ * Note well: the Tribble 4-way race condition does not require each vat to be *distinct*; as long
1353
+ * as each resolution crosses a network boundary the race can occur -- so this concerns even level
1354
+ * 1 implementations, not just level 3 implementations.
1355
+ *
1356
+ */
1357
+ declare class Disembargo extends Struct {
1358
+ static readonly _capnp: {
1359
+ displayName: string;
1360
+ id: string;
1361
+ size: ObjectSize;
1362
+ };
1363
+ _adoptTarget(value: Orphan<MessageTarget>): void;
1364
+ _disownTarget(): Orphan<MessageTarget>;
1365
+ /**
1366
+ * What is to be disembargoed.
1367
+ *
1368
+ */
1369
+ get target(): MessageTarget;
1370
+ _hasTarget(): boolean;
1371
+ _initTarget(): MessageTarget;
1372
+ set target(value: MessageTarget);
1373
+ get context(): Disembargo_Context;
1374
+ _initContext(): Disembargo_Context;
1375
+ toString(): string;
1376
+ }
1377
+ /**
1378
+ * **(level 3)**
1379
+ *
1380
+ * Message type sent to indicate that the sender wishes to make a particular capability implemented
1381
+ * by the receiver available to a third party for direct access (without the need for the third
1382
+ * party to proxy through the sender).
1383
+ *
1384
+ * (In CapTP, `Provide` and `Accept` are methods of the global `NonceLocator` object exported by
1385
+ * every vat. In Cap'n Proto, we bake this into the core protocol.)
1386
+ *
1387
+ */
1388
+ declare class Provide extends Struct {
1389
+ static readonly _capnp: {
1390
+ displayName: string;
1391
+ id: string;
1392
+ size: ObjectSize;
1393
+ };
1394
+ /**
1395
+ * Question ID to be held open until the recipient has received the capability. A result will be
1396
+ * returned once the third party has successfully received the capability. The sender must at some
1397
+ * point send a `Finish` message as with any other call, and that message can be used to cancel the
1398
+ * whole operation.
1399
+ *
1400
+ */
1401
+ get questionId(): number;
1402
+ set questionId(value: number);
1403
+ _adoptTarget(value: Orphan<MessageTarget>): void;
1404
+ _disownTarget(): Orphan<MessageTarget>;
1405
+ /**
1406
+ * What is to be provided to the third party.
1407
+ *
1408
+ */
1409
+ get target(): MessageTarget;
1410
+ _hasTarget(): boolean;
1411
+ _initTarget(): MessageTarget;
1412
+ set target(value: MessageTarget);
1413
+ _adoptRecipient(value: Orphan<Pointer>): void;
1414
+ _disownRecipient(): Orphan<Pointer>;
1415
+ /**
1416
+ * Identity of the third party that is expected to pick up the capability.
1417
+ *
1418
+ */
1419
+ get recipient(): Pointer;
1420
+ _hasRecipient(): boolean;
1421
+ set recipient(value: Pointer);
1422
+ toString(): string;
1423
+ }
1424
+ /**
1425
+ * **(level 3)**
1426
+ *
1427
+ * Message type sent to pick up a capability hosted by the receiving vat and provided by a third
1428
+ * party. The third party previously designated the capability using `Provide`.
1429
+ *
1430
+ * This message is also used to pick up a redirected return -- see `Return.acceptFromThirdParty`.
1431
+ *
1432
+ */
1433
+ declare class Accept extends Struct {
1434
+ static readonly _capnp: {
1435
+ displayName: string;
1436
+ id: string;
1437
+ size: ObjectSize;
1438
+ };
1439
+ /**
1440
+ * A new question ID identifying this accept message, which will eventually receive a Return
1441
+ * message containing the provided capability (or the call result in the case of a redirected
1442
+ * return).
1443
+ *
1444
+ */
1445
+ get questionId(): number;
1446
+ set questionId(value: number);
1447
+ _adoptProvision(value: Orphan<Pointer>): void;
1448
+ _disownProvision(): Orphan<Pointer>;
1449
+ /**
1450
+ * Identifies the provided object to be picked up.
1451
+ *
1452
+ */
1453
+ get provision(): Pointer;
1454
+ _hasProvision(): boolean;
1455
+ set provision(value: Pointer);
1456
+ /**
1457
+ * If true, this accept shall be temporarily embargoed. The resulting `Return` will not be sent,
1458
+ * and any pipelined calls will not be delivered, until the embargo is released. The receiver
1459
+ * (the capability host) will expect the provider (the vat that sent the `Provide` message) to
1460
+ * eventually send a `Disembargo` message with the field `context.provide` set to the question ID
1461
+ * of the original `Provide` message. At that point, the embargo is released and the queued
1462
+ * messages are delivered.
1463
+ *
1464
+ * For example:
1465
+ * - Alice, in Vat A, holds a promise P, which currently points toward Vat B.
1466
+ * - Alice calls foo() on P. The `Call` message is sent to Vat B.
1467
+ * - The promise P in Vat B ends up resolving to Carol, in Vat C.
1468
+ * - Vat B sends a `Provide` message to Vat C, identifying Vat A as the recipient.
1469
+ * - Vat B sends a `Resolve` message to Vat A, indicating that the promise has resolved to a
1470
+ * `ThirdPartyCapId` identifying Carol in Vat C.
1471
+ * - Vat A sends an `Accept` message to Vat C to pick up the capability. Since Vat A knows that
1472
+ * it has an outstanding call to the promise, it sets `embargo` to `true` in the `Accept`
1473
+ * message.
1474
+ * - Vat A sends a `Disembargo` message to Vat B on promise P, with `context.accept` set.
1475
+ * - Alice makes a call bar() to promise P, which is now pointing towards Vat C. Alice doesn't
1476
+ * know anything about the mechanics of promise resolution happening under the hood, but she
1477
+ * expects that bar() will be delivered after foo() because that is the order in which she
1478
+ * initiated the calls.
1479
+ * - Vat A sends the bar() call to Vat C, as a pipelined call on the result of the `Accept` (which
1480
+ * hasn't returned yet, due to the embargo). Since calls to the newly-accepted capability
1481
+ * are embargoed, Vat C does not deliver the call yet.
1482
+ * - At some point, Vat B forwards the foo() call from the beginning of this example on to Vat C.
1483
+ * - Vat B forwards the `Disembargo` from Vat A on to vat C. It sets `context.provide` to the
1484
+ * question ID of the `Provide` message it had sent previously.
1485
+ * - Vat C receives foo() before `Disembargo`, thus allowing it to correctly deliver foo()
1486
+ * before delivering bar().
1487
+ * - Vat C receives `Disembargo` from Vat B. It can now send a `Return` for the `Accept` from
1488
+ * Vat A, as well as deliver bar().
1489
+ *
1490
+ */
1491
+ get embargo(): boolean;
1492
+ set embargo(value: boolean);
1493
+ toString(): string;
1494
+ }
1495
+ /**
1496
+ * **(level 4)**
1497
+ *
1498
+ * Message type sent to implement E.join(), which, given a number of capabilities that are
1499
+ * expected to be equivalent, finds the underlying object upon which they all agree and forms a
1500
+ * direct connection to it, skipping any proxies that may have been constructed by other vats
1501
+ * while transmitting the capability. See:
1502
+ * http://erights.org/elib/equality/index.html
1503
+ *
1504
+ * Note that this should only serve to bypass fully-transparent proxies -- proxies that were
1505
+ * created merely for convenience, without any intention of hiding the underlying object.
1506
+ *
1507
+ * For example, say Bob holds two capabilities hosted by Alice and Carol, but he expects that both
1508
+ * are simply proxies for a capability hosted elsewhere. He then issues a join request, which
1509
+ * operates as follows:
1510
+ * - Bob issues Join requests on both Alice and Carol. Each request contains a different piece
1511
+ * of the JoinKey.
1512
+ * - Alice is proxying a capability hosted by Dana, so forwards the request to Dana's cap.
1513
+ * - Dana receives the first request and sees that the JoinKeyPart is one of two. She notes that
1514
+ * she doesn't have the other part yet, so she records the request and responds with a
1515
+ * JoinResult.
1516
+ * - Alice relays the JoinAnswer back to Bob.
1517
+ * - Carol is also proxying a capability from Dana, and so forwards her Join request to Dana as
1518
+ * well.
1519
+ * - Dana receives Carol's request and notes that she now has both parts of a JoinKey. She
1520
+ * combines them in order to form information needed to form a secure connection to Bob. She
1521
+ * also responds with another JoinResult.
1522
+ * - Bob receives the responses from Alice and Carol. He uses the returned JoinResults to
1523
+ * determine how to connect to Dana and attempts to form the connection. Since Bob and Dana now
1524
+ * agree on a secret key that neither Alice nor Carol ever saw, this connection can be made
1525
+ * securely even if Alice or Carol is conspiring against the other. (If Alice and Carol are
1526
+ * conspiring _together_, they can obviously reproduce the key, but this doesn't matter because
1527
+ * the whole point of the join is to verify that Alice and Carol agree on what capability they
1528
+ * are proxying.)
1529
+ *
1530
+ * If the two capabilities aren't actually proxies of the same object, then the join requests
1531
+ * will come back with conflicting `hostId`s and the join will fail before attempting to form any
1532
+ * connection.
1533
+ *
1534
+ */
1535
+ declare class Join extends Struct {
1536
+ static readonly _capnp: {
1537
+ displayName: string;
1538
+ id: string;
1539
+ size: ObjectSize;
1540
+ };
1541
+ /**
1542
+ * Question ID used to respond to this Join. (Note that this ID only identifies one part of the
1543
+ * request for one hop; each part has a different ID and relayed copies of the request have
1544
+ * (probably) different IDs still.)
1545
+ *
1546
+ * The receiver will reply with a `Return` whose `results` is a JoinResult. This `JoinResult`
1547
+ * is relayed from the joined object's host, possibly with transformation applied as needed
1548
+ * by the network.
1549
+ *
1550
+ * Like any return, the result must be released using a `Finish`. However, this release
1551
+ * should not occur until the joiner has either successfully connected to the joined object.
1552
+ * Vats relaying a `Join` message similarly must not release the result they receive until the
1553
+ * return they relayed back towards the joiner has itself been released. This allows the
1554
+ * joined object's host to detect when the Join operation is canceled before completing -- if
1555
+ * it receives a `Finish` for one of the join results before the joiner successfully
1556
+ * connects. It can then free any resources it had allocated as part of the join.
1557
+ *
1558
+ */
1559
+ get questionId(): number;
1560
+ set questionId(value: number);
1561
+ _adoptTarget(value: Orphan<MessageTarget>): void;
1562
+ _disownTarget(): Orphan<MessageTarget>;
1563
+ /**
1564
+ * The capability to join.
1565
+ *
1566
+ */
1567
+ get target(): MessageTarget;
1568
+ _hasTarget(): boolean;
1569
+ _initTarget(): MessageTarget;
1570
+ set target(value: MessageTarget);
1571
+ _adoptKeyPart(value: Orphan<Pointer>): void;
1572
+ _disownKeyPart(): Orphan<Pointer>;
1573
+ /**
1574
+ * A part of the join key. These combine to form the complete join key, which is used to establish
1575
+ * a direct connection.
1576
+ *
1577
+ */
1578
+ get keyPart(): Pointer;
1579
+ _hasKeyPart(): boolean;
1580
+ set keyPart(value: Pointer);
1581
+ toString(): string;
1582
+ }
1583
+ declare const MessageTarget_Which: {
1584
+ /**
1585
+ * This message is to a capability or promise previously imported by the caller (exported by
1586
+ * the receiver).
1587
+ *
1588
+ */
1589
+ readonly IMPORTED_CAP: 0;
1590
+ /**
1591
+ * This message is to a capability that is expected to be returned by another call that has not
1592
+ * yet been completed.
1593
+ *
1594
+ * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
1595
+ * that initial startup doesn't require a round trip.
1596
+ *
1597
+ */
1598
+ readonly PROMISED_ANSWER: 1;
1599
+ };
1600
+ type MessageTarget_Which = (typeof MessageTarget_Which)[keyof typeof MessageTarget_Which];
1601
+ /**
1602
+ * The target of a `Call` or other messages that target a capability.
1603
+ *
1604
+ */
1605
+ declare class MessageTarget extends Struct {
1606
+ static readonly IMPORTED_CAP: 0;
1607
+ static readonly PROMISED_ANSWER: 1;
1608
+ static readonly _capnp: {
1609
+ displayName: string;
1610
+ id: string;
1611
+ size: ObjectSize;
1612
+ };
1613
+ /**
1614
+ * This message is to a capability or promise previously imported by the caller (exported by
1615
+ * the receiver).
1616
+ *
1617
+ */
1618
+ get importedCap(): number;
1619
+ get _isImportedCap(): boolean;
1620
+ set importedCap(value: number);
1621
+ _adoptPromisedAnswer(value: Orphan<PromisedAnswer>): void;
1622
+ _disownPromisedAnswer(): Orphan<PromisedAnswer>;
1623
+ /**
1624
+ * This message is to a capability that is expected to be returned by another call that has not
1625
+ * yet been completed.
1626
+ *
1627
+ * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
1628
+ * that initial startup doesn't require a round trip.
1629
+ *
1630
+ */
1631
+ get promisedAnswer(): PromisedAnswer;
1632
+ _hasPromisedAnswer(): boolean;
1633
+ _initPromisedAnswer(): PromisedAnswer;
1634
+ get _isPromisedAnswer(): boolean;
1635
+ set promisedAnswer(value: PromisedAnswer);
1636
+ toString(): string;
1637
+ which(): MessageTarget_Which;
1638
+ }
1639
+ /**
1640
+ * Represents some data structure that might contain capabilities.
1641
+ *
1642
+ */
1643
+ declare class Payload extends Struct {
1644
+ static readonly _capnp: {
1645
+ displayName: string;
1646
+ id: string;
1647
+ size: ObjectSize;
1648
+ };
1649
+ static _CapTable: ListCtor<CapDescriptor>;
1650
+ _adoptContent(value: Orphan<Pointer>): void;
1651
+ _disownContent(): Orphan<Pointer>;
1652
+ /**
1653
+ * Some Cap'n Proto data structure. Capability pointers embedded in this structure index into
1654
+ * `capTable`.
1655
+ *
1656
+ */
1657
+ get content(): Pointer;
1658
+ _hasContent(): boolean;
1659
+ set content(value: Pointer);
1660
+ _adoptCapTable(value: Orphan<List<CapDescriptor>>): void;
1661
+ _disownCapTable(): Orphan<List<CapDescriptor>>;
1662
+ /**
1663
+ * Descriptors corresponding to the cap pointers in `content`.
1664
+ *
1665
+ */
1666
+ get capTable(): List<CapDescriptor>;
1667
+ _hasCapTable(): boolean;
1668
+ _initCapTable(length: number): List<CapDescriptor>;
1669
+ set capTable(value: List<CapDescriptor>);
1670
+ toString(): string;
1671
+ }
1672
+ declare const CapDescriptor_Which: {
1673
+ /**
1674
+ * There is no capability here. This `CapDescriptor` should not appear in the payload content.
1675
+ * A `none` CapDescriptor can be generated when an application inserts a capability into a
1676
+ * message and then later changes its mind and removes it -- rewriting all of the other
1677
+ * capability pointers may be hard, so instead a tombstone is left, similar to the way a removed
1678
+ * struct or list instance is zeroed out of the message but the space is not reclaimed.
1679
+ * Hopefully this is unusual.
1680
+ *
1681
+ */
1682
+ readonly NONE: 0;
1683
+ /**
1684
+ * The ID of a capability in the sender's export table (receiver's import table). It may be a
1685
+ * newly allocated table entry, or an existing entry (increments the reference count).
1686
+ *
1687
+ */
1688
+ readonly SENDER_HOSTED: 1;
1689
+ /**
1690
+ * A promise that the sender will resolve later. The sender will send exactly one Resolve
1691
+ * message at a future point in time to replace this promise. Note that even if the same
1692
+ * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
1693
+ * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
1694
+ * `CapDescriptor`) may choose not to send the `Resolve` at all.
1695
+ *
1696
+ */
1697
+ readonly SENDER_PROMISE: 2;
1698
+ /**
1699
+ * A capability (or promise) previously exported by the receiver (imported by the sender).
1700
+ *
1701
+ */
1702
+ readonly RECEIVER_HOSTED: 3;
1703
+ /**
1704
+ * A capability expected to be returned in the results of a currently-outstanding call posed
1705
+ * by the sender.
1706
+ *
1707
+ */
1708
+ readonly RECEIVER_ANSWER: 4;
1709
+ /**
1710
+ * **(level 3)**
1711
+ *
1712
+ * A capability that lives in neither the sender's nor the receiver's vat. The sender needs
1713
+ * to form a direct connection to a third party to pick up the capability.
1714
+ *
1715
+ * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
1716
+ * `vine` instead.
1717
+ *
1718
+ */
1719
+ readonly THIRD_PARTY_HOSTED: 5;
1720
+ };
1721
+ type CapDescriptor_Which = (typeof CapDescriptor_Which)[keyof typeof CapDescriptor_Which];
1722
+ /**
1723
+ * **(level 1)**
1724
+ *
1725
+ * When an application-defined type contains an interface pointer, that pointer contains an index
1726
+ * into the message's capability table -- i.e. the `capTable` part of the `Payload`. Each
1727
+ * capability in the table is represented as a `CapDescriptor`. The runtime API should not reveal
1728
+ * the CapDescriptor directly to the application, but should instead wrap it in some kind of
1729
+ * callable object with methods corresponding to the interface that the capability implements.
1730
+ *
1731
+ * Keep in mind that `ExportIds` in a `CapDescriptor` are subject to reference counting. See the
1732
+ * description of `ExportId`.
1733
+ *
1734
+ * Note that it is currently not possible to include a broken capability in the CapDescriptor
1735
+ * table. Instead, create a new export (`senderPromise`) for each broken capability and then
1736
+ * immediately follow the payload-bearing Call or Return message with one Resolve message for each
1737
+ * broken capability, resolving it to an exception.
1738
+ *
1739
+ */
1740
+ declare class CapDescriptor extends Struct {
1741
+ static readonly NONE: 0;
1742
+ static readonly SENDER_HOSTED: 1;
1743
+ static readonly SENDER_PROMISE: 2;
1744
+ static readonly RECEIVER_HOSTED: 3;
1745
+ static readonly RECEIVER_ANSWER: 4;
1746
+ static readonly THIRD_PARTY_HOSTED: 5;
1747
+ static readonly _capnp: {
1748
+ displayName: string;
1749
+ id: string;
1750
+ size: ObjectSize;
1751
+ defaultAttachedFd: DataView<ArrayBufferLike>;
1752
+ };
1753
+ get _isNone(): boolean;
1754
+ set none(_: true);
1755
+ /**
1756
+ * The ID of a capability in the sender's export table (receiver's import table). It may be a
1757
+ * newly allocated table entry, or an existing entry (increments the reference count).
1758
+ *
1759
+ */
1760
+ get senderHosted(): number;
1761
+ get _isSenderHosted(): boolean;
1762
+ set senderHosted(value: number);
1763
+ /**
1764
+ * A promise that the sender will resolve later. The sender will send exactly one Resolve
1765
+ * message at a future point in time to replace this promise. Note that even if the same
1766
+ * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
1767
+ * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
1768
+ * `CapDescriptor`) may choose not to send the `Resolve` at all.
1769
+ *
1770
+ */
1771
+ get senderPromise(): number;
1772
+ get _isSenderPromise(): boolean;
1773
+ set senderPromise(value: number);
1774
+ /**
1775
+ * A capability (or promise) previously exported by the receiver (imported by the sender).
1776
+ *
1777
+ */
1778
+ get receiverHosted(): number;
1779
+ get _isReceiverHosted(): boolean;
1780
+ set receiverHosted(value: number);
1781
+ _adoptReceiverAnswer(value: Orphan<PromisedAnswer>): void;
1782
+ _disownReceiverAnswer(): Orphan<PromisedAnswer>;
1783
+ /**
1784
+ * A capability expected to be returned in the results of a currently-outstanding call posed
1785
+ * by the sender.
1786
+ *
1787
+ */
1788
+ get receiverAnswer(): PromisedAnswer;
1789
+ _hasReceiverAnswer(): boolean;
1790
+ _initReceiverAnswer(): PromisedAnswer;
1791
+ get _isReceiverAnswer(): boolean;
1792
+ set receiverAnswer(value: PromisedAnswer);
1793
+ _adoptThirdPartyHosted(value: Orphan<ThirdPartyCapDescriptor>): void;
1794
+ _disownThirdPartyHosted(): Orphan<ThirdPartyCapDescriptor>;
1795
+ /**
1796
+ * **(level 3)**
1797
+ *
1798
+ * A capability that lives in neither the sender's nor the receiver's vat. The sender needs
1799
+ * to form a direct connection to a third party to pick up the capability.
1800
+ *
1801
+ * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
1802
+ * `vine` instead.
1803
+ *
1804
+ */
1805
+ get thirdPartyHosted(): ThirdPartyCapDescriptor;
1806
+ _hasThirdPartyHosted(): boolean;
1807
+ _initThirdPartyHosted(): ThirdPartyCapDescriptor;
1808
+ get _isThirdPartyHosted(): boolean;
1809
+ set thirdPartyHosted(value: ThirdPartyCapDescriptor);
1810
+ /**
1811
+ * If the RPC message in which this CapDescriptor was delivered also had file descriptors
1812
+ * attached, and `fd` is a valid index into the list of attached file descriptors, then
1813
+ * that file descriptor should be attached to this capability. If `attachedFd` is out-of-bounds
1814
+ * for said list, then no FD is attached.
1815
+ *
1816
+ * For example, if the RPC message arrived over a Unix socket, then file descriptors may be
1817
+ * attached by sending an SCM_RIGHTS ancillary message attached to the data bytes making up the
1818
+ * raw message. Receivers who wish to opt into FD passing should arrange to receive SCM_RIGHTS
1819
+ * whenever receiving an RPC message. Senders who wish to send FDs need not verify whether the
1820
+ * receiver knows how to receive them, because the operating system will automatically discard
1821
+ * ancillary messages like SCM_RIGHTS if the receiver doesn't ask to receive them, including
1822
+ * automatically closing any FDs.
1823
+ *
1824
+ * It is up to the application protocol to define what capabilities are expected to have file
1825
+ * descriptors attached, and what those FDs mean. But, for example, an application could use this
1826
+ * to open a file on disk and then transmit the open file descriptor to a sandboxed process that
1827
+ * does not otherwise have permission to access the filesystem directly. This is usually an
1828
+ * optimization: the sending process could instead provide an RPC interface supporting all the
1829
+ * operations needed (such as reading and writing a file), but by passing the file descriptor
1830
+ * directly, the recipient can often perform operations much more efficiently. Application
1831
+ * designers are encouraged to provide such RPC interfaces and automatically fall back to them
1832
+ * when FD passing is not available, so that the application can still work when the parties are
1833
+ * remote over a network.
1834
+ *
1835
+ * An attached FD is most often associated with a `senderHosted` descriptor. It could also make
1836
+ * sense in the case of `thirdPartyHosted`: in this case, the sender is forwarding the FD that
1837
+ * they received from the third party, so that the receiver can start using it without first
1838
+ * interacting with the third party. This is an optional optimization -- the middleman may choose
1839
+ * not to forward capabilities, in which case the receiver will need to complete the handshake
1840
+ * with the third party directly before receiving the FD. If an implementation receives a second
1841
+ * attached FD after having already received one previously (e.g. both in a `thirdPartyHosted`
1842
+ * CapDescriptor and then later again when receiving the final capability directly from the
1843
+ * third party), the implementation should discard the later FD and stick with the original. At
1844
+ * present, there is no known reason why other capability types (e.g. `receiverHosted`) would want
1845
+ * to carry an attached FD, but we reserve the right to define a meaning for this in the future.
1846
+ *
1847
+ * Each file descriptor attached to the message must be used in no more than one CapDescriptor,
1848
+ * so that the receiver does not need to use dup() or refcounting to handle the possibility of
1849
+ * multiple capabilities using the same descriptor. If multiple CapDescriptors do point to the
1850
+ * same FD index, then the receiver can arbitrarily choose which capability ends up having the
1851
+ * FD attached.
1852
+ *
1853
+ * To mitigate DoS attacks, RPC implementations should limit the number of FDs they are willing to
1854
+ * receive in a single message to a small value. If a message happens to contain more than that,
1855
+ * the list is truncated. Moreover, in some cases, FD passing needs to be blocked entirely for
1856
+ * security or implementation reasons, in which case the list may be truncated to zero. Hence,
1857
+ * `attachedFd` might point past the end of the list, which the implementation should treat as if
1858
+ * no FD was attached at all.
1859
+ *
1860
+ * The type of this field was chosen to be UInt8 because Linux supports sending only a maximum
1861
+ * of 253 file descriptors in an SCM_RIGHTS message anyway, and CapDescriptor had two bytes of
1862
+ * padding left -- so after adding this, there is still one byte for a future feature.
1863
+ * Conveniently, this also means we're able to use 0xff as the default value, which will always
1864
+ * be out-of-range (of course, the implementation should explicitly enforce that 255 descriptors
1865
+ * cannot be sent at once, rather than relying on Linux to do so).
1866
+ *
1867
+ */
1868
+ get attachedFd(): number;
1869
+ set attachedFd(value: number);
1870
+ toString(): string;
1871
+ which(): CapDescriptor_Which;
1872
+ }
1873
+ declare const PromisedAnswer_Op_Which: {
1874
+ /**
1875
+ * Does nothing. This member is mostly defined so that we can make `Op` a union even
1876
+ * though (as of this writing) only one real operation is defined.
1877
+ *
1878
+ */
1879
+ readonly NOOP: 0;
1880
+ /**
1881
+ * Get a pointer field within a struct. The number is an index into the pointer section, NOT
1882
+ * a field ordinal, so that the receiver does not need to understand the schema.
1883
+ *
1884
+ */
1885
+ readonly GET_POINTER_FIELD: 1;
1886
+ };
1887
+ type PromisedAnswer_Op_Which = (typeof PromisedAnswer_Op_Which)[keyof typeof PromisedAnswer_Op_Which];
1888
+ declare class PromisedAnswer_Op extends Struct {
1889
+ static readonly NOOP: 0;
1890
+ static readonly GET_POINTER_FIELD: 1;
1891
+ static readonly _capnp: {
1892
+ displayName: string;
1893
+ id: string;
1894
+ size: ObjectSize;
1895
+ };
1896
+ get _isNoop(): boolean;
1897
+ set noop(_: true);
1898
+ /**
1899
+ * Get a pointer field within a struct. The number is an index into the pointer section, NOT
1900
+ * a field ordinal, so that the receiver does not need to understand the schema.
1901
+ *
1902
+ */
1903
+ get getPointerField(): number;
1904
+ get _isGetPointerField(): boolean;
1905
+ set getPointerField(value: number);
1906
+ toString(): string;
1907
+ which(): PromisedAnswer_Op_Which;
1908
+ }
1909
+ /**
1910
+ * **(mostly level 1)**
1911
+ *
1912
+ * Specifies how to derive a promise from an unanswered question, by specifying the path of fields
1913
+ * to follow from the root of the eventual result struct to get to the desired capability. Used
1914
+ * to address method calls to a not-yet-returned capability or to pass such a capability as an
1915
+ * input to some other method call.
1916
+ *
1917
+ * Level 0 implementations must support `PromisedAnswer` only for the case where the answer is
1918
+ * to a `Bootstrap` message. In this case, `path` is always empty since `Bootstrap` always returns
1919
+ * a raw capability.
1920
+ *
1921
+ */
1922
+ declare class PromisedAnswer extends Struct {
1923
+ static readonly Op: typeof PromisedAnswer_Op;
1924
+ static readonly _capnp: {
1925
+ displayName: string;
1926
+ id: string;
1927
+ size: ObjectSize;
1928
+ };
1929
+ static _Transform: ListCtor<PromisedAnswer_Op>;
1930
+ /**
1931
+ * ID of the question (in the sender's question table / receiver's answer table) whose answer is
1932
+ * expected to contain the capability.
1933
+ *
1934
+ */
1935
+ get questionId(): number;
1936
+ set questionId(value: number);
1937
+ _adoptTransform(value: Orphan<List<PromisedAnswer_Op>>): void;
1938
+ _disownTransform(): Orphan<List<PromisedAnswer_Op>>;
1939
+ /**
1940
+ * Operations / transformations to apply to the result in order to get the capability actually
1941
+ * being addressed. E.g. if the result is a struct and you want to call a method on a capability
1942
+ * pointed to by a field of the struct, you need a `getPointerField` op.
1943
+ *
1944
+ */
1945
+ get transform(): List<PromisedAnswer_Op>;
1946
+ _hasTransform(): boolean;
1947
+ _initTransform(length: number): List<PromisedAnswer_Op>;
1948
+ set transform(value: List<PromisedAnswer_Op>);
1949
+ toString(): string;
1950
+ }
1951
+ /**
1952
+ * **(level 3)**
1953
+ *
1954
+ * Identifies a capability in a third-party vat that the sender wants the receiver to pick up.
1955
+ *
1956
+ */
1957
+ declare class ThirdPartyCapDescriptor extends Struct {
1958
+ static readonly _capnp: {
1959
+ displayName: string;
1960
+ id: string;
1961
+ size: ObjectSize;
1962
+ };
1963
+ _adoptId(value: Orphan<Pointer>): void;
1964
+ _disownId(): Orphan<Pointer>;
1965
+ /**
1966
+ * Identifies the third-party host and the specific capability to accept from it.
1967
+ *
1968
+ */
1969
+ get id(): Pointer;
1970
+ _hasId(): boolean;
1971
+ set id(value: Pointer);
1972
+ /**
1973
+ * A proxy for the third-party object exported by the sender. In CapTP terminology this is called
1974
+ * a "vine", because it is an indirect reference to the third-party object that snakes through the
1975
+ * sender vat. This serves two purposes:
1976
+ *
1977
+ * * Level 1 and 2 implementations that don't understand how to connect to a third party may
1978
+ * simply send calls to the vine. Such calls will be forwarded to the third-party by the
1979
+ * sender.
1980
+ *
1981
+ * * Level 3 implementations must release the vine only once they have successfully picked up the
1982
+ * object from the third party. This ensures that the capability is not released by the sender
1983
+ * prematurely.
1984
+ *
1985
+ * The sender will close the `Provide` request that it has sent to the third party as soon as
1986
+ * it receives either a `Call` or a `Release` message directed at the vine.
1987
+ *
1988
+ */
1989
+ get vineId(): number;
1990
+ set vineId(value: number);
1991
+ toString(): string;
1992
+ }
1993
+ declare const Exception_Type: {
1994
+ /**
1995
+ * A generic problem occurred, and it is believed that if the operation were repeated without
1996
+ * any change in the state of the world, the problem would occur again.
1997
+ *
1998
+ * A client might respond to this error by logging it for investigation by the developer and/or
1999
+ * displaying it to the user.
2000
+ *
2001
+ */
2002
+ readonly FAILED: 0;
2003
+ /**
2004
+ * The request was rejected due to a temporary lack of resources.
2005
+ *
2006
+ * Examples include:
2007
+ * - There's not enough CPU time to keep up with incoming requests, so some are rejected.
2008
+ * - The server ran out of RAM or disk space during the request.
2009
+ * - The operation timed out (took significantly longer than it should have).
2010
+ *
2011
+ * A client might respond to this error by scheduling to retry the operation much later. The
2012
+ * client should NOT retry again immediately since this would likely exacerbate the problem.
2013
+ *
2014
+ */
2015
+ readonly OVERLOADED: 1;
2016
+ /**
2017
+ * The method failed because a connection to some necessary capability was lost.
2018
+ *
2019
+ * Examples include:
2020
+ * - The client introduced the server to a third-party capability, the connection to that third
2021
+ * party was subsequently lost, and then the client requested that the server use the dead
2022
+ * capability for something.
2023
+ * - The client previously requested that the server obtain a capability from some third party.
2024
+ * The server returned a capability to an object wrapping the third-party capability. Later,
2025
+ * the server's connection to the third party was lost.
2026
+ * - The capability has been revoked. Revocation does not necessarily mean that the client is
2027
+ * no longer authorized to use the capability; it is often used simply as a way to force the
2028
+ * client to repeat the setup process, perhaps to efficiently move them to a new back-end or
2029
+ * get them to recognize some other change that has occurred.
2030
+ *
2031
+ * A client should normally respond to this error by releasing all capabilities it is currently
2032
+ * holding related to the one it called and then re-creating them by restoring SturdyRefs and/or
2033
+ * repeating the method calls used to create them originally. In other words, disconnect and
2034
+ * start over. This should in turn cause the server to obtain a new copy of the capability that
2035
+ * it lost, thus making everything work.
2036
+ *
2037
+ * If the client receives another `disconnected` error in the process of rebuilding the
2038
+ * capability and retrying the call, it should treat this as an `overloaded` error: the network
2039
+ * is currently unreliable, possibly due to load or other temporary issues.
2040
+ *
2041
+ */
2042
+ readonly DISCONNECTED: 2;
2043
+ /**
2044
+ * The server doesn't implement the requested method. If there is some other method that the
2045
+ * client could call (perhaps an older and/or slower interface), it should try that instead.
2046
+ * Otherwise, this should be treated like `failed`.
2047
+ *
2048
+ */
2049
+ readonly UNIMPLEMENTED: 3;
2050
+ };
2051
+ type Exception_Type = (typeof Exception_Type)[keyof typeof Exception_Type];
2052
+ /**
2053
+ * **(level 0)**
2054
+ *
2055
+ * Describes an arbitrary error that prevented an operation (e.g. a call) from completing.
2056
+ *
2057
+ * Cap'n Proto exceptions always indicate that something went wrong. In other words, in a fantasy
2058
+ * world where everything always works as expected, no exceptions would ever be thrown. Clients
2059
+ * should only ever catch exceptions as a means to implement fault-tolerance, where "fault" can
2060
+ * mean:
2061
+ * - Bugs.
2062
+ * - Invalid input.
2063
+ * - Configuration errors.
2064
+ * - Network problems.
2065
+ * - Insufficient resources.
2066
+ * - Version skew (unimplemented functionality).
2067
+ * - Other logistical problems.
2068
+ *
2069
+ * Exceptions should NOT be used to flag application-specific conditions that a client is expected
2070
+ * to handle in an application-specific way. Put another way, in the Cap'n Proto world,
2071
+ * "checked exceptions" (where an interface explicitly defines the exceptions it throws and
2072
+ * clients are forced by the type system to handle those exceptions) do NOT make sense.
2073
+ *
2074
+ */
2075
+ declare class Exception extends Struct {
2076
+ static readonly Type: {
2077
+ /**
2078
+ * A generic problem occurred, and it is believed that if the operation were repeated without
2079
+ * any change in the state of the world, the problem would occur again.
2080
+ *
2081
+ * A client might respond to this error by logging it for investigation by the developer and/or
2082
+ * displaying it to the user.
2083
+ *
2084
+ */
2085
+ readonly FAILED: 0;
2086
+ /**
2087
+ * The request was rejected due to a temporary lack of resources.
2088
+ *
2089
+ * Examples include:
2090
+ * - There's not enough CPU time to keep up with incoming requests, so some are rejected.
2091
+ * - The server ran out of RAM or disk space during the request.
2092
+ * - The operation timed out (took significantly longer than it should have).
2093
+ *
2094
+ * A client might respond to this error by scheduling to retry the operation much later. The
2095
+ * client should NOT retry again immediately since this would likely exacerbate the problem.
2096
+ *
2097
+ */
2098
+ readonly OVERLOADED: 1;
2099
+ /**
2100
+ * The method failed because a connection to some necessary capability was lost.
2101
+ *
2102
+ * Examples include:
2103
+ * - The client introduced the server to a third-party capability, the connection to that third
2104
+ * party was subsequently lost, and then the client requested that the server use the dead
2105
+ * capability for something.
2106
+ * - The client previously requested that the server obtain a capability from some third party.
2107
+ * The server returned a capability to an object wrapping the third-party capability. Later,
2108
+ * the server's connection to the third party was lost.
2109
+ * - The capability has been revoked. Revocation does not necessarily mean that the client is
2110
+ * no longer authorized to use the capability; it is often used simply as a way to force the
2111
+ * client to repeat the setup process, perhaps to efficiently move them to a new back-end or
2112
+ * get them to recognize some other change that has occurred.
2113
+ *
2114
+ * A client should normally respond to this error by releasing all capabilities it is currently
2115
+ * holding related to the one it called and then re-creating them by restoring SturdyRefs and/or
2116
+ * repeating the method calls used to create them originally. In other words, disconnect and
2117
+ * start over. This should in turn cause the server to obtain a new copy of the capability that
2118
+ * it lost, thus making everything work.
2119
+ *
2120
+ * If the client receives another `disconnected` error in the process of rebuilding the
2121
+ * capability and retrying the call, it should treat this as an `overloaded` error: the network
2122
+ * is currently unreliable, possibly due to load or other temporary issues.
2123
+ *
2124
+ */
2125
+ readonly DISCONNECTED: 2;
2126
+ /**
2127
+ * The server doesn't implement the requested method. If there is some other method that the
2128
+ * client could call (perhaps an older and/or slower interface), it should try that instead.
2129
+ * Otherwise, this should be treated like `failed`.
2130
+ *
2131
+ */
2132
+ readonly UNIMPLEMENTED: 3;
2133
+ };
2134
+ static readonly _capnp: {
2135
+ displayName: string;
2136
+ id: string;
2137
+ size: ObjectSize;
2138
+ };
2139
+ /**
2140
+ * Human-readable failure description.
2141
+ *
2142
+ */
2143
+ get reason(): string;
2144
+ set reason(value: string);
2145
+ /**
2146
+ * The type of the error. The purpose of this enum is not to describe the error itself, but
2147
+ * rather to describe how the client might want to respond to the error.
2148
+ *
2149
+ */
2150
+ get type(): Exception_Type;
2151
+ set type(value: Exception_Type);
2152
+ /**
2153
+ * OBSOLETE. Ignore.
2154
+ *
2155
+ */
2156
+ get obsoleteIsCallersFault(): boolean;
2157
+ set obsoleteIsCallersFault(value: boolean);
2158
+ /**
2159
+ * OBSOLETE. See `type` instead.
2160
+ *
2161
+ */
2162
+ get obsoleteDurability(): number;
2163
+ set obsoleteDurability(value: number);
2164
+ /**
2165
+ * Stack trace text from the remote server. The format is not specified. By default,
2166
+ * implementations do not provide stack traces; the application must explicitly enable them
2167
+ * when desired.
2168
+ *
2169
+ */
2170
+ get trace(): string;
2171
+ set trace(value: string);
2172
+ toString(): string;
2173
+ }
2174
+ type CapabilityID = number;
2175
+ interface Method<P extends Struct, R extends Struct> {
2176
+ interfaceId: bigint;
2177
+ methodId: number;
2178
+ interfaceName?: string;
2179
+ methodName?: string;
2180
+ ParamsClass: StructCtor<P>;
2181
+ ResultsClass: StructCtor<R>;
2182
+ }
2183
+ type Call<P extends Struct, R extends Struct> = FuncCall<P, R> | DataCall<P, R>;
2184
+ interface BaseCall<P extends Struct, R extends Struct> {
2185
+ method: Method<P, R>;
2186
+ }
2187
+ type FuncCall<P extends Struct, R extends Struct> = BaseCall<P, R> & {
2188
+ paramsFunc?(params: P): void;
2189
+ };
2190
+ type DataCall<P extends Struct, R extends Struct> = BaseCall<P, R> & {
2191
+ params: P;
2192
+ };
2193
+ declare function isFuncCall<P extends Struct, R extends Struct>(call: Call<P, R>): call is FuncCall<P, R>;
2194
+ declare function isDataCall<P extends Struct, R extends Struct>(call: Call<P, R>): call is DataCall<P, R>;
2195
+ declare function copyCall<P extends Struct, R extends Struct>(call: Call<P, R>): DataCall<P, R>;
2196
+ declare function placeParams<P extends Struct, R extends Struct>(call: Call<P, R>, contentPtr: Pointer | undefined): P;
2197
+ declare class IDGen {
2198
+ i: number;
2199
+ free: number[];
2200
+ next(): number;
2201
+ remove(i: number): void;
2202
+ }
2203
+ interface PipelineOp {
2204
+ field: number;
2205
+ defaultValue?: Pointer;
2206
+ }
2207
+ declare class Deferred<T> {
2208
+ static fromPromise<T>(p: Promise<T>): Deferred<T>;
2209
+ promise: Promise<T>;
2210
+ reject: (reason?: unknown) => void;
2211
+ resolve: (value: T | PromiseLike<T>) => void;
2212
+ constructor();
2213
+ }
2214
+ interface ecall {
2215
+ call: Call<any, any>;
2216
+ f: Fulfiller<any>;
2217
+ }
2218
+ interface pcall extends ecall {
2219
+ transform: PipelineOp[];
2220
+ }
2221
+ type ecallSlot = ecall | null;
2222
+ declare class Ecalls {
2223
+ data: ecallSlot[];
2224
+ constructor(data: ecallSlot[]);
2225
+ static copyOf(data: ecallSlot[]): Ecalls;
2226
+ len(): number;
2227
+ clear(i: number): void;
2228
+ copy(): Ecalls;
2229
+ }
2230
+ declare class Fulfiller<R extends Struct> implements Answer<R> {
2231
+ resolved: boolean;
2232
+ answer?: Answer<R>;
2233
+ queue: pcall[];
2234
+ queueCap: number;
2235
+ deferred: Deferred<R>;
2236
+ fulfill(s: R): void;
2237
+ reject(err: Error): void;
2238
+ peek(): Answer<R> | undefined;
2239
+ struct(): Promise<R>;
2240
+ pipelineCall<CallParams extends Struct, CallResults extends Struct>(transform: PipelineOp[], call: Call<CallParams, CallResults>): Answer<CallResults>;
2241
+ pipelineClose(transform: PipelineOp[]): void;
2242
+ emptyQueue(s: Struct): Record<number, Ecalls>;
2243
+ }
2244
+ interface Answer<R extends Struct> {
2245
+ struct(): Promise<R>;
2246
+ pipelineCall<CallParams extends Struct, CallResults extends Struct>(transform: PipelineOp[], call: Call<CallParams, CallResults>): Answer<CallResults>;
2247
+ pipelineClose(transform: PipelineOp[]): void;
2248
+ }
2249
+ declare class AnswerEntry<R extends Struct> {
2250
+ id: number;
2251
+ conn: Conn;
2252
+ resultCaps: number[];
2253
+ done: boolean;
2254
+ obj?: R;
2255
+ err?: Error;
2256
+ deferred: Deferred<R>;
2257
+ queue: AnswerPCall[];
2258
+ constructor(conn: Conn, id: number);
2259
+ fulfill(obj: R): void;
2260
+ reject(err: Error): void;
2261
+ emptyQueue(obj: R): [{
2262
+ [key: number]: AnswerQCall[];
2263
+ }, Error | undefined];
2264
+ queueCall<P extends Struct, R extends Struct>(call: Call<P, R>, transform: PipelineOp[], a: AnswerEntry<R>): void;
2265
+ }
2266
+ type AnswerQCall = QCallRemoteCall | QCallLocalCall | QCallDisembargo;
2267
+ interface QCallRemoteCall {
2268
+ call: Call<any, any>;
2269
+ a: AnswerEntry<any>;
2270
+ }
2271
+ interface QCallLocalCall {
2272
+ call: Call<any, any>;
2273
+ f: Fulfiller<any>;
2274
+ }
2275
+ interface QCallDisembargo {
2276
+ embargoID: number;
2277
+ embargoTarget: MessageTarget;
2278
+ }
2279
+ interface AnswerPCall {
2280
+ qcall: AnswerQCall;
2281
+ transform: PipelineOp[];
2282
+ }
2283
+ type Finalize = (obj: unknown, finalizer: Finalizer) => void;
2284
+ type Finalizer = () => void;
2285
+ declare class Ref implements Client {
2286
+ rc: RefCount;
2287
+ closeState: {
2288
+ closed: boolean;
2289
+ };
2290
+ constructor(rc: RefCount, finalize: Finalize);
2291
+ call<P extends Struct, R extends Struct>(cl: Call<P, R>): Answer<R>;
2292
+ client(): Client;
2293
+ close(): void;
2294
+ }
2295
+ /**
2296
+ * A RefCount will close its underlying client once all its references are
2297
+ * closed.
2298
+ */
2299
+ declare class RefCount implements Client {
2300
+ refs: number;
2301
+ finalize: Finalize;
2302
+ _client: Client;
2303
+ private constructor();
2304
+ static new(c: Client, finalize: Finalize): [RefCount, Ref];
2305
+ call<P extends Struct, R extends Struct>(cl: Call<P, R>): Answer<R>;
2306
+ client(): Client;
2307
+ close(): void;
2308
+ ref(): Client;
2309
+ newRef(): Ref;
2310
+ decref(): void;
2311
+ }
2312
+ interface Transport {
2313
+ sendMessage(msg: Message$1): void;
2314
+ recvMessage(): Promise<Message$1>;
2315
+ close(): void;
2316
+ }
2317
+ declare enum QuestionState {
2318
+ IN_PROGRESS = 0,
2319
+ RESOLVED = 1,
2320
+ CANCELED = 2
2321
+ }
2322
+ declare class Question<P extends Struct, R extends Struct> implements Answer<R> {
2323
+ conn: Conn;
2324
+ id: number;
2325
+ method?: Method<P, R> | undefined;
2326
+ paramCaps: number[];
2327
+ state: QuestionState;
2328
+ obj?: R;
2329
+ err?: Error;
2330
+ derived: PipelineOp[][];
2331
+ deferred: Deferred<R>;
2332
+ constructor(conn: Conn, id: number, method?: Method<P, R> | undefined);
2333
+ struct(): Promise<R>;
2334
+ start(): void;
2335
+ fulfill(obj: Pointer): void;
2336
+ reject(err: Error): void;
2337
+ cancel(err: Error): boolean;
2338
+ pipelineCall<CallParams extends Struct, CallResults extends Struct>(transform: PipelineOp[], call: Call<CallParams, CallResults>): Answer<CallResults>;
2339
+ addPromise(transform: PipelineOp[]): void;
2340
+ pipelineClose(): void;
2341
+ }
2342
+ interface ServerMethod<P extends Struct, R extends Struct> extends Method<P, R> {
2343
+ impl(params: P, results: R): Promise<void>;
2344
+ }
2345
+ interface ServerCall<P extends Struct, R extends Struct> extends DataCall<P, R> {
2346
+ serverMethod: ServerMethod<P, R>;
2347
+ answer: Fulfiller<R>;
2348
+ }
2349
+ declare class Server implements Client {
2350
+ target: any;
2351
+ methods: Array<ServerMethod<any, any>>;
2352
+ constructor(target: any, methods: Array<ServerMethod<any, any>>);
2353
+ startCall<P extends Struct, R extends Struct>(call: ServerCall<P, R>): void;
2354
+ call<P extends Struct, R extends Struct>(call: Call<P, R>): Answer<R>;
2355
+ close(): void;
2356
+ }
2357
+ type QuestionSlot = Question<any, any> | null;
2358
+ declare class Conn {
2359
+ transport: Transport;
2360
+ finalize: Finalize;
2361
+ questionID: IDGen;
2362
+ questions: QuestionSlot[];
2363
+ answers: {
2364
+ [key: number]: AnswerEntry<any>;
2365
+ };
2366
+ exportID: IDGen;
2367
+ exports: Array<Export | null>;
2368
+ imports: {
2369
+ [key: number]: ImportEntry;
2370
+ };
2371
+ onError?: (err?: Error) => void;
2372
+ main?: Client;
2373
+ working: boolean;
2374
+ /**
2375
+ * Create a new connection
2376
+ * @param transport The transport used to receive/send messages.
2377
+ * @param finalize Weak reference implementation. Compatible with
2378
+ * the 'weak' module on node.js (just add weak as a dependency and pass
2379
+ * require("weak")), but alternative implementations can be provided for
2380
+ * other platforms like Electron. Defaults to using FinalizationRegistry if
2381
+ * available.
2382
+ * @returns A new connection.
2383
+ */
2384
+ constructor(transport: Transport, finalize?: Finalize);
2385
+ bootstrap<C>(InterfaceClass: InterfaceCtor<C, Server>): C;
2386
+ initMain<S extends InterfaceCtor<unknown, Server>>(InterfaceClass: S, target: ServerTarget<S>): void;
2387
+ startWork(): void;
2388
+ sendReturnException(id: number, err: Error): void;
2389
+ handleBootstrapMessage(m: Message$1): void;
2390
+ handleFinishMessage(m: Message$1): void;
2391
+ handleMessage(m: Message$1): void;
2392
+ handleReturnMessage(m: Message$1): void;
2393
+ handleCallMessage(m: Message$1): void;
2394
+ routeCallMessage<P extends Struct, R extends Struct>(result: AnswerEntry<R>, mt: MessageTarget, cl: Call<P, R>): void;
2395
+ populateMessageCapTable(payload: Payload): void;
2396
+ addImport(id: number): Client;
2397
+ findExport(id: number): Export | null;
2398
+ addExport(client: Client): number;
2399
+ releaseExport(id: number, refs: number): void;
2400
+ error(s: string): void;
2401
+ newQuestion<CallParams extends Struct, CallResults extends Struct>(method?: Method<CallParams, CallResults>): Question<CallParams, CallResults>;
2402
+ findQuestion<P extends Struct, R extends Struct>(id: number): Question<P, R> | null;
2403
+ popQuestion<P extends Struct, R extends Struct>(id: number): Question<P, R> | null;
2404
+ insertAnswer(id: number): AnswerEntry<any> | null;
2405
+ popAnswer(id: number): AnswerEntry<any> | null;
2406
+ shutdown(_err?: Error): void;
2407
+ call<P extends Struct, R extends Struct>(client: Client, call: Call<P, R>): Answer<R>;
2408
+ fillParams<P extends Struct, R extends Struct>(payload: Payload, cl: Call<P, R>): void;
2409
+ makeCapTable(s: Segment, init: (length: number) => List<CapDescriptor>): void;
2410
+ descriptorForClient(desc: CapDescriptor, _client: Client): void;
2411
+ sendMessage(msg: Message$1): void;
2412
+ private work;
2413
+ }
2414
+ interface Export {
2415
+ id: number;
2416
+ rc: RefCount;
2417
+ client: Client;
2418
+ wireRefs: number;
2419
+ }
2420
+ interface ImportEntry {
2421
+ rc: RefCount;
2422
+ refs: number;
2423
+ }
2424
+ declare function answerPipelineClient<T extends Struct>(a: AnswerEntry<T>, transform: PipelineOp[]): Client;
2425
+ type ServerTarget<S extends InterfaceCtor<unknown, Server>> = ConstructorParameters<S["Server"]>[0];
2426
+ interface InterfaceCtor<C, S extends Server> {
2427
+ readonly _capnp: {
2428
+ displayName: string;
2429
+ id: string;
2430
+ size: ObjectSize;
2431
+ };
2432
+ readonly Client: {
2433
+ new (client: Client): C;
2434
+ };
2435
+ readonly Server: {
2436
+ new (target: any): S;
2437
+ };
2438
+ new (segment: Segment, byteOffset: number, depthLimit?: number): Interface;
2439
+ }
2440
+ declare class Interface extends Pointer {
2441
+ static readonly _capnp: {
2442
+ displayName: string;
2443
+ };
2444
+ static readonly getCapID: typeof getCapID;
2445
+ static readonly getAsInterface: typeof getAsInterface;
2446
+ static readonly isInterface: typeof isInterface;
2447
+ static readonly getClient: typeof getClient;
2448
+ constructor(segment: Segment, byteOffset: number, depthLimit?: number);
2449
+ static fromPointer(p: Pointer): Interface | null;
2450
+ getCapId(): CapabilityID;
2451
+ getClient(): Client | null;
2452
+ }
2453
+ declare function getAsInterface(p: Pointer): Interface | null;
2454
+ declare function isInterface(p: Pointer): boolean;
2455
+ declare function getCapID(i: Interface): CapabilityID;
2456
+ declare function getClient(i: Interface): Client | null;
2457
+ interface _Orphan {
2458
+ capId: number;
2459
+ elementSize: ListElementSize;
2460
+ length: number;
2461
+ size: ObjectSize;
2462
+ type: PointerType;
2463
+ }
2464
+ /**
2465
+ * An orphaned pointer. This object itself is technically a pointer to the original pointer's content, which was left
2466
+ * untouched in its original message. The original pointer data is encoded as attributes on the Orphan object, ready to
2467
+ * be reconstructed once another pointer is ready to adopt it.
2468
+ */
2469
+ declare class Orphan<T extends Pointer> {
2470
+ /** If this member is not present then the orphan has already been adopted, or something went very wrong. */
2471
+ _capnp?: _Orphan;
2472
+ byteOffset: number;
2473
+ segment: Segment;
2474
+ constructor(src: T);
2475
+ /**
2476
+ * Adopt (move) this orphan into the target pointer location. This will allocate far pointers in `dst` as needed.
2477
+ *
2478
+ * @param dst The destination pointer.
2479
+ */
2480
+ _moveTo(dst: T): void;
2481
+ dispose(): void;
2482
+ }
2483
+ declare class Segment implements DataView {
2484
+ readonly id: number;
2485
+ readonly message: Message;
2486
+ buffer: ArrayBuffer;
2487
+ /** The number of bytes currently allocated in the segment. */
2488
+ byteLength: number;
2489
+ /**
2490
+ * This value should always be zero. It's only here to satisfy the DataView interface.
2491
+ *
2492
+ * In the future the Segment implementation (or a child class) may allow accessing the buffer from a nonzero offset,
2493
+ * but that adds a lot of extra arithmetic.
2494
+ */
2495
+ byteOffset: number;
2496
+ readonly [Symbol.toStringTag]: "DataView";
2497
+ private _dv;
2498
+ constructor(id: number, message: Message, buffer: ArrayBuffer, byteLength?: number);
2499
+ /**
2500
+ * Attempt to allocate the requested number of bytes in this segment. If this segment is full this method will return
2501
+ * a pointer to freshly allocated space in another segment from the same message.
2502
+ *
2503
+ * @param byteLength The number of bytes to allocate, will be rounded up to the nearest word.
2504
+ * @returns A pointer to the newly allocated space.
2505
+ */
2506
+ allocate(byteLength: number): Pointer;
2507
+ /**
2508
+ * Quickly copy a word (8 bytes) from `srcSegment` into this one at the given offset.
2509
+ *
2510
+ * @param byteOffset The offset to write the word to.
2511
+ * @param srcSegment The segment to copy the word from.
2512
+ * @param srcByteOffset The offset from the start of `srcSegment` to copy from.
2513
+ */
2514
+ copyWord(byteOffset: number, srcSegment: Segment, srcByteOffset: number): void;
2515
+ /**
2516
+ * Quickly copy words from `srcSegment` into this one.
2517
+ *
2518
+ * @param byteOffset The offset to start copying into.
2519
+ * @param srcSegment The segment to copy from.
2520
+ * @param srcByteOffset The start offset to copy from.
2521
+ * @param wordLength The number of words to copy.
2522
+ */
2523
+ copyWords(byteOffset: number, srcSegment: Segment, srcByteOffset: number, wordLength: number): void;
2524
+ /**
2525
+ * Quickly fill a number of words in the buffer with zeroes.
2526
+ *
2527
+ * @param byteOffset The first byte to set to zero.
2528
+ * @param wordLength The number of words (not bytes!) to zero out.
2529
+ */
2530
+ fillZeroWords(byteOffset: number, wordLength: number): void;
2531
+ getBigInt64(byteOffset: number, littleEndian?: boolean): bigint;
2532
+ getBigUint64(byteOffset: number, littleEndian?: boolean): bigint;
2533
+ /**
2534
+ * Get the total number of bytes available in this segment (the size of its underlying buffer).
2535
+ *
2536
+ * @returns The total number of bytes this segment can hold.
2537
+ */
2538
+ getCapacity(): number;
2539
+ /**
2540
+ * Read a float32 value out of this segment.
2541
+ *
2542
+ * @param byteOffset The offset in bytes to the value.
2543
+ * @returns The value.
2544
+ */
2545
+ getFloat32(byteOffset: number): number;
2546
+ /**
2547
+ * Read a float64 value out of this segment.
2548
+ *
2549
+ * @param byteOffset The offset in bytes to the value.
2550
+ * @returns The value.
2551
+ */
2552
+ getFloat64(byteOffset: number): number;
2553
+ /**
2554
+ * Read an int16 value out of this segment.
2555
+ *
2556
+ * @param byteOffset The offset in bytes to the value.
2557
+ * @returns The value.
2558
+ */
2559
+ getInt16(byteOffset: number): number;
2560
+ /**
2561
+ * Read an int32 value out of this segment.
2562
+ *
2563
+ * @param byteOffset The offset in bytes to the value.
2564
+ * @returns The value.
2565
+ */
2566
+ getInt32(byteOffset: number): number;
2567
+ /**
2568
+ * Read an int64 value out of this segment.
2569
+ *
2570
+ * @param byteOffset The offset in bytes to the value.
2571
+ * @returns The value.
2572
+ */
2573
+ getInt64(byteOffset: number): bigint;
2574
+ /**
2575
+ * Read an int8 value out of this segment.
2576
+ *
2577
+ * @param byteOffset The offset in bytes to the value.
2578
+ * @returns The value.
2579
+ */
2580
+ getInt8(byteOffset: number): number;
2581
+ /**
2582
+ * Read a uint16 value out of this segment.
2583
+ *
2584
+ * @param byteOffset The offset in bytes to the value.
2585
+ * @returns The value.
2586
+ */
2587
+ getUint16(byteOffset: number): number;
2588
+ /**
2589
+ * Read a uint32 value out of this segment.
2590
+ *
2591
+ * @param byteOffset The offset in bytes to the value.
2592
+ * @returns The value.
2593
+ */
2594
+ getUint32(byteOffset: number): number;
2595
+ /**
2596
+ * Read a uint64 value (as a bigint) out of this segment.
2597
+ * NOTE: this does not copy the memory region, so updates to the underlying buffer will affect the returned value!
2598
+ *
2599
+ * @param byteOffset The offset in bytes to the value.
2600
+ * @returns The value.
2601
+ */
2602
+ getUint64(byteOffset: number): bigint;
2603
+ /**
2604
+ * Read a uint8 value out of this segment.
2605
+ *
2606
+ * @param byteOffset The offset in bytes to the value.
2607
+ * @returns The value.
2608
+ */
2609
+ getUint8(byteOffset: number): number;
2610
+ hasCapacity(byteLength: number): boolean;
2611
+ /**
2612
+ * Quickly check the word at the given offset to see if it is equal to zero.
2613
+ *
2614
+ * PERF_V8: Fastest way to do this is by reading the whole word as a `number` (float64) in the _native_ endian format
2615
+ * and see if it's zero.
2616
+ *
2617
+ * Benchmark: http://jsben.ch/#/Pjooc
2618
+ *
2619
+ * @param byteOffset The offset to the word.
2620
+ * @returns `true` if the word is zero.
2621
+ */
2622
+ isWordZero(byteOffset: number): boolean;
2623
+ /**
2624
+ * Swap out this segment's underlying buffer with a new one. It's assumed that the new buffer has the same content but
2625
+ * more free space, otherwise all existing pointers to this segment will be hilariously broken.
2626
+ *
2627
+ * @param buffer The new buffer to use.
2628
+ */
2629
+ replaceBuffer(buffer: ArrayBuffer): void;
2630
+ /**
2631
+ * Read a float16 value from the specified offset.
2632
+ *
2633
+ * @param byteOffset The offset from the beginning of the buffer.
2634
+ * @param littleEndian If true, read the value as little-endian, otherwise read it as big-endian.
2635
+ * @returns The value read from the buffer.
2636
+ */
2637
+ getFloat16(byteOffset: number, littleEndian?: boolean | undefined): number;
2638
+ /**
2639
+ * Write an float16 value to the specified offset.
2640
+ *
2641
+ * @param byteOffset The offset from the beginning of the buffer.
2642
+ * @param val The value to store.
2643
+ */
2644
+ setFloat16(byteOffset: number, val: number): void;
2645
+ setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
2646
+ /** WARNING: This function is not yet implemented. */
2647
+ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
2648
+ /**
2649
+ * Write a float32 value to the specified offset.
2650
+ *
2651
+ * @param byteOffset The offset from the beginning of the buffer.
2652
+ * @param val The value to store.
2653
+ */
2654
+ setFloat32(byteOffset: number, val: number): void;
2655
+ /**
2656
+ * Write an float64 value to the specified offset.
2657
+ *
2658
+ * @param byteOffset The offset from the beginning of the buffer.
2659
+ * @param val The value to store.
2660
+ */
2661
+ setFloat64(byteOffset: number, val: number): void;
2662
+ /**
2663
+ * Write an int16 value to the specified offset.
2664
+ *
2665
+ * @param byteOffset The offset from the beginning of the buffer.
2666
+ * @param val The value to store.
2667
+ */
2668
+ setInt16(byteOffset: number, val: number): void;
2669
+ /**
2670
+ * Write an int32 value to the specified offset.
2671
+ *
2672
+ * @param byteOffset The offset from the beginning of the buffer.
2673
+ * @param val The value to store.
2674
+ */
2675
+ setInt32(byteOffset: number, val: number): void;
2676
+ /**
2677
+ * Write an int8 value to the specified offset.
2678
+ *
2679
+ * @param byteOffset The offset from the beginning of the buffer.
2680
+ * @param val The value to store.
2681
+ */
2682
+ setInt8(byteOffset: number, val: number): void;
2683
+ /**
2684
+ * Write an int64 value to the specified offset.
2685
+ *
2686
+ * @param byteOffset The offset from the beginning of the buffer.
2687
+ * @param val The value to store.
2688
+ */
2689
+ setInt64(byteOffset: number, val: bigint): void;
2690
+ /**
2691
+ * Write a uint16 value to the specified offset.
2692
+ *
2693
+ * @param byteOffset The offset from the beginning of the buffer.
2694
+ * @param val The value to store.
2695
+ */
2696
+ setUint16(byteOffset: number, val: number): void;
2697
+ /**
2698
+ * Write a uint32 value to the specified offset.
2699
+ *
2700
+ * @param byteOffset The offset from the beginning of the buffer.
2701
+ * @param val The value to store.
2702
+ */
2703
+ setUint32(byteOffset: number, val: number): void;
2704
+ /**
2705
+ * Write a uint64 value to the specified offset.
2706
+ *
2707
+ * @param byteOffset The offset from the beginning of the buffer.
2708
+ * @param val The value to store.
2709
+ */
2710
+ setUint64(byteOffset: number, val: bigint): void;
2711
+ /**
2712
+ * Write a uint8 (byte) value to the specified offset.
2713
+ *
2714
+ * @param byteOffset The offset from the beginning of the buffer.
2715
+ * @param val The value to store.
2716
+ */
2717
+ setUint8(byteOffset: number, val: number): void;
2718
+ /**
2719
+ * Write a zero word (8 bytes) to the specified offset. This is slightly faster than calling `setUint64` or
2720
+ * `setFloat64` with a zero value.
2721
+ *
2722
+ * Benchmark: http://jsben.ch/#/dUdPI
2723
+ *
2724
+ * @param byteOffset The offset of the word to set to zero.
2725
+ */
2726
+ setWordZero(byteOffset: number): void;
2727
+ toString(): string;
2728
+ }
2729
+ interface _StructCtor extends _PointerCtor {
2730
+ readonly id: string;
2731
+ readonly size: ObjectSize;
2732
+ }
2733
+ interface StructCtor<T extends Struct> {
2734
+ readonly _capnp: _StructCtor;
2735
+ new (segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number): T;
2736
+ }
2737
+ interface _Struct extends _Pointer {
2738
+ compositeIndex?: number;
2739
+ }
2740
+ declare class Struct extends Pointer<_Struct> {
2741
+ static readonly _capnp: {
2742
+ displayName: string;
2743
+ };
2744
+ /**
2745
+ * Create a new pointer to a struct.
2746
+ *
2747
+ * @param segment The segment the pointer resides in.
2748
+ * @param byteOffset The offset from the beginning of the segment to the beginning of the pointer data.
2749
+ * @param depthLimit The nesting depth limit for this object.
2750
+ * @param compositeIndex If set, then this pointer is actually a reference to a composite list
2751
+ * (`this._getPointerTargetType() === PointerType.LIST`), and this number is used as the index of the struct within
2752
+ * the list. It is not valid to call `initStruct()` on a composite struct – the struct contents are initialized when
2753
+ * the list pointer is initialized.
2754
+ */
2755
+ constructor(segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number);
2756
+ static [Symbol.toStringTag](): string;
2757
+ [Symbol.toStringTag](): string;
2758
+ }
2759
+ interface Client {
2760
+ call<P extends Struct, R extends Struct>(call: Call<P, R>): Answer<R>;
2761
+ close(): void;
2762
+ }
2763
+ declare function isSameClient(c: Client, d: Client): boolean;
2764
+ declare function clientFromResolution(transform: PipelineOp[], obj?: Struct, err?: Error): Client;
2765
+ declare class ArenaAllocationResult {
2766
+ /**
2767
+ * The newly allocated buffer. This buffer might be a copy of an existing segment's buffer with free space appended.
2768
+ */
2769
+ readonly buffer: ArrayBuffer;
2770
+ /**
2771
+ * The id of the newly-allocated segment.
2772
+ */
2773
+ readonly id: number;
2774
+ constructor(id: number, buffer: ArrayBuffer);
2775
+ }
2776
+ declare enum ArenaKind {
2777
+ SINGLE_SEGMENT = 0,
2778
+ MULTI_SEGMENT = 1
2779
+ }
2780
+ declare class MultiSegmentArena {
2781
+ readonly buffers: ArrayBuffer[];
2782
+ static readonly allocate: typeof allocate$1;
2783
+ static readonly getBuffer: typeof getBuffer$1;
2784
+ static readonly getNumSegments: typeof getNumSegments$1;
2785
+ readonly kind = ArenaKind.MULTI_SEGMENT;
2786
+ constructor(buffers?: ArrayBuffer[]);
2787
+ toString(): string;
2788
+ }
2789
+ declare function allocate$1(minSize: number, m: MultiSegmentArena): ArenaAllocationResult;
2790
+ declare function getBuffer$1(id: number, m: MultiSegmentArena): ArrayBuffer;
2791
+ declare function getNumSegments$1(m: MultiSegmentArena): number;
2792
+ declare class SingleSegmentArena {
2793
+ static readonly allocate: typeof allocate;
2794
+ static readonly getBuffer: typeof getBuffer;
2795
+ static readonly getNumSegments: typeof getNumSegments;
2796
+ buffer: ArrayBuffer;
2797
+ readonly kind = ArenaKind.SINGLE_SEGMENT;
2798
+ constructor(buffer?: ArrayBuffer);
2799
+ toString(): string;
2800
+ }
2801
+ declare function allocate(minSize: number, segments: Segment[], s: SingleSegmentArena): ArenaAllocationResult;
2802
+ declare function getBuffer(id: number, s: SingleSegmentArena): ArrayBuffer;
2803
+ declare function getNumSegments(): number;
2804
+ type AnyArena = MultiSegmentArena | SingleSegmentArena;
2805
+ interface _Message {
2806
+ readonly arena: AnyArena;
2807
+ segments: Segment[];
2808
+ traversalLimit: number;
2809
+ capTable?: Array<Client | null>;
2810
+ }
2811
+ declare class Message {
2812
+ static readonly allocateSegment: typeof allocateSegment;
2813
+ static readonly dump: typeof dump;
2814
+ static readonly getRoot: typeof getRoot;
2815
+ static readonly getSegment: typeof getSegment;
2816
+ static readonly initRoot: typeof initRoot;
2817
+ static readonly readRawPointer: typeof readRawPointer;
2818
+ static readonly toArrayBuffer: typeof toArrayBuffer;
2819
+ static readonly toPackedArrayBuffer: typeof toPackedArrayBuffer;
2820
+ readonly _capnp: _Message;
2821
+ /**
2822
+ * A Cap'n Proto message.
2823
+ *
2824
+ * SECURITY WARNING: In Node.js do not pass a Buffer's internal array buffer into this constructor. Pass the buffer
2825
+ * directly and everything will be fine. If not, your message will potentially be initialized with random memory
2826
+ * contents!
2827
+ *
2828
+ * The constructor method creates a new Message, optionally using a provided arena for segment allocation, or a buffer
2829
+ * to read from.
2830
+ *
2831
+ * @param src The source for the message.
2832
+ * A value of `undefined` will cause the message to initialize with a single segment arena only big enough for the
2833
+ * root pointer; it will expand as you go. This is a reasonable choice for most messages.
2834
+ *
2835
+ * Passing an arena will cause the message to use that arena for its segment allocation. Contents will be accepted
2836
+ * as-is.
2837
+ *
2838
+ * Passing an array buffer view (like `DataView`, `Uint8Array` or `Buffer`) will create a **copy** of the source
2839
+ * buffer; beware of the potential performance cost!
2840
+ *
2841
+ * @param packed Whether or not the message is packed. If `true` (the default), the message will be
2842
+ * unpacked.
2843
+ *
2844
+ * @param singleSegment If true, `src` will be treated as a message consisting of a single segment without
2845
+ * a framing header.
2846
+ *
2847
+ */
2848
+ constructor(src?: AnyArena | ArrayBufferView | ArrayBuffer, packed?: boolean, singleSegment?: boolean);
2849
+ allocateSegment(byteLength: number): Segment;
2850
+ /**
2851
+ * Copies the contents of this message into an identical message with its own ArrayBuffers.
2852
+ *
2853
+ * @returns A copy of this message.
2854
+ */
2855
+ copy(): Message;
2856
+ /**
2857
+ * Create a pretty-printed string dump of this message; incredibly useful for debugging.
2858
+ *
2859
+ * WARNING: Do not call this method on large messages!
2860
+ *
2861
+ * @returns A big steaming pile of pretty hex digits.
2862
+ */
2863
+ dump(): string;
2864
+ /**
2865
+ * Get a struct pointer for the root of this message. This is primarily used when reading a message; it will not
2866
+ * overwrite existing data.
2867
+ *
2868
+ * @param RootStruct The struct type to use as the root.
2869
+ * @returns A struct representing the root of the message.
2870
+ */
2871
+ getRoot<T extends Struct>(RootStruct: StructCtor<T>): T;
2872
+ /**
2873
+ * Get a segment by its id.
2874
+ *
2875
+ * This will lazily allocate the first segment if it doesn't already exist.
2876
+ *
2877
+ * @param id The segment id.
2878
+ * @returns The requested segment.
2879
+ */
2880
+ getSegment(id: number): Segment;
2881
+ /**
2882
+ * Initialize a new message using the provided struct type as the root.
2883
+ *
2884
+ * @param RootStruct The struct type to use as the root.
2885
+ * @returns An initialized struct pointing to the root of the message.
2886
+ */
2887
+ initRoot<T extends Struct>(RootStruct: StructCtor<T>): T;
2888
+ /**
2889
+ * Set the root of the message to a copy of the given pointer. Used internally
2890
+ * to make copies of pointers for default values.
2891
+ *
2892
+ * @param src The source pointer to copy.
2893
+ */
2894
+ setRoot(src: Pointer): void;
2895
+ /**
2896
+ * Combine the contents of this message's segments into a single array buffer and prepend a stream framing header
2897
+ * containing information about the following segment data.
2898
+ *
2899
+ * @returns An ArrayBuffer with the contents of this message.
2900
+ */
2901
+ toArrayBuffer(): ArrayBuffer;
2902
+ /**
2903
+ * Like `toArrayBuffer()`, but also applies the packing algorithm to the output. This is typically what you want to
2904
+ * use if you're sending the message over a network link or other slow I/O interface where size matters.
2905
+ *
2906
+ * @returns A packed message.
2907
+ */
2908
+ toPackedArrayBuffer(): ArrayBuffer;
2909
+ addCap(client: Client | null): number;
2910
+ toString(): string;
2911
+ }
2912
+ declare function allocateSegment(byteLength: number, m: Message): Segment;
2913
+ declare function dump(m: Message): string;
2914
+ declare function getRoot<T extends Struct>(RootStruct: StructCtor<T>, m: Message): T;
2915
+ declare function getSegment(id: number, m: Message): Segment;
2916
+ declare function initRoot<T extends Struct>(RootStruct: StructCtor<T>, m: Message): T;
2917
+ /**
2918
+ * Read a pointer in raw form (a packed message with framing headers). Does not
2919
+ * care or attempt to validate the input beyond parsing the message
2920
+ * segments.
2921
+ *
2922
+ * This is typically used by the compiler to load default values, but can be
2923
+ * useful to work with messages with an unknown schema.
2924
+ *
2925
+ * @param data The raw data to read.
2926
+ * @returns A root pointer.
2927
+ */
2928
+ declare function readRawPointer(data: ArrayBuffer): Pointer;
2929
+ declare function toArrayBuffer(m: Message): ArrayBuffer;
2930
+ declare function toPackedArrayBuffer(m: Message): ArrayBuffer;
2931
+ //#endregion
2932
+ //#region ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=503a440bd2bef41c0cb22819bc4ced5a7f04993fb999f0d944e284220f14916b_typescript@6.0.3/node_modules/capnp-es/dist/shared/capnp-es.BHkXHvyK.d.mts
2933
+ /**
2934
+ * A generic blob of bytes. Can be converted to a DataView or Uint8Array to access its contents using `toDataView()` and
2935
+ * `toUint8Array()`. Use `copyBuffer()` to copy an entire buffer at once.
2936
+ */
2937
+ declare class Data extends List<number> {
2938
+ static fromPointer(pointer: Pointer): Data;
2939
+ protected static _fromPointerUnchecked(pointer: Pointer): Data;
2940
+ /**
2941
+ * Copy the contents of `src` into this Data pointer. If `src` is smaller than the length of this pointer then the
2942
+ * remaining bytes will be zeroed out. Extra bytes in `src` are ignored.
2943
+ *
2944
+ * @param src The source buffer.
2945
+ */
2946
+ copyBuffer(src: ArrayBuffer | ArrayBufferView): void;
2947
+ /**
2948
+ * Read a byte from the specified offset.
2949
+ *
2950
+ * @param byteOffset The byte offset to read.
2951
+ * @returns The byte value.
2952
+ */
2953
+ get(byteOffset: number): number;
2954
+ /**
2955
+ * Write a byte at the specified offset.
2956
+ *
2957
+ * @param byteOffset The byte offset to set.
2958
+ * @param value The byte value to set.
2959
+ */
2960
+ set(byteOffset: number, value: number): void;
2961
+ /**
2962
+ * Creates a **copy** of the underlying buffer data and returns it as an ArrayBuffer.
2963
+ *
2964
+ * To obtain a reference to the underlying buffer instead, use `toUint8Array()` or `toDataView()`.
2965
+ *
2966
+ * @returns A copy of this data buffer.
2967
+ */
2968
+ toArrayBuffer(): ArrayBuffer;
2969
+ /**
2970
+ * Convert this Data pointer to a DataView representing the pointer's contents.
2971
+ *
2972
+ * WARNING: The DataView references memory from a message segment, so do not venture outside the bounds of the
2973
+ * DataView or else BAD THINGS.
2974
+ *
2975
+ * @returns A live reference to the underlying buffer.
2976
+ */
2977
+ toDataView(): DataView;
2978
+ [Symbol.toStringTag](): string;
2979
+ /**
2980
+ * Convert this Data pointer to a Uint8Array representing the pointer's contents.
2981
+ *
2982
+ * WARNING: The Uint8Array references memory from a message segment, so do not venture outside the bounds of the
2983
+ * Uint8Array or else BAD THINGS.
2984
+ *
2985
+ * @returns A live reference to the underlying buffer.
2986
+ */
2987
+ toUint8Array(): Uint8Array;
2988
+ }
2989
+ //#endregion
2990
+ export { type Transport as A, type placeParams as B, type PointerType as C, ServerMethod as D, type ServerCall as E, type clientFromResolution as F, copyCall as I, type isDataCall as L, _Pointer as M, _StructCtor as N, Struct as O, answerPipelineClient as P, isFuncCall as R, PointerCtor as S, type Server as T, readRawPointer as V, type Method as _, Client as a, type PipelineOp as b, Deferred as c, Interface as d, type List as f, type Message$1 as g, Message as h, type Call as i, _ListCtor as j, StructCtor as k, FuncCall as l, type ListElementSize as m, type Answer as n, type Conn as o, ListCtor as p, BaseCall as r, DataCall as s, Data as t, ImportEntry as u, ObjectSize as v, Segment as w, type Pointer as x, Orphan as y, type isSameClient as z };
2991
+ //# sourceMappingURL=capnp-es.BHkXHvyK-CQWXOqvU.d.cts.map