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,498 @@
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.Branches = exports.LocalTable = exports.Table = void 0;
6
+ const arrow_1 = require("./arrow");
7
+ const registry_1 = require("./embedding/registry");
8
+ const merge_1 = require("./merge");
9
+ const query_1 = require("./query");
10
+ const sanitize_1 = require("./sanitize");
11
+ const util_1 = require("./util");
12
+ /**
13
+ * A Table is a collection of Records in a LanceDB Database.
14
+ *
15
+ * A Table object is expected to be long lived and reused for multiple operations.
16
+ * Table objects will cache a certain amount of index data in memory. This cache
17
+ * will be freed when the Table is garbage collected. To eagerly free the cache you
18
+ * can call the `close` method. Once the Table is closed, it cannot be used for any
19
+ * further operations.
20
+ *
21
+ * Tables are created using the methods {@link Connection#createTable}
22
+ * and {@link Connection#createEmptyTable}. Existing tables are opened
23
+ * using {@link Connection#openTable}.
24
+ *
25
+ * Closing a table is optional. It not closed, it will be closed when it is garbage
26
+ * collected.
27
+ *
28
+ * @hideconstructor
29
+ */
30
+ class Table {
31
+ [Symbol.for("nodejs.util.inspect.custom")]() {
32
+ return this.display();
33
+ }
34
+ }
35
+ exports.Table = Table;
36
+ class LocalTable extends Table {
37
+ inner;
38
+ constructor(inner) {
39
+ super();
40
+ this.inner = inner;
41
+ }
42
+ get name() {
43
+ return this.inner.name;
44
+ }
45
+ isOpen() {
46
+ return this.inner.isOpen();
47
+ }
48
+ close() {
49
+ this.inner.close();
50
+ }
51
+ display() {
52
+ return this.inner.display();
53
+ }
54
+ async getEmbeddingFunctions(inner = this.inner) {
55
+ const schemaBuf = await inner.schema();
56
+ const schema = (0, arrow_1.tableFromIPC)(schemaBuf).schema;
57
+ const registry = (0, registry_1.getRegistry)();
58
+ return registry.parseFunctions(schema.metadata);
59
+ }
60
+ /** Get the schema of the table. */
61
+ async schema() {
62
+ const schemaBuf = await this.inner.schema();
63
+ const tbl = (0, arrow_1.tableFromIPC)(schemaBuf);
64
+ return tbl.schema;
65
+ }
66
+ async add(data, options) {
67
+ const mode = options?.mode ?? "append";
68
+ const schema = await this.schema();
69
+ const buffer = await (0, arrow_1.fromDataToBuffer)(data, undefined, schema);
70
+ // Wrap the user callback so a thrown error doesn't surface as an
71
+ // unhandled exception (the callback fires from a napi threadsafe
72
+ // function — exceptions there crash the process).
73
+ const userProgress = options?.progress;
74
+ const progress = userProgress
75
+ ? (p) => {
76
+ try {
77
+ userProgress(p);
78
+ }
79
+ catch (e) {
80
+ console.warn("Table.add progress callback threw:", e);
81
+ }
82
+ }
83
+ : undefined;
84
+ return await this.inner.add(buffer, mode, progress);
85
+ }
86
+ async update(optsOrUpdates, options) {
87
+ const isValues = "values" in optsOrUpdates && typeof optsOrUpdates.values !== "string";
88
+ const isValuesSql = "valuesSql" in optsOrUpdates &&
89
+ typeof optsOrUpdates.valuesSql !== "string";
90
+ const isMap = (obj) => {
91
+ return obj instanceof Map;
92
+ };
93
+ let predicate;
94
+ let columns;
95
+ switch (true) {
96
+ case isMap(optsOrUpdates):
97
+ columns = Array.from(optsOrUpdates.entries());
98
+ predicate = options?.where;
99
+ break;
100
+ case isValues && isMap(optsOrUpdates.values):
101
+ columns = Array.from(optsOrUpdates.values.entries()).map(([k, v]) => [
102
+ k,
103
+ (0, util_1.toSQL)(v),
104
+ ]);
105
+ predicate = optsOrUpdates.where;
106
+ break;
107
+ case isValues && !isMap(optsOrUpdates.values):
108
+ columns = Object.entries(optsOrUpdates.values).map(([k, v]) => [
109
+ k,
110
+ (0, util_1.toSQL)(v),
111
+ ]);
112
+ predicate = optsOrUpdates.where;
113
+ break;
114
+ case isValuesSql && isMap(optsOrUpdates.valuesSql):
115
+ columns = Array.from(optsOrUpdates.valuesSql.entries());
116
+ predicate = optsOrUpdates.where;
117
+ break;
118
+ case isValuesSql && !isMap(optsOrUpdates.valuesSql):
119
+ columns = Object.entries(optsOrUpdates.valuesSql).map(([k, v]) => [
120
+ k,
121
+ v,
122
+ ]);
123
+ predicate = optsOrUpdates.where;
124
+ break;
125
+ default:
126
+ columns = Object.entries(optsOrUpdates);
127
+ predicate = options?.where;
128
+ }
129
+ return await this.inner.update(predicate, columns);
130
+ }
131
+ async countRows(filter) {
132
+ return await this.inner.countRows(filter);
133
+ }
134
+ async delete(predicate) {
135
+ return await this.inner.delete(predicate);
136
+ }
137
+ async createIndex(column, options) {
138
+ // Bit of a hack to get around the fact that TS has no package-scope.
139
+ // biome-ignore lint/suspicious/noExplicitAny: skip
140
+ const nativeIndex = options?.config?.inner;
141
+ await this.inner.createIndex(nativeIndex, column, options?.replace, options?.waitTimeoutSeconds, options?.name, options?.train);
142
+ }
143
+ async createIndexAsync(column, options) {
144
+ // biome-ignore lint/suspicious/noExplicitAny: skip
145
+ const nativeIndex = options?.config?.inner;
146
+ return await this.inner.createIndexAsync(nativeIndex, column, options?.replace, options?.waitTimeoutSeconds, options?.name, options?.train);
147
+ }
148
+ async dropIndex(name) {
149
+ await this.inner.dropIndex(name);
150
+ }
151
+ async prewarmIndex(name) {
152
+ await this.inner.prewarmIndex(name);
153
+ }
154
+ async prewarmData(columns) {
155
+ await this.inner.prewarmData(columns);
156
+ }
157
+ async waitForIndex(indexNames, timeoutSeconds) {
158
+ await this.inner.waitForIndex(indexNames, timeoutSeconds);
159
+ }
160
+ takeOffsets(offsets) {
161
+ return new query_1.TakeQuery(this.inner.takeOffsets(offsets));
162
+ }
163
+ takeRowIds(rowIds) {
164
+ const ids = rowIds.map((id) => {
165
+ if (typeof id === "bigint") {
166
+ return id;
167
+ }
168
+ if (!Number.isInteger(id)) {
169
+ throw new Error("Row id must be an integer (or bigint)");
170
+ }
171
+ if (id < 0) {
172
+ throw new Error("Row id cannot be negative");
173
+ }
174
+ if (!Number.isSafeInteger(id)) {
175
+ throw new Error("Row id is too large for number; use bigint instead");
176
+ }
177
+ return BigInt(id);
178
+ });
179
+ return new query_1.TakeQuery(this.inner.takeRowIds(ids));
180
+ }
181
+ query() {
182
+ return new query_1.Query(this.inner);
183
+ }
184
+ search(query, queryType = "auto", ftsColumns) {
185
+ if (typeof query !== "string" && !(0, query_1.instanceOfFullTextQuery)(query)) {
186
+ if (queryType === "fts") {
187
+ throw new Error("Cannot perform full text search on a vector query");
188
+ }
189
+ return this.vectorSearch(query);
190
+ }
191
+ // If the query is a string, we need to determine if it is a vector query or a full text search query
192
+ if (queryType === "fts") {
193
+ return this.query().fullTextSearch(query, {
194
+ columns: ftsColumns,
195
+ });
196
+ }
197
+ if (queryType === "auto") {
198
+ if ((0, query_1.instanceOfFullTextQuery)(query)) {
199
+ return this.query().fullTextSearch(query, {
200
+ columns: ftsColumns,
201
+ });
202
+ }
203
+ const columns = typeof ftsColumns === "string" ? [ftsColumns] : (ftsColumns ?? null);
204
+ return (0, query_1.createAutoQuery)(this.inner, query, columns, async (metadata) => {
205
+ const functions = await (0, registry_1.getRegistry)().parseFunctions(new Map([["embedding_functions", metadata]]));
206
+ // TODO: Support multiple embedding functions
207
+ const embeddingFunc = functions
208
+ .values()
209
+ .next().value;
210
+ // The route only calls this callback when embedding metadata exists.
211
+ // parseFunctions either yields a provider or reports malformed metadata.
212
+ if (!embeddingFunc)
213
+ throw new Error("Invalid embedding function metadata");
214
+ return await embeddingFunc.function.computeQueryEmbeddings(query);
215
+ });
216
+ }
217
+ const queryPromise = this.getEmbeddingFunctions().then(async (functions) => {
218
+ // TODO: Support multiple embedding functions
219
+ const embeddingFunc = functions
220
+ .values()
221
+ .next().value;
222
+ if (!embeddingFunc) {
223
+ return Promise.reject(new Error("No embedding functions are defined in the table"));
224
+ }
225
+ return await embeddingFunc.function.computeQueryEmbeddings(query);
226
+ });
227
+ return this.query().nearestTo(queryPromise);
228
+ }
229
+ vectorSearch(vector) {
230
+ if ((0, arrow_1.isMultiVector)(vector)) {
231
+ const query = this.query().nearestTo(vector[0]);
232
+ for (const v of vector.slice(1)) {
233
+ query.addQueryVector(v);
234
+ }
235
+ return query;
236
+ }
237
+ return this.query().nearestTo(vector);
238
+ }
239
+ // TODO: Support BatchUDF
240
+ async addColumns(newColumnTransforms) {
241
+ // Columns defined by an expression are declared, not materialized here.
242
+ if (typeof newColumnTransforms === "object" &&
243
+ !Array.isArray(newColumnTransforms) &&
244
+ "computed" in newColumnTransforms) {
245
+ return await this.inner.addComputedColumns(newColumnTransforms.computed);
246
+ }
247
+ // Handle single Field -> convert to array of Fields
248
+ if (newColumnTransforms instanceof arrow_1.Field) {
249
+ newColumnTransforms = [newColumnTransforms];
250
+ }
251
+ // Handle array of Fields -> convert to Schema
252
+ if (Array.isArray(newColumnTransforms) &&
253
+ newColumnTransforms.length > 0 &&
254
+ newColumnTransforms[0] instanceof arrow_1.Field) {
255
+ const fields = newColumnTransforms;
256
+ newColumnTransforms = new arrow_1.Schema(fields);
257
+ }
258
+ // Handle Schema -> use schema-based approach
259
+ if (newColumnTransforms instanceof arrow_1.Schema) {
260
+ const schema = newColumnTransforms;
261
+ // Convert schema to buffer using Arrow IPC format
262
+ const emptyTable = (0, arrow_1.makeEmptyTable)(schema);
263
+ const schemaBuf = await (0, arrow_1.fromTableToBuffer)(emptyTable);
264
+ return await this.inner.addColumnsWithSchema(schemaBuf);
265
+ }
266
+ // Handle SQL expressions (existing functionality)
267
+ if (Array.isArray(newColumnTransforms)) {
268
+ return await this.inner.addColumns(newColumnTransforms);
269
+ }
270
+ throw new Error("Invalid input type for addColumns");
271
+ }
272
+ async refreshColumn(column) {
273
+ return await this.inner.refreshColumn(column);
274
+ }
275
+ async refreshColumnAsync(column) {
276
+ return await this.inner.refreshColumnAsync(column);
277
+ }
278
+ async refreshMaterializedView(full, sourceVersion) {
279
+ return await this.inner.refreshMaterializedView(full, sourceVersion);
280
+ }
281
+ async alterColumns(columnAlterations) {
282
+ const processedAlterations = columnAlterations.map((alteration) => {
283
+ if (typeof alteration.dataType === "string") {
284
+ return {
285
+ ...alteration,
286
+ dataType: JSON.stringify({ type: alteration.dataType }),
287
+ };
288
+ }
289
+ else if (alteration.dataType === undefined) {
290
+ return {
291
+ ...alteration,
292
+ dataType: undefined,
293
+ };
294
+ }
295
+ else {
296
+ const dataType = (0, sanitize_1.sanitizeType)(alteration.dataType);
297
+ return {
298
+ ...alteration,
299
+ dataType: JSON.stringify((0, arrow_1.dataTypeToJson)(dataType)),
300
+ };
301
+ }
302
+ });
303
+ return await this.inner.alterColumns(processedAlterations);
304
+ }
305
+ async updateFieldMetadata(updates) {
306
+ return await this.inner.updateFieldMetadata(updates);
307
+ }
308
+ async dropColumns(columnNames) {
309
+ return await this.inner.dropColumns(columnNames);
310
+ }
311
+ async setUnenforcedPrimaryKey(columns) {
312
+ const cols = typeof columns === "string" ? [columns] : columns;
313
+ return await this.inner.setUnenforcedPrimaryKey(cols);
314
+ }
315
+ async setLsmWriteSpec(spec) {
316
+ return await this.inner.setLsmWriteSpec(spec);
317
+ }
318
+ async unsetLsmWriteSpec() {
319
+ return await this.inner.unsetLsmWriteSpec();
320
+ }
321
+ async getLsmWriteSpec() {
322
+ // The native binding types `specType` as a plain `string`; narrow it back
323
+ // to the public union. The Rust `From` impl only ever emits one of the
324
+ // three valid values, so the cast is safe.
325
+ return ((await this.inner.getLsmWriteSpec()) ?? undefined);
326
+ }
327
+ async closeLsmWriters() {
328
+ return await this.inner.closeLsmWriters();
329
+ }
330
+ async flushLsm() {
331
+ return await this.inner.flushLsm();
332
+ }
333
+ async compactLsm() {
334
+ return await this.inner.compactLsm();
335
+ }
336
+ async checkpointLsm() {
337
+ return await this.inner.checkpointLsm();
338
+ }
339
+ async getLsmStats(includeGenerationRows = false) {
340
+ return (await this.inner.getLsmStats(includeGenerationRows)) ?? undefined;
341
+ }
342
+ async version() {
343
+ return await this.inner.version();
344
+ }
345
+ async checkout(version) {
346
+ if (typeof version === "string") {
347
+ return this.inner.checkoutTag(version);
348
+ }
349
+ return this.inner.checkout(version);
350
+ }
351
+ async checkoutLatest() {
352
+ await this.inner.checkoutLatest();
353
+ }
354
+ async listVersions() {
355
+ return (await this.inner.listVersions()).map((version) => ({
356
+ version: version.version,
357
+ timestamp: new Date(version.timestamp / 1000),
358
+ metadata: version.metadata,
359
+ }));
360
+ }
361
+ async restore() {
362
+ await this.inner.restore();
363
+ }
364
+ async tags() {
365
+ return await this.inner.tags();
366
+ }
367
+ async branches() {
368
+ return new Branches(await this.inner.branches());
369
+ }
370
+ currentBranch() {
371
+ return this.inner.currentBranch() ?? null;
372
+ }
373
+ async optimize(options) {
374
+ let cleanupOlderThanMs;
375
+ if (options?.cleanupOlderThan !== undefined &&
376
+ options?.cleanupOlderThan !== null) {
377
+ cleanupOlderThanMs =
378
+ new Date().getTime() - options.cleanupOlderThan.getTime();
379
+ }
380
+ return await this.inner.optimize(cleanupOlderThanMs, options?.deleteUnverified);
381
+ }
382
+ async listIndices() {
383
+ return await this.inner.listIndices();
384
+ }
385
+ async tokenize(query, options) {
386
+ return await this.inner.tokenize(query, options?.column, options?.indexName);
387
+ }
388
+ async toArrow() {
389
+ return await this.query().toArrow();
390
+ }
391
+ async indexStats(name) {
392
+ const stats = await this.inner.indexStats(name);
393
+ if (stats === null) {
394
+ return undefined;
395
+ }
396
+ return stats;
397
+ }
398
+ async stats() {
399
+ return await this.inner.stats();
400
+ }
401
+ async initialStorageOptions() {
402
+ return await this.inner.initialStorageOptions();
403
+ }
404
+ async latestStorageOptions() {
405
+ return await this.inner.latestStorageOptions();
406
+ }
407
+ mergeInsert(on) {
408
+ on = Array.isArray(on) ? on : [on];
409
+ return new merge_1.MergeInsertBuilder(this.inner.mergeInsert(on), this.schema());
410
+ }
411
+ /**
412
+ * Check if the table uses the new manifest path scheme.
413
+ *
414
+ * This function will return true if the table uses the V2 manifest
415
+ * path scheme.
416
+ */
417
+ async usesV2ManifestPaths() {
418
+ return await this.inner.usesV2ManifestPaths();
419
+ }
420
+ /**
421
+ * Migrate the table to use the new manifest path scheme.
422
+ *
423
+ * This function will rename all V1 manifests to V2 manifest paths.
424
+ * These paths provide more efficient opening of datasets with many versions
425
+ * on object stores.
426
+ *
427
+ * This function is idempotent, and can be run multiple times without
428
+ * changing the state of the object store.
429
+ *
430
+ * However, it should not be run while other concurrent operations are happening.
431
+ * And it should also run until completion before resuming other operations.
432
+ */
433
+ async migrateManifestPathsV2() {
434
+ await this.inner.migrateManifestPathsV2();
435
+ }
436
+ }
437
+ exports.LocalTable = LocalTable;
438
+ /**
439
+ * Branch manager for a {@link Table}.
440
+ *
441
+ * Unlike tags, `create` and `checkout` return a new {@link Table} handle scoped
442
+ * to the branch; writes on it do not affect `main`.
443
+ */
444
+ class Branches {
445
+ #inner;
446
+ /**
447
+ * Construct a Branches manager. Internal use only.
448
+ * @hidden
449
+ */
450
+ constructor(inner) {
451
+ this.#inner = inner;
452
+ }
453
+ /** List all branches, mapping name to branch metadata. */
454
+ async list() {
455
+ return await this.#inner.list();
456
+ }
457
+ /**
458
+ * Create a branch and return a handle scoped to it.
459
+ *
460
+ * @param name Name of the new branch.
461
+ * @param fromRef Source branch to fork from. Defaults to `main`.
462
+ * @param fromVersion A specific version on `fromRef`. Defaults to latest.
463
+ */
464
+ async create(name, fromRef, fromVersion) {
465
+ return new LocalTable(await this.#inner.create(name, fromRef, fromVersion));
466
+ }
467
+ /**
468
+ * Check out an existing branch and return a handle scoped to it.
469
+ *
470
+ * With `version` set, the returned handle is pinned to that version of the
471
+ * branch (a read-only, detached view); otherwise it tracks the branch's
472
+ * latest and stays writable.
473
+ */
474
+ async checkout(name, version) {
475
+ return new LocalTable(await this.#inner.checkout(name, version));
476
+ }
477
+ /** Delete a branch. */
478
+ async delete(name) {
479
+ return await this.#inner.delete(name);
480
+ }
481
+ /** Compare a branch against main without modifying either branch. */
482
+ async diff(fromBranch) {
483
+ return (await this.#inner.diff(fromBranch));
484
+ }
485
+ /**
486
+ * Cherry-pick a branch onto main.
487
+ *
488
+ * Set `dryRun` to `true` to preview. A failed cherry-pick resolves
489
+ * with `status: "failed"` instead of throwing.
490
+ *
491
+ * @param fromBranch Branch to cherry-pick from.
492
+ * @param dryRun When true, only preview. Defaults to false.
493
+ */
494
+ async cherryPick(fromBranch, dryRun = false) {
495
+ return (await this.#inner.cherryPick(fromBranch, dryRun));
496
+ }
497
+ }
498
+ exports.Branches = Branches;
@@ -0,0 +1,14 @@
1
+ export type IntoSql = string | number | boolean | null | Date | ArrayBufferLike | Buffer | IntoSql[];
2
+ export declare function toSQL(value: IntoSql): string;
3
+ export declare function packBits(data: Array<number>): Array<number>;
4
+ export declare class TTLCache {
5
+ private readonly ttl;
6
+ private readonly cache;
7
+ /**
8
+ * @param ttl Time to live in milliseconds
9
+ */
10
+ constructor(ttl: number);
11
+ get(key: string): any | undefined;
12
+ set(key: string, value: any): void;
13
+ delete(key: string): void;
14
+ }
@@ -0,0 +1,77 @@
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.TTLCache = void 0;
6
+ exports.toSQL = toSQL;
7
+ exports.packBits = packBits;
8
+ function toSQL(value) {
9
+ if (typeof value === "string") {
10
+ return `'${value.replace(/'/g, "''")}'`;
11
+ }
12
+ else if (typeof value === "number") {
13
+ return value.toString();
14
+ }
15
+ else if (typeof value === "boolean") {
16
+ return value ? "TRUE" : "FALSE";
17
+ }
18
+ else if (value === null) {
19
+ return "NULL";
20
+ }
21
+ else if (value instanceof Date) {
22
+ return `'${value.toISOString()}'`;
23
+ }
24
+ else if (Array.isArray(value)) {
25
+ return `[${value.map(toSQL).join(", ")}]`;
26
+ }
27
+ else if (Buffer.isBuffer(value)) {
28
+ return `X'${value.toString("hex")}'`;
29
+ }
30
+ else if (value instanceof ArrayBuffer) {
31
+ return `X'${Buffer.from(value).toString("hex")}'`;
32
+ }
33
+ else {
34
+ throw new Error(`Unsupported value type: ${typeof value} value: (${value})`);
35
+ }
36
+ }
37
+ function packBits(data) {
38
+ const packed = Array(data.length >> 3).fill(0);
39
+ for (let i = 0; i < data.length; i++) {
40
+ const byte = i >> 3;
41
+ const bit = i & 7;
42
+ packed[byte] |= data[i] << bit;
43
+ }
44
+ return packed;
45
+ }
46
+ class TTLCache {
47
+ ttl;
48
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
49
+ cache;
50
+ /**
51
+ * @param ttl Time to live in milliseconds
52
+ */
53
+ constructor(ttl) {
54
+ this.ttl = ttl;
55
+ this.cache = new Map();
56
+ }
57
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
58
+ get(key) {
59
+ const entry = this.cache.get(key);
60
+ if (entry === undefined) {
61
+ return undefined;
62
+ }
63
+ if (entry.expires < Date.now()) {
64
+ this.cache.delete(key);
65
+ return undefined;
66
+ }
67
+ return entry.value;
68
+ }
69
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
70
+ set(key, value) {
71
+ this.cache.set(key, { value, expires: Date.now() + this.ttl });
72
+ }
73
+ delete(key) {
74
+ this.cache.delete(key);
75
+ }
76
+ }
77
+ exports.TTLCache = TTLCache;
@@ -0,0 +1,2 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: Copyright The LanceDB Authors
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@lancedb/lancedb",
3
+ "description": "LanceDB: A serverless, low-latency vector database for AI applications",
4
+ "keywords": [
5
+ "database",
6
+ "lance",
7
+ "lancedb",
8
+ "search",
9
+ "vector",
10
+ "vector database",
11
+ "ann"
12
+ ],
13
+ "private": false,
14
+ "version": "0.38.0",
15
+ "main": "dist/index.js",
16
+ "exports": {
17
+ ".": "./dist/index.js",
18
+ "./embedding": "./dist/embedding/index.js",
19
+ "./embedding/openai": "./dist/embedding/openai.js",
20
+ "./embedding/transformers": "./dist/embedding/transformers.js"
21
+ },
22
+ "types": "dist/index.d.ts",
23
+ "napi": {
24
+ "binaryName": "lancedb",
25
+ "targets": [
26
+ "aarch64-apple-darwin",
27
+ "x86_64-unknown-linux-gnu",
28
+ "aarch64-unknown-linux-gnu",
29
+ "x86_64-unknown-linux-musl",
30
+ "aarch64-unknown-linux-musl",
31
+ "x86_64-pc-windows-msvc",
32
+ "aarch64-pc-windows-msvc"
33
+ ]
34
+ },
35
+ "license": "Apache-2.0",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/lancedb/lancedb"
39
+ },
40
+ "ava": {
41
+ "timeout": "3m"
42
+ },
43
+ "engines": {
44
+ "node": ">= 22"
45
+ },
46
+ "packageManager": "pnpm@11.1.1",
47
+ "cpu": [
48
+ "x64",
49
+ "arm64"
50
+ ],
51
+ "os": [
52
+ "darwin",
53
+ "linux",
54
+ "win32"
55
+ ]
56
+ }