@lunora/ai 1.0.0-alpha.65 → 1.0.0-alpha.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -63,9 +63,14 @@ interface ModelUsage {
63
63
  * An indicative price table, keyed by model id.
64
64
  *
65
65
  * Deliberately small: a table that tries to cover every model is a table that
66
- * is wrong about most of them. It holds the Workers AI models Lunora's own
67
- * defaults reference plus the common OpenAI embedding models, and everything
68
- * else returns `undefined` rather than a guess.
66
+ * is wrong about most of them. It holds the models Lunora's own defaults and
67
+ * documented examples reference text generation and embeddings, on Workers AI
68
+ * and OpenAI — and everything else returns `undefined` rather than a guess.
69
+ *
70
+ * Generation models carry an `output` price; embedding models do not (they have
71
+ * no completion). A generation model missing from here is why a chat span would
72
+ * carry no cost at all off an AI Gateway, so the ids the docs teach are the ones
73
+ * that have to be in the table.
69
74
  */
70
75
  declare const DEFAULT_MODEL_PRICES: Readonly<Record<string, ModelPrice>>;
71
76
  /**
package/dist/index.d.ts CHANGED
@@ -63,9 +63,14 @@ interface ModelUsage {
63
63
  * An indicative price table, keyed by model id.
64
64
  *
65
65
  * Deliberately small: a table that tries to cover every model is a table that
66
- * is wrong about most of them. It holds the Workers AI models Lunora's own
67
- * defaults reference plus the common OpenAI embedding models, and everything
68
- * else returns `undefined` rather than a guess.
66
+ * is wrong about most of them. It holds the models Lunora's own defaults and
67
+ * documented examples reference text generation and embeddings, on Workers AI
68
+ * and OpenAI — and everything else returns `undefined` rather than a guess.
69
+ *
70
+ * Generation models carry an `output` price; embedding models do not (they have
71
+ * no completion). A generation model missing from here is why a chat span would
72
+ * carry no cost at all off an AI Gateway, so the ids the docs teach are the ones
73
+ * that have to be in the table.
69
74
  */
70
75
  declare const DEFAULT_MODEL_PRICES: Readonly<Record<string, ModelPrice>>;
71
76
  /**
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{default as o}from"./packem_shared/createAi-DIJS_f7H.mjs";import{AI_GATEWAY_ACCOUNT_ID_ENV as r,AI_GATEWAY_ID_ENV as A,AI_GATEWAY_TOKEN_ENV as _,buildAiGatewayMetadataFields as l,resolveAiGateway as m}from"./packem_shared/AI_GATEWAY_ACCOUNT_ID_ENV-9ptmPAYP.mjs";import{DEFAULT_MODEL_PRICES as E,estimateModelCost as T,lookupModelPrice as d}from"./packem_shared/DEFAULT_MODEL_PRICES-DZ3dYVUn.mjs";import{embed as x,embedMany as I,generateObject as c,generateText as f,hasToolCall as p,jsonSchema as b,streamObject as C,streamText as G,tool as M}from"ai";import{createWorkersAI as O}from"workers-ai-provider";export{r as AI_GATEWAY_ACCOUNT_ID_ENV,A as AI_GATEWAY_ID_ENV,_ as AI_GATEWAY_TOKEN_ENV,E as DEFAULT_MODEL_PRICES,l as buildAiGatewayMetadataFields,o as createAi,O as createWorkersAI,x as embed,I as embedMany,T as estimateModelCost,c as generateObject,f as generateText,p as hasToolCall,b as jsonSchema,d as lookupModelPrice,m as resolveAiGateway,C as streamObject,G as streamText,M as tool};
1
+ import{default as o}from"./packem_shared/createAi-DIJS_f7H.mjs";import{AI_GATEWAY_ACCOUNT_ID_ENV as r,AI_GATEWAY_ID_ENV as A,AI_GATEWAY_TOKEN_ENV as _,buildAiGatewayMetadataFields as l,resolveAiGateway as m}from"./packem_shared/AI_GATEWAY_ACCOUNT_ID_ENV-9ptmPAYP.mjs";import{DEFAULT_MODEL_PRICES as E,estimateModelCost as T,lookupModelPrice as d}from"./packem_shared/DEFAULT_MODEL_PRICES-Q8uxdiuV.mjs";import{embed as x,embedMany as I,generateObject as c,generateText as f,hasToolCall as p,jsonSchema as b,streamObject as C,streamText as G,tool as M}from"ai";import{createWorkersAI as O}from"workers-ai-provider";export{r as AI_GATEWAY_ACCOUNT_ID_ENV,A as AI_GATEWAY_ID_ENV,_ as AI_GATEWAY_TOKEN_ENV,E as DEFAULT_MODEL_PRICES,l as buildAiGatewayMetadataFields,o as createAi,O as createWorkersAI,x as embed,I as embedMany,T as estimateModelCost,c as generateObject,f as generateText,p as hasToolCall,b as jsonSchema,d as lookupModelPrice,m as resolveAiGateway,C as streamObject,G as streamText,M as tool};
@@ -0,0 +1 @@
1
+ const p=/^(.*)-\d{4}-\d{2}-\d{2}$/u,a={"@cf/baai/bge-base-en-v1.5":{input:.067},"@cf/baai/bge-large-en-v1.5":{input:.204},"@cf/baai/bge-m3":{input:.012},"@cf/baai/bge-small-en-v1.5":{input:.02},"@cf/meta/llama-3.1-8b-instruct":{input:.28,output:.83},"@cf/meta/llama-3.3-70b-instruct-fp8-fast":{input:.29,output:2.25},"text-embedding-3-large":{input:.13},"text-embedding-3-small":{input:.02},"gpt-4o":{input:2.5,output:10},"gpt-4o-mini":{input:.15,output:.6},"gpt-5":{input:1.25,output:10}},r=n=>{const t=n.trim(),i=t.lastIndexOf("/");return(i!==-1&&!t.startsWith("@")?[t,t.slice(i+1)]:[t]).flatMap(e=>{const o=p.exec(e)?.[1];return o===void 0?[e]:[e,o]})},c=(n,t=a)=>{for(const i of r(n))if(Object.hasOwn(t,i))return t[i]},b=(n,t,i)=>{if(n===void 0||n.length===0)return;const u=c(n,i);if(u===void 0)return;const e=Number.isFinite(t.inputTokens)?Math.max(0,t.inputTokens):0,o=Number.isFinite(t.outputTokens)?Math.max(0,t.outputTokens):0;if(e<=0&&o<=0)return;const s=(e*u.input+o*(u.output??0))/1e6;return Number.isFinite(s)?s:void 0};export{a as DEFAULT_MODEL_PRICES,b as estimateModelCost,c as lookupModelPrice};
@@ -1,4 +1,4 @@
1
- import{LunoraError as g,isLunoraError as ye}from"@lunora/errors";import{tool as xe,jsonSchema as Ie,embedMany as Se,embed as _e}from"ai";import{estimateModelCost as ke}from"./DEFAULT_MODEL_PRICES-DZ3dYVUn.mjs";import Te from"./fixedWindowChunks-C461ahRE.mjs";import{c as Ae,I as Ne}from"./concurrent-C6nqBv41.mjs";import{contentHash as Me}from"./contentHash-BIn6ECP8.mjs";import ee from"./hybridRank-DejmVw2I.mjs";import{VECTORIZE_CAPABILITIES as te,vectorizeStore as De}from"./VECTORIZE_CAPABILITIES-CUQDoxis.mjs";const Re=1e3,Ce=200,$e=5,Be=4,ne=te.maxMetadataBytes===!1?Number.POSITIVE_INFINITY:te.maxMetadataBytes,Oe=2*1024,ie="__ragChunk",ce="__ragSource",A="__ragText",Q="__ragHash",V="__ragChunks",B="__ragImportance",de="__ragModel",Ke=new Set([ie,V,Q,B,de,ce,A]),Ue=(e,i,m,w)=>{if(w===!1)return;const E=new TextEncoder().encode(JSON.stringify(e)).length;if(E<=w)return;const R=(typeof e[A]=="string"?new TextEncoder().encode(e[A]).length:0)*2>E?"lower `chunkSize` (it counts characters, not bytes — multibyte text costs up to 3 bytes each), or supply `textStore` to move chunk text out of metadata entirely":"attach less per-source `metadata`";throw new g("BAD_REQUEST",`@lunora/ai/rag: chunk ${String(i)} of "${m}" carries ${String(E)} bytes of metadata, over the store's ${String(w)}-byte per-vector ceiling — ${R}`)},Qe=(e,i,m)=>{if(m===!1)return;const w=new TextEncoder().encode(e).length;if(!(w<=m))throw new g("BAD_REQUEST",`@lunora/ai/rag: chunk id "${e}" for source "${i}" is ${String(w)} bytes, over the store's ${String(m)}-byte per-vector id ceiling — shorten the source id (hash long keys before indexing them) or shorten the \`namespace\`, which is prefixed onto every chunk id`)},Ve=/^[\w.-]{1,40}$/,ue=e=>e===void 0?"":`${encodeURIComponent(e)}#`,T=(e,i,m)=>`${ue(e)}${i}#${String(m)}`,re=(e,i)=>{const m=ue(i),w=m!==""&&e.startsWith(m)?e.slice(m.length):e,E=w.lastIndexOf("#"),S=E===-1?Number.NaN:Number(w.slice(E+1));return E===-1||!Number.isInteger(S)||S<0?{chunkIndex:0,sourceId:w}:{chunkIndex:S,sourceId:w.slice(0,E)}},Fe=async e=>Me(new TextEncoder().encode(e)),ze=(e,i)=>e.filter(m=>m.score>=i),oe=e=>{if(!e)return;const i=Object.entries(e).filter(([m])=>!Ke.has(m));return i.length>0?Object.fromEntries(i):void 0},se=new Set,Le=e=>{se.has(e)||(se.add(e),console.warn(`[@lunora/ai/rag] index "${e}" is used without a namespace — in a multi-tenant/sharded
1
+ import{LunoraError as g,isLunoraError as ye}from"@lunora/errors";import{tool as xe,jsonSchema as Ie,embedMany as Se,embed as _e}from"ai";import{estimateModelCost as ke}from"./DEFAULT_MODEL_PRICES-Q8uxdiuV.mjs";import Te from"./fixedWindowChunks-C461ahRE.mjs";import{c as Ae,I as Ne}from"./concurrent-C6nqBv41.mjs";import{contentHash as Me}from"./contentHash-BIn6ECP8.mjs";import ee from"./hybridRank-DejmVw2I.mjs";import{VECTORIZE_CAPABILITIES as te,vectorizeStore as De}from"./VECTORIZE_CAPABILITIES-CUQDoxis.mjs";const Re=1e3,Ce=200,$e=5,Be=4,ne=te.maxMetadataBytes===!1?Number.POSITIVE_INFINITY:te.maxMetadataBytes,Oe=2*1024,ie="__ragChunk",ce="__ragSource",A="__ragText",Q="__ragHash",V="__ragChunks",B="__ragImportance",de="__ragModel",Ke=new Set([ie,V,Q,B,de,ce,A]),Ue=(e,i,m,w)=>{if(w===!1)return;const E=new TextEncoder().encode(JSON.stringify(e)).length;if(E<=w)return;const R=(typeof e[A]=="string"?new TextEncoder().encode(e[A]).length:0)*2>E?"lower `chunkSize` (it counts characters, not bytes — multibyte text costs up to 3 bytes each), or supply `textStore` to move chunk text out of metadata entirely":"attach less per-source `metadata`";throw new g("BAD_REQUEST",`@lunora/ai/rag: chunk ${String(i)} of "${m}" carries ${String(E)} bytes of metadata, over the store's ${String(w)}-byte per-vector ceiling — ${R}`)},Qe=(e,i,m)=>{if(m===!1)return;const w=new TextEncoder().encode(e).length;if(!(w<=m))throw new g("BAD_REQUEST",`@lunora/ai/rag: chunk id "${e}" for source "${i}" is ${String(w)} bytes, over the store's ${String(m)}-byte per-vector id ceiling — shorten the source id (hash long keys before indexing them) or shorten the \`namespace\`, which is prefixed onto every chunk id`)},Ve=/^[\w.-]{1,40}$/,ue=e=>e===void 0?"":`${encodeURIComponent(e)}#`,T=(e,i,m)=>`${ue(e)}${i}#${String(m)}`,re=(e,i)=>{const m=ue(i),w=m!==""&&e.startsWith(m)?e.slice(m.length):e,E=w.lastIndexOf("#"),S=E===-1?Number.NaN:Number(w.slice(E+1));return E===-1||!Number.isInteger(S)||S<0?{chunkIndex:0,sourceId:w}:{chunkIndex:S,sourceId:w.slice(0,E)}},Fe=async e=>Me(new TextEncoder().encode(e)),ze=(e,i)=>e.filter(m=>m.score>=i),oe=e=>{if(!e)return;const i=Object.entries(e).filter(([m])=>!Ke.has(m));return i.length>0?Object.fromEntries(i):void 0},se=new Set,Le=e=>{se.has(e)||(se.add(e),console.warn(`[@lunora/ai/rag] index "${e}" is used without a namespace — in a multi-tenant/sharded
2
2
  app this shares one tenant's chunks (text included) with every other tenant, since
3
3
  Vectorize indexes are account-global. Pass \`namespace\` (the shard/tenant key) on both
4
4
  index() and retrieve(). Single-tenant apps suppress this via { allowSharedNamespace: true }.`))},Pe=e=>e.map(i=>`[source:${i.sourceId}#${String(i.chunkIndex)}]
@@ -1 +1 @@
1
- import{default as o}from"../packem_shared/fixedWindowChunks-C461ahRE.mjs";import{markdownChunker as a,sentenceChunker as f,tokenChunker as n}from"../packem_shared/markdownChunker-CDME5gEs.mjs";import{default as x}from"../packem_shared/defineRag-Dzh-MbCu.mjs";import{contentHash as p,guessMimeTypeFromExtension as i}from"../packem_shared/contentHash-BIn6ECP8.mjs";import{default as c}from"../packem_shared/hybridRank-DejmVw2I.mjs";import{default as l}from"../packem_shared/bm25LexicalStore-CALA7Lhm.mjs";import{default as h}from"../packem_shared/matchesMetadataFilter-BbIOyA5g.mjs";import{batchReranker as g,scoreReranker as C}from"../packem_shared/batchReranker-Bc38FBLH.mjs";import{defineRagSource as E}from"../packem_shared/defineRagSource-Q3f3niU8.mjs";import{sqlLexicalStore as T}from"../packem_shared/sqlLexicalStore-qkTJHHzM.mjs";import{sqliteVectorStore as y}from"../packem_shared/sqliteVectorStore-DEqrp-Uc.mjs";import{ragSyncTriggers as q}from"../packem_shared/ragSyncTriggers-DPqzBNFw.mjs";import{VECTORIZE_CAPABILITIES as A,vectorizeStore as F}from"../packem_shared/VECTORIZE_CAPABILITIES-CUQDoxis.mjs";export{A as VECTORIZE_CAPABILITIES,g as batchReranker,l as bm25LexicalStore,p as contentHash,x as defineRag,E as defineRagSource,o as fixedWindowChunks,i as guessMimeTypeFromExtension,c as hybridRank,a as markdownChunker,h as matchesMetadataFilter,q as ragSyncTriggers,C as scoreReranker,f as sentenceChunker,T as sqlLexicalStore,y as sqliteVectorStore,n as tokenChunker,F as vectorizeStore};
1
+ import{default as o}from"../packem_shared/fixedWindowChunks-C461ahRE.mjs";import{markdownChunker as a,sentenceChunker as f,tokenChunker as n}from"../packem_shared/markdownChunker-CDME5gEs.mjs";import{default as x}from"../packem_shared/defineRag-CMM17YeT.mjs";import{contentHash as p,guessMimeTypeFromExtension as i}from"../packem_shared/contentHash-BIn6ECP8.mjs";import{default as c}from"../packem_shared/hybridRank-DejmVw2I.mjs";import{default as l}from"../packem_shared/bm25LexicalStore-CALA7Lhm.mjs";import{default as h}from"../packem_shared/matchesMetadataFilter-BbIOyA5g.mjs";import{batchReranker as g,scoreReranker as C}from"../packem_shared/batchReranker-Bc38FBLH.mjs";import{defineRagSource as E}from"../packem_shared/defineRagSource-Q3f3niU8.mjs";import{sqlLexicalStore as T}from"../packem_shared/sqlLexicalStore-qkTJHHzM.mjs";import{sqliteVectorStore as y}from"../packem_shared/sqliteVectorStore-DEqrp-Uc.mjs";import{ragSyncTriggers as q}from"../packem_shared/ragSyncTriggers-DPqzBNFw.mjs";import{VECTORIZE_CAPABILITIES as A,vectorizeStore as F}from"../packem_shared/VECTORIZE_CAPABILITIES-CUQDoxis.mjs";export{A as VECTORIZE_CAPABILITIES,g as batchReranker,l as bm25LexicalStore,p as contentHash,x as defineRag,E as defineRagSource,o as fixedWindowChunks,i as guessMimeTypeFromExtension,c as hybridRank,a as markdownChunker,h as matchesMetadataFilter,q as ragSyncTriggers,C as scoreReranker,f as sentenceChunker,T as sqlLexicalStore,y as sqliteVectorStore,n as tokenChunker,F as vectorizeStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/ai",
3
- "version": "1.0.0-alpha.65",
3
+ "version": "1.0.0-alpha.66",
4
4
  "description": "Workers AI helper for Lunora: provider-agnostic AI SDK access from functions, Workers AI by default",
5
5
  "keywords": [
6
6
  "ai",
@@ -1 +0,0 @@
1
- const r=/^(.*)-\d{4}-\d{2}-\d{2}$/u,a={"@cf/baai/bge-base-en-v1.5":{input:.067},"@cf/baai/bge-large-en-v1.5":{input:.204},"@cf/baai/bge-m3":{input:.012},"@cf/baai/bge-small-en-v1.5":{input:.02},"text-embedding-3-large":{input:.13},"text-embedding-3-small":{input:.02}},c=n=>{const t=n.trim(),e=t.lastIndexOf("/");return(e!==-1&&!t.startsWith("@")?[t,t.slice(e+1)]:[t]).flatMap(i=>{const o=r.exec(i)?.[1];return o===void 0?[i]:[i,o]})},b=(n,t=a)=>{for(const e of c(n))if(Object.hasOwn(t,e))return t[e]},d=(n,t,e)=>{if(n===void 0||n.length===0)return;const s=b(n,e);if(s===void 0)return;const i=Number.isFinite(t.inputTokens)?Math.max(0,t.inputTokens):0,o=Number.isFinite(t.outputTokens)?Math.max(0,t.outputTokens):0;if(i<=0&&o<=0)return;const u=(i*s.input+o*(s.output??0))/1e6;return Number.isFinite(u)?u:void 0};export{a as DEFAULT_MODEL_PRICES,d as estimateModelCost,b as lookupModelPrice};