@nomux-sh/extension 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,183 @@
1
+ import { CallError, RunError, describe } from "./error.js";
2
+ import { FrameError, FrameReader } from "./frame.js";
3
+ import { answerHello } from "./handshake.js";
4
+ import { Host } from "./host.js";
5
+ import { Outbound } from "./outbound.js";
6
+ import { PendingCalls } from "./pending-calls.js";
7
+ /**
8
+ * One connection to the host, from `Hello` to the end.
9
+ *
10
+ * The connection reads the frames as they arrive. It answers health
11
+ * requests, records cancellations and gives the responses of host services
12
+ * to the calls that wait for them at once. The work of the other requests
13
+ * runs in a queue, one request at a time, in the sequence of arrival.
14
+ */
15
+ export class Connection {
16
+ input;
17
+ identity;
18
+ answer;
19
+ reader = new FrameReader();
20
+ outbound;
21
+ pending = new PendingCalls();
22
+ cancellations = new Map();
23
+ queue = [];
24
+ host;
25
+ isWorking = false;
26
+ isStopped = false;
27
+ resolve = () => { };
28
+ reject = () => { };
29
+ onData = (chunk) => this.receive(chunk);
30
+ onEnd = () => this.receiveEnd();
31
+ onError = (error) => this.stop(new RunError("frame", `the stream failed: ${error.message}`, { cause: error }));
32
+ constructor(input, output, identity, answer) {
33
+ this.input = input;
34
+ this.identity = identity;
35
+ this.answer = answer;
36
+ this.outbound = new Outbound(output);
37
+ output.on("error", this.onError);
38
+ }
39
+ /** Serves the host until a shutdown request or a failure. */
40
+ run() {
41
+ const done = new Promise((resolve, reject) => {
42
+ this.resolve = resolve;
43
+ this.reject = reject;
44
+ });
45
+ this.input.on("data", this.onData);
46
+ this.input.on("end", this.onEnd);
47
+ this.input.on("error", this.onError);
48
+ return done;
49
+ }
50
+ receive(chunk) {
51
+ try {
52
+ for (const envelope of this.reader.read(chunk)) {
53
+ if (this.isStopped) {
54
+ return;
55
+ }
56
+ this.route(envelope);
57
+ }
58
+ }
59
+ catch (error) {
60
+ if (!(error instanceof FrameError)) {
61
+ throw error;
62
+ }
63
+ this.stop(new RunError("frame", error.message, { cause: error }));
64
+ }
65
+ }
66
+ receiveEnd() {
67
+ const error = this.reader.isBetweenFrames
68
+ ? new RunError("disconnected", "the host closed the stream and did not send a shutdown request")
69
+ : new RunError("frame", "the stream ended in the middle of a frame");
70
+ this.stop(error);
71
+ }
72
+ route(envelope) {
73
+ if (this.host === undefined) {
74
+ this.handshake(envelope);
75
+ return;
76
+ }
77
+ switch (envelope.kind?.$case) {
78
+ case "request":
79
+ this.routeRequest(envelope.kind.value);
80
+ break;
81
+ case "response":
82
+ this.pending.resolve(envelope.kind.value);
83
+ break;
84
+ case "cancel":
85
+ this.cancellations.get(envelope.kind.value.id)?.abort();
86
+ break;
87
+ // The host sends no events. A kind that this version does not know
88
+ // comes from a newer host and is not an error.
89
+ default:
90
+ break;
91
+ }
92
+ }
93
+ handshake(envelope) {
94
+ const { response, outcome } = answerHello(envelope, this.identity);
95
+ if (response !== undefined) {
96
+ this.outbound.send({ $case: "response", value: response });
97
+ }
98
+ if (outcome instanceof RunError) {
99
+ this.stop(outcome);
100
+ return;
101
+ }
102
+ this.host = new Host(this.outbound, this.pending, outcome);
103
+ }
104
+ routeRequest(request) {
105
+ const { id, body } = request;
106
+ switch (body?.$case) {
107
+ case "health":
108
+ this.respond(id, { $case: "health", value: {} });
109
+ return;
110
+ case "hello":
111
+ this.respond(id, failure("the handshake is already complete"));
112
+ return;
113
+ case "initialize":
114
+ case "shutdown":
115
+ this.enqueue(id, { $case: body.$case });
116
+ return;
117
+ case "call":
118
+ this.enqueue(id, body);
119
+ return;
120
+ default:
121
+ this.respond(id, failure("the extension does not know this request"));
122
+ }
123
+ }
124
+ enqueue(id, work) {
125
+ const controller = new AbortController();
126
+ this.cancellations.set(id, controller);
127
+ this.queue.push({ id, work, controller });
128
+ void this.work();
129
+ }
130
+ async work() {
131
+ if (this.isWorking || this.host === undefined) {
132
+ return;
133
+ }
134
+ this.isWorking = true;
135
+ const host = this.host;
136
+ let next = this.queue.shift();
137
+ while (next !== undefined && !this.isStopped) {
138
+ const result = await this.answer(next.work, { host, signal: next.controller.signal });
139
+ this.cancellations.delete(next.id);
140
+ if (this.isStopped) {
141
+ break;
142
+ }
143
+ this.respond(next.id, result);
144
+ if (next.work.$case === "shutdown") {
145
+ this.stop(undefined);
146
+ break;
147
+ }
148
+ next = this.queue.shift();
149
+ }
150
+ this.isWorking = false;
151
+ }
152
+ respond(id, result) {
153
+ try {
154
+ this.outbound.send({ $case: "response", value: { id, result } });
155
+ }
156
+ catch (error) {
157
+ // A result that is too large is the failure of one call. The
158
+ // connection stays open.
159
+ if (!(error instanceof FrameError) || !error.isTooLarge) {
160
+ throw error;
161
+ }
162
+ this.outbound.send({ $case: "response", value: { id, result: failure(describe(error)) } });
163
+ }
164
+ }
165
+ /** Stops the connection. `error` is `undefined` after a shutdown request. */
166
+ stop(error) {
167
+ if (this.isStopped) {
168
+ return;
169
+ }
170
+ this.isStopped = true;
171
+ this.input.off("data", this.onData);
172
+ this.input.off("end", this.onEnd);
173
+ this.input.destroy();
174
+ this.pending.close();
175
+ for (const controller of this.cancellations.values()) {
176
+ controller.abort();
177
+ }
178
+ this.outbound.flush().then(() => (error === undefined ? this.resolve() : this.reject(error)), (cause) => this.reject(new RunError("frame", `the stream failed: ${describe(cause)}`, { cause })));
179
+ }
180
+ }
181
+ function failure(message) {
182
+ return { $case: "error", value: CallError.failed(message).toWire() };
183
+ }
@@ -0,0 +1,41 @@
1
+ import { ErrorCode } from "./generated/nomux/extension/v1/envelope.js";
2
+ import type { Error as WireError } from "./generated/nomux/extension/v1/envelope.js";
3
+ export { ErrorCode };
4
+ /**
5
+ * The failure of one call.
6
+ *
7
+ * A method of an extension throws it, and the host gets the code and the
8
+ * message. A call of a host service throws it when the host refuses or fails
9
+ * the call.
10
+ */
11
+ export declare class CallError extends Error {
12
+ /** The reason for the failure. */
13
+ readonly code: ErrorCode;
14
+ /** Makes an error with a code and a message in English for the user. */
15
+ constructor(code: ErrorCode, message: string);
16
+ /** Makes an error with the code {@link ErrorCode.FAILED}. */
17
+ static failed(message: string): CallError;
18
+ /**
19
+ * Makes the error that a method throws when it stops because its
20
+ * `signal` is aborted.
21
+ */
22
+ static cancelled(): CallError;
23
+ /** Makes the error of a wire message. A code that is not known fails. */
24
+ static fromWire(error: WireError): CallError;
25
+ /** The wire message of the error. */
26
+ toWire(): WireError;
27
+ }
28
+ /** The reason why {@link RunError} stopped the extension. */
29
+ export type RunErrorKind = "frame" | "no-hello" | "incompatible-api" | "disconnected";
30
+ /**
31
+ * The reason why `Extension.run` stopped before the host sent a shutdown
32
+ * request.
33
+ */
34
+ export declare class RunError extends Error {
35
+ /** The kind of the failure. */
36
+ readonly kind: RunErrorKind;
37
+ /** Makes an error of a kind with a message. */
38
+ constructor(kind: RunErrorKind, message: string, options?: ErrorOptions);
39
+ }
40
+ /** The message of a thrown value. */
41
+ export declare function describe(error: unknown): string;
package/dist/error.js ADDED
@@ -0,0 +1,61 @@
1
+ import { ErrorCode } from "./generated/nomux/extension/v1/envelope.js";
2
+ export { ErrorCode };
3
+ /**
4
+ * The failure of one call.
5
+ *
6
+ * A method of an extension throws it, and the host gets the code and the
7
+ * message. A call of a host service throws it when the host refuses or fails
8
+ * the call.
9
+ */
10
+ export class CallError extends Error {
11
+ /** The reason for the failure. */
12
+ code;
13
+ /** Makes an error with a code and a message in English for the user. */
14
+ constructor(code, message) {
15
+ super(message);
16
+ this.name = "CallError";
17
+ this.code = code;
18
+ }
19
+ /** Makes an error with the code {@link ErrorCode.FAILED}. */
20
+ static failed(message) {
21
+ return new CallError(ErrorCode.FAILED, message);
22
+ }
23
+ /**
24
+ * Makes the error that a method throws when it stops because its
25
+ * `signal` is aborted.
26
+ */
27
+ static cancelled() {
28
+ return new CallError(ErrorCode.CANCELLED, "the call was cancelled");
29
+ }
30
+ /** Makes the error of a wire message. A code that is not known fails. */
31
+ static fromWire(error) {
32
+ return new CallError(knownCode(error.code), error.message);
33
+ }
34
+ /** The wire message of the error. */
35
+ toWire() {
36
+ return { code: this.code, message: this.message };
37
+ }
38
+ }
39
+ /** A code that is not set or not known is a failure with no other reason. */
40
+ function knownCode(code) {
41
+ const isKnown = Number.isInteger(code) && code > ErrorCode.UNSPECIFIED && code <= ErrorCode.CANCELLED;
42
+ return isKnown ? code : ErrorCode.FAILED;
43
+ }
44
+ /**
45
+ * The reason why `Extension.run` stopped before the host sent a shutdown
46
+ * request.
47
+ */
48
+ export class RunError extends Error {
49
+ /** The kind of the failure. */
50
+ kind;
51
+ /** Makes an error of a kind with a message. */
52
+ constructor(kind, message, options) {
53
+ super(message, options);
54
+ this.name = "RunError";
55
+ this.kind = kind;
56
+ }
57
+ }
58
+ /** The message of a thrown value. */
59
+ export function describe(error) {
60
+ return error instanceof Error ? error.message : String(error);
61
+ }
@@ -0,0 +1,75 @@
1
+ import type { Readable, Writable } from "node:stream";
2
+ import type { Call } from "./call.js";
3
+ import type { MethodCodecs } from "./codec.js";
4
+ import type { Host } from "./host.js";
5
+ /**
6
+ * A method that the host can call. It gets the decoded argument and the
7
+ * context of the call, and returns the result. It throws a
8
+ * {@link CallError} to fail the call with a code.
9
+ */
10
+ export type Method<Input, Output> = (input: Input, call: Call) => Output | Promise<Output>;
11
+ type Initialize = (host: Host) => void | Promise<void>;
12
+ /**
13
+ * The daemon part of an extension.
14
+ *
15
+ * Add the methods, then call {@link Extension.run}:
16
+ *
17
+ * ```ts
18
+ * await new Extension("nomux.echo", "0.1.0")
19
+ * .method("echo", { input: Text, output: Text }, (text) => text)
20
+ * .run();
21
+ * ```
22
+ */
23
+ export declare class Extension {
24
+ private readonly id;
25
+ private readonly version;
26
+ private readonly methods;
27
+ private initializer;
28
+ private isInitialized;
29
+ /**
30
+ * Starts the definition of an extension.
31
+ *
32
+ * `id` and `version` are the values of `id` and `version` in
33
+ * `extension.toml`. The host stops an extension whose `id` is different
34
+ * from its manifest.
35
+ */
36
+ constructor(id: string, version: string);
37
+ /**
38
+ * Adds a method that the host can call.
39
+ *
40
+ * If the payload of a call is not a valid argument, the host gets
41
+ * {@link ErrorCode.INVALID_ARGUMENT} and the method does not run.
42
+ *
43
+ * The methods run one at a time, in the sequence in which the calls
44
+ * arrive. While a method waits, the extension answers health requests and
45
+ * records cancellations.
46
+ *
47
+ * Throws if the extension already has a method with this name.
48
+ */
49
+ method<Input, Output>(name: string, codecs: MethodCodecs<Input, Output>, method: Method<Input, Output>): this;
50
+ /**
51
+ * Sets a function that runs one time, after the handshake and before the
52
+ * first call. If the function throws, the host gets the error and no
53
+ * method runs.
54
+ */
55
+ onInitialize(initialize: Initialize): this;
56
+ /**
57
+ * Serves the host on the standard input and the standard output of the
58
+ * process, until the host sends a shutdown request. Then the promise
59
+ * resolves and the process can exit. The promise rejects with a
60
+ * {@link RunError} when the extension must stop for a different reason.
61
+ *
62
+ * The standard output carries the protocol. Write logs to the standard
63
+ * error.
64
+ */
65
+ run(): Promise<void>;
66
+ /**
67
+ * Serves a host on the given streams, until the host sends a shutdown
68
+ * request. Use it to test an extension in the process of the test.
69
+ */
70
+ serve(input: Readable, output: Writable): Promise<void>;
71
+ private answer;
72
+ private initialize;
73
+ private call;
74
+ }
75
+ export {};
@@ -0,0 +1,132 @@
1
+ import process from "node:process";
2
+ import { Connection } from "./connection.js";
3
+ import { CallError, ErrorCode } from "./error.js";
4
+ import { decode } from "./host.js";
5
+ /**
6
+ * The daemon part of an extension.
7
+ *
8
+ * Add the methods, then call {@link Extension.run}:
9
+ *
10
+ * ```ts
11
+ * await new Extension("nomux.echo", "0.1.0")
12
+ * .method("echo", { input: Text, output: Text }, (text) => text)
13
+ * .run();
14
+ * ```
15
+ */
16
+ export class Extension {
17
+ id;
18
+ version;
19
+ methods = new Map();
20
+ initializer;
21
+ isInitialized = false;
22
+ /**
23
+ * Starts the definition of an extension.
24
+ *
25
+ * `id` and `version` are the values of `id` and `version` in
26
+ * `extension.toml`. The host stops an extension whose `id` is different
27
+ * from its manifest.
28
+ */
29
+ constructor(id, version) {
30
+ this.id = id;
31
+ this.version = version;
32
+ }
33
+ /**
34
+ * Adds a method that the host can call.
35
+ *
36
+ * If the payload of a call is not a valid argument, the host gets
37
+ * {@link ErrorCode.INVALID_ARGUMENT} and the method does not run.
38
+ *
39
+ * The methods run one at a time, in the sequence in which the calls
40
+ * arrive. While a method waits, the extension answers health requests and
41
+ * records cancellations.
42
+ *
43
+ * Throws if the extension already has a method with this name.
44
+ */
45
+ method(name, codecs, method) {
46
+ if (this.methods.has(name)) {
47
+ throw new Error(`the method \`${name}\` is added twice`);
48
+ }
49
+ this.methods.set(name, async (payload, call) => {
50
+ const input = decode(codecs.input, payload, "the payload");
51
+ return codecs.output.encode(await method(input, call));
52
+ });
53
+ return this;
54
+ }
55
+ /**
56
+ * Sets a function that runs one time, after the handshake and before the
57
+ * first call. If the function throws, the host gets the error and no
58
+ * method runs.
59
+ */
60
+ onInitialize(initialize) {
61
+ this.initializer = initialize;
62
+ return this;
63
+ }
64
+ /**
65
+ * Serves the host on the standard input and the standard output of the
66
+ * process, until the host sends a shutdown request. Then the promise
67
+ * resolves and the process can exit. The promise rejects with a
68
+ * {@link RunError} when the extension must stop for a different reason.
69
+ *
70
+ * The standard output carries the protocol. Write logs to the standard
71
+ * error.
72
+ */
73
+ run() {
74
+ return this.serve(process.stdin, process.stdout);
75
+ }
76
+ /**
77
+ * Serves a host on the given streams, until the host sends a shutdown
78
+ * request. Use it to test an extension in the process of the test.
79
+ */
80
+ serve(input, output) {
81
+ const identity = { id: this.id, version: this.version };
82
+ return new Connection(input, output, identity, (work, call) => this.answer(work, call)).run();
83
+ }
84
+ async answer(work, call) {
85
+ try {
86
+ switch (work.$case) {
87
+ case "initialize":
88
+ await this.initialize(call.host);
89
+ return { $case: "initialize", value: {} };
90
+ case "shutdown":
91
+ return { $case: "shutdown", value: {} };
92
+ case "call":
93
+ return { $case: "call", value: { payload: await this.call(work.value, call) } };
94
+ }
95
+ }
96
+ catch (error) {
97
+ return { $case: "error", value: callError(error, call.signal).toWire() };
98
+ }
99
+ }
100
+ async initialize(host) {
101
+ if (this.isInitialized) {
102
+ throw CallError.failed("the extension is already initialized");
103
+ }
104
+ const initialize = this.initializer;
105
+ this.initializer = undefined;
106
+ await initialize?.(host);
107
+ this.isInitialized = true;
108
+ }
109
+ async call(request, call) {
110
+ if (!this.isInitialized) {
111
+ throw CallError.failed("the extension is not initialized");
112
+ }
113
+ if (call.signal.aborted) {
114
+ throw CallError.cancelled();
115
+ }
116
+ const method = this.methods.get(request.method);
117
+ if (method === undefined) {
118
+ throw new CallError(ErrorCode.NOT_FOUND, `the extension has no method \`${request.method}\``);
119
+ }
120
+ return method(request.payload, call);
121
+ }
122
+ }
123
+ /** The error that the host gets for a value that a method threw. */
124
+ function callError(error, signal) {
125
+ if (error instanceof CallError) {
126
+ return error;
127
+ }
128
+ if (signal.aborted) {
129
+ return CallError.cancelled();
130
+ }
131
+ return CallError.failed(error instanceof Error ? error.message : String(error));
132
+ }
@@ -0,0 +1,32 @@
1
+ import { Envelope } from "./generated/nomux/extension/v1/envelope.js";
2
+ /**
3
+ * The largest number of bytes of one encoded {@link Envelope}. A peer that
4
+ * reads a larger length stops: it cannot find the start of the subsequent
5
+ * frame.
6
+ */
7
+ export declare const MAX_ENVELOPE_LENGTH: number;
8
+ /** The reason why a frame was not read or written. */
9
+ export declare class FrameError extends Error {
10
+ /** `true` if the envelope is larger than {@link MAX_ENVELOPE_LENGTH}. */
11
+ readonly isTooLarge: boolean;
12
+ constructor(message: string, isTooLarge?: boolean, options?: ErrorOptions);
13
+ }
14
+ /** Encodes one envelope as a frame: the varint length, then the envelope. */
15
+ export declare function encodeFrame(envelope: Envelope): Uint8Array;
16
+ /**
17
+ * Takes the bytes of a stream in chunks of any size and gives the envelopes
18
+ * in them.
19
+ */
20
+ export declare class FrameReader {
21
+ private length;
22
+ private lengthBytes;
23
+ private body;
24
+ private filled;
25
+ /** `true` if the bytes so far end between two frames. */
26
+ get isBetweenFrames(): boolean;
27
+ /** Reads a chunk. Throws {@link FrameError} if a frame is not valid. */
28
+ read(chunk: Uint8Array): Generator<Envelope>;
29
+ private readLength;
30
+ private startBody;
31
+ private takeEnvelope;
32
+ }
package/dist/frame.js ADDED
@@ -0,0 +1,99 @@
1
+ import { BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ import { describe } from "./error.js";
3
+ import { Envelope } from "./generated/nomux/extension/v1/envelope.js";
4
+ /**
5
+ * The largest number of bytes of one encoded {@link Envelope}. A peer that
6
+ * reads a larger length stops: it cannot find the start of the subsequent
7
+ * frame.
8
+ */
9
+ export const MAX_ENVELOPE_LENGTH = 4 * 1024 * 1024;
10
+ /** The largest number of bytes of the length of a frame. */
11
+ const MAX_LENGTH_BYTES = 5;
12
+ /** The reason why a frame was not read or written. */
13
+ export class FrameError extends Error {
14
+ /** `true` if the envelope is larger than {@link MAX_ENVELOPE_LENGTH}. */
15
+ isTooLarge;
16
+ constructor(message, isTooLarge = false, options) {
17
+ super(message, options);
18
+ this.name = "FrameError";
19
+ this.isTooLarge = isTooLarge;
20
+ }
21
+ }
22
+ /** Encodes one envelope as a frame: the varint length, then the envelope. */
23
+ export function encodeFrame(envelope) {
24
+ const body = Envelope.encode(envelope).finish();
25
+ if (body.length > MAX_ENVELOPE_LENGTH) {
26
+ throw new FrameError(`the envelope has ${body.length} bytes, but the limit is ${MAX_ENVELOPE_LENGTH} bytes`, true);
27
+ }
28
+ return new BinaryWriter().bytes(body).finish();
29
+ }
30
+ /**
31
+ * Takes the bytes of a stream in chunks of any size and gives the envelopes
32
+ * in them.
33
+ */
34
+ export class FrameReader {
35
+ length = 0;
36
+ lengthBytes = 0;
37
+ body;
38
+ filled = 0;
39
+ /** `true` if the bytes so far end between two frames. */
40
+ get isBetweenFrames() {
41
+ return this.lengthBytes === 0 && this.body === undefined;
42
+ }
43
+ /** Reads a chunk. Throws {@link FrameError} if a frame is not valid. */
44
+ *read(chunk) {
45
+ let offset = 0;
46
+ while (offset < chunk.length) {
47
+ if (this.body === undefined) {
48
+ offset = this.readLength(chunk, offset);
49
+ if (this.body === undefined) {
50
+ continue;
51
+ }
52
+ }
53
+ const count = Math.min(this.body.length - this.filled, chunk.length - offset);
54
+ this.body.set(chunk.subarray(offset, offset + count), this.filled);
55
+ this.filled += count;
56
+ offset += count;
57
+ if (this.filled === this.body.length) {
58
+ yield this.takeEnvelope(this.body);
59
+ }
60
+ }
61
+ }
62
+ readLength(chunk, start) {
63
+ let offset = start;
64
+ while (offset < chunk.length) {
65
+ const byte = chunk[offset] ?? 0;
66
+ offset += 1;
67
+ this.length += (byte & 0x7f) * 2 ** (7 * this.lengthBytes);
68
+ this.lengthBytes += 1;
69
+ if ((byte & 0x80) === 0) {
70
+ this.startBody();
71
+ return offset;
72
+ }
73
+ if (this.lengthBytes === MAX_LENGTH_BYTES) {
74
+ throw new FrameError("the length of the frame is not valid");
75
+ }
76
+ }
77
+ return offset;
78
+ }
79
+ startBody() {
80
+ if (this.length > MAX_ENVELOPE_LENGTH) {
81
+ throw new FrameError(`the envelope has ${this.length} bytes, but the limit is ${MAX_ENVELOPE_LENGTH} bytes`, true);
82
+ }
83
+ this.body = new Uint8Array(this.length);
84
+ this.filled = 0;
85
+ }
86
+ takeEnvelope(body) {
87
+ this.length = 0;
88
+ this.lengthBytes = 0;
89
+ this.body = undefined;
90
+ try {
91
+ return Envelope.decode(body);
92
+ }
93
+ catch (error) {
94
+ throw new FrameError(`the frame is not an envelope: ${describe(error)}`, false, {
95
+ cause: error,
96
+ });
97
+ }
98
+ }
99
+ }
@@ -0,0 +1,29 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ /** Calls one method. */
3
+ export interface CallRequest {
4
+ /**
5
+ * The name of the method.
6
+ *
7
+ * From the host: a method that the extension supplies, for example `echo`.
8
+ * From the extension: a method of a host service in the form
9
+ * `<service>.<method>`, for example `sessions.list`.
10
+ */
11
+ method: string;
12
+ /**
13
+ * The argument of the method. The method specifies the encoding. The Rust
14
+ * SDK uses an encoded protobuf message.
15
+ */
16
+ payload: Uint8Array;
17
+ }
18
+ /** The reply to `CallRequest`. */
19
+ export interface CallResponse {
20
+ /** The result of the method. The method specifies the encoding. */
21
+ payload: Uint8Array;
22
+ }
23
+ export declare const CallRequest: MessageFns<CallRequest>;
24
+ export declare const CallResponse: MessageFns<CallResponse>;
25
+ interface MessageFns<T> {
26
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
27
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
28
+ }
29
+ export {};