ccusage 16.2.4 → 17.0.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/README.md +20 -35
- package/config-schema.json +0 -33
- package/dist/_types-CV6z8-9_.js +583 -0
- package/dist/{calculate-cost-BDqO4yWA.js → calculate-cost-CX9KwEZt.js} +1 -1
- package/dist/calculate-cost.d.ts +1 -4
- package/dist/calculate-cost.js +2 -3
- package/dist/data-loader-DQtk3Va0.js +3733 -0
- package/dist/data-loader-D_hlygEz.d.ts +2307 -0
- package/dist/data-loader.d.ts +1 -2
- package/dist/data-loader.js +3 -5
- package/dist/debug-Bn_uiKiR.js +148 -0
- package/dist/debug.d.ts +8 -0
- package/dist/debug.js +4 -6
- package/dist/index.d.ts +0 -0
- package/dist/index.js +2839 -2061
- package/dist/{logger-Df86rWXR.js → logger-1M8m84B7.js} +179 -74
- package/dist/logger.d.ts +11 -7
- package/dist/logger.js +1 -1
- package/dist/{prompt-DsUFNEY7.js → prompt-BeRmYuGP.js} +49 -28
- package/package.json +4 -4
- package/dist/_token-utils-WjkbrjKv.js +0 -5
- package/dist/_types-DIdtMJ6V.js +0 -3076
- package/dist/data-loader-D1FVB4Lp.d.ts +0 -785
- package/dist/data-loader-DV25VhPk.js +0 -2681
- package/dist/debug-CWd5mOJK.js +0 -109
- package/dist/mcp-CEW0jW3t.js +0 -6832
- package/dist/mcp.d.ts +0 -35
- package/dist/mcp.js +0 -8
- package/dist/pricing-fetcher-COuXYEih.js +0 -402
- package/dist/pricing-fetcher-DK8lcI1w.d.ts +0 -219
- package/dist/pricing-fetcher.d.ts +0 -2
- package/dist/pricing-fetcher.js +0 -4
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
function getTotalTokens(tokenCounts) {
|
|
2
|
+
const cacheCreation = "cacheCreationInputTokens" in tokenCounts ? tokenCounts.cacheCreationInputTokens : tokenCounts.cacheCreationTokens;
|
|
3
|
+
const cacheRead = "cacheReadInputTokens" in tokenCounts ? tokenCounts.cacheReadInputTokens : tokenCounts.cacheReadTokens;
|
|
4
|
+
return tokenCounts.inputTokens + tokenCounts.outputTokens + cacheCreation + cacheRead;
|
|
5
|
+
}
|
|
6
|
+
var store;
|
|
7
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
8
|
+
function getGlobalConfig(config2) {
|
|
9
|
+
return {
|
|
10
|
+
lang: config2?.lang ?? store?.lang,
|
|
11
|
+
message: config2?.message,
|
|
12
|
+
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
13
|
+
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
var store2;
|
|
17
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
18
|
+
function getGlobalMessage(lang) {
|
|
19
|
+
return store2?.get(lang);
|
|
20
|
+
}
|
|
21
|
+
var store3;
|
|
22
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
23
|
+
function getSchemaMessage(lang) {
|
|
24
|
+
return store3?.get(lang);
|
|
25
|
+
}
|
|
26
|
+
var store4;
|
|
27
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
28
|
+
function getSpecificMessage(reference, lang) {
|
|
29
|
+
return store4?.get(reference)?.get(lang);
|
|
30
|
+
}
|
|
31
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
32
|
+
function _stringify(input) {
|
|
33
|
+
const type = typeof input;
|
|
34
|
+
if (type === "string") return `"${input}"`;
|
|
35
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
36
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
37
|
+
return type;
|
|
38
|
+
}
|
|
39
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
40
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
41
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
42
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
43
|
+
const issue = {
|
|
44
|
+
kind: context.kind,
|
|
45
|
+
type: context.type,
|
|
46
|
+
input,
|
|
47
|
+
expected,
|
|
48
|
+
received,
|
|
49
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
50
|
+
requirement: context.requirement,
|
|
51
|
+
path: other?.path,
|
|
52
|
+
issues: other?.issues,
|
|
53
|
+
lang: config2.lang,
|
|
54
|
+
abortEarly: config2.abortEarly,
|
|
55
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
56
|
+
};
|
|
57
|
+
const isSchema = context.kind === "schema";
|
|
58
|
+
const message2 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
59
|
+
if (message2 !== void 0) issue.message = typeof message2 === "function" ? message2(issue) : message2;
|
|
60
|
+
if (isSchema) dataset.typed = false;
|
|
61
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
62
|
+
else dataset.issues = [issue];
|
|
63
|
+
}
|
|
64
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
65
|
+
function _getStandardProps(context) {
|
|
66
|
+
return {
|
|
67
|
+
version: 1,
|
|
68
|
+
vendor: "valibot",
|
|
69
|
+
validate(value2) {
|
|
70
|
+
return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
75
|
+
function _joinExpects(values2, separator) {
|
|
76
|
+
const list = [...new Set(values2)];
|
|
77
|
+
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
78
|
+
return list[0] ?? "never";
|
|
79
|
+
}
|
|
80
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
81
|
+
function getDotPath(issue) {
|
|
82
|
+
if (issue.path) {
|
|
83
|
+
let key = "";
|
|
84
|
+
for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
|
|
85
|
+
else key += item.key;
|
|
86
|
+
else return null;
|
|
87
|
+
return key;
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
var ValiError = class extends Error {
|
|
92
|
+
constructor(issues) {
|
|
93
|
+
super(issues[0].message);
|
|
94
|
+
this.name = "ValiError";
|
|
95
|
+
this.issues = issues;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
99
|
+
function brand(name) {
|
|
100
|
+
return {
|
|
101
|
+
kind: "transformation",
|
|
102
|
+
type: "brand",
|
|
103
|
+
reference: brand,
|
|
104
|
+
async: false,
|
|
105
|
+
name,
|
|
106
|
+
"~run"(dataset) {
|
|
107
|
+
return dataset;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
112
|
+
function check(requirement, message2) {
|
|
113
|
+
return {
|
|
114
|
+
kind: "validation",
|
|
115
|
+
type: "check",
|
|
116
|
+
reference: check,
|
|
117
|
+
async: false,
|
|
118
|
+
expects: null,
|
|
119
|
+
requirement,
|
|
120
|
+
message: message2,
|
|
121
|
+
"~run"(dataset, config2) {
|
|
122
|
+
if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config2);
|
|
123
|
+
return dataset;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
128
|
+
function integer(message2) {
|
|
129
|
+
return {
|
|
130
|
+
kind: "validation",
|
|
131
|
+
type: "integer",
|
|
132
|
+
reference: integer,
|
|
133
|
+
async: false,
|
|
134
|
+
expects: null,
|
|
135
|
+
requirement: Number.isInteger,
|
|
136
|
+
message: message2,
|
|
137
|
+
"~run"(dataset, config2) {
|
|
138
|
+
if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config2);
|
|
139
|
+
return dataset;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
144
|
+
function maxValue(requirement, message2) {
|
|
145
|
+
return {
|
|
146
|
+
kind: "validation",
|
|
147
|
+
type: "max_value",
|
|
148
|
+
reference: maxValue,
|
|
149
|
+
async: false,
|
|
150
|
+
expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
|
|
151
|
+
requirement,
|
|
152
|
+
message: message2,
|
|
153
|
+
"~run"(dataset, config2) {
|
|
154
|
+
if (dataset.typed && !(dataset.value <= this.requirement)) _addIssue(this, "value", dataset, config2, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
|
|
155
|
+
return dataset;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
160
|
+
function minLength(requirement, message2) {
|
|
161
|
+
return {
|
|
162
|
+
kind: "validation",
|
|
163
|
+
type: "min_length",
|
|
164
|
+
reference: minLength,
|
|
165
|
+
async: false,
|
|
166
|
+
expects: `>=${requirement}`,
|
|
167
|
+
requirement,
|
|
168
|
+
message: message2,
|
|
169
|
+
"~run"(dataset, config2) {
|
|
170
|
+
if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config2, { received: `${dataset.value.length}` });
|
|
171
|
+
return dataset;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
176
|
+
function minValue(requirement, message2) {
|
|
177
|
+
return {
|
|
178
|
+
kind: "validation",
|
|
179
|
+
type: "min_value",
|
|
180
|
+
reference: minValue,
|
|
181
|
+
async: false,
|
|
182
|
+
expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
|
|
183
|
+
requirement,
|
|
184
|
+
message: message2,
|
|
185
|
+
"~run"(dataset, config2) {
|
|
186
|
+
if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config2, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
|
|
187
|
+
return dataset;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
192
|
+
function regex(requirement, message2) {
|
|
193
|
+
return {
|
|
194
|
+
kind: "validation",
|
|
195
|
+
type: "regex",
|
|
196
|
+
reference: regex,
|
|
197
|
+
async: false,
|
|
198
|
+
expects: `${requirement}`,
|
|
199
|
+
requirement,
|
|
200
|
+
message: message2,
|
|
201
|
+
"~run"(dataset, config2) {
|
|
202
|
+
if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config2);
|
|
203
|
+
return dataset;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
208
|
+
function transform(operation) {
|
|
209
|
+
return {
|
|
210
|
+
kind: "transformation",
|
|
211
|
+
type: "transform",
|
|
212
|
+
reference: transform,
|
|
213
|
+
async: false,
|
|
214
|
+
operation,
|
|
215
|
+
"~run"(dataset) {
|
|
216
|
+
dataset.value = this.operation(dataset.value);
|
|
217
|
+
return dataset;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
222
|
+
function trim() {
|
|
223
|
+
return {
|
|
224
|
+
kind: "transformation",
|
|
225
|
+
type: "trim",
|
|
226
|
+
reference: trim,
|
|
227
|
+
async: false,
|
|
228
|
+
"~run"(dataset) {
|
|
229
|
+
dataset.value = dataset.value.trim();
|
|
230
|
+
return dataset;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
235
|
+
function getFallback(schema, dataset, config2) {
|
|
236
|
+
return typeof schema.fallback === "function" ? schema.fallback(dataset, config2) : schema.fallback;
|
|
237
|
+
}
|
|
238
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
239
|
+
function flatten(issues) {
|
|
240
|
+
const flatErrors = {};
|
|
241
|
+
for (const issue of issues) if (issue.path) {
|
|
242
|
+
const dotPath = /* @__PURE__ */ getDotPath(issue);
|
|
243
|
+
if (dotPath) {
|
|
244
|
+
if (!flatErrors.nested) flatErrors.nested = {};
|
|
245
|
+
if (flatErrors.nested[dotPath]) flatErrors.nested[dotPath].push(issue.message);
|
|
246
|
+
else flatErrors.nested[dotPath] = [issue.message];
|
|
247
|
+
} else if (flatErrors.other) flatErrors.other.push(issue.message);
|
|
248
|
+
else flatErrors.other = [issue.message];
|
|
249
|
+
} else if (flatErrors.root) flatErrors.root.push(issue.message);
|
|
250
|
+
else flatErrors.root = [issue.message];
|
|
251
|
+
return flatErrors;
|
|
252
|
+
}
|
|
253
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
254
|
+
function getDefault(schema, dataset, config2) {
|
|
255
|
+
return typeof schema.default === "function" ? schema.default(dataset, config2) : schema.default;
|
|
256
|
+
}
|
|
257
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
258
|
+
function array(item, message2) {
|
|
259
|
+
return {
|
|
260
|
+
kind: "schema",
|
|
261
|
+
type: "array",
|
|
262
|
+
reference: array,
|
|
263
|
+
expects: "Array",
|
|
264
|
+
async: false,
|
|
265
|
+
item,
|
|
266
|
+
message: message2,
|
|
267
|
+
get "~standard"() {
|
|
268
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
269
|
+
},
|
|
270
|
+
"~run"(dataset, config2) {
|
|
271
|
+
const input = dataset.value;
|
|
272
|
+
if (Array.isArray(input)) {
|
|
273
|
+
dataset.typed = true;
|
|
274
|
+
dataset.value = [];
|
|
275
|
+
for (let key = 0; key < input.length; key++) {
|
|
276
|
+
const value2 = input[key];
|
|
277
|
+
const itemDataset = this.item["~run"]({ value: value2 }, config2);
|
|
278
|
+
if (itemDataset.issues) {
|
|
279
|
+
const pathItem = {
|
|
280
|
+
type: "array",
|
|
281
|
+
origin: "value",
|
|
282
|
+
input,
|
|
283
|
+
key,
|
|
284
|
+
value: value2
|
|
285
|
+
};
|
|
286
|
+
for (const issue of itemDataset.issues) {
|
|
287
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
288
|
+
else issue.path = [pathItem];
|
|
289
|
+
dataset.issues?.push(issue);
|
|
290
|
+
}
|
|
291
|
+
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
292
|
+
if (config2.abortEarly) {
|
|
293
|
+
dataset.typed = false;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (!itemDataset.typed) dataset.typed = false;
|
|
298
|
+
dataset.value.push(itemDataset.value);
|
|
299
|
+
}
|
|
300
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
301
|
+
return dataset;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
306
|
+
function boolean(message2) {
|
|
307
|
+
return {
|
|
308
|
+
kind: "schema",
|
|
309
|
+
type: "boolean",
|
|
310
|
+
reference: boolean,
|
|
311
|
+
expects: "boolean",
|
|
312
|
+
async: false,
|
|
313
|
+
message: message2,
|
|
314
|
+
get "~standard"() {
|
|
315
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
316
|
+
},
|
|
317
|
+
"~run"(dataset, config2) {
|
|
318
|
+
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
319
|
+
else _addIssue(this, "type", dataset, config2);
|
|
320
|
+
return dataset;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
325
|
+
function number(message2) {
|
|
326
|
+
return {
|
|
327
|
+
kind: "schema",
|
|
328
|
+
type: "number",
|
|
329
|
+
reference: number,
|
|
330
|
+
expects: "number",
|
|
331
|
+
async: false,
|
|
332
|
+
message: message2,
|
|
333
|
+
get "~standard"() {
|
|
334
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
335
|
+
},
|
|
336
|
+
"~run"(dataset, config2) {
|
|
337
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
338
|
+
else _addIssue(this, "type", dataset, config2);
|
|
339
|
+
return dataset;
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
344
|
+
function object(entries2, message2) {
|
|
345
|
+
return {
|
|
346
|
+
kind: "schema",
|
|
347
|
+
type: "object",
|
|
348
|
+
reference: object,
|
|
349
|
+
expects: "Object",
|
|
350
|
+
async: false,
|
|
351
|
+
entries: entries2,
|
|
352
|
+
message: message2,
|
|
353
|
+
get "~standard"() {
|
|
354
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
355
|
+
},
|
|
356
|
+
"~run"(dataset, config2) {
|
|
357
|
+
const input = dataset.value;
|
|
358
|
+
if (input && typeof input === "object") {
|
|
359
|
+
dataset.typed = true;
|
|
360
|
+
dataset.value = {};
|
|
361
|
+
for (const key in this.entries) {
|
|
362
|
+
const valueSchema = this.entries[key];
|
|
363
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
364
|
+
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
365
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
366
|
+
if (valueDataset.issues) {
|
|
367
|
+
const pathItem = {
|
|
368
|
+
type: "object",
|
|
369
|
+
origin: "value",
|
|
370
|
+
input,
|
|
371
|
+
key,
|
|
372
|
+
value: value2
|
|
373
|
+
};
|
|
374
|
+
for (const issue of valueDataset.issues) {
|
|
375
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
376
|
+
else issue.path = [pathItem];
|
|
377
|
+
dataset.issues?.push(issue);
|
|
378
|
+
}
|
|
379
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
380
|
+
if (config2.abortEarly) {
|
|
381
|
+
dataset.typed = false;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
386
|
+
dataset.value[key] = valueDataset.value;
|
|
387
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
388
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
389
|
+
_addIssue(this, "key", dataset, config2, {
|
|
390
|
+
input: void 0,
|
|
391
|
+
expected: `"${key}"`,
|
|
392
|
+
path: [{
|
|
393
|
+
type: "object",
|
|
394
|
+
origin: "key",
|
|
395
|
+
input,
|
|
396
|
+
key,
|
|
397
|
+
value: input[key]
|
|
398
|
+
}]
|
|
399
|
+
});
|
|
400
|
+
if (config2.abortEarly) break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
404
|
+
return dataset;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
409
|
+
function optional(wrapped, default_) {
|
|
410
|
+
return {
|
|
411
|
+
kind: "schema",
|
|
412
|
+
type: "optional",
|
|
413
|
+
reference: optional,
|
|
414
|
+
expects: `(${wrapped.expects} | undefined)`,
|
|
415
|
+
async: false,
|
|
416
|
+
wrapped,
|
|
417
|
+
default: default_,
|
|
418
|
+
get "~standard"() {
|
|
419
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
420
|
+
},
|
|
421
|
+
"~run"(dataset, config2) {
|
|
422
|
+
if (dataset.value === void 0) {
|
|
423
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
424
|
+
if (dataset.value === void 0) {
|
|
425
|
+
dataset.typed = true;
|
|
426
|
+
return dataset;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return this.wrapped["~run"](dataset, config2);
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
434
|
+
function string(message2) {
|
|
435
|
+
return {
|
|
436
|
+
kind: "schema",
|
|
437
|
+
type: "string",
|
|
438
|
+
reference: string,
|
|
439
|
+
expects: "string",
|
|
440
|
+
async: false,
|
|
441
|
+
message: message2,
|
|
442
|
+
get "~standard"() {
|
|
443
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
444
|
+
},
|
|
445
|
+
"~run"(dataset, config2) {
|
|
446
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
447
|
+
else _addIssue(this, "type", dataset, config2);
|
|
448
|
+
return dataset;
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
453
|
+
function _subIssues(datasets) {
|
|
454
|
+
let issues;
|
|
455
|
+
if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
|
|
456
|
+
else issues = dataset.issues;
|
|
457
|
+
return issues;
|
|
458
|
+
}
|
|
459
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
460
|
+
function union(options, message2) {
|
|
461
|
+
return {
|
|
462
|
+
kind: "schema",
|
|
463
|
+
type: "union",
|
|
464
|
+
reference: union,
|
|
465
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
466
|
+
async: false,
|
|
467
|
+
options,
|
|
468
|
+
message: message2,
|
|
469
|
+
get "~standard"() {
|
|
470
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
471
|
+
},
|
|
472
|
+
"~run"(dataset, config2) {
|
|
473
|
+
let validDataset;
|
|
474
|
+
let typedDatasets;
|
|
475
|
+
let untypedDatasets;
|
|
476
|
+
for (const schema of this.options) {
|
|
477
|
+
const optionDataset = schema["~run"]({ value: dataset.value }, config2);
|
|
478
|
+
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
479
|
+
else typedDatasets = [optionDataset];
|
|
480
|
+
else {
|
|
481
|
+
validDataset = optionDataset;
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
485
|
+
else untypedDatasets = [optionDataset];
|
|
486
|
+
}
|
|
487
|
+
if (validDataset) return validDataset;
|
|
488
|
+
if (typedDatasets) {
|
|
489
|
+
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
490
|
+
_addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
491
|
+
dataset.typed = true;
|
|
492
|
+
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
493
|
+
else _addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
494
|
+
return dataset;
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function parse(schema, input, config2) {
|
|
499
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
500
|
+
if (dataset.issues) throw new ValiError(dataset.issues);
|
|
501
|
+
return dataset.value;
|
|
502
|
+
}
|
|
503
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
504
|
+
function pipe(...pipe2) {
|
|
505
|
+
return {
|
|
506
|
+
...pipe2[0],
|
|
507
|
+
pipe: pipe2,
|
|
508
|
+
get "~standard"() {
|
|
509
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
510
|
+
},
|
|
511
|
+
"~run"(dataset, config2) {
|
|
512
|
+
for (const item of pipe2) if (item.kind !== "metadata") {
|
|
513
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
514
|
+
dataset.typed = false;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) dataset = item["~run"](dataset, config2);
|
|
518
|
+
}
|
|
519
|
+
return dataset;
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
524
|
+
function safeParse(schema, input, config2) {
|
|
525
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
526
|
+
return {
|
|
527
|
+
typed: dataset.typed,
|
|
528
|
+
success: !dataset.issues,
|
|
529
|
+
output: dataset.value,
|
|
530
|
+
issues: dataset.issues
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
const modelNameSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1, "Model name cannot be empty"), /* @__PURE__ */ brand("ModelName"));
|
|
534
|
+
const sessionIdSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1, "Session ID cannot be empty"), /* @__PURE__ */ brand("SessionId"));
|
|
535
|
+
const requestIdSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1, "Request ID cannot be empty"), /* @__PURE__ */ brand("RequestId"));
|
|
536
|
+
const messageIdSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1, "Message ID cannot be empty"), /* @__PURE__ */ brand("MessageId"));
|
|
537
|
+
const isoTimestampSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/, "Invalid ISO timestamp"), /* @__PURE__ */ brand("ISOTimestamp"));
|
|
538
|
+
const yyyymmddRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
539
|
+
const dailyDateSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ regex(yyyymmddRegex, "Date must be in YYYY-MM-DD format"), /* @__PURE__ */ brand("DailyDate"));
|
|
540
|
+
const activityDateSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ regex(yyyymmddRegex, "Date must be in YYYY-MM-DD format"), /* @__PURE__ */ brand("ActivityDate"));
|
|
541
|
+
const monthlyDateSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ regex(/^\d{4}-\d{2}$/, "Date must be in YYYY-MM format"), /* @__PURE__ */ brand("MonthlyDate"));
|
|
542
|
+
const weeklyDateSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ regex(yyyymmddRegex, "Date must be in YYYY-MM-DD format"), /* @__PURE__ */ brand("WeeklyDate"));
|
|
543
|
+
const filterDateSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ regex(/^\d{8}$/, "Date must be in YYYYMMDD format"), /* @__PURE__ */ brand("FilterDate"));
|
|
544
|
+
const projectPathSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1, "Project path cannot be empty"), /* @__PURE__ */ brand("ProjectPath"));
|
|
545
|
+
const versionSchema = /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ regex(/^\d+\.\d+\.\d+/, "Invalid version format"), /* @__PURE__ */ brand("Version"));
|
|
546
|
+
const createSessionId = (value) => parse(sessionIdSchema, value);
|
|
547
|
+
const createDailyDate = (value) => parse(dailyDateSchema, value);
|
|
548
|
+
const createMonthlyDate = (value) => parse(monthlyDateSchema, value);
|
|
549
|
+
const createWeeklyDate = (value) => parse(weeklyDateSchema, value);
|
|
550
|
+
const createProjectPath = (value) => parse(projectPathSchema, value);
|
|
551
|
+
function createBucket(value) {
|
|
552
|
+
const weeklyResult = /* @__PURE__ */ safeParse(weeklyDateSchema, value);
|
|
553
|
+
if (weeklyResult.success) return weeklyResult.output;
|
|
554
|
+
return createMonthlyDate(value);
|
|
555
|
+
}
|
|
556
|
+
const CostModes = [
|
|
557
|
+
"auto",
|
|
558
|
+
"calculate",
|
|
559
|
+
"display"
|
|
560
|
+
];
|
|
561
|
+
const SortOrders = ["desc", "asc"];
|
|
562
|
+
const statuslineHookJsonSchema = /* @__PURE__ */ object({
|
|
563
|
+
session_id: /* @__PURE__ */ string(),
|
|
564
|
+
transcript_path: /* @__PURE__ */ string(),
|
|
565
|
+
cwd: /* @__PURE__ */ string(),
|
|
566
|
+
model: /* @__PURE__ */ object({
|
|
567
|
+
id: /* @__PURE__ */ string(),
|
|
568
|
+
display_name: /* @__PURE__ */ string()
|
|
569
|
+
}),
|
|
570
|
+
workspace: /* @__PURE__ */ object({
|
|
571
|
+
current_dir: /* @__PURE__ */ string(),
|
|
572
|
+
project_dir: /* @__PURE__ */ string()
|
|
573
|
+
}),
|
|
574
|
+
version: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
|
|
575
|
+
cost: /* @__PURE__ */ optional(/* @__PURE__ */ object({
|
|
576
|
+
total_cost_usd: /* @__PURE__ */ number(),
|
|
577
|
+
total_duration_ms: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
|
|
578
|
+
total_api_duration_ms: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
|
|
579
|
+
total_lines_added: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
|
|
580
|
+
total_lines_removed: /* @__PURE__ */ optional(/* @__PURE__ */ number())
|
|
581
|
+
}))
|
|
582
|
+
});
|
|
583
|
+
export { CostModes, SortOrders, activityDateSchema, array, boolean, check, createBucket, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, createWeeklyDate, dailyDateSchema, filterDateSchema, flatten, getTotalTokens, integer, isoTimestampSchema, maxValue, messageIdSchema, minValue, modelNameSchema, monthlyDateSchema, number, object, optional, parse, pipe, projectPathSchema, requestIdSchema, safeParse, sessionIdSchema, statuslineHookJsonSchema, string, transform, trim, union, versionSchema, weeklyDateSchema };
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { DailyUsage, MonthlyUsage, SessionUsage, WeeklyUsage } from "./data-loader-
|
|
2
|
-
import "./pricing-fetcher-DK8lcI1w.js";
|
|
1
|
+
import { DailyUsage, MonthlyUsage, SessionUsage, WeeklyUsage } from "./data-loader-D_hlygEz.js";
|
|
3
2
|
|
|
4
3
|
//#region src/_token-utils.d.ts
|
|
5
4
|
|
|
@@ -64,8 +63,6 @@ type TotalsObject = TokenTotals & {
|
|
|
64
63
|
* @returns Aggregated token totals and cost
|
|
65
64
|
*/
|
|
66
65
|
declare function calculateTotals(data: Array<DailyUsage | MonthlyUsage | WeeklyUsage | SessionUsage>): TokenTotals;
|
|
67
|
-
// Re-export getTotalTokens from shared utilities for backward compatibility
|
|
68
|
-
|
|
69
66
|
/**
|
|
70
67
|
* Creates a complete totals object by adding total token count to existing totals
|
|
71
68
|
* @param totals - Token totals with cost information
|
package/dist/calculate-cost.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getTotalTokens } from "./
|
|
2
|
-
import "./
|
|
3
|
-
import { calculateTotals, createTotalsObject } from "./calculate-cost-BDqO4yWA.js";
|
|
1
|
+
import { getTotalTokens } from "./_types-CV6z8-9_.js";
|
|
2
|
+
import { calculateTotals, createTotalsObject } from "./calculate-cost-CX9KwEZt.js";
|
|
4
3
|
export { calculateTotals, createTotalsObject, getTotalTokens };
|