@query-farm/vgi-rpc 0.6.3 → 0.7.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 (160) hide show
  1. package/dist/access-log.d.ts +50 -0
  2. package/dist/access-log.d.ts.map +1 -0
  3. package/dist/arrow/impl-arrowjs/index.d.ts +96 -0
  4. package/dist/arrow/impl-arrowjs/index.d.ts.map +1 -0
  5. package/dist/arrow/impl-flechette/index.d.ts +102 -0
  6. package/dist/arrow/impl-flechette/index.d.ts.map +1 -0
  7. package/dist/arrow/impl-flechette/message-meta.d.ts +11 -0
  8. package/dist/arrow/impl-flechette/message-meta.d.ts.map +1 -0
  9. package/dist/arrow/index.d.ts +4 -0
  10. package/dist/arrow/index.d.ts.map +1 -0
  11. package/dist/arrow/predicates.d.ts +44 -0
  12. package/dist/arrow/predicates.d.ts.map +1 -0
  13. package/dist/arrow/types.d.ts +62 -0
  14. package/dist/arrow/types.d.ts.map +1 -0
  15. package/dist/client/capabilities.d.ts +25 -0
  16. package/dist/client/capabilities.d.ts.map +1 -0
  17. package/dist/client/connect.d.ts.map +1 -1
  18. package/dist/client/introspect.d.ts +7 -0
  19. package/dist/client/introspect.d.ts.map +1 -1
  20. package/dist/client/ipc.d.ts +8 -2
  21. package/dist/client/ipc.d.ts.map +1 -1
  22. package/dist/client/pipe.d.ts.map +1 -1
  23. package/dist/client/stream.d.ts +11 -2
  24. package/dist/client/stream.d.ts.map +1 -1
  25. package/dist/client/uploadUrl.d.ts +25 -0
  26. package/dist/client/uploadUrl.d.ts.map +1 -0
  27. package/dist/constants.d.ts +15 -1
  28. package/dist/constants.d.ts.map +1 -1
  29. package/dist/crypto.d.ts +22 -0
  30. package/dist/crypto.d.ts.map +1 -0
  31. package/dist/dispatch/describe.d.ts +10 -6
  32. package/dist/dispatch/describe.d.ts.map +1 -1
  33. package/dist/dispatch/stream.d.ts +2 -2
  34. package/dist/dispatch/stream.d.ts.map +1 -1
  35. package/dist/dispatch/unary.d.ts +2 -2
  36. package/dist/dispatch/unary.d.ts.map +1 -1
  37. package/dist/errors.d.ts +46 -0
  38. package/dist/errors.d.ts.map +1 -1
  39. package/dist/external.d.ts +25 -5
  40. package/dist/external.d.ts.map +1 -1
  41. package/dist/http/bearer.d.ts.map +1 -1
  42. package/dist/http/common.d.ts +42 -7
  43. package/dist/http/common.d.ts.map +1 -1
  44. package/dist/http/dispatch.d.ts +20 -2
  45. package/dist/http/dispatch.d.ts.map +1 -1
  46. package/dist/http/handler.d.ts.map +1 -1
  47. package/dist/http/index.d.ts +1 -0
  48. package/dist/http/index.d.ts.map +1 -1
  49. package/dist/http/mtls.d.ts +2 -1
  50. package/dist/http/mtls.d.ts.map +1 -1
  51. package/dist/http/oauth-pkce.d.ts +141 -0
  52. package/dist/http/oauth-pkce.d.ts.map +1 -0
  53. package/dist/http/pages.d.ts +3 -0
  54. package/dist/http/pages.d.ts.map +1 -1
  55. package/dist/http/sticky.d.ts +124 -0
  56. package/dist/http/sticky.d.ts.map +1 -0
  57. package/dist/http/token.d.ts +38 -12
  58. package/dist/http/token.d.ts.map +1 -1
  59. package/dist/http/types.d.ts +68 -5
  60. package/dist/http/types.d.ts.map +1 -1
  61. package/dist/index.d.ts +6 -4
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +1275 -3507
  64. package/dist/index.js.map +19 -37
  65. package/dist/launcher/hash.d.ts +22 -0
  66. package/dist/launcher/hash.d.ts.map +1 -0
  67. package/dist/launcher/index.d.ts +23 -0
  68. package/dist/launcher/index.d.ts.map +1 -0
  69. package/dist/launcher/launch.d.ts +27 -0
  70. package/dist/launcher/launch.d.ts.map +1 -0
  71. package/dist/launcher/lock.d.ts +19 -0
  72. package/dist/launcher/lock.d.ts.map +1 -0
  73. package/dist/launcher/serve-unix.d.ts +54 -0
  74. package/dist/launcher/serve-unix.d.ts.map +1 -0
  75. package/dist/launcher/state.d.ts +59 -0
  76. package/dist/launcher/state.d.ts.map +1 -0
  77. package/dist/otel.d.ts.map +1 -1
  78. package/dist/protocol.d.ts +16 -2
  79. package/dist/protocol.d.ts.map +1 -1
  80. package/dist/schema.d.ts +45 -18
  81. package/dist/schema.d.ts.map +1 -1
  82. package/dist/server.d.ts +23 -2
  83. package/dist/server.d.ts.map +1 -1
  84. package/dist/types.d.ts +216 -12
  85. package/dist/types.d.ts.map +1 -1
  86. package/dist/util/gzip.d.ts +10 -0
  87. package/dist/util/gzip.d.ts.map +1 -0
  88. package/dist/util/schema.d.ts +3 -15
  89. package/dist/util/schema.d.ts.map +1 -1
  90. package/dist/util/web-crypto.d.ts +22 -0
  91. package/dist/util/web-crypto.d.ts.map +1 -0
  92. package/dist/util/zstd.d.ts +26 -3
  93. package/dist/util/zstd.d.ts.map +1 -1
  94. package/dist/wire/opaque.d.ts +11 -0
  95. package/dist/wire/opaque.d.ts.map +1 -0
  96. package/dist/wire/reader.d.ts +5 -5
  97. package/dist/wire/reader.d.ts.map +1 -1
  98. package/dist/wire/request.d.ts +11 -3
  99. package/dist/wire/request.d.ts.map +1 -1
  100. package/dist/wire/response.d.ts +6 -6
  101. package/dist/wire/response.d.ts.map +1 -1
  102. package/dist/wire/writer.d.ts +49 -39
  103. package/dist/wire/writer.d.ts.map +1 -1
  104. package/package.json +24 -10
  105. package/src/access-log.ts +195 -0
  106. package/src/arrow/impl-arrowjs/index.ts +433 -0
  107. package/src/arrow/impl-flechette/index.ts +414 -0
  108. package/src/arrow/impl-flechette/message-meta.ts +174 -0
  109. package/src/arrow/index.ts +89 -0
  110. package/src/arrow/predicates.ts +56 -0
  111. package/src/arrow/types.ts +73 -0
  112. package/src/client/capabilities.ts +84 -0
  113. package/src/client/connect.ts +103 -26
  114. package/src/client/introspect.ts +60 -38
  115. package/src/client/ipc.ts +37 -27
  116. package/src/client/pipe.ts +12 -9
  117. package/src/client/stream.ts +34 -19
  118. package/src/client/uploadUrl.ts +169 -0
  119. package/src/constants.ts +18 -1
  120. package/src/crypto.ts +95 -0
  121. package/src/dispatch/describe.ts +146 -107
  122. package/src/dispatch/stream.ts +53 -24
  123. package/src/dispatch/unary.ts +5 -4
  124. package/src/errors.ts +76 -0
  125. package/src/external.ts +43 -29
  126. package/src/http/bearer.ts +2 -5
  127. package/src/http/common.ts +90 -23
  128. package/src/http/dispatch.ts +373 -46
  129. package/src/http/handler.ts +794 -68
  130. package/src/http/index.ts +1 -0
  131. package/src/http/mtls.ts +18 -3
  132. package/src/http/oauth-pkce.ts +1035 -0
  133. package/src/http/pages.ts +30 -15
  134. package/src/http/sticky.ts +429 -0
  135. package/src/http/token.ts +165 -75
  136. package/src/http/types.ts +69 -5
  137. package/src/index.ts +40 -1
  138. package/src/launcher/hash.ts +104 -0
  139. package/src/launcher/index.ts +35 -0
  140. package/src/launcher/launch.ts +284 -0
  141. package/src/launcher/lock.ts +171 -0
  142. package/src/launcher/serve-unix.ts +385 -0
  143. package/src/launcher/state.ts +245 -0
  144. package/src/otel.ts +39 -33
  145. package/src/protocol.ts +27 -3
  146. package/src/schema.ts +107 -56
  147. package/src/server.ts +196 -20
  148. package/src/types.ts +322 -18
  149. package/src/util/gzip.ts +63 -0
  150. package/src/util/schema.ts +4 -22
  151. package/src/util/web-crypto.ts +98 -0
  152. package/src/util/zstd.ts +133 -14
  153. package/src/wire/opaque.ts +37 -0
  154. package/src/wire/reader.ts +5 -4
  155. package/src/wire/request.ts +67 -8
  156. package/src/wire/response.ts +51 -85
  157. package/src/wire/writer.ts +165 -69
  158. package/dist/util/conform.d.ts +0 -18
  159. package/dist/util/conform.d.ts.map +0 -1
  160. package/src/util/conform.ts +0 -94
@@ -0,0 +1,22 @@
1
+ /** Recursively stringify with sorted object keys and `,`/`:` separators —
2
+ * the JS equivalent of `json.dumps(..., sort_keys=True, separators=(",",":"))`.
3
+ * We can't reuse `JSON.stringify` because the V8 implementation preserves
4
+ * insertion order rather than sorting. */
5
+ declare function canonicalJson(value: unknown): string;
6
+ /**
7
+ * Compute the 16-hex-char tuple hash for a worker.
8
+ *
9
+ * @param workerArgv The worker command and its arguments.
10
+ * @param cwd Working directory; defaults to `process.cwd()`.
11
+ * @param env Process environment; defaults to `process.env`. Only
12
+ * keys starting with `VGI_RPC_` participate in the hash —
13
+ * workers that differ only in unrelated env (PATH,
14
+ * HOME, …) intentionally share a worker.
15
+ */
16
+ export declare function computeHash(workerArgv: readonly string[], cwd?: string, env?: Record<string, string | undefined>): Promise<string>;
17
+ /** Exposed for parity-test fixtures that need to inspect the canonical form. */
18
+ export declare const _internal: {
19
+ canonicalJson: typeof canonicalJson;
20
+ };
21
+ export {};
22
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/launcher/hash.ts"],"names":[],"mappings":"AA6BA;;;2CAG2C;AAC3C,iBAAS,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAoB7C;AAaD;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACvC,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,gFAAgF;AAChF,eAAO,MAAM,SAAS;;CAAoB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * AF_UNIX worker launcher — TypeScript port of `vgi_rpc.launcher`.
3
+ *
4
+ * Two halves:
5
+ *
6
+ * - **Coordination** ({@link launch}, {@link computeHash}, {@link gcStateDir},
7
+ * {@link statusRows}): spawn-or-reuse a long-running worker process for a
8
+ * given command tuple, returning the AF_UNIX socket path the caller
9
+ * should connect to. Hash and on-disk layout match the Python
10
+ * implementation byte-for-byte so workers in any language under the
11
+ * same tuple resolve to the same socket.
12
+ *
13
+ * - **Worker runner** ({@link serveUnix}): bind a Unix socket and serve a
14
+ * {@link Protocol} via per-connection IPC streams. Implements the
15
+ * `--unix PATH` / `--idle-timeout SEC` / `UNIX:<path>` contract so
16
+ * launchers (Python or TS) can spawn TS workers transparently.
17
+ */
18
+ export { computeHash } from "./hash.js";
19
+ export { type LaunchConfig, launch } from "./launch.js";
20
+ export { acquireLock, type FileLockHandle, tryAcquireLock } from "./lock.js";
21
+ export { type ServeUnixHandle, type ServeUnixOptions, serveUnix } from "./serve-unix.js";
22
+ export { defaultStateDir, type GcResult, gcStateDir, probeSocket, type SocketPaths, type StatusRow, socketPaths, statusRows, } from "./state.js";
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/launcher/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EACL,eAAe,EACf,KAAK,QAAQ,EACb,UAAU,EACV,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -0,0 +1,27 @@
1
+ /** Inputs to {@link launch}. */
2
+ export interface LaunchConfig {
3
+ /** The worker command and its arguments. Must be non-empty. */
4
+ workerArgv: readonly string[];
5
+ /** Explicit socket path; when omitted, derived from the hash of the tuple. */
6
+ socketPath?: string;
7
+ /** Worker self-shutdown after this many seconds idle. Forwarded as
8
+ * `--idle-timeout SEC`. Default: 300. */
9
+ idleTimeout?: number;
10
+ /** Maximum seconds to block waiting for the per-hash file lock. Default: 30. */
11
+ connectTimeout?: number;
12
+ /** Maximum seconds to wait for the worker to print `UNIX:<path>`. Default: 60. */
13
+ workerStartupTimeout?: number;
14
+ /** If set, worker stderr is appended to this file; otherwise discarded. */
15
+ workerStderr?: string;
16
+ /** Override the default state directory. */
17
+ stateDir?: string;
18
+ }
19
+ /**
20
+ * Ensure a worker is running and return its socket path.
21
+ *
22
+ * Either the existing worker for this hash is reused (probe succeeds) or
23
+ * a fresh one is spawned under flock. Throws on any failure to bring up
24
+ * a worker.
25
+ */
26
+ export declare function launch(config: LaunchConfig): Promise<string>;
27
+ //# sourceMappingURL=launch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/launcher/launch.ts"],"names":[],"mappings":"AAyCA,gCAAgC;AAChC,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;+CAC2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAiElE"}
@@ -0,0 +1,19 @@
1
+ /** Result of a successful lock acquisition. */
2
+ export interface FileLockHandle {
3
+ /** Path to the lockfile (informational). */
4
+ readonly path: string;
5
+ /** Release the lock — truncates the file to zero bytes; the file
6
+ * itself persists as a slot marker. Idempotent. */
7
+ release(): void;
8
+ }
9
+ /**
10
+ * Try to acquire the lock once, non-blocking.
11
+ *
12
+ * Returns a release callback on success, or `null` when the lock is
13
+ * held by another live process. Stale stamps (PID not alive) are
14
+ * cleared and the call retries.
15
+ */
16
+ export declare function tryAcquireLock(lockPath: string): FileLockHandle | null;
17
+ /** Async version that polls until the lock is acquired or the timeout fires. */
18
+ export declare function acquireLock(lockPath: string, timeoutMs: number): Promise<FileLockHandle>;
19
+ //# sourceMappingURL=lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/launcher/lock.ts"],"names":[],"mappings":"AAuCA,+CAA+C;AAC/C,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;yDACqD;IACrD,OAAO,IAAI,IAAI,CAAC;CACjB;AA8ED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CA0BtE;AAED,gFAAgF;AAChF,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAU9F"}
@@ -0,0 +1,54 @@
1
+ import type { ExternalLocationConfig } from "../external.js";
2
+ import type { Protocol } from "../protocol.js";
3
+ import { type DispatchHook, type ServeStartHook } from "../types.js";
4
+ /** Configuration for {@link serveUnix}. */
5
+ export interface ServeUnixOptions {
6
+ /** Absolute path to the Unix socket file the worker should bind. */
7
+ unixPath: string;
8
+ /** Self-terminate after this many seconds with zero connected clients.
9
+ * Default: 300. `0` disables the timer (server runs until killed). */
10
+ idleTimeout?: number;
11
+ /** Grace period after `listen()` succeeds before the idle timer starts
12
+ * ticking. Default: 5 — gives the first launcher caller a chance to
13
+ * connect after the `UNIX:<path>` announcement. */
14
+ startupGraceSeconds?: number;
15
+ /** Optional logical-service / protocol-contract version label. */
16
+ protocolVersion?: string;
17
+ /** Custom server identifier. */
18
+ serverId?: string;
19
+ /** Enable __describe__ method. Default: true. */
20
+ enableDescribe?: boolean;
21
+ /** Optional dispatch hook for observability. */
22
+ dispatchHook?: DispatchHook;
23
+ /** Optional external-storage config for large-batch externalisation. */
24
+ externalLocation?: ExternalLocationConfig;
25
+ /** Lifecycle hook fired once before the first dispatched request. */
26
+ onServeStart?: ServeStartHook;
27
+ /** Maximum sequential listen backlog. Mirrors Python's `serve_unix`
28
+ * (`backlog=16`). Default: 16. */
29
+ backlog?: number;
30
+ /** Called *after* `listen()` returns successfully but *before*
31
+ * `UNIX:<path>` is printed. The launcher uses this hook to write the
32
+ * announcement only after we're sure the bind took. */
33
+ onBound?: (sockPath: string) => void;
34
+ /** Override the stream used for the `UNIX:<path>` line. Defaults to
35
+ * `process.stdout`. */
36
+ announcementSink?: NodeJS.WritableStream;
37
+ }
38
+ /** Handle returned by {@link serveUnix} for callers that want to stop the server. */
39
+ export interface ServeUnixHandle {
40
+ readonly socketPath: string;
41
+ /** Shut down the listener and unlink the socket file. */
42
+ stop(): Promise<void>;
43
+ /** Promise that resolves when the server has stopped (idle timeout, stop(),
44
+ * or a fatal error). Mirrors Python's blocking `serve()` return. */
45
+ readonly done: Promise<void>;
46
+ }
47
+ /**
48
+ * Bind an AF_UNIX socket and serve `protocol` over per-connection IPC streams.
49
+ *
50
+ * Sequential listen — one client at a time, just like Python's `serve_unix`.
51
+ * Each connection gets its own dispatch loop and shares the protocol.
52
+ */
53
+ export declare function serveUnix(protocol: Protocol, options: ServeUnixOptions): Promise<ServeUnixHandle>;
54
+ //# sourceMappingURL=serve-unix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve-unix.d.ts","sourceRoot":"","sources":["../../src/launcher/serve-unix.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAEL,KAAK,YAAY,EAGjB,KAAK,cAAc,EAEpB,MAAM,aAAa,CAAC;AAQrB,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB;4EACwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;wDAEoD;IACpD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gDAAgD;IAChD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C,qEAAqE;IACrE,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B;wCACoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;4DAEwD;IACxD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;4BACwB;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAC1C;AAED,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB;0EACsE;IACtE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAiSvG"}
@@ -0,0 +1,59 @@
1
+ import { computeHash } from "./hash.js";
2
+ /** Filesystem layout for one worker tuple: `<state_dir>/<hash>.{lock,sock,meta}`. */
3
+ export interface SocketPaths {
4
+ lockPath: string;
5
+ sockPath: string;
6
+ metaPath: string;
7
+ }
8
+ export declare function socketPaths(stateDir: string, hashId: string): SocketPaths;
9
+ /**
10
+ * Resolve the per-user state directory used for lockfiles + sockets.
11
+ *
12
+ * - Linux: `$XDG_RUNTIME_DIR/vgi-rpc/` when set (systemd-managed,
13
+ * auto-cleaned on logout); otherwise `$TMPDIR/vgi-rpc-$UID/`.
14
+ * - macOS / BSD: `$TMPDIR/vgi-rpc-$UID/`.
15
+ * - Windows: `$TMP/vgi-rpc/`.
16
+ *
17
+ * The directory is created mode 0700 if missing. On POSIX, we refuse to
18
+ * operate on a directory not owned by the current user — defends against
19
+ * a hijacked `/tmp/vgi-rpc-$UID` left by an attacker.
20
+ */
21
+ export declare function defaultStateDir(): string;
22
+ /** Best-effort write of human-readable launch metadata. Used by `--status`. */
23
+ export declare function writeMeta(metaPath: string, workerArgv: readonly string[], cwd: string, sockPath: string): void;
24
+ export interface StatusRow {
25
+ hashId: string;
26
+ cmd: string[];
27
+ cwd: string;
28
+ socket: string;
29
+ startedAt: number | null;
30
+ alive: boolean;
31
+ }
32
+ export interface GcResult {
33
+ /** Hash IDs of stale entries that were removed. */
34
+ cleaned: string[];
35
+ /** Hash IDs whose lockfile is currently held (a launch is in flight or the
36
+ * worker is alive). */
37
+ skippedInUse: string[];
38
+ }
39
+ /** Probe whether anyone is currently accepting on `sockPath`. */
40
+ export declare function probeSocket(sockPath: string, timeoutMs?: number): Promise<boolean>;
41
+ /** List one row per `<hash>.lock` in `stateDir`. Read-only; takes no locks. */
42
+ export declare function statusRows(stateDir: string): Promise<StatusRow[]>;
43
+ /**
44
+ * Remove `<hash>.lock`/`.sock`/`.meta` triples whose worker is no longer
45
+ * accepting connections.
46
+ *
47
+ * @param tryAcquire Function provided by the lock module so we don't pull
48
+ * the lock implementation into a circular import. Returns a release
49
+ * callback when the lock can be acquired non-blocking, or `null` when
50
+ * it's already held (the worker is alive or another launch is in flight).
51
+ */
52
+ export declare function gcStateDir(stateDir: string, tryAcquire: (lockPath: string) => Promise<(() => void) | null>, options?: {
53
+ limit?: number;
54
+ excludeHash?: string;
55
+ }): Promise<GcResult>;
56
+ /** Re-export for callers that want canonical hashing without going through the
57
+ * launch entry point. */
58
+ export { computeHash };
59
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/launcher/state.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qFAAqF;AACrF,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAMzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,IAAI,MAAM,CA+BxC;AAMD,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAa9G;AAMD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;4BACwB;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,iEAAiE;AACjE,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBtF;AAgBD,gFAAgF;AAChF,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAA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ourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAIL,KAAK,KAAK,EAKV,KAAK,MAAM,EAEZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAkB,YAAY,EAA2B,MAAM,YAAY,CAAC;AAIxF,uDAAuD;AACvD,MAAM,WAAW,UAAU;IACzB,oEAAoE;IACpE,cAAc,CAAC,EAAE;QAAE,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACrD,mEAAmE;IACnE,aAAa,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAC;IAClD,2CAA2C;IAC3C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yDAAyD;IACzD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAOD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,CAqGhE"}
@@ -1,13 +1,25 @@
1
1
  import { type SchemaLike } from "./schema.js";
2
- import { type ExchangeFn, type ExchangeInit, type HeaderInit, type MethodDefinition, type ProducerFn, type ProducerInit, type UnaryHandler } from "./types.js";
2
+ import { type ExchangeFn, type ExchangeInit, type HeaderInit, type MethodDefinition, type OnCancelFn, type ProducerFn, type ProducerInit, type UnaryHandler } from "./types.js";
3
3
  /**
4
4
  * Fluent builder for defining RPC methods.
5
5
  * Register unary, producer, and exchange methods, then pass to `VgiRpcServer`.
6
6
  */
7
7
  export declare class Protocol {
8
8
  readonly name: string;
9
+ /**
10
+ * Application protocol surface version. When non-empty, the server enforces
11
+ * exact major+minor match (patch ignored) against every request's
12
+ * `vgi_rpc.protocol_version` metadata; clients bound to this Protocol emit
13
+ * the value on every request. Format: canonical semver MAJOR.MINOR.PATCH.
14
+ * Mirrors Python's `Protocol.protocol_version` ClassVar.
15
+ */
16
+ readonly protocolVersion: string;
17
+ /** Parsed semver tuple; null when `protocolVersion` is unset. */
18
+ readonly protocolVersionParts: readonly [number, number, number] | null;
9
19
  private _methods;
10
- constructor(name: string);
20
+ constructor(name: string, options?: {
21
+ protocolVersion?: string;
22
+ });
11
23
  /**
12
24
  * Register a unary (request-response) method.
13
25
  * @param name - Method name exposed to clients
@@ -35,6 +47,7 @@ export declare class Protocol {
35
47
  outputSchema: SchemaLike;
36
48
  init: ProducerInit<S>;
37
49
  produce: ProducerFn<S>;
50
+ onCancel?: OnCancelFn<S>;
38
51
  headerSchema?: SchemaLike;
39
52
  headerInit?: HeaderInit;
40
53
  doc?: string;
@@ -51,6 +64,7 @@ export declare class Protocol {
51
64
  outputSchema: SchemaLike;
52
65
  init: ExchangeInit<S>;
53
66
  exchange: ExchangeFn<S>;
67
+ onCancel?: OnCancelFn<S>;
54
68
  headerSchema?: SchemaLike;
55
69
  headerInit?: HeaderInit;
56
70
  doc?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AACzE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,qBAAa,QAAQ;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,QAAQ,CAA4C;gBAEhD,IAAI,EAAE,MAAM;IAIxB;;;;;;;;;OASG;IACH,KAAK,CACH,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE;QACN,MAAM,EAAE,UAAU,CAAC;QACnB,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C;QACnB,YAAY,EAAE,UAAU,CAAC;QACzB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;QACtB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QACvB,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QACzB,YAAY,CAAC,EAAE,UAAU,CAAC;QAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACrC,GACA,IAAI;IAqBP;;;OAGG;IACH,QAAQ,CAAC,CAAC,EACR,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE;QACN,MAAM,EAAE,UAAU,CAAC;QACnB,WAAW,EAAE,UAAU,CAAC;QACxB,YAAY,EAAE,UAAU,CAAC;QACzB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;QACtB,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QACxB,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QACzB,YAAY,CAAC,EAAE,UAAU,CAAC;QAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACrC,GACA,IAAI;IAqBP,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC;CAG5C"}
package/dist/schema.d.ts CHANGED
@@ -1,34 +1,61 @@
1
- import { Binary, Bool, DataType, Field, Float32, Float64, Int32, Int64, Schema, Utf8 } from "@query-farm/apache-arrow";
1
+ import { type VgiDataType, type VgiField, type VgiSchema } from "./arrow/index.js";
2
2
  /** Apache Arrow Utf8 type. Use as schema shorthand: `{ name: str }` */
3
- export declare const str: Utf8;
3
+ export declare const str: VgiDataType;
4
4
  /** Apache Arrow Binary type. Use as schema shorthand: `{ data: bytes }` */
5
- export declare const bytes: Binary;
5
+ export declare const bytes: VgiDataType;
6
6
  /** Apache Arrow Int64 type. Use as schema shorthand: `{ count: int }` */
7
- export declare const int: Int64;
7
+ export declare const int: VgiDataType;
8
8
  /** Apache Arrow Int32 type. Use as schema shorthand: `{ count: int32 }` */
9
- export declare const int32: Int32;
9
+ export declare const int32: VgiDataType;
10
+ /** Apache Arrow Int16 type. Use as schema shorthand: `{ count: int16 }` */
11
+ export declare const int16: VgiDataType;
12
+ /** Apache Arrow Int8 type. Use as schema shorthand: `{ count: int8 }` */
13
+ export declare const int8: VgiDataType;
14
+ /** Apache Arrow Uint8 type. Use as schema shorthand: `{ count: uint8 }` */
15
+ export declare const uint8: VgiDataType;
16
+ /** Apache Arrow Uint16 type. Use as schema shorthand: `{ count: uint16 }` */
17
+ export declare const uint16: VgiDataType;
18
+ /** Apache Arrow Uint32 type. Use as schema shorthand: `{ count: uint32 }` */
19
+ export declare const uint32: VgiDataType;
20
+ /** Apache Arrow Uint64 type. Use as schema shorthand: `{ count: uint64 }` */
21
+ export declare const uint64: VgiDataType;
10
22
  /** Apache Arrow Float64 type. Use as schema shorthand: `{ value: float }` */
11
- export declare const float: Float64;
23
+ export declare const float: VgiDataType;
12
24
  /** Apache Arrow Float32 type. Use as schema shorthand: `{ value: float32 }` */
13
- export declare const float32: Float32;
25
+ export declare const float32: VgiDataType;
14
26
  /** Apache Arrow Bool type. Use as schema shorthand: `{ flag: bool }` */
15
- export declare const bool: Bool;
27
+ export declare const bool: VgiDataType;
28
+ /**
29
+ * Structural minimum that any backend's Schema must satisfy. arrow-js's
30
+ * `Schema`, vgi-typescript's `VgiSchema`, and flechette's `Schema` all match
31
+ * this shape. Used so vgi-rpc consumers don't have to know which Arrow
32
+ * library is on the other side of the wire.
33
+ *
34
+ * Kept exported for backwards compatibility — equivalent to `VgiSchema`.
35
+ */
36
+ export interface SchemaShape {
37
+ readonly fields: ReadonlyArray<{
38
+ readonly name: string;
39
+ readonly type: {
40
+ readonly typeId: number;
41
+ };
42
+ readonly nullable?: boolean;
43
+ readonly metadata?: Map<string, string>;
44
+ }>;
45
+ readonly metadata?: Map<string, string> | null;
46
+ }
16
47
  /**
17
48
  * A schema specification that accepts:
18
- * - A real `Schema` (passed through)
19
- * - A record mapping field names to `DataType` instances or `Field` instances
49
+ * - A real `VgiSchema` (passed through)
50
+ * - Anything structurally `SchemaShape`
51
+ * - A record mapping field names to `VgiDataType` instances or `VgiField` instances
20
52
  * - An empty `{}` for an empty schema
21
53
  */
22
- export type SchemaLike = Schema | Record<string, DataType | Field>;
54
+ export type SchemaLike = VgiSchema | SchemaShape | Record<string, VgiDataType | VgiField>;
23
55
  /**
24
- * Convert a SchemaLike spec into a real `Schema`.
25
- *
26
- * - `Schema` → returned as-is
27
- * - `Record<string, DataType>` → each entry becomes `new Field(name, type, false)`
28
- * - `Record<string, Field>` → each entry is passed through
29
- * - `{}` → `new Schema([])`
56
+ * Convert a SchemaLike spec into a real `VgiSchema`.
30
57
  */
31
- export declare function toSchema(spec: SchemaLike): Schema;
58
+ export declare function toSchema(spec: SchemaLike): VgiSchema;
32
59
  /**
33
60
  * Derive a `paramTypes` record from a SchemaLike spec.
34
61
  * Maps common Arrow scalar types to Python-style type strings.
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,OAAO,EACP,OAAO,EAEP,KAAK,EACL,KAAK,EACL,MAAM,EACN,IAAI,EACL,MAAM,0BAA0B,CAAC;AAMlC,uEAAuE;AACvE,eAAO,MAAM,GAAG,MAAa,CAAC;AAC9B,2EAA2E;AAC3E,eA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,CAAC;AACnC,6EAA6E;AAC7E,eAAO,MAAM,MAAM,aAAe,CAAC;AACnC,6EAA6E;AAC7E,eAAO,MAAM,KAAK,aAAgB,CAAC;AACnC,+EAA+E;AAC/E,eAAO,MAAM,OAAO,aAAgB,CAAC;AACrC,wEAAwE;AACxE,eAAO,MAAM,IAAI,aAAa,CAAC;AAM/B;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;QAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE;YAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACzC,CAAC,CAAC;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAChD;AAED;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAC;AAe1F;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CA0BpD;AAMD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAgBpF"}
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ExternalLocationConfig } from "./external.js";
2
2
  import type { Protocol } from "./protocol.js";
3
- import { type DispatchHook } from "./types.js";
3
+ import { type DispatchHook, type ServeStartHook } from "./types.js";
4
4
  /**
5
5
  * RPC server that reads Arrow IPC requests from stdin and writes responses to stdout.
6
6
  * Supports unary and streaming (producer/exchange) methods.
@@ -9,15 +9,36 @@ export declare class VgiRpcServer {
9
9
  private protocol;
10
10
  private enableDescribe;
11
11
  private serverId;
12
- private describeBatch;
12
+ private _describePromise;
13
+ private protocolVersion;
13
14
  private dispatchHook;
14
15
  private externalConfig;
16
+ private onServeStart;
17
+ /** True once the on_serve_start hook has fired successfully. The bind
18
+ * state is committed only after the hook returns, so a transient
19
+ * failure on first request leaves it `false` and the next request
20
+ * re-fires rather than silently skipping. Mirrors Python 7b3999c. */
21
+ private serveStartFired;
15
22
  constructor(protocol: Protocol, options?: {
16
23
  enableDescribe?: boolean;
17
24
  serverId?: string;
18
25
  dispatchHook?: DispatchHook;
19
26
  externalLocation?: ExternalLocationConfig;
27
+ protocolVersion?: string;
28
+ /** Lifecycle hook fired once before the first dispatched request. */
29
+ onServeStart?: ServeStartHook;
20
30
  });
31
+ /** Fire the on_serve_start hook once for this transport. Idempotent
32
+ * on success — re-throws on failure without committing the bind. */
33
+ private notifyTransport;
34
+ /** Build (or retrieve cached) describe batch + protocol hash. */
35
+ private describeInfo;
36
+ /** Validate a client's declared protocol_version against the Protocol's
37
+ * declared version. Caller invokes only when
38
+ * `protocol.protocolVersionParts` is non-null. Mirrors Python's
39
+ * `RpcServer._check_protocol_version`: exact major+minor match, patch
40
+ * ignored; directional error message names which side is older. */
41
+ private checkProtocolVersion;
21
42
  /** Start the server loop. Reads requests until stdin closes. */
22
43
  run(): Promise<void>;
23
44
  private serveOne;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAuB,KAAK,YAAY,EAAiC,MAAM,YAAY,CAAC;AAQnG;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAW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