@query-farm/vgi 0.28.0 → 0.29.1

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 (121) hide show
  1. package/README.md +52 -8
  2. package/dist/arguments/argument-spec.d.ts +57 -2
  3. package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
  4. package/dist/arrow/impl-arrowjs/iterate.d.ts +10 -1
  5. package/dist/arrow/impl-arrowjs/schema.d.ts +2 -0
  6. package/dist/arrow/impl-flechette/index.d.ts +1 -1
  7. package/dist/arrow/impl-flechette/iterate.d.ts +10 -1
  8. package/dist/arrow/impl-flechette/schema.d.ts +2 -0
  9. package/dist/arrow/index.d.ts +1 -1
  10. package/dist/arrow/schema-types.d.ts +3 -1
  11. package/dist/arrow/types.d.ts +39 -3
  12. package/dist/catalog/composite.d.ts +13 -13
  13. package/dist/catalog/descriptors.d.ts +7 -3
  14. package/dist/catalog/interface.d.ts +108 -38
  15. package/dist/catalog/read-only.d.ts +32 -15
  16. package/dist/client/client.d.ts +37 -30
  17. package/dist/client/types.d.ts +2 -0
  18. package/dist/client-entry.d.ts +1 -1
  19. package/dist/client-entry.js +791 -447
  20. package/dist/client-entry.js.map +18 -17
  21. package/dist/filter-pushdown/capabilities.d.ts +3 -0
  22. package/dist/filter-pushdown/deserialize.d.ts +14 -15
  23. package/dist/filter-pushdown/evaluate.d.ts +14 -44
  24. package/dist/filter-pushdown/index.d.ts +2 -2
  25. package/dist/filter-pushdown/types.d.ts +120 -68
  26. package/dist/functions/aggregate.d.ts +4 -0
  27. package/dist/functions/registry.d.ts +5 -5
  28. package/dist/functions/scalar.d.ts +6 -1
  29. package/dist/functions/table-buffering.d.ts +9 -0
  30. package/dist/functions/table-in-out.d.ts +13 -0
  31. package/dist/functions/table.d.ts +72 -2
  32. package/dist/functions/types.d.ts +60 -2
  33. package/dist/generated/vgi-client.d.ts +114 -26
  34. package/dist/generated/vgi-protocol-schemas.d.ts +34 -0
  35. package/dist/http/fetch.d.ts +16 -0
  36. package/dist/index.core.d.ts +4 -3
  37. package/dist/index.js +3396 -2064
  38. package/dist/index.js.map +55 -49
  39. package/dist/metadata/types.d.ts +15 -2
  40. package/dist/protocol/handlers/catalog/shared.d.ts +0 -8
  41. package/dist/protocol/handlers/function.d.ts +11 -0
  42. package/dist/protocol/handlers/shared.d.ts +3 -1
  43. package/dist/protocol/serializers/bind.d.ts +1 -2
  44. package/dist/protocol/serializers/cardinality.d.ts +1 -2
  45. package/dist/protocol/serializers/splits.d.ts +126 -0
  46. package/dist/protocol/types.d.ts +36 -3
  47. package/dist/request-auth.d.ts +28 -0
  48. package/dist/schema-path.d.ts +7 -0
  49. package/dist/serve-entry.d.ts +25 -0
  50. package/dist/serve-entry.js +1129 -569
  51. package/dist/serve-entry.js.map +36 -32
  52. package/dist/split-token.d.ts +88 -0
  53. package/dist/types.d.ts +8 -0
  54. package/dist/worker-cf-entry.js +2928 -1689
  55. package/dist/worker-cf-entry.js.map +51 -44
  56. package/dist/worker.d.ts +1 -1
  57. package/package.json +3 -3
  58. package/src/arguments/argument-spec.ts +93 -4
  59. package/src/arguments/arguments.ts +0 -1
  60. package/src/arrow/impl-arrowjs/index.ts +1 -1
  61. package/src/arrow/impl-arrowjs/iterate.ts +21 -0
  62. package/src/arrow/impl-arrowjs/schema.ts +4 -0
  63. package/src/arrow/impl-flechette/index.ts +1 -1
  64. package/src/arrow/impl-flechette/iterate.ts +24 -1
  65. package/src/arrow/impl-flechette/schema.ts +4 -0
  66. package/src/arrow/index.ts +1 -1
  67. package/src/arrow/schema-types.ts +4 -0
  68. package/src/arrow/types.ts +39 -3
  69. package/src/catalog/composite.ts +26 -26
  70. package/src/catalog/descriptors.ts +12 -3
  71. package/src/catalog/interface.ts +217 -72
  72. package/src/catalog/read-only.ts +141 -84
  73. package/src/client/client.ts +97 -73
  74. package/src/client/types.ts +2 -0
  75. package/src/client-entry.ts +2 -1
  76. package/src/filter-pushdown/capabilities.ts +13 -0
  77. package/src/filter-pushdown/collector.ts +22 -35
  78. package/src/filter-pushdown/deserialize.ts +657 -221
  79. package/src/filter-pushdown/evaluate.ts +410 -499
  80. package/src/filter-pushdown/index.ts +16 -2
  81. package/src/filter-pushdown/types.ts +88 -71
  82. package/src/functions/aggregate.ts +12 -1
  83. package/src/functions/copy-from.ts +2 -1
  84. package/src/functions/copy-to.ts +2 -1
  85. package/src/functions/registry.ts +24 -22
  86. package/src/functions/scalar.ts +37 -0
  87. package/src/functions/table-buffering.ts +48 -6
  88. package/src/functions/table-in-out.ts +194 -33
  89. package/src/functions/table.ts +187 -22
  90. package/src/functions/types.ts +64 -1
  91. package/src/generated/vgi-client.ts +122 -28
  92. package/src/generated/vgi-protocol-schemas.ts +455 -58
  93. package/src/http/fetch.ts +129 -2
  94. package/src/index.core.ts +4 -2
  95. package/src/metadata/resolve.ts +43 -1
  96. package/src/metadata/serialize.ts +43 -5
  97. package/src/metadata/types.ts +17 -1
  98. package/src/protocol/dispatch.ts +1 -1
  99. package/src/protocol/handlers/aggregate.ts +23 -12
  100. package/src/protocol/handlers/catalog/admin.ts +47 -54
  101. package/src/protocol/handlers/catalog/index_methods.ts +6 -13
  102. package/src/protocol/handlers/catalog/macro.ts +12 -20
  103. package/src/protocol/handlers/catalog/shared.ts +12 -57
  104. package/src/protocol/handlers/catalog/table.ts +49 -112
  105. package/src/protocol/handlers/catalog/view.ts +18 -22
  106. package/src/protocol/handlers/function.ts +311 -18
  107. package/src/protocol/handlers/shared.ts +12 -3
  108. package/src/protocol/handlers/table-buffering.ts +11 -8
  109. package/src/protocol/serializers/bind.ts +69 -67
  110. package/src/protocol/serializers/cardinality.ts +7 -7
  111. package/src/protocol/serializers/init.ts +52 -10
  112. package/src/protocol/serializers/splits.ts +221 -0
  113. package/src/protocol/state-serializer.ts +55 -1
  114. package/src/protocol/types.ts +36 -3
  115. package/src/request-auth.ts +73 -0
  116. package/src/schema-path.ts +25 -0
  117. package/src/serve-entry.ts +69 -2
  118. package/src/split-token.ts +297 -0
  119. package/src/types.ts +9 -0
  120. package/src/worker-cf-entry.ts +2 -1
  121. package/src/worker.ts +79 -14
@@ -1,4 +1,4 @@
1
- import { FunctionStability, NullHandling, OrderPreservation, OrderDependence, DistinctDependence } from "../types.js";
1
+ import { FunctionStability, NullHandling, ArgumentMonotonicity, OrderPreservation, OrderDependence, DistinctDependence } from "../types.js";
2
2
  export declare enum CatalogFunctionType {
3
3
  SCALAR = "SCALAR",
4
4
  TABLE = "TABLE",
@@ -23,6 +23,15 @@ export interface FunctionExample {
23
23
  description: string;
24
24
  expectedOutput: string | null;
25
25
  }
26
+ export interface FilterFunctionCapability {
27
+ namespace: string;
28
+ name: string;
29
+ version: number;
30
+ }
31
+ export interface EvaluationContextCapability {
32
+ profile: string;
33
+ providerFingerprint: string | null;
34
+ }
26
35
  export interface ResolvedMetadata {
27
36
  name: string;
28
37
  className: string;
@@ -34,12 +43,16 @@ export interface ResolvedMetadata {
34
43
  parameters: ParameterInfo[];
35
44
  stability: FunctionStability;
36
45
  nullHandling: NullHandling;
46
+ argumentMonotonicity: ArgumentMonotonicity[] | null;
37
47
  requiredSettings: string[];
38
48
  requiredSecrets: string[];
39
49
  projectionPushdown: boolean;
40
50
  filterPushdown: boolean;
41
51
  samplingPushdown: boolean;
42
- supportedExpressionFilters: string[];
52
+ filterSemanticProfiles: string[];
53
+ additionalFilterFunctions: FilterFunctionCapability[];
54
+ runtimeFilterAlgorithms: FilterFunctionCapability[];
55
+ filterEvaluationContexts: EvaluationContextCapability[];
43
56
  preservesOrder: OrderPreservation;
44
57
  maxWorkers: number | null;
45
58
  orderDependent: OrderDependence;
@@ -60,11 +60,3 @@ export declare function makeGetCatalog(catalog: CatalogInterface | undefined): G
60
60
  */
61
61
  export declare function decodeOptionsBatch(bytes: any): Record<string, unknown>;
62
62
  export declare const emptyResultSchema: VgiSchema;
63
- export declare const attachOpaqueDataParam: VgiSchema;
64
- export declare const attachOpaqueDataTxnParams: VgiSchema;
65
- export declare const attachOpaqueDataNameTxnParams: VgiSchema;
66
- export declare const attachOpaqueDataSchemaNameTxnParams: VgiSchema;
67
- export declare const schemaNameIgnoreNotFoundTxnParams: VgiSchema;
68
- export declare const schemaNameCommentParams: VgiSchema;
69
- export declare const schemaNameRenameParams: VgiSchema;
70
- export declare const columnOpParams: VgiSchema;
@@ -11,6 +11,17 @@ export interface FunctionHandlerConfig {
11
11
  */
12
12
  catalogInterface?: {
13
13
  catalogNameForAttach(a: Uint8Array): string | null;
14
+ /**
15
+ * The catalog's current version, which is the consistency anchor every split
16
+ * token is stamped with AND checked against.
17
+ *
18
+ * Both sides read it from here on purpose. Minting from a different value
19
+ * than redemption compares against is not a subtle bug: it refuses every
20
+ * token, and the documented response to SPLIT_SNAPSHOT_EXPIRED is "re-run
21
+ * the query", which re-plans, mints the same mismatch and fails again — a
22
+ * livelock returning no rows, blaming the data for moving when it has not.
23
+ */
24
+ version?(attach: Uint8Array, txn?: Uint8Array): number | Promise<number>;
14
25
  };
15
26
  }
16
27
  export declare function registerFunctionMethods(protocol: Protocol, config: FunctionHandlerConfig): void;
@@ -9,6 +9,8 @@ export declare const RESULT_BINARY_NULLABLE_SCHEMA: VgiSchema;
9
9
  * and return flat columns as a dict (row 0).
10
10
  */
11
11
  export declare function unwrapRequest(requestBytes: any): Record<string, any>;
12
+ /** Convert Arrow list scalars at RPC boundaries into ordinary string arrays. */
13
+ export declare function normalizeRequestSchemaPaths(params: Record<string, any>): void;
12
14
  /**
13
15
  * Wrap a dict of values into a single "result" Binary column.
14
16
  * Builds a 1-row batch from the values using the given schema,
@@ -22,7 +24,7 @@ export declare function overloadContext(req: {
22
24
  arguments: any;
23
25
  input_schema: any;
24
26
  function_type: any;
25
- schema_name?: string | null;
27
+ schema_path?: string[] | null;
26
28
  attach_opaque_data?: Uint8Array | null;
27
29
  }, catalogInterface?: {
28
30
  catalogNameForAttach(a: Uint8Array): string | null;
@@ -1,9 +1,8 @@
1
1
  import { type VgiSchema, type VgiBatch } from "../../arrow/index.js";
2
2
  import type { BindRequest, BindResponse } from "../types.js";
3
3
  declare const BIND_REQUEST_SCHEMA: VgiSchema;
4
- declare const BIND_RESPONSE_SCHEMA: VgiSchema;
5
4
  export declare function serializeBindRequest(req: BindRequest): VgiBatch;
6
5
  export declare function deserializeBindRequest(params: Record<string, any>): BindRequest;
7
6
  export declare function serializeBindResponse(resp: BindResponse): Record<string, any>;
8
7
  export declare function deserializeBindResponse(params: Record<string, any>): BindResponse;
9
- export { BIND_REQUEST_SCHEMA, BIND_RESPONSE_SCHEMA };
8
+ export { BIND_REQUEST_SCHEMA };
@@ -1,7 +1,6 @@
1
1
  import { type VgiSchema } from "../../arrow/index.js";
2
2
  import type { TableFunctionCardinalityRequest, TableCardinality } from "../types.js";
3
- declare const TABLE_CARDINALITY_SCHEMA: VgiSchema;
4
3
  declare const TABLE_FUNCTION_CARDINALITY_REQUEST_SCHEMA: VgiSchema;
5
4
  export declare function deserializeCardinalityRequest(params: Record<string, any>): TableFunctionCardinalityRequest;
6
5
  export declare function serializeTableCardinality(card: TableCardinality): Record<string, any>;
7
- export { TABLE_CARDINALITY_SCHEMA, TABLE_FUNCTION_CARDINALITY_REQUEST_SCHEMA };
6
+ export { TABLE_FUNCTION_CARDINALITY_REQUEST_SCHEMA };
@@ -0,0 +1,126 @@
1
+ import { type VgiSchema } from "../../arrow/index.js";
2
+ import type { BindRequest } from "../types.js";
3
+ /**
4
+ * One named, independently redeemable unit of scan work.
5
+ *
6
+ * A worker sets `payload` and nothing else; the framework stamps `token` from
7
+ * it, so an author cannot forget the consistency anchor or mis-bind the
8
+ * fingerprint. The client sends the TOKEN back, never the raw payload.
9
+ */
10
+ export interface ScanSplit {
11
+ /** The worker's own bytes NAMING this unit of work. */
12
+ payload: Uint8Array;
13
+ /** Framework-stamped envelope. Set by the framework, never by a worker. */
14
+ token?: Uint8Array;
15
+ estimatedRows?: number | bigint | null;
16
+ /** True if `estimatedRows` is exact — unlocks COUNT(*) from statistics. */
17
+ rowsExact?: boolean;
18
+ /**
19
+ * Load-bearing for engines that bin-pack (DataFusion weight, Trino
20
+ * SplitWeight). Omitting it degrades them to round-robin by count; a greedily
21
+ * claiming client needs no cost model at all.
22
+ */
23
+ estimatedBytes?: number | bigint | null;
24
+ /** 2-row (min, max) batch in the existing `vgi_partition_values` encoding. */
25
+ partitionBounds?: Uint8Array | null;
26
+ columnStatistics?: Uint8Array | null;
27
+ locationIds?: number[] | null;
28
+ startPosition?: Uint8Array | null;
29
+ /** Absent means UNBOUNDED — a shard read forever. */
30
+ endPosition?: Uint8Array | null;
31
+ }
32
+ /** What a table function's `plan` hook returns. */
33
+ export interface PlanResult {
34
+ /**
35
+ * One entry per unit of work. EMPTY is legal and means "no work": a
36
+ * fully-pruned scan reaches it, and the client must produce an empty result
37
+ * rather than an error.
38
+ */
39
+ splits: ScanSplit[];
40
+ /**
41
+ * Continued enumeration. More than one MUST partition the remaining
42
+ * enumeration disjointly and exhaustively. No client checks this: a dedup was
43
+ * tried and removed (it needed a set holding a copy of every token, it compared
44
+ * token bytes so it could never work on a keyed worker where each mint uses a
45
+ * fresh nonce, and the most a client can do with a duplicate is refuse anyway).
46
+ * Violating it returns DUPLICATE ROWS, silently.
47
+ */
48
+ nextCursors?: Uint8Array[];
49
+ /** NORMATIVE cap on redemption concurrency, not advisory. */
50
+ maxWorkers?: number | null;
51
+ estimatedTotalSplits?: number | bigint | null;
52
+ estimatedTotalRows?: number | bigint | null;
53
+ estimatedTotalBytes?: number | bigint | null;
54
+ /**
55
+ * The counter a stale token is detected against, and the anchor the framework
56
+ * stamps into every token in this plan.
57
+ */
58
+ catalogVersion?: number | bigint | null;
59
+ /**
60
+ * `catalog` (the default) or `transaction`. A transaction-scoped plan is not
61
+ * cacheable and is not redeemable after commit or rollback.
62
+ */
63
+ scope?: "catalog" | "transaction";
64
+ cacheMaxAgeSeconds?: number | null;
65
+ }
66
+ /** The request a client sends to divide a scan. */
67
+ export interface TableFunctionPlanRequest {
68
+ bind_call: BindRequest;
69
+ bind_opaque_data: Uint8Array | null;
70
+ projection_ids: number[] | null;
71
+ pushdown_filters: Uint8Array | null;
72
+ /** The primary sizing lever: every engine is byte-driven. */
73
+ target_split_bytes: bigint | null;
74
+ /**
75
+ * The parallelism FLOOR — a small but expensive table still needs one reader
76
+ * per thread, which a byte target alone would not give it.
77
+ */
78
+ min_splits: bigint | null;
79
+ /**
80
+ * A place in the ENUMERATION of splits — NOT a place in the data. A cursor
81
+ * lives for one plan call; a position is checkpointed and must survive
82
+ * restarts, upgrades and key rotation.
83
+ */
84
+ cursor: Uint8Array | null;
85
+ }
86
+ /**
87
+ * The ScanSplit shape, from codegen rather than hand-written.
88
+ *
89
+ * It used to be spelled out here, and hand-written is how four SDKs ended up
90
+ * disagreeing about which of these columns were binary and which were
91
+ * large_binary — a disagreement the client surfaced as "the worker bypassed the
92
+ * framework", on every scan.
93
+ */
94
+ export declare const SCAN_SPLIT_SCHEMA: VgiSchema;
95
+ /**
96
+ * The PlanResponse shape, taken from codegen rather than hand-written: it is
97
+ * regenerated from the canonical protocol, so it cannot drift.
98
+ */
99
+ export declare const PLAN_RESPONSE_SCHEMA: VgiSchema;
100
+ /**
101
+ * Decode a plan request.
102
+ *
103
+ * A client sends only the sizing inputs it actually has — the DuckDB extension
104
+ * sends seven columns, because it has no basis to invent a byte target it did
105
+ * not set — so every field but `bind_call` is read defensively.
106
+ */
107
+ export declare function deserializePlanRequest(params: Record<string, any>): TableFunctionPlanRequest;
108
+ /**
109
+ * The raw bind fields the split-token fingerprint is derived from.
110
+ *
111
+ * Read from the UNDECODED bind_call dict rather than the parsed BindRequest,
112
+ * because the fingerprint must be reproducible byte-for-byte between the plan
113
+ * that minted a token and the init that redeems it. A decoded-then-re-encoded
114
+ * argument list is not guaranteed to round-trip to identical bytes; the wire
115
+ * bytes are.
116
+ */
117
+ export declare function fingerprintInputs(bindCallBytes: Uint8Array): {
118
+ schemaPath: string[];
119
+ functionName: string;
120
+ args: Uint8Array;
121
+ settings: Uint8Array;
122
+ };
123
+ /** Build the row dict for one `ScanSplit`. */
124
+ export declare function scanSplitRow(split: ScanSplit, token: Uint8Array): Record<string, any>;
125
+ /** Build the row dict for a `PlanResponse`, given already-serialized splits. */
126
+ export declare function planResponseRow(result: PlanResult, splitBlobs: Uint8Array[]): Record<string, any>;
@@ -76,11 +76,17 @@ export interface BindRequest {
76
76
  /**
77
77
  * Catalog schema that declares the function being bound. A worker may
78
78
  * register the same name in more than one schema, so the bare name does not
79
- * identify an implementation — resolution is by `(schema_name,
79
+ * identify an implementation — resolution is by `(schema_path,
80
80
  * function_name)`. Null for callers with no catalog context (COPY handler
81
- * binds). Mirrors vgi-python's `BindRequest.schema_name`.
81
+ * binds). Mirrors vgi-python's `BindRequest.schema_path`.
82
82
  */
83
- schema_name?: string | null;
83
+ schema_path?: string[] | null;
84
+ /**
85
+ * Resolved name for every logical argument, in complete call order. Fixed
86
+ * parameters carry their declared names, unnamed varargs carry `null`, and
87
+ * named varargs retain the caller-provided name. `null` means unavailable.
88
+ */
89
+ argument_names?: (string | null)[] | null;
84
90
  }
85
91
  export interface BindResponse {
86
92
  output_schema: VgiSchema;
@@ -108,6 +114,33 @@ export interface InitRequest {
108
114
  * bytes the worker's combine() chose.
109
115
  */
110
116
  finalize_state_id: Uint8Array | null;
117
+ /**
118
+ * The framework-stamped split envelopes this init redeems, or null when this
119
+ * is not a split init.
120
+ *
121
+ * A LIST because an engine whose partition count IS its concurrency bin-packs
122
+ * at planning time and reads a whole group per partition; DuckDB always sends
123
+ * exactly one. A worker handed several concatenates them in the order given.
124
+ */
125
+ split_tokens: Uint8Array[] | null;
126
+ /**
127
+ * The VERIFIED payloads behind `split_tokens` — the worker's own bytes, with
128
+ * the envelope already opened and stripped.
129
+ *
130
+ * Populated by the protocol handler, which is what holds the signing key, so
131
+ * an unverified token never reaches a function. Null when this is not a split
132
+ * init.
133
+ */
134
+ split_payloads?: Uint8Array[] | null;
135
+ /**
136
+ * A plain fetch limit, when the engine can supply one.
137
+ *
138
+ * Always null from DuckDB — `TableFunctionInitInput` carries no limit, and
139
+ * the Top-N `order_by_limit` means something different ("top K by that
140
+ * column"). DataFusion supplies a real value via `TableProvider::scan(limit)`.
141
+ * Over-producing is legal; the engine re-applies the limit above the scan.
142
+ */
143
+ row_limit: number | null;
111
144
  execution_id: Uint8Array | null;
112
145
  init_opaque_data: Uint8Array | null;
113
146
  /**
@@ -0,0 +1,28 @@
1
+ import type { AuthContext } from "@query-farm/vgi-rpc";
2
+ /** Mutable per-request cell. The scope is opened before the identity is known
3
+ * (authentication happens inside the handler), so the holder is published
4
+ * first and filled in when the framework reports the principal. */
5
+ export interface RequestAuthHolder {
6
+ auth?: AuthContext;
7
+ }
8
+ /** The slice of `AsyncLocalStorage` this module needs. Structural on purpose:
9
+ * it keeps `node:async_hooks` out of every non-HTTP build, and lets a test
10
+ * install a trivial stub. */
11
+ export interface RequestAuthScope {
12
+ getStore(): RequestAuthHolder | undefined;
13
+ }
14
+ /**
15
+ * Publish the scope `currentRequestAuth()` reads. Called once per process by
16
+ * the HTTP entry point; idempotent for the same scope.
17
+ */
18
+ export declare function setRequestAuthScope(next: RequestAuthScope | undefined): void;
19
+ /**
20
+ * The authenticated principal of the request being served on this async
21
+ * context, or `undefined` when there is none — no scope installed (stdio /
22
+ * AF_UNIX / a host that has no `AsyncLocalStorage`), or an unauthenticated
23
+ * request.
24
+ *
25
+ * `undefined` and an anonymous `AuthContext` produce the same identity tail, so
26
+ * the two cases need not be distinguished by callers.
27
+ */
28
+ export declare function currentRequestAuth(): AuthContext | undefined;
@@ -0,0 +1,7 @@
1
+ /** Raw identifier components of a catalog schema, from root to leaf. */
2
+ export type SchemaPath = string[];
3
+ /** Case-insensitive key used for catalog lookup and function dispatch. */
4
+ export declare function normalizeSchemaPath(path: Iterable<unknown> | string): string[];
5
+ export declare function schemaPathKey(path: Iterable<unknown> | string): string;
6
+ export declare function schemaPathsEqual(left: Iterable<unknown> | string, right: Iterable<unknown> | string): boolean;
7
+ export declare function schemaPathDisplay(path: Iterable<unknown> | string): string;
@@ -1,5 +1,6 @@
1
1
  import type { CatalogInterface } from "./catalog/interface.js";
2
2
  import type { FunctionRegistry } from "./functions/registry.js";
3
+ import { type AuthenticateFn, type PeerResolutionOptions } from "@query-farm/vgi-rpc";
3
4
  /** Environment variables `serveVgiWorker` reads. Injectable for testing. */
4
5
  export interface ServeEnv {
5
6
  PORT?: string;
@@ -11,6 +12,20 @@ export declare const DEFAULT_PORT = 8787;
11
12
  export declare const DEFAULT_TOKEN_TTL = 3600;
12
13
  /** Bytes of HMAC key `createHttpHandler` expects; 64 hex characters. */
13
14
  export declare const SIGNING_KEY_BYTES = 32;
15
+ /** HTTP trust boundary for a colocated `vgi-iroh-bridge`. */
16
+ export interface IrohHttpBridgeOptions {
17
+ /** Worker-local namespace for EndpointId principals. */
18
+ issuer: string;
19
+ /** Exact bridge IP addresses. No CIDRs or hostnames. */
20
+ trustedProxyAddresses?: readonly string[];
21
+ /** Authenticate the EndpointId (default) or expose evidence only. */
22
+ authenticate?: boolean;
23
+ /**
24
+ * Host-specific physical peer and raw-header adapter. Required because a
25
+ * Fetch Request alone does not preserve duplicate header fields.
26
+ */
27
+ peerResolutionContext?: (request: Request) => PeerResolutionOptions | Promise<PeerResolutionOptions>;
28
+ }
14
29
  export interface ServeVgiWorkerOptions {
15
30
  /** Short worker name shown on the landing page, e.g. "ishares". */
16
31
  name: string;
@@ -26,6 +41,8 @@ export interface ServeVgiWorkerOptions {
26
41
  repositoryUrl?: string;
27
42
  /** Overrides `$PORT` (default 8787). Pass 0 to bind an ephemeral port. */
28
43
  port?: number;
44
+ /** Bind address. Iroh bridge mode defaults to loopback; otherwise Bun's default. */
45
+ hostname?: string;
29
46
  /** Overrides `$VGI_SIGNING_KEY`. 32 bytes. */
30
47
  signingKey?: Uint8Array;
31
48
  /** Overrides `$VGI_TOKEN_TTL` (default 3600 seconds). */
@@ -40,12 +57,20 @@ export interface ServeVgiWorkerOptions {
40
57
  quiet?: boolean;
41
58
  /** Environment source (default `process.env`). */
42
59
  env?: ServeEnv;
60
+ /** Authenticates each request, returning the caller's `AuthContext`.
61
+ * Omit for an anonymous worker (the default). */
62
+ authenticate?: AuthenticateFn;
63
+ /** Preserve authenticated Iroh identity forwarded by an adjacent HTTP bridge. */
64
+ irohBridge?: IrohHttpBridgeOptions;
43
65
  }
44
66
  /** The slice of `Bun.serve`'s return value this module uses. */
45
67
  export interface VgiHttpServer {
46
68
  readonly port: number;
47
69
  readonly url: URL;
48
70
  stop(closeActiveConnections?: boolean): void;
71
+ requestIP?(request: Request): {
72
+ address: string;
73
+ } | null;
49
74
  }
50
75
  /**
51
76
  * Decode a 32-byte signing key from its hex representation.