@query-farm/vgi-rpc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/LICENSE.md +191 -0
  2. package/README.md +332 -0
  3. package/dist/client/connect.d.ts +10 -0
  4. package/dist/client/connect.d.ts.map +1 -0
  5. package/dist/client/index.d.ts +6 -0
  6. package/dist/client/index.d.ts.map +1 -0
  7. package/dist/client/introspect.d.ts +30 -0
  8. package/dist/client/introspect.d.ts.map +1 -0
  9. package/dist/client/ipc.d.ts +34 -0
  10. package/dist/client/ipc.d.ts.map +1 -0
  11. package/dist/client/pipe.d.ts +63 -0
  12. package/dist/client/pipe.d.ts.map +1 -0
  13. package/dist/client/stream.d.ts +52 -0
  14. package/dist/client/stream.d.ts.map +1 -0
  15. package/dist/client/types.d.ts +25 -0
  16. package/dist/client/types.d.ts.map +1 -0
  17. package/dist/constants.d.ts +15 -0
  18. package/dist/constants.d.ts.map +1 -0
  19. package/dist/dispatch/describe.d.ts +14 -0
  20. package/dist/dispatch/describe.d.ts.map +1 -0
  21. package/dist/dispatch/stream.d.ts +20 -0
  22. package/dist/dispatch/stream.d.ts.map +1 -0
  23. package/dist/dispatch/unary.d.ts +9 -0
  24. package/dist/dispatch/unary.d.ts.map +1 -0
  25. package/dist/errors.d.ts +12 -0
  26. package/dist/errors.d.ts.map +1 -0
  27. package/dist/http/common.d.ts +16 -0
  28. package/dist/http/common.d.ts.map +1 -0
  29. package/dist/http/dispatch.d.ts +18 -0
  30. package/dist/http/dispatch.d.ts.map +1 -0
  31. package/dist/http/handler.d.ts +16 -0
  32. package/dist/http/handler.d.ts.map +1 -0
  33. package/dist/http/index.d.ts +4 -0
  34. package/dist/http/index.d.ts.map +1 -0
  35. package/dist/http/token.d.ts +24 -0
  36. package/dist/http/token.d.ts.map +1 -0
  37. package/dist/http/types.d.ts +30 -0
  38. package/dist/http/types.d.ts.map +1 -0
  39. package/dist/index.d.ts +9 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +2493 -0
  42. package/dist/index.js.map +34 -0
  43. package/dist/protocol.d.ts +62 -0
  44. package/dist/protocol.d.ts.map +1 -0
  45. package/dist/schema.d.ts +38 -0
  46. package/dist/schema.d.ts.map +1 -0
  47. package/dist/server.d.ts +19 -0
  48. package/dist/server.d.ts.map +1 -0
  49. package/dist/types.d.ts +71 -0
  50. package/dist/types.d.ts.map +1 -0
  51. package/dist/util/schema.d.ts +20 -0
  52. package/dist/util/schema.d.ts.map +1 -0
  53. package/dist/util/zstd.d.ts +5 -0
  54. package/dist/util/zstd.d.ts.map +1 -0
  55. package/dist/wire/reader.d.ts +40 -0
  56. package/dist/wire/reader.d.ts.map +1 -0
  57. package/dist/wire/request.d.ts +15 -0
  58. package/dist/wire/request.d.ts.map +1 -0
  59. package/dist/wire/response.d.ts +25 -0
  60. package/dist/wire/response.d.ts.map +1 -0
  61. package/dist/wire/writer.d.ts +59 -0
  62. package/dist/wire/writer.d.ts.map +1 -0
  63. package/package.json +32 -0
  64. package/src/client/connect.ts +310 -0
  65. package/src/client/index.ts +14 -0
  66. package/src/client/introspect.ts +138 -0
  67. package/src/client/ipc.ts +225 -0
  68. package/src/client/pipe.ts +661 -0
  69. package/src/client/stream.ts +297 -0
  70. package/src/client/types.ts +31 -0
  71. package/src/constants.ts +22 -0
  72. package/src/dispatch/describe.ts +155 -0
  73. package/src/dispatch/stream.ts +151 -0
  74. package/src/dispatch/unary.ts +35 -0
  75. package/src/errors.ts +22 -0
  76. package/src/http/common.ts +89 -0
  77. package/src/http/dispatch.ts +340 -0
  78. package/src/http/handler.ts +247 -0
  79. package/src/http/index.ts +6 -0
  80. package/src/http/token.ts +149 -0
  81. package/src/http/types.ts +49 -0
  82. package/src/index.ts +52 -0
  83. package/src/protocol.ts +144 -0
  84. package/src/schema.ts +114 -0
  85. package/src/server.ts +159 -0
  86. package/src/types.ts +162 -0
  87. package/src/util/schema.ts +31 -0
  88. package/src/util/zstd.ts +49 -0
  89. package/src/wire/reader.ts +113 -0
  90. package/src/wire/request.ts +98 -0
  91. package/src/wire/response.ts +181 -0
  92. package/src/wire/writer.ts +137 -0
@@ -0,0 +1,63 @@
1
+ import { Schema } from "apache-arrow";
2
+ import { IpcStreamReader } from "../wire/reader.js";
3
+ import type { LogMessage, PipeConnectOptions, SubprocessConnectOptions, StreamSession } from "./types.js";
4
+ import type { RpcClient } from "./connect.js";
5
+ interface PipeWritable {
6
+ write(data: Uint8Array): void;
7
+ flush?(): void;
8
+ end(): void;
9
+ }
10
+ type WriteFn = (bytes: Uint8Array) => void;
11
+ export declare class PipeStreamSession implements StreamSession {
12
+ private _reader;
13
+ private _writeFn;
14
+ private _onLog?;
15
+ private _header;
16
+ private _inputWriter;
17
+ private _inputSchema;
18
+ private _outputStreamOpened;
19
+ private _closed;
20
+ private _outputSchema;
21
+ private _releaseBusy;
22
+ private _setDrainPromise;
23
+ constructor(opts: {
24
+ reader: IpcStreamReader;
25
+ writeFn: WriteFn;
26
+ onLog?: (msg: LogMessage) => void;
27
+ header: Record<string, any> | null;
28
+ outputSchema: Schema;
29
+ releaseBusy: () => void;
30
+ setDrainPromise: (p: Promise<void>) => void;
31
+ });
32
+ get header(): Record<string, any> | null;
33
+ /**
34
+ * Read output batches from the server until a data batch is found.
35
+ * Dispatches log/error batches along the way.
36
+ * Returns null when server closes output stream (EOS).
37
+ */
38
+ private _readOutputBatch;
39
+ /**
40
+ * Ensure the server's output stream is opened for reading.
41
+ * Must be called AFTER sending the first input batch, because
42
+ * the server's output schema may not be flushed until it processes
43
+ * the first input and writes the first output batch.
44
+ */
45
+ private _ensureOutputStream;
46
+ /**
47
+ * Send an exchange request and return the data rows.
48
+ */
49
+ exchange(input: Record<string, any>[]): Promise<Record<string, any>[]>;
50
+ /**
51
+ * Clean up after an error: close input, drain output, release busy.
52
+ */
53
+ private _cleanup;
54
+ /**
55
+ * Iterate over producer stream batches (lockstep).
56
+ */
57
+ [Symbol.asyncIterator](): AsyncIterableIterator<Record<string, any>[]>;
58
+ close(): void;
59
+ }
60
+ export declare function pipeConnect(readable: ReadableStream<Uint8Array>, writable: PipeWritable, options?: PipeConnectOptions): RpcClient;
61
+ export declare function subprocessConnect(cmd: string[], options?: SubprocessConnectOptions): RpcClient;
62
+ export {};
63
+ //# sourceMappingURL=pipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../src/client/pipe.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,MAAM,EAKP,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAYpD,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAO9C,UAAU,YAAY;IACpB,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,IAAI,IAAI,CAAC;IACf,GAAG,IAAI,IAAI,CAAC;CACb;AAED,KAAK,OAAO,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;AA6C3C,qBAAa,iBAAkB,YAAW,aAAa;IACrD,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,MAAM,CAAC,CAA4B;IAC3C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,YAAY,CAAsC;IAC1D,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,gBAAgB,CAA6B;gBAEzC,IAAI,EAAE;QAChB,MAAM,EAAE,eAAe,CAAC;QACxB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;QAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;QACnC,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,IAAI,CAAC;QACxB,eAAe,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;KAC7C;IAUD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAEvC;IAED;;;;OAIG;YACW,gBAAgB;IAiB9B;;;;;OAKG;YACW,mBAAmB;IASjC;;OAEG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAmG5E;;OAEG;YACW,QAAQ;IAiBtB;;OAEG;IACI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAqD7E,KAAK,IAAI,IAAI;CAoCd;AAMD,wBAAgB,WAAW,CACzB,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,EACpC,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,SAAS,CAkOX;AAMD,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EAAE,EACb,OAAO,CAAC,EAAE,wBAAwB,GACjC,SAAS,CAuCX"}
@@ -0,0 +1,52 @@
1
+ import { RecordBatch, Schema } from "apache-arrow";
2
+ import type { LogMessage, StreamSession } from "./types.js";
3
+ type CompressFn = (data: Uint8Array, level: number) => Uint8Array;
4
+ type DecompressFn = (data: Uint8Array) => Uint8Array;
5
+ export declare class HttpStreamSession implements StreamSession {
6
+ private _baseUrl;
7
+ private _prefix;
8
+ private _method;
9
+ private _stateToken;
10
+ private _outputSchema;
11
+ private _inputSchema?;
12
+ private _onLog?;
13
+ private _pendingBatches;
14
+ private _finished;
15
+ private _header;
16
+ private _compressionLevel?;
17
+ private _compressFn?;
18
+ private _decompressFn?;
19
+ constructor(opts: {
20
+ baseUrl: string;
21
+ prefix: string;
22
+ method: string;
23
+ stateToken: string | null;
24
+ outputSchema: Schema;
25
+ inputSchema?: Schema;
26
+ onLog?: (msg: LogMessage) => void;
27
+ pendingBatches: RecordBatch[];
28
+ finished: boolean;
29
+ header: Record<string, any> | null;
30
+ compressionLevel?: number;
31
+ compressFn?: CompressFn;
32
+ decompressFn?: DecompressFn;
33
+ });
34
+ get header(): Record<string, any> | null;
35
+ private _buildHeaders;
36
+ private _prepareBody;
37
+ private _readResponse;
38
+ /**
39
+ * Send an exchange request and return the data rows.
40
+ */
41
+ exchange(input: Record<string, any>[]): Promise<Record<string, any>[]>;
42
+ private _doExchange;
43
+ private _buildEmptyBatch;
44
+ /**
45
+ * Iterate over producer stream batches.
46
+ */
47
+ [Symbol.asyncIterator](): AsyncIterableIterator<Record<string, any>[]>;
48
+ private _sendContinuation;
49
+ close(): void;
50
+ }
51
+ export {};
52
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/client/stream.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,MAAM,EAKP,MAAM,cAAc,CAAC;AAUtB,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;AAClE,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;AAErD,qBAAa,iBAAkB,YAAW,aAAa;IACrD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,MAAM,CAAC,CAA4B;IAC3C,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,iBAAiB,CAAC,CAAS;IACnC,OAAO,CAAC,WAAW,CAAC,CAAa;IACjC,OAAO,CAAC,aAAa,CAAC,CAAe;gBAEzB,IAAI,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;QAClC,cAAc,EAAE,WAAW,EAAE,CAAC;QAC9B,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;QACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,YAAY,CAAC,EAAE,YAAY,CAAC;KAC7B;IAgBD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAEvC;IAED,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,YAAY;YAON,aAAa;IAQ3B;;OAEG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;YA+D9D,WAAW;IA0CzB,OAAO,CAAC,gBAAgB;IAcxB;;OAEG;IACI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;YAyC/D,iBAAiB;IA2B/B,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,25 @@
1
+ export interface HttpConnectOptions {
2
+ prefix?: string;
3
+ onLog?: (msg: LogMessage) => void;
4
+ compressionLevel?: number;
5
+ }
6
+ export interface LogMessage {
7
+ level: string;
8
+ message: string;
9
+ extra?: Record<string, any>;
10
+ }
11
+ export interface StreamSession {
12
+ readonly header: Record<string, any> | null;
13
+ exchange(input: Record<string, any>[]): Promise<Record<string, any>[]>;
14
+ [Symbol.asyncIterator](): AsyncIterableIterator<Record<string, any>[]>;
15
+ close(): void;
16
+ }
17
+ export interface PipeConnectOptions {
18
+ onLog?: (msg: LogMessage) => void;
19
+ }
20
+ export interface SubprocessConnectOptions extends PipeConnectOptions {
21
+ cwd?: string;
22
+ env?: Record<string, string>;
23
+ stderr?: "inherit" | "pipe" | "ignore";
24
+ }
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACvE,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;CACxC"}
@@ -0,0 +1,15 @@
1
+ /** Well-known metadata keys matching Python's metadata.py */
2
+ export declare const RPC_METHOD_KEY = "vgi_rpc.method";
3
+ export declare const LOG_LEVEL_KEY = "vgi_rpc.log_level";
4
+ export declare const LOG_MESSAGE_KEY = "vgi_rpc.log_message";
5
+ export declare const LOG_EXTRA_KEY = "vgi_rpc.log_extra";
6
+ export declare const REQUEST_VERSION_KEY = "vgi_rpc.request_version";
7
+ export declare const REQUEST_VERSION = "1";
8
+ export declare const SERVER_ID_KEY = "vgi_rpc.server_id";
9
+ export declare const REQUEST_ID_KEY = "vgi_rpc.request_id";
10
+ export declare const PROTOCOL_NAME_KEY = "vgi_rpc.protocol_name";
11
+ export declare const DESCRIBE_VERSION_KEY = "vgi_rpc.describe_version";
12
+ export declare const DESCRIBE_VERSION = "2";
13
+ export declare const DESCRIBE_METHOD_NAME = "__describe__";
14
+ export declare const STATE_KEY = "vgi_rpc.stream_state#b64";
15
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,6DAA6D;AAE7D,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD,eAAO,MAAM,eAAe,wBAAwB,CAAC;AACrD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAC7D,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,aAAa,sBAAsB,CAAC;AACjD,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AACzD,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAC/D,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AAEnD,eAAO,MAAM,SAAS,6BAA6B,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Schema, RecordBatch } from "apache-arrow";
2
+ import type { MethodDefinition } from "../types.js";
3
+ /**
4
+ * The schema for the __describe__ response, matching Python's _DESCRIBE_SCHEMA.
5
+ */
6
+ export declare const DESCRIBE_SCHEMA: Schema<any>;
7
+ /**
8
+ * Build the __describe__ response batch and metadata.
9
+ */
10
+ export declare function buildDescribeBatch(protocolName: string, methods: Map<string, MethodDefinition>, serverId: string): {
11
+ batch: RecordBatch;
12
+ metadata: Map<string, string>;
13
+ };
14
+ //# sourceMappingURL=describe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/dispatch/describe.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EAEN,WAAW,EAOZ,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAWpD;;GAEG;AACH,eAAO,MAAM,eAAe,aAW1B,CAAC;AAEH;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACtC,QAAQ,EAAE,MAAM,GACf;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA0GvD"}
@@ -0,0 +1,20 @@
1
+ import type { MethodDefinition } from "../types.js";
2
+ import type { IpcStreamWriter } from "../wire/writer.js";
3
+ import type { IpcStreamReader } from "../wire/reader.js";
4
+ /**
5
+ * Dispatch a stream RPC call (producer or exchange).
6
+ *
7
+ * Producer streams (empty input schema):
8
+ * - Client sends tick batches (empty schema, 0 rows)
9
+ * - Server reads each tick, calls produce(state, out)
10
+ * - Server writes output batch(es) for each tick
11
+ * - When produce() calls out.finish(), server closes output stream
12
+ *
13
+ * Exchange streams (real input schema):
14
+ * - Client sends data batches
15
+ * - Server reads each batch, calls exchange(state, input, out)
16
+ * - Server writes output batch(es) for each input
17
+ * - Stream ends when client closes input (EOS)
18
+ */
19
+ export declare function dispatchStream(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, reader: IpcStreamReader, serverId: string, requestId: string | null): Promise<void>;
20
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/dispatch/stream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB,OAAO,CAAC,IAAI,CAAC,CAoHf"}
@@ -0,0 +1,9 @@
1
+ import type { MethodDefinition } from "../types.js";
2
+ import type { IpcStreamWriter } from "../wire/writer.js";
3
+ /**
4
+ * Dispatch a unary RPC call.
5
+ * Calls the handler with parsed params, writes result or error batch.
6
+ * Supports client-directed logging via ctx.clientLog().
7
+ */
8
+ export declare function dispatchUnary(method: MethodDefinition, params: Record<string, any>, writer: IpcStreamWriter, serverId: string, requestId: string | null): Promise<void>;
9
+ //# sourceMappingURL=unary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unary.d.ts","sourceRoot":"","sources":["../../src/dispatch/unary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -0,0 +1,12 @@
1
+ /** Error thrown when the server encounters an RPC protocol error. */
2
+ export declare class RpcError extends Error {
3
+ readonly errorType: string;
4
+ readonly errorMessage: string;
5
+ readonly remoteTraceback: string;
6
+ constructor(errorType: string, errorMessage: string, remoteTraceback: string);
7
+ }
8
+ /** Error thrown when the client sends an unsupported request version. */
9
+ export declare class VersionError extends Error {
10
+ constructor(message: string);
11
+ }
12
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,qBAAa,QAAS,SAAQ,KAAK;aAEf,SAAS,EAAE,MAAM;aACjB,YAAY,EAAE,MAAM;aACpB,eAAe,EAAE,MAAM;gBAFvB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM;CAK1C;AAED,yEAAyE;AACzE,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1,16 @@
1
+ import { RecordBatch, Schema } from "apache-arrow";
2
+ export declare const ARROW_CONTENT_TYPE = "application/vnd.apache.arrow.stream";
3
+ export declare class HttpRpcError extends Error {
4
+ readonly statusCode: number;
5
+ constructor(message: string, statusCode: number);
6
+ }
7
+ /** Serialize a schema + batches into a complete IPC stream as Uint8Array. */
8
+ export declare function serializeIpcStream(schema: Schema, batches: RecordBatch[]): Uint8Array;
9
+ /** Create a Response with Arrow IPC content type. Casts Uint8Array for TS lib compat. */
10
+ export declare function arrowResponse(body: Uint8Array, status?: number, extraHeaders?: Headers): Response;
11
+ /** Read schema + first batch from an IPC stream body. */
12
+ export declare function readRequestFromBody(body: Uint8Array): Promise<{
13
+ schema: Schema;
14
+ batch: RecordBatch;
15
+ }>;
16
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/http/common.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,WAAW,EACX,MAAM,EAGP,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,kBAAkB,wCAAwC,CAAC;AAExE,qBAAa,YAAa,SAAQ,KAAK;aAGnB,UAAU,EAAE,MAAM;gBADlC,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM;CAKrC;AA8BD,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EAAE,GACrB,UAAU,CAQZ;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,SAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,CAI9F;AAED,yDAAyD;AACzD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAAC,CAYjD"}
@@ -0,0 +1,18 @@
1
+ import type { MethodDefinition } from "../types.js";
2
+ import type { StateSerializer } from "./types.js";
3
+ export interface DispatchContext {
4
+ signingKey: Uint8Array;
5
+ tokenTtl: number;
6
+ serverId: string;
7
+ maxStreamResponseBytes?: number;
8
+ stateSerializer: StateSerializer;
9
+ }
10
+ /** Dispatch a __describe__ request. */
11
+ export declare function httpDispatchDescribe(protocolName: string, methods: Map<string, MethodDefinition>, serverId: string): Response;
12
+ /** Dispatch a unary HTTP request. */
13
+ export declare function httpDispatchUnary(method: MethodDefinition, body: Uint8Array, ctx: DispatchContext): Promise<Response>;
14
+ /** Dispatch a stream init HTTP request (producer or exchange). */
15
+ export declare function httpDispatchStreamInit(method: MethodDefinition, body: Uint8Array, ctx: DispatchContext): Promise<Response>;
16
+ /** Dispatch a stream exchange HTTP request (producer continuation or exchange round). */
17
+ export declare function httpDispatchStreamExchange(method: MethodDefinition, body: Uint8Array, ctx: DispatchContext): Promise<Response>;
18
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/http/dispatch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkBpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,uCAAuC;AACvC,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACtC,QAAQ,EAAE,MAAM,GACf,QAAQ,CAIV;AAED,qCAAqC;AACrC,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,CAuBnB;AAED,kEAAkE;AAClE,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,CAuGnB;AAED,yFAAyF;AACzF,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,CA2EnB"}
@@ -0,0 +1,16 @@
1
+ import type { Protocol } from "../protocol.js";
2
+ import { type HttpHandlerOptions } from "./types.js";
3
+ /**
4
+ * Create a fetch-compatible HTTP handler for a vgi-rpc Protocol.
5
+ *
6
+ * Compatible with Bun.serve(), Deno.serve(), Cloudflare Workers, and any
7
+ * Web API runtime that uses the standard Request/Response types.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const handler = createHttpHandler(protocol);
12
+ * Bun.serve({ port: 8080, fetch: handler });
13
+ * ```
14
+ */
15
+ export declare function createHttpHandler(protocol: Protocol, options?: HttpHandlerOptions): (request: Request) => Response | Promise<Response>;
16
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAiB1E;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6MpD"}
@@ -0,0 +1,4 @@
1
+ export { createHttpHandler } from "./handler.js";
2
+ export type { HttpHandlerOptions, StateSerializer } from "./types.js";
3
+ export { ARROW_CONTENT_TYPE } from "./common.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Pack a state token matching the Python v2 wire format.
3
+ *
4
+ * Layout:
5
+ * [1B version=2]
6
+ * [8B created_at uint64 LE (seconds since epoch)]
7
+ * [4B state_len uint32 LE] [state_len bytes]
8
+ * [4B schema_len uint32 LE] [schema_len bytes]
9
+ * [4B input_schema_len uint32 LE] [input_schema_len bytes]
10
+ * [32B HMAC-SHA256(signing_key, all above bytes)]
11
+ */
12
+ export declare function packStateToken(stateBytes: Uint8Array, schemaBytes: Uint8Array, inputSchemaBytes: Uint8Array, signingKey: Uint8Array, createdAt?: number): string;
13
+ export interface UnpackedToken {
14
+ stateBytes: Uint8Array;
15
+ schemaBytes: Uint8Array;
16
+ inputSchemaBytes: Uint8Array;
17
+ createdAt: number;
18
+ }
19
+ /**
20
+ * Unpack and verify a state token.
21
+ * Throws on tampered, expired, or malformed tokens.
22
+ */
23
+ export declare function unpackStateToken(tokenBase64: string, signingKey: Uint8Array, tokenTtl: number): UnpackedToken;
24
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/http/token.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,UAAU,EACvB,gBAAgB,EAAE,UAAU,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAuCR;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,CAAC;IACxB,gBAAgB,EAAE,UAAU,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,GACf,aAAa,CAiEf"}
@@ -0,0 +1,30 @@
1
+ /** Configuration options for createHttpHandler(). */
2
+ export interface HttpHandlerOptions {
3
+ /** URL path prefix for all endpoints. Default: "/vgi" */
4
+ prefix?: string;
5
+ /** HMAC-SHA256 signing key for state tokens. Random 32 bytes if omitted. */
6
+ signingKey?: Uint8Array;
7
+ /** State token time-to-live in seconds. Default: 3600 (1 hour). 0 disables TTL checks. */
8
+ tokenTtl?: number;
9
+ /** CORS allowed origins. If set, CORS headers are added to all responses. */
10
+ corsOrigins?: string;
11
+ /** Maximum request body size in bytes. Advertised via VGI-Max-Request-Bytes header. */
12
+ maxRequestBytes?: number;
13
+ /** Maximum bytes before a producer stream emits a continuation token. */
14
+ maxStreamResponseBytes?: number;
15
+ /** Server ID included in response metadata. Random if omitted. */
16
+ serverId?: string;
17
+ /** Custom state serializer for stream state objects. Default: JSON with BigInt support. */
18
+ stateSerializer?: StateSerializer;
19
+ /** zstd compression level for responses (1-22). If set, responses are
20
+ * compressed when the client sends Accept-Encoding: zstd. */
21
+ compressionLevel?: number;
22
+ }
23
+ /** Serializer for stream state objects stored in state tokens. */
24
+ export interface StateSerializer {
25
+ serialize(state: any): Uint8Array;
26
+ deserialize(bytes: Uint8Array): any;
27
+ }
28
+ /** Default state serializer using JSON (with BigInt support). */
29
+ export declare const jsonStateSerializer: StateSerializer;
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/http/types.ts"],"names":[],"mappings":"AAGA,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;kEAC8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,UAAU,CAAC;IAClC,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAAC;CACrC;AAED,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,EAAE,eAejC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { VgiRpcServer } from "./server.js";
2
+ export { Protocol } from "./protocol.js";
3
+ export { MethodType, OutputCollector, type LogContext, type MethodDefinition, type UnaryHandler, type HeaderInit, type ProducerInit, type ProducerFn, type ExchangeInit, type ExchangeFn, } from "./types.js";
4
+ export { type SchemaLike, toSchema, inferParamTypes, str, bytes, int, int32, float, float32, bool, } from "./schema.js";
5
+ export { RpcError, VersionError } from "./errors.js";
6
+ export { createHttpHandler, ARROW_CONTENT_TYPE, type HttpHandlerOptions, type StateSerializer, } from "./http/index.js";
7
+ export { RPC_METHOD_KEY, REQUEST_VERSION_KEY, REQUEST_VERSION, LOG_LEVEL_KEY, LOG_MESSAGE_KEY, LOG_EXTRA_KEY, SERVER_ID_KEY, REQUEST_ID_KEY, PROTOCOL_NAME_KEY, DESCRIBE_VERSION_KEY, DESCRIBE_VERSION, DESCRIBE_METHOD_NAME, STATE_KEY, } from "./constants.js";
8
+ export * from "./client/index.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,UAAU,EACV,eAAe,EACf,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,UAAU,EACf,QAAQ,EACR,eAAe,EACf,GAAG,EACH,KAAK,EACL,GAAG,EACH,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,GACL,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,cAAc,mBAAmB,CAAC"}