@dbx-tools/search 0.6.107 → 0.6.111
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.
- package/README.md +96 -110
- package/index.ts +6 -2
- package/lib/index.d.ts +6 -2
- package/lib/index.js +4 -1
- package/lib/src/client.d.ts +23 -43
- package/lib/src/client.js +51 -114
- package/lib/src/lakebase-plugin.d.ts +73 -0
- package/lib/src/lakebase-plugin.js +191 -0
- package/lib/src/lakebase.d.ts +6 -4
- package/lib/src/lakebase.js +45 -13
- package/lib/src/native.d.ts +18 -0
- package/lib/src/native.js +79 -0
- package/lib/src/plugin.d.ts +31 -59
- package/lib/src/plugin.js +63 -130
- package/lib/src/query.d.ts +1 -57
- package/lib/src/query.js +2 -93
- package/lib/src/runtime.d.ts +4 -11
- package/lib/src/runtime.js +3 -7
- package/lib/src/schema.d.ts +1 -1
- package/lib/src/tool.d.ts +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/client.ts +69 -137
- package/src/lakebase-plugin.ts +258 -0
- package/src/lakebase.ts +56 -15
- package/src/native.ts +117 -0
- package/src/plugin.ts +63 -148
- package/src/query.ts +1 -109
- package/src/runtime.ts +6 -16
package/README.md
CHANGED
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
# @dbx-tools/search
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Extensions for AppKit's beta AI Search plugin: agent tools, federated search,
|
|
4
|
+
index lifecycle helpers, and an AppKit-compatible Lakebase full-text provider.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Use native AppKit `aiSearch` for
|
|
7
7
|
[Databricks AI Search](https://docs.databricks.com/aws/en/ai-search/ai-search)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
client, and ships the agent tools, HTTP routes, and boot config a search UI
|
|
13
|
-
needs - so search is one plugin and, in the simple case, zero config.
|
|
8
|
+
queries. Add this package when an agent needs `search` /
|
|
9
|
+
`universal_search`, an app needs to create, sync, or seed indexes, or a
|
|
10
|
+
deployment needs the same AppKit query contract backed by PostgreSQL full-text
|
|
11
|
+
search instead of Vector Search.
|
|
14
12
|
|
|
15
13
|
**Key features:**
|
|
16
14
|
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- Hybrid matching by default (semantic similarity fused with BM25 keyword
|
|
22
|
-
ranking), with `vector` and `keyword` modes when you want one or the other.
|
|
15
|
+
- Vector Search reads delegate to AppKit `aiSearch`, which owns OBO execution,
|
|
16
|
+
caching, reranking, pagination, route validation, and response decoding.
|
|
17
|
+
- `lakebaseAiSearch()` implements the same `aiSearch` alias, route,
|
|
18
|
+
client-config, and `SearchResponse` contract with PostgreSQL `tsvector`.
|
|
23
19
|
- Agent tools for both Mastra (`searchTool()` etc.) and AppKit agents (through
|
|
24
|
-
the plugin's `ToolProvider`): `search` and `universal_search`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- A `clientConfig()` payload so a UI knows the indexes, default, and page size at
|
|
31
|
-
boot with no round-trip (read it with `usePluginClientConfig("search")`).
|
|
20
|
+
the extension plugin's `ToolProvider`): `search` and `universal_search`
|
|
21
|
+
reads, plus provider-aware write tools. Lakebase exposes `add_documents`;
|
|
22
|
+
native Vector Search can also expose `create_index` and `sync_index`.
|
|
23
|
+
- AppKit-compatible query routes under `/api/ai-search/:alias`; extension
|
|
24
|
+
routes under `/api/search` cover universal search and optional lifecycle
|
|
25
|
+
operations.
|
|
32
26
|
- Sensible-default config that infers almost everything: name a default index
|
|
33
27
|
(or set `DATABRICKS_VECTOR_SEARCH_INDEX`) and the columns, page size, mode,
|
|
34
28
|
aliases, and route path all have defaults you can override when you need to go
|
|
35
29
|
deeper.
|
|
36
|
-
- OBO
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- Filters as plain `{ column: value }` (or `{ column: { ">=": n } }`) compiled to
|
|
40
|
-
the index `filters_json` for you; the columnar response is unpacked into
|
|
41
|
-
`{ id, score, fields }` hits.
|
|
30
|
+
- OBO for Vector Search comes from native AppKit `aiSearch`. Lakebase full-text
|
|
31
|
+
search uses the sibling `lakebase` plugin's service-principal pool.
|
|
32
|
+
- Filters use AppKit's scalar/array shape: `{ column: valueOrValues }`.
|
|
42
33
|
- Embedding-model resolution for index creation reuses
|
|
43
34
|
[`@dbx-tools/model`](../model): a loose name fuzzy-matches the live catalogue,
|
|
44
35
|
or the best embedding endpoint is chosen automatically.
|
|
@@ -52,28 +43,24 @@ needs - so search is one plugin and, in the simple case, zero config.
|
|
|
52
43
|
endpoint + index and seeds documents in the background using the app's SDK
|
|
53
44
|
auth (env or `DATABRICKS_CONFIG_PROFILE`), so a fresh deployment is searchable
|
|
54
45
|
with no manual setup.
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`add_documents` calls, same `{ id, score, fields }` hits, so tools, routes, and
|
|
59
|
-
the UI can't tell which backend answered. No endpoint, no embeddings, no Delta
|
|
60
|
-
table - just a table the plugin creates and seeds on boot.
|
|
46
|
+
- An explicit **Lakebase full-text provider**: register `lakebaseAiSearch`
|
|
47
|
+
instead of native `aiSearch` to serve the same aliases, query routes, filters,
|
|
48
|
+
and result shape from a Postgres `tsvector` index.
|
|
61
49
|
|
|
62
50
|
## Why Use This Over Native AppKit
|
|
63
51
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
single index name. Reach for the raw SDK when you need index lifecycle
|
|
71
|
-
operations this package does not wrap.
|
|
52
|
+
Do not use this package instead of native AppKit for ordinary Vector Search
|
|
53
|
+
queries. Register `aiSearch` from `@databricks/appkit/beta`.
|
|
54
|
+
|
|
55
|
+
Use this package for capabilities AppKit does not ship: agent tool providers,
|
|
56
|
+
federated fan-out, index lifecycle and seeding, reusable result components, or
|
|
57
|
+
the Lakebase full-text implementation of the AppKit AI Search contract.
|
|
72
58
|
|
|
73
59
|
## Quick Start
|
|
74
60
|
|
|
75
61
|
```ts
|
|
76
62
|
import { createApp, server } from "@databricks/appkit";
|
|
63
|
+
import { aiSearch } from "@databricks/appkit/beta";
|
|
77
64
|
import { plugin as searchPlugin, tool as searchToolApi } from "@dbx-tools/search";
|
|
78
65
|
import { agents, plugin as mastraPlugin } from "@dbx-tools/appkit-mastra";
|
|
79
66
|
|
|
@@ -85,47 +72,50 @@ const support = agents.createAgent({
|
|
|
85
72
|
await createApp({
|
|
86
73
|
plugins: [
|
|
87
74
|
server(),
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
aiSearch({
|
|
76
|
+
indexes: {
|
|
77
|
+
docs: {
|
|
78
|
+
indexName: "main.support.docs",
|
|
79
|
+
columns: ["id", "title", "url", "body"],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
searchPlugin.search({
|
|
84
|
+
index: "main.support.docs",
|
|
85
|
+
indexes: [{ name: "main.support.docs", alias: "docs" }],
|
|
86
|
+
}),
|
|
90
87
|
mastraPlugin.mastra({ agents: support }),
|
|
91
88
|
],
|
|
92
89
|
});
|
|
93
90
|
```
|
|
94
91
|
|
|
95
|
-
|
|
92
|
+
Use Lakebase full-text search without changing the AppKit UI hook:
|
|
96
93
|
|
|
97
94
|
```ts
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
import { lakebase } from "@databricks/appkit";
|
|
96
|
+
import { lakebaseAiSearch } from "@dbx-tools/search";
|
|
97
|
+
|
|
98
|
+
createApp({
|
|
99
|
+
plugins: [
|
|
100
|
+
lakebase(),
|
|
101
|
+
lakebaseAiSearch({
|
|
102
|
+
indexes: {
|
|
103
|
+
docs: {
|
|
104
|
+
indexName: "docs",
|
|
105
|
+
columns: ["id", "title", "body"],
|
|
106
|
+
queryType: "full_text",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
103
110
|
],
|
|
104
|
-
columns: ["title", "url", "body"],
|
|
105
|
-
mode: "hybrid",
|
|
106
|
-
pageSize: 10,
|
|
107
|
-
allowWrite: false,
|
|
108
111
|
});
|
|
109
112
|
```
|
|
110
113
|
|
|
111
|
-
## Use The Client Directly
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
import { createSearchClient } from "@dbx-tools/search";
|
|
115
|
-
|
|
116
|
-
const client = createSearchClient();
|
|
117
|
-
const docs = client.index("main.support.docs");
|
|
118
|
-
|
|
119
|
-
const { hits } = await docs.search("reset my password", { limit: 5 });
|
|
120
|
-
const suggestions = await docs.autocomplete("rese");
|
|
121
|
-
const everywhere = await client.universalSearch("invoice error 402");
|
|
122
|
-
|
|
123
|
-
await docs.addDocuments([{ id: "42", title: "Reset", body: "…" }]);
|
|
124
|
-
```
|
|
125
|
-
|
|
126
114
|
## Manage Indexes
|
|
127
115
|
|
|
128
|
-
|
|
116
|
+
`SearchClient` is the lifecycle client; query execution requires the registered
|
|
117
|
+
AppKit-compatible provider. Create and maintain indexes with the same
|
|
118
|
+
infer-everything ergonomics. A Delta
|
|
129
119
|
Sync index computes embeddings from a source Delta table and stays synced; the
|
|
130
120
|
embedding model, endpoint, primary key (`id`), and text column
|
|
131
121
|
(`text`/`content`/`body`) are all inferred when omitted.
|
|
@@ -207,16 +197,14 @@ Idempotent: later boots see the endpoint, index, and rows already present and do
|
|
|
207
197
|
nothing. Point `ensureOnSetup.sourceTable` at a Delta table to provision a Delta
|
|
208
198
|
Sync index instead of a managed direct-access one.
|
|
209
199
|
|
|
210
|
-
### Lakebase full-text
|
|
200
|
+
### Lakebase full-text provider
|
|
211
201
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
[`@dbx-tools/appkit-mastra`](../appkit-mastra) builds its memory pool - no auth
|
|
219
|
-
is re-implemented.
|
|
202
|
+
`lakebaseAiSearch()` is an AppKit `aiSearch` provider backed by a Postgres
|
|
203
|
+
full-text index. It provisions one table per alias (a generated `tsvector`
|
|
204
|
+
column with a GIN index), seeds configured documents, and answers queries with
|
|
205
|
+
a prefix `to_tsquery` + `ts_rank`. The pool comes from the native `lakebase`
|
|
206
|
+
plugin's service-principal config, so database authentication is not
|
|
207
|
+
re-implemented.
|
|
220
208
|
|
|
221
209
|
Queries are compiled from the search box rather than handed to
|
|
222
210
|
`websearch_to_tsquery`, which is too literal for type-ahead in two ways:
|
|
@@ -229,40 +217,39 @@ Queries are compiled from the search box rather than handed to
|
|
|
229
217
|
- **Prefixes.** Every term is matched as a prefix, so `intel` reaches
|
|
230
218
|
`intelligence` and `store intel` finds `racetrac-store-intelligence`.
|
|
231
219
|
|
|
232
|
-
All terms must match. When none do,
|
|
220
|
+
All terms must match. When none do, search relaxes instead of returning an
|
|
233
221
|
empty box: any single term counts, plus a substring pass that catches a
|
|
234
222
|
fragment which is not a prefix (`telligence`). The substring pass cannot use
|
|
235
223
|
the GIN index, so it only runs after the indexed pass finds nothing.
|
|
236
224
|
|
|
237
|
-
The
|
|
238
|
-
`
|
|
239
|
-
tools
|
|
240
|
-
whichever backend is active. Register `lakebase()`, omit `endpoint`, and search
|
|
241
|
-
works with no Vector Search infrastructure:
|
|
225
|
+
The provider returns AppKit's `SearchResponse` and mounts the same
|
|
226
|
+
`/api/ai-search/:alias` query surface. AppKit UI's `useAiSearchQuery` and
|
|
227
|
+
`@dbx-tools/ui-search` work without a backend-specific client:
|
|
242
228
|
|
|
243
229
|
```ts
|
|
244
230
|
import { createApp, lakebase } from "@databricks/appkit";
|
|
245
|
-
import {
|
|
246
|
-
|
|
247
|
-
const { search } = searchPlugin;
|
|
231
|
+
import { lakebaseAiSearch } from "@dbx-tools/search";
|
|
248
232
|
|
|
249
233
|
createApp({
|
|
250
234
|
plugins: [
|
|
251
|
-
lakebase(),
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
235
|
+
lakebase(),
|
|
236
|
+
lakebaseAiSearch({
|
|
237
|
+
indexes: {
|
|
238
|
+
docs: {
|
|
239
|
+
indexName: "docs",
|
|
240
|
+
queryType: "full_text",
|
|
241
|
+
columns: ["id", "title", "text"],
|
|
242
|
+
documents: [{ id: "1", title: "Overview", text: "Search over Postgres full-text." }],
|
|
243
|
+
},
|
|
257
244
|
},
|
|
258
245
|
}),
|
|
259
246
|
],
|
|
260
247
|
});
|
|
261
248
|
```
|
|
262
249
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
250
|
+
Register either native `aiSearch` for Vector Search or `lakebaseAiSearch` for
|
|
251
|
+
Postgres full text. Both use the registered plugin name `aiSearch`, so they are
|
|
252
|
+
alternatives and must not be registered together.
|
|
266
253
|
|
|
267
254
|
## Configuration
|
|
268
255
|
|
|
@@ -279,16 +266,14 @@ default.
|
|
|
279
266
|
| `mode` | `SEARCH_MODE` | `hybrid` | `hybrid` / `vector` / `keyword`. |
|
|
280
267
|
| `embeddingModel` | `SEARCH_EMBEDDING_MODEL` | best embedding endpoint | Embedding endpoint for index creation. |
|
|
281
268
|
| `timeoutMs` | `SEARCH_TIMEOUT_MS` | `30000` | Per-call timeout. |
|
|
282
|
-
| `allowWrite` | `SEARCH_WRITE` | `false` | Enable
|
|
283
|
-
| `ensureOnSetup` | – | – | Provision
|
|
269
|
+
| `allowWrite` | `SEARCH_WRITE` | `false` | Enable provider-supported write tools and routes. |
|
|
270
|
+
| `ensureOnSetup` | – | – | Provision and seed a native Vector Search index at boot. |
|
|
284
271
|
|
|
285
272
|
## Modules
|
|
286
273
|
|
|
287
|
-
- `client` - `SearchClient`, `SearchIndex`,
|
|
288
|
-
|
|
289
|
-
/ `
|
|
290
|
-
`UniversalSearchOptions` / `IndexInfo` / `CreateIndexOptions` /
|
|
291
|
-
`EnsureEndpointOptions` types.
|
|
274
|
+
- `client` - `SearchClient`, `SearchIndex`, and the Vector Search lifecycle
|
|
275
|
+
(`createIndex` / `ensureIndex` / `syncIndex` / `deleteIndex` / `listIndexes`
|
|
276
|
+
/ `ensureEndpoint`), plus provider-backed federated reads.
|
|
292
277
|
- `plugin` - `SearchPlugin` and the `search()` factory (`ToolProvider`,
|
|
293
278
|
routes, `clientConfig`, `exports`).
|
|
294
279
|
- `tool` - the `searchTool()`, `universalSearchTool()`, `addDocumentsTool()`,
|
|
@@ -299,11 +284,12 @@ default.
|
|
|
299
284
|
- `config` - `resolveSearchConfig`, `resolveIndexName`, `SEARCH_CONFIG_SCHEMA`,
|
|
300
285
|
the config env constants, and the `SearchPluginConfig` /
|
|
301
286
|
`ResolvedSearchConfig` types.
|
|
302
|
-
- `
|
|
303
|
-
|
|
304
|
-
- `lakebase` - `
|
|
305
|
-
|
|
306
|
-
|
|
287
|
+
- `native` - adapter from an AppKit-compatible `aiSearch` provider to the
|
|
288
|
+
extension tools and universal-search client.
|
|
289
|
+
- `lakebase-plugin` - `lakebaseAiSearch`, the AppKit-compatible PostgreSQL
|
|
290
|
+
full-text provider.
|
|
291
|
+
- `lakebase` - `LakebaseSearchBackend`, the provider's `tsvector` runtime.
|
|
292
|
+
- `query` - `toDocumentArray`, shared by write routes and tools.
|
|
307
293
|
- `runtime` - `getSearchRuntime` / `resetSearchRuntime` (the shared client).
|
|
308
294
|
- `schema` - the tool descriptions and re-exported request schemas.
|
|
309
295
|
|
package/index.ts
CHANGED
|
@@ -7,19 +7,23 @@ export * as client from "./src/client.ts";
|
|
|
7
7
|
export * as config from "./src/config.ts";
|
|
8
8
|
export * as indexTools from "./src/index-tools.ts";
|
|
9
9
|
export * as lakebase from "./src/lakebase.ts";
|
|
10
|
+
export * as lakebasePlugin from "./src/lakebase-plugin.ts";
|
|
11
|
+
export * as native from "./src/native.ts";
|
|
10
12
|
export * as plugin from "./src/plugin.ts";
|
|
11
13
|
export * as query from "./src/query.ts";
|
|
12
14
|
export * as runtime from "./src/runtime.ts";
|
|
13
15
|
export * as schema from "./src/schema.ts";
|
|
14
16
|
export * as tool from "./src/tool.ts";
|
|
15
17
|
export { SearchIndex, SearchClient } from "./src/client.ts";
|
|
16
|
-
export type { SearchOptions, UniversalSearchOptions, IndexInfo, CreateIndexOptions, EnsureEndpointOptions, ProvisionOptions } from "./src/client.ts";
|
|
18
|
+
export type { SearchReadBackend, SearchOptions, UniversalSearchOptions, IndexInfo, CreateIndexOptions, EnsureEndpointOptions, ProvisionOptions } from "./src/client.ts";
|
|
17
19
|
export { INDEX_ENV, DATABRICKS_INDEX_ENV, ENDPOINT_ENV, DEFAULT_MODE, DEFAULT_PAGE_SIZE, DEFAULT_TIMEOUT_MS, DEFAULT_BASE_PATH, SEARCH_CONFIG_SCHEMA } from "./src/config.ts";
|
|
18
20
|
export type { SearchIndexConfig, SearchPluginConfig, EnsureOnSetupConfig, ResolvedIndexConfig, ResolvedSearchConfig } from "./src/config.ts";
|
|
19
21
|
export { LakebaseSearchBackend } from "./src/lakebase.ts";
|
|
20
22
|
export type { LakebaseSearchOptions, LakebaseProvisionOptions } from "./src/lakebase.ts";
|
|
23
|
+
export { LakebaseAiSearchPlugin, lakebaseAiSearch } from "./src/lakebase-plugin.ts";
|
|
24
|
+
export type { LakebaseAiSearchIndexConfig, LakebaseAiSearchConfig } from "./src/lakebase-plugin.ts";
|
|
25
|
+
export type { AiSearchProvider } from "./src/native.ts";
|
|
21
26
|
export { SearchPlugin, search } from "./src/plugin.ts";
|
|
22
|
-
export type { QueryResponseLike } from "./src/query.ts";
|
|
23
27
|
export type { SearchRuntimeOptions, SearchRuntime } from "./src/runtime.ts";
|
|
24
28
|
export { SEARCH_TOOL_DESCRIPTION, UNIVERSAL_SEARCH_TOOL_DESCRIPTION, ADD_DOCUMENTS_TOOL_DESCRIPTION, CREATE_INDEX_TOOL_DESCRIPTION, SYNC_INDEX_TOOL_DESCRIPTION, searchToolSchema, universalSearchToolSchema, searchResultSchema, createIndexToolSchema, indexInfoSchema, syncIndexToolSchema } from "./src/schema.ts";
|
|
25
29
|
export type { SearchToolOptions } from "./src/tool.ts";
|
package/lib/index.d.ts
CHANGED
|
@@ -3,19 +3,23 @@ export * as client from "./src/client.ts";
|
|
|
3
3
|
export * as config from "./src/config.ts";
|
|
4
4
|
export * as indexTools from "./src/index-tools.ts";
|
|
5
5
|
export * as lakebase from "./src/lakebase.ts";
|
|
6
|
+
export * as lakebasePlugin from "./src/lakebase-plugin.ts";
|
|
7
|
+
export * as native from "./src/native.ts";
|
|
6
8
|
export * as plugin from "./src/plugin.ts";
|
|
7
9
|
export * as query from "./src/query.ts";
|
|
8
10
|
export * as runtime from "./src/runtime.ts";
|
|
9
11
|
export * as schema from "./src/schema.ts";
|
|
10
12
|
export * as tool from "./src/tool.ts";
|
|
11
13
|
export { SearchIndex, SearchClient } from "./src/client.ts";
|
|
12
|
-
export type { SearchOptions, UniversalSearchOptions, IndexInfo, CreateIndexOptions, EnsureEndpointOptions, ProvisionOptions } from "./src/client.ts";
|
|
14
|
+
export type { SearchReadBackend, SearchOptions, UniversalSearchOptions, IndexInfo, CreateIndexOptions, EnsureEndpointOptions, ProvisionOptions } from "./src/client.ts";
|
|
13
15
|
export { INDEX_ENV, DATABRICKS_INDEX_ENV, ENDPOINT_ENV, DEFAULT_MODE, DEFAULT_PAGE_SIZE, DEFAULT_TIMEOUT_MS, DEFAULT_BASE_PATH, SEARCH_CONFIG_SCHEMA } from "./src/config.ts";
|
|
14
16
|
export type { SearchIndexConfig, SearchPluginConfig, EnsureOnSetupConfig, ResolvedIndexConfig, ResolvedSearchConfig } from "./src/config.ts";
|
|
15
17
|
export { LakebaseSearchBackend } from "./src/lakebase.ts";
|
|
16
18
|
export type { LakebaseSearchOptions, LakebaseProvisionOptions } from "./src/lakebase.ts";
|
|
19
|
+
export { LakebaseAiSearchPlugin, lakebaseAiSearch } from "./src/lakebase-plugin.ts";
|
|
20
|
+
export type { LakebaseAiSearchIndexConfig, LakebaseAiSearchConfig } from "./src/lakebase-plugin.ts";
|
|
21
|
+
export type { AiSearchProvider } from "./src/native.ts";
|
|
17
22
|
export { SearchPlugin, search } from "./src/plugin.ts";
|
|
18
|
-
export type { QueryResponseLike } from "./src/query.ts";
|
|
19
23
|
export type { SearchRuntimeOptions, SearchRuntime } from "./src/runtime.ts";
|
|
20
24
|
export { SEARCH_TOOL_DESCRIPTION, UNIVERSAL_SEARCH_TOOL_DESCRIPTION, ADD_DOCUMENTS_TOOL_DESCRIPTION, CREATE_INDEX_TOOL_DESCRIPTION, SYNC_INDEX_TOOL_DESCRIPTION, searchToolSchema, universalSearchToolSchema, searchResultSchema, createIndexToolSchema, indexInfoSchema, syncIndexToolSchema } from "./src/schema.ts";
|
|
21
25
|
export type { SearchToolOptions } from "./src/tool.ts";
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,8 @@ export * as client from "./src/client.js";
|
|
|
6
6
|
export * as config from "./src/config.js";
|
|
7
7
|
export * as indexTools from "./src/index-tools.js";
|
|
8
8
|
export * as lakebase from "./src/lakebase.js";
|
|
9
|
+
export * as lakebasePlugin from "./src/lakebase-plugin.js";
|
|
10
|
+
export * as native from "./src/native.js";
|
|
9
11
|
export * as plugin from "./src/plugin.js";
|
|
10
12
|
export * as query from "./src/query.js";
|
|
11
13
|
export * as runtime from "./src/runtime.js";
|
|
@@ -14,6 +16,7 @@ export * as tool from "./src/tool.js";
|
|
|
14
16
|
export { SearchIndex, SearchClient } from "./src/client.js";
|
|
15
17
|
export { INDEX_ENV, DATABRICKS_INDEX_ENV, ENDPOINT_ENV, DEFAULT_MODE, DEFAULT_PAGE_SIZE, DEFAULT_TIMEOUT_MS, DEFAULT_BASE_PATH, SEARCH_CONFIG_SCHEMA } from "./src/config.js";
|
|
16
18
|
export { LakebaseSearchBackend } from "./src/lakebase.js";
|
|
19
|
+
export { LakebaseAiSearchPlugin, lakebaseAiSearch } from "./src/lakebase-plugin.js";
|
|
17
20
|
export { SearchPlugin, search } from "./src/plugin.js";
|
|
18
21
|
export { SEARCH_TOOL_DESCRIPTION, UNIVERSAL_SEARCH_TOOL_DESCRIPTION, ADD_DOCUMENTS_TOOL_DESCRIPTION, CREATE_INDEX_TOOL_DESCRIPTION, SYNC_INDEX_TOOL_DESCRIPTION, searchToolSchema, universalSearchToolSchema, searchResultSchema, createIndexToolSchema, indexInfoSchema, syncIndexToolSchema } from "./src/schema.js";
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQ0FBMkM7QUFDM0MsbURBQW1EO0FBQ25ELHdFQUF3RTtBQUV4RSxNQUFNLENBQUMsTUFBTSxrQkFBa0IsR0FBRyxtQkFBbUIsQ0FBQztBQUN0RCxPQUFPLEtBQUssTUFBTSxNQUFNLGlCQUFpQixDQUFDO0FBQzFDLE9BQU8sS0FBSyxNQUFNLE1BQU0saUJBQWlCLENBQUM7QUFDMUMsT0FBTyxLQUFLLFVBQVUsTUFBTSxzQkFBc0IsQ0FBQztBQUNuRCxPQUFPLEtBQUssUUFBUSxNQUFNLG1CQUFtQixDQUFDO0FBQzlDLE9BQU8sS0FBSyxjQUFjLE1BQU0sMEJBQTBCLENBQUM7QUFDM0QsT0FBTyxLQUFLLE1BQU0sTUFBTSxpQkFBaUIsQ0FBQztBQUMxQyxPQUFPLEtBQUssTUFBTSxNQUFNLGlCQUFpQixDQUFDO0FBQzFDLE9BQU8sS0FBSyxLQUFLLE1BQU0sZ0JBQWdCLENBQUM7QUFDeEMsT0FBTyxLQUFLLE9BQU8sTUFBTSxrQkFBa0IsQ0FBQztBQUM1QyxPQUFPLEtBQUssTUFBTSxNQUFNLGlCQUFpQixDQUFDO0FBQzFDLE9BQU8sS0FBSyxJQUFJLE1BQU0sZUFBZSxDQUFDO0FBQ3RDLE9BQU8sRUFBRSxXQUFXLEVBQUUsWUFBWSx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DSF9UT09MX0RFU0NSSVBUSU9OLCBBRERfRE9DVU1FTlRTX1RPT0xfREVTQ1JJUFRJT04sIENSRUFURV9JTkRFWF9UT09MX0RFU0NSSVBUSU9OLCBTWU5DX0lOREVYX1RPT0xfREVTQ1JJUFRJT04sIHNlYXJjaFRvb2xTY2hlbWEsIHVuaXZlcnNhbFNlYXJjaFRvb2xTY2hlbWEsIHNlYXJjaFJlc3VsdFNjaGVtYSwgY3JlYXRlSW5kZXhUb29sU2NoZW1hLCBpbmRleEluZm9TY2hlbWEsIHN5bmNJbmRleFRvb2xTY2hlbWEgfSBmcm9tIFwiLi9zcmMvc2NoZW1hLnRzXCI7XG5leHBvcnQgdHlwZSB7IFNlYXJjaFRvb2xPcHRpb25zIH0gZnJvbSBcIi4vc3JjL3Rvb2wudHNcIjtcbiJdfQ==
|
package/lib/src/client.d.ts
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* query_type, num_results, filters_json })` is powerful but verbose, and the
|
|
6
|
-
* response is columnar. This client hides all of that behind two objects:
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* const client = createSearchClient();
|
|
10
|
-
* const index = client.index("main.support.docs");
|
|
11
|
-
* const { hits } = await index.search("reset my password", { limit: 5 });
|
|
12
|
-
* await index.addDocuments([{ id: "42", title: "Reset", body: "..." }]);
|
|
13
|
-
* ```
|
|
2
|
+
* Search extension client. Reads delegate to the registered AppKit-compatible
|
|
3
|
+
* `aiSearch` provider; this module owns federated fan-out and the Vector Search
|
|
4
|
+
* lifecycle APIs AppKit does not expose.
|
|
14
5
|
*
|
|
15
6
|
* `client.search(query, opts)` searches the default index; `client.index(name)`
|
|
16
7
|
* returns a handle bound to one index; `client.universalSearch(query)` fans a
|
|
17
8
|
* query across several indexes and merges the results (Meilisearch's federated
|
|
18
9
|
* / multi-search, the "universal search" the caller asked for). Everything is
|
|
19
|
-
* async and cancellable
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
10
|
+
* async and cancellable and returns the browser-safe shapes from
|
|
11
|
+
* `@dbx-tools/shared-search`. Lifecycle methods cross AppKit's explicit legacy
|
|
12
|
+
* client handoff because the public facade does not yet expose index creation,
|
|
13
|
+
* sync, or deletion.
|
|
23
14
|
*
|
|
24
15
|
* Autocomplete is just a search with a small `limit` and the raw query text -
|
|
25
16
|
* hybrid mode already prefix-matches, so no separate endpoint is needed; the
|
|
@@ -28,10 +19,16 @@
|
|
|
28
19
|
* @module
|
|
29
20
|
*/
|
|
30
21
|
import { appkit } from "@dbx-tools/appkit";
|
|
31
|
-
import type { SearchDocument, SearchMode, SearchResult, UpsertResult } from "@dbx-tools/shared-search";
|
|
22
|
+
import type { SearchDocument, SearchMode, SearchRequest, SearchResult, UpsertResult } from "@dbx-tools/shared-search";
|
|
32
23
|
import { type ResolvedSearchConfig } from "./config.ts";
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
type WorkspaceClientLike = ReturnType<appkit.WorkspaceClientLike["toLegacyWorkspaceClient"]>;
|
|
25
|
+
/** Query backend used when AppKit owns the Vector Search execution path. */
|
|
26
|
+
export interface SearchReadBackend {
|
|
27
|
+
/** Whether Vector Search lifecycle methods are valid for this provider. */
|
|
28
|
+
supportsLifecycle: boolean;
|
|
29
|
+
search(index: string, query: string, options?: SearchOptions): Promise<SearchResult>;
|
|
30
|
+
addDocuments?(index: string, documents: SearchDocument[], signal?: AbortSignal): Promise<UpsertResult>;
|
|
31
|
+
}
|
|
35
32
|
/** Options accepted by a single-index search. */
|
|
36
33
|
export interface SearchOptions {
|
|
37
34
|
/** Maximum hits to return. Defaults to the configured page size. */
|
|
@@ -40,8 +37,8 @@ export interface SearchOptions {
|
|
|
40
37
|
mode?: SearchMode;
|
|
41
38
|
/** Columns to return per hit. Defaults to the index's configured columns. */
|
|
42
39
|
columns?: readonly string[];
|
|
43
|
-
/**
|
|
44
|
-
filter?:
|
|
40
|
+
/** AppKit AI Search scalar/array filters. */
|
|
41
|
+
filter?: SearchRequest["filter"];
|
|
45
42
|
/** Drop hits below this score. */
|
|
46
43
|
scoreThreshold?: number;
|
|
47
44
|
/** External cancellation. */
|
|
@@ -178,23 +175,8 @@ export interface ProvisionOptions extends CreateIndexOptions {
|
|
|
178
175
|
export declare class SearchClient {
|
|
179
176
|
private readonly config;
|
|
180
177
|
private readonly workspaceClientFactory;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
* Search endpoint is configured but a Lakebase pool is available; when set,
|
|
184
|
-
* search / provision / write operations delegate to it and return the exact
|
|
185
|
-
* same shapes, so nothing downstream can tell which backend answered.
|
|
186
|
-
*/
|
|
187
|
-
private readonly lakebase?;
|
|
188
|
-
constructor(config?: ResolvedSearchConfig, workspaceClientFactory?: () => WorkspaceClientLike,
|
|
189
|
-
/**
|
|
190
|
-
* Optional Lakebase full-text FALLBACK backend. Present only when no Vector
|
|
191
|
-
* Search endpoint is configured but a Lakebase pool is available; when set,
|
|
192
|
-
* search / provision / write operations delegate to it and return the exact
|
|
193
|
-
* same shapes, so nothing downstream can tell which backend answered.
|
|
194
|
-
*/
|
|
195
|
-
lakebase?: LakebaseSearchBackend | undefined);
|
|
196
|
-
/** True when this client is answering out of the Lakebase fallback backend. */
|
|
197
|
-
get usesLakebase(): boolean;
|
|
178
|
+
private readonly readBackend?;
|
|
179
|
+
constructor(config?: ResolvedSearchConfig, workspaceClientFactory?: () => WorkspaceClientLike, readBackend?: SearchReadBackend | undefined);
|
|
198
180
|
/** A handle bound to one index (by full UC name or configured alias). */
|
|
199
181
|
index(reference: string): SearchIndex;
|
|
200
182
|
/**
|
|
@@ -204,10 +186,6 @@ export declare class SearchClient {
|
|
|
204
186
|
search(query: string, options?: SearchOptions & {
|
|
205
187
|
index?: string;
|
|
206
188
|
}): Promise<SearchResult>;
|
|
207
|
-
/** Cache of index-name -> is-DIRECT_ACCESS, so a search embeds its query only when needed. */
|
|
208
|
-
private readonly directAccessCache;
|
|
209
|
-
/** Whether an index is DIRECT_ACCESS (memoized); a lookup failure assumes Delta Sync. */
|
|
210
|
-
private isDirectAccess;
|
|
211
189
|
/**
|
|
212
190
|
* Fan a query across several indexes and merge the hits, sorted by score -
|
|
213
191
|
* the "universal search" a single box over many collections needs. Each
|
|
@@ -224,6 +202,8 @@ export declare class SearchClient {
|
|
|
224
202
|
* `ENDPOINT_NOT_FOUND` instead of naming the real problem.
|
|
225
203
|
*/
|
|
226
204
|
private requireIndexName;
|
|
205
|
+
/** Reject Vector Search lifecycle calls against a non-Vector provider. */
|
|
206
|
+
private requireLifecycle;
|
|
227
207
|
/** Fetch an index's live definition. */
|
|
228
208
|
getIndex(reference: string, signal?: AbortSignal): Promise<IndexInfo>;
|
|
229
209
|
/** Add or update documents in a direct-access index. */
|
|
@@ -300,5 +280,5 @@ export declare class SearchClient {
|
|
|
300
280
|
private withClient;
|
|
301
281
|
}
|
|
302
282
|
/** Construct a {@link SearchClient} from a resolved config. */
|
|
303
|
-
export declare function createSearchClient(config?: ResolvedSearchConfig, workspaceClientFactory?: () => WorkspaceClientLike,
|
|
283
|
+
export declare function createSearchClient(config?: ResolvedSearchConfig, workspaceClientFactory?: () => WorkspaceClientLike, readBackend?: SearchReadBackend): SearchClient;
|
|
304
284
|
export {};
|