@tinkerlandai/indiana-sdk 0.0.1 → 0.1.0
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/CHANGELOG.md +10 -0
- package/README.md +50 -266
- package/dist/{api-DDlcUvTv.d.ts → ai-usage-DX99gvfl.d.ts} +2946 -591
- package/dist/chunk-2HEB2TPD.js +1 -0
- package/dist/chunk-FMAMDKAV.js +27 -0
- package/dist/chunk-Y7LNDG3O.js +1 -0
- package/dist/{coupon-gncDkBtm.d.ts → customer-page-aZb5Twue.d.ts} +122 -3
- package/dist/funnel-runtime-host-QIYKF5KH.js +1 -0
- package/dist/funnel-runtime-start-CcuXliU_.d.ts +7834 -0
- package/dist/index.d.ts +8058 -1576
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/paywall-6HHA4OJV.js +1 -0
- package/dist/popup.d.ts +19 -123
- package/dist/popup.js +5 -4
- package/dist/{funnel-runtime-C05ZECiP.d.ts → screen-DfuSw6Tz.d.ts} +320 -2419
- package/dist/server.d.ts +4 -765
- package/dist/server.js +1 -1
- package/dist/src-G7U7DUQR.js +1 -0
- package/package.json +3 -3
- package/dist/ai-usage-CzA11PV5.d.ts +0 -235
- package/dist/chunk-IUDHYOKC.js +0 -21
- package/dist/chunk-OIWEFX7U.js +0 -1
- package/dist/chunk-TDSKWZTO.js +0 -1
- package/dist/feature-client-CyYevYy2.d.ts +0 -450
- package/dist/funnel-runtime-host-DWRQK5U2.js +0 -4
- package/dist/src-MCXYJ2QR.js +0 -1
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as P}from"./chunk-OIWEFX7U.js";import{a as o,b as g}from"./chunk-TDSKWZTO.js";import{Jh as W,Ji as Z,Ki as H,Xe as i,Xg as b,Yg as K,_g as z,ch as _,dh as C,eh as $,h as M,i as B,j as G,k as j,l as R,wa as Q,yh as Y,z as N}from"./chunk-IUDHYOKC.js";function p(n,r){try{return n.parse(r)}catch{throw new o("INVALID_RESPONSE","Invalid gateway response")}}function oe(n){if(typeof window<"u")throw new o("SERVER_ONLY","Funnel starts are issued by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let r=g({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async start(t){let e=Y.safeParse({...t,operation:"start"});if(!e.success||e.data.operation!=="start")throw new o("INVALID_REQUEST","Invalid current Funnel start");let s=e.data,c=W.safeParse(await r.request("funnels",s));if(!c.success||!c.data.runToken)throw new o("INVALID_RESPONSE","Funnel start credentials are missing");let a=c.data,u=s.commerce??null;if(a.run.commerce?.provider!==u?.provider||a.run.commerce?.currency!==u?.currency||s.source.type==="funnel"&&a.run.funnelId!==s.source.id)throw new o("INVALID_RESPONSE","Funnel start contract changed");return{...a,runToken:a.runToken}}}}var S=class extends o{constructor(t,e){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,e);this.decisionId=t;this.decisionRequestId=e}decisionId;decisionRequestId};function ie(n){if(typeof window<"u")throw new o("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new o("INVALID_TOKEN","A server API key is required");async function r(s,c,a=!1){let u=g({...n,fetch:(l,m)=>{let f=new Headers(m?.headers);return f.set("Accept-Encoding","identity"),a&&f.set("Prefer","respond-async"),(n.fetch??globalThis.fetch)(l,{...m,headers:f})},timeoutMs:Math.min(n.timeoutMs??1e4,c?Math.max(1,c-Date.now()):12e4)});return u.identify(n.apiKey),u.request("funnels",s)}async function t(s,c){let a=C.parse(await r(_.parse({operation:"read_decision",decisionId:s}),c));if(a.decisionId!==s)throw new o("INVALID_RESPONSE","Decision identity changed");return a}async function e(s,c,a=!1){let u=_.parse({...s,operation:"decide",funnelId:n.funnelId}),l;try{l=C.parse(await r(u,c,a))}catch(m){throw m instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(m.code)?new o("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",m.status,s.requestId):m}if(l.requestId!==s.requestId||l.decision&&l.decision.customerId!==s.customerId)throw new o("INVALID_RESPONSE","Decision request or customer changed");return l}return{features(s={}){return P({...s,scope:n.scope,funnelId:n.funnelId,load:async()=>Q.parse(await r({operation:"feature_config",funnelId:n.funnelId}))})},read:s=>t(s),async submit(s){return e(s,void 0,!0)},async decide(s){let c=Date.now()+3e4,a=await e(s,c),u=a.decisionId,l=250;for(;;){if(a.requestId!==s.requestId||a.decision&&a.decision.customerId!==s.customerId)throw new o("INVALID_RESPONSE","Decision request or customer changed");if(a.decision)return a.decision;if(a.status==="failed")throw new o("DECISION_FAILED","Decision execution failed",503,s.requestId);if(Date.now()>=c)throw new S(u,s.requestId);if(await new Promise(m=>setTimeout(m,Math.min(l,c-Date.now()))),Date.now()>=c)throw new S(u,s.requestId);try{l=Math.min(1e3,l*2),a=await t(u,c)}catch(m){if(m instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(m.code))continue;throw m}}},async reportUsed(s){let c=$.parse(await r(_.parse({...s,operation:"report_used"})));if(c.decisionId!==s.decisionId||c.eventId!==s.eventId)throw new o("INVALID_RESPONSE","Usage receipt identity changed");return c}}}function ce(n){if(typeof window<"u")throw new o("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new o("INVALID_TOKEN","Server API key required");let r=g({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async recover(t){let e=Z.parse(t),s=H.parse(await r.request("funnels",e));if(s.requestId!==e.requestId||s.orderId!==e.orderId||s.receiptId!==e.receiptId||s.scope.projectId!==n.scope.projectId||s.scope.environment!==n.scope.environment)throw new o("INVALID_RESPONSE","Current order receipt scope changed");return s}}}import{z as d}from"zod";var q=M,ue=d.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),te=d.strictObject(Object.fromEntries(q.map(n=>[n,d.number().int().nonnegative().max(1e9)]))),re=B,pe=G,U=d.strictObject({modelId:re,source:d.enum(["models.dev","custom"]),fetchedAt:d.iso.datetime(),rates:j,contextTier:d.number().int().nonnegative(),markupPercent:pe}),O=d.strictObject({pricing:U,tokens:te,quantity:N,digest:d.string().regex(/^[a-f0-9]{64}$/)}),ne=n=>{let[r,t=""]=n.split(".");return BigInt(r)*10n**12n+BigInt(t.padEnd(12,"0"))};function de(n){if(typeof n!="number"||!Number.isFinite(n)||n<0)throw new o("AI_PRICE_UNAVAILABLE","A published token price is missing");let r=String(n),t=r.includes("e")?n.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):r;if(Number(t)!==n||!ue.safeParse(t).success)throw new o("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return t}var J=d.strictObject({input:d.number().nonnegative(),output:d.number().nonnegative(),cache_read:d.number().nonnegative().optional(),cache_write:d.number().nonnegative().optional(),reasoning:d.number().nonnegative().optional(),input_audio:d.number().nonnegative().optional(),output_audio:d.number().nonnegative().optional()}),le=J.extend({context_over_200k:d.unknown().optional(),tiers:d.array(J.extend({tier:d.strictObject({type:d.literal("context"),size:d.number().int().nonnegative()})})).max(20).refine(n=>new Set(n.map(r=>r.tier.size)).size===n.length).optional()});async function X(n,r,t){let e=new TextEncoder().encode(JSON.stringify({pricing:n,tokens:r,quantity:t}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",e))].map(s=>s.toString(16).padStart(2,"0")).join("")}function ee(n,r){let t=0n;for(let a of q){if(!r[a])continue;let u=n.rates[a];if(u===void 0)throw new o("AI_PRICE_UNAVAILABLE",`No published price for ${a}; report exclusive token pools`);t+=ne(u)*BigInt(r[a])}let e=1000000n+BigInt(Math.round(n.markupPercent*1e4)),s=10n**12n,c=(t*e+s-1n)/s;return N.parse(`${c/1000000n}.${(c%1000000n).toString().padStart(6,"0")}`)}function se(n={}){if(typeof window<"u")throw new o("SERVER_ONLY","AI token pricing belongs on your backend");let r=R.parse({defaultMarkup:n.defaultMarkup??0,providerMarkups:n.providerMarkups??{},modelMarkups:n.modelMarkups??{},customModels:n.customModels??{}}),t=null,e=0;async function s(){if(!t||Date.now()>=e){e=Date.now()+15*6e4;let c=(async()=>{let a=await(n.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!a.ok)throw new o("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:d.record(d.string(),d.object({models:d.record(d.string(),d.unknown())})).parse(await a.json()),fetchedAt:new Date().toISOString()}})().catch(a=>{throw t===c&&(t=null),a});t=c}return t}return{refreshPrices(){t=null,e=0},async quoteTokens(c){let a=re.parse(c.modelId),u=te.parse(c.tokens),[l,...m]=a.split("/"),f=r.customModels[a],w,I,y,T=0;if(f)w=f,I="custom",y=new Date().toISOString();else{let D=await s(),L=D.data[l]?.models[m.join("/")];if(!L)throw new o("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:E}=d.object({cost:le}).parse(L),V=u.input+u.cache_read+u.cache_write+u.input_audio;if(E.tiers===void 0&&E.context_over_200k!==void 0&&V>2e5)throw new o("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let k=E.tiers?.filter(h=>V>h.tier.size).sort((h,ae)=>ae.tier.size-h.tier.size)[0],F=k??E;k&&(T=k.tier.size),w=Object.fromEntries(q.filter(h=>F[h]!==void 0).map(h=>[h,de(F[h])])),I="models.dev",y=D.fetchedAt}let v=U.parse({modelId:a,source:I,fetchedAt:y,rates:w,contextTier:T,markupPercent:r.modelMarkups[a]??r.providerMarkups[l]??r.defaultMarkup}),x=ee(v,u);return O.parse({pricing:v,tokens:u,quantity:x,digest:await X(v,u,x)})},async trackTokens(c,a){let u=O.parse(a.quote);if(u.quantity!==ee(u.pricing,u.tokens)||u.digest!==await X(u.pricing,u.tokens,u.quantity))throw new o("INVALID_REQUEST","AI quote changed after pricing");let l=a.properties??{},m=a.providerCostUsd===void 0?void 0:d.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(a.providerCostUsd),f=a.generationId===void 0?void 0:d.string().min(1).max(120).parse(a.generationId),w=8+ +(m!==void 0)+ +(f!==void 0);if(Object.keys(l).some(y=>y.startsWith("ai_")))throw new o("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(l).length>16-w)throw new o("INVALID_REQUEST","AI tracking properties exceed the available event budget");let I={operation:"consume",entitlementId:a.entitlementId,quantity:u.quantity,idempotencyKey:a.idempotencyKey,properties:{...l,...m!==void 0?{ai_provider_cost_usd:m}:{},...f!==void 0?{ai_generation_id:f}:{},ai_model:u.pricing.modelId,ai_source:u.pricing.source,ai_price_at:u.pricing.fetchedAt,ai_quote_hash:u.digest,ai_markup:String(u.pricing.markupPercent),ai_tier:String(u.pricing.contextTier),ai_tokens:q.map(y=>u.tokens[y]).join(","),ai_rates:"v1:"+q.map(y=>u.pricing.rates[y]===void 0?"-":ne(u.pricing.rates[y]).toString(36)).join(",")},...a.entityId?{entityId:a.entityId}:{}};return c.mutateBalance({customerId:a.customerId,command:I})}}}async function me(n,r,t={}){let{configuration:e}=await n.readAiPricing(r);return se({...R.parse(e),...t})}import{z as fe}from"zod";var A=fe.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function we(n,r){let t=A.parse(n.inputTokens.total),e=A.parse(n.outputTokens.total),s=A.parse(n.inputTokens.cacheRead??0),c=A.parse(n.inputTokens.cacheWrite??0),a=A.parse(n.outputTokens.reasoning??0);if(s+c>t||a>e||n.inputTokens.noCache!==void 0&&A.parse(n.inputTokens.noCache)!==t-s-c||n.outputTokens.text!==void 0&&A.parse(n.outputTokens.text)!==e-a)throw new o("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:t-s-c,cache_read:s,cache_write:c,output:r==="output"?e:e-a,reasoning:r==="separate"?a:0,input_audio:0,output_audio:0}}function ge(n){if(typeof window<"u")throw new o("SERVER_ONLY","AI usage belongs on the trusted backend");if(!n.modelId||!["output","separate"].includes(n.reasoning))throw new o("INVALID_REQUEST","Model ID and reasoning pricing are required");async function r(e){await n.persist({context:e,modelId:n.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function t(e,s){let c={context:e,modelId:n.modelId,usage:s,tokens:null,quote:null,receipt:null,phase:"captured"};await n.persist(c);let a=n.mapTokens?n.mapTokens(s):we(s,n.reasoning),u=await n.pricing.quoteTokens({modelId:n.modelId,tokens:a});await n.persist({...c,tokens:a,quote:u,phase:"quoted"});let l=await n.pricing.trackTokens(n.client,{...e,quote:u});if(!l.receipt.accepted)throw new o("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await n.persist({...c,tokens:a,quote:u,receipt:l,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:e}){let s=await n.context(),c;try{c=await e()}catch(a){throw await r(s),a}return await t(s,c.usage),c},async wrapStream({doStream:e}){let s=await n.context(),c;try{c=await e()}catch(f){throw await r(s),f}let a=!1,u=!1,l=c.stream.getReader();async function m(){a||u||(u=!0,await r(s))}return{...c,stream:new ReadableStream({async pull(f){try{let{value:w,done:I}=await l.read();if(I){if(!a)throw await m(),new o("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");f.close();return}if(w.type==="finish"){if(a)throw new o("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");a=!0,await t(s,w.usage)}f.enqueue(w)}catch(w){try{await m()}finally{f.error(w),await l.cancel(w)}}},async cancel(f){try{await m()}finally{await l.cancel(f)}}})}}}}function ye(n){if(typeof window<"u")throw new o("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let r=g(n);return r.identify(n.apiKey),{async signal(t){let e=b.parse({...t,operation:"signal"}),s=K.parse(await r.request("funnels",e));if(s.runId!==t.runId||s.eventId!==t.eventId||s.scope.projectId!==n.scope.projectId||s.scope.environment!==n.scope.environment)throw new o("INVALID_RESPONSE","Receipt identity changed");return s},async readResults(t){let e=b.parse({operation:"read_results",runId:t}),s=z.parse(await r.request("funnels",e));if(s.runId!==t||s.scope.projectId!==n.scope.projectId||s.scope.environment!==n.scope.environment)throw new o("INVALID_RESPONSE","Result identity changed");return s}}}function je(){if(typeof window<"u")throw new o("SERVER_ONLY","Guest identity is issued by your backend");let n=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...n)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function Qe(n){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on your backend");let r=g(n);return r.identify(n.apiKey),{async setupPayment(t){let e=i.setupPayment;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readPaymentSetup(t){let e=i.readPaymentSetup;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewSubscriptionBatch(t){let e=i.previewSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async confirmSubscriptionBatch(t){let e=i.confirmSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionBatch(t){let e=i.readSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async abandonSubscriptionBatch(t){let e=i.abandonSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageSubscriptionTrial(t){let e=i.manageSubscriptionTrial;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionTrial(t){let e=i.readSubscriptionTrial;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptions(t){let e=i.listSubscriptions;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listPurchases(t){let e=i.listPurchases;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptionConflicts(t){let e=i.listSubscriptionConflicts;return p(e.response,await r.request(e.path,e.request.parse(t)))},async retrySubscriptionConflict(t){let e=i.retrySubscriptionConflict;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewRefund(t){let e=i.previewRefund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async refund(t){let e=i.refund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readRefund(t){let e=i.readRefund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewUpdate(t){let e=i.previewUpdate;return p(e.response,await r.request(e.path,e.request.parse(t)))},async update(t){let e=i.update;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){let e=i.readSubscriptionUpdate;return p(e.response,await r.request(e.path,e.request.parse(t)))},async restoreNativePurchase(t){let e=i.restoreNativePurchase;return p(e.response,await r.request(e.path,e.request.parse(t)))},async verifySubscriptions(t){let e=i.verifySubscriptions;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewAttach(t){let e=i.previewAttach;return p(e.response,await r.request(e.path,e.request.parse(t)))},async attach(t){let e=i.attach;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){let e=i.readSubscriptionOperation;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readAiPricing(t){let e=i.readAiPricing;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsage(t){let e=i.readUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async setUsage(t){let e=i.setUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageBalanceGrant(t){let e=i.manageBalanceGrant;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readBalanceSource(t){let e=i.readBalanceSource;return p(e.response,await r.request(e.path,e.request.parse(t)))},async adjustBalance(t){let e=i.adjustBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listBalanceGrants(t){let e=i.listBalanceGrants;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageBillingLimits(t){let e=i.manageBillingLimits;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSeats(t){let e=i.readSeats;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageSeat(t){let e=i.manageSeat;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageUsageEntity(t){let e=i.manageUsageEntity;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageAnalytics(t){let e=i.readUsageAnalytics;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditAnalytics(t){let e=i.readCreditAnalytics;return p(e.response,await r.request(e.path,e.request.parse(t)))},async submitUsageBatch(t){let e=i.submitUsageBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageBatch(t){let e=i.readUsageBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readHoldings(t){let e=i.readHoldings;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readLedger(t){let e=i.readLedger;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readBillingInvoice(t){let e=i.readBillingInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditStatement(t){let e=i.readCreditStatement;return p(e.response,await r.request(e.path,e.request.parse(t)))},async quoteBalance(t){let e=i.quoteBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async mutateBalance(t){let e=i.mutateBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async getCustomer(t){let e=i.getCustomer,s=e.request.safeParse(t);if(!s.success)throw new o("INVALID_REQUEST","Invalid customer lookup");let c=e.response.safeParse(await r.request(e.path,s.data));if(!c.success)throw new o("INVALID_RESPONSE","Invalid customer response");return c.data},async listCustomers(t={}){let e=i.listCustomers,s=e.request.safeParse(t);if(!s.success)throw new o("INVALID_REQUEST","Invalid customer filters");let c=e.response.safeParse(await r.request(e.path,s.data));if(!c.success)throw new o("INVALID_RESPONSE","Invalid customer response");return c.data},async updateCustomer(t){let e=i.updateCustomer,s=e.request.safeParse(t);if(!s.success)throw new o("INVALID_REQUEST","Invalid customer patch");let c=e.response.safeParse(await r.request(e.path,s.data));if(!c.success)throw new o("INVALID_RESPONSE","Invalid customer response");return c.data},async createGuestCustomer(t){let e=i.createGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async resumeGuestSession(t){let e=i.resumeGuestSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async claimGuestCustomer(t){let e=i.claimGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async renewCustomerSession(t){let e=i.renewSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async revokeCustomerSessions(t){let e=i.revokeSessions;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async createCustomerSession(t){let e=i.createSession.request.safeParse({customerId:t});if(!e.success)throw new o("INVALID_REQUEST","A customer ID is required");let s=i.createSession.response.safeParse(await r.request("customer-sessions",e.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid customer session response");return s.data},async getOrCreateCustomer(t){let e=i.createCustomer.request.safeParse(t);if(!e.success)throw new o("INVALID_REQUEST","Invalid customer input");let s=i.createCustomer.response.safeParse(await r.request("customers",e.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid customer response");return s.data},async grantOffer(t){let e=i.grantOffer.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!e.success)throw new o("INVALID_REQUEST","Invalid offer grant");let s=i.grantOffer.response.safeParse(await r.request("offers/grant",e.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid offer response");return s.data}}}async function Ke(n,r){if(typeof window<"u")throw new o("SERVER_ONLY","Renewal requires your backend");let{funnelCredentialCommandSchema:t,funnelCredentialResponseSchema:e}=await import("./src-MCXYJ2QR.js"),s=g(n);return s.identify(n.apiKey),e.parse(await s.request("funnels",t.parse({...r,operation:"renew_run"})))}export{S as FunnelDecisionTimeoutError,o as GrooveError,U as aiPriceSnapshotSchema,O as aiTokenQuoteSchema,se as createAiPricing,ge as createAiUsageMiddleware,me as createConfiguredAiPricing,P as createFeatureClient,ie as createFunnelDecisionClient,ye as createFunnelOrchestrationClient,oe as createFunnelStartClient,Qe as createGrooveServer,je as createGuestToken,ce as createNativeReceiptClient,Ke as renewFunnelRun};
|
|
1
|
+
import{b as Z,c as N,d as ie,e as oe}from"./chunk-Y7LNDG3O.js";import{a as c,b as I}from"./chunk-2HEB2TPD.js";import{Ag as F,Bg as j,Bj as $,Cg as Q,Di as C,Dj as Y,Ei as K,Fh as o,G as b,Gi as G,Ji as k,Ki as P,Li as z,Lk as H,Mk as W,yg as M,zg as B}from"./chunk-FMAMDKAV.js";function u(n,r){try{return n.parse(r)}catch{throw new c("INVALID_RESPONSE","Invalid gateway response")}}function ce(n){if(typeof window<"u")throw new c("SERVER_ONLY","Secret API keys must stay on the backend");return{start:r=>Z(n,r)}}var _=class extends c{constructor(t,e){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,e);this.decisionId=t;this.decisionRequestId=e}decisionId;decisionRequestId};function ue(n){if("remoteEval"in n)throw new c("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new c("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new c("INVALID_TOKEN","A server API key is required");async function r(a,i,s=!1){let p=I({...n,fetch:(l,f)=>{let m=new Headers(f?.headers);return m.set("Accept-Encoding","identity"),s&&m.set("Prefer","respond-async"),(n.fetch??globalThis.fetch)(l,{...f,headers:m})},timeoutMs:Math.min(n.timeoutMs??1e4,i?Math.max(1,i-Date.now()):12e4)});return p.identify(n.apiKey),p.request("funnels",a)}async function t(a,i){let s=P.parse(await r(k.parse({operation:"read_decision",decisionId:a}),i));if(s.decisionId!==a)throw new c("INVALID_RESPONSE","Decision identity changed");return s}async function e(a,i,s=!1){let p=k.parse({...a,operation:"decide",funnelId:n.funnelId}),l;try{l=P.parse(await r(p,i,s))}catch(f){throw f instanceof c&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(f.code)?new c("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",f.status,a.requestId):f}if(l.requestId!==a.requestId||l.decision&&l.decision.customerId!==a.customerId)throw new c("INVALID_RESPONSE","Decision request or customer changed");return l}return{async configuration(){let a=Y.parse(await r({operation:"configuration",funnelId:n.funnelId}));if(a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment||a.funnelId!==n.funnelId)throw new c("SCOPE_MISMATCH","Configuration scope changed");return a},features(a={}){return N({...a,scope:n.scope,load:async()=>$.parse(await r({operation:"feature_config",funnelId:n.funnelId}))})},read:a=>t(a),async submit(a){return e(a,void 0,!0)},async decide(a){let i=Date.now()+3e4,s=await e(a,i),p=s.decisionId,l=250;for(;;){if(s.requestId!==a.requestId||s.decision&&s.decision.customerId!==a.customerId)throw new c("INVALID_RESPONSE","Decision request or customer changed");if(s.decision)return s.decision;if(s.status==="failed")throw new c("DECISION_FAILED","Decision execution failed",503,a.requestId);if(Date.now()>=i)throw new _(p,a.requestId);if(await new Promise(f=>setTimeout(f,Math.min(l,i-Date.now()))),Date.now()>=i)throw new _(p,a.requestId);try{l=Math.min(1e3,l*2),s=await t(p,i)}catch(f){if(f instanceof c&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(f.code))continue;throw f}}},async reportUsed(a){let i=z.parse(await r(k.parse({...a,operation:"report_used"})));if(i.decisionId!==a.decisionId||i.eventId!==a.eventId)throw new c("INVALID_RESPONSE","Usage receipt identity changed");return i}}}function pe(n){if(typeof window<"u")throw new c("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new c("INVALID_TOKEN","Server API key required");let r=I({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async recover(t){let e=H.parse(t),a=W.parse(await r.request("funnels",e));if(a.requestId!==e.requestId||a.orderId!==e.orderId||a.receiptId!==e.receiptId||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new c("INVALID_RESPONSE","Current order receipt scope changed");return a}}}import{z as d}from"zod";var S=M,de=d.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),te=d.strictObject(Object.fromEntries(S.map(n=>[n,d.number().int().nonnegative().max(1e9)]))),re=B,le=F,U=d.strictObject({modelId:re,source:d.enum(["models.dev","custom"]),fetchedAt:d.iso.datetime(),rates:j,contextTier:d.number().int().nonnegative(),markupPercent:le}),O=d.strictObject({pricing:U,tokens:te,quantity:b,digest:d.string().regex(/^[a-f0-9]{64}$/)}),ne=n=>{let[r,t=""]=n.split(".");return BigInt(r)*10n**12n+BigInt(t.padEnd(12,"0"))};function me(n){if(typeof n!="number"||!Number.isFinite(n)||n<0)throw new c("AI_PRICE_UNAVAILABLE","A published token price is missing");let r=String(n),t=r.includes("e")?n.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):r;if(Number(t)!==n||!de.safeParse(t).success)throw new c("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return t}var J=d.strictObject({input:d.number().nonnegative(),output:d.number().nonnegative(),cache_read:d.number().nonnegative().optional(),cache_write:d.number().nonnegative().optional(),reasoning:d.number().nonnegative().optional(),input_audio:d.number().nonnegative().optional(),output_audio:d.number().nonnegative().optional()}),fe=J.extend({context_over_200k:d.unknown().optional(),tiers:d.array(J.extend({tier:d.strictObject({type:d.literal("context"),size:d.number().int().nonnegative()})})).max(20).refine(n=>new Set(n.map(r=>r.tier.size)).size===n.length).optional()});async function X(n,r,t){let e=new TextEncoder().encode(JSON.stringify({pricing:n,tokens:r,quantity:t}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",e))].map(a=>a.toString(16).padStart(2,"0")).join("")}function ee(n,r){let t=0n;for(let w of S){if(!r[w])continue;let g=n.rates[w];if(g===void 0)throw new c("AI_PRICE_UNAVAILABLE",`No published price for ${w}; report exclusive token pools`);t+=ne(g)*BigInt(r[w])}let[e,a="0"]=String(n.markupPercent).split("e"),i=(e.split(".")[1]?.length??0)-Number(a),s=10n**BigInt(Math.max(i,0)),p=BigInt(e.replace(".",""))*10n**BigInt(Math.max(-i,0)),l=100n*s+p,f=100n*s*1000000n,m=(t*l+f-1n)/f;return b.parse(`${m/1000000n}.${(m%1000000n).toString().padStart(6,"0")}`)}function ae(n={}){if(typeof window<"u")throw new c("SERVER_ONLY","AI token pricing belongs on your backend");let r=Q.parse({defaultMarkup:n.defaultMarkup??0,providerMarkups:n.providerMarkups??{},modelMarkups:n.modelMarkups??{},customModels:n.customModels??{}}),t=null,e=0;async function a(){if(!t||Date.now()>=e){e=Date.now()+15*6e4;let i=(async()=>{let s=await(n.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!s.ok)throw new c("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:d.record(d.string(),d.object({models:d.record(d.string(),d.unknown())})).parse(await s.json()),fetchedAt:new Date().toISOString()}})().catch(s=>{throw t===i&&(t=null),s});t=i}return t}return{refreshPrices(){t=null,e=0},async quoteTokens(i){let s=re.parse(i.modelId),p=te.parse(i.tokens),[l,...f]=s.split("/"),m=r.customModels[s],w,g,y,x=0;if(m?.input!==void 0&&m.output!==void 0&&S.every(q=>p[q]===0||m[q]!==void 0))w={...m,input:m.input,output:m.output},g="custom",y=new Date().toISOString();else{let q=await a(),D=q.data[l]?.models[f.join("/")];if(!D)throw new c("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:E}=d.object({cost:fe}).parse(D),L=p.input+p.cache_read+p.cache_write+p.input_audio;if(E.tiers===void 0&&E.context_over_200k!==void 0&&L>2e5)throw new c("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let R=E.tiers?.filter(h=>L>h.tier.size).sort((h,se)=>se.tier.size-h.tier.size)[0],V=R??E;R&&(x=R.tier.size),w=Object.fromEntries(S.filter(h=>V[h]!==void 0).map(h=>[h,me(V[h])])),w={...w,...m},g=m?"custom":"models.dev",y=q.fetchedAt}let v=U.parse({modelId:s,source:g,fetchedAt:y,rates:w,contextTier:x,markupPercent:r.modelMarkups[s]??r.providerMarkups[l]??r.defaultMarkup}),T=ee(v,p);return O.parse({pricing:v,tokens:p,quantity:T,digest:await X(v,p,T)})},async trackTokens(i,s){let p=O.parse(s.quote);if(p.quantity!==ee(p.pricing,p.tokens)||p.digest!==await X(p.pricing,p.tokens,p.quantity))throw new c("INVALID_REQUEST","AI quote changed after pricing");let l=s.properties??{},f=s.providerCostUsd===void 0?void 0:d.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(s.providerCostUsd),m=s.generationId===void 0?void 0:d.string().min(1).max(120).parse(s.generationId),w=8+ +(f!==void 0)+ +(m!==void 0);if(Object.keys(l).some(y=>y.startsWith("ai_")))throw new c("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(l).length>16-w)throw new c("INVALID_REQUEST","AI tracking properties exceed the available event budget");let g={operation:"consume",internal_feature_id:s.internal_feature_id,quantity:p.quantity,idempotencyKey:s.idempotencyKey,properties:{...l,...f!==void 0?{ai_provider_cost_usd:f}:{},...m!==void 0?{ai_generation_id:m}:{},ai_model:p.pricing.modelId,ai_source:p.pricing.source,ai_price_at:p.pricing.fetchedAt,ai_quote_hash:p.digest,ai_markup:String(p.pricing.markupPercent),ai_tier:String(p.pricing.contextTier),ai_tokens:S.map(y=>p.tokens[y]).join(","),ai_rates:"v1:"+S.map(y=>p.pricing.rates[y]===void 0?"-":ne(p.pricing.rates[y]).toString(36)).join(",")},...s.entityId?{entityId:s.entityId}:{}};return i.mutateBalance({customerId:s.customerId,command:g})}}}async function we(n,r,t={}){let{config:e,model_markups:a}=await n.readAiPricing(r);return ae({defaultMarkup:e.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(e.provider_markups??{}).map(([i,s])=>[i,s.markup])),modelMarkups:Object.fromEntries(Object.entries(a??{}).filter(([,i])=>i.markup!==void 0).map(([i,s])=>[i,s.markup])),customModels:Object.fromEntries(Object.entries(a??{}).filter(([,i])=>i.input_cost!==void 0||i.output_cost!==void 0).map(([i,s])=>[i,{...s.input_cost!==void 0?{input:String(s.input_cost)}:{},...s.output_cost!==void 0?{output:String(s.output_cost)}:{}}])),...t})}import{z as ge}from"zod";var A=ge.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function ye(n,r){let t=A.parse(n.inputTokens.total),e=A.parse(n.outputTokens.total),a=A.parse(n.inputTokens.cacheRead??0),i=A.parse(n.inputTokens.cacheWrite??0),s=A.parse(n.outputTokens.reasoning??0);if(a+i>t||s>e||n.inputTokens.noCache!==void 0&&A.parse(n.inputTokens.noCache)!==t-a-i||n.outputTokens.text!==void 0&&A.parse(n.outputTokens.text)!==e-s)throw new c("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:t-a-i,cache_read:a,cache_write:i,output:r==="output"?e:e-s,reasoning:r==="separate"?s:0,input_audio:0,output_audio:0}}function Ie(n){if(typeof window<"u")throw new c("SERVER_ONLY","AI usage belongs on the trusted backend");if(!n.modelId||!["output","separate"].includes(n.reasoning))throw new c("INVALID_REQUEST","Model ID and reasoning pricing are required");async function r(e){await n.persist({context:e,modelId:n.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function t(e,a){let i={context:e,modelId:n.modelId,usage:a,tokens:null,quote:null,receipt:null,phase:"captured"};await n.persist(i);let s=n.mapTokens?n.mapTokens(a):ye(a,n.reasoning),p=await n.pricing.quoteTokens({modelId:n.modelId,tokens:s});await n.persist({...i,tokens:s,quote:p,phase:"quoted"});let l=await n.pricing.trackTokens(n.client,{...e,quote:p});if(!l.receipt.accepted)throw new c("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await n.persist({...i,tokens:s,quote:p,receipt:l,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:e}){let a=await n.context(),i;try{i=await e()}catch(s){throw await r(a),s}return await t(a,i.usage),i},async wrapStream({doStream:e}){let a=await n.context(),i;try{i=await e()}catch(m){throw await r(a),m}let s=!1,p=!1,l=i.stream.getReader();async function f(){s||p||(p=!0,await r(a))}return{...i,stream:new ReadableStream({async pull(m){try{let{value:w,done:g}=await l.read();if(g){if(!s)throw await f(),new c("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");m.close();return}if(w.type==="finish"){if(s)throw new c("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");s=!0,await t(a,w.usage)}m.enqueue(w)}catch(w){try{await f()}finally{m.error(w),await l.cancel(w)}}},async cancel(m){try{await f()}finally{await l.cancel(m)}}})}}}}function he(n){if(typeof window<"u")throw new c("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new c("INVALID_TOKEN","A server API key is required");let r=I(n);return r.identify(n.apiKey),{async signal(t){let e=C.parse({...t,operation:"signal"}),a=K.parse(await r.request("funnels",e));if(a.runId!==t.runId||a.eventId!==t.eventId||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new c("INVALID_RESPONSE","Receipt identity changed");return a},async readResults(t){let e=C.parse({operation:"read_results",runId:t}),a=G.parse(await r.request("funnels",e));if(a.runId!==t||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new c("INVALID_RESPONSE","Result identity changed");return a}}}function Ge(){if(typeof window<"u")throw new c("SERVER_ONLY","Guest identity is issued by your backend");let n=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...n)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function ze(n){if(typeof window<"u")throw new c("SERVER_ONLY","Secret API keys must stay on your backend");let r=I(n);return r.identify(n.apiKey),{async resolvePaywall(t){let e=o.resolvePaywall;return u(e.response,await r.request(e.path,e.request.parse(t)))},async resolveOffering(t){let e=o.resolveOffering;return u(e.response,await r.request(e.path,e.request.parse(t)))},async checkEntitlement(t){let e=o.checkEntitlement;return u(e.response,await r.request(e.path,e.request.parse(t)))},async setupPayment(t){let e=o.setupPayment;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readPaymentSetup(t){let e=o.readPaymentSetup;return u(e.response,await r.request(e.path,e.request.parse(t)))},async previewSubscriptionBatch(t){let e=o.previewSubscriptionBatch;return u(e.response,await r.request(e.path,e.request.parse(t)))},async confirmSubscriptionBatch(t){let e=o.confirmSubscriptionBatch;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionBatch(t){let e=o.readSubscriptionBatch;return u(e.response,await r.request(e.path,e.request.parse(t)))},async abandonSubscriptionBatch(t){let e=o.abandonSubscriptionBatch;return u(e.response,await r.request(e.path,e.request.parse(t)))},async manageSubscriptionTrial(t){let e=o.manageSubscriptionTrial;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionTrial(t){let e=o.readSubscriptionTrial;return u(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptions(t){let e=o.listSubscriptions;return u(e.response,await r.request(e.path,e.request.parse(t)))},async listPurchases(t){let e=o.listPurchases;return u(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptionConflicts(t){let e=o.listSubscriptionConflicts;return u(e.response,await r.request(e.path,e.request.parse(t)))},async retrySubscriptionConflict(t){let e=o.retrySubscriptionConflict;return u(e.response,await r.request(e.path,e.request.parse(t)))},async previewRefund(t){let e=o.previewRefund;return u(e.response,await r.request(e.path,e.request.parse(t)))},async refund(t){let e=o.refund;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readRefund(t){let e=o.readRefund;return u(e.response,await r.request(e.path,e.request.parse(t)))},async previewUpdate(t){let e=o.previewUpdate;return u(e.response,await r.request(e.path,e.request.parse(t)))},async update(t){let e=o.update;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){let e=o.readSubscriptionUpdate;return u(e.response,await r.request(e.path,e.request.parse(t)))},async restoreNativePurchase(t){let e=o.restoreNativePurchase;return u(e.response,await r.request(e.path,e.request.parse(t)))},async verifySubscriptions(t){let e=o.verifySubscriptions;return u(e.response,await r.request(e.path,e.request.parse(t)))},async previewAttach(t){let e=o.previewAttach;return u(e.response,await r.request(e.path,e.request.parse(t)))},async attach(t){let e=o.attach;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){let e=o.readSubscriptionOperation;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readAiPricing(t){let e=o.readAiPricing;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readUsage(t){let e=o.readUsage;return u(e.response,await r.request(e.path,e.request.parse(t)))},async setUsage(t){let e=o.setUsage;return u(e.response,await r.request(e.path,e.request.parse(t)))},async manageBalanceGrant(t){let e=o.manageBalanceGrant;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readBalanceSource(t){let e=o.readBalanceSource;return u(e.response,await r.request(e.path,e.request.parse(t)))},async adjustBalance(t){let e=o.adjustBalance;return u(e.response,await r.request(e.path,e.request.parse(t)))},async listBalanceGrants(t){let e=o.listBalanceGrants;return u(e.response,await r.request(e.path,e.request.parse(t)))},async manageBillingLimits(t){let e=o.manageBillingLimits;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readSeats(t){let e=o.readSeats;return u(e.response,await r.request(e.path,e.request.parse(t)))},async manageSeat(t){let e=o.manageSeat;return u(e.response,await r.request(e.path,e.request.parse(t)))},async manageUsageEntity(t){let e=o.manageUsageEntity;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageAnalytics(t){let e=o.readUsageAnalytics;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditAnalytics(t){let e=o.readCreditAnalytics;return u(e.response,await r.request(e.path,e.request.parse(t)))},async submitUsageBatch(t){let e=o.submitUsageBatch;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageBatch(t){let e=o.readUsageBatch;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readHoldings(t){let e=o.readHoldings;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readLedger(t){let e=o.readLedger;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readBillingInvoice(t){let e=o.readBillingInvoice;return u(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditStatement(t){let e=o.readCreditStatement;return u(e.response,await r.request(e.path,e.request.parse(t)))},async quoteBalance(t){let e=o.quoteBalance;return u(e.response,await r.request(e.path,e.request.parse(t)))},async trackUsage(t){let e=o.trackUsage;return u(e.response,await r.request(e.path,e.request.parse(t)))},async mutateBalance(t){let e=o.mutateBalance;return u(e.response,await r.request(e.path,e.request.parse(t)))},async getCustomer(t){let e=o.getCustomer,a=e.request.safeParse(t);if(!a.success)throw new c("INVALID_REQUEST","Invalid customer lookup");let i=e.response.safeParse(await r.request(e.path,a.data));if(!i.success)throw new c("INVALID_RESPONSE","Invalid customer response");return i.data},async listCustomers(t={}){let e=o.listCustomers,a=e.request.safeParse(t);if(!a.success)throw new c("INVALID_REQUEST","Invalid customer filters");let i=e.response.safeParse(await r.request(e.path,a.data));if(!i.success)throw new c("INVALID_RESPONSE","Invalid customer response");return i.data},async updateCustomer(t){let e=o.updateCustomer,a=e.request.safeParse(t);if(!a.success)throw new c("INVALID_REQUEST","Invalid customer patch");let i=e.response.safeParse(await r.request(e.path,a.data));if(!i.success)throw new c("INVALID_RESPONSE","Invalid customer response");return i.data},async createGuestCustomer(t){let e=o.createGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async resumeGuestSession(t){let e=o.resumeGuestSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async claimGuestCustomer(t){let e=o.claimGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async renewCustomerSession(t){let e=o.renewSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async revokeCustomerSessions(t){let e=o.revokeSessions;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async createCustomerSession(t){let e=o.createSession.request.safeParse({customerId:t});if(!e.success)throw new c("INVALID_REQUEST","A customer ID is required");let a=o.createSession.response.safeParse(await r.request("customer-sessions",e.data));if(!a.success)throw new c("INVALID_RESPONSE","Invalid customer session response");return a.data},async getOrCreateCustomer(t){let e=o.createCustomer.request.safeParse(t);if(!e.success)throw new c("INVALID_REQUEST","Invalid customer input");let a=o.createCustomer.response.safeParse(await r.request("customers",e.data));if(!a.success)throw new c("INVALID_RESPONSE","Invalid customer response");return a.data},async grantOffer(t){let e=o.grantOffer.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!e.success)throw new c("INVALID_REQUEST","Invalid offer grant");let a=o.grantOffer.response.safeParse(await r.request("offers/grant",e.data));if(!a.success)throw new c("INVALID_RESPONSE","Invalid offer response");return a.data}}}async function $e(n,r){if(typeof window<"u")throw new c("SERVER_ONLY","Renewal requires your backend");let{funnelCredentialCommandSchema:t,funnelCredentialResponseSchema:e}=await import("./src-G7U7DUQR.js"),a=I(n);return a.identify(n.apiKey),e.parse(await a.request("funnels",t.parse({...r,operation:"renew_run"})))}export{_ as FunnelDecisionTimeoutError,c as IndianaError,U as aiPriceSnapshotSchema,O as aiTokenQuoteSchema,ae as createAiPricing,Ie as createAiUsageMiddleware,we as createConfiguredAiPricing,N as createFeatureClient,ue as createFunnelDecisionClient,he as createFunnelOrchestrationClient,oe as createFunnelStartClient,Ge as createGuestToken,ze as createIndianaServer,pe as createNativeReceiptClient,ce as createPaywallStartClient,ie as evaluateFunnelNode,$e as renewFunnelRun};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$,$a,$b,$c,$d,$e,$f as ag,$g as ah,$h as ai,$i as aj,$j as ak,$k as al,A,Aa,Ab,Ac,Ad,Ae,Af as Bf,Ag as Bg,Ah as Bh,Ai as Bi,Aj as Bj,Ak as Bk,B,Ba,Bb,Bc,Bd,Be,Bf as Cf,Bg as Cg,Bh as Ch,Bi as Ci,Bj as Cj,Bk as Ck,C,Ca,Cb,Cc,Cd,Ce,Cf as Df,Cg as Dg,Ch as Dh,Ci as Di,Cj as Dj,Ck as Dk,D,Da,Db,Dc,Dd,De,Df as Ef,Dg as Eg,Dh as Eh,Di as Ei,Dj as Ej,Dk as Ek,E,Ea,Eb,Ec,Ed,Ee,Ef as Ff,Eg as Fg,Eh as Fh,Ei as Fi,Ej as Fj,Ek as Fk,F,Fa,Fb,Fc,Fd,Fe,Ff as Gf,Fg as Gg,Fh as Gh,Fi as Gi,Fj as Gj,Fk as Gk,G,Ga,Gb,Gc,Gd,Ge,Gf as Hf,Gg as Hg,Gh as Hh,Gi as Hi,Gj as Hj,Gk as Hk,H,Ha,Hb,Hc,Hd,He,Hf as If,Hg as Ig,Hh as Ih,Hi as Ii,Hj as Ij,Hk as Ik,I,Ia,Ib,Ic,Id,Ie,If as Jf,Ig as Jg,Ih as Jh,Ii as Ji,Ij as Jj,Ik as Jk,J,Ja,Jb,Jc,Jd,Je,Jf as Kf,Jg as Kg,Jh as Kh,Ji as Ki,Jj as Kj,Jk as Kk,K,Ka,Kb,Kc,Kd,Ke,Kf as Lf,Kg as Lg,Kh as Lh,Ki as Li,Kj as Lj,Kk as Lk,L,La,Lb,Lc,Ld,Le,Lf as Mf,Lg as Mg,Lh as Mh,Li as Mi,Lj as Mj,Lk as Mk,M,Ma,Mb,Mc,Md,Me,Mf as Nf,Mg as Ng,Mh as Nh,Mi as Ni,Mj as Nj,Mk as Nk,N,Na,Nb,Nc,Nd,Ne,Nf as Of,Ng as Og,Nh as Oh,Ni as Oi,Nj as Oj,Nk as Ok,O,Oa,Ob,Oc,Od,Oe,Of as Pf,Og as Pg,Oh as Ph,Oi as Pi,Oj as Pj,Ok as Pk,P,Pa,Pb,Pc,Pd,Pe,Pf as Qf,Pg as Qg,Ph as Qh,Pi as Qi,Pj as Qj,Pk as Qk,Q,Qa,Qb,Qc,Qd,Qe,Qf as Rf,Qg as Rg,Qh as Rh,Qi as Ri,Qj as Rj,Qk as Rk,R,Ra,Rb,Rc,Rd,Re,Rf as Sf,Rg as Sg,Rh as Sh,Ri as Si,Rj as Sj,Rk as Sk,S,Sa,Sb,Sc,Sd,Se,Sf as Tf,Sg as Tg,Sh as Th,Si as Ti,Sj as Tj,Sk as Tk,T,Ta,Tb,Tc,Td,Te,Tf as Uf,Tg as Ug,Th as Uh,Ti as Ui,Tj as Uj,Tk as Uk,U,Ua,Ub,Uc,Ud,Ue,Uf as Vf,Ug as Vg,Uh as Vh,Ui as Vi,Uj as Vj,Uk as Vk,V,Va,Vb,Vc,Vd,Ve,Vf as Wf,Vg as Wg,Vh as Wh,Vi as Wi,Vj as Wj,Vk as Wk,W,Wa,Wb,Wc,Wd,We,Wf as Xf,Wg as Xg,Wh as Xh,Wi as Xi,Wj as Xj,Wk as Xk,X,Xa,Xb,Xc,Xd,Xe,Xf as Yf,Xg as Yg,Xh as Yh,Xi as Yi,Xj as Yj,Xk as Yk,Y,Ya,Yb,Yc,Yd,Ye,Yf as Zf,Yg as Zg,Yh as Zh,Yi as Zi,Yj as Zj,Yk as Zk,Z,Za,Zb,Zc,Zd,Ze,Zf as _f,Zg as _g,Zh as _h,Zi as _i,Zj as _j,Zk as _k,_,_a,_b,_c,_d,_e,_f as $f,_g as $g,_h as $h,_i as $i,_j as $j,_k as $k,a,aa,ab,ac,ad,ae,af,ag as bg,ah as bh,ai as bi,aj as bj,ak as bk,al as bl,b,ba,bb,bc,bd,be,bf,bg as cg,bh as ch,bi as ci,bj as cj,bk as ck,bl as cl,c,ca,cb,cc,cd,ce,cf,cg as dg,ch as dh,ci as di,cj as dj,ck as dk,cl as dl,d,da,db,dc,dd,de,df,dg as eg,dh as eh,di as ei,dj as ej,dk as ek,dl as el,e,ea,eb,ec,ed,ee,ef,eg as fg,eh as fh,ei as fi,ej as fj,ek as fk,el as fl,f,fa,fb,fc,fd,fe,ff,fg as gg,fh as gh,fi as gi,fj as gj,fk as gk,fl as gl,g,ga,gb,gc,gd,ge,gf,gg as hg,gh as hh,gi as hi,gj as hj,gk as hk,gl as hl,h,ha,hb,hc,hd,he,hf,hg as ig,hh as ih,hi as ii,hj as ij,hk as ik,hl as il,i,ia,ib,ic,id,ie,if as jf,ig as jg,ih as jh,ii as ji,ij as jj,ik as jk,il as jl,j,ja,jb,jc,jd,je,jf as kf,jg as kg,jh as kh,ji as ki,jj as kj,jk as kk,jl as kl,k,ka,kb,kc,kd,ke,kf as lf,kg as lg,kh as lh,ki as li,kj as lj,kk as lk,kl as ll,l,la,lb,lc,ld,le,lf as mf,lg as mg,lh as mh,li as mi,lj as mj,lk as mk,ll as ml,m,ma,mb,mc,md,me,mf as nf,mg as ng,mh as nh,mi as ni,mj as nj,mk as nk,ml as nl,n,na,nb,nc,nd,ne,nf as of,ng as og,nh as oh,ni as oi,nj as oj,nk as ok,nl as ol,o,oa,ob,oc,od,oe,of as pf,og as pg,oh as ph,oi as pi,oj as pj,ok as pk,ol as pl,p,pa,pb,pc,pd,pe,pf as qf,pg as qg,ph as qh,pi as qi,pj as qj,pk as qk,pl as ql,q,qa,qb,qc,qd,qe,qf as rf,qg as rg,qh as rh,qi as ri,qj as rj,qk as rk,ql as rl,r,ra,rb,rc,rd,re,rf as sf,rg as sg,rh as sh,ri as si,rj as sj,rk as sk,s,sa,sb,sc,sd,se,sf as tf,sg as tg,sh as th,si as ti,sj as tj,sk as tk,t,ta,tb,tc,td,te,tf as uf,tg as ug,th as uh,ti as ui,tj as uj,tk as uk,u,ua,ub,uc,ud,ue,uf as vf,ug as vg,uh as vh,ui as vi,uj as vj,uk as vk,v,va,vb,vc,vd,ve,vf as wf,vg as wg,vh as wh,vi as wi,vj as wj,vk as wk,w,wa,wb,wc,wd,we,wf as xf,wg as xg,wh as xh,wi as xi,wj as xj,wk as xk,x,xa,xb,xc,xd,xe,xf as yf,xg as yg,xh as yh,xi as yi,xj as yj,xk as yk,y,ya,yb,yc,yd,ye,yf as zf,yg as zg,yh as zh,yi as zi,yj as zj,yk as zk,z,za,zb,zc,zd,ze,zf as Af,zg as Ag,zh as Ah,zi as Ai,zj as Aj,zk as Ak}from"./chunk-FMAMDKAV.js";export{Ma as COMMON_LOCALES,Oa as COUPON_TERM_LOCALES,Ye as CUSTOMER_DATA_SOURCES,ok as DEFAULT_AUDIENCE_GROUP,Ai as DEFAULT_FUNNEL_EXECUTION_POLICY,Ni as FUNNEL_API_CAPABILITIES,Ih as FUNNEL_LIMITS,Jj as FUNNEL_PREVIEW_LIMITS,pe as OFFERING_MAX_DEPTH,re as OFFERING_MAX_ITEMS,qe as OFFERING_MAX_PRODUCTS,Tf as POPUP_WIDTHS,hf as SCREEN_LIMITS,gf as SCREEN_SCHEMA_VERSION,Lh as SCREEN_TEMPLATES,Rf as SURFACE_PATHS,Qe as SURFACE_VARIABLES,Jh as UNBOUND_PRODUCT_VERSION_ID,j as aiCreditSystemConfigSchema,Bg as aiMarkupSchema,Ag as aiModelIdSchema,Cg as aiModelRatesSchema,Dg as aiPricingConfigurationSchema,zg as aiTokenPools,w as amountToMinor,Fh as apiErrorCodeSchema,Gh as apiOperations,yh as apiPermissionSchema,Ik as appResultsSchema,Hk as appRevenueSchema,Rk as appendScreenTemplate,il as applyGrowthReleasePlan,ki as archiveSurfaceTemplateSchema,rk as audienceCustomerSchema,Ak as audienceFunnelUsageSchema,Bk as audienceFunnelUsagesSchema,sk as audienceMembersSchema,cc as audienceSchema,qk as audienceWriteSchema,jk as auditFieldSchema,mk as auditHistoryCursorSchema,nk as auditHistorySchema,ik as auditResourceSchema,nb as autoTopupPurchaseLimitsSchema,zb as autoTopupStateSchema,pl as autumnAmountToMinor,Zj as autumnCustomerAutoTopupSchema,ck as autumnCustomerControlsSchema,ek as autumnCustomerMetadataSchema,bk as autumnCustomerOverageAllowedSchema,gk as autumnCustomerProductSummarySchema,fk as autumnCustomerProfileRecordSchema,_j as autumnCustomerSpendLimitSchema,ak as autumnCustomerUsageAlertSchema,$j as autumnCustomerUsageLimitSchema,dk as autumnEntityControlsSchema,ql as autumnMinorToAmount,rl as autumnUsageUnitAmountDecimal,ug as balanceAdjustmentCommandSchema,vg as balanceAdjustmentStateSchema,uc as balanceAllocationSchema,rc as balanceCommandSchema,zc as balanceGrantCommandSchema,yc as balanceGrantCreateSchema,Cc as balanceGrantPageSchema,Bc as balanceGrantReadSchema,Ac as balanceGrantSchema,xc as balanceOperationSchema,sc as balancePricingSegmentSchema,wc as balanceQuoteSchema,tc as balanceReceiptUnitsSchema,vc as balanceRejectionReasonSchema,Xk as balanceSourceReasonSchema,wg as balanceSourceStateSchema,Yk as balanceSourceStatusSchema,_k as balanceSourcesPageSchema,Zk as balanceSourcesQuerySchema,gb as billingAccruedMinorSchema,fb as billingAmountMinorSchema,qb as billingAuthorizationSchema,pb as billingAuthorizationTermsSchema,hb as billingBudgetMinorSchema,Ab as billingControlInputSchema,Bb as billingControlsSchema,Ib as billingCouponsSchema,z as billingCurrencies,Cb as billingInvoiceLineSchema,Db as billingInvoiceSchema,Gb as billingInvoicesSchema,ub as billingLimitSchema,gi as billingPortalInputSchema,hi as billingPortalSchema,D as billingSettingsMutationSchema,B as billingSettingsSchema,C as billingSettingsScopeSchema,yb as billingUsageWindowSchema,wf as borderSchema,Cf as buttonNodeSchema,fc as campaignInputSchema,dc as campaignOfferSchema,gc as campaignSchema,Ka as canonicalLocale,Re as capabilityBindingSchema,lb as cashPriceSchema,jb as cashPricingSchema,ib as cashPricingTiersSchema,eb as cashUnitAmountMinorSchema,ch as claimRewardProductRequestSchema,cd as commerceAccessSchema,ge as commerceContextSchema,Vd as commerceCursorSchema,Wd as commerceListQuerySchema,dd as commerceMoneySchema,Tk as commerceProductKind,bd as commerceProductKindSchema,ad as commerceProviderSchema,Ba as compileGrowthFeatures,Eb as confirmBillingAdjustmentInputSchema,sb as confirmBillingAuthorizationInputSchema,ml as consoleHasPermission,Fd as consoleRefundRequestSchema,kl as consoleResources,ll as consoleRolePermissions,jl as consoleRoleSchema,Jf as countdownNodeSchema,Va as couponAppliesToSchema,_a as couponChangeErrors,If as couponCodeNodeSchema,Ta as couponDiscountSchema,tk as couponDisplaySchema,Qh as couponDistributionBatchSchema,Sh as couponDistributionDetailSchema,Ph as couponDistributionPreviewSchema,Rh as couponDistributionRecipientSchema,Th as couponDistributionWriteSchema,Ua as couponDurationSchema,Wa as couponEligibilitySchema,Xa as couponInputSchema,Sa as couponStatusSchema,Yj as couponTemplateExample,Wj as couponTemplateKey,bb as couponWindow,wk as createAccountOverviewPage,vk as createCreditCenterPage,yk as createCustomerPageTemplates,Bh as createCustomerRequestSchema,Ch as createCustomerResponseSchema,xk as createMembershipPage,eh as createReferralCodeRequestSchema,F as creditAmountSchema,Gg as creditAnalyticsFilterSchema,Ig as creditAnalyticsPageSchema,Hg as creditAnalyticsQuerySchema,Eg as creditAnalyticsRangeSchema,Fg as creditAnalyticsTimezoneSchema,L as creditDimensionSchema,M as creditMultiplierSchema,H as creditPriceAdjustmentSchema,N as creditPricingSchema,J as creditPropertiesSchema,G as creditQuantitySchema,O as creditRateSchema,Kb as creditResetCountSchema,Jb as creditResetSchema,I as creditResourceKeySchema,Lb as creditRolloverSchema,c as creditSchemaItemSchema,Gc as creditStatementInputSchema,Hc as creditStatementSchema,i as creditSystemConfigSchema,K as creditTiersSchema,t as currencies,A as currencyAmountOptionsSchema,v as currencyDecimals,u as currencySchema,Hh as currentApiOperations,Ic as currentNotificationEventTypeSchema,Gf as customHtmlNodeSchema,ka as customerActivitySchema,nh as customerAttributesSchema,pk as customerAudienceSchema,_e as customerDataConfigSchema,bf as customerDataIntentSchema,Ef as customerDataNodeSchema,Ze as customerDataSourceSchema,Eh as customerEntitlementsSchema,wh as customerFiltersSchema,oh as customerFingerprintSchema,Jk as customerFunnelDecisionsSchema,uh as customerGetSchema,Qc as customerHoldingsSchema,ph as customerInputSchema,Uc as customerLedgerEntrySchema,Vc as customerLedgerPageSchema,Tc as customerLedgerQuerySchema,sh as customerLookupSchema,rh as customerMutationSchema,af as customerPageDataSchema,$e as customerPageNodeStateSchema,hk as customerPageSampleData,xh as customerPageSchema,th as customerPatchSchema,ac as customerPlanCreateSchema,bc as customerPlanCreatedSchema,ja as customerPlanSchema,qh as customerProfileSchema,fi as customerScheduledChangeCancelSchema,di as customerScheduledChangeSchema,ei as customerScheduledChangesSchema,hc as customerSchema,mh as customerTagsSchema,vh as customerUpdateRequestSchema,Kh as defaultScreenTheme,$a as describeCoupon,Wb as diffProductVariant,Df as dividerNodeSchema,cf as emptyCustomerPageNode,ie as entitlementCheckInputSchema,je as entitlementCheckReasonSchema,le as entitlementCheckResultSchema,he as entitlementRequirementSchema,ga as entitlementSnapshotSchema,Dh as entitlementStatusSchema,X as environmentSchema,_c as environmentSettingsSchema,ic as errorResponseSchema,ef as escapeHtmlText,na as evalCondition,pa as evalFeature,vj as executionSourceSchema,Aa as experimentConfigurationSchema,za as experimentPhaseSchema,Ea as experimentSnapshotSchema,n as featureCollectionSchema,g as featureConfigOverrideSchema,k as featureDefinitionSchema,a as featureIdSchema,$ as featureInputSchema,f as featureMarkupsOverrideSchema,o as featureOptionsSchema,Cj as featurePayloadSchema,m as featureRecordSchema,aa as featureSchema,nl as featureTypes,ol as featureUpdateBlockers,l as featureUpdateRulesSchema,Mc as featureUsageReadSchema,Nc as featureUsageSetSchema,Oc as featureUsageStateSchema,b as featureUsageTypeSchema,p as featureWriteSchema,Zf as fieldValue,uf as fillSchema,Pc as financialAmountSchema,Sc as financialCursorSchema,Rc as financialEntryTypeSchema,eg as findDocumentNode,dg as findNode,Vj as formatCouponConditions,Qa as formatCouponDiscount,Pa as formatCouponMoney,Ra as formatCouponTerms,y as formatCurrencyMinor,Wk as formatProductBillingPeriod,ab as formatUsd,Oi as funnelApiBindingSchema,Pi as funnelCapabilitySchema,qj as funnelCollectionSchema,mj as funnelCommandSchema,Ej as funnelConfigurationSchema,Yi as funnelConsumedVariables,Hj as funnelCredentialCommandSchema,Ij as funnelCredentialResponseSchema,lj as funnelDataQueriesSchema,Ki as funnelDecisionCommandSchema,Ii as funnelDecisionOutputSchema,Li as funnelDecisionResponseSchema,Ji as funnelDecisionSchema,Mi as funnelDecisionUsedResponseSchema,gj as funnelDocumentDraftSchema,ij as funnelDocumentSchema,mi as funnelEvaluationAttributes,oj as funnelEvaluationModeSchema,zi as funnelExecutionPolicySchema,cj as funnelExecutionStateSchema,yi as funnelExternalTaskSchema,Si as funnelGraphDraftSchema,Ri as funnelGraphNodeSchema,Ti as funnelGraphSchema,Ui as funnelGraphTargets,zk as funnelGroupReferenceSchema,uj as funnelInstructionSchema,aj as funnelNodeInputSchema,_i as funnelNodeKindSchema,bj as funnelNodeResultSchema,Ei as funnelOrchestrationCommandSchema,si as funnelParametersFromUrl,kj as funnelPresentationSubmissionSchema,Kj as funnelPreviewCommandSchema,Nj as funnelPreviewDependencySchema,Oj as funnelPreviewJournalSchema,Lj as funnelPreviewOutcomeSchema,Qj as funnelPreviewRequestSchema,Rj as funnelPreviewResponseSchema,Mj as funnelPreviewScenarioSchema,Tj as funnelPreviewShareWriteSchema,Sj as funnelPreviewSnapshotSchema,Pj as funnelPreviewSourceSchema,hj as funnelPublishableDraftSchema,pj as funnelRecordSchema,$i as funnelResourceReferenceSchema,Ck as funnelResultsCursorSchema,Dk as funnelResultsQuerySchema,Hi as funnelResultsResponseSchema,Ek as funnelResultsSchema,wj as funnelRunViewSchema,xj as funnelRuntimeResponseSchema,tj as funnelRuntimeStatusSchema,Fi as funnelSignalResponseSchema,Uj as funnelStatisticsSchema,xi as funnelTaskBindingSchema,vi as funnelTaskDataSchema,wi as funnelTaskOutputsSchema,Bi as funnelTaskResponseSchema,Gi as funnelTaskResultsSchema,Qk as funnelTemplateDraft,Ok as funnelTemplateSchema,Fj as funnelTopology,Dj as funnelTopologySchema,dj as funnelTraceEventSchema,fj as funnelValueDeclarationSchema,jj as funnelValueMatches,li as funnelValueSchema,Zi as funnelWaitKindSchema,rj as funnelWriteSchema,yj as gbRuntimeExperimentSchema,zj as gbRuntimeFeatureRuleSchema,Aj as gbRuntimeFeatureSchema,Bj as gbRuntimeSavedGroupsSchema,hl as getRecommendedRolloutData,$k as growthAttributeSchema,ra as growthAttributesSchema,bl as growthCatalogSchema,ua as growthConditionGroupIds,oi as growthConditionPaths,sa as growthConditionSchema,dl as growthDryRunSchema,el as growthExperimentInspectionSchema,Ca as growthExperimentStop,Da as growthFeatureExpiry,wa as growthFeatureRuleSchema,xa as growthFeatureSchema,ya as growthFeaturesSchema,fl as growthGroupReferenceCursorSchema,gl as growthGroupReferencesSchema,ta as growthGroupSchema,al as growthNamespaceSchema,cl as growthResourceWriteSchema,Ha as growthRuleContextSchema,va as growthSavedGroupsSchema,Fa as growthSnapshotSchema,Ia as growthSplitResultSchema,df as htmlVariableErrors,kf as identifierSchema,Bf as imageNodeSchema,tf as imagePositionSchema,rf as insetsSchema,Dc as invoiceDetailInputSchema,Fc as invoiceDetailSchema,Ec as invoiceProductItemSchema,Ed as invoiceRefundsSchema,mb as isInvoiceCreditPrice,Ne as isProductGroup,Sk as isRecurringMembership,fg as isRtlLocale,kb as itemBillingCycleSchema,qa as jsonValueSchema,E as licenseOfferSchema,Fb as listBillingInvoicesInputSchema,Na as localeLabel,Ja as localeSchema,_f as localeStatuses,cg as localizeScreen,wb as manageBillingLimitsInputSchema,vb as manageOveragePolicyInputSchema,sf as marginSchema,La as matchLocale,ni as matchesGrowthCondition,T as membershipActionSchema,Uk as membershipBillingCount,U as membershipChangeSchema,V as membershipHoldingSchema,R as membershipRulesSchema,W as membershipStateSchema,S as membershipTimingSchema,kk as mergeAuditSchema,_ as metadataSchema,h as meteredConfigSchema,x as minorToAmount,e as modelMarkupsSchema,Lk as nativeCompletionSchema,ed as nativeCouponStoreOfferLinkWriteSchema,fd as nativeCouponStoreOfferLinksSchema,nc as nativeProductBindingSchema,pc as nativeProductBindingWriteSchema,oc as nativeProductBindingsPageSchema,Kk as nativeProofSchema,kd as nativePurchaseInstructionSchema,Mk as nativeReceiptCommandSchema,Nk as nativeReceiptResponseSchema,ee as nativeRestoreCommandSchema,fe as nativeRestoreResultSchema,id as nativeStoreOfferForProduct,gd as nativeStoreOfferSelectionSchema,hd as nativeStoreOfferSelectionsSchema,jd as nativeStoreSelectionMatches,wd as nativeSubscriptionUpdatePreviewSchema,xd as nativeSubscriptionUpdateResultSchema,Oh as newBlankSurface,Za as newCouponInput,sj as newFunnelDocument,Mh as newScreenFromTemplate,Nh as newSurfaceFromTemplate,jf as nodeIdSchema,lk as objectAuditSchema,Fk as offerFlowInputSchema,Gk as offerFlowResultSchema,cb as offerSchema,db as offerUnavailableReasonSchema,xe as offeringAuthorSchema,Be as offeringCollectionSchema,we as offeringDocumentSchema,se as offeringItemSchema,te as offeringItemsSchema,oe as offeringMetadataSchema,ye as offeringProductEvidenceSchema,ne as offeringProductIdSchema,ue as offeringProductIds,Fe as offeringProductOptionSchema,ve as offeringProductPaths,He as offeringPublicationIssues,ze as offeringRecordSchema,Ee as offeringSelectorSchema,Ie as offeringValueSchema,Ae as offeringVersionSchema,Ge as offeringWorkspaceSchema,De as offeringWriteResultSchema,Ce as offeringWriteSchema,qc as overageBehaviorSchema,xb as overagePolicySchema,ej as ownedFunnelScreenSchema,pf as paintColorSchema,Pd as paymentSetupCommandSchema,Qd as paymentSetupReadSchema,Sd as paymentSetupSchema,ke as paywallCandidateSchema,jg as paywallClientActionSchema,pg as paywallCollectionSchema,kg as paywallDocumentDraftSchema,lg as paywallDocumentSchema,ng as paywallFlowIssues,rg as paywallLibrarySchema,mg as paywallProductIssues,Le as paywallProductsSchema,og as paywallRecordSchema,me as paywallRequestSchema,tg as paywallResolutionSchema,sg as paywallResolveInputSchema,qg as paywallWriteSchema,da as planConfigSchema,ea as planInputSchema,ca as planItemSchema,Kf as planPickerNodeSchema,fa as planSchema,ha as planVersionSchema,ec as popupSchema,$b as prepaidAllowanceAmount,r as prepaidPriceAmount,s as prepaidQuantityAmount,jc as prepaidQuantitySchema,q as prepaidTierPricingSchema,ob as prepareBillingAuthorizationInputSchema,Xj as prepareCouponTemplate,ma as prepareSavedGroups,rb as preparedBillingAuthorizationSchema,Sf as presentationSchema,Hf as priceNodeSchema,ba as priceSchema,Ob as productAllowanceSchema,kc as productBindingSchema,mc as productBindingWriteSchema,lc as productBindingsPageSchema,Zb as productCollectionSchema,Rb as productConfigurationSchema,Ub as productDefinitionSchema,_b as productEditorOptionsSchema,Ke as productGroupingMatches,Je as productGroupingSchema,Qb as productLicenseSchema,Uh as productMigrationBlockReasonSchema,$h as productMigrationDetailSchema,Vh as productMigrationErrorCodeSchema,_h as productMigrationItemSchema,Yh as productMigrationItemStatusSchema,ai as productMigrationListSchema,Wh as productMigrationPreviewSchema,ci as productMigrationQuerySchema,Xh as productMigrationRunStatusSchema,Zh as productMigrationSchema,bi as productMigrationWriteSchema,Xb as productOptionsSchema,Nb as productPrepaidPriceSchema,Mb as productPricesSchema,Yb as productRecordSchema,hg as productSelectionSchema,Pb as productTrialSchema,Sb as productVariantOverridesSchema,Tb as productVariantSchema,Gj as projectFunnelConfiguration,Zc as projectSettingsSchema,Ya as promotionCodeInputSchema,d as providerMarkupsSchema,$f as publishChecks,Yd as purchaseListItemSchema,ce as purchaseListPageSchema,mf as radiusSchema,bh as redeemRewardRequestSchema,fh as referralCodeSchema,hh as referralProgramCollectionSchema,Wg as referralProgramInputSchema,Yg as referralProgramRecordSchema,$g as referralProgramWriteSchema,Vf as replaceFirstPageRoot,uk as resolveCouponDisplay,Qi as resolveFunnelCapabilityInputs,Di as resolveFunnelTaskInputs,Vb as resolveProductVariant,bg as resolveScreenLocale,Ah as responseMetaSchema,tb as revokeBillingAuthorizationInputSchema,jh as rewardActivityRedemptionSchema,kh as rewardActivitySchema,Vg as rewardCodeInputSchema,ih as rewardCodeSchema,lh as rewardCodeWriteSchema,gh as rewardCollectionSchema,Sg as rewardConfigurationSchema,Qg as rewardGrantExpirySchema,Rg as rewardGrantSchema,Ug as rewardInputSchema,Tg as rewardKeySchema,Zg as rewardOptionSchema,dh as rewardProductCheckoutSchema,Xg as rewardRecordSchema,ah as rewardRedemptionSchema,Pg as rewardStatusSchema,Og as rewardTypeSchema,_g as rewardWriteSchema,oa as runExperiment,Vk as sameMembershipBillingCycle,ji as saveSurfaceTemplateSchema,Y as scopeSchema,Of as screenActionSchema,qi as screenAnswersSchema,pi as screenDataCursorSchema,Wf as screenDocumentSchema,nf as screenImageSourceSchema,ti as screenInputBindingsSchema,Nf as screenNodeSchema,ri as screenParametersSchema,ig as screenPresentationSchema,Oe as screenProductScopes,Pe as screenProductSelections,ui as screenRendererInputSchema,gg as screenSelections,Pf as screenStringsSchema,Xc as seatCommandSchema,Wc as seatReadSchema,Yc as seatsStateSchema,Wi as selectFunnelCondition,Me as selectedPaywallProduct,Xe as selectedSurfaceValue,ag as servableLocales,Hb as setBillingCouponsInputSchema,xf as shadowSchema,vf as shapeSchema,qf as sizeSchema,lf as spaceSchema,Ff as spacerNodeSchema,Z as stableKeySchema,Lf as stackInteractionSchema,Mf as stackNodeSchema,Ga as stickyAssignmentDocumentSchema,nd as stripeCouponTermsSchema,od as stripePurchaseExecutionSchema,Bd as stripeRefundExecutionSchema,Rd as stripeSetupExecutionSchema,td as stripeSubscriptionUpdateExecutionSchema,ud as stripeSubscriptionUpdatePreviewSchema,vd as stripeSubscriptionUpdateResultSchema,Md as stripeTrialExecutionSchema,zf as styleSchema,ld as subscriptionAttachCommandSchema,pd as subscriptionAttachQuoteSchema,Gd as subscriptionBatchCommandSchema,Id as subscriptionBatchGroupSchema,Hd as subscriptionBatchReadSchema,Jd as subscriptionBatchSchema,rd as subscriptionCarryOptionsSchema,de as subscriptionConflictPageSchema,_d as subscriptionConflictQuerySchema,ae as subscriptionConflictRetryResultSchema,$d as subscriptionConflictRetrySchema,Zd as subscriptionConflictSchema,Xd as subscriptionListItemSchema,be as subscriptionListPageSchema,md as subscriptionOperationInputSchema,qd as subscriptionOperationSchema,Ad as subscriptionRefundCommandSchema,Cd as subscriptionRefundPreviewSchema,Dd as subscriptionRefundResultSchema,Kd as subscriptionTrialCommandSchema,Od as subscriptionTrialPolicySchema,Ld as subscriptionTrialReadSchema,Nd as subscriptionTrialResultSchema,sd as subscriptionUpdateCommandSchema,yd as subscriptionUpdatePreviewSchema,zd as subscriptionUpdateResultSchema,Td as subscriptionVerificationInputSchema,Ud as subscriptionVerificationSchema,ff as substituteHtmlVariables,We as substituteSurfaceVariables,Te as surfaceDataSchema,Qf as surfaceSchema,ii as surfaceTemplateSchema,Se as surfaceValueSchema,Ue as surfaceVariableNames,Pk as templateScreen,Af as textNodeSchema,yf as textStyleSchema,of as themeSchema,la as toAttributeString,Xi as transitionFunnelGraph,Yf as translatableFields,P as trialPolicySchema,Q as trialRecordSchema,Ve as unknownSurfaceVariables,Kc as usageAlertNotificationDataSchema,Lc as usageAllowanceNotificationDataSchema,Kg as usageAnalyticsPageSchema,Jg as usageAnalyticsQuerySchema,Ng as usageBatchPageSchema,Mg as usageBatchReadSchema,Lg as usageBatchSubmitSchema,xg as usageEntityCommandSchema,yg as usageEntitySchema,Jc as usageLimitNotificationDataSchema,Vi as validateFunnelGraph,Ci as validateFunnelTaskData,nj as validateScreenAnswers,ia as validitySchema,zh as verifiedPrincipalSchema,Uf as walkDocument,Xf as walkScreen,$c as workspaceSettingsSchema};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinkerlandai/indiana-sdk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Framework-independent Indiana SDK for customer identity, entitlements, credits, offers and growth surfaces.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/tinkerlandai/
|
|
8
|
+
"url": "git+https://github.com/tinkerlandai/Indiana.git",
|
|
9
9
|
"directory": "packages/sdk"
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"ai": "7.0.136",
|
|
59
59
|
"tsup": "^8.5.1",
|
|
60
60
|
"typescript": "^5.9.3",
|
|
61
|
-
"@
|
|
61
|
+
"@indiana/contracts": "0.1.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@openrouter/sdk": "^1.4.25"
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { LanguageModelV4Usage, LanguageModelV4Middleware } from '@ai-sdk/provider';
|
|
2
|
-
import { F as FoundationApi, A as ApiInput } from './api-DDlcUvTv.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
declare const tokenCounts: z.ZodObject<{
|
|
6
|
-
input: z.ZodNumber;
|
|
7
|
-
output: z.ZodNumber;
|
|
8
|
-
cache_read: z.ZodNumber;
|
|
9
|
-
cache_write: z.ZodNumber;
|
|
10
|
-
reasoning: z.ZodNumber;
|
|
11
|
-
input_audio: z.ZodNumber;
|
|
12
|
-
output_audio: z.ZodNumber;
|
|
13
|
-
}, z.core.$strict>;
|
|
14
|
-
declare const aiPriceSnapshotSchema: z.ZodObject<{
|
|
15
|
-
modelId: z.ZodString;
|
|
16
|
-
source: z.ZodEnum<{
|
|
17
|
-
"models.dev": "models.dev";
|
|
18
|
-
custom: "custom";
|
|
19
|
-
}>;
|
|
20
|
-
fetchedAt: z.ZodISODateTime;
|
|
21
|
-
rates: z.ZodObject<{
|
|
22
|
-
input: z.ZodString;
|
|
23
|
-
output: z.ZodString;
|
|
24
|
-
cache_read: z.ZodOptional<z.ZodString>;
|
|
25
|
-
cache_write: z.ZodOptional<z.ZodString>;
|
|
26
|
-
reasoning: z.ZodOptional<z.ZodString>;
|
|
27
|
-
input_audio: z.ZodOptional<z.ZodString>;
|
|
28
|
-
output_audio: z.ZodOptional<z.ZodString>;
|
|
29
|
-
}, z.core.$strict>;
|
|
30
|
-
contextTier: z.ZodNumber;
|
|
31
|
-
markupPercent: z.ZodNumber;
|
|
32
|
-
}, z.core.$strict>;
|
|
33
|
-
declare const aiTokenQuoteSchema: z.ZodObject<{
|
|
34
|
-
pricing: z.ZodObject<{
|
|
35
|
-
modelId: z.ZodString;
|
|
36
|
-
source: z.ZodEnum<{
|
|
37
|
-
"models.dev": "models.dev";
|
|
38
|
-
custom: "custom";
|
|
39
|
-
}>;
|
|
40
|
-
fetchedAt: z.ZodISODateTime;
|
|
41
|
-
rates: z.ZodObject<{
|
|
42
|
-
input: z.ZodString;
|
|
43
|
-
output: z.ZodString;
|
|
44
|
-
cache_read: z.ZodOptional<z.ZodString>;
|
|
45
|
-
cache_write: z.ZodOptional<z.ZodString>;
|
|
46
|
-
reasoning: z.ZodOptional<z.ZodString>;
|
|
47
|
-
input_audio: z.ZodOptional<z.ZodString>;
|
|
48
|
-
output_audio: z.ZodOptional<z.ZodString>;
|
|
49
|
-
}, z.core.$strict>;
|
|
50
|
-
contextTier: z.ZodNumber;
|
|
51
|
-
markupPercent: z.ZodNumber;
|
|
52
|
-
}, z.core.$strict>;
|
|
53
|
-
tokens: z.ZodObject<{
|
|
54
|
-
input: z.ZodNumber;
|
|
55
|
-
output: z.ZodNumber;
|
|
56
|
-
cache_read: z.ZodNumber;
|
|
57
|
-
cache_write: z.ZodNumber;
|
|
58
|
-
reasoning: z.ZodNumber;
|
|
59
|
-
input_audio: z.ZodNumber;
|
|
60
|
-
output_audio: z.ZodNumber;
|
|
61
|
-
}, z.core.$strict>;
|
|
62
|
-
quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
63
|
-
digest: z.ZodString;
|
|
64
|
-
}, z.core.$strict>;
|
|
65
|
-
type AiTokenQuote = z.infer<typeof aiTokenQuoteSchema>;
|
|
66
|
-
type AiTokenUsage = z.infer<typeof tokenCounts>;
|
|
67
|
-
type AiPricingOptions = {
|
|
68
|
-
defaultMarkup?: number;
|
|
69
|
-
providerMarkups?: Record<string, number>;
|
|
70
|
-
modelMarkups?: Record<string, number>;
|
|
71
|
-
customModels?: Record<string, z.infer<typeof aiPriceSnapshotSchema>["rates"]>;
|
|
72
|
-
fetch?: typeof fetch;
|
|
73
|
-
};
|
|
74
|
-
/** Fetch automatic model prices on a trusted backend. Quotes can be saved with a job and reused verbatim on retries. */
|
|
75
|
-
declare function createAiPricing(options?: AiPricingOptions): {
|
|
76
|
-
/** Explicit refresh affects future quotes only, including their immutable timestamps and digest. */
|
|
77
|
-
refreshPrices(): void;
|
|
78
|
-
quoteTokens(input: {
|
|
79
|
-
modelId: string;
|
|
80
|
-
tokens: AiTokenUsage;
|
|
81
|
-
}): Promise<AiTokenQuote>;
|
|
82
|
-
/** All pools become one atomic balance operation. The metered entitlement unit must be one micro USD. */
|
|
83
|
-
trackTokens(client: Pick<FoundationApi, "mutateBalance">, input: {
|
|
84
|
-
customerId: string;
|
|
85
|
-
entitlementId: string;
|
|
86
|
-
entityId?: string;
|
|
87
|
-
idempotencyKey: string;
|
|
88
|
-
quote: AiTokenQuote;
|
|
89
|
-
properties?: Record<string, string>;
|
|
90
|
-
providerCostUsd?: string;
|
|
91
|
-
generationId?: string;
|
|
92
|
-
}): Promise<{
|
|
93
|
-
requestId: string;
|
|
94
|
-
scope: {
|
|
95
|
-
projectId: string;
|
|
96
|
-
environment: "sandbox" | "live";
|
|
97
|
-
};
|
|
98
|
-
receipt: {
|
|
99
|
-
id: string;
|
|
100
|
-
entitlementId: string;
|
|
101
|
-
kind: "confirm" | "consume" | "reserve" | "refund" | "release" | "expire";
|
|
102
|
-
originalId: string | null;
|
|
103
|
-
quantity: string;
|
|
104
|
-
accepted: boolean;
|
|
105
|
-
reason: "expired" | "unavailable" | "insufficient_balance" | "limit_exceeded" | "awaiting_topup" | "authorization_required" | "payment_blocked" | "cash_budget_exceeded" | null;
|
|
106
|
-
createdAt: string;
|
|
107
|
-
reservationStatus: "pending" | "expired" | "confirmed" | "released" | null;
|
|
108
|
-
expiresAt: string | null;
|
|
109
|
-
allocations: ({
|
|
110
|
-
funding: "prepaid";
|
|
111
|
-
sourceId: string;
|
|
112
|
-
units: string;
|
|
113
|
-
amount: string;
|
|
114
|
-
pricing: {
|
|
115
|
-
creditVersionId: string | null;
|
|
116
|
-
meteredVersionId: string;
|
|
117
|
-
dimension: string;
|
|
118
|
-
counterKey: string;
|
|
119
|
-
cycleStart: string;
|
|
120
|
-
unitCost: string;
|
|
121
|
-
units: string;
|
|
122
|
-
amount: string;
|
|
123
|
-
tier: number | null;
|
|
124
|
-
}[];
|
|
125
|
-
} | {
|
|
126
|
-
funding: "unbilled";
|
|
127
|
-
units: string;
|
|
128
|
-
} | {
|
|
129
|
-
funding: "postpaid";
|
|
130
|
-
invoiceLineId: string | null;
|
|
131
|
-
units: string;
|
|
132
|
-
authorizationId: string;
|
|
133
|
-
})[];
|
|
134
|
-
requestedQuantity?: string | undefined;
|
|
135
|
-
overageBehavior?: "cap" | "overflow" | undefined;
|
|
136
|
-
};
|
|
137
|
-
}>;
|
|
138
|
-
};
|
|
139
|
-
/** Read one published configuration for new provider calls. Saved quotes keep their original rules. */
|
|
140
|
-
declare function createConfiguredAiPricing(client: Pick<FoundationApi, "readAiPricing">, input: ApiInput<"readAiPricing">, options?: Pick<AiPricingOptions, "fetch">): Promise<{
|
|
141
|
-
/** Explicit refresh affects future quotes only, including their immutable timestamps and digest. */
|
|
142
|
-
refreshPrices(): void;
|
|
143
|
-
quoteTokens(input: {
|
|
144
|
-
modelId: string;
|
|
145
|
-
tokens: AiTokenUsage;
|
|
146
|
-
}): Promise<AiTokenQuote>;
|
|
147
|
-
/** All pools become one atomic balance operation. The metered entitlement unit must be one micro USD. */
|
|
148
|
-
trackTokens(client: Pick<FoundationApi, "mutateBalance">, input: {
|
|
149
|
-
customerId: string;
|
|
150
|
-
entitlementId: string;
|
|
151
|
-
entityId?: string;
|
|
152
|
-
idempotencyKey: string;
|
|
153
|
-
quote: AiTokenQuote;
|
|
154
|
-
properties?: Record<string, string>;
|
|
155
|
-
providerCostUsd?: string;
|
|
156
|
-
generationId?: string;
|
|
157
|
-
}): Promise<{
|
|
158
|
-
requestId: string;
|
|
159
|
-
scope: {
|
|
160
|
-
projectId: string;
|
|
161
|
-
environment: "sandbox" | "live";
|
|
162
|
-
};
|
|
163
|
-
receipt: {
|
|
164
|
-
id: string;
|
|
165
|
-
entitlementId: string;
|
|
166
|
-
kind: "confirm" | "consume" | "reserve" | "refund" | "release" | "expire";
|
|
167
|
-
originalId: string | null;
|
|
168
|
-
quantity: string;
|
|
169
|
-
accepted: boolean;
|
|
170
|
-
reason: "expired" | "unavailable" | "insufficient_balance" | "limit_exceeded" | "awaiting_topup" | "authorization_required" | "payment_blocked" | "cash_budget_exceeded" | null;
|
|
171
|
-
createdAt: string;
|
|
172
|
-
reservationStatus: "pending" | "expired" | "confirmed" | "released" | null;
|
|
173
|
-
expiresAt: string | null;
|
|
174
|
-
allocations: ({
|
|
175
|
-
funding: "prepaid";
|
|
176
|
-
sourceId: string;
|
|
177
|
-
units: string;
|
|
178
|
-
amount: string;
|
|
179
|
-
pricing: {
|
|
180
|
-
creditVersionId: string | null;
|
|
181
|
-
meteredVersionId: string;
|
|
182
|
-
dimension: string;
|
|
183
|
-
counterKey: string;
|
|
184
|
-
cycleStart: string;
|
|
185
|
-
unitCost: string;
|
|
186
|
-
units: string;
|
|
187
|
-
amount: string;
|
|
188
|
-
tier: number | null;
|
|
189
|
-
}[];
|
|
190
|
-
} | {
|
|
191
|
-
funding: "unbilled";
|
|
192
|
-
units: string;
|
|
193
|
-
} | {
|
|
194
|
-
funding: "postpaid";
|
|
195
|
-
invoiceLineId: string | null;
|
|
196
|
-
units: string;
|
|
197
|
-
authorizationId: string;
|
|
198
|
-
})[];
|
|
199
|
-
requestedQuantity?: string | undefined;
|
|
200
|
-
overageBehavior?: "cap" | "overflow" | undefined;
|
|
201
|
-
};
|
|
202
|
-
}>;
|
|
203
|
-
}>;
|
|
204
|
-
|
|
205
|
-
type AiUsageContext = {
|
|
206
|
-
customerId: string;
|
|
207
|
-
entitlementId: string;
|
|
208
|
-
entityId?: string;
|
|
209
|
-
idempotencyKey: string;
|
|
210
|
-
properties?: Record<string, string>;
|
|
211
|
-
};
|
|
212
|
-
type AiUsageRecord = {
|
|
213
|
-
context: AiUsageContext;
|
|
214
|
-
modelId: string;
|
|
215
|
-
usage: LanguageModelV4Usage | null;
|
|
216
|
-
tokens: AiTokenUsage | null;
|
|
217
|
-
quote: AiTokenQuote | null;
|
|
218
|
-
receipt: Awaited<ReturnType<FoundationApi["mutateBalance"]>> | null;
|
|
219
|
-
phase: "captured" | "quoted" | "settled" | "incomplete";
|
|
220
|
-
};
|
|
221
|
-
type AiUsageMiddlewareOptions = {
|
|
222
|
-
pricing: ReturnType<typeof createAiPricing>;
|
|
223
|
-
client: Pick<FoundationApi, "mutateBalance">;
|
|
224
|
-
modelId: string;
|
|
225
|
-
/** Allocate a durable, unique ID per provider call, including each tool step. */
|
|
226
|
-
context: () => AiUsageContext | Promise<AiUsageContext>;
|
|
227
|
-
/** Save raw usage before pricing, and the frozen quote before a balance request. */
|
|
228
|
-
persist: (record: AiUsageRecord) => Promise<void>;
|
|
229
|
-
reasoning: "output" | "separate";
|
|
230
|
-
mapTokens?: (usage: LanguageModelV4Usage) => AiTokenUsage;
|
|
231
|
-
};
|
|
232
|
-
/** Current AI SDK v7 / LanguageModelV4 only. Never suppress a failed financial settlement. */
|
|
233
|
-
declare function createAiUsageMiddleware(options: AiUsageMiddlewareOptions): LanguageModelV4Middleware;
|
|
234
|
-
|
|
235
|
-
export { type AiUsageContext as A, type AiTokenUsage as a, type AiTokenQuote as b, createAiPricing as c, type AiPricingOptions as d, type AiUsageMiddlewareOptions as e, type AiUsageRecord as f, aiPriceSnapshotSchema as g, aiTokenQuoteSchema as h, createAiUsageMiddleware as i, createConfiguredAiPricing as j };
|