presubmit 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 (220) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +51 -0
  3. package/THIRD_PARTY_NOTICES.md +24 -0
  4. package/apps/web/dist/assets/FileCode-CZZH52o7.js +5 -0
  5. package/apps/web/dist/assets/FileCode-DovDO7Jh.css +1 -0
  6. package/apps/web/dist/assets/SettingsPage-CRvOwdjt.js +4 -0
  7. package/apps/web/dist/assets/SettingsPage-UbYSCwJj.css +1 -0
  8. package/apps/web/dist/assets/TerminalPanel-0sw-J6YS.css +1 -0
  9. package/apps/web/dist/assets/TerminalPanel-BqUjPWav.js +16 -0
  10. package/apps/web/dist/assets/index-BhqNNFja.js +54 -0
  11. package/apps/web/dist/assets/index-DD8VXy8H.css +1 -0
  12. package/apps/web/dist/assets/presubmit-mark-BBQ19Fmr.svg +7 -0
  13. package/apps/web/dist/assets/presubmit-mark-busy-CwBC-7on.svg +8 -0
  14. package/apps/web/dist/assets/react-vendor-wiHys0m2.js +9 -0
  15. package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
  16. package/apps/web/dist/index.html +6 -0
  17. package/apps/web/dist/service-worker.js +11 -0
  18. package/dist/apps/server/src/agent-builder.js +204 -0
  19. package/dist/apps/server/src/attach.js +163 -0
  20. package/dist/apps/server/src/attachments.js +86 -0
  21. package/dist/apps/server/src/browser-access.js +131 -0
  22. package/dist/apps/server/src/check-provenance.js +95 -0
  23. package/dist/apps/server/src/check-supervisor.js +112 -0
  24. package/dist/apps/server/src/checks.js +402 -0
  25. package/dist/apps/server/src/child-collaboration-guidance.js +2 -0
  26. package/dist/apps/server/src/child-sessions.js +191 -0
  27. package/dist/apps/server/src/cli.js +162 -0
  28. package/dist/apps/server/src/conversation-search.js +12 -0
  29. package/dist/apps/server/src/coordinator-messages.js +72 -0
  30. package/dist/apps/server/src/dev-auth.js +54 -0
  31. package/dist/apps/server/src/dev-server.js +201 -0
  32. package/dist/apps/server/src/dev-worker.js +48 -0
  33. package/dist/apps/server/src/diagnostics.js +105 -0
  34. package/dist/apps/server/src/fast-mode.js +8 -0
  35. package/dist/apps/server/src/folder-picker.js +54 -0
  36. package/dist/apps/server/src/git-blobs.js +62 -0
  37. package/dist/apps/server/src/git-handoff.js +127 -0
  38. package/dist/apps/server/src/history-sources.js +59 -0
  39. package/dist/apps/server/src/hub.js +159 -0
  40. package/dist/apps/server/src/internal-transport.js +38 -0
  41. package/dist/apps/server/src/local-embeddings.js +70 -0
  42. package/dist/apps/server/src/ollama-setup.js +56 -0
  43. package/dist/apps/server/src/planning.js +30 -0
  44. package/dist/apps/server/src/project-agents.js +276 -0
  45. package/dist/apps/server/src/project-memory.js +94 -0
  46. package/dist/apps/server/src/projects.js +106 -0
  47. package/dist/apps/server/src/queued-launch.js +13 -0
  48. package/dist/apps/server/src/reply-search.js +172 -0
  49. package/dist/apps/server/src/review-context.js +60 -0
  50. package/dist/apps/server/src/review-refresh.js +14 -0
  51. package/dist/apps/server/src/reviewers.js +75 -0
  52. package/dist/apps/server/src/search-settings.js +22 -0
  53. package/dist/apps/server/src/semantic-history.js +186 -0
  54. package/dist/apps/server/src/server.js +4338 -0
  55. package/dist/apps/server/src/session-changes.js +181 -0
  56. package/dist/apps/server/src/session-router-settings.js +198 -0
  57. package/dist/apps/server/src/session-workspaces.js +135 -0
  58. package/dist/apps/server/src/sessions.js +579 -0
  59. package/dist/apps/server/src/shared-auth.js +70 -0
  60. package/dist/apps/server/src/shell-evaluator-settings.js +53 -0
  61. package/dist/apps/server/src/store.js +203 -0
  62. package/dist/apps/server/src/tailscale-process.js +115 -0
  63. package/dist/apps/server/src/tailscale-serve-worker.js +33 -0
  64. package/dist/apps/server/src/tailscale-serve.js +276 -0
  65. package/dist/apps/server/src/task-capacity.js +92 -0
  66. package/dist/apps/server/src/task-graph.js +190 -0
  67. package/dist/apps/server/src/task-logs.js +74 -0
  68. package/dist/apps/server/src/task-numbers.js +25 -0
  69. package/dist/apps/server/src/task-orchestrator.js +1088 -0
  70. package/dist/apps/server/src/terminal.js +182 -0
  71. package/dist/apps/server/src/terminals.js +80 -0
  72. package/dist/apps/server/src/tool-safety.js +2 -0
  73. package/dist/apps/server/src/workspace-lock.js +140 -0
  74. package/dist/apps/server/src/workspace-watcher.js +65 -0
  75. package/dist/apps/server/src/workspace.js +517 -0
  76. package/dist/packages/agent-pi/src/agent-builder-tool.js +32 -0
  77. package/dist/packages/agent-pi/src/agent-capabilities.js +44 -0
  78. package/dist/packages/agent-pi/src/ask-user.js +86 -0
  79. package/dist/packages/agent-pi/src/auth.js +510 -0
  80. package/dist/packages/agent-pi/src/check-tools.js +72 -0
  81. package/dist/packages/agent-pi/src/command-policy.js +246 -0
  82. package/dist/packages/agent-pi/src/coordinator-tools.js +122 -0
  83. package/dist/packages/agent-pi/src/fast-mode.js +67 -0
  84. package/dist/packages/agent-pi/src/file-tools.js +163 -0
  85. package/dist/packages/agent-pi/src/history-tool.js +40 -0
  86. package/dist/packages/agent-pi/src/history.js +34 -0
  87. package/dist/packages/agent-pi/src/index.js +177 -0
  88. package/dist/packages/agent-pi/src/ipc.js +314 -0
  89. package/dist/packages/agent-pi/src/jev-session-router.js +408 -0
  90. package/dist/packages/agent-pi/src/jev-tools.js +71 -0
  91. package/dist/packages/agent-pi/src/local-model.js +277 -0
  92. package/dist/packages/agent-pi/src/memory-tools.js +119 -0
  93. package/dist/packages/agent-pi/src/model.js +25 -0
  94. package/dist/packages/agent-pi/src/planning.js +206 -0
  95. package/dist/packages/agent-pi/src/resource-loader.js +23 -0
  96. package/dist/packages/agent-pi/src/review-tools.js +158 -0
  97. package/dist/packages/agent-pi/src/review-transition.js +73 -0
  98. package/dist/packages/agent-pi/src/review.js +40 -0
  99. package/dist/packages/agent-pi/src/routing.js +27 -0
  100. package/dist/packages/agent-pi/src/session-setup.js +118 -0
  101. package/dist/packages/agent-pi/src/shell-context.js +51 -0
  102. package/dist/packages/agent-pi/src/shell-policy.js +281 -0
  103. package/dist/packages/agent-pi/src/shell-safety.js +205 -0
  104. package/dist/packages/agent-pi/src/shell.js +121 -0
  105. package/dist/packages/agent-pi/src/snapshot-permissions.js +12 -0
  106. package/dist/packages/agent-pi/src/spike.js +41 -0
  107. package/dist/packages/agent-pi/src/task-tools.js +53 -0
  108. package/dist/packages/agent-pi/src/types.js +1 -0
  109. package/dist/packages/agent-pi/src/usage.js +30 -0
  110. package/dist/packages/agent-pi/src/worker.js +602 -0
  111. package/dist/packages/protocol/src/activity-summary.js +77 -0
  112. package/dist/packages/protocol/src/agents.js +301 -0
  113. package/dist/packages/protocol/src/browser-access.js +1 -0
  114. package/dist/packages/protocol/src/checks.js +40 -0
  115. package/dist/packages/protocol/src/child-sessions.js +28 -0
  116. package/dist/packages/protocol/src/command-policy.js +3 -0
  117. package/dist/packages/protocol/src/coordinator.js +135 -0
  118. package/dist/packages/protocol/src/delegation.js +40 -0
  119. package/dist/packages/protocol/src/git-diff.js +71 -0
  120. package/dist/packages/protocol/src/git-handoff.js +1 -0
  121. package/dist/packages/protocol/src/index.js +1 -0
  122. package/dist/packages/protocol/src/memory.js +46 -0
  123. package/dist/packages/protocol/src/metrics.js +70 -0
  124. package/dist/packages/protocol/src/planning.js +138 -0
  125. package/dist/packages/protocol/src/retrieval.js +36 -0
  126. package/dist/packages/protocol/src/reviewers.js +17 -0
  127. package/dist/packages/protocol/src/search.js +16 -0
  128. package/dist/packages/protocol/src/session-changes.js +29 -0
  129. package/dist/packages/protocol/src/session-router.js +123 -0
  130. package/dist/packages/protocol/src/shell-evaluator.js +43 -0
  131. package/dist/packages/protocol/src/task-graph.js +1 -0
  132. package/dist/packages/protocol/src/token-usage.js +17 -0
  133. package/dist/packages/protocol/src/user-questions.js +106 -0
  134. package/package.json +71 -0
  135. package/vendor/lancedb/NODEJS_THIRD_PARTY_LICENSES.md +668 -0
  136. package/vendor/lancedb/RUST_THIRD_PARTY_LICENSES.html +14607 -0
  137. package/vendor/lancedb/dist/arrow.d.ts +296 -0
  138. package/vendor/lancedb/dist/arrow.js +1145 -0
  139. package/vendor/lancedb/dist/arrow_type.d.ts +9 -0
  140. package/vendor/lancedb/dist/arrow_type.js +29 -0
  141. package/vendor/lancedb/dist/connection.d.ts +508 -0
  142. package/vendor/lancedb/dist/connection.js +298 -0
  143. package/vendor/lancedb/dist/embedding/embedding_function.d.ts +103 -0
  144. package/vendor/lancedb/dist/embedding/embedding_function.js +192 -0
  145. package/vendor/lancedb/dist/embedding/index.d.ts +37 -0
  146. package/vendor/lancedb/dist/embedding/index.js +108 -0
  147. package/vendor/lancedb/dist/embedding/openai.d.ts +16 -0
  148. package/vendor/lancedb/dist/embedding/openai.js +81 -0
  149. package/vendor/lancedb/dist/embedding/registry.d.ts +94 -0
  150. package/vendor/lancedb/dist/embedding/registry.js +221 -0
  151. package/vendor/lancedb/dist/embedding/transformers.d.ts +36 -0
  152. package/vendor/lancedb/dist/embedding/transformers.js +110 -0
  153. package/vendor/lancedb/dist/header.d.ts +162 -0
  154. package/vendor/lancedb/dist/header.js +217 -0
  155. package/vendor/lancedb/dist/index.d.ts +246 -0
  156. package/vendor/lancedb/dist/index.js +176 -0
  157. package/vendor/lancedb/dist/indices.d.ts +721 -0
  158. package/vendor/lancedb/dist/indices.js +166 -0
  159. package/vendor/lancedb/dist/materialized_view.d.ts +69 -0
  160. package/vendor/lancedb/dist/materialized_view.js +112 -0
  161. package/vendor/lancedb/dist/merge.d.ts +104 -0
  162. package/vendor/lancedb/dist/merge.js +120 -0
  163. package/vendor/lancedb/dist/native.d.ts +1193 -0
  164. package/vendor/lancedb/dist/native.js +688 -0
  165. package/vendor/lancedb/dist/oauth.d.ts +66 -0
  166. package/vendor/lancedb/dist/oauth.js +15 -0
  167. package/vendor/lancedb/dist/otel.d.ts +26 -0
  168. package/vendor/lancedb/dist/otel.js +114 -0
  169. package/vendor/lancedb/dist/permutation.d.ts +143 -0
  170. package/vendor/lancedb/dist/permutation.js +184 -0
  171. package/vendor/lancedb/dist/query.d.ts +663 -0
  172. package/vendor/lancedb/dist/query.js +966 -0
  173. package/vendor/lancedb/dist/rerankers/index.d.ts +5 -0
  174. package/vendor/lancedb/dist/rerankers/index.js +19 -0
  175. package/vendor/lancedb/dist/rerankers/rrf.d.ts +14 -0
  176. package/vendor/lancedb/dist/rerankers/rrf.js +28 -0
  177. package/vendor/lancedb/dist/sanitize.d.ts +32 -0
  178. package/vendor/lancedb/dist/sanitize.js +544 -0
  179. package/vendor/lancedb/dist/scannable.d.ts +92 -0
  180. package/vendor/lancedb/dist/scannable.js +200 -0
  181. package/vendor/lancedb/dist/schema.d.ts +16 -0
  182. package/vendor/lancedb/dist/schema.js +387 -0
  183. package/vendor/lancedb/dist/table.d.ts +1069 -0
  184. package/vendor/lancedb/dist/table.js +498 -0
  185. package/vendor/lancedb/dist/util.d.ts +14 -0
  186. package/vendor/lancedb/dist/util.js +77 -0
  187. package/vendor/lancedb/license_header.txt +2 -0
  188. package/vendor/lancedb/package.json +56 -0
  189. package/vendor/transformers/LICENSE +202 -0
  190. package/vendor/transformers/dist/transformers.cjs +30844 -0
  191. package/vendor/transformers/dist/transformers.mjs +31404 -0
  192. package/vendor/transformers/package.json +55 -0
  193. package/vendor/transformers/types/backends/onnx.d.ts +30 -0
  194. package/vendor/transformers/types/configs.d.ts +85 -0
  195. package/vendor/transformers/types/env.d.ts +110 -0
  196. package/vendor/transformers/types/generation/configuration_utils.d.ts +320 -0
  197. package/vendor/transformers/types/generation/logits_process.d.ts +354 -0
  198. package/vendor/transformers/types/generation/logits_sampler.d.ts +51 -0
  199. package/vendor/transformers/types/generation/parameters.d.ts +47 -0
  200. package/vendor/transformers/types/generation/stopping_criteria.d.ts +81 -0
  201. package/vendor/transformers/types/generation/streamers.d.ts +81 -0
  202. package/vendor/transformers/types/models/whisper/common_whisper.d.ts +8 -0
  203. package/vendor/transformers/types/models/whisper/generation_whisper.d.ts +76 -0
  204. package/vendor/transformers/types/models.d.ts +3684 -0
  205. package/vendor/transformers/types/ops/registry.d.ts +11 -0
  206. package/vendor/transformers/types/pipelines.d.ts +2402 -0
  207. package/vendor/transformers/types/processors.d.ts +924 -0
  208. package/vendor/transformers/types/tokenizers.d.ts +990 -0
  209. package/vendor/transformers/types/transformers.d.ts +13 -0
  210. package/vendor/transformers/types/utils/audio.d.ts +130 -0
  211. package/vendor/transformers/types/utils/constants.d.ts +2 -0
  212. package/vendor/transformers/types/utils/core.d.ts +98 -0
  213. package/vendor/transformers/types/utils/data-structures.d.ts +236 -0
  214. package/vendor/transformers/types/utils/devices.d.ts +18 -0
  215. package/vendor/transformers/types/utils/dtypes.d.ts +19 -0
  216. package/vendor/transformers/types/utils/generic.d.ts +11 -0
  217. package/vendor/transformers/types/utils/hub.d.ts +152 -0
  218. package/vendor/transformers/types/utils/image.d.ts +119 -0
  219. package/vendor/transformers/types/utils/maths.d.ts +280 -0
  220. package/vendor/transformers/types/utils/tensor.d.ts +418 -0
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Header providers for LanceDB remote connections.
3
+ *
4
+ * This module provides a flexible header management framework for LanceDB remote
5
+ * connections, allowing users to implement custom header strategies for
6
+ * authentication, request tracking, custom metadata, or any other header-based
7
+ * requirements.
8
+ *
9
+ * @module header
10
+ */
11
+ /**
12
+ * Abstract base class for providing custom headers for each request.
13
+ *
14
+ * Users can implement this interface to provide dynamic headers for various purposes
15
+ * such as authentication (OAuth tokens, API keys), request tracking (correlation IDs),
16
+ * custom metadata, or any other header-based requirements. The provider is called
17
+ * before each request to ensure fresh header values are always used.
18
+ *
19
+ * @example
20
+ * Simple JWT token provider:
21
+ * ```typescript
22
+ * class JWTProvider extends HeaderProvider {
23
+ * constructor(private token: string) {
24
+ * super();
25
+ * }
26
+ *
27
+ * getHeaders(): Record<string, string> {
28
+ * return { authorization: `Bearer ${this.token}` };
29
+ * }
30
+ * }
31
+ * ```
32
+ *
33
+ * @example
34
+ * Provider with request tracking:
35
+ * ```typescript
36
+ * class RequestTrackingProvider extends HeaderProvider {
37
+ * constructor(private sessionId: string) {
38
+ * super();
39
+ * }
40
+ *
41
+ * getHeaders(): Record<string, string> {
42
+ * return {
43
+ * "X-Session-Id": this.sessionId,
44
+ * "X-Request-Id": `req-${Date.now()}`
45
+ * };
46
+ * }
47
+ * }
48
+ * ```
49
+ */
50
+ export declare abstract class HeaderProvider {
51
+ /**
52
+ * Get the latest headers to be added to requests.
53
+ *
54
+ * This method is called before each request to the remote LanceDB server.
55
+ * Implementations should return headers that will be merged with existing headers.
56
+ *
57
+ * @returns Dictionary of header names to values to add to the request.
58
+ * @throws If unable to fetch headers, the exception will be propagated and the request will fail.
59
+ */
60
+ abstract getHeaders(): Record<string, string>;
61
+ }
62
+ /**
63
+ * Example implementation: A simple header provider that returns static headers.
64
+ *
65
+ * This is an example implementation showing how to create a HeaderProvider
66
+ * for cases where headers don't change during the session.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const provider = new StaticHeaderProvider({
71
+ * authorization: "Bearer my-token",
72
+ * "X-Custom-Header": "custom-value"
73
+ * });
74
+ * const headers = provider.getHeaders();
75
+ * // Returns: {authorization: 'Bearer my-token', 'X-Custom-Header': 'custom-value'}
76
+ * ```
77
+ */
78
+ export declare class StaticHeaderProvider extends HeaderProvider {
79
+ private _headers;
80
+ /**
81
+ * Initialize with static headers.
82
+ * @param headers - Headers to return for every request.
83
+ */
84
+ constructor(headers: Record<string, string>);
85
+ /**
86
+ * Return the static headers.
87
+ * @returns Copy of the static headers.
88
+ */
89
+ getHeaders(): Record<string, string>;
90
+ }
91
+ /**
92
+ * Token response from OAuth provider.
93
+ * @public
94
+ */
95
+ export interface TokenResponse {
96
+ accessToken: string;
97
+ expiresIn?: number;
98
+ }
99
+ /**
100
+ * Example implementation: OAuth token provider with automatic refresh.
101
+ *
102
+ * This is an example implementation showing how to manage OAuth tokens
103
+ * with automatic refresh when they expire.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * async function fetchToken(): Promise<TokenResponse> {
108
+ * const response = await fetch("https://oauth.example.com/token", {
109
+ * method: "POST",
110
+ * body: JSON.stringify({
111
+ * grant_type: "client_credentials",
112
+ * client_id: "your-client-id",
113
+ * client_secret: "your-client-secret"
114
+ * }),
115
+ * headers: { "Content-Type": "application/json" }
116
+ * });
117
+ * const data = await response.json();
118
+ * return {
119
+ * accessToken: data.access_token,
120
+ * expiresIn: data.expires_in
121
+ * };
122
+ * }
123
+ *
124
+ * const provider = new OAuthHeaderProvider(fetchToken);
125
+ * const headers = provider.getHeaders();
126
+ * // Returns: {"authorization": "Bearer <your-token>"}
127
+ * ```
128
+ */
129
+ export declare class OAuthHeaderProvider extends HeaderProvider {
130
+ private _tokenFetcher;
131
+ private _refreshBufferSeconds;
132
+ private _currentToken;
133
+ private _tokenExpiresAt;
134
+ private _refreshPromise;
135
+ /**
136
+ * Initialize the OAuth provider.
137
+ * @param tokenFetcher - Function to fetch new tokens. Should return object with 'accessToken' and optionally 'expiresIn'.
138
+ * @param refreshBufferSeconds - Seconds before expiry to refresh token. Default 300 (5 minutes).
139
+ */
140
+ constructor(tokenFetcher: () => Promise<TokenResponse> | TokenResponse, refreshBufferSeconds?: number);
141
+ /**
142
+ * Check if token needs refresh.
143
+ */
144
+ private _needsRefresh;
145
+ /**
146
+ * Refresh the token if it's expired or close to expiring.
147
+ */
148
+ private _refreshTokenIfNeeded;
149
+ /**
150
+ * Get OAuth headers, refreshing token if needed.
151
+ * Note: This is synchronous for now as the Rust implementation expects sync.
152
+ * In a real implementation, this would need to handle async properly.
153
+ * @returns Headers with Bearer token authorization.
154
+ * @throws If unable to fetch or refresh token.
155
+ */
156
+ getHeaders(): Record<string, string>;
157
+ /**
158
+ * Manually refresh the token.
159
+ * Call this before using getHeaders() to ensure token is available.
160
+ */
161
+ refreshToken(): Promise<void>;
162
+ }
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // SPDX-FileCopyrightText: Copyright The LanceDB Authors
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.OAuthHeaderProvider = exports.StaticHeaderProvider = exports.HeaderProvider = void 0;
6
+ /**
7
+ * Header providers for LanceDB remote connections.
8
+ *
9
+ * This module provides a flexible header management framework for LanceDB remote
10
+ * connections, allowing users to implement custom header strategies for
11
+ * authentication, request tracking, custom metadata, or any other header-based
12
+ * requirements.
13
+ *
14
+ * @module header
15
+ */
16
+ /**
17
+ * Abstract base class for providing custom headers for each request.
18
+ *
19
+ * Users can implement this interface to provide dynamic headers for various purposes
20
+ * such as authentication (OAuth tokens, API keys), request tracking (correlation IDs),
21
+ * custom metadata, or any other header-based requirements. The provider is called
22
+ * before each request to ensure fresh header values are always used.
23
+ *
24
+ * @example
25
+ * Simple JWT token provider:
26
+ * ```typescript
27
+ * class JWTProvider extends HeaderProvider {
28
+ * constructor(private token: string) {
29
+ * super();
30
+ * }
31
+ *
32
+ * getHeaders(): Record<string, string> {
33
+ * return { authorization: `Bearer ${this.token}` };
34
+ * }
35
+ * }
36
+ * ```
37
+ *
38
+ * @example
39
+ * Provider with request tracking:
40
+ * ```typescript
41
+ * class RequestTrackingProvider extends HeaderProvider {
42
+ * constructor(private sessionId: string) {
43
+ * super();
44
+ * }
45
+ *
46
+ * getHeaders(): Record<string, string> {
47
+ * return {
48
+ * "X-Session-Id": this.sessionId,
49
+ * "X-Request-Id": `req-${Date.now()}`
50
+ * };
51
+ * }
52
+ * }
53
+ * ```
54
+ */
55
+ class HeaderProvider {
56
+ }
57
+ exports.HeaderProvider = HeaderProvider;
58
+ /**
59
+ * Example implementation: A simple header provider that returns static headers.
60
+ *
61
+ * This is an example implementation showing how to create a HeaderProvider
62
+ * for cases where headers don't change during the session.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const provider = new StaticHeaderProvider({
67
+ * authorization: "Bearer my-token",
68
+ * "X-Custom-Header": "custom-value"
69
+ * });
70
+ * const headers = provider.getHeaders();
71
+ * // Returns: {authorization: 'Bearer my-token', 'X-Custom-Header': 'custom-value'}
72
+ * ```
73
+ */
74
+ class StaticHeaderProvider extends HeaderProvider {
75
+ _headers;
76
+ /**
77
+ * Initialize with static headers.
78
+ * @param headers - Headers to return for every request.
79
+ */
80
+ constructor(headers) {
81
+ super();
82
+ this._headers = { ...headers };
83
+ }
84
+ /**
85
+ * Return the static headers.
86
+ * @returns Copy of the static headers.
87
+ */
88
+ getHeaders() {
89
+ return { ...this._headers };
90
+ }
91
+ }
92
+ exports.StaticHeaderProvider = StaticHeaderProvider;
93
+ /**
94
+ * Example implementation: OAuth token provider with automatic refresh.
95
+ *
96
+ * This is an example implementation showing how to manage OAuth tokens
97
+ * with automatic refresh when they expire.
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * async function fetchToken(): Promise<TokenResponse> {
102
+ * const response = await fetch("https://oauth.example.com/token", {
103
+ * method: "POST",
104
+ * body: JSON.stringify({
105
+ * grant_type: "client_credentials",
106
+ * client_id: "your-client-id",
107
+ * client_secret: "your-client-secret"
108
+ * }),
109
+ * headers: { "Content-Type": "application/json" }
110
+ * });
111
+ * const data = await response.json();
112
+ * return {
113
+ * accessToken: data.access_token,
114
+ * expiresIn: data.expires_in
115
+ * };
116
+ * }
117
+ *
118
+ * const provider = new OAuthHeaderProvider(fetchToken);
119
+ * const headers = provider.getHeaders();
120
+ * // Returns: {"authorization": "Bearer <your-token>"}
121
+ * ```
122
+ */
123
+ class OAuthHeaderProvider extends HeaderProvider {
124
+ _tokenFetcher;
125
+ _refreshBufferSeconds;
126
+ _currentToken = null;
127
+ _tokenExpiresAt = null;
128
+ _refreshPromise = null;
129
+ /**
130
+ * Initialize the OAuth provider.
131
+ * @param tokenFetcher - Function to fetch new tokens. Should return object with 'accessToken' and optionally 'expiresIn'.
132
+ * @param refreshBufferSeconds - Seconds before expiry to refresh token. Default 300 (5 minutes).
133
+ */
134
+ constructor(tokenFetcher, refreshBufferSeconds = 300) {
135
+ super();
136
+ this._tokenFetcher = tokenFetcher;
137
+ this._refreshBufferSeconds = refreshBufferSeconds;
138
+ }
139
+ /**
140
+ * Check if token needs refresh.
141
+ */
142
+ _needsRefresh() {
143
+ if (this._currentToken === null) {
144
+ return true;
145
+ }
146
+ if (this._tokenExpiresAt === null) {
147
+ // No expiration info, assume token is valid
148
+ return false;
149
+ }
150
+ // Refresh if we're within the buffer time of expiration
151
+ const now = Date.now() / 1000;
152
+ return now >= this._tokenExpiresAt - this._refreshBufferSeconds;
153
+ }
154
+ /**
155
+ * Refresh the token if it's expired or close to expiring.
156
+ */
157
+ async _refreshTokenIfNeeded() {
158
+ if (!this._needsRefresh()) {
159
+ return;
160
+ }
161
+ // If refresh is already in progress, wait for it
162
+ if (this._refreshPromise) {
163
+ await this._refreshPromise;
164
+ return;
165
+ }
166
+ // Start refresh
167
+ this._refreshPromise = (async () => {
168
+ try {
169
+ const tokenData = await this._tokenFetcher();
170
+ this._currentToken = tokenData.accessToken;
171
+ if (!this._currentToken) {
172
+ throw new Error("Token fetcher did not return 'accessToken'");
173
+ }
174
+ // Set expiration if provided
175
+ if (tokenData.expiresIn) {
176
+ this._tokenExpiresAt = Date.now() / 1000 + tokenData.expiresIn;
177
+ }
178
+ else {
179
+ // Token doesn't expire or expiration unknown
180
+ this._tokenExpiresAt = null;
181
+ }
182
+ }
183
+ finally {
184
+ this._refreshPromise = null;
185
+ }
186
+ })();
187
+ await this._refreshPromise;
188
+ }
189
+ /**
190
+ * Get OAuth headers, refreshing token if needed.
191
+ * Note: This is synchronous for now as the Rust implementation expects sync.
192
+ * In a real implementation, this would need to handle async properly.
193
+ * @returns Headers with Bearer token authorization.
194
+ * @throws If unable to fetch or refresh token.
195
+ */
196
+ getHeaders() {
197
+ // For simplicity in this example, we assume the token is already fetched
198
+ // In a real implementation, this would need to handle the async nature properly
199
+ if (!this._currentToken && !this._refreshPromise) {
200
+ // Synchronously trigger refresh - this is a limitation of the current implementation
201
+ throw new Error("Token not initialized. Call refreshToken() first or use async initialization.");
202
+ }
203
+ if (!this._currentToken) {
204
+ throw new Error("Failed to obtain OAuth token");
205
+ }
206
+ return { authorization: `Bearer ${this._currentToken}` };
207
+ }
208
+ /**
209
+ * Manually refresh the token.
210
+ * Call this before using getHeaders() to ensure token is available.
211
+ */
212
+ async refreshToken() {
213
+ this._currentToken = null; // Force refresh
214
+ await this._refreshTokenIfNeeded();
215
+ }
216
+ }
217
+ exports.OAuthHeaderProvider = OAuthHeaderProvider;
@@ -0,0 +1,246 @@
1
+ import { Connection } from "./connection";
2
+ import { ConnectNamespaceOptions, ConnectionOptions, Session } from "./native.js";
3
+ import { HeaderProvider } from "./header";
4
+ import type { BaseTokenizer } from "./indices";
5
+ import type { FtsToken } from "./table";
6
+ export { MaterializedView, MaterializedViewDefinition, MaterializedViewSelect, } from "./materialized_view";
7
+ export { JsHeaderProvider as NativeJsHeaderProvider } from "./native.js";
8
+ export { instrumentLanceDbMetrics } from "./otel";
9
+ export { AddColumnsSql, ConnectionOptions, ConnectNamespaceOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, TlsConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, BranchContents, MergeResult, AddResult, AddColumnsResult, RefreshColumnResult, RefreshMaterializedViewResult, AlterColumnsResult, UpdateFieldMetadataResult, DeleteResult, DropColumnsResult, UpdateResult, SplitCalculatedOptions, SplitRandomOptions, SplitHashOptions, SplitSequentialOptions, ShuffleOptions, OAuthConfig as NativeOAuthConfig, } from "./native.js";
10
+ export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
11
+ export { Connection, CreateTableOptions, TableNamesOptions, ListTablesOptions, OpenTableOptions, ListNamespacesOptions, CreateNamespaceOptions, DropNamespaceOptions, ListNamespacesResponse, ListTablesResponse, CreateNamespaceResponse, DropNamespaceResponse, DescribeNamespaceResponse, RenameTableOptions, } from "./connection";
12
+ export { Job, JobDescription, JobFailureInfo, JobInfo, Session, } from "./native.js";
13
+ export { AutoQuery, ExecutableQuery, Query, QueryBase, VectorQuery, TakeQuery, AnalyzePlanDistributedMetrics, QueryExecutionOptions, ColumnOrdering, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, BooleanQuery, FullTextQueryType, Operator, Occur, } from "./query";
14
+ export { Index, IndexOptions, IvfPqOptions, IvfRqOptions, IvfFlatOptions, HnswPqOptions, HnswSqOptions, FtsOptions, BaseTokenizer, } from "./indices";
15
+ export { Table, Branches, BranchColumnSummary, BranchColumnChange, BranchIndexSummary, BranchRowCountSummary, CherryPickError, BranchDiff, CherryPickPreview, CherryPickResult, AddDataOptions, UpdateOptions, OptimizeOptions, Version, WriteProgress, FtsToken, TokenizeTableOptions, LsmWriteSpec, LsmStats, BucketStats, GenerationStats, MemtableStats, ColumnAlteration, FieldMetadataUpdate, } from "./table";
16
+ export { HeaderProvider, StaticHeaderProvider, OAuthHeaderProvider, TokenResponse, } from "./header";
17
+ export { OAuthConfig, OAuthFlowType } from "./oauth";
18
+ export { MergeInsertBuilder, WriteExecutionOptions } from "./merge";
19
+ export * as embedding from "./embedding";
20
+ export { permutationBuilder, PermutationBuilder } from "./permutation";
21
+ export { Scannable, ScannableOptions } from "./scannable";
22
+ export * as rerankers from "./rerankers";
23
+ export { SchemaLike, TableLike, FieldLike, RecordBatchLike, DataLike, IntoVector, MultiVector, } from "./arrow";
24
+ export { IntoSql, packBits } from "./util";
25
+ /**
26
+ * Options for tokenizing a full-text search query without a table index.
27
+ */
28
+ export interface TokenizeOptions {
29
+ /**
30
+ * The tokenizer to use. The default is "simple".
31
+ */
32
+ baseTokenizer?: BaseTokenizer;
33
+ /** Language for stemming and stop words. */
34
+ language?: string;
35
+ /** Maximum token length; tokens longer than this are ignored. */
36
+ maxTokenLength?: number;
37
+ /** Whether to lowercase tokens. */
38
+ lowercase?: boolean;
39
+ /** Whether to stem tokens. */
40
+ stem?: boolean;
41
+ /** Whether to remove stop words. */
42
+ removeStopWords?: boolean;
43
+ /**
44
+ * Custom stop words that replace the built-in list for `language`.
45
+ *
46
+ * This option only affects tokenization when `removeStopWords` is true.
47
+ *
48
+ * `undefined` keeps the built-in language list. An empty array explicitly
49
+ * replaces it with no stop words.
50
+ */
51
+ customStopWords?: string[];
52
+ /** Whether to fold ASCII characters. */
53
+ asciiFolding?: boolean;
54
+ /** N-gram minimum length. */
55
+ ngramMinLength?: number;
56
+ /** N-gram maximum length. */
57
+ ngramMaxLength?: number;
58
+ /** Whether to only emit token prefixes for the n-gram tokenizer. */
59
+ prefixOnly?: boolean;
60
+ }
61
+ /**
62
+ * Tokenize a full-text search query using an explicit tokenizer.
63
+ *
64
+ * This does not require a table or FTS index. The tokenizer options match
65
+ * {@link Index.fts}.
66
+ */
67
+ export declare function tokenize(query: string, options?: Partial<TokenizeOptions>): Promise<FtsToken[]>;
68
+ /**
69
+ * Connect to a LanceDB instance at the given URI.
70
+ *
71
+ * Accepted formats:
72
+ *
73
+ * - `/path/to/database` - local database
74
+ * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
75
+ * - `db://host:port` - remote database (LanceDB cloud)
76
+ * @param {string} uri - The uri of the database. If the database uri starts
77
+ * with `db://` then it connects to a remote database.
78
+ * @see {@link ConnectionOptions} for more details on the URI format.
79
+ * @param options - The options to use when connecting to the database
80
+ * @example
81
+ * ```ts
82
+ * const conn = await connect("/path/to/database");
83
+ * ```
84
+ * @example
85
+ * ```ts
86
+ * const conn = await connect(
87
+ * "s3://bucket/path/to/database",
88
+ * {storageOptions: {timeout: "60s"}
89
+ * });
90
+ * ```
91
+ * @example
92
+ * Using with a header provider for per-request authentication:
93
+ * ```ts
94
+ * const provider = new StaticHeaderProvider({
95
+ * "X-API-Key": "my-key"
96
+ * });
97
+ * const conn = await connectWithHeaderProvider(
98
+ * "db://host:port",
99
+ * options,
100
+ * provider
101
+ * );
102
+ * ```
103
+ */
104
+ export declare function connect(uri: string, options?: Partial<ConnectionOptions>, session?: Session, headerProvider?: HeaderProvider | (() => Record<string, string>) | (() => Promise<Record<string, string>>)): Promise<Connection>;
105
+ /**
106
+ * Connect to a LanceDB instance at the given URI.
107
+ *
108
+ * Accepted formats:
109
+ *
110
+ * - `/path/to/database` - local database
111
+ * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
112
+ * - `db://host:port` - remote database (LanceDB cloud)
113
+ * @param options - The options to use when connecting to the database
114
+ * @see {@link ConnectionOptions} for more details on the URI format.
115
+ * @example
116
+ * ```ts
117
+ * const conn = await connect({
118
+ * uri: "/path/to/database",
119
+ * storageOptions: {timeout: "60s"}
120
+ * });
121
+ * ```
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const session = Session.default();
126
+ * const conn = await connect({
127
+ * uri: "/path/to/database",
128
+ * session: session
129
+ * });
130
+ * ```
131
+ */
132
+ export declare function connect(options: Partial<ConnectionOptions> & {
133
+ uri: string;
134
+ }): Promise<Connection>;
135
+ /**
136
+ * Configuration for the built-in directory namespace (`"dir"`).
137
+ *
138
+ * The directory namespace stores tables under a single root path (local
139
+ * filesystem or object storage URI). See
140
+ * {@link https://docs.lancedb.com/namespaces} for the documented surface;
141
+ * less-common knobs live under {@link DirNamespaceConfig.extraProperties}.
142
+ */
143
+ export interface DirNamespaceConfig {
144
+ /** Root path or URI containing the LanceDB tables. */
145
+ root: string;
146
+ /**
147
+ * Whether to maintain a namespace manifest at the root. Required for
148
+ * child namespaces. Defaults to true on the impl side.
149
+ */
150
+ manifestEnabled?: boolean;
151
+ /**
152
+ * Additional raw properties passed verbatim to the namespace
153
+ * implementation (e.g. `storage.*`, `credential_vendor.*`). Typed
154
+ * fields above take precedence on key collision.
155
+ */
156
+ extraProperties?: Record<string, string>;
157
+ }
158
+ /**
159
+ * Configuration for the built-in REST namespace (`"rest"`).
160
+ *
161
+ * The REST namespace talks to a remote catalog server over HTTP. See
162
+ * {@link https://docs.lancedb.com/namespaces} for the documented surface;
163
+ * less-common knobs (TLS, metrics) live under
164
+ * {@link RestNamespaceConfig.extraProperties}.
165
+ */
166
+ export interface RestNamespaceConfig {
167
+ /** Catalog endpoint URL. */
168
+ uri: string;
169
+ /**
170
+ * HTTP headers forwarded with each request. Keys are passed through
171
+ * as-is (e.g. `"x-api-key"`, `"Authorization"`).
172
+ */
173
+ headers?: Record<string, string>;
174
+ /**
175
+ * Additional raw properties passed verbatim to the namespace
176
+ * implementation (e.g. `tls.*`, `ops_metrics_enabled`, `delimiter`).
177
+ * Typed fields above take precedence on key collision.
178
+ */
179
+ extraProperties?: Record<string, string>;
180
+ }
181
+ /**
182
+ * Connect to a LanceDB database through a namespace.
183
+ *
184
+ * Unlike {@link connect}, which routes by URI scheme (local path vs.
185
+ * `db://` cloud), `connectNamespace` always returns a namespace-backed
186
+ * connection. The `implName` selects the namespace implementation:
187
+ *
188
+ * - `"dir"` — directory namespace, configured with {@link DirNamespaceConfig}.
189
+ * - `"rest"` — remote REST catalog, configured with {@link RestNamespaceConfig}.
190
+ * - Any other string — full module path for a custom implementation,
191
+ * configured with a free-form string-keyed `properties` map.
192
+ *
193
+ * @example Typed dir namespace
194
+ * ```ts
195
+ * const db = await connectNamespace("dir", { root: "/path/to/db" });
196
+ * await db.createTable("users", [{ id: 1 }]);
197
+ * ```
198
+ *
199
+ * @example Typed REST namespace with auth headers
200
+ * ```ts
201
+ * const db = await connectNamespace("rest", {
202
+ * uri: "https://catalog.example.com",
203
+ * headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
204
+ * });
205
+ * ```
206
+ *
207
+ * @example Custom implementation with raw properties
208
+ * ```ts
209
+ * const db = await connectNamespace("my.custom.Namespace", {
210
+ * endpoint: "...",
211
+ * });
212
+ * ```
213
+ */
214
+ export declare function connectNamespace(implName: "dir", config: DirNamespaceConfig, options?: Partial<ConnectNamespaceOptions>): Promise<Connection>;
215
+ /**
216
+ * Connect through the built-in REST namespace.
217
+ *
218
+ * Configured with {@link RestNamespaceConfig}. See the function-level
219
+ * documentation above for the full surface, examples, and how this
220
+ * relates to {@link connect}.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * const db = await connectNamespace("rest", {
225
+ * uri: "https://catalog.example.com",
226
+ * headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
227
+ * });
228
+ * ```
229
+ */
230
+ export declare function connectNamespace(implName: "rest", config: RestNamespaceConfig, options?: Partial<ConnectNamespaceOptions>): Promise<Connection>;
231
+ /**
232
+ * Connect through a custom namespace implementation by full module path,
233
+ * configured with a free-form string-keyed `properties` map. Use the
234
+ * typed overloads above for the built-in `"dir"` and `"rest"` impls.
235
+ *
236
+ * See the function-level documentation above for examples and how this
237
+ * relates to {@link connect}.
238
+ *
239
+ * @example
240
+ * ```ts
241
+ * const db = await connectNamespace("my.custom.Namespace", {
242
+ * endpoint: "...",
243
+ * });
244
+ * ```
245
+ */
246
+ export declare function connectNamespace(implName: string, properties: Record<string, string>, options?: Partial<ConnectNamespaceOptions>): Promise<Connection>;