@wazootech/worlds-sdk 0.0.0-stage → 0.11.3

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 (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +288 -2
  3. package/THIRD_PARTY_NOTICES.md +279 -0
  4. package/dist/ai-sdk.d.ts +27 -0
  5. package/dist/ai-sdk.js +28 -0
  6. package/dist/build-search-result-id-qxdmXp0V.js +12 -0
  7. package/dist/chunk-and-embed-0crm0xLl.js +75 -0
  8. package/dist/client-BJ45zmXU.d.ts +74 -0
  9. package/dist/client-BWh0UAM0.js +45 -0
  10. package/dist/embedding-service-DebRMVmn.d.ts +15 -0
  11. package/dist/embedding-service.d.ts +3 -0
  12. package/dist/embedding-service.js +19 -0
  13. package/dist/index.d.ts +8 -0
  14. package/dist/index.js +9 -0
  15. package/dist/memory.d.ts +26 -0
  16. package/dist/memory.js +29 -0
  17. package/dist/mod-8Zh1f9vW.d.ts +24 -0
  18. package/dist/mod-BuF_B_xU.d.ts +362 -0
  19. package/dist/mod-CHiiyEER.d.ts +79 -0
  20. package/dist/mod-ClDFMN-C.d.ts +625 -0
  21. package/dist/mod-Dmrdrb03.d.ts +13 -0
  22. package/dist/quad-chunker.d.ts +2 -0
  23. package/dist/quad-chunker.js +1 -0
  24. package/dist/quad-store-BGCOUBxK.js +851 -0
  25. package/dist/quad-store.d.ts +2 -0
  26. package/dist/quad-store.js +3 -0
  27. package/dist/rdf-formats-BkGt5RDB.js +93 -0
  28. package/dist/rdfjs-BNVjLSNL.js +190 -0
  29. package/dist/rdfjs.d.ts +79 -0
  30. package/dist/rdfjs.js +1 -0
  31. package/dist/search-index.d.ts +2 -0
  32. package/dist/search-index.js +219 -0
  33. package/dist/sparql-engine.d.ts +2 -0
  34. package/dist/sparql-engine.js +0 -0
  35. package/dist/testing.d.ts +301 -0
  36. package/dist/testing.js +786 -0
  37. package/dist/tfjs-use.d.ts +42 -0
  38. package/dist/tfjs-use.js +315 -0
  39. package/dist/wazoo.d.ts +86 -0
  40. package/dist/wazoo.js +347 -0
  41. package/package.json +119 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wazoo Technologies
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,289 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <a href="https://docs.wazoo.dev">
3
+ <img src="https://wazoo.dev/assets/wazoo.svg" alt="Wazoo Worlds" width="120" />
4
+ </a>
5
+ <br /><br />
6
+ <em>Persistent, edge-native knowledge graph storage for agents.</em>
7
+ <br /><br />
8
+ <a href="https://www.npmjs.com/package/@wazootech/worlds-sdk"><img src="https://img.shields.io/npm/v/%40wazootech%2Fworlds-sdk" alt="npm" /></a>
9
+ <a href="https://github.com/wazootech/worlds-sdk-ts"><img src="https://img.shields.io/badge/GitHub-black?logo=github" alt="GitHub" /></a>
10
+ <a href="https://deepwiki.com/wazootech/worlds-sdk-ts"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki" /></a>
11
+ </p>
2
12
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
13
+ - **Portable facade** — Unified `WorldsSdk` API that works across in-memory and
14
+ LibSQL/Turso backends.
15
+ - **Search** — Hybrid retrieval combining keyword FTS5 and vector embeddings.
16
+ - **Query** — The zero-dependency Wazoo SPARQL engine as the opinionated minimal
17
+ default.
18
+ - **In-memory RDF/JS** — Zero-setup, zero-dependency graph store and search (the
19
+ engine's `MemoryStore`) for dev, tests, and demos.
20
+
21
+ ## Install
22
+
23
+ ### Package managers
24
+
25
+ ```sh
26
+ npm install @wazootech/worlds-sdk @wazootech/sparql-engine # Node.js 22 or newer
27
+ bun add @wazootech/worlds-sdk @wazootech/sparql-engine # Bun
28
+ deno add npm:@wazootech/worlds-sdk npm:@wazootech/sparql-engine # Deno
29
+ ```
30
+
31
+ Deno waits a day before it installs a new release. To get one sooner, add
32
+ `--minimum-dependency-age=0` to the command.
33
+
34
+ See [docs/runtime-compatibility.md](docs/runtime-compatibility.md) for what is
35
+ verified on Node.js, Bun, and Deno, and the known limitations.
36
+
37
+ Versions up to 0.11.2 were published on JSR as `@worlds/sdk`. Only the name and
38
+ the registry changed: every import path and export is the same. Move every Wazoo
39
+ package in an app at once, because an app that mixes old and new names loads two
40
+ copies of the SPARQL engine.
41
+
42
+ ### CDN (browser / no build step)
43
+
44
+ [esm.sh](https://esm.sh) serves npm packages as ES modules — no install, no
45
+ bundler needed.
46
+
47
+ ```html
48
+ <script type="importmap">
49
+ {
50
+ "imports": {
51
+ "@wazootech/worlds-sdk": "https://esm.sh/@wazootech/worlds-sdk"
52
+ }
53
+ }
54
+ </script>
55
+ <script type="module">
56
+ import { WorldsSdk } from "@wazootech/worlds-sdk";
57
+ </script>
58
+ ```
59
+
60
+ Add a version to the address, such as `@wazootech/worlds-sdk@<version>`, so that
61
+ a new release can't change your page.
62
+
63
+ ## Quickstart
64
+
65
+ ```typescript
66
+ import { WorldsSdk } from "@wazootech/worlds-sdk";
67
+ import { MemoryStore, WazooSparqlEngine } from "@wazootech/sparql-engine";
68
+ import { RdfjsQuadStore, RdfjsSearchIndex } from "@wazootech/worlds-sdk/rdfjs";
69
+
70
+ const store = new MemoryStore();
71
+ const client = new WorldsSdk({
72
+ quadStore: new RdfjsQuadStore({ store }),
73
+ searchIndex: new RdfjsSearchIndex(store),
74
+ sparqlEngine: new WazooSparqlEngine({ store }),
75
+ });
76
+
77
+ await client.import({
78
+ source: {
79
+ kind: "serialized",
80
+ contentType: "text/turtle",
81
+ data: `@prefix ex: <http://example.org/> .
82
+ ex:Alice ex:bio "Alice explores the depths." ;
83
+ ex:location "Underdark" .`,
84
+ },
85
+ });
86
+
87
+ const searchResults = await client.search({ query: "explores" });
88
+ const subject = searchResults.results[0].subject;
89
+
90
+ const sparqlResponse = await client.sparql({
91
+ query: `SELECT ?property ?object WHERE { <${subject}> ?property ?object }`,
92
+ });
93
+ console.log(sparqlResponse);
94
+ ```
95
+
96
+ > [!TIP]
97
+ > For production search and scale, use the durable LibSQL backend
98
+ > (`@wazootech/worlds-libsql`). The Deno KV backend (`@worlds/denokv`) is
99
+ > [archived](https://github.com/wazootech/worlds-denokv); use `@wazootech/worlds-libsql`
100
+ > instead.
101
+
102
+ ## How a fact moves through a world
103
+
104
+ ![Worlds, part 1: writing a fact. An operator creates a world and mints a token; each agent turn, the agent curates what to keep; the SDK imports new facts, commits them as one atomic patch, and indexes them for search. A changed fact deletes the old triple and inserts the new one.](docs/diagrams/worlds-write.svg)
105
+
106
+ ![Worlds, part 2: recalling a fact. The agent searches with keyword and vector retrieval to find subject IRIs, grounds them with an exact SPARQL query, and answers from graph facts.](docs/diagrams/worlds-read.svg)
107
+
108
+ Time runs left to right. The stroke shows who is acting: the agent (wave), SDK
109
+ or API code (solid), an operator (dashed), or nothing at all while the fact sits
110
+ in the world (dotted). Red marks steps that cannot be undone: world IDs are
111
+ immutable, token secrets are shown once, and Worlds keeps no history of deleted
112
+ triples yet. A commit skips triples the world already holds. Durable backends
113
+ such as [`@wazootech/worlds-libsql`](https://github.com/wazootech/worlds-libsql) index new
114
+ triples on commit and roll the commit back if indexing fails; indexing can also
115
+ be deferred and run later with `reindex()`. Retrieval takes two hops: fuzzy
116
+ search finds subject IRIs, then SPARQL fetches the exact facts about them.
117
+
118
+ The diagrams are generated from
119
+ [`worlds-write.feynman.json`](docs/diagrams/worlds-write.feynman.json) and
120
+ [`worlds-read.feynman.json`](docs/diagrams/worlds-read.feynman.json) with the
121
+ [`feynman-diagram`](https://github.com/EthanThatOneKid/feynman-diagram) skill.
122
+
123
+ ## Core concepts
124
+
125
+ **Quad store**: Manages RDF triples (subject, predicate, object, graph) with
126
+ transactional import and export.
127
+
128
+ **Search index**: Hybrid retrieval over graph literals, combining keyword FTS5
129
+ with vector similarity via an embedding service and quad chunker.
130
+
131
+ **SPARQL engine**: Evaluates declarative queries and updates against the graph
132
+ for structured traversal and reasoning, powered by the zero-dependency
133
+ [`@wazootech/sparql-engine`](https://www.npmjs.com/package/@wazootech/sparql-engine).
134
+
135
+ ## Module layout
136
+
137
+ `WorldsSdk` is the portable facade. Shared modules sit under `src/client/`:
138
+
139
+ | Export | Role |
140
+ | ------------------------------------- | ---------------------------------------------------- |
141
+ | `@wazootech/worlds-sdk` | Root barrel: `WorldsSdk`, interfaces, patch types |
142
+ | `@wazootech/worlds-sdk/quad-store` | Quad import/export API, RDF formats, patch buffering |
143
+ | `@wazootech/worlds-sdk/search-index` | Search index interface and types |
144
+ | `@wazootech/worlds-sdk/sparql-engine` | SPARQL engine interface |
145
+ | `@wazootech/worlds-sdk/rdfjs` | In-memory `RdfjsQuadStore` and `RdfjsSearchIndex` |
146
+ | `@wazootech/worlds-sdk/ai-sdk` | Vercel AI SDK tool bindings |
147
+
148
+ The SPARQL engine is the external
149
+ [`@wazootech/sparql-engine`](https://www.npmjs.com/package/@wazootech/sparql-engine) package, which
150
+ implements `SparqlEngineInterface`.
151
+
152
+ For architecture documentation (package topology, runtime
153
+ model), see [ARCHITECTURE.md](ARCHITECTURE.md). For agent coding rules and
154
+ conventions, see [AGENTS.md](AGENTS.md).
155
+
156
+ ## Adapters
157
+
158
+ This package provides the core in-memory RDF/JS backend. Durable backends live
159
+ in separate packages:
160
+
161
+ | Package | Persistence | Search | Status |
162
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------- |
163
+ | `@wazootech/worlds-sdk` (this package) | In-memory (`MemoryStore`) | RDF/JS keyword | Core client + in-memory backend |
164
+ | [`@wazootech/worlds-libsql`](https://www.npmjs.com/package/@wazootech/worlds-libsql) ([repo](https://github.com/wazootech/worlds-libsql)) | SQLite / Turso Cloud | Hybrid FTS5 + vector | **Available** — full SDK factory (`createLibsqlWorldsSdk`) |
165
+ | [`@wazootech/worlds-sqlite`](https://www.npmjs.com/package/@wazootech/worlds-sqlite) ([repo](https://github.com/wazootech/worlds-sqlite)) | Local file (`node:sqlite`) | Hybrid FTS5 + sqlite-vec | **Available** — full SDK factory (`createSqliteWorldsSdk`); SQLite-family `sql-core` source of truth |
166
+ | [`@wazootech/worlds-postgres`](https://www.npmjs.com/package/@wazootech/worlds-postgres) ([repo](https://github.com/wazootech/worlds-postgres)) | PostgreSQL + pgvector | Hybrid tsvector + pgvector | **Available** — full SDK factory (`createPostgresWorldsSdk`) |
167
+ | [`@wazootech/worlds-cloudflare`](https://www.npmjs.com/package/@wazootech/worlds-cloudflare) ([repo](https://github.com/wazootech/worlds-cloudflare)) | D1 (miniflare) | FTS5 keyword (Vectorize planned) | **Available** — full SDK factory (`createCloudflareWorldsSdk`) |
168
+ | [`@wazootech/worlds-indexeddb`](https://www.npmjs.com/package/@wazootech/worlds-indexeddb) ([repo](https://github.com/wazootech/worlds-indexeddb)) | Browser IndexedDB | JS hybrid TF-IDF + cosine | **Available** — full SDK factory (`createIndexeddbWorldsSdk`) |
169
+
170
+ **Backend maturity:** All five durable backends now ship full SDK factories and
171
+ parity-green CI suites. Each assembles a quad store, hybrid search index, and
172
+ SPARQL engine through the standard `create*WorldsSdk` factory. The Deno KV
173
+ backend (`@worlds/denokv`) is
174
+ [archived](https://github.com/wazootech/worlds-denokv); use `@wazootech/worlds-libsql`.
175
+
176
+ **Choosing persistence:** LibSQL is the default for hybrid FTS/vector search and
177
+ faster cold quad index preload at scale. See
178
+ [discussion #69](https://github.com/wazootech/worlds-sdk-ts/discussions/69) for
179
+ benchmark methodology.
180
+
181
+ ### In-memory (dev, tests, demos)
182
+
183
+ ```typescript
184
+ import { WorldsSdk } from "@wazootech/worlds-sdk";
185
+ import { MemoryStore, WazooSparqlEngine } from "@wazootech/sparql-engine";
186
+ import { RdfjsQuadStore, RdfjsSearchIndex } from "@wazootech/worlds-sdk/rdfjs";
187
+
188
+ const store = new MemoryStore();
189
+ const client = new WorldsSdk({
190
+ quadStore: new RdfjsQuadStore({ store }),
191
+ searchIndex: new RdfjsSearchIndex(store),
192
+ sparqlEngine: new WazooSparqlEngine({ store }),
193
+ });
194
+ ```
195
+
196
+ ## Examples
197
+
198
+ | Example | Description | Command |
199
+ | -------------------------------- | ----------------------------------- | ------------------------------------------------- |
200
+ | Hello world | In-memory graph with search | `bun run example:hello-world` |
201
+ | AI SDK | Vercel AI SDK tools with Gemini | `bun run example:ai-sdk-hello-world` |
202
+ | TF.js Universal Sentence Encoder | Offline TF.js USE embedding service | `bun run example:tfjs-universal-sentence-encoder` |
203
+
204
+ For LibSQL examples, see the
205
+ [`@wazootech/worlds-libsql`](https://github.com/wazootech/worlds-libsql) repository.
206
+
207
+ Agent evaluation and memory benchmarking lives in the separate
208
+ [wazoo-memorybench](https://github.com/wazootech/wazoo-memorybench) repository,
209
+ successor to the archived worlds-client-evals eval harness.
210
+
211
+ ## Agent skills
212
+
213
+ The [onboarding skill](skills/worlds-sdk-ts-onboarding/SKILL.md) walks new
214
+ contributors through the codebase in a pair-programming style — environment
215
+ setup, running examples, understanding the client architecture, and
216
+ troubleshooting common gotchas. It is not a README in disguise: it enforces an
217
+ opinionated sequence (verify before proceeding, run tests before claiming done)
218
+ that catches the "it works on my machine" class of onboarding failures.
219
+
220
+ The skill adopts a named persona (Ethan, the lead developer) and validates each
221
+ stage before moving on — Bun version, dependency install, model file presence,
222
+ example execution, full test suite. If anything fails, it cross-references the
223
+ [TROUBLESHOOTING.md](skills/worlds-sdk-ts-onboarding/TROUBLESHOOTING.md) instead
224
+ of guessing.
225
+
226
+ ```bash
227
+ # Load the skill in your agent workspace
228
+ cp -r skills/worlds-sdk-ts-onboarding .agents/skills/
229
+ ```
230
+
231
+ Ask your coding assistant: _"Load the onboarding skill and guide me through the
232
+ Worlds client."_
233
+
234
+ ## Advanced
235
+
236
+ **Agent integration**: search-then-SPARQL two-hop pattern for LLM tool use with
237
+ hybrid retrieval. See [AGENTS.md](AGENTS.md) and
238
+ [ARCHITECTURE.md](ARCHITECTURE.md).
239
+
240
+ **LibSQL benchmarks**: Quad index performance methodology, regression policy,
241
+ and comparison tables live in the
242
+ [`@wazootech/worlds-libsql`](https://github.com/wazootech/worlds-libsql) adapter repo.
243
+
244
+ ## Development workflow
245
+
246
+ All CI checks must pass before merging updates.
247
+
248
+ | Command | Description |
249
+ | --------------- | --------------------------------------- |
250
+ | `bun run fmt` | Format all code with `bun fmt`. |
251
+ | `bun run lint` | Run static analysis (Oxlint). |
252
+ | `bun run check` | Type-check with `bun check`. |
253
+ | `bun run test` | Execute the test suite with `bun test`. |
254
+ | `bun run ci` | Run complete CI pipeline sequentially. |
255
+
256
+ Development uses the latest [Bun](https://bun.com) 1.x, at least 1.4.5 (`bun install` first).
257
+ `src/` must stay usable from Deno, Node.js and Bun alike.
258
+
259
+ `bun run build && bun run check:package` builds the npm package, installs it in
260
+ an empty project, and uses it on Node.js, Bun and Deno, which must all be on your
261
+ PATH. CI runs it on Linux and Windows.
262
+
263
+ ## Releases
264
+
265
+ Every push to `main` runs the [Publish workflow](.github/workflows/publish.yml),
266
+ which publishes only when `package.json`'s `version` is not yet on npm:
267
+
268
+ - **Release PR** (bumps `version`): merging it publishes the new version of
269
+ `@wazootech/worlds-sdk`.
270
+ - **Routine PR** (no bump): the Publish job skips green with a notice. That is
271
+ expected, not a failure.
272
+
273
+ To release, bump `version` in `package.json` (a patch, unless the change breaks
274
+ callers) and add a [changelog](CHANGELOG.md) entry in the PR that should ship. A
275
+ version with a suffix, such as `0.12.0-rc.0`, goes to the `next` tag instead of
276
+ `latest`.
277
+
278
+ npm accepts the publish because this repository's `publish.yml` is the package's
279
+ trusted publisher, so there is no npm token to store or rotate. After publishing,
280
+ a second job installs the new version from npm and checks it. If only that job
281
+ fails, re-run it on its own.
282
+
283
+ ## Quicklinks
284
+
285
+ - [Documentation](https://docs.wazoo.dev)
286
+ - [Wazoo Technologies](https://wazoo.dev)
287
+ - [Support](https://github.com/wazootech/worlds-sdk-ts/issues)
288
+
289
+ Developed with [**@wazootech**](https://github.com/wazootech)
@@ -0,0 +1,279 @@
1
+ # Third-party notices
2
+
3
+ The files in `dist/` include code from the projects below. Their licenses are
4
+ reproduced as those licenses require.
5
+
6
+ ## Deno Standard Library
7
+
8
+ `@std/encoding`, from <https://github.com/denoland/std>.
9
+
10
+ ```text
11
+ MIT License
12
+
13
+ Copyright 2018-2022 the Deno authors.
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+ ```
33
+
34
+ ## Go
35
+
36
+ The hex functions of `@std/encoding` are ported from Go's
37
+ [`encoding/hex`](https://github.com/golang/go/blob/go1.12.5/src/encoding/hex/hex.go).
38
+
39
+ ```text
40
+ Copyright (c) 2009 The Go Authors. All rights reserved.
41
+
42
+ Redistribution and use in source and binary forms, with or without
43
+ modification, are permitted provided that the following conditions are
44
+ met:
45
+
46
+ * Redistributions of source code must retain the above copyright
47
+ notice, this list of conditions and the following disclaimer.
48
+ * Redistributions in binary form must reproduce the above
49
+ copyright notice, this list of conditions and the following disclaimer
50
+ in the documentation and/or other materials provided with the
51
+ distribution.
52
+ * Neither the name of Google Inc. nor the names of its
53
+ contributors may be used to endorse or promote products derived from
54
+ this software without specific prior written permission.
55
+
56
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
57
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
58
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
59
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
60
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
62
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
66
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67
+ ```
68
+
69
+ ## TensorFlow.js Models
70
+
71
+ `dist/tfjs-use.js` contains a modified copy of the Universal Sentence Encoder's
72
+ tokenizer, from <https://github.com/tensorflow/tfjs-models>. The tokenizer is a
73
+ port of code from [SentencePiece](https://github.com/google/sentencepiece), which
74
+ has the same license.
75
+
76
+ ```text
77
+
78
+ Apache License
79
+ Version 2.0, January 2004
80
+ http://www.apache.org/licenses/
81
+
82
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
83
+
84
+ 1. Definitions.
85
+
86
+ "License" shall mean the terms and conditions for use, reproduction,
87
+ and distribution as defined by Sections 1 through 9 of this document.
88
+
89
+ "Licensor" shall mean the copyright owner or entity authorized by
90
+ the copyright owner that is granting the License.
91
+
92
+ "Legal Entity" shall mean the union of the acting entity and all
93
+ other entities that control, are controlled by, or are under common
94
+ control with that entity. For the purposes of this definition,
95
+ "control" means (i) the power, direct or indirect, to cause the
96
+ direction or management of such entity, whether by contract or
97
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
98
+ outstanding shares, or (iii) beneficial ownership of such entity.
99
+
100
+ "You" (or "Your") shall mean an individual or Legal Entity
101
+ exercising permissions granted by this License.
102
+
103
+ "Source" form shall mean the preferred form for making modifications,
104
+ including but not limited to software source code, documentation
105
+ source, and configuration files.
106
+
107
+ "Object" form shall mean any form resulting from mechanical
108
+ transformation or translation of a Source form, including but
109
+ not limited to compiled object code, generated documentation,
110
+ and conversions to other media types.
111
+
112
+ "Work" shall mean the work of authorship, whether in Source or
113
+ Object form, made available under the License, as indicated by a
114
+ copyright notice that is included in or attached to the work
115
+ (an example is provided in the Appendix below).
116
+
117
+ "Derivative Works" shall mean any work, whether in Source or Object
118
+ form, that is based on (or derived from) the Work and for which the
119
+ editorial revisions, annotations, elaborations, or other modifications
120
+ represent, as a whole, an original work of authorship. For the purposes
121
+ of this License, Derivative Works shall not include works that remain
122
+ separable from, or merely link (or bind by name) to the interfaces of,
123
+ the Work and Derivative Works thereof.
124
+
125
+ "Contribution" shall mean any work of authorship, including
126
+ the original version of the Work and any modifications or additions
127
+ to that Work or Derivative Works thereof, that is intentionally
128
+ submitted to Licensor for inclusion in the Work by the copyright owner
129
+ or by an individual or Legal Entity authorized to submit on behalf of
130
+ the copyright owner. For the purposes of this definition, "submitted"
131
+ means any form of electronic, verbal, or written communication sent
132
+ to the Licensor or its representatives, including but not limited to
133
+ communication on electronic mailing lists, source code control systems,
134
+ and issue tracking systems that are managed by, or on behalf of, the
135
+ Licensor for the purpose of discussing and improving the Work, but
136
+ excluding communication that is conspicuously marked or otherwise
137
+ designated in writing by the copyright owner as "Not a Contribution."
138
+
139
+ "Contributor" shall mean Licensor and any individual or Legal Entity
140
+ on behalf of whom a Contribution has been received by Licensor and
141
+ subsequently incorporated within the Work.
142
+
143
+ 2. Grant of Copyright License. Subject to the terms and conditions of
144
+ this License, each Contributor hereby grants to You a perpetual,
145
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
146
+ copyright license to reproduce, prepare Derivative Works of,
147
+ publicly display, publicly perform, sublicense, and distribute the
148
+ Work and such Derivative Works in Source or Object form.
149
+
150
+ 3. Grant of Patent License. Subject to the terms and conditions of
151
+ this License, each Contributor hereby grants to You a perpetual,
152
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
153
+ (except as stated in this section) patent license to make, have made,
154
+ use, offer to sell, sell, import, and otherwise transfer the Work,
155
+ where such license applies only to those patent claims licensable
156
+ by such Contributor that are necessarily infringed by their
157
+ Contribution(s) alone or by combination of their Contribution(s)
158
+ with the Work to which such Contribution(s) was submitted. If You
159
+ institute patent litigation against any entity (including a
160
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
161
+ or a Contribution incorporated within the Work constitutes direct
162
+ or contributory patent infringement, then any patent licenses
163
+ granted to You under this License for that Work shall terminate
164
+ as of the date such litigation is filed.
165
+
166
+ 4. Redistribution. You may reproduce and distribute copies of the
167
+ Work or Derivative Works thereof in any medium, with or without
168
+ modifications, and in Source or Object form, provided that You
169
+ meet the following conditions:
170
+
171
+ (a) You must give any other recipients of the Work or
172
+ Derivative Works a copy of this License; and
173
+
174
+ (b) You must cause any modified files to carry prominent notices
175
+ stating that You changed the files; and
176
+
177
+ (c) You must retain, in the Source form of any Derivative Works
178
+ that You distribute, all copyright, patent, trademark, and
179
+ attribution notices from the Source form of the Work,
180
+ excluding those notices that do not pertain to any part of
181
+ the Derivative Works; and
182
+
183
+ (d) If the Work includes a "NOTICE" text file as part of its
184
+ distribution, then any Derivative Works that You distribute must
185
+ include a readable copy of the attribution notices contained
186
+ within such NOTICE file, excluding those notices that do not
187
+ pertain to any part of the Derivative Works, in at least one
188
+ of the following places: within a NOTICE text file distributed
189
+ as part of the Derivative Works; within the Source form or
190
+ documentation, if provided along with the Derivative Works; or,
191
+ within a display generated by the Derivative Works, if and
192
+ wherever such third-party notices normally appear. The contents
193
+ of the NOTICE file are for informational purposes only and
194
+ do not modify the License. You may add Your own attribution
195
+ notices within Derivative Works that You distribute, alongside
196
+ or as an addendum to the NOTICE text from the Work, provided
197
+ that such additional attribution notices cannot be construed
198
+ as modifying the License.
199
+
200
+ You may add Your own copyright statement to Your modifications and
201
+ may provide additional or different license terms and conditions
202
+ for use, reproduction, or distribution of Your modifications, or
203
+ for any such Derivative Works as a whole, provided Your use,
204
+ reproduction, and distribution of the Work otherwise complies with
205
+ the conditions stated in this License.
206
+
207
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
208
+ any Contribution intentionally submitted for inclusion in the Work
209
+ by You to the Licensor shall be under the terms and conditions of
210
+ this License, without any additional terms or conditions.
211
+ Notwithstanding the above, nothing herein shall supersede or modify
212
+ the terms of any separate license agreement you may have executed
213
+ with Licensor regarding such Contributions.
214
+
215
+ 6. Trademarks. This License does not grant permission to use the trade
216
+ names, trademarks, service marks, or product names of the Licensor,
217
+ except as required for reasonable and customary use in describing the
218
+ origin of the Work and reproducing the content of the NOTICE file.
219
+
220
+ 7. Disclaimer of Warranty. Unless required by applicable law or
221
+ agreed to in writing, Licensor provides the Work (and each
222
+ Contributor provides its Contributions) on an "AS IS" BASIS,
223
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
224
+ implied, including, without limitation, any warranties or conditions
225
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
226
+ PARTICULAR PURPOSE. You are solely responsible for determining the
227
+ appropriateness of using or redistributing the Work and assume any
228
+ risks associated with Your exercise of permissions under this License.
229
+
230
+ 8. Limitation of Liability. In no event and under no legal theory,
231
+ whether in tort (including negligence), contract, or otherwise,
232
+ unless required by applicable law (such as deliberate and grossly
233
+ negligent acts) or agreed to in writing, shall any Contributor be
234
+ liable to You for damages, including any direct, indirect, special,
235
+ incidental, or consequential damages of any character arising as a
236
+ result of this License or out of the use or inability to use the
237
+ Work (including but not limited to damages for loss of goodwill,
238
+ work stoppage, computer failure or malfunction, or any and all
239
+ other commercial damages or losses), even if such Contributor
240
+ has been advised of the possibility of such damages.
241
+
242
+ 9. Accepting Warranty or Additional Liability. While redistributing
243
+ the Work or Derivative Works thereof, You may choose to offer,
244
+ and charge a fee for, acceptance of support, warranty, indemnity,
245
+ or other liability obligations and/or rights consistent with this
246
+ License. However, in accepting such obligations, You may act only
247
+ on Your own behalf and on Your sole responsibility, not on behalf
248
+ of any other Contributor, and only if You agree to indemnify,
249
+ defend, and hold each Contributor harmless for any liability
250
+ incurred by, or claims asserted against, such Contributor by reason
251
+ of your accepting any such warranty or additional liability.
252
+
253
+ END OF TERMS AND CONDITIONS
254
+
255
+ APPENDIX: How to apply the Apache License to your work.
256
+
257
+ To apply the Apache License to your work, attach the following
258
+ boilerplate notice, with the fields enclosed by brackets "[]"
259
+ replaced with your own identifying information. (Don't include
260
+ the brackets!) The text should be enclosed in the appropriate
261
+ comment syntax for the file format. We also recommend that a
262
+ file or class name and description of purpose be included on the
263
+ same "printed page" as the copyright notice for easier
264
+ identification within third-party archives.
265
+
266
+ Copyright [yyyy] [name of copyright owner]
267
+
268
+ Licensed under the Apache License, Version 2.0 (the "License");
269
+ you may not use this file except in compliance with the License.
270
+ You may obtain a copy of the License at
271
+
272
+ http://www.apache.org/licenses/LICENSE-2.0
273
+
274
+ Unless required by applicable law or agreed to in writing, software
275
+ distributed under the License is distributed on an "AS IS" BASIS,
276
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
277
+ See the License for the specific language governing permissions and
278
+ limitations under the License.
279
+ ```
@@ -0,0 +1,27 @@
1
+ import { EmbeddingModel } from "ai";
2
+ import { t as EmbeddingService } from "./embedding-service-DebRMVmn.js";
3
+ /**
4
+ * AiSdkEmbeddingServiceOptions provides configurations for the AI SDK embedding service.
5
+ */
6
+ export interface AiSdkEmbeddingServiceOptions {
7
+ /** model is the Vercel AI SDK embedding model instance. */
8
+ model: EmbeddingModel;
9
+ /** maxRetries is the optional maximum number of retries for embedding requests. */
10
+ maxRetries?: number;
11
+ /** abortSignal is the optional signal to cancel request execution. */
12
+ abortSignal?: AbortSignal;
13
+ }
14
+ /**
15
+ * AiSdkEmbeddingService provides text embedding generation leveraging Vercel AI SDK's embedMany.
16
+ */
17
+ export declare class AiSdkEmbeddingService implements EmbeddingService {
18
+ private readonly options;
19
+ constructor(options: AiSdkEmbeddingServiceOptions);
20
+ /**
21
+ * embed converts text sequences into high-dimensional vector arrays using Vercel AI SDK.
22
+ *
23
+ * @param texts Array of clean input sequences targeted for vectorizing.
24
+ * @returns Vector space projection arrays matching the input array index positioning.
25
+ */
26
+ embed(texts: string[]): Promise<Array<Float32Array | number[]>>;
27
+ }
package/dist/ai-sdk.js ADDED
@@ -0,0 +1,28 @@
1
+ import { embedMany } from "ai";
2
+ // src/ai-sdk/ai-sdk-embedding-service.ts
3
+ /**
4
+ * AiSdkEmbeddingService provides text embedding generation leveraging Vercel AI SDK's embedMany.
5
+ */
6
+ var AiSdkEmbeddingService = class {
7
+ options;
8
+ constructor(options) {
9
+ this.options = options;
10
+ }
11
+ /**
12
+ * embed converts text sequences into high-dimensional vector arrays using Vercel AI SDK.
13
+ *
14
+ * @param texts Array of clean input sequences targeted for vectorizing.
15
+ * @returns Vector space projection arrays matching the input array index positioning.
16
+ */
17
+ async embed(texts) {
18
+ if (texts.length === 0) return [];
19
+ const { embeddings } = await embedMany({
20
+ model: this.options.model,
21
+ values: texts,
22
+ maxRetries: this.options.maxRetries,
23
+ abortSignal: this.options.abortSignal
24
+ });
25
+ return embeddings;
26
+ }
27
+ };
28
+ export { AiSdkEmbeddingService };
@@ -0,0 +1,12 @@
1
+ import { DataFactory } from "@wazootech/sparql-engine/data-model";
2
+ import { h as hashQuad } from "./quad-store-BGCOUBxK.js";
3
+ // src/client/search-index/build-search-result-id.ts
4
+ const { literal, namedNode, quad: createQuad, defaultGraph } = DataFactory;
5
+ /**
6
+ * buildSearchResultId computes a stable id from the discovery-facing literal text.
7
+ */
8
+ function buildSearchResultId(options) {
9
+ const searchQuad = createQuad(namedNode(options.subject), namedNode(options.predicate), literal(options.text), options.graph ? namedNode(options.graph) : defaultGraph());
10
+ return hashQuad(searchQuad);
11
+ }
12
+ export { buildSearchResultId as t };