@lunora/ai 1.0.0-alpha.1 → 1.0.0-alpha.100

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 (33) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +12 -4
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/index.d.mts +88 -27
  5. package/dist/index.d.ts +88 -27
  6. package/dist/index.mjs +1 -3
  7. package/dist/packem_shared/AI_DEFAULT_EMBEDDING_MODEL_ENV-B58f6yo6.mjs +1 -0
  8. package/dist/packem_shared/DEFAULT_MODEL_PRICES-CIJLs1Ah.mjs +1 -0
  9. package/dist/packem_shared/VECTORIZE_CAPABILITIES-CUQDoxis.mjs +1 -0
  10. package/dist/packem_shared/batchReranker-Bc38FBLH.mjs +1 -0
  11. package/dist/packem_shared/bm25-9q0Avwi-.mjs +1 -0
  12. package/dist/packem_shared/bm25LexicalStore-DMUzAL0O.mjs +1 -0
  13. package/dist/packem_shared/concurrent-C6nqBv41.mjs +1 -0
  14. package/dist/packem_shared/contentHash-BIn6ECP8.mjs +1 -0
  15. package/dist/packem_shared/createAi-mXofcZid.mjs +1 -0
  16. package/dist/packem_shared/defineRag-Cs7m4xJJ.mjs +8 -0
  17. package/dist/packem_shared/defineRagSource-Q3f3niU8.mjs +1 -0
  18. package/dist/packem_shared/fixedWindowChunks-C461ahRE.mjs +1 -0
  19. package/dist/packem_shared/hybridRank-B4skyCLx.mjs +1 -0
  20. package/dist/packem_shared/markdownChunker-iW8V4klY.mjs +5 -0
  21. package/dist/packem_shared/matchesMetadataFilter-BbIOyA5g.mjs +1 -0
  22. package/dist/packem_shared/ragSyncTriggers-hgMcA4f2.mjs +1 -0
  23. package/dist/packem_shared/sql-D5aqEMCY.mjs +1 -0
  24. package/dist/packem_shared/sqlLexicalStore-4C_cIwef.mjs +1 -0
  25. package/dist/packem_shared/sqliteVectorStore-D32l9lP0.mjs +1 -0
  26. package/dist/packem_shared/stable-key-B_BlboiY.mjs +1 -0
  27. package/dist/packem_shared/types.d-D3U2budn.d.mts +310 -0
  28. package/dist/packem_shared/types.d-D3U2budn.d.ts +310 -0
  29. package/dist/rag/index.d.mts +1342 -0
  30. package/dist/rag/index.d.ts +1342 -0
  31. package/dist/rag/index.mjs +1 -0
  32. package/package.json +13 -6
  33. package/dist/packem_shared/createAi-CaLhvwAd.mjs +0 -49
package/LICENSE.md CHANGED
@@ -103,3 +103,9 @@ Unless required by applicable law or agreed to in writing, software distributed
103
103
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
104
  CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
105
  specific language governing permissions and limitations under the License.
106
+
107
+ <!-- DEPENDENCIES -->
108
+ <!-- /DEPENDENCIES -->
109
+
110
+ <!-- TYPE_DEPENDENCIES -->
111
+ <!-- /TYPE_DEPENDENCIES -->
package/README.md CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
  <!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
12
12
 
13
+ > **Experimental** — this package is outside the Lunora 1.0 stability promise: its API may change in any release, without a major version bump.
14
+
13
15
  <br />
14
16
 
15
17
  <div align="center">
@@ -34,7 +36,7 @@
34
36
 
35
37
  ---
36
38
 
37
- A small AI helper for Lunora, built on the [Vercel AI SDK](https://ai-sdk.dev) v6 core and Cloudflare's official [`workers-ai-provider`](https://github.com/cloudflare/ai). Call `generateText`/`streamText`/`generateObject`/`embed`/`tool` from any function handler. **Cloudflare Workers AI is the zero-config default**, but the helper is provider-agnostic: every call takes either a Workers AI model id (a string) or any AI SDK model object — `@ai-sdk/openai`, `@ai-sdk/anthropic`, OpenRouter, … — so apps are never locked to Workers AI. Pair `embed` with [`@lunora/vectors`](https://www.npmjs.com/package/@lunora/vectors) for RAG.
39
+ A small AI helper for Lunora, built on the [Vercel AI SDK](https://ai-sdk.dev) v7 core and Cloudflare's official [`workers-ai-provider`](https://github.com/cloudflare/ai). Call `generateText`/`streamText`/`generateObject`/`embed`/`tool` from any function handler. **Cloudflare Workers AI is the zero-config default**, but the helper is provider-agnostic: every call takes either a Workers AI model id (a string) or any AI SDK model object — `@ai-sdk/openai`, `@ai-sdk/anthropic`, OpenRouter, … — so apps are never locked to Workers AI. Pair `embed` with [`@lunora/bindings/vectors`](https://www.npmjs.com/package/@lunora/bindings) for RAG.
38
40
 
39
41
  Part of the [Lunora](https://github.com/anolilab/lunora) framework — a type-safe, real-time backend on Cloudflare Workers + Durable Objects with a Vite-first DX.
40
42
 
@@ -63,8 +65,14 @@ When a function uses AI, codegen wires a typed **`ctx.ai`** onto the action cont
63
65
  import { action, v } from "@/lunora/_generated/server";
64
66
  import { generateText } from "@lunora/ai";
65
67
 
66
- export const summarize = action.input({ text: v.string() }).action(async ({ args: { text }, ctx }) => {
68
+ export const summarize = action.input({ text: v.string().max(20_000) }).action(async ({ args: { text }, ctx }) => {
67
69
  const { text: summary } = await generateText({
70
+ // Both ends of the token bill are bounded: the input by `.max()` above,
71
+ // the completion here. An `action` is public RPC and inference is
72
+ // metered, so an unbounded completion is a denial-of-wallet vector — a
73
+ // short prompt can ask for an arbitrarily long answer, and output
74
+ // tokens are the expensive half.
75
+ maxOutputTokens: 300,
68
76
  model: ctx.ai.model("@cf/meta/llama-3.3-70b-instruct-fp8-fast"),
69
77
  prompt: `Summarize:\n\n${text}`,
70
78
  });
@@ -82,7 +90,7 @@ const result = streamText({ model: openai("gpt-5"), messages });
82
90
  ```
83
91
 
84
92
  ```ts
85
- // RAG: embed via ctx.ai, store/search with @lunora/vectors (ctx.vectors)
93
+ // RAG: embed via ctx.ai, store/search with @lunora/bindings/vectors (ctx.vectors)
86
94
  import { embed } from "@lunora/ai";
87
95
 
88
96
  const { embedding } = await embed({ model: ctx.ai.embeddingModel("@cf/baai/bge-base-en-v1.5"), value: text });
@@ -96,7 +104,7 @@ Outside an action — in the worker entry, a Durable Object, or a queue/schedule
96
104
  ## Related
97
105
 
98
106
  - [`@lunora/server`](https://www.npmjs.com/package/@lunora/server) — function primitives whose `ctx.ai` this package backs.
99
- - [`@lunora/vectors`](https://www.npmjs.com/package/@lunora/vectors) — pair `embed` with Vectorize for RAG.
107
+ - [`@lunora/bindings/vectors`](https://www.npmjs.com/package/@lunora/bindings) — pair `embed` with Vectorize for RAG.
100
108
  - [`@lunora/vite`](https://www.npmjs.com/package/@lunora/vite) — infers and reconciles the `AI` binding into `wrangler.jsonc`.
101
109
 
102
110
  ## Supported Node.js Versions