@tinkerlandai/indiana-sdk 0.8.0 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +67 -20
- package/README.zh-CN.md +66 -19
- package/dist/ai-usage-BV-FlgWr.d.ts +247 -0
- package/dist/{ai-usage-Bigjb8MS.d.ts → api-B3FIE41b.d.ts} +554 -423
- package/dist/chunk-2QPETWDX.js +1 -0
- package/dist/chunk-ANOOBDW5.js +350 -0
- package/dist/chunk-BNU6IG3F.js +1 -0
- package/dist/chunk-GRLMT5PR.js +1 -0
- package/dist/chunk-LMR2TM3X.js +1 -0
- package/dist/chunk-OBYJWIRB.js +1 -0
- package/dist/{chunk-G2R56FKU.js → chunk-SHSNIJJM.js} +1 -1
- package/dist/{chunk-OVMNCZYC.js → chunk-SOQO2RDZ.js} +1 -1
- package/dist/chunk-VVV3JNS3.js +1 -0
- package/dist/{chunk-YAFMBXIE.js → chunk-X747SY26.js} +1 -1
- package/dist/chunk-Y32NPIYY.js +1 -0
- package/dist/chunk-ZT66RIFU.js +10 -0
- package/dist/{configuration-sync-VFbY1pCN.d.ts → configuration-sync-DNvKXHk-.d.ts} +25 -25
- package/dist/{content-K2HCZVC2.js → content-J3FKZTGT.js} +1 -1
- package/dist/{errors-BpCmukJr.d.ts → errors-C8lRYZ0n.d.ts} +49 -2
- package/dist/{funnel-runtime-start-DKcTCRrd.d.ts → funnel-local-client-wbz-4gFx.d.ts} +701 -6055
- package/dist/funnel-runtime-host-C5P5JTV3.js +1 -0
- package/dist/index.d.ts +1831 -1901
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +4 -3
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +7 -7
- package/dist/page.js +1 -1
- package/dist/paywall-3GIRKSHN.js +1 -0
- package/dist/popup.d.ts +2 -2
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +97 -4
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-5FPYVSPW.js +1 -0
- package/dist/server.d.ts +4648 -8
- package/dist/server.js +1 -1
- package/dist/src-BMJCIMIF.js +1 -0
- package/dist/visual.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-2A6UYUFA.js +0 -1
- package/dist/chunk-3BQFJANQ.js +0 -1
- package/dist/chunk-3ENVRJE6.js +0 -350
- package/dist/chunk-A3N4ZZTM.js +0 -7
- package/dist/chunk-AE4CUTUE.js +0 -1
- package/dist/chunk-CXYOZSOF.js +0 -1
- package/dist/funnel-runtime-host-HNZ47TZW.js +0 -1
- package/dist/paywall-PD62B2AY.js +0 -1
- package/dist/src-4MRSESVS.js +0 -1
- package/dist/{chunk-6X42DWOM.js → chunk-DSPLGTQI.js} +0 -0
- package/dist/{chunk-S5TVMQRC.js → chunk-EXCPE2XH.js} +0 -0
- package/dist/{customer-page-BrCZxcaQ.d.ts → customer-page-WUQVK_tp.d.ts} +4 -4
- package/dist/{screen-BazUOjwM.d.ts → screen-BpAejkn0.d.ts} +267 -267
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { LanguageModelV4Usage, LanguageModelV4Middleware } from '@ai-sdk/provider';
|
|
2
|
+
import { F as FoundationApi, A as ApiInput } from './api-B3FIE41b.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare const tokenCounts: z.ZodObject<{
|
|
6
|
+
output: z.ZodNumber;
|
|
7
|
+
input: 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
|
+
custom: "custom";
|
|
18
|
+
"models.dev": "models.dev";
|
|
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
|
+
custom: "custom";
|
|
38
|
+
"models.dev": "models.dev";
|
|
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
|
+
output: z.ZodNumber;
|
|
55
|
+
input: 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, Partial<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
|
+
internal_feature_id: 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
|
+
internal_feature_id: string;
|
|
101
|
+
kind: "consume" | "reserve" | "confirm" | "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
|
+
internal_credit_feature_id: string | null;
|
|
116
|
+
internal_metered_feature_id: 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: "balance";
|
|
127
|
+
sourceId: string;
|
|
128
|
+
rolloverId: string | null;
|
|
129
|
+
units: string;
|
|
130
|
+
amount: string;
|
|
131
|
+
} | {
|
|
132
|
+
funding: "unbilled";
|
|
133
|
+
units: string;
|
|
134
|
+
} | {
|
|
135
|
+
funding: "postpaid";
|
|
136
|
+
invoiceLineId: string | null;
|
|
137
|
+
units: string;
|
|
138
|
+
authorizationId: string;
|
|
139
|
+
})[];
|
|
140
|
+
requestedQuantity?: string | undefined;
|
|
141
|
+
overageBehavior?: "cap" | "overflow" | undefined;
|
|
142
|
+
};
|
|
143
|
+
}>;
|
|
144
|
+
};
|
|
145
|
+
/** Read one published configuration for new provider calls. Saved quotes keep their original rules. */
|
|
146
|
+
declare function createConfiguredAiPricing(client: Pick<FoundationApi, "readAiPricing">, input: ApiInput<"readAiPricing">, options?: Pick<AiPricingOptions, "fetch">): Promise<{
|
|
147
|
+
/** Explicit refresh affects future quotes only, including their immutable timestamps and digest. */
|
|
148
|
+
refreshPrices(): void;
|
|
149
|
+
quoteTokens(input: {
|
|
150
|
+
modelId: string;
|
|
151
|
+
tokens: AiTokenUsage;
|
|
152
|
+
}): Promise<AiTokenQuote>;
|
|
153
|
+
/** All pools become one atomic balance operation. The metered entitlement unit must be one micro USD. */
|
|
154
|
+
trackTokens(client: Pick<FoundationApi, "mutateBalance">, input: {
|
|
155
|
+
customerId: string;
|
|
156
|
+
internal_feature_id: string;
|
|
157
|
+
entityId?: string;
|
|
158
|
+
idempotencyKey: string;
|
|
159
|
+
quote: AiTokenQuote;
|
|
160
|
+
properties?: Record<string, string>;
|
|
161
|
+
providerCostUsd?: string;
|
|
162
|
+
generationId?: string;
|
|
163
|
+
}): Promise<{
|
|
164
|
+
requestId: string;
|
|
165
|
+
scope: {
|
|
166
|
+
projectId: string;
|
|
167
|
+
environment: "sandbox" | "live";
|
|
168
|
+
};
|
|
169
|
+
receipt: {
|
|
170
|
+
id: string;
|
|
171
|
+
internal_feature_id: string;
|
|
172
|
+
kind: "consume" | "reserve" | "confirm" | "refund" | "release" | "expire";
|
|
173
|
+
originalId: string | null;
|
|
174
|
+
quantity: string;
|
|
175
|
+
accepted: boolean;
|
|
176
|
+
reason: "expired" | "unavailable" | "insufficient_balance" | "limit_exceeded" | "awaiting_topup" | "authorization_required" | "payment_blocked" | "cash_budget_exceeded" | null;
|
|
177
|
+
createdAt: string;
|
|
178
|
+
reservationStatus: "pending" | "expired" | "confirmed" | "released" | null;
|
|
179
|
+
expiresAt: string | null;
|
|
180
|
+
allocations: ({
|
|
181
|
+
funding: "prepaid";
|
|
182
|
+
sourceId: string;
|
|
183
|
+
units: string;
|
|
184
|
+
amount: string;
|
|
185
|
+
pricing: {
|
|
186
|
+
internal_credit_feature_id: string | null;
|
|
187
|
+
internal_metered_feature_id: string;
|
|
188
|
+
dimension: string;
|
|
189
|
+
counterKey: string;
|
|
190
|
+
cycleStart: string;
|
|
191
|
+
unitCost: string;
|
|
192
|
+
units: string;
|
|
193
|
+
amount: string;
|
|
194
|
+
tier: number | null;
|
|
195
|
+
}[];
|
|
196
|
+
} | {
|
|
197
|
+
funding: "balance";
|
|
198
|
+
sourceId: string;
|
|
199
|
+
rolloverId: string | null;
|
|
200
|
+
units: string;
|
|
201
|
+
amount: string;
|
|
202
|
+
} | {
|
|
203
|
+
funding: "unbilled";
|
|
204
|
+
units: string;
|
|
205
|
+
} | {
|
|
206
|
+
funding: "postpaid";
|
|
207
|
+
invoiceLineId: string | null;
|
|
208
|
+
units: string;
|
|
209
|
+
authorizationId: string;
|
|
210
|
+
})[];
|
|
211
|
+
requestedQuantity?: string | undefined;
|
|
212
|
+
overageBehavior?: "cap" | "overflow" | undefined;
|
|
213
|
+
};
|
|
214
|
+
}>;
|
|
215
|
+
}>;
|
|
216
|
+
|
|
217
|
+
type AiUsageContext = {
|
|
218
|
+
customerId: string;
|
|
219
|
+
internal_feature_id: string;
|
|
220
|
+
entityId?: string;
|
|
221
|
+
idempotencyKey: string;
|
|
222
|
+
properties?: Record<string, string>;
|
|
223
|
+
};
|
|
224
|
+
type AiUsageRecord = {
|
|
225
|
+
context: AiUsageContext;
|
|
226
|
+
modelId: string;
|
|
227
|
+
usage: LanguageModelV4Usage | null;
|
|
228
|
+
tokens: AiTokenUsage | null;
|
|
229
|
+
quote: AiTokenQuote | null;
|
|
230
|
+
receipt: Awaited<ReturnType<FoundationApi["mutateBalance"]>> | null;
|
|
231
|
+
phase: "captured" | "quoted" | "settled" | "incomplete";
|
|
232
|
+
};
|
|
233
|
+
type AiUsageMiddlewareOptions = {
|
|
234
|
+
pricing: ReturnType<typeof createAiPricing>;
|
|
235
|
+
client: Pick<FoundationApi, "mutateBalance">;
|
|
236
|
+
modelId: string;
|
|
237
|
+
/** Allocate a durable, unique ID per provider call, including each tool step. */
|
|
238
|
+
context: () => AiUsageContext | Promise<AiUsageContext>;
|
|
239
|
+
/** Save raw usage before pricing, and the frozen quote before a balance request. */
|
|
240
|
+
persist: (record: AiUsageRecord) => Promise<void>;
|
|
241
|
+
reasoning: "output" | "separate";
|
|
242
|
+
mapTokens?: (usage: LanguageModelV4Usage) => AiTokenUsage;
|
|
243
|
+
};
|
|
244
|
+
/** Current AI SDK v7 / LanguageModelV4 only. Never suppress a failed financial settlement. */
|
|
245
|
+
declare function createAiUsageMiddleware(options: AiUsageMiddlewareOptions): LanguageModelV4Middleware;
|
|
246
|
+
|
|
247
|
+
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 };
|