@midsummer-ai/sdk 0.1.0-next.901 → 0.1.0-staging.3100

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 (40) hide show
  1. package/auth-1W-SzpD3.mjs +441 -0
  2. package/build-DQo-JrlN.d.mts +120 -0
  3. package/bytes-C2pcyl9u.mjs +280 -0
  4. package/{connection-CDk7H1FL.mjs → connection-Cu2GSOaR.mjs} +171 -31
  5. package/database/build.d.mts +2 -2
  6. package/database/build.mjs +1404 -117
  7. package/database/client.d.mts +85 -9
  8. package/database/client.mjs +550 -32
  9. package/database/contract.d.mts +92 -2
  10. package/database/contract.mjs +2179 -3
  11. package/database/errors.d.mts +1 -22
  12. package/database/react.d.mts +133 -0
  13. package/database/react.mjs +488 -0
  14. package/database/server.d.mts +2 -3
  15. package/database/server.mjs +3 -320
  16. package/database/stand-in.d.mts +95 -9
  17. package/database/stand-in.mjs +1436 -116
  18. package/errors-x2vXKi0u.d.mts +25 -0
  19. package/index-DNNXNny7.d.mts +410 -0
  20. package/key-BrRdFY-n.mjs +11 -0
  21. package/package.json +114 -1
  22. package/schema-CTHQMRsW.mjs +217 -0
  23. package/server-B5HK2Ou9.d.mts +574 -0
  24. package/server-EDRbF2u-.mjs +1893 -0
  25. package/{store-BzI9at5x.mjs → store-lIZ5GxVv.mjs} +1 -1
  26. package/{tabs-D-P8_ci_.mjs → tabs-zCh8kceo.mjs} +1 -1
  27. package/vector/contract.d.mts +1 -1
  28. package/vector/contract.mjs +773 -1
  29. package/vector/index.d.mts +2 -2
  30. package/vector/index.mjs +71 -3
  31. package/vector/stand-in.d.mts +1 -1
  32. package/vector/stand-in.mjs +326 -23
  33. package/vector/wire.d.mts +11 -2
  34. package/vector/wire.mjs +179 -14
  35. package/build-SQ44jwSa.d.mts +0 -41
  36. package/index-DdoK0y7D.d.mts +0 -192
  37. package/schema-BF-Y1EVu.mjs +0 -142
  38. package/schema-DS8x1Dn8.mjs +0 -115
  39. package/schema-f7E9uzUn.d.mts +0 -74
  40. package/server-C7O7CICU.d.mts +0 -182
@@ -0,0 +1,25 @@
1
+ //#region src/database/errors.d.ts
2
+ /**
3
+ * Why a Database refused a call, as the client throws it: the same codes from the Stand-in and the
4
+ * Database.
5
+ *
6
+ * - `refused`: the function threw; nothing it wrote was kept.
7
+ * - `short`: a `take` asked for more than a field holds; nothing moved.
8
+ * - `notfound`: a patch or replace named a row that is not there.
9
+ * - `invalid`: the arguments, the answer or a write did not fit their shapes.
10
+ * - `internal`: an internal function, which no client may call.
11
+ * - `no function`: no function of that name.
12
+ * - `busy`, `quota`, `paused`: a limit the Project's plan or budget sets; `busy` may be sent again.
13
+ * - `denied`: the caller may not do this: a Database Key or token was refused, or a token that only reads asked to write.
14
+ * - `unauthenticated`: the Database took no caller from the connection: its token did not verify (expired, forged, for
15
+ * another audience, from an issuer it doesn't trust), or there was none and the Database admits no anonymous callers.
16
+ * - `unavailable`: the Database could not be reached, or could not finish the call.
17
+ */
18
+ type DatabaseErrorCode = "refused" | "short" | "notfound" | "invalid" | "internal" | "no function" | "busy" | "quota" | "paused" | "denied" | "unauthenticated" | "unavailable";
19
+ declare class DatabaseError extends Error {
20
+ readonly code: DatabaseErrorCode | (string & {});
21
+ readonly detail?: unknown;
22
+ constructor(code: DatabaseErrorCode | (string & {}), message?: string, detail?: unknown);
23
+ }
24
+ //#endregion
25
+ export { DatabaseErrorCode as n, DatabaseError as t };
@@ -0,0 +1,410 @@
1
+ import { z } from "zod";
2
+ //#region src/vector/errors.d.ts
3
+ /**
4
+ * Why a Vector DB call failed. `invalid`: a name, Vector, filter or option is wrong, or a Vector's
5
+ * dimension is not its namespace's. `not_found`: the Vector namespace does not exist. `conflict`:
6
+ * a namespace by that name exists with another dimension or metric. `forbidden`: the caller may not
7
+ * do this. `unavailable`: try again.
8
+ */
9
+ type VectorErrorCode = "invalid" | "not_found" | "conflict" | "forbidden" | "unavailable";
10
+ declare const vectorErrorCodes: ReadonlyArray<VectorErrorCode>;
11
+ declare class VectorError extends Error {
12
+ readonly code: VectorErrorCode;
13
+ constructor(code: VectorErrorCode, why: string);
14
+ }
15
+ //#endregion
16
+ //#region src/vector/schema.d.ts
17
+ /** Most numbers a Vector holds. */
18
+ declare const MAX_DIMENSION = 4096;
19
+ /** Most Vectors one upsert takes, and most ids one fetch or delete names. */
20
+ declare const MAX_BATCH = 1000;
21
+ /** The most matches one query returns. */
22
+ declare const MAX_TOP_K = 100;
23
+ /** Most characters a text to embed has. */
24
+ declare const MAX_TEXT = 30000;
25
+ /** Most bytes a Vector's metadata takes, as JSON. */
26
+ declare const MAX_METADATA_BYTES = 10240;
27
+ /** Most searches one `multiQuery` asks. */
28
+ declare const MAX_QUERIES = 16;
29
+ /** Most metadata fields a namespace keeps full text. */
30
+ declare const MAX_FULL_TEXT = 16;
31
+ /**
32
+ * The largest value a Vector holds. Engines keep values and scores as 32-bit floats, and within it
33
+ * every score of 4,096 values is one, finite: a squared distance is at most 4,096 · (2e17)², about
34
+ * 1.6e38, under a 32-bit float's 3.4e38. Scores are exact to a 32-bit float's precision for values
35
+ * from 1e-17 up.
36
+ */
37
+ declare const MAX_VALUE = 100000000000000000;
38
+ //#endregion
39
+ //#region src/vector/index.d.ts
40
+ /** How closeness is measured: fixed when a Vector namespace is made. */
41
+ type Metric = "cosine" | "euclidean" | "dot";
42
+ /** A single metadata value: a string, a finite number or a boolean. */
43
+ type Scalar = string | number | boolean;
44
+ /** A metadata value: a scalar, or an array of strings and numbers (100 at most). */
45
+ type MetadataValue = Scalar | ReadonlyArray<string | number>;
46
+ /** One Vector: its id in its namespace, its numbers, and the caller's own fields to filter on. */
47
+ interface Vector {
48
+ /** 1 to 512 characters. */
49
+ readonly id: string;
50
+ /** Exactly the namespace's dimension of finite numbers. With `cosine`, not all zero. */
51
+ readonly values: ReadonlyArray<number>;
52
+ /** Up to 10 KiB as JSON; field names do not start with `$`. */
53
+ readonly metadata?: Readonly<Record<string, MetadataValue>>;
54
+ }
55
+ /** A Vector given as text, for a namespace made with an embedding model: its values are the text's embedding. */
56
+ interface TextVector {
57
+ /** 1 to 512 characters. */
58
+ readonly id: string;
59
+ /** 1 to 30,000 characters, not all of them spaces. */
60
+ readonly text: string;
61
+ readonly metadata?: Readonly<Record<string, MetadataValue>>;
62
+ }
63
+ /**
64
+ * What a field's metadata must be. A bare value is `$eq`.
65
+ *
66
+ * - `$eq`, `$ne`, `$in`, `$nin`: equal to the value, or one of them. `null` stands for a field the
67
+ * Vector does not have: `{ $eq: null }` holds for a Vector without the field.
68
+ * - `$gt`, `$gte`, `$lt`, `$lte`: compare a number with a number and a string with a string, in
69
+ * code-unit order; anything else fails them.
70
+ * - `$contains`, `$notContains`: an array has the value, or a string has it as a substring.
71
+ * `$containsAny`, `$notContainsAny`: an array holds any of the values.
72
+ * - `$anyGt`, `$anyGte`, `$anyLt`, `$anyLte`: some number (or string) of an array compares so.
73
+ * - `$glob`, `$notGlob`: a string matches the pattern (`*` any run, `?` any one character, `[a-z]` one
74
+ * of a set, `[!a-z]` one not in it); `$iglob`, `$notIGlob` the same ignoring case.
75
+ * - `$containsAllTokens`, `$containsAnyToken`, `$containsTokenSequence`: the field's words (letters
76
+ * and digits, in lower case) hold every word of the string, any of them (the last a prefix with
77
+ * `lastAsPrefix`), or all of them in that order.
78
+ *
79
+ * A Vector without the field fails every condition but `$eq: null`, `$ne`, `$in` with `null`, `$nin`
80
+ * without it, and the `$not` ones (`$notContains`, `$notContainsAny`, `$notGlob`, `$notIGlob`).
81
+ */
82
+ type Condition = Scalar | {
83
+ readonly $eq?: Scalar | null;
84
+ readonly $ne?: Scalar | null;
85
+ readonly $in?: ReadonlyArray<Scalar | null>;
86
+ readonly $nin?: ReadonlyArray<Scalar | null>;
87
+ readonly $gt?: number | string;
88
+ readonly $gte?: number | string;
89
+ readonly $lt?: number | string;
90
+ readonly $lte?: number | string;
91
+ readonly $contains?: string | number;
92
+ readonly $notContains?: string | number;
93
+ readonly $containsAny?: ReadonlyArray<string | number>;
94
+ readonly $notContainsAny?: ReadonlyArray<string | number>;
95
+ readonly $anyGt?: number | string;
96
+ readonly $anyGte?: number | string;
97
+ readonly $anyLt?: number | string;
98
+ readonly $anyLte?: number | string;
99
+ readonly $glob?: string;
100
+ readonly $notGlob?: string;
101
+ readonly $iglob?: string;
102
+ readonly $notIGlob?: string;
103
+ readonly $containsAllTokens?: string;
104
+ readonly $containsAnyToken?: string | {
105
+ readonly tokens: string;
106
+ readonly lastAsPrefix?: boolean;
107
+ };
108
+ readonly $containsTokenSequence?: string;
109
+ };
110
+ /**
111
+ * Each field's condition, all of which must hold (`id` is the Vector's id); or `$and` / `$or` of
112
+ * filters, or `$not` of one.
113
+ */
114
+ type Filter = {
115
+ readonly [field: string]: Condition;
116
+ } | {
117
+ readonly $and: ReadonlyArray<Filter>;
118
+ } | {
119
+ readonly $or: ReadonlyArray<Filter>;
120
+ } | {
121
+ readonly $not: Filter;
122
+ };
123
+ interface QueryOptions {
124
+ /** How many matches, closest first: 1 to 100, default 10. */
125
+ readonly topK?: number;
126
+ readonly filter?: Filter;
127
+ /** Answer each match's values too. */
128
+ readonly includeValues?: boolean;
129
+ /** Answer each match's metadata too. */
130
+ readonly includeMetadata?: boolean;
131
+ /**
132
+ * `strong` (the default): every write made before the query is seen, and it runs in the namespace's
133
+ * home region. `eventual`: it runs where it is asked, on what the engine has indexed, which lags
134
+ * writes by up to about 15 seconds.
135
+ */
136
+ readonly consistency?: Consistency;
137
+ }
138
+ /** Whether a query sees every write made before it, or runs nearest and may lag them. */
139
+ type Consistency = "strong" | "eventual";
140
+ /**
141
+ * One Vector a query found. `score` is the metric's own number: the cosine similarity (1 is the
142
+ * same direction), the dot product, or the euclidean distance (0 is the same point). Matches come
143
+ * closest first, so highest score first except for `euclidean`, lowest first; equal scores in id order.
144
+ */
145
+ interface Match {
146
+ readonly id: string;
147
+ readonly score: number;
148
+ readonly values?: ReadonlyArray<number>;
149
+ readonly metadata?: Readonly<Record<string, MetadataValue>>;
150
+ }
151
+ /** What a listing or a text search returns of each Vector, beyond its id. */
152
+ interface Include {
153
+ /** Answer each Vector's values too. */
154
+ readonly includeValues?: boolean;
155
+ /** Answer each Vector's metadata too. */
156
+ readonly includeMetadata?: boolean;
157
+ }
158
+ /**
159
+ * Vectors in the order of their metadata: each `[field, "asc" | "desc"]` (`id` too) decides where the
160
+ * one before it ties, then id. A Vector without the field comes after every one with it, either way;
161
+ * values of different kinds (a number and a string) tie.
162
+ */
163
+ interface ListOptions extends Include {
164
+ /** 1 to 8 fields. */
165
+ readonly orderBy: ReadonlyArray<readonly [string, "asc" | "desc"]>;
166
+ readonly filter?: Filter;
167
+ /** 1 to 100, default 10. */
168
+ readonly topK?: number;
169
+ }
170
+ /** A Vector a listing found: no score. */
171
+ interface Listed {
172
+ readonly id: string;
173
+ readonly values?: ReadonlyArray<number>;
174
+ readonly metadata?: Readonly<Record<string, MetadataValue>>;
175
+ }
176
+ /**
177
+ * A text search: the Vectors whose `field` (one the namespace keeps full text) has the words, by
178
+ * BM25, best first. A field's text is its string, or its array's strings joined.
179
+ */
180
+ interface TextSearchOptions extends Include {
181
+ readonly field: string;
182
+ readonly filter?: Filter;
183
+ /** 1 to 100, default 10. */
184
+ readonly topK?: number;
185
+ }
186
+ /** One search of a `multiQuery`: by a vector (or a text to embed), or by words in a full-text field. */
187
+ type MultiQueryPart = (({
188
+ readonly vector: ReadonlyArray<number> | string;
189
+ }) | {
190
+ readonly textSearch: string;
191
+ readonly field: string;
192
+ }) & {
193
+ readonly filter?: Filter;
194
+ /** 1 to 100, default 10. */
195
+ readonly topK?: number;
196
+ };
197
+ /**
198
+ * Several searches at once, each seeing the same writes. With `fuse`, their matches are also fused
199
+ * into one list by reciprocal rank: a Vector's score is the sum, over the searches that found it, of
200
+ * the search's weight (1 unless `weights` says) over `k` (60 unless it says) plus its rank there,
201
+ * counting from 1; best first, ties by id.
202
+ */
203
+ interface MultiQueryOptions {
204
+ readonly fuse?: {
205
+ readonly rrf: {
206
+ readonly k?: number;
207
+ readonly weights?: ReadonlyArray<number>;
208
+ };
209
+ };
210
+ /** How many fused matches: 1 to 100, default 10. */
211
+ readonly topK?: number;
212
+ readonly includeMetadata?: boolean;
213
+ }
214
+ interface MultiQueryResult {
215
+ /** Each search's matches, in the order asked. */
216
+ readonly results: ReadonlyArray<ReadonlyArray<Match>>;
217
+ /** Asked `fuse`: the fused matches. */
218
+ readonly fused?: ReadonlyArray<Match>;
219
+ }
220
+ /** An aggregate: how many Vectors (`["count"]`), or the sum of a field's numbers (`["sum", field]`; a Vector without one adds nothing). */
221
+ type Aggregate = readonly ["count"] | readonly ["sum", string];
222
+ interface AggregateOptions {
223
+ /** 1 to 16, by the name each is returned under. */
224
+ readonly aggregates: Readonly<Record<string, Aggregate>>;
225
+ /** Grouped by these fields' values (1 to 8): a group for each distinct key, a Vector without a field `null` there. */
226
+ readonly groupBy?: ReadonlyArray<string>;
227
+ readonly filter?: Filter;
228
+ /** How many groups: 1 to 10,000, default 1,000. */
229
+ readonly limit?: number;
230
+ }
231
+ /** One group of an aggregate: its key (empty when not grouped) and its aggregates. Groups come by key, each field ascending, `null` last. */
232
+ interface AggregateGroup {
233
+ readonly key: Readonly<Record<string, MetadataValue | null>>;
234
+ readonly aggregates: Readonly<Record<string, number>>;
235
+ }
236
+ /** A Vector namespace as it is now. */
237
+ interface NamespaceInfo {
238
+ readonly dimension: number;
239
+ readonly metric: Metric;
240
+ /** How many Vectors it holds. */
241
+ readonly count: number;
242
+ }
243
+ /** The Vectors of one Vector namespace. */
244
+ interface Namespace {
245
+ readonly name: string;
246
+ /** Stores each Vector under its id, replacing what was there; one given as text is embedded first. The next query anywhere sees it. */
247
+ upsert(vectors: ReadonlyArray<Vector | TextVector>): Promise<{
248
+ readonly upserted: number;
249
+ }>;
250
+ /** The `topK` Vectors closest to `vector`, or to a text's embedding, that match `filter`, closest first. */
251
+ query(vector: ReadonlyArray<number> | string, options?: QueryOptions): Promise<ReadonlyArray<Match>>;
252
+ /** The Vectors with these ids, in the order asked, values and metadata included; ids it does not hold are left out. */
253
+ fetch(ids: ReadonlyArray<string>): Promise<ReadonlyArray<Vector>>;
254
+ /** Removes the Vectors with these ids. Removing one that is not there is not an error. */
255
+ delete(ids: ReadonlyArray<string>): Promise<void>;
256
+ describe(): Promise<NamespaceInfo>;
257
+ /** The first `topK` Vectors that match `filter` in the order `orderBy` says. */
258
+ list(options: ListOptions): Promise<ReadonlyArray<Listed>>;
259
+ /**
260
+ * The `topK` Vectors whose full-text `field` best holds `words`, by BM25. A field the namespace does
261
+ * not keep full text is `invalid`; one added a moment ago is `unavailable` until it is built.
262
+ */
263
+ textSearch(words: string, options: TextSearchOptions): Promise<ReadonlyArray<Match>>;
264
+ /** Up to 16 searches at once, fused into one list with `fuse`. */
265
+ multiQuery(queries: ReadonlyArray<MultiQueryPart>, options?: MultiQueryOptions): Promise<MultiQueryResult>;
266
+ /** Counts and sums over the Vectors that match `filter`, maybe grouped. */
267
+ aggregate(options: AggregateOptions): Promise<ReadonlyArray<AggregateGroup>>;
268
+ }
269
+ interface VectorDb {
270
+ /** A Vector namespace by name: 1 to 63 lowercase letters, digits and hyphens, starting with a letter or digit. */
271
+ namespace(name: string): Namespace;
272
+ }
273
+ /** A query as an engine takes it: checked, with its defaults filled in; by a vector, or a text to embed. */
274
+ type EngineQuery = ({
275
+ readonly vector: ReadonlyArray<number>;
276
+ } | {
277
+ readonly text: string;
278
+ }) & {
279
+ readonly topK: number;
280
+ readonly filter?: Filter;
281
+ readonly includeValues: boolean;
282
+ readonly includeMetadata: boolean;
283
+ readonly consistency?: Consistency;
284
+ };
285
+ /** A listing as an engine takes it: checked, its defaults filled in. */
286
+ interface EngineList {
287
+ readonly orderBy: ReadonlyArray<readonly [string, "asc" | "desc"]>;
288
+ readonly filter?: Filter;
289
+ readonly topK: number;
290
+ readonly includeValues: boolean;
291
+ readonly includeMetadata: boolean;
292
+ }
293
+ /** A text search as an engine takes it. */
294
+ interface EngineTextSearch {
295
+ readonly words: string;
296
+ readonly field: string;
297
+ readonly filter?: Filter;
298
+ readonly topK: number;
299
+ readonly includeValues: boolean;
300
+ readonly includeMetadata: boolean;
301
+ }
302
+ /** A multiQuery's search as an engine takes it: a text to embed (`text`) only before `embedded`. */
303
+ type EnginePart = ({
304
+ readonly vector: ReadonlyArray<number>;
305
+ } | {
306
+ readonly text: string;
307
+ } | {
308
+ readonly textSearch: string;
309
+ readonly field: string;
310
+ }) & {
311
+ readonly filter?: Filter;
312
+ readonly topK: number;
313
+ };
314
+ interface EngineMultiQuery {
315
+ readonly queries: ReadonlyArray<EnginePart>;
316
+ readonly fuse?: {
317
+ readonly k: number;
318
+ readonly weights: ReadonlyArray<number>;
319
+ };
320
+ readonly topK: number;
321
+ readonly includeMetadata: boolean;
322
+ }
323
+ /** A multiQuery as an engine that keeps only values takes it: its texts embedded already (`embedded`). */
324
+ type ValuesMultiQuery = Omit<EngineMultiQuery, "queries"> & {
325
+ readonly queries: ReadonlyArray<Exclude<EnginePart, {
326
+ readonly text: string;
327
+ }>>;
328
+ };
329
+ interface EngineAggregate {
330
+ readonly aggregates: Readonly<Record<string, Aggregate>>;
331
+ readonly groupBy: ReadonlyArray<string>;
332
+ readonly filter?: Filter;
333
+ readonly limit: number;
334
+ }
335
+ /**
336
+ * Where Vectors live: the Seam under `vectorDb()`. The Stand-in and the real Capability are its
337
+ * Adapters. A call arrives checked: names, ids, values, filters and limits valid. The engine checks
338
+ * what only it knows: that the namespace exists, and that each Vector has its dimension. An engine
339
+ * that keeps only values takes text through `embedded`.
340
+ */
341
+ interface VectorEngine {
342
+ describe(namespace: string): Promise<NamespaceInfo>;
343
+ upsert(namespace: string, vectors: ReadonlyArray<Vector | TextVector>): Promise<{
344
+ readonly upserted: number;
345
+ }>;
346
+ query(namespace: string, query: EngineQuery): Promise<ReadonlyArray<Match>>;
347
+ fetch(namespace: string, ids: ReadonlyArray<string>): Promise<ReadonlyArray<Vector>>;
348
+ delete(namespace: string, ids: ReadonlyArray<string>): Promise<void>;
349
+ list(namespace: string, list: EngineList): Promise<ReadonlyArray<Listed>>;
350
+ textSearch(namespace: string, search: EngineTextSearch): Promise<ReadonlyArray<Match>>;
351
+ multiQuery(namespace: string, multi: EngineMultiQuery): Promise<MultiQueryResult>;
352
+ aggregate(namespace: string, aggregate: EngineAggregate): Promise<ReadonlyArray<AggregateGroup>>;
353
+ }
354
+ /** An engine that keeps only values, as most do: `VectorEngine` without text, which `embedded` gives it. */
355
+ interface ValuesEngine {
356
+ describe(namespace: string): Promise<NamespaceInfo>;
357
+ upsert(namespace: string, vectors: ReadonlyArray<Vector>): Promise<{
358
+ readonly upserted: number;
359
+ }>;
360
+ query(namespace: string, query: Extract<EngineQuery, {
361
+ readonly vector: ReadonlyArray<number>;
362
+ }>): Promise<ReadonlyArray<Match>>;
363
+ fetch(namespace: string, ids: ReadonlyArray<string>): Promise<ReadonlyArray<Vector>>;
364
+ delete(namespace: string, ids: ReadonlyArray<string>): Promise<void>;
365
+ list(namespace: string, list: EngineList): Promise<ReadonlyArray<Listed>>;
366
+ textSearch(namespace: string, search: EngineTextSearch): Promise<ReadonlyArray<Match>>;
367
+ multiQuery(namespace: string, multi: ValuesMultiQuery): Promise<MultiQueryResult>;
368
+ aggregate(namespace: string, aggregate: EngineAggregate): Promise<ReadonlyArray<AggregateGroup>>;
369
+ }
370
+ /**
371
+ * Making, growing and dropping Vector namespaces: the platform's, never a Site's. `create` of one that
372
+ * exists with the same settings does nothing, and with others is `conflict`; `drop` of one that does
373
+ * not exist does nothing.
374
+ */
375
+ interface VectorControl {
376
+ /**
377
+ * `embed` is the embedding model whose vectors the namespace holds; without one, it takes values
378
+ * only. `fullText` lists the metadata fields kept full text, for `textSearch` (up to 16; more are
379
+ * added with `update`). `vectorType` is how values are kept: `f32` (the default), exactly as written;
380
+ * `f16`, in half the space, each value as a 16-bit float holds it (a fetch returns that, and matches
381
+ * are scored on it), where every value is at most 65,504 in size and the largest at least 2^-10.
382
+ */
383
+ create(namespace: string, settings: {
384
+ readonly dimension: number;
385
+ readonly metric: Metric;
386
+ readonly embed?: string;
387
+ readonly fullText?: ReadonlyArray<string>;
388
+ readonly vectorType?: "f32" | "f16";
389
+ }): Promise<void>;
390
+ /**
391
+ * Adds full-text fields (a field kept already stays): each is built from the Vectors there, and a
392
+ * text search of it is `unavailable` until it is. A field is never taken away.
393
+ */
394
+ update(namespace: string, change: {
395
+ readonly addFullText: ReadonlyArray<string>;
396
+ }): Promise<void>;
397
+ drop(namespace: string): Promise<void>;
398
+ }
399
+ /** Vector DB over `engine`. */
400
+ declare function vectorDb(engine: VectorEngine): VectorDb;
401
+ /**
402
+ * `engine`, which keeps only values, taking text too: the texts of each call are embedded by `embed`,
403
+ * given the namespace and the texts in order, before `engine` sees the call. `embed` returns
404
+ * `undefined` for a namespace made without an embedding model, which is `invalid`.
405
+ *
406
+ * const site = embedded(engine, (namespace, texts) => vector.embed(namespace, texts))
407
+ */
408
+ declare function embedded(engine: ValuesEngine, embed: (namespace: string, texts: ReadonlyArray<string>) => Promise<ReadonlyArray<ReadonlyArray<number>> | undefined>): VectorEngine;
409
+ //#endregion
410
+ export { VectorControl as A, MAX_TEXT as B, QueryOptions as C, ValuesEngine as D, TextVector as E, MAX_BATCH as F, vectorErrorCodes as G, MAX_VALUE as H, MAX_DIMENSION as I, MAX_FULL_TEXT as L, VectorEngine as M, embedded as N, ValuesMultiQuery as O, vectorDb as P, MAX_METADATA_BYTES as R, NamespaceInfo as S, TextSearchOptions as T, VectorError as U, MAX_TOP_K as V, VectorErrorCode as W, Metric as _, Consistency as a, MultiQueryResult as b, EngineMultiQuery as c, EngineTextSearch as d, Filter as f, MetadataValue as g, Match as h, Condition as i, VectorDb as j, Vector as k, EnginePart as l, Listed as m, AggregateGroup as n, EngineAggregate as o, ListOptions as p, AggregateOptions as r, EngineList as s, Aggregate as t, EngineQuery as u, MultiQueryOptions as v, Scalar as w, Namespace as x, MultiQueryPart as y, MAX_QUERIES as z };
@@ -0,0 +1,11 @@
1
+ import { n as bytesTagged } from "./bytes-C2pcyl9u.mjs";
2
+ //#region src/database/key.ts
3
+ /**
4
+ * A function call's identity: its name and its arguments as JSON with every object's keys sorted, so
5
+ * `{ a: 1, b: 2 }` and `{ b: 2, a: 1 }` are one query. What a watch is shared and found by.
6
+ */
7
+ function callKey(name, args) {
8
+ return `${name}|${JSON.stringify(bytesTagged(args ?? {}), (_key, value) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : value)}`;
9
+ }
10
+ //#endregion
11
+ export { callKey as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midsummer-ai/sdk",
3
- "version": "0.1.0-next.901",
3
+ "version": "0.1.0-staging.3100",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Midsummer's handles for an app's code: its Database, Storage, Queues, Vector DB, AI, Email and Agents, with stand-ins for tests.",
@@ -75,6 +75,10 @@
75
75
  "types": "./database/client.d.mts",
76
76
  "import": "./database/client.mjs"
77
77
  },
78
+ "./react": {
79
+ "types": "./database/react.d.mts",
80
+ "import": "./database/react.mjs"
81
+ },
78
82
  "./agents": {
79
83
  "types": "./agents/index.d.mts",
80
84
  "import": "./agents/index.mjs"
@@ -140,6 +144,107 @@
140
144
  "import": "./vector/wire.mjs"
141
145
  }
142
146
  },
147
+ "types": "./index.d.mts",
148
+ "typesVersions": {
149
+ "*": {
150
+ "stand-in": [
151
+ "./stand-in.d.mts"
152
+ ],
153
+ "contract": [
154
+ "./contract.d.mts"
155
+ ],
156
+ "wire": [
157
+ "./wire.d.mts"
158
+ ],
159
+ "s3": [
160
+ "./s3.d.mts"
161
+ ],
162
+ "socket": [
163
+ "./socket.d.mts"
164
+ ],
165
+ "ai": [
166
+ "./ai/index.d.mts"
167
+ ],
168
+ "ai/stand-in": [
169
+ "./ai/stand-in.d.mts"
170
+ ],
171
+ "ai/contract": [
172
+ "./ai/contract.d.mts"
173
+ ],
174
+ "client": [
175
+ "./client.d.mts"
176
+ ],
177
+ "server": [
178
+ "./database/server.d.mts"
179
+ ],
180
+ "database/build": [
181
+ "./database/build.d.mts"
182
+ ],
183
+ "database/stand-in": [
184
+ "./database/stand-in.d.mts"
185
+ ],
186
+ "database/contract": [
187
+ "./database/contract.d.mts"
188
+ ],
189
+ "database/errors": [
190
+ "./database/errors.d.mts"
191
+ ],
192
+ "database": [
193
+ "./database/client.d.mts"
194
+ ],
195
+ "react": [
196
+ "./database/react.d.mts"
197
+ ],
198
+ "agents": [
199
+ "./agents/index.d.mts"
200
+ ],
201
+ "agents/stand-in": [
202
+ "./agents/stand-in.d.mts"
203
+ ],
204
+ "agents/contract": [
205
+ "./agents/contract.d.mts"
206
+ ],
207
+ "queues": [
208
+ "./queues/index.d.mts"
209
+ ],
210
+ "queues/stand-in": [
211
+ "./queues/stand-in.d.mts"
212
+ ],
213
+ "queues/contract": [
214
+ "./queues/contract.d.mts"
215
+ ],
216
+ "queues/wire": [
217
+ "./queues/wire.d.mts"
218
+ ],
219
+ "email": [
220
+ "./email/index.d.mts"
221
+ ],
222
+ "email/stand-in": [
223
+ "./email/stand-in.d.mts"
224
+ ],
225
+ "email/contract": [
226
+ "./email/contract.d.mts"
227
+ ],
228
+ "email/client": [
229
+ "./email/client.d.mts"
230
+ ],
231
+ "email/smtp": [
232
+ "./email/smtp.d.mts"
233
+ ],
234
+ "vector": [
235
+ "./vector/index.d.mts"
236
+ ],
237
+ "vector/stand-in": [
238
+ "./vector/stand-in.d.mts"
239
+ ],
240
+ "vector/contract": [
241
+ "./vector/contract.d.mts"
242
+ ],
243
+ "vector/wire": [
244
+ "./vector/wire.d.mts"
245
+ ]
246
+ }
247
+ },
143
248
  "files": [
144
249
  "**/*.mjs",
145
250
  "**/*.d.mts",
@@ -150,5 +255,13 @@
150
255
  "acorn": "8.15.0",
151
256
  "zod": "4.1.12"
152
257
  },
258
+ "peerDependencies": {
259
+ "react": "^18.2.0 || ^19.0.0"
260
+ },
261
+ "peerDependenciesMeta": {
262
+ "react": {
263
+ "optional": true
264
+ }
265
+ },
153
266
  "sideEffects": false
154
267
  }