@yaks/embedding 0.0.0-stage → 0.2.36

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 (132) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +549 -2
  3. package/_dist/compile.d.ts +34 -0
  4. package/_dist/compile.d.ts.map +1 -0
  5. package/_dist/ddl.d.ts +31 -0
  6. package/_dist/ddl.d.ts.map +1 -0
  7. package/_dist/embedder.d.ts +55 -0
  8. package/_dist/embedder.d.ts.map +1 -0
  9. package/_dist/fields.d.ts +70 -0
  10. package/_dist/fields.d.ts.map +1 -0
  11. package/_dist/graph.d.ts +63 -0
  12. package/_dist/graph.d.ts.map +1 -0
  13. package/_dist/held.d.ts +16 -0
  14. package/_dist/held.d.ts.map +1 -0
  15. package/_dist/image.d.ts +20 -0
  16. package/_dist/image.d.ts.map +1 -0
  17. package/_dist/mod.d.ts +105 -0
  18. package/_dist/mod.d.ts.map +1 -0
  19. package/_dist/native.d.ts +20 -0
  20. package/_dist/native.d.ts.map +1 -0
  21. package/_dist/near.d.ts +35 -0
  22. package/_dist/near.d.ts.map +1 -0
  23. package/_dist/neighbours.d.ts +29 -0
  24. package/_dist/neighbours.d.ts.map +1 -0
  25. package/_dist/options.d.ts +37 -0
  26. package/_dist/options.d.ts.map +1 -0
  27. package/_dist/outage.d.ts +64 -0
  28. package/_dist/outage.d.ts.map +1 -0
  29. package/_dist/owed.d.ts +79 -0
  30. package/_dist/owed.d.ts.map +1 -0
  31. package/_dist/remote.d.ts +116 -0
  32. package/_dist/remote.d.ts.map +1 -0
  33. package/_dist/score.d.ts +10 -0
  34. package/_dist/score.d.ts.map +1 -0
  35. package/_dist/search.d.ts +24 -0
  36. package/_dist/search.d.ts.map +1 -0
  37. package/_dist/service.d.ts +23 -0
  38. package/_dist/service.d.ts.map +1 -0
  39. package/_dist/sleeper.d.ts +37 -0
  40. package/_dist/sleeper.d.ts.map +1 -0
  41. package/_dist/sweep.d.ts +71 -0
  42. package/_dist/sweep.d.ts.map +1 -0
  43. package/_dist/tools.d.ts +14 -0
  44. package/_dist/tools.d.ts.map +1 -0
  45. package/_dist/vector.d.ts +30 -0
  46. package/_dist/vector.d.ts.map +1 -0
  47. package/_dist/vocab.d.ts +6 -0
  48. package/_dist/vocab.d.ts.map +1 -0
  49. package/coded.js +98 -0
  50. package/coded.js.map +1 -0
  51. package/coded.ts +85 -0
  52. package/compile.js +145 -0
  53. package/compile.js.map +1 -0
  54. package/compile.ts +206 -0
  55. package/ddl.js +476 -0
  56. package/ddl.js.map +1 -0
  57. package/ddl.ts +346 -0
  58. package/deno.json +1 -0
  59. package/embedder.js +85 -0
  60. package/embedder.js.map +1 -0
  61. package/embedder.ts +113 -0
  62. package/fields.js +178 -0
  63. package/fields.js.map +1 -0
  64. package/fields.ts +259 -0
  65. package/fill.js +177 -0
  66. package/fill.js.map +1 -0
  67. package/fill.ts +144 -0
  68. package/graph.js +113 -0
  69. package/graph.js.map +1 -0
  70. package/graph.ts +167 -0
  71. package/held.js +680 -0
  72. package/held.js.map +1 -0
  73. package/held.ts +726 -0
  74. package/image.js +202 -0
  75. package/image.js.map +1 -0
  76. package/image.ts +185 -0
  77. package/mod.js +105 -0
  78. package/mod.js.map +1 -0
  79. package/mod.ts +113 -0
  80. package/native.js +236 -0
  81. package/native.js.map +1 -0
  82. package/native.ts +288 -0
  83. package/near.js +123 -0
  84. package/near.js.map +1 -0
  85. package/near.ts +192 -0
  86. package/neighbours.js +223 -0
  87. package/neighbours.js.map +1 -0
  88. package/neighbours.ts +303 -0
  89. package/options.js +187 -0
  90. package/options.js.map +1 -0
  91. package/options.ts +269 -0
  92. package/outage.js +128 -0
  93. package/outage.js.map +1 -0
  94. package/outage.ts +132 -0
  95. package/owed.js +287 -0
  96. package/owed.js.map +1 -0
  97. package/owed.ts +346 -0
  98. package/package.json +45 -4
  99. package/remote.js +264 -0
  100. package/remote.js.map +1 -0
  101. package/remote.ts +391 -0
  102. package/score.js +46 -0
  103. package/score.js.map +1 -0
  104. package/score.ts +60 -0
  105. package/search.js +65 -0
  106. package/search.js.map +1 -0
  107. package/search.ts +118 -0
  108. package/service.js +107 -0
  109. package/service.js.map +1 -0
  110. package/service.ts +133 -0
  111. package/sleeper.js +107 -0
  112. package/sleeper.js.map +1 -0
  113. package/sleeper.ts +166 -0
  114. package/sparse.js +36 -0
  115. package/sparse.js.map +1 -0
  116. package/sparse.ts +49 -0
  117. package/sweep.js +374 -0
  118. package/sweep.js.map +1 -0
  119. package/sweep.ts +446 -0
  120. package/tools.js +57 -0
  121. package/tools.js.map +1 -0
  122. package/tools.ts +88 -0
  123. package/vector.js +78 -0
  124. package/vector.js.map +1 -0
  125. package/vector.ts +96 -0
  126. package/visibility.js +83 -0
  127. package/visibility.js.map +1 -0
  128. package/visibility.ts +111 -0
  129. package/vocab.js +22 -0
  130. package/vocab.js.map +1 -0
  131. package/vocab.json +19 -0
  132. package/vocab.ts +22 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Text in, vector out — plus the name of the space the vectors live in. A model
3
+ * change is a `model` change: the stored hash covers it, so the sweep re-embeds
4
+ * the corpus and a search never mixes two spaces.
5
+ */ export type Embedder<Input = string> = {
6
+ /** names the vector space; changing it invalidates every stored vector */ model: string;
7
+ /** the vector for a piece of text; may be async (a hosted model). Calls
8
+ * made together may be answered together (./remote.ts batches them). */ embed: (input: Input) => Float32Array | Promise<Float32Array>;
9
+ };
10
+ /**
11
+ * What an embedder throws for a text it will not take, as distinct from an
12
+ * embedder that cannot be reached: the sweep drops a refused text and carries
13
+ * on, and stops at anything else, keeping the rest owed.
14
+ */ export declare class Refused extends Error {
15
+ }
16
+ /**
17
+ * What an embedder throws when its provider answered but will not embed for
18
+ * this host until a ceiling it set lifts, such as a monthly budget that is
19
+ * spent. Nothing failed: the texts stay owed, asking again sooner changes
20
+ * nothing, and the drain after the ceiling lifts embeds them (./outage.ts).
21
+ */ export declare class Withheld extends Error {
22
+ name: string;
23
+ }
24
+ /**
25
+ * What an embedder throws when its provider failed every time it was asked
26
+ * (./remote.ts `retrying`). One provider out is one failure, however many
27
+ * texts it was asked for or in which words it failed, so the message names
28
+ * only the provider: what varies rides `context` (the model, how many texts,
29
+ * how many tries), and the provider's last failure is the `cause`.
30
+ */ export declare class Unanswered extends Error {
31
+ name: string;
32
+ context: {
33
+ model: string;
34
+ texts: string;
35
+ tries: string;
36
+ };
37
+ constructor(provider: string, context: Unanswered['context'], cause: unknown);
38
+ }
39
+ /**
40
+ * Names the exact embedding a stored row holds: FNV-1a over the model and the
41
+ * text. It is what lets the sweep skip what has not changed without keeping a
42
+ * second copy of the prose.
43
+ */ export declare let hash: (model: string, text: string) => string;
44
+ /**
45
+ * A deterministic embedder with no model behind it: every word is hashed into
46
+ * one of `dim` buckets and the counts are normalized. Instant, offline, and the
47
+ * same answer on every machine, so tests and local development never reach the
48
+ * network.
49
+ *
50
+ * What it captures is vocabulary overlap — two texts sharing words score high,
51
+ * two texts sharing none score 0 — and nothing else. It has no sense of
52
+ * meaning, so swap in an embedding model before promising anyone semantic
53
+ * search; the rest of this package does not change when you do.
54
+ */ export declare let hashEmbedder: (dim?: number) => Embedder;
55
+ //# sourceMappingURL=embedder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedder.d.ts","sources":["../embedder.ts"],"names":[],"mappings":"AAgBA;;;;CAIC,GACD,YAAY,SAAS,QAAQ,MAAM;EACjC,wEAAwE,GACxE,OAAO,MAAM;EACb;wEACsE,GACtE,QAAQ,OAAO,UAAU,eAAe,QAAQ;;AAGlD;;;;CAIC,GACD,OAAO,cAAM,gBAAgB;AAAO;AAEpC;;;;;CAKC,GACD,OAAO,cAAM,iBAAiB;EACnB,aAAiB;AAC5B;AAEA;;;;;;CAMC,GACD,OAAO,cAAM,mBAAmB;EACrB,aAAmB;EAC5B;IAAW,OAAO,MAAM;IAAE,OAAO,MAAM;IAAE,OAAO,MAAM;IAAE;EACxD,YACE,UAAU,MAAM,EAChB,SAAS,WAAW,UAAU,EAC9B,OAAO,OAAO;AAKlB;AAEA;;;;CAIC,GACD,OAAO,YAAI,OAAQ,OAAO,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,CAChB;AAkBvC;;;;;;;;;;CAUC,GACD,OAAO,YAAI,eAAgB,iBAAW,SAWpC"}
@@ -0,0 +1,70 @@
1
+ import { ARMS, type Derived, type Expr, type Query, type Statements } from "@yaks/sql";
2
+ import type { Prop, Vocab } from "@yaks/vocab";
3
+ /** A `comp.prop` pair naming one embedded text property; for text an entity
4
+ * is found by through another of its components, that component (`on`: an
5
+ * `entry` is found by `content.body`); and — for a property that does not hold
6
+ * its own text, like a @yaks/blob body holding an address — the expression that
7
+ * reads the text a stored value stands for. */ export type Field = {
8
+ comp: string;
9
+ prop: string;
10
+ on?: string;
11
+ /** components whose wearers are never embedded (vocabulary `embed: false`,
12
+ * or `found: false`, which no search finds) */ not?: string[];
13
+ text?: (stored: Expr) => Expr;
14
+ };
15
+ /** Fields read through a host's derived columns (@yaks/sql `Derived`), so a
16
+ * content-addressed body is embedded as its prose, never as its hash. */ export declare let resolved: (fields: Field[], derived?: Derived) => Field[];
17
+ /**
18
+ * Decides whether a property is embedded. An application passes its own to
19
+ * embed less than everything textual — say, the blurb but not the title.
20
+ */ export type Pick = (prop: Prop) => boolean;
21
+ /**
22
+ * The default choice: every stored text property. A computed property has no
23
+ * row to read, and a number, a stamp or a reference is not prose.
24
+ */ export declare let textual: Pick;
25
+ /**
26
+ * The text a bare word searches: the stored text properties the vocabulary
27
+ * marks `search: true`. What a plugin embeds when its config names no `text`,
28
+ * beside the text a component's `search` list says its entities are found by
29
+ * (a transcript entry's `content.body`), so a vector is made of what people
30
+ * and agents said, never of tool arguments or command lines, which are text
31
+ * too.
32
+ */ export declare let searched: Pick;
33
+ /** The embedded fields of a vocabulary, by component then declaration order,
34
+ * then the text each component's `search` list names — the same text a bare
35
+ * word finds (@yaks/fts), so what is found by its words is found by its
36
+ * meaning too. `pick` narrows the properties; a list is the vocabulary's own
37
+ * statement about its component and is always taken. */ export declare let fields: (vocab: Vocab, pick?: Pick) => Field[];
38
+ /** What keeps an entity from being embedded: the components the vocabulary
39
+ * marks `embed: false`, or `found: false` (found by no search, so no vector
40
+ * is made of it either), as the `not` of a field (none, no key). */ export declare let unembedded: (vocab: Vocab) => {
41
+ not?: string[];
42
+ };
43
+ /** The tables a store holds: a store makes a component's table the first
44
+ * time a write names it (@yaks/sqlite), and until then no entity wears it. */ export declare let tablesIn: (db: Statements) => Set<string>;
45
+ /** `f`, excluding only the components among `names`: one no table stands
46
+ * for excludes no entity. */ export declare let trimmed: (f: Field, names: Set<string>) => Field;
47
+ /** The fields whose text a store holds a table for, each excluding only the
48
+ * components it holds a table for (`trim`, by default): there is no text to
49
+ * read or watch in a table nothing has written, and nothing to be excluded
50
+ * by. */ export declare let present: (db: Statements, fields: Field[], trim?: boolean) => Field[];
51
+ export declare let allowed: (f: Field, owner?: Expr) => Expr[];
52
+ /**
53
+ * Every embeddable piece of text in the graph, as one row per (entity, field):
54
+ * the owner's integer id, the field's position in the join order, and the text.
55
+ * Blank fields are dropped here, so an entity appears in these results exactly
56
+ * when it has something to embed. `owners` narrows them to those entities,
57
+ * which is how the sweep reads only what it owes. One compound statement per
58
+ * `arms` fields, since an engine bounds the terms one may carry (@yaks/sql
59
+ * `ARMS`: a Durable Object's SQLite takes five); none for a vocabulary with no
60
+ * text properties at all. A caller that checks the owner after joining it can
61
+ * supply `eligible` to replace the component-table checks in each piece.
62
+ */ export declare let pieces: (fields: Field[], owners?: number[], eligible?: (field: Field) => Expr[]) => Query[];
63
+ /**
64
+ * Every entity that wears an embedded field, text or no text: what is owed a
65
+ * look when the fields themselves change. It reads no text, so it costs an
66
+ * index scan per field rather than the corpus. `owners` drives those seeks
67
+ * from a smaller set of candidates. One statement per `arms` fields, as
68
+ * {@link pieces}.
69
+ */ export declare let wearers: (fields: Field[], owners?: Query) => Query[];
70
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sources":["../fields.ts"],"names":[],"mappings":"AAeA,SAEE,IAAI,EAIJ,KAAK,OAAO,EAGZ,KAAK,IAAI,EAQT,KAAK,KAAK,EAEV,KAAK,UAAU,yBAKY;AAC7B,cAAc,IAAI,EAAE,KAAK,2BAAgC;AAEzD;;;;6CAI6C,GAC7C,YAAY;EACV,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,KAAK,MAAM;EACX;+CAC6C,GAC7C,MAAM,MAAM;EACZ,QAAQ,QAAQ,SAAS;;AAG3B;uEACuE,GACvE,OAAO,YAAI,WAAY,QAAQ,SAAS,UAAS,YAAe,QAI5D;AAEJ;;;CAGC,GACD,YAAY,QAAQ,MAAM,SAAS,OAAO;AAE1C;;;CAGC,GACD,OAAO,YAAI,SAAS,KACyC;AAE7D;;;;;;;CAOC,GACD,OAAO,YAAI,UAAU,KAAoC;AAEzD;;;;sDAIsD,GACtD,OAAO,YAAI,SAAU,OAAO,OAAO,OAAM,SAAiB,QAiBzD;AAED;;kEAEkE,GAClE,OAAO,YAAI,aAAc,OAAO;EAAU,MAAM,MAAM;EAMrD;AAKD;4EAC4E,GAC5E,OAAO,YAAI,WAAY,IAAI,eAAa,IAAI,MAAM,EAajD;AAED;2BAC2B,GAC3B,OAAO,YAAI,UAAW,GAAG,OAAO,OAAO,IAAI,MAAM,MAAI,MAGE;AAEvD;;;OAGO,GACP,OAAO,YAAI,UACT,IAAI,YACJ,QAAQ,SACR,mBACC,QAMF;AASD,OAAO,YAAI,UAAW,GAAG,OAAO,QAAO,SAA4B,OAOhE;AAQH;;;;;;;;;;CAUC,GACD,OAAO,YAAI,SACT,QAAQ,SACR,SAAS,MAAM,IAEf,YAAW,OAAO,UAAU,WAC3B,QA0BE;AAEL;;;;;;CAMC,GACD,OAAO,YAAI,UAAW,QAAQ,SAAsB,SAAS,UAAQ,QAmBlE"}
@@ -0,0 +1,63 @@
1
+ import type { Graph, Plugin } from "@yaks/graph";
2
+ import type { Reply } from "@yaks/tools";
3
+ import type { Derived, Extension, Raw } from "@yaks/sql";
4
+ import type { Vocab } from "@yaks/vocab";
5
+ import { type Statements, type Stmt } from "@yaks/sql";
6
+ import { type Lent, type Options } from "./options.js";
7
+ import { type Hit, type MeaningOpts } from "./search.js";
8
+ import { type Host } from "./neighbours.js";
9
+ /** The vector tables, which a writing host adds with the
10
+ * rest of its composed schema. It contributes no rule to `apply()`: nothing a
11
+ * client writes is a vector, and what keeps the vectors in step with the text
12
+ * is the sweep (`./service`), off the write path. */ export declare let schema: (host?: {
13
+ storage: {
14
+ statements?: Statements;
15
+ };
16
+ }) => Stmt[];
17
+ /** Binding the index does not create or migrate its tables. */ export declare let plugins: () => Plugin[];
18
+ /** The `.near` and `.order=similar` compiler, over the vectors this server
19
+ * stores. One extension serves every query: it is told when a new one begins
20
+ * (@yaks/sql `Begin`), so a neighbourhood never outlives the query that
21
+ * resolved it.
22
+ *
23
+ * What it needs is the vector space, not the embedding function — compiling a
24
+ * query reads the vector an entity already has and never embeds anything — so
25
+ * a server still waiting for a key can still answer `.near` over whatever is
26
+ * stored. Only a config that names no embedder at all has no space to rank in;
27
+ * that one contributes no extension, and `.near` gets the compiler's own
28
+ * refusal. */ export declare let extend: (host: {
29
+ storage: {
30
+ statements?: Statements;
31
+ };
32
+ vocab?: Vocab;
33
+ derived?: Derived;
34
+ embedders?: Lent;
35
+ }, options?: Options) => Extension[];
36
+ /** A phrase search over this graph's vectors, among what the `within` filter
37
+ * line admits where one is given (the storage's `screen` compiles it). Resolve
38
+ * options and the rows they name on every call: the service may have started
39
+ * embedding after a key or a provider arrived, without a new host or a new
40
+ * search function. */ export declare let meaning: (host: {
41
+ storage: {
42
+ statements?: Statements;
43
+ screen?: (query: string) => Raw | null;
44
+ };
45
+ vocab: Vocab;
46
+ graph: Pick<Graph, 'get'>;
47
+ derived?: Derived;
48
+ embedders?: Lent;
49
+ }, options?: Options) => (words: string, opts?: Pick<MeaningOpts, 'limit' | 'floor'> & {
50
+ within?: string;
51
+ }) => Promise<Hit[]>;
52
+ /** Hold this graph's vectors in memory before the first search asks for them
53
+ * (./held.ts), so a process answering many searches reads its copy before it
54
+ * answers any, not during one. Nothing where no embedder names a space. */ export declare let preload: (host: {
55
+ storage: {
56
+ statements?: Statements;
57
+ };
58
+ embedders?: Lent;
59
+ }, options?: Options) => () => void;
60
+ /** What a direct tool call's answer carries beside the tool's own: for each
61
+ * entity the call created, its nearest few of the same kind (./neighbours.ts),
62
+ * so a twin is seen while it is being written. */ export declare let reply: (host: Host, options?: Options) => Reply;
63
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAoBA,cAAc,KAAK,EAAE,MAAM,2BAAgC;AAC3D,cAAc,KAAK,2BAAgC;AACnD,cAAc,OAAO,EAAE,SAAS,EAAE,GAAG,yBAA8B;AACnE,cAAc,KAAK,2BAAgC;AAEnD,SAAS,KAAK,UAAU,EAAc,KAAK,IAAI,yBAA8B;AAG7E,SAAiB,KAAK,IAAI,EAAE,KAAK,OAAO,uBAAsC;AAC9E,SAAS,KAAK,GAAG,EAAqB,KAAK,WAAW,sBAAqB;AAC3E,SAAS,KAAK,IAAI,0BAAqC;AAIvD;;;mDAGmD,GACnD,OAAO,YAAI,SAAU;EAAS;IAAW,aAAa;;MAAiB,OACR;AAE/D,6DAA6D,GAC7D,OAAO,YAAI,eAAc,SAAc;AAEvC;;;;;;;;;;YAUY,GACZ,OAAO,YAAI,SACT;EACE;IAAW,aAAa;;EACxB,QAAQ;EACR,UAAU;EACV,YAAY;GAEd,UAAS,YACR,YAmBF;AAED;;;;oBAIoB,GACpB,OAAO,YAAI,UACT;EACE;IACE,aAAa;IACb,UAAU,OAAO,MAAM,KAAK,MAAM,IAAI;;EAExC,OAAO;EACP,OAAO,KAAK,OAAO;EACnB,UAAU;EACV,YAAY;GAEd,UAAS,aAET,OAAO,MAAM,EACb,OAAO,KAAK,aAAa,UAAU;EAAa,SAAS,MAAM;MAC5D,QAAQ,OA4CZ;AAED;;yEAEyE,GACzE,OAAO,YAAI,UACT;EAAQ;IAAW,aAAa;;EAAc,YAAY;GAC1D,UAAS,kBACF,IAAI,CAIZ;AAED;;gDAEgD,GAChD,OAAO,YAAI,QAAS,MAAM,MAAM,UAAS,YAAe,MAC7B"}
@@ -0,0 +1,16 @@
1
+ import { type Statements } from "@yaks/sql";
2
+ /** How many bytes of vectors this process holds across every copy: 48 MB of
3
+ * a Worker isolate's 128 MB, which every object in it shares. */ export declare let HELD: any;
4
+ /** How many bytes of shared storage's vectors this process holds across every
5
+ * copy: a box's process, which has the memory a Worker's isolate does not. */ export declare let SHARED: any;
6
+ /** How many changes a copy of shared storage reads on through before it loads
7
+ * again instead, and how many the sweep keeps when it trims the journal. */ export declare let FOLLOW: number;
8
+ /** How many of the scan's best a search reads from their rows and ranks by
9
+ * their exact cosine (more where it asks for more neighbours). */ export declare let RESCORE: number;
10
+ /**
11
+ * Fold what the dirty set names into this process's copy and clear the set:
12
+ * what a sweep pass wrote, from the process that wrote it (./sweep.ts
13
+ * `drain`). On shared storage, where each process's copy reads the journal
14
+ * itself, trim the journal to its newest {@link FOLLOW} changes instead.
15
+ */ export declare let absorb: (db: Statements) => void;
16
+ //# sourceMappingURL=held.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"held.d.ts","sources":["../held.ts"],"names":[],"mappings":"AAkDA,SAkBE,KAAK,UAAU,yBAIY;AAO7B;+DAC+D,GAC/D,OAAO,YAAI,UAAmB;AAE9B;4EAC4E,GAC5E,OAAO,YAAI,YAAsB;AAEjC;0EAC0E,GAC1E,OAAO,YAAI,eAAa;AAExB;gEACgE,GAChE,OAAO,YAAI,gBAAa;AAmaxB;;;;;CAKC,GACD,OAAO,YAAI,SAAU,IAAI,eAAa,IAAI,CA2BzC"}
@@ -0,0 +1,20 @@
1
+ import type { Eid } from "@yaks/graph";
2
+ import { type Statements } from "@yaks/sql";
3
+ import type { Rank, Screen } from "./near.js";
4
+ /** Bytes of an image with the media type its embedder consumes. */ export type ImageInput = {
5
+ bytes: Uint8Array;
6
+ mediaType: string;
7
+ };
8
+ export type ImageIndex = {
9
+ get: (eid: Eid, within?: Screen) => Float32Array | null;
10
+ nearest: Rank;
11
+ put: (eid: Eid, vector: Float32Array) => Promise<boolean>;
12
+ putAll: (vectors: Map<Eid, Float32Array>) => Promise<Set<Eid>>;
13
+ drop: (eid: Eid) => void;
14
+ clear: () => void;
15
+ };
16
+ /** Whether a store has vectors already, without creating an index. */ export declare let hasImages: (db: Pick<Statements, 'query'>) => boolean;
17
+ /** The image vector space of one store. Vectors live in derived storage and
18
+ * never in a bundle, journal entry or call result. Text sweeps own their
19
+ * separate index, including when both sources describe the same entity. */ export declare let imageIndex: (db: Statements, model: string) => ImageIndex;
20
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sources":["../image.ts"],"names":[],"mappings":"AAAA,cAAc,GAAG,2BAAgC;AACjD,SAWE,KAAK,UAAU,yBAGY;AAE7B,cAAoB,IAAI,EAAE,MAAM,oBAAmB;AAInD,iEAAiE,GACjE,YAAY;EAAe,OAAO;EAAY,WAAW,MAAM;;AAE/D,YAAY;EACV,MAAM,KAAK,KAAK,SAAS,WAAW,eAAe,IAAI;EACvD,SAAS;EACT,MAAM,KAAK,KAAK,QAAQ,iBAAiB,QAAQ,OAAO;EACxD,SAAS,SAAS,IAAI,KAAK,kBAAkB,QAAQ,IAAI;EACzD,OAAO,KAAK,QAAQ,IAAI;EACxB,aAAa,IAAI;;AAKnB,oEAAoE,GACpE,OAAO,YAAI,YAAa,IAAI,KAAK,YAAY,aAAW,OAAO,CACxC;AAEvB;;yEAEyE,GACzE,OAAO,YAAI,aAAc,IAAI,YAAY,OAAO,MAAM,KAAG,WA8IxD"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @yaks/embedding — semantic search for a yaks graph: the entities nearest in
3
+ * meaning, beside the literal matches full-text gives.
4
+ *
5
+ * Full-text search finds the word you typed. This finds the book you meant. A
6
+ * vector is stored for every entity that has text, and `.near=<entity>` ranks
7
+ * the graph by how close each one is to that entity's vector — which is how
8
+ * "more like this", "related reading" and "you may already have written this"
9
+ * are all the same query.
10
+ *
11
+ * It is generic over the text, exactly as {@link https://jsr.io/@yaks/fts |
12
+ * @yaks/fts} is: a vocabulary declares components, some of their properties
13
+ * hold prose, and {@link fields} chooses which of them a vector is made from.
14
+ * An entity gets one vector, made from all of its text fields joined together —
15
+ * a vector is a point in a space of meanings, and an entity is one thing.
16
+ *
17
+ * Six small pieces, each usable alone:
18
+ *
19
+ * - {@link fields} reads the embedded properties off a
20
+ * {@link https://jsr.io/@yaks/vocab | @yaks/vocab} schema;
21
+ * - {@link schema} returns the statements for the table the vectors live in,
22
+ * its update queue, and the generation of vectors held in memory;
23
+ * - {@link sweep} embeds what changed and drops what left, off the write path,
24
+ * reading what moved from a queue the database's own triggers keep
25
+ * ({@link watch});
26
+ * - {@link nearest} ranks the stored vectors against a query vector;
27
+ * - {@link meaning} embeds a new phrase and returns nearby entities with
28
+ * excerpts from the text that made their vectors;
29
+ * - {@link semantic} — the {@link https://jsr.io/@yaks/sql | @yaks/sql}
30
+ * extension — compiles `.near=<entity>` and `.order=similar` into that
31
+ * ranking, so a neighbourhood combines with ordinary filters in one query.
32
+ *
33
+ * ```ts
34
+ * import { loadVocab } from '@yaks/vocab'
35
+ * import { graph } from '@yaks/graph'
36
+ * import { statements, storage } from '@yaks/sqlite'
37
+ * import { open } from '@yaks/sqlite/db'
38
+ * import {
39
+ * fields,
40
+ * hashEmbedder,
41
+ * schema,
42
+ * semantic,
43
+ * sweep,
44
+ * } from '@yaks/embedding'
45
+ *
46
+ * let title = { type: 'string', search: true }
47
+ * let price = { type: 'number' }
48
+ * let shop = loadVocab([{
49
+ * $defs: { book: { component: true, properties: { title, price } } },
50
+ * }])
51
+ * let driver = open(':memory:')
52
+ * let db = statements(driver)
53
+ * for (let stmt of storage(driver, shop).ddl()) db.query(stmt)
54
+ * graph({ storage: storage(driver, shop), vocab: shop }).apply([
55
+ * { entity: { eid: 'book-1' }, book: { title: 'The Hobbit', price: 12 } },
56
+ * { entity: { eid: 'book-2' }, book: { title: 'Farmer Giles', price: 9 } },
57
+ * ])
58
+ *
59
+ * let text = fields(shop) // every text property the vocabulary declares
60
+ * for (let stmt of schema()) db.query(stmt)
61
+ *
62
+ * let embedder = hashEmbedder() // swap in a model when you have one
63
+ * await sweep(db, text, embedder) // keeps the vectors in step with the text
64
+ *
65
+ * // the books most like this one, still under the rest of the query's filters
66
+ * let near = semantic(db, embedder)
67
+ * let store = storage(driver, shop, { extend: [near] })
68
+ * let hits = near.rank(store.read('.near=book-1&.order=similar .book.price<20'))
69
+ * // each with a `rank.score`
70
+ * ```
71
+ *
72
+ * The embedder is injected — {@link hashEmbedder} is the deterministic,
73
+ * offline one shipped here and {@link remote} is one over HTTP, so tests and
74
+ * early development never reach a network. `.near` reads a stored vector
75
+ * synchronously; searching new words embeds them asynchronously.
76
+ *
77
+ * As a plugin, `./graph` creates the vector table, registers the `.near`
78
+ * compiler and answers phrase searches; `./service` settles the queue. A
79
+ * provider and a model are named beside the plugin in the config, and a
80
+ * provider reached over HTTP is a `provider` row serving the `model` row
81
+ * (@yaks/model). It declares no component — no client ever writes a vector.
82
+ *
83
+ * It assumes the storage layout @yaks/sql's SQLite dialect reads and
84
+ * {@link https://jsr.io/@yaks/sqlite | @yaks/sqlite} creates: an `entity`
85
+ * table of integer ids, one table per component keyed by an `entity` owner,
86
+ * and a `tombstone` table listing deleted entities.
87
+ *
88
+ * @module
89
+ */ export * from "./vector.js";
90
+ export * from "./embedder.js";
91
+ export * from "./remote.js";
92
+ export * from "./fields.js";
93
+ export * from "./ddl.js";
94
+ export * from "./sweep.js";
95
+ export * from "./sleeper.js";
96
+ export * from "./outage.js";
97
+ export * from "./owed.js";
98
+ export * from "./near.js";
99
+ export { absorb, FOLLOW, HELD, RESCORE, SHARED } from "./held.js";
100
+ export { type Build, install as installNative, prepare, type State, state } from "./native.js";
101
+ export * from "./search.js";
102
+ export * from "./compile.js";
103
+ export { type Scored, scored, type Vector } from "./score.js";
104
+ export * from "./image.js";
105
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFC,GAED,4BAA2B;AAC3B,8BAA6B;AAC7B,4BAA2B;AAC3B,4BAA2B;AAC3B,yBAAwB;AACxB,2BAA0B;AAC1B,6BAA4B;AAC5B,4BAA2B;AAC3B,0BAAyB;AACzB,0BAAyB;AACzB,SAAS,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAmB;AACjE,SACE,KAAK,KAAK,EACV,WAAW,aAAa,EACxB,OAAO,EACP,KAAK,KAAK,EACV,KAAK,sBACa;AACpB,4BAA2B;AAC3B,6BAA4B;AAE5B,SAAS,KAAK,MAAM,EAAE,MAAM,EAAE,KAAK,MAAM,qBAAoB;AAC7D,2BAA0B"}
@@ -0,0 +1,20 @@
1
+ import { type Statements } from "@yaks/sql";
2
+ /** Explicit one-time installation: back up the database before calling this
3
+ * on shared storage. The adapter loads its vector facility, which adds the
4
+ * extension's metadata table to the database. */ export declare let install: (db: Statements) => void;
5
+ /** Which build of the index is current: its number (0 before the first), and
6
+ * the model, dimension and count of the vectors it was built from. */ export type Build = {
7
+ n: number;
8
+ model: string | null;
9
+ dim: number;
10
+ rows: number;
11
+ };
12
+ /** What a health check reads, from plain tables any connection can read. */ export type State = {
13
+ /** whether sqlite-vector was installed on this database */ installed: boolean;
14
+ build: Build;
15
+ /** the model every vector is under, or null while there are two (or none) */ model: string | null;
16
+ /** how many vectors changed since the build */ dirty: number;
17
+ };
18
+ /** Vector space and generation metadata for diagnostics. */ export declare let state: (db: Statements) => State;
19
+ /** Register the vector shape once, before read-only connections use it. */ export declare let prepare: (db: Statements, dim?: number) => boolean;
20
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sources":["../native.ts"],"names":[],"mappings":"AAIA,SAeE,KAAK,UAAU,yBAIY;AAM7B;;+CAE+C,GAC/C,OAAO,YAAI,UAAW,IAAI,eAAa,IAAI,CAK1C;AAKD;oEACoE,GACpE,YAAY;EACV,GAAG,MAAM;EACT,OAAO,MAAM,GAAG,IAAI;EACpB,KAAK,MAAM;EACX,MAAM,MAAM;;AA8Dd,0EAA0E,GAC1E,YAAY;EACV,yDAAyD,GACzD,WAAW,OAAO;EAClB,OAAO;EACP,2EAA2E,GAC3E,OAAO,MAAM,GAAG,IAAI;EACpB,6CAA6C,GAC7C,OAAO,MAAM;;AAGf,0DAA0D,GAC1D,OAAO,YAAI,QAAS,IAAI,eAAa,MAKnC;AA2DF,yEAAyE,GACzE,OAAO,YAAI,UAAW,IAAI,YAAY,MAAM,MAAM,KAAG,OAAO,CAY3D"}
@@ -0,0 +1,35 @@
1
+ import type { Eid } from "@yaks/graph";
2
+ import { type Selection, type Statements } from "@yaks/sql";
3
+ /**
4
+ * One semantic neighbour: the entity, the integer id its rows key on, and how
5
+ * similar it is (1 identical, 0 unrelated).
6
+ */ export type Near = {
7
+ entity: Eid;
8
+ owner: number;
9
+ similarity: number;
10
+ };
11
+ /**
12
+ * A statement selecting, as `id`, the integer ids of the entities a neighbour
13
+ * must be among — what @yaks/sql's `screen` compiled for the rest of the query,
14
+ * passed straight in (the same interface @yaks/fts's `find` takes).
15
+ */ export type Screen = Selection;
16
+ /**
17
+ * A ranking: the nearest `limit` entities to a query vector, most similar
18
+ * first, among the entities `within` allows. {@link nearest} is the exact one;
19
+ * an approximate index has the same type, and one that cannot honour `within`
20
+ * returns the wrong neighbourhood for every query that also filters.
21
+ */ export type Rank = (query: Float32Array, limit: number, within?: Screen) => Near[];
22
+ /**
23
+ * The vector stored for an entity under a model, or null when it has none —
24
+ * because it holds no text, because the sweep has not reached it, or because
25
+ * the model moved and its row belongs to the old space.
26
+ */ export declare let vectorOf: (db: Statements, entity: Eid, model: string, within?: Screen) => Float32Array | null;
27
+ /** How a search is narrowed beyond "the nearest few". */ export type NearOpts = {
28
+ /** the model whose space to search — the one the vectors were stored under */ model: string;
29
+ /** how many neighbours at most (default 8) */ limit?: number;
30
+ /** the similarity a neighbour must reach to count at all (default 0) */ floor?: number;
31
+ /** an entity to leave out — nothing is its own neighbour */ without?: Eid;
32
+ /** the ids a neighbour must be among — what the rest of the query selects */ within?: Screen;
33
+ };
34
+ /** The entities nearest a query vector, most similar first. */ export declare let nearest: (db: Statements, query: Float32Array, opts: NearOpts) => Near[];
35
+ //# sourceMappingURL=near.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"near.d.ts","sources":["../near.ts"],"names":[],"mappings":"AAcA,cAAc,GAAG,2BAAgC;AACjD,SAaE,KAAK,SAAS,EACd,KAAK,UAAU,yBAGY;AAO7B;;;CAGC,GACD,YAAY;EAAS,QAAQ;EAAK,OAAO,MAAM;EAAE,YAAY,MAAM;;AAEnE;;;;CAIC,GACD,YAAY,SAAS;AAErB;;;;;CAKC,GACD,YAAY,QACV,OAAO,cACP,OAAO,MAAM,EACb,SAAS,WACN;AAuCL;;;;CAIC,GACD,OAAO,YAAI,WACT,IAAI,YACJ,QAAQ,KACR,OAAO,MAAM,EACb,SAAS,WACR,eAAe,IAAI,CAYrB;AAED,uDAAuD,GACvD,YAAY;EACV,4EAA4E,GAC5E,OAAO,MAAM;EACb,4CAA4C,GAC5C,QAAQ,MAAM;EACd,sEAAsE,GACtE,QAAQ,MAAM;EACd,0DAA0D,GAC1D,UAAU;EACV,2EAA2E,GAC3E,SAAS;;AAGX,6DAA6D,GAC7D,OAAO,YAAI,UACT,IAAI,YACJ,OAAO,cACP,MAAM,aACL,OA+CF"}
@@ -0,0 +1,29 @@
1
+ import { type Graph } from "@yaks/graph";
2
+ import { type Reply } from "@yaks/tools";
3
+ import { type Clause } from "@yaks/query";
4
+ import { type Derived, type Statements } from "@yaks/sql";
5
+ import type { Vocab } from "@yaks/vocab";
6
+ import { type Lent, type Options } from "./options.js";
7
+ /** How many neighbours of each list a new entity is answered with. */ export declare let FEW: number;
8
+ /** How many of one call's new entities are looked at: a plan of twenty
9
+ * tasks is answered about its first few, not with sixty lines. */ export declare let MOST: number;
10
+ /** How long an answer waits for the model, in milliseconds, before it falls
11
+ * back to words. */ export declare let WAIT: number;
12
+ /** What a reply reads: the graph, its vocabulary, and the database the
13
+ * vectors are kept in. */ export type Host = {
14
+ storage: {
15
+ statements?: Statements;
16
+ };
17
+ vocab: Vocab;
18
+ graph: Graph;
19
+ derived?: Derived;
20
+ /** the embedders lent by name (@yaks/host `embedders`) */ embedders?: Lent;
21
+ };
22
+ /** What a neighbour in either list is: wearing no notice, or written by a
23
+ * person, where the vocabulary knows people. */ export declare let resources: (vocab: Vocab) => Clause[];
24
+ /**
25
+ * The reply: for each entity the call's write made, its nearest few existing
26
+ * entities of the same kind, then its nearest few resources of any kind, as
27
+ * `hit` bundles.
28
+ */ export declare let neighbours: (host: Host, options?: Options) => Reply;
29
+ //# sourceMappingURL=neighbours.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neighbours.d.ts","sources":["../neighbours.ts"],"names":[],"mappings":"AAoCA,SAA2C,KAAK,KAAK,2BAAqC;AAG1F,SAAiB,KAAK,KAAK,2BAAgC;AAC3D,SAGE,KAAK,MAAM,2BASkB;AAC/B,SAGE,KAAK,OAAO,EAGZ,KAAK,UAAU,yBAGY;AAC7B,cAAc,KAAK,2BAAgC;AAGnD,SAAS,KAAK,IAAI,EAAE,KAAK,OAAO,uBAA6B;AAQ7D,oEAAoE,GACpE,OAAO,YAAI,YAAO;AAElB;gEACgE,GAChE,OAAO,YAAI,aAAQ;AAEnB;kBACkB,GAClB,OAAO,YAAI,aAAW;AAEtB;wBACwB,GACxB,YAAY;EACV;IAAW,aAAa;;EACxB,OAAO;EACP,OAAO;EACP,UAAU;EACV,wDAAwD,GACxD,YAAY;;AA2Hd;8CAC8C,GAC9C,OAAO,YAAI,YAAa,OAAO,UAAQ,SAKtC;AAED;;;;CAIC,GACD,OAAO,YAAI,aAAc,MAAM,MAAM,UAAS,YAAe,MAwE5D"}
@@ -0,0 +1,37 @@
1
+ import type { Embedder } from "./embedder.js";
2
+ import { type Fetch } from "./remote.js";
3
+ /** An embedder, as a config names one: a provider and the model it serves. */ export type Named = {
4
+ /** `hash` or an embedder lent by name in this process, or the name of a
5
+ * `provider` row reached over HTTP */ provider: string;
6
+ /** the `model` row's name, which names the vector space; for a lent
7
+ * embedder, the model it loads; none for `hash` */ model?: string;
8
+ /** keep this many leading coordinates (Matryoshka); a second width of one
9
+ * model is a second space. For `hash`, how many buckets (default 64). */ dim?: number;
10
+ /** a bearer token for a provider that wants one */ key?: string;
11
+ /** the most characters sent for one vector (./remote.ts `CHARS`) */ chars?: number;
12
+ /** how long to wait for one request, in milliseconds */ timeout?: number;
13
+ /** the most inputs one request carries (./remote.ts `COUNT`) */ count?: number;
14
+ /** the most characters one request carries (./remote.ts `LOAD`) */ load?: number;
15
+ /** the fetch to call through: a test's */ fetch?: Fetch;
16
+ /** the pauses before resending a failed call, in milliseconds */ waits?: readonly number[];
17
+ };
18
+ /** What a config declares to `@yaks/embedding`. */ export type Options = {
19
+ /** which embedder the vectors are made with — required, and its model
20
+ * names the space every stored row is stamped with */ embedder?: Named;
21
+ /** which text feeds a vector, as `comp.prop` pairs. The default is every
22
+ * property the vocabulary marks `search: true` (./fields.ts `searched`). */ text?: string[];
23
+ /** how many neighbours a `.near` selects (default 8) */ neighbours?: number;
24
+ /** the similarity a neighbour must reach to be one at all (default 0) */ floor?: number;
25
+ /** how many queued entities one sweep takes (default 64, ./sweep.ts
26
+ * `BATCH`); the next sweep follows at once while any are left */ batch?: number;
27
+ /** how long an empty queue waits before the service looks again, in
28
+ * milliseconds (default 3000) — how soon a new text is embedded */ after?: number;
29
+ /** the clock the service times a model's outage by (default `Date.now`):
30
+ * a test's */ now?: () => number;
31
+ };
32
+ /** The embedders a host lends by name, each made from the `model` and `dim` a
33
+ * config names; the embedder's `model` names its space. */ export type Lent = Readonly<Record<string, (said: {
34
+ model: string;
35
+ dim?: number;
36
+ }) => Embedder>>;
37
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sources":["../options.ts"],"names":[],"mappings":"AA4CA,cAAc,QAAQ,wBAAuB;AAG7C,SAAmB,KAAK,KAAK,sBAA6B;AAE1D,4EAA4E,GAC5E,YAAY;EACV;sCACoC,GACpC,UAAU,MAAM;EAChB;mDACiD,GACjD,QAAQ,MAAM;EACd;yEACuE,GACvE,MAAM,MAAM;EACZ,iDAAiD,GACjD,MAAM,MAAM;EACZ,kEAAkE,GAClE,QAAQ,MAAM;EACd,sDAAsD,GACtD,UAAU,MAAM;EAChB,8DAA8D,GAC9D,QAAQ,MAAM;EACd,iEAAiE,GACjE,OAAO,MAAM;EACb,wCAAwC,GACxC,QAAQ;EACR,+DAA+D,GAC/D,iBAAiB,MAAM;;AAGzB,iDAAiD,GACjD,YAAY;EACV;sDACoD,GACpD,WAAW;EACX;4EAC0E,GAC1E,OAAO,MAAM;EACb,sDAAsD,GACtD,aAAa,MAAM;EACnB,uEAAuE,GACvE,QAAQ,MAAM;EACd;iEAC+D,GAC/D,QAAQ,MAAM;EACd;mEACiE,GACjE,QAAQ,MAAM;EACd;cACY,GACZ,YAAY,MAAM;;AAsBpB;yDACyD,GACzD,YAAY,OAAO,SACjB,OAAO,MAAM,GAAG;EAAQ,OAAO,MAAM;EAAE,MAAM,MAAM;MAAO"}
@@ -0,0 +1,64 @@
1
+ import { type Outage } from "@yaks/effects/outage";
2
+ import { Unanswered } from "./embedder.js";
3
+ /**
4
+ * How long owed texts may wait on a model that does not answer before the
5
+ * wait is a failure. A drain retries about once a minute, and the Workers AI
6
+ * outages the stores have met passed within a few minutes; a quarter of an
7
+ * hour is several times that, and as long as a person's searches by meaning
8
+ * should go without a new text before someone hears of it.
9
+ */ export declare let OVERDUE: number;
10
+ /** An outage a host's drains are riding out (@yaks/effects/outage): since
11
+ * when no drain has answered, whether the wait has been reported or, withheld,
12
+ * needs no report, and as its `cause` the unexpected failure already
13
+ * reported, while drains keep failing by it. */ export type { Outage };
14
+ /** What one drain's outcome makes of the outage: the outage it leaves, the
15
+ * failure to report and the line to log, where there is one. */ export type Rode = {
16
+ outage: Outage | null;
17
+ report?: unknown;
18
+ log?: string;
19
+ };
20
+ /** One drain's outcome, given the outage it met and when it ended. */ export type Ride = (outage: Outage | null, now: number) => Rode;
21
+ /** What a report of owed texts waiting past {@link OVERDUE} throws: a fixed
22
+ * message, since one outage is one failure however long it lasts or whatever
23
+ * the model said; what varies rides `context`, and the model's last failure
24
+ * is the `cause`. */ export declare class Overdue extends Error {
25
+ name: string;
26
+ context: Unanswered['context'] & {
27
+ waited: string;
28
+ };
29
+ constructor(waited: number, cause: Unanswered);
30
+ }
31
+ /**
32
+ * A drain that answered: an outage it rode out, or the failure it reported,
33
+ * is over.
34
+ *
35
+ * ```ts
36
+ * import { equal } from '@yaks/testing'
37
+ * equal(drained(null, 0), { outage: null })
38
+ * equal(drained({ since: 0 }, 90_000),
39
+ * { outage: null, log: 'the outage ended after 90000 ms' })
40
+ * equal(drained({ since: 0, cause: 'Error: no table' }, 9_000), {
41
+ * outage: null,
42
+ * log: 'drains answer again after 9000 ms of Error: no table',
43
+ * })
44
+ * ```
45
+ */ export declare let drained: Ride;
46
+ /**
47
+ * A drain that threw `error`. A model that did not answer starts an outage or
48
+ * rides on in one, until its texts have waited {@link OVERDUE}, which reports
49
+ * once; a model that withheld its answer waits without a report; anything
50
+ * else reports at once, and not again while drains keep failing by it.
51
+ *
52
+ * ```ts
53
+ * import { equal } from '@yaks/testing'
54
+ * import { Unanswered } from './embedder.ts'
55
+ * let down = new Unanswered('workers-ai',
56
+ * { model: '@cf/m', texts: '2', tries: '4' }, Error('4009'))
57
+ * equal(failed(down)(null, 0).outage, { since: 0 })
58
+ * equal(failed(down)({ since: 0 }, 60_000), { outage: { since: 0 } })
59
+ * let bug = failed(Error('no table'))
60
+ * equal(bug(null, 0).outage, { since: 0, cause: 'Error: no table' })
61
+ * equal(bug(bug(null, 0).outage, 3_000).report, undefined)
62
+ * ```
63
+ */ export declare let failed: (error: unknown) => Ride;
64
+ //# sourceMappingURL=outage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outage.d.ts","sources":["../outage.ts"],"names":[],"mappings":"AAsBA,SAA4B,KAAK,MAAM,oCAAyC;AAChF,SAAS,UAAU,wBAAiC;AAEpD;;;;;;CAMC,GACD,OAAO,YAAI,SAAS,MAAM,CAAc;AAExC;;;8CAG8C,GAC9C,cAAc,MAAM,GAAE;AAEtB;8DAC8D,GAC9D,YAAY;EAAS,QAAQ,SAAS,IAAI;EAAE,SAAS,OAAO;EAAE,MAAM,MAAM;;AAE1E,oEAAoE,GACpE,YAAY,QAAQ,QAAQ,SAAS,IAAI,EAAE,KAAK,MAAM,KAAK;AAE3D;;;mBAGmB,GACnB,OAAO,cAAM,gBAAgB;EAClB,aAAgB;EACzB,SAAS,WAAW;IAAe,QAAQ,MAAM;IAAE;EACnD,YAAY,QAAQ,MAAM,EAAE,OAAO,UAAU;AAM/C;AAEA;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,SAAS,KASnB;AAED;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,YAAI,SAAU,OAAO,OAAO,KAAG,KAyBrC"}