@agent-native/core 0.94.3 → 0.95.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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +6 -0
- package/corpus/core/docs/content/pr-visual-recap.mdx +20 -12
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/engine/ai-sdk-engine.ts +3 -0
- package/corpus/core/src/agent/engine/registry.ts +6 -1
- package/corpus/core/src/agent/engine/types.ts +2 -0
- package/corpus/core/src/cli/code-agent-executor.ts +61 -1
- package/corpus/core/src/cli/pr-visual-recap-workflow.ts +1 -1
- package/corpus/core/src/cli/recap.ts +262 -25
- package/corpus/core/src/client/settings/UsageSection.tsx +26 -5
- package/corpus/core/src/index.ts +2 -0
- package/corpus/core/src/usage/store.ts +82 -20
- package/corpus/templates/plan/actions/record-recap-usage-cost.ts +49 -0
- package/corpus/templates/plan/actions/record-recap-usage.ts +15 -22
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +3 -0
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/registry.d.ts +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +2 -0
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/engine/types.d.ts +2 -0
- package/dist/agent/engine/types.d.ts.map +1 -1
- package/dist/agent/engine/types.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts +2 -0
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +52 -3
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.js +1 -1
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/cli/recap.d.ts +22 -2
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +199 -22
- package/dist/cli/recap.js.map +1 -1
- package/dist/client/settings/UsageSection.d.ts.map +1 -1
- package/dist/client/settings/UsageSection.js +12 -3
- package/dist/client/settings/UsageSection.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/usage/store.d.ts +21 -0
- package/dist/usage/store.d.ts.map +1 -1
- package/dist/usage/store.js +54 -19
- package/dist/usage/store.js.map +1 -1
- package/docs/content/pr-visual-recap.mdx +20 -12
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsageSection.d.ts","sourceRoot":"","sources":["../../../src/client/settings/UsageSection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UsageSection.d.ts","sourceRoot":"","sources":["../../../src/client/settings/UsageSection.tsx"],"names":[],"mappings":"AAkNA,wBAAgB,YAAY,gCA8L3B"}
|
|
@@ -44,6 +44,13 @@ function formatSpend(cents, billing) {
|
|
|
44
44
|
return `${cents.toFixed(2)}¢`;
|
|
45
45
|
return `$${(cents / 100).toFixed(2)}`;
|
|
46
46
|
}
|
|
47
|
+
function formatAggregateCost(cost, billing) {
|
|
48
|
+
if (cost.status === "known")
|
|
49
|
+
return formatSpend(cost.knownCents, billing);
|
|
50
|
+
if (cost.status === "unavailable")
|
|
51
|
+
return "Unknown";
|
|
52
|
+
return `${formatSpend(cost.knownCents, billing)} + ${cost.unavailableCalls} unpriced`;
|
|
53
|
+
}
|
|
47
54
|
function formatTokens(n) {
|
|
48
55
|
if (n >= 1_000_000)
|
|
49
56
|
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
@@ -56,7 +63,7 @@ function BucketBars({ buckets, emptyMessage, billing, }) {
|
|
|
56
63
|
return (_jsx("p", { className: "text-[10px] text-muted-foreground py-1.5", children: emptyMessage }));
|
|
57
64
|
}
|
|
58
65
|
const max = Math.max(...buckets.map((b) => displayAmountFromCostCents(b.cents, billing)), 0.0001);
|
|
59
|
-
return (_jsx("div", { className: "space-y-1", children: buckets.map((b) => (_jsxs("div", { className: "text-[10px]", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 mb-0.5", children: [_jsx("span", { className: "truncate text-foreground", title: b.key || "(none)", children: b.key || "(none)" }), _jsxs("span", { className: "shrink-0 text-muted-foreground tabular-nums", children: [
|
|
66
|
+
return (_jsx("div", { className: "space-y-1", children: buckets.map((b) => (_jsxs("div", { className: "text-[10px]", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 mb-0.5", children: [_jsx("span", { className: "truncate text-foreground", title: b.key || "(none)", children: b.key || "(none)" }), _jsxs("span", { className: "shrink-0 text-muted-foreground tabular-nums", children: [formatAggregateCost(b.cost, billing), _jsxs("span", { className: "ms-1 opacity-60", children: ["\u00B7 ", formatTokens(b.inputTokens + b.outputTokens), " tok"] })] })] }), _jsx("div", { className: "h-1 rounded-full bg-accent/40 overflow-hidden", children: _jsx("div", { className: "h-full bg-foreground/70", style: {
|
|
60
67
|
width: `${(displayAmountFromCostCents(b.cents, billing) / max) * 100}%`,
|
|
61
68
|
} }) })] }, b.key))) }));
|
|
62
69
|
}
|
|
@@ -66,7 +73,7 @@ function DailySparkline({ days, billing, }) {
|
|
|
66
73
|
const max = Math.max(...days.map((d) => displayAmountFromCostCents(d.cents, billing)), 0.0001);
|
|
67
74
|
return (_jsx("div", { className: "flex items-end gap-[2px] h-8 pt-2", children: days.map((d) => (_jsx("div", { className: "flex-1 bg-foreground/60 rounded-sm min-h-[1px]", style: {
|
|
68
75
|
height: `${Math.max(2, (displayAmountFromCostCents(d.cents, billing) / max) * 100)}%`,
|
|
69
|
-
}, title: `${d.date}: ${
|
|
76
|
+
}, title: `${d.date}: ${formatAggregateCost(d.cost, billing)} (${d.calls} calls)` }, d.date))) }));
|
|
70
77
|
}
|
|
71
78
|
export function UsageSection() {
|
|
72
79
|
const [days, setDays] = useState(30);
|
|
@@ -99,6 +106,8 @@ export function UsageSection() {
|
|
|
99
106
|
? "bg-accent text-foreground"
|
|
100
107
|
: "text-muted-foreground hover:text-foreground"}`, children: r.label }, r.value))) }), _jsx("button", { onClick: () => load(days), className: "flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground", disabled: loading, children: loading ? (_jsx(IconLoader2, { size: 11, className: "animate-spin" })) : (_jsx(IconRefresh, { size: 11 })) })] }), error && _jsx("p", { className: "text-[10px] text-red-500", children: error }), data && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "rounded-md border border-border px-2.5 py-2", children: [_jsxs("div", { className: "flex items-baseline justify-between", children: [_jsxs("div", { children: [_jsx("div", { className: "text-[10px] text-muted-foreground", children: billing.unit === "builder-credits"
|
|
101
108
|
? "Builder.io credit spend"
|
|
102
|
-
: "Total spend" }), _jsx("div", { className: "text-[18px] font-semibold tabular-nums", children:
|
|
109
|
+
: "Total spend" }), _jsx("div", { className: "text-[18px] font-semibold tabular-nums", children: formatAggregateCost(data.totalCost, billing) })] }), _jsxs("div", { className: "text-end", children: [_jsxs("div", { className: "text-[10px] text-muted-foreground", children: [data.totalCalls, " calls"] }), _jsxs("div", { className: "text-[10px] text-muted-foreground", children: [formatTokens(data.totalInputTokens), " in \u00B7", " ", formatTokens(data.totalOutputTokens), " out"] }), data.totalCacheReadTokens > 0 && (_jsxs("div", { className: "text-[10px] text-green-500/80", children: [formatTokens(data.totalCacheReadTokens), " cached"] }))] })] }), _jsx(DailySparkline, { days: data.byDay, billing: billing })] }), _jsxs("div", { children: [_jsx("div", { className: "text-[10px] font-medium text-foreground mb-1", children: "By label" }), _jsx(BucketBars, { buckets: data.byLabel, emptyMessage: "No labeled calls yet.", billing: billing })] }), _jsxs("div", { children: [_jsx("div", { className: "text-[10px] font-medium text-foreground mb-1", children: "By model" }), _jsx(BucketBars, { buckets: data.byModel, emptyMessage: "No calls recorded.", billing: billing })] }), data.byApp.filter((b) => b.key).length > 1 && (_jsxs("div", { children: [_jsx("div", { className: "text-[10px] font-medium text-foreground mb-1", children: "By app" }), _jsx(BucketBars, { buckets: data.byApp, emptyMessage: "", billing: billing })] })), data.recent.length > 0 && (_jsxs("details", { children: [_jsxs("summary", { className: "text-[10px] font-medium text-foreground cursor-pointer select-none hover:text-foreground/80", children: ["Recent calls (", data.recent.length, ")"] }), _jsx("div", { className: "mt-1.5 max-h-48 overflow-y-auto space-y-0.5 rounded border border-border", children: data.recent.map((r) => (_jsxs("div", { className: "flex items-center justify-between gap-2 px-2 py-1 text-[10px] border-b border-border last:border-b-0", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "truncate text-foreground", title: r.label, children: [r.label, r.app ? (_jsxs("span", { className: "text-muted-foreground", children: [" ", "\u00B7 ", r.app] })) : null] }), _jsxs("div", { className: "truncate text-muted-foreground", children: [new Date(r.createdAt).toLocaleString(), " \u00B7 ", r.model] })] }), _jsx("div", { className: "shrink-0 text-end tabular-nums text-muted-foreground", children: r.costSource === "unavailable"
|
|
110
|
+
? "Unknown"
|
|
111
|
+
: formatSpend(r.cents, billing) })] }, r.id))) })] })), billing.unit === "builder-credits" ? (_jsxs("p", { className: "text-[10px] text-muted-foreground", children: ["Builder.io credits are estimated from hard token cost, a", " ", billing.hardCostMarginMultiplier ?? 1.25, "x margin, and", " ", billing.creditsPerUsd ?? 20, " credits per dollar."] })) : (_jsx("p", { className: "text-[10px] text-muted-foreground", children: "Spend is estimated from published Anthropic pricing and your own recorded token counts. Cached input is priced at ~10% of regular input. Calls without provider pricing are marked unknown and excluded from known-cost subtotals." }))] }))] }));
|
|
103
112
|
}
|
|
104
113
|
//# sourceMappingURL=UsageSection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsageSection.js","sourceRoot":"","sources":["../../../src/client/settings/UsageSection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D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C,CAAC,CACpC,aAAG,SAAS,EAAC,mCAAmC,yEACW,GAAG,EAC3D,OAAO,CAAC,wBAAwB,IAAI,IAAI,mBAAe,GAAG,EAC1D,OAAO,CAAC,aAAa,IAAI,EAAE,4BAC1B,CACL,CAAC,CAAC,CAAC,CACF,YAAG,SAAS,EAAC,mCAAmC,yJAI5C,CACL,IACA,CACJ,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { IconLoader2, IconRefresh } from \"@tabler/icons-react\";\nimport { useEffect, useState } from \"react\";\n\nimport { agentNativePath } from \"../api-path.js\";\n\ninterface UsageBucket {\n key: string;\n cents: number;\n calls: number;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n}\n\ninterface DailyBucket {\n date: string;\n cents: number;\n calls: number;\n}\n\ninterface UsageRecentEntry {\n id: number;\n createdAt: number;\n label: string;\n app: string;\n model: string;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n cents: number;\n}\n\ninterface UsageBillingMode {\n unit: \"usd\" | \"builder-credits\";\n label: string;\n shortLabel: string;\n source: \"estimated-provider-cost\" | \"builder-agent-credits\";\n hardCostMarginMultiplier?: number;\n creditsPerUsd?: number;\n}\n\ninterface UsageSummary {\n billing?: UsageBillingMode;\n totalCents: number;\n totalCalls: number;\n totalInputTokens: number;\n totalOutputTokens: number;\n totalCacheReadTokens: number;\n totalCacheWriteTokens: number;\n sinceMs: number;\n byLabel: UsageBucket[];\n byModel: UsageBucket[];\n byApp: UsageBucket[];\n byDay: DailyBucket[];\n recent: UsageRecentEntry[];\n}\n\nconst RANGES = [\n { value: 1, label: \"24h\" },\n { value: 7, label: \"7d\" },\n { value: 30, label: \"30d\" },\n { value: 90, label: \"90d\" },\n];\n\nconst USD_BILLING: UsageBillingMode = {\n unit: \"usd\",\n label: \"Estimated spend\",\n shortLabel: \"Cost\",\n source: \"estimated-provider-cost\",\n};\n\nfunction displayAmountFromCostCents(\n cents: number,\n billing: UsageBillingMode,\n): number {\n if (billing.unit !== \"builder-credits\") return cents;\n const margin = billing.hardCostMarginMultiplier ?? 1.25;\n const creditsPerUsd = billing.creditsPerUsd ?? 20;\n const credits = (cents / 100) * margin * creditsPerUsd;\n return credits <= 0 ? 0 : Math.ceil(credits * 1000) / 1000;\n}\n\nfunction formatCredits(credits: number): string {\n if (!Number.isFinite(credits) || credits === 0) return \"0 credits\";\n const maximumFractionDigits = credits < 1 ? 3 : credits < 10 ? 2 : 1;\n const value = credits.toLocaleString(undefined, {\n maximumFractionDigits,\n });\n return `${value} ${credits === 1 ? \"credit\" : \"credits\"}`;\n}\n\nfunction formatSpend(cents: number, billing: UsageBillingMode): string {\n if (billing.unit === \"builder-credits\") {\n return formatCredits(displayAmountFromCostCents(cents, billing));\n }\n // Sub-cent values (e.g. a single LLM call at $0.0045 = 0.45¢) — keep\n // three decimals so tiny calls don't round to 0.00¢. The prior impl\n // multiplied by 100 in this branch, overstating small costs 100×.\n if (cents < 1) return `${cents.toFixed(3)}¢`;\n if (cents < 100) return `${cents.toFixed(2)}¢`;\n return `$${(cents / 100).toFixed(2)}`;\n}\n\nfunction formatTokens(n: number): string {\n if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;\n if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;\n return String(n);\n}\n\nfunction BucketBars({\n buckets,\n emptyMessage,\n billing,\n}: {\n buckets: UsageBucket[];\n emptyMessage: string;\n billing: UsageBillingMode;\n}) {\n if (buckets.length === 0) {\n return (\n <p className=\"text-[10px] text-muted-foreground py-1.5\">{emptyMessage}</p>\n );\n }\n const max = Math.max(\n ...buckets.map((b) => displayAmountFromCostCents(b.cents, billing)),\n 0.0001,\n );\n return (\n <div className=\"space-y-1\">\n {buckets.map((b) => (\n <div key={b.key} className=\"text-[10px]\">\n <div className=\"flex items-center justify-between gap-2 mb-0.5\">\n <span\n className=\"truncate text-foreground\"\n title={b.key || \"(none)\"}\n >\n {b.key || \"(none)\"}\n </span>\n <span className=\"shrink-0 text-muted-foreground tabular-nums\">\n {formatSpend(b.cents, billing)}\n <span className=\"ms-1 opacity-60\">\n · {formatTokens(b.inputTokens + b.outputTokens)} tok\n </span>\n </span>\n </div>\n <div className=\"h-1 rounded-full bg-accent/40 overflow-hidden\">\n <div\n className=\"h-full bg-foreground/70\"\n style={{\n width: `${(displayAmountFromCostCents(b.cents, billing) / max) * 100}%`,\n }}\n />\n </div>\n </div>\n ))}\n </div>\n );\n}\n\nfunction DailySparkline({\n days,\n billing,\n}: {\n days: DailyBucket[];\n billing: UsageBillingMode;\n}) {\n if (days.length === 0) return null;\n const max = Math.max(\n ...days.map((d) => displayAmountFromCostCents(d.cents, billing)),\n 0.0001,\n );\n return (\n <div className=\"flex items-end gap-[2px] h-8 pt-2\">\n {days.map((d) => (\n <div\n key={d.date}\n className=\"flex-1 bg-foreground/60 rounded-sm min-h-[1px]\"\n style={{\n height: `${Math.max(\n 2,\n (displayAmountFromCostCents(d.cents, billing) / max) * 100,\n )}%`,\n }}\n title={`${d.date}: ${formatSpend(d.cents, billing)} (${d.calls} calls)`}\n />\n ))}\n </div>\n );\n}\n\nexport function UsageSection() {\n const [days, setDays] = useState(30);\n const [data, setData] = useState<UsageSummary | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const billing = data?.billing ?? USD_BILLING;\n\n const load = async (rangeDays: number) => {\n setLoading(true);\n setError(null);\n try {\n const res = await fetch(\n agentNativePath(`/_agent-native/usage?sinceDays=${rangeDays}`),\n );\n if (!res.ok) {\n throw new Error(`Failed (${res.status})`);\n }\n const json = (await res.json()) as UsageSummary;\n setData(json);\n } catch (err: any) {\n setError(err?.message || \"Failed to load usage\");\n } finally {\n setLoading(false);\n }\n };\n\n useEffect(() => {\n load(days);\n }, [days]);\n\n return (\n <div className=\"space-y-3\">\n {/* Range selector + refresh */}\n <div className=\"flex items-center justify-between\">\n <div className=\"flex gap-1 rounded-md border border-border p-0.5\">\n {RANGES.map((r) => (\n <button\n key={r.value}\n onClick={() => setDays(r.value)}\n className={`px-2 py-0.5 text-[10px] rounded ${\n days === r.value\n ? \"bg-accent text-foreground\"\n : \"text-muted-foreground hover:text-foreground\"\n }`}\n >\n {r.label}\n </button>\n ))}\n </div>\n <button\n onClick={() => load(days)}\n className=\"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground\"\n disabled={loading}\n >\n {loading ? (\n <IconLoader2 size={11} className=\"animate-spin\" />\n ) : (\n <IconRefresh size={11} />\n )}\n </button>\n </div>\n\n {error && <p className=\"text-[10px] text-red-500\">{error}</p>}\n\n {data && (\n <>\n {/* Totals */}\n <div className=\"rounded-md border border-border px-2.5 py-2\">\n <div className=\"flex items-baseline justify-between\">\n <div>\n <div className=\"text-[10px] text-muted-foreground\">\n {billing.unit === \"builder-credits\"\n ? \"Builder.io credit spend\"\n : \"Total spend\"}\n </div>\n <div className=\"text-[18px] font-semibold tabular-nums\">\n {formatSpend(data.totalCents, billing)}\n </div>\n </div>\n <div className=\"text-end\">\n <div className=\"text-[10px] text-muted-foreground\">\n {data.totalCalls} calls\n </div>\n <div className=\"text-[10px] text-muted-foreground\">\n {formatTokens(data.totalInputTokens)} in ·{\" \"}\n {formatTokens(data.totalOutputTokens)} out\n </div>\n {data.totalCacheReadTokens > 0 && (\n <div className=\"text-[10px] text-green-500/80\">\n {formatTokens(data.totalCacheReadTokens)} cached\n </div>\n )}\n </div>\n </div>\n <DailySparkline days={data.byDay} billing={billing} />\n </div>\n\n {/* By label */}\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By label\n </div>\n <BucketBars\n buckets={data.byLabel}\n emptyMessage=\"No labeled calls yet.\"\n billing={billing}\n />\n </div>\n\n {/* By model */}\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By model\n </div>\n <BucketBars\n buckets={data.byModel}\n emptyMessage=\"No calls recorded.\"\n billing={billing}\n />\n </div>\n\n {/* By app — only show when multiple apps contribute */}\n {data.byApp.filter((b) => b.key).length > 1 && (\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By app\n </div>\n <BucketBars\n buckets={data.byApp}\n emptyMessage=\"\"\n billing={billing}\n />\n </div>\n )}\n\n {/* Recent calls */}\n {data.recent.length > 0 && (\n <details>\n <summary className=\"text-[10px] font-medium text-foreground cursor-pointer select-none hover:text-foreground/80\">\n Recent calls ({data.recent.length})\n </summary>\n <div className=\"mt-1.5 max-h-48 overflow-y-auto space-y-0.5 rounded border border-border\">\n {data.recent.map((r) => (\n <div\n key={r.id}\n className=\"flex items-center justify-between gap-2 px-2 py-1 text-[10px] border-b border-border last:border-b-0\"\n >\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-foreground\" title={r.label}>\n {r.label}\n {r.app ? (\n <span className=\"text-muted-foreground\">\n {\" \"}\n · {r.app}\n </span>\n ) : null}\n </div>\n <div className=\"truncate text-muted-foreground\">\n {new Date(r.createdAt).toLocaleString()} · {r.model}\n </div>\n </div>\n <div className=\"shrink-0 text-end tabular-nums text-muted-foreground\">\n {formatSpend(r.cents, billing)}\n </div>\n </div>\n ))}\n </div>\n </details>\n )}\n\n {billing.unit === \"builder-credits\" ? (\n <p className=\"text-[10px] text-muted-foreground\">\n Builder.io credits are estimated from hard token cost, a{\" \"}\n {billing.hardCostMarginMultiplier ?? 1.25}x margin, and{\" \"}\n {billing.creditsPerUsd ?? 20} credits per dollar.\n </p>\n ) : (\n <p className=\"text-[10px] text-muted-foreground\">\n Spend is estimated from published Anthropic pricing and your own\n recorded token counts. Cached input is priced at ~10% of regular\n input.\n </p>\n )}\n </>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UsageSection.js","sourceRoot":"","sources":["../../../src/client/settings/UsageSection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,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,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,cAAK,CAAC,CAAC,KAAK,IAC/C,IACF,EACN,cAAK,SAAS,EAAC,sDAAsD,YAClE,CAAC,CAAC,UAAU,KAAK,aAAa;gDAC7B,CAAC,CAAC,SAAS;gDACX,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,GAC7B,KArBD,CAAC,CAAC,EAAE,CAsBL,CACP,CAAC,GACE,IACE,CACX,EAEA,OAAO,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,CACpC,aAAG,SAAS,EAAC,mCAAmC,yEACW,GAAG,EAC3D,OAAO,CAAC,wBAAwB,IAAI,IAAI,mBAAe,GAAG,EAC1D,OAAO,CAAC,aAAa,IAAI,EAAE,4BAC1B,CACL,CAAC,CAAC,CAAC,CACF,YAAG,SAAS,EAAC,mCAAmC,mPAK5C,CACL,IACA,CACJ,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { IconLoader2, IconRefresh } from \"@tabler/icons-react\";\nimport { useEffect, useState } from \"react\";\n\nimport { agentNativePath } from \"../api-path.js\";\n\ninterface UsageBucket {\n key: string;\n cents: number;\n cost: UsageCostAggregate;\n calls: number;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n}\n\ninterface DailyBucket {\n date: string;\n cents: number;\n cost: UsageCostAggregate;\n calls: number;\n}\n\ninterface UsageRecentEntry {\n id: number;\n createdAt: number;\n label: string;\n app: string;\n model: string;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n cents: number;\n costSource: \"reported\" | \"estimated\" | \"unavailable\";\n}\n\ntype UsageCostAggregate =\n | { status: \"known\"; knownCents: number; unavailableCalls: 0 }\n | { status: \"partial\"; knownCents: number; unavailableCalls: number }\n | { status: \"unavailable\"; knownCents: 0; unavailableCalls: number };\n\ninterface UsageBillingMode {\n unit: \"usd\" | \"builder-credits\";\n label: string;\n shortLabel: string;\n source: \"estimated-provider-cost\" | \"builder-agent-credits\";\n hardCostMarginMultiplier?: number;\n creditsPerUsd?: number;\n}\n\ninterface UsageSummary {\n billing?: UsageBillingMode;\n totalCents: number;\n totalCost: UsageCostAggregate;\n totalCalls: number;\n totalInputTokens: number;\n totalOutputTokens: number;\n totalCacheReadTokens: number;\n totalCacheWriteTokens: number;\n sinceMs: number;\n byLabel: UsageBucket[];\n byModel: UsageBucket[];\n byApp: UsageBucket[];\n byDay: DailyBucket[];\n recent: UsageRecentEntry[];\n}\n\nconst RANGES = [\n { value: 1, label: \"24h\" },\n { value: 7, label: \"7d\" },\n { value: 30, label: \"30d\" },\n { value: 90, label: \"90d\" },\n];\n\nconst USD_BILLING: UsageBillingMode = {\n unit: \"usd\",\n label: \"Estimated spend\",\n shortLabel: \"Cost\",\n source: \"estimated-provider-cost\",\n};\n\nfunction displayAmountFromCostCents(\n cents: number,\n billing: UsageBillingMode,\n): number {\n if (billing.unit !== \"builder-credits\") return cents;\n const margin = billing.hardCostMarginMultiplier ?? 1.25;\n const creditsPerUsd = billing.creditsPerUsd ?? 20;\n const credits = (cents / 100) * margin * creditsPerUsd;\n return credits <= 0 ? 0 : Math.ceil(credits * 1000) / 1000;\n}\n\nfunction formatCredits(credits: number): string {\n if (!Number.isFinite(credits) || credits === 0) return \"0 credits\";\n const maximumFractionDigits = credits < 1 ? 3 : credits < 10 ? 2 : 1;\n const value = credits.toLocaleString(undefined, {\n maximumFractionDigits,\n });\n return `${value} ${credits === 1 ? \"credit\" : \"credits\"}`;\n}\n\nfunction formatSpend(cents: number, billing: UsageBillingMode): string {\n if (billing.unit === \"builder-credits\") {\n return formatCredits(displayAmountFromCostCents(cents, billing));\n }\n // Sub-cent values (e.g. a single LLM call at $0.0045 = 0.45¢) — keep\n // three decimals so tiny calls don't round to 0.00¢. The prior impl\n // multiplied by 100 in this branch, overstating small costs 100×.\n if (cents < 1) return `${cents.toFixed(3)}¢`;\n if (cents < 100) return `${cents.toFixed(2)}¢`;\n return `$${(cents / 100).toFixed(2)}`;\n}\n\nfunction formatAggregateCost(\n cost: UsageCostAggregate,\n billing: UsageBillingMode,\n): string {\n if (cost.status === \"known\") return formatSpend(cost.knownCents, billing);\n if (cost.status === \"unavailable\") return \"Unknown\";\n return `${formatSpend(cost.knownCents, billing)} + ${cost.unavailableCalls} unpriced`;\n}\n\nfunction formatTokens(n: number): string {\n if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;\n if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;\n return String(n);\n}\n\nfunction BucketBars({\n buckets,\n emptyMessage,\n billing,\n}: {\n buckets: UsageBucket[];\n emptyMessage: string;\n billing: UsageBillingMode;\n}) {\n if (buckets.length === 0) {\n return (\n <p className=\"text-[10px] text-muted-foreground py-1.5\">{emptyMessage}</p>\n );\n }\n const max = Math.max(\n ...buckets.map((b) => displayAmountFromCostCents(b.cents, billing)),\n 0.0001,\n );\n return (\n <div className=\"space-y-1\">\n {buckets.map((b) => (\n <div key={b.key} className=\"text-[10px]\">\n <div className=\"flex items-center justify-between gap-2 mb-0.5\">\n <span\n className=\"truncate text-foreground\"\n title={b.key || \"(none)\"}\n >\n {b.key || \"(none)\"}\n </span>\n <span className=\"shrink-0 text-muted-foreground tabular-nums\">\n {formatAggregateCost(b.cost, billing)}\n <span className=\"ms-1 opacity-60\">\n · {formatTokens(b.inputTokens + b.outputTokens)} tok\n </span>\n </span>\n </div>\n <div className=\"h-1 rounded-full bg-accent/40 overflow-hidden\">\n <div\n className=\"h-full bg-foreground/70\"\n style={{\n width: `${(displayAmountFromCostCents(b.cents, billing) / max) * 100}%`,\n }}\n />\n </div>\n </div>\n ))}\n </div>\n );\n}\n\nfunction DailySparkline({\n days,\n billing,\n}: {\n days: DailyBucket[];\n billing: UsageBillingMode;\n}) {\n if (days.length === 0) return null;\n const max = Math.max(\n ...days.map((d) => displayAmountFromCostCents(d.cents, billing)),\n 0.0001,\n );\n return (\n <div className=\"flex items-end gap-[2px] h-8 pt-2\">\n {days.map((d) => (\n <div\n key={d.date}\n className=\"flex-1 bg-foreground/60 rounded-sm min-h-[1px]\"\n style={{\n height: `${Math.max(\n 2,\n (displayAmountFromCostCents(d.cents, billing) / max) * 100,\n )}%`,\n }}\n title={`${d.date}: ${formatAggregateCost(d.cost, billing)} (${d.calls} calls)`}\n />\n ))}\n </div>\n );\n}\n\nexport function UsageSection() {\n const [days, setDays] = useState(30);\n const [data, setData] = useState<UsageSummary | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const billing = data?.billing ?? USD_BILLING;\n\n const load = async (rangeDays: number) => {\n setLoading(true);\n setError(null);\n try {\n const res = await fetch(\n agentNativePath(`/_agent-native/usage?sinceDays=${rangeDays}`),\n );\n if (!res.ok) {\n throw new Error(`Failed (${res.status})`);\n }\n const json = (await res.json()) as UsageSummary;\n setData(json);\n } catch (err: any) {\n setError(err?.message || \"Failed to load usage\");\n } finally {\n setLoading(false);\n }\n };\n\n useEffect(() => {\n load(days);\n }, [days]);\n\n return (\n <div className=\"space-y-3\">\n {/* Range selector + refresh */}\n <div className=\"flex items-center justify-between\">\n <div className=\"flex gap-1 rounded-md border border-border p-0.5\">\n {RANGES.map((r) => (\n <button\n key={r.value}\n onClick={() => setDays(r.value)}\n className={`px-2 py-0.5 text-[10px] rounded ${\n days === r.value\n ? \"bg-accent text-foreground\"\n : \"text-muted-foreground hover:text-foreground\"\n }`}\n >\n {r.label}\n </button>\n ))}\n </div>\n <button\n onClick={() => load(days)}\n className=\"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground\"\n disabled={loading}\n >\n {loading ? (\n <IconLoader2 size={11} className=\"animate-spin\" />\n ) : (\n <IconRefresh size={11} />\n )}\n </button>\n </div>\n\n {error && <p className=\"text-[10px] text-red-500\">{error}</p>}\n\n {data && (\n <>\n {/* Totals */}\n <div className=\"rounded-md border border-border px-2.5 py-2\">\n <div className=\"flex items-baseline justify-between\">\n <div>\n <div className=\"text-[10px] text-muted-foreground\">\n {billing.unit === \"builder-credits\"\n ? \"Builder.io credit spend\"\n : \"Total spend\"}\n </div>\n <div className=\"text-[18px] font-semibold tabular-nums\">\n {formatAggregateCost(data.totalCost, billing)}\n </div>\n </div>\n <div className=\"text-end\">\n <div className=\"text-[10px] text-muted-foreground\">\n {data.totalCalls} calls\n </div>\n <div className=\"text-[10px] text-muted-foreground\">\n {formatTokens(data.totalInputTokens)} in ·{\" \"}\n {formatTokens(data.totalOutputTokens)} out\n </div>\n {data.totalCacheReadTokens > 0 && (\n <div className=\"text-[10px] text-green-500/80\">\n {formatTokens(data.totalCacheReadTokens)} cached\n </div>\n )}\n </div>\n </div>\n <DailySparkline days={data.byDay} billing={billing} />\n </div>\n\n {/* By label */}\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By label\n </div>\n <BucketBars\n buckets={data.byLabel}\n emptyMessage=\"No labeled calls yet.\"\n billing={billing}\n />\n </div>\n\n {/* By model */}\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By model\n </div>\n <BucketBars\n buckets={data.byModel}\n emptyMessage=\"No calls recorded.\"\n billing={billing}\n />\n </div>\n\n {/* By app — only show when multiple apps contribute */}\n {data.byApp.filter((b) => b.key).length > 1 && (\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By app\n </div>\n <BucketBars\n buckets={data.byApp}\n emptyMessage=\"\"\n billing={billing}\n />\n </div>\n )}\n\n {/* Recent calls */}\n {data.recent.length > 0 && (\n <details>\n <summary className=\"text-[10px] font-medium text-foreground cursor-pointer select-none hover:text-foreground/80\">\n Recent calls ({data.recent.length})\n </summary>\n <div className=\"mt-1.5 max-h-48 overflow-y-auto space-y-0.5 rounded border border-border\">\n {data.recent.map((r) => (\n <div\n key={r.id}\n className=\"flex items-center justify-between gap-2 px-2 py-1 text-[10px] border-b border-border last:border-b-0\"\n >\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-foreground\" title={r.label}>\n {r.label}\n {r.app ? (\n <span className=\"text-muted-foreground\">\n {\" \"}\n · {r.app}\n </span>\n ) : null}\n </div>\n <div className=\"truncate text-muted-foreground\">\n {new Date(r.createdAt).toLocaleString()} · {r.model}\n </div>\n </div>\n <div className=\"shrink-0 text-end tabular-nums text-muted-foreground\">\n {r.costSource === \"unavailable\"\n ? \"Unknown\"\n : formatSpend(r.cents, billing)}\n </div>\n </div>\n ))}\n </div>\n </details>\n )}\n\n {billing.unit === \"builder-credits\" ? (\n <p className=\"text-[10px] text-muted-foreground\">\n Builder.io credits are estimated from hard token cost, a{\" \"}\n {billing.hardCostMarginMultiplier ?? 1.25}x margin, and{\" \"}\n {billing.creditsPerUsd ?? 20} credits per dollar.\n </p>\n ) : (\n <p className=\"text-[10px] text-muted-foreground\">\n Spend is estimated from published Anthropic pricing and your own\n recorded token counts. Cached input is priced at ~10% of regular\n input. Calls without provider pricing are marked unknown and\n excluded from known-cost subtotals.\n </p>\n )}\n </>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
|
|
14
14
|
*/
|
|
15
15
|
export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
16
|
-
error: string;
|
|
17
16
|
ok?: undefined;
|
|
17
|
+
error: string;
|
|
18
18
|
} | {
|
|
19
19
|
error?: undefined;
|
|
20
20
|
ok: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { createServer, createSSEHandler, defineNitroPlugin, autoMountAuth, getSe
|
|
|
13
13
|
export { agentChat, type AgentChatCallOptions, type AgentChatResponse, } from "./shared/index.js";
|
|
14
14
|
export { EMBED_MODE_QUERY_PARAM, EMBED_SESSION_COOKIE, EMBED_START_PATH, EMBED_TOKEN_QUERY_PARAM, } from "./shared/embed-auth.js";
|
|
15
15
|
export { AGENT_WEB_CRAWLER_CATEGORIES, AGENT_WEB_CRAWLER_USER_AGENTS, DEFAULT_AGENT_WEB_CRAWLER_POLICY, absoluteUrl, agentWebConfigFromPackageJson, buildAgentWebStaticFiles, buildBaseJsonLd, buildLlmsFullTxt, buildLlmsTxt, buildMarkdownResponseHeaders, buildPageJsonLd, buildRobotsTxt, buildSitemapXml, deriveAgentWebPublicRoutes, estimateMarkdownTokens, markdownFilePathForPage, markdownUrlForPage, normalizeAgentWebConfig, pathPatternMatches, resolveAgentWebCrawlerPolicy, type AgentWebConfig, type AgentWebCrawlerCategory, type AgentWebCrawlerDecision, type AgentWebCrawlerOverrides, type AgentWebCrawlerPolicy, type AgentWebInputConfig, type AgentWebPage, type AgentWebStaticFile, type BuildAgentWebStaticFilesOptions, type DeriveAgentWebPublicRoutesOptions, type MarkdownResponseHeadersOptions, } from "./agent-web/index.js";
|
|
16
|
-
export { recordUsage, getUsageSummary, getUserUsageCents, calculateCost, usageBillingForEngine, builderCreditsFromCostCents, BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER, BUILDER_AGENT_CREDITS_PER_USD, BUILDER_CREDIT_USAGE_BILLING, USD_USAGE_BILLING, type UsageRecord, type UsageSummary, type UsageBillingMode, type UsageBillingUnit, type UsageBucket, type DailyBucket, type UsageRecentEntry, } from "./usage/store.js";
|
|
16
|
+
export { recordUsage, getUsageSummary, getUserUsageCents, calculateCost, usageBillingForEngine, builderCreditsFromCostCents, BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER, BUILDER_AGENT_CREDITS_PER_USD, BUILDER_CREDIT_USAGE_BILLING, USD_USAGE_BILLING, type UsageRecord, type UsageCostSource, type UsageCostAggregate, type UsageSummary, type UsageBillingMode, type UsageBillingUnit, type UsageBucket, type DailyBucket, type UsageRecentEntry, } from "./usage/store.js";
|
|
17
17
|
export { deleteWorkspaceConnection, getWorkspaceConnectionAppAccess, getWorkspaceConnection, getWorkspaceConnectionGrant, listWorkspaceConnectionProviderCatalogForApp, listWorkspaceConnectionGrants, listWorkspaceConnections, resolveWorkspaceConnectionCredentialForApp, resolveWorkspaceConnectionCredentialsForApp, revokeWorkspaceConnectionGrant, serializeWorkspaceConnectionGrant, serializeWorkspaceConnection, summarizeWorkspaceConnectionProviderForApp, summarizeWorkspaceConnectionProviderReadiness, upsertWorkspaceConnectionGrant, upsertWorkspaceConnection, type ListWorkspaceConnectionProviderCatalogForAppOptions, type ListWorkspaceConnectionGrantsOptions, type ListWorkspaceConnectionsOptions, type ResolveWorkspaceConnectionCredentialForAppOptions, type ResolveWorkspaceConnectionCredentialsForAppOptions, type SerializedWorkspaceConnectionGrant, type SerializedWorkspaceConnection, type SummarizeWorkspaceConnectionProviderForAppOptions, type SummarizeWorkspaceConnectionProviderReadinessOptions, type UpsertWorkspaceConnectionGrantInput, type UpsertWorkspaceConnectionInput, type WorkspaceConnectionAppAccess, type WorkspaceConnectionAppAccessMode, type WorkspaceConnection, type WorkspaceConnectionCredentialBackend, type WorkspaceConnectionCredentialProvenance, type WorkspaceConnectionCredentialRef, type WorkspaceConnectionCredentialResolution, type WorkspaceConnectionCredentialResolutionCheck, type WorkspaceConnectionCredentialResolutionStatus, type WorkspaceConnectionCredentialsResolution, type WorkspaceConnectionExplicitGrantSummary, type WorkspaceConnectionForAppSummary, type WorkspaceConnectionGrant, type WorkspaceConnectionGrantAvailability, type WorkspaceConnectionGrantState, type WorkspaceConnectionProviderAppSummary, type WorkspaceConnectionProviderLike, type WorkspaceConnectionProviderCatalogForApp, type WorkspaceConnectionProviderCatalogForAppItem, type WorkspaceConnectionProviderReadiness, type WorkspaceConnectionProviderReadinessStatus, type WorkspaceConnectionPublicCredentialRef, type WorkspaceConnectionStatus, workspaceConnectionIsAvailableToApp, } from "./workspace-connections/index.js";
|
|
18
18
|
export { PROVIDER_READERS, ProviderReaderRuntimeError, WORKSPACE_CONNECTION_PROVIDERS, createProviderReaderRuntime, defineProviderReader, defineProviderReaderImplementation, defineWorkspaceConnectionProvider, getProviderReader, getWorkspaceConnectionProvider, isWorkspaceConnectionProviderId, listProviderReaders, listWorkspaceConnectionProviders, listWorkspaceConnectionProvidersForCapability, listWorkspaceConnectionProvidersForTemplate, providerReaderSupports, workspaceConnectionProviderSupports, type ListWorkspaceConnectionProvidersOptions, type ListProviderReadersOptions, type ProviderReaderCapability, type ProviderReaderCredentialRequirement, type ProviderReaderDefinition, type ProviderReaderImplementationStatus, type ProviderReaderOperation, type ProviderReaderOperationDescriptor, type ProviderReaderOperationParameter, type ProviderReaderRequest, type ProviderReaderRuntime, type ProviderReaderRuntimeConnection, type ProviderReaderRuntimeConnectionResolverOptions, type ProviderReaderRuntimeContext, type ProviderReaderRuntimeCredentialsResolverOptions, type ProviderReaderRuntimeErrorCode, type ProviderReaderRuntimeHandler, type ProviderReaderRuntimeImplementation, type ProviderReaderRuntimeItem, type ProviderReaderRuntimeOptions, type ProviderReaderRuntimeResponse, type WorkspaceConnectionCapability, type WorkspaceConnectionCredentialKey, type WorkspaceConnectionProvider, type WorkspaceConnectionProviderId, type WorkspaceConnectionTemplateUse, } from "./connections/index.js";
|
|
19
19
|
export { runScript, loadEnv, parseArgs, camelCaseArgs, isValidPath, isValidProjectPath, ensureDir, fail, } from "./scripts/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,4BAA4B,EAC5B,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,aAAa,EAEb,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,K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CAA8C,EACnD,KAAK,4BAA4B,EACjC,KAAK,+CAA+C,EACpD,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,mCAAmC,EACxC,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACrC,KAAK,2BAA2B,EAChC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,GACpC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,IAAI,GACL,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,oBAAoB,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EACL,yCAAyC,EACzC,KAAK,gDAAgD,GACtD,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,4BAA4B,EAC5B,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,aAAa,EAEb,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,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gC,EACrC,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACpC,KAAK,8CAA8C,EACnD,KAAK,4BAA4B,EACjC,KAAK,+CAA+C,EACpD,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,mCAAmC,EACxC,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACrC,KAAK,2BAA2B,EAChC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,GACpC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,IAAI,GACL,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,oBAAoB,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EACL,yCAAyC,EACzC,KAAK,gDAAgD,GACtD,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,+CAA+C;AAE/C,0BAA0B;AAC1B,OAAO,EACL,4BAA4B,EAU5B,aAAa;AACb,6DAA6D;AAC7D,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EAOtB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C,EAClC,iCAAiC,EACjC,iBAAiB,EACjB,8BAA8B,EAC9B,+BAA+B,EAC/B,mBAAmB,EACnB,gCAAgC,EAChC,6CAA6C,EAC7C,2CAA2C,EAC3C,sBAAsB,EACtB,mCAAmC,GA2BpC,MAAM,wBAAwB,CAAC;AAEhC,UAAU;AACV,OAAO,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,IAAI,GACL,MAAM,oBAAoB,CAAC;AAE5B,4EAA4E;AAC5E,wEAAwE;AACxE,mCAAmC;AACnC,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,GAMhB,MAAM,oBAAoB,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EACL,yCAAyC,GAE1C,MAAM,8BAA8B,CAAC","sourcesContent":["// Framework for agent-native apps.\n// Import everything from \"@agent-native/core\".\n\n// Agent (production mode)\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n DEFAULT_MODEL,\n // In-loop processors (observers/guardrails for runAgentLoop)\n TripWire,\n type Processor,\n type ProcessorState,\n type ProcessorAbort,\n} from \"./agent/index.js\";\nexport {\n defineAction,\n AgentActionStopError,\n isAgentActionStopError,\n type ActionDefinition,\n type ActionHttpConfig,\n type AgentActionStopOptions,\n type PublicAgentActionConfig,\n type ActionDeepLink,\n type ActionLinkBuilder,\n MCP_APP_EXTENSION_ID,\n MCP_APP_MIME_TYPE,\n MCP_APP_RESOURCE_URI_META_KEY,\n type ActionMcpAppConfig,\n type ActionMcpAppCsp,\n type ActionMcpAppCspBuilder,\n type ActionMcpAppHtmlBuilder,\n type ActionMcpAppPermissions,\n type ActionMcpAppResourceConfig,\n type ActionMcpAppResourceMeta,\n} from \"./action.js\";\nexport {\n embedApp,\n MCP_APP_REQUEST_ORIGIN_CSP_SOURCE,\n type EmbedAppOptions,\n} from \"./mcp/embed-app.js\";\nexport {\n embedRoute,\n type EmbedRouteContext,\n type EmbedRouteOptions,\n type EmbedRoutePathBuilder,\n type EmbedRouteResult,\n} from \"./mcp/embed-route.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER,\n type ActionChatUIConfig,\n} from \"./action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./data-widgets/index.js\";\nexport { createDevScriptRegistry } from \"./scripts/dev/index.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./server/agent-chat-plugin.js\";\nexport {\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./server/embedded.js\";\nexport {\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type AutomationCapabilities,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"./integrations/catalog.js\";\nexport {\n AutomationConnectorError,\n createAutomationCallbackHandler,\n createAutomationRuntime,\n createInvokeAutomationWorkflowAction,\n type AutomationCallbackAuthentication,\n type AutomationCallbackInput,\n type AutomationCallbackResult,\n type AutomationInboundDefinition,\n type AutomationInvocation,\n type AutomationInvocationResult,\n type AutomationInvocationStatus,\n type AutomationOutboundDefinition,\n type AutomationResponseMode,\n type AutomationRetryPolicy,\n type AutomationRuntime,\n type AutomationRuntimeOptions,\n type AutomationWorkflowCapabilities,\n type AutomationWorkflowDefinition,\n type JsonSchema,\n} from \"./automation/index.js\";\n\n// Server\nexport {\n createServer,\n createSSEHandler,\n defineNitroPlugin,\n autoMountAuth,\n getSession,\n type CreateServerOptions,\n type SSEHandlerOptions,\n type AuthSession,\n type AuthOptions,\n} from \"./server/index.js\";\n\n// Client\n//\n// IMPORTANT: this top-level entry (the package `default`/Node condition) must\n// stay server-safe. It is what `import { defineAction } from \"@agent-native/core\"`\n// resolves to in a headless / Node / SSR context, where React, react-router, and\n// @tanstack/react-query are NOT installed. The React client surface therefore\n// lives behind the `@agent-native/core/client` subpath instead of being\n// re-exported here — re-exporting \"./client/index.js\" from this module would\n// eagerly pull route-state.ts → \"@tanstack/react-query\" into the load graph and\n// crash any headless app at module load.\n//\n// Browser bundlers resolve \"@agent-native/core\" to the `browser` condition\n// (./index.browser.ts), which re-exports the client surface, so UI code that\n// imports client helpers from the bare specifier keeps working in the browser.\n// Code that runs through the Node entry (SSR, scripts, headless) must import\n// client helpers explicitly:\n//\n// import { useDbSync, cn } from \"@agent-native/core/client\";\n\n// Shared (isomorphic)\nexport {\n agentChat,\n type AgentChatCallOptions,\n type AgentChatResponse,\n} from \"./shared/index.js\";\nexport {\n EMBED_MODE_QUERY_PARAM,\n EMBED_SESSION_COOKIE,\n EMBED_START_PATH,\n EMBED_TOKEN_QUERY_PARAM,\n} from \"./shared/embed-auth.js\";\n\n// Agent Web surfaces\nexport {\n AGENT_WEB_CRAWLER_CATEGORIES,\n AGENT_WEB_CRAWLER_USER_AGENTS,\n DEFAULT_AGENT_WEB_CRAWLER_POLICY,\n absoluteUrl,\n agentWebConfigFromPackageJson,\n buildAgentWebStaticFiles,\n buildBaseJsonLd,\n buildLlmsFullTxt,\n buildLlmsTxt,\n buildMarkdownResponseHeaders,\n buildPageJsonLd,\n buildRobotsTxt,\n buildSitemapXml,\n deriveAgentWebPublicRoutes,\n estimateMarkdownTokens,\n markdownFilePathForPage,\n markdownUrlForPage,\n normalizeAgentWebConfig,\n pathPatternMatches,\n resolveAgentWebCrawlerPolicy,\n type AgentWebConfig,\n type AgentWebCrawlerCategory,\n type AgentWebCrawlerDecision,\n type AgentWebCrawlerOverrides,\n type AgentWebCrawlerPolicy,\n type AgentWebInputConfig,\n type AgentWebPage,\n type AgentWebStaticFile,\n type BuildAgentWebStaticFilesOptions,\n type DeriveAgentWebPublicRoutesOptions,\n type MarkdownResponseHeadersOptions,\n} from \"./agent-web/index.js\";\n\n// Token usage tracking\nexport {\n recordUsage,\n getUsageSummary,\n getUserUsageCents,\n calculateCost,\n usageBillingForEngine,\n builderCreditsFromCostCents,\n BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER,\n BUILDER_AGENT_CREDITS_PER_USD,\n BUILDER_CREDIT_USAGE_BILLING,\n USD_USAGE_BILLING,\n type UsageRecord,\n type UsageSummary,\n type UsageBillingMode,\n type UsageBillingUnit,\n type UsageBucket,\n type DailyBucket,\n type UsageRecentEntry,\n} from \"./usage/store.js\";\n\n// Workspace-scoped third-party connection metadata\nexport {\n deleteWorkspaceConnection,\n getWorkspaceConnectionAppAccess,\n getWorkspaceConnection,\n getWorkspaceConnectionGrant,\n listWorkspaceConnectionProviderCatalogForApp,\n listWorkspaceConnectionGrants,\n listWorkspaceConnections,\n resolveWorkspaceConnectionCredentialForApp,\n resolveWorkspaceConnectionCredentialsForApp,\n revokeWorkspaceConnectionGrant,\n serializeWorkspaceConnectionGrant,\n serializeWorkspaceConnection,\n summarizeWorkspaceConnectionProviderForApp,\n summarizeWorkspaceConnectionProviderReadiness,\n upsertWorkspaceConnectionGrant,\n upsertWorkspaceConnection,\n type ListWorkspaceConnectionProviderCatalogForAppOptions,\n type ListWorkspaceConnectionGrantsOptions,\n type ListWorkspaceConnectionsOptions,\n type ResolveWorkspaceConnectionCredentialForAppOptions,\n type ResolveWorkspaceConnectionCredentialsForAppOptions,\n type SerializedWorkspaceConnectionGrant,\n type SerializedWorkspaceConnection,\n type SummarizeWorkspaceConnectionProviderForAppOptions,\n type SummarizeWorkspaceConnectionProviderReadinessOptions,\n type UpsertWorkspaceConnectionGrantInput,\n type UpsertWorkspaceConnectionInput,\n type WorkspaceConnectionAppAccess,\n type WorkspaceConnectionAppAccessMode,\n type WorkspaceConnection,\n type WorkspaceConnectionCredentialBackend,\n type WorkspaceConnectionCredentialProvenance,\n type WorkspaceConnectionCredentialRef,\n type WorkspaceConnectionCredentialResolution,\n type WorkspaceConnectionCredentialResolutionCheck,\n type WorkspaceConnectionCredentialResolutionStatus,\n type WorkspaceConnectionCredentialsResolution,\n type WorkspaceConnectionExplicitGrantSummary,\n type WorkspaceConnectionForAppSummary,\n type WorkspaceConnectionGrant,\n type WorkspaceConnectionGrantAvailability,\n type WorkspaceConnectionGrantState,\n type WorkspaceConnectionProviderAppSummary,\n type WorkspaceConnectionProviderLike,\n type WorkspaceConnectionProviderCatalogForApp,\n type WorkspaceConnectionProviderCatalogForAppItem,\n type WorkspaceConnectionProviderReadiness,\n type WorkspaceConnectionProviderReadinessStatus,\n type WorkspaceConnectionPublicCredentialRef,\n type WorkspaceConnectionStatus,\n workspaceConnectionIsAvailableToApp,\n} from \"./workspace-connections/index.js\";\n\n// Reusable workspace connection provider catalog\nexport {\n PROVIDER_READERS,\n ProviderReaderRuntimeError,\n WORKSPACE_CONNECTION_PROVIDERS,\n createProviderReaderRuntime,\n defineProviderReader,\n defineProviderReaderImplementation,\n defineWorkspaceConnectionProvider,\n getProviderReader,\n getWorkspaceConnectionProvider,\n isWorkspaceConnectionProviderId,\n listProviderReaders,\n listWorkspaceConnectionProviders,\n listWorkspaceConnectionProvidersForCapability,\n listWorkspaceConnectionProvidersForTemplate,\n providerReaderSupports,\n workspaceConnectionProviderSupports,\n type ListWorkspaceConnectionProvidersOptions,\n type ListProviderReadersOptions,\n type ProviderReaderCapability,\n type ProviderReaderCredentialRequirement,\n type ProviderReaderDefinition,\n type ProviderReaderImplementationStatus,\n type ProviderReaderOperation,\n type ProviderReaderOperationDescriptor,\n type ProviderReaderOperationParameter,\n type ProviderReaderRequest,\n type ProviderReaderRuntime,\n type ProviderReaderRuntimeConnection,\n type ProviderReaderRuntimeConnectionResolverOptions,\n type ProviderReaderRuntimeContext,\n type ProviderReaderRuntimeCredentialsResolverOptions,\n type ProviderReaderRuntimeErrorCode,\n type ProviderReaderRuntimeHandler,\n type ProviderReaderRuntimeImplementation,\n type ProviderReaderRuntimeItem,\n type ProviderReaderRuntimeOptions,\n type ProviderReaderRuntimeResponse,\n type WorkspaceConnectionCapability,\n type WorkspaceConnectionCredentialKey,\n type WorkspaceConnectionProvider,\n type WorkspaceConnectionProviderId,\n type WorkspaceConnectionTemplateUse,\n} from \"./connections/index.js\";\n\n// Scripts\nexport {\n runScript,\n loadEnv,\n parseArgs,\n camelCaseArgs,\n isValidPath,\n isValidProjectPath,\n ensureDir,\n fail,\n} from \"./scripts/index.js\";\n\n// Secrets registry — import from \"@agent-native/core/secrets\" when possible\n// (the subpath keeps the top-level entry point lean), but re-export the\n// public API here for convenience.\nexport {\n registerRequiredSecret,\n listRequiredSecrets,\n getRequiredSecret,\n readAppSecret,\n writeAppSecret,\n deleteAppSecret,\n type RegisteredSecret,\n type SecretScope,\n type SecretKind,\n type SecretValidator,\n type SecretRef,\n} from \"./secrets/index.js\";\n\nexport * from \"./history/index.js\";\nexport * from \"./review/index.js\";\nexport * from \"./org-team/index.js\";\nexport * from \"./navigation/index.js\";\nexport * from \"./command-navigation/index.js\";\nexport {\n registerWorkspaceConnectionOnboardingStep,\n type RegisterWorkspaceConnectionOnboardingStepOptions,\n} from \"./setup-connections/index.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,+CAA+C;AAE/C,0BAA0B;AAC1B,OAAO,EACL,4BAA4B,EAU5B,aAAa;AACb,6DAA6D;AAC7D,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EAOtB,oBAAoB,EACpB,iBAAiB,EACjB,6BAA6B,GAQ9B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,iCAAiC,GAElC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,UAAU,GAKX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAClC,mCAAmC,EACnC,wCAAwC,GAEzC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB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AmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EACL,yCAAyC,GAE1C,MAAM,8BAA8B,CAAC","sourcesContent":["// Framework for agent-native apps.\n// Import everything from \"@agent-native/core\".\n\n// Agent (production mode)\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n DEFAULT_MODEL,\n // In-loop processors (observers/guardrails for runAgentLoop)\n TripWire,\n type Processor,\n type ProcessorState,\n type ProcessorAbort,\n} from \"./agent/index.js\";\nexport {\n defineAction,\n AgentActionStopError,\n isAgentActionStopError,\n type ActionDefinition,\n type ActionHttpConfig,\n type AgentActionStopOptions,\n type PublicAgentActionConfig,\n type ActionDeepLink,\n type ActionLinkBuilder,\n MCP_APP_EXTENSION_ID,\n MCP_APP_MIME_TYPE,\n MCP_APP_RESOURCE_URI_META_KEY,\n type ActionMcpAppConfig,\n type ActionMcpAppCsp,\n type ActionMcpAppCspBuilder,\n type ActionMcpAppHtmlBuilder,\n type ActionMcpAppPermissions,\n type ActionMcpAppResourceConfig,\n type ActionMcpAppResourceMeta,\n} from \"./action.js\";\nexport {\n embedApp,\n MCP_APP_REQUEST_ORIGIN_CSP_SOURCE,\n type EmbedAppOptions,\n} from \"./mcp/embed-app.js\";\nexport {\n embedRoute,\n type EmbedRouteContext,\n type EmbedRouteOptions,\n type EmbedRoutePathBuilder,\n type EmbedRouteResult,\n} from \"./mcp/embed-route.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER,\n type ActionChatUIConfig,\n} from \"./action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./data-widgets/index.js\";\nexport { createDevScriptRegistry } from \"./scripts/dev/index.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./server/agent-chat-plugin.js\";\nexport {\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./server/embedded.js\";\nexport {\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type AutomationCapabilities,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"./integrations/catalog.js\";\nexport {\n AutomationConnectorError,\n createAutomationCallbackHandler,\n createAutomationRuntime,\n createInvokeAutomationWorkflowAction,\n type AutomationCallbackAuthentication,\n type AutomationCallbackInput,\n type AutomationCallbackResult,\n type AutomationInboundDefinition,\n type AutomationInvocation,\n type AutomationInvocationResult,\n type AutomationInvocationStatus,\n type AutomationOutboundDefinition,\n type AutomationResponseMode,\n type AutomationRetryPolicy,\n type AutomationRuntime,\n type AutomationRuntimeOptions,\n type AutomationWorkflowCapabilities,\n type AutomationWorkflowDefinition,\n type JsonSchema,\n} from \"./automation/index.js\";\n\n// Server\nexport {\n createServer,\n createSSEHandler,\n defineNitroPlugin,\n autoMountAuth,\n getSession,\n type CreateServerOptions,\n type SSEHandlerOptions,\n type AuthSession,\n type AuthOptions,\n} from \"./server/index.js\";\n\n// Client\n//\n// IMPORTANT: this top-level entry (the package `default`/Node condition) must\n// stay server-safe. It is what `import { defineAction } from \"@agent-native/core\"`\n// resolves to in a headless / Node / SSR context, where React, react-router, and\n// @tanstack/react-query are NOT installed. The React client surface therefore\n// lives behind the `@agent-native/core/client` subpath instead of being\n// re-exported here — re-exporting \"./client/index.js\" from this module would\n// eagerly pull route-state.ts → \"@tanstack/react-query\" into the load graph and\n// crash any headless app at module load.\n//\n// Browser bundlers resolve \"@agent-native/core\" to the `browser` condition\n// (./index.browser.ts), which re-exports the client surface, so UI code that\n// imports client helpers from the bare specifier keeps working in the browser.\n// Code that runs through the Node entry (SSR, scripts, headless) must import\n// client helpers explicitly:\n//\n// import { useDbSync, cn } from \"@agent-native/core/client\";\n\n// Shared (isomorphic)\nexport {\n agentChat,\n type AgentChatCallOptions,\n type AgentChatResponse,\n} from \"./shared/index.js\";\nexport {\n EMBED_MODE_QUERY_PARAM,\n EMBED_SESSION_COOKIE,\n EMBED_START_PATH,\n EMBED_TOKEN_QUERY_PARAM,\n} from \"./shared/embed-auth.js\";\n\n// Agent Web surfaces\nexport {\n AGENT_WEB_CRAWLER_CATEGORIES,\n AGENT_WEB_CRAWLER_USER_AGENTS,\n DEFAULT_AGENT_WEB_CRAWLER_POLICY,\n absoluteUrl,\n agentWebConfigFromPackageJson,\n buildAgentWebStaticFiles,\n buildBaseJsonLd,\n buildLlmsFullTxt,\n buildLlmsTxt,\n buildMarkdownResponseHeaders,\n buildPageJsonLd,\n buildRobotsTxt,\n buildSitemapXml,\n deriveAgentWebPublicRoutes,\n estimateMarkdownTokens,\n markdownFilePathForPage,\n markdownUrlForPage,\n normalizeAgentWebConfig,\n pathPatternMatches,\n resolveAgentWebCrawlerPolicy,\n type AgentWebConfig,\n type AgentWebCrawlerCategory,\n type AgentWebCrawlerDecision,\n type AgentWebCrawlerOverrides,\n type AgentWebCrawlerPolicy,\n type AgentWebInputConfig,\n type AgentWebPage,\n type AgentWebStaticFile,\n type BuildAgentWebStaticFilesOptions,\n type DeriveAgentWebPublicRoutesOptions,\n type MarkdownResponseHeadersOptions,\n} from \"./agent-web/index.js\";\n\n// Token usage tracking\nexport {\n recordUsage,\n getUsageSummary,\n getUserUsageCents,\n calculateCost,\n usageBillingForEngine,\n builderCreditsFromCostCents,\n BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER,\n BUILDER_AGENT_CREDITS_PER_USD,\n BUILDER_CREDIT_USAGE_BILLING,\n USD_USAGE_BILLING,\n type UsageRecord,\n type UsageCostSource,\n type UsageCostAggregate,\n type UsageSummary,\n type UsageBillingMode,\n type UsageBillingUnit,\n type UsageBucket,\n type DailyBucket,\n type UsageRecentEntry,\n} from \"./usage/store.js\";\n\n// Workspace-scoped third-party connection metadata\nexport {\n deleteWorkspaceConnection,\n getWorkspaceConnectionAppAccess,\n getWorkspaceConnection,\n getWorkspaceConnectionGrant,\n listWorkspaceConnectionProviderCatalogForApp,\n listWorkspaceConnectionGrants,\n listWorkspaceConnections,\n resolveWorkspaceConnectionCredentialForApp,\n resolveWorkspaceConnectionCredentialsForApp,\n revokeWorkspaceConnectionGrant,\n serializeWorkspaceConnectionGrant,\n serializeWorkspaceConnection,\n summarizeWorkspaceConnectionProviderForApp,\n summarizeWorkspaceConnectionProviderReadiness,\n upsertWorkspaceConnectionGrant,\n upsertWorkspaceConnection,\n type ListWorkspaceConnectionProviderCatalogForAppOptions,\n type ListWorkspaceConnectionGrantsOptions,\n type ListWorkspaceConnectionsOptions,\n type ResolveWorkspaceConnectionCredentialForAppOptions,\n type ResolveWorkspaceConnectionCredentialsForAppOptions,\n type SerializedWorkspaceConnectionGrant,\n type SerializedWorkspaceConnection,\n type SummarizeWorkspaceConnectionProviderForAppOptions,\n type SummarizeWorkspaceConnectionProviderReadinessOptions,\n type UpsertWorkspaceConnectionGrantInput,\n type UpsertWorkspaceConnectionInput,\n type WorkspaceConnectionAppAccess,\n type WorkspaceConnectionAppAccessMode,\n type WorkspaceConnection,\n type WorkspaceConnectionCredentialBackend,\n type WorkspaceConnectionCredentialProvenance,\n type WorkspaceConnectionCredentialRef,\n type WorkspaceConnectionCredentialResolution,\n type WorkspaceConnectionCredentialResolutionCheck,\n type WorkspaceConnectionCredentialResolutionStatus,\n type WorkspaceConnectionCredentialsResolution,\n type WorkspaceConnectionExplicitGrantSummary,\n type WorkspaceConnectionForAppSummary,\n type WorkspaceConnectionGrant,\n type WorkspaceConnectionGrantAvailability,\n type WorkspaceConnectionGrantState,\n type WorkspaceConnectionProviderAppSummary,\n type WorkspaceConnectionProviderLike,\n type WorkspaceConnectionProviderCatalogForApp,\n type WorkspaceConnectionProviderCatalogForAppItem,\n type WorkspaceConnectionProviderReadiness,\n type WorkspaceConnectionProviderReadinessStatus,\n type WorkspaceConnectionPublicCredentialRef,\n type WorkspaceConnectionStatus,\n workspaceConnectionIsAvailableToApp,\n} from \"./workspace-connections/index.js\";\n\n// Reusable workspace connection provider catalog\nexport {\n PROVIDER_READERS,\n ProviderReaderRuntimeError,\n WORKSPACE_CONNECTION_PROVIDERS,\n createProviderReaderRuntime,\n defineProviderReader,\n defineProviderReaderImplementation,\n defineWorkspaceConnectionProvider,\n getProviderReader,\n getWorkspaceConnectionProvider,\n isWorkspaceConnectionProviderId,\n listProviderReaders,\n listWorkspaceConnectionProviders,\n listWorkspaceConnectionProvidersForCapability,\n listWorkspaceConnectionProvidersForTemplate,\n providerReaderSupports,\n workspaceConnectionProviderSupports,\n type ListWorkspaceConnectionProvidersOptions,\n type ListProviderReadersOptions,\n type ProviderReaderCapability,\n type ProviderReaderCredentialRequirement,\n type ProviderReaderDefinition,\n type ProviderReaderImplementationStatus,\n type ProviderReaderOperation,\n type ProviderReaderOperationDescriptor,\n type ProviderReaderOperationParameter,\n type ProviderReaderRequest,\n type ProviderReaderRuntime,\n type ProviderReaderRuntimeConnection,\n type ProviderReaderRuntimeConnectionResolverOptions,\n type ProviderReaderRuntimeContext,\n type ProviderReaderRuntimeCredentialsResolverOptions,\n type ProviderReaderRuntimeErrorCode,\n type ProviderReaderRuntimeHandler,\n type ProviderReaderRuntimeImplementation,\n type ProviderReaderRuntimeItem,\n type ProviderReaderRuntimeOptions,\n type ProviderReaderRuntimeResponse,\n type WorkspaceConnectionCapability,\n type WorkspaceConnectionCredentialKey,\n type WorkspaceConnectionProvider,\n type WorkspaceConnectionProviderId,\n type WorkspaceConnectionTemplateUse,\n} from \"./connections/index.js\";\n\n// Scripts\nexport {\n runScript,\n loadEnv,\n parseArgs,\n camelCaseArgs,\n isValidPath,\n isValidProjectPath,\n ensureDir,\n fail,\n} from \"./scripts/index.js\";\n\n// Secrets registry — import from \"@agent-native/core/secrets\" when possible\n// (the subpath keeps the top-level entry point lean), but re-export the\n// public API here for convenience.\nexport {\n registerRequiredSecret,\n listRequiredSecrets,\n getRequiredSecret,\n readAppSecret,\n writeAppSecret,\n deleteAppSecret,\n type RegisteredSecret,\n type SecretScope,\n type SecretKind,\n type SecretValidator,\n type SecretRef,\n} from \"./secrets/index.js\";\n\nexport * from \"./history/index.js\";\nexport * from \"./review/index.js\";\nexport * from \"./org-team/index.js\";\nexport * from \"./navigation/index.js\";\nexport * from \"./command-navigation/index.js\";\nexport {\n registerWorkspaceConnectionOnboardingStep,\n type RegisterWorkspaceConnectionOnboardingStepOptions,\n} from \"./setup-connections/index.js\";\n"]}
|
package/dist/usage/store.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface UsageRecord {
|
|
|
36
36
|
* provider-reported dollar cost so two surfaces agree exactly.
|
|
37
37
|
*/
|
|
38
38
|
costCentsX100?: number;
|
|
39
|
+
/** Whether cost is provider-reported, estimated, or unavailable. */
|
|
40
|
+
costSource?: UsageCostSource;
|
|
39
41
|
orgId?: string;
|
|
40
42
|
runId?: string;
|
|
41
43
|
threadId?: string;
|
|
@@ -44,6 +46,7 @@ export interface UsageRecord {
|
|
|
44
46
|
sourcePlatform?: string;
|
|
45
47
|
sourceId?: string;
|
|
46
48
|
}
|
|
49
|
+
export type UsageCostSource = "reported" | "estimated" | "unavailable";
|
|
47
50
|
/**
|
|
48
51
|
* Calculate cost in centicents (1/100th of a cent).
|
|
49
52
|
* Accepts cache tokens so callers that use prompt caching are priced
|
|
@@ -72,14 +75,29 @@ export interface UsageBucket {
|
|
|
72
75
|
cacheReadTokens: number;
|
|
73
76
|
cacheWriteTokens: number;
|
|
74
77
|
cents: number;
|
|
78
|
+
cost: UsageCostAggregate;
|
|
75
79
|
calls: number;
|
|
76
80
|
}
|
|
77
81
|
export interface DailyBucket {
|
|
78
82
|
/** YYYY-MM-DD (UTC) */
|
|
79
83
|
date: string;
|
|
80
84
|
cents: number;
|
|
85
|
+
cost: UsageCostAggregate;
|
|
81
86
|
calls: number;
|
|
82
87
|
}
|
|
88
|
+
export type UsageCostAggregate = {
|
|
89
|
+
status: "known";
|
|
90
|
+
knownCents: number;
|
|
91
|
+
unavailableCalls: 0;
|
|
92
|
+
} | {
|
|
93
|
+
status: "partial";
|
|
94
|
+
knownCents: number;
|
|
95
|
+
unavailableCalls: number;
|
|
96
|
+
} | {
|
|
97
|
+
status: "unavailable";
|
|
98
|
+
knownCents: 0;
|
|
99
|
+
unavailableCalls: number;
|
|
100
|
+
};
|
|
83
101
|
export interface UsageRecentEntry {
|
|
84
102
|
id: number;
|
|
85
103
|
createdAt: number;
|
|
@@ -91,10 +109,13 @@ export interface UsageRecentEntry {
|
|
|
91
109
|
cacheReadTokens: number;
|
|
92
110
|
cacheWriteTokens: number;
|
|
93
111
|
cents: number;
|
|
112
|
+
costSource: UsageCostSource;
|
|
94
113
|
}
|
|
95
114
|
export interface UsageSummary {
|
|
96
115
|
billing?: UsageBillingMode;
|
|
116
|
+
/** Legacy known-cost subtotal. Use totalCost to preserve unavailable spend. */
|
|
97
117
|
totalCents: number;
|
|
118
|
+
totalCost: UsageCostAggregate;
|
|
98
119
|
totalCalls: number;
|
|
99
120
|
totalInputTokens: number;
|
|
100
121
|
totalOutputTokens: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/usage/store.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,sCAAsC,OAAO,CAAC;AAC3D,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,iBAAiB,CAAC;AAEzD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,yBAAyB,GAAG,uBAAuB,CAAC;IAC5D,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,gBAO1C,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACpC,gBAAgB,CAIlB;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQjE;AAqGD,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,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,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AAID;;;GAGG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,CA0IvB"}
|
package/dist/usage/store.js
CHANGED
|
@@ -152,6 +152,7 @@ async function ensureUsageTable() {
|
|
|
152
152
|
cache_read_tokens ${intType()} NOT NULL DEFAULT 0,
|
|
153
153
|
cache_write_tokens ${intType()} NOT NULL DEFAULT 0,
|
|
154
154
|
cost_cents_x100 ${intType()} NOT NULL DEFAULT 0,
|
|
155
|
+
cost_source TEXT NOT NULL DEFAULT 'estimated',
|
|
155
156
|
model TEXT NOT NULL DEFAULT '',
|
|
156
157
|
label TEXT NOT NULL DEFAULT 'chat',
|
|
157
158
|
app TEXT NOT NULL DEFAULT '',
|
|
@@ -170,6 +171,7 @@ async function ensureUsageTable() {
|
|
|
170
171
|
const additions = [
|
|
171
172
|
["cache_read_tokens", `${intType()} NOT NULL DEFAULT 0`],
|
|
172
173
|
["cache_write_tokens", `${intType()} NOT NULL DEFAULT 0`],
|
|
174
|
+
["cost_source", `TEXT NOT NULL DEFAULT 'estimated'`],
|
|
173
175
|
["label", `TEXT NOT NULL DEFAULT 'chat'`],
|
|
174
176
|
["app", `TEXT NOT NULL DEFAULT ''`],
|
|
175
177
|
["ref_id", `TEXT NOT NULL DEFAULT ''`],
|
|
@@ -258,7 +260,7 @@ export async function recordUsage(recordOrOwner, inputTokens, outputTokens, mode
|
|
|
258
260
|
model: model ?? "",
|
|
259
261
|
}
|
|
260
262
|
: recordOrOwner;
|
|
261
|
-
const { ownerEmail, inputTokens: inTok, outputTokens: outTok, cacheReadTokens = 0, cacheWriteTokens = 0, model: modelName, label, app, refId, costCentsX100, orgId, runId, threadId, taskId, integrationScopeId, sourcePlatform, sourceId, } = record;
|
|
263
|
+
const { ownerEmail, inputTokens: inTok, outputTokens: outTok, cacheReadTokens = 0, cacheWriteTokens = 0, model: modelName, label, app, refId, costCentsX100, costSource, orgId, runId, threadId, taskId, integrationScopeId, sourcePlatform, sourceId, } = record;
|
|
262
264
|
// Skip no-op writes (e.g. a stream aborted before any tokens flowed)
|
|
263
265
|
if (!inTok && !outTok && !cacheReadTokens && !cacheWriteTokens)
|
|
264
266
|
return;
|
|
@@ -278,13 +280,16 @@ export async function recordUsage(recordOrOwner, inputTokens, outputTokens, mode
|
|
|
278
280
|
}
|
|
279
281
|
// Prefer an explicit precomputed cost (e.g. a provider-reported dollar cost);
|
|
280
282
|
// otherwise derive it from tokens via the pricing table.
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
+
const resolvedCostSource = costSource ?? (costCentsX100 == null ? "estimated" : "reported");
|
|
284
|
+
const costX100 = resolvedCostSource === "unavailable"
|
|
285
|
+
? 0
|
|
286
|
+
: (costCentsX100 ??
|
|
287
|
+
calculateCost(inTok, outTok, modelName, cacheReadTokens, cacheWriteTokens));
|
|
283
288
|
const id = Date.now() * 1000 + Math.floor(Math.random() * 1000);
|
|
284
289
|
await client.execute({
|
|
285
290
|
sql: `INSERT INTO token_usage
|
|
286
|
-
(id, owner_email, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost_cents_x100, model, label, app, ref_id, org_id, run_id, thread_id, task_id, integration_scope_id, source_platform, source_id, created_at)
|
|
287
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
291
|
+
(id, owner_email, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost_cents_x100, cost_source, model, label, app, ref_id, org_id, run_id, thread_id, task_id, integration_scope_id, source_platform, source_id, created_at)
|
|
292
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
288
293
|
args: [
|
|
289
294
|
id,
|
|
290
295
|
ownerEmail,
|
|
@@ -293,6 +298,7 @@ export async function recordUsage(recordOrOwner, inputTokens, outputTokens, mode
|
|
|
293
298
|
cacheReadTokens,
|
|
294
299
|
cacheWriteTokens,
|
|
295
300
|
costX100,
|
|
301
|
+
resolvedCostSource,
|
|
296
302
|
modelName,
|
|
297
303
|
resolvedLabel,
|
|
298
304
|
resolvedApp,
|
|
@@ -330,7 +336,8 @@ export async function getUsageSummary(options) {
|
|
|
330
336
|
const sinceMs = options.sinceMs ?? Date.now() - 30 * DAY_MS;
|
|
331
337
|
const totalRow = await client.execute({
|
|
332
338
|
sql: `SELECT
|
|
333
|
-
COALESCE(SUM(cost_cents_x100), 0) AS
|
|
339
|
+
COALESCE(SUM(CASE WHEN cost_source = 'unavailable' THEN 0 ELSE cost_cents_x100 END), 0) AS known_cents,
|
|
340
|
+
COALESCE(SUM(CASE WHEN cost_source = 'unavailable' THEN 1 ELSE 0 END), 0) AS unavailable_calls,
|
|
334
341
|
COUNT(*) AS calls,
|
|
335
342
|
COALESCE(SUM(input_tokens), 0) AS in_tok,
|
|
336
343
|
COALESCE(SUM(output_tokens), 0) AS out_tok,
|
|
@@ -342,7 +349,8 @@ export async function getUsageSummary(options) {
|
|
|
342
349
|
const t = (totalRow.rows[0] ?? {});
|
|
343
350
|
const bucketSql = (col) => ({
|
|
344
351
|
sql: `SELECT ${col} AS k,
|
|
345
|
-
COALESCE(SUM(cost_cents_x100), 0) AS
|
|
352
|
+
COALESCE(SUM(CASE WHEN cost_source = 'unavailable' THEN 0 ELSE cost_cents_x100 END), 0) AS known_cents,
|
|
353
|
+
COALESCE(SUM(CASE WHEN cost_source = 'unavailable' THEN 1 ELSE 0 END), 0) AS unavailable_calls,
|
|
346
354
|
COUNT(*) AS calls,
|
|
347
355
|
COALESCE(SUM(input_tokens), 0) AS in_tok,
|
|
348
356
|
COALESCE(SUM(output_tokens), 0) AS out_tok,
|
|
@@ -351,14 +359,17 @@ export async function getUsageSummary(options) {
|
|
|
351
359
|
FROM token_usage
|
|
352
360
|
WHERE owner_email = ? AND created_at >= ?
|
|
353
361
|
GROUP BY ${col}
|
|
354
|
-
ORDER BY
|
|
362
|
+
ORDER BY known_cents DESC`,
|
|
355
363
|
args: [options.ownerEmail, sinceMs],
|
|
356
364
|
});
|
|
357
365
|
const mapBuckets = (rows) => rows.map((r) => {
|
|
358
366
|
const row = r;
|
|
367
|
+
const knownCents = Number(row.known_cents ?? 0) / 100;
|
|
368
|
+
const unavailableCalls = Number(row.unavailable_calls ?? 0);
|
|
359
369
|
return {
|
|
360
370
|
key: String(row.k ?? ""),
|
|
361
|
-
cents:
|
|
371
|
+
cents: knownCents,
|
|
372
|
+
cost: buildUsageCostAggregate(knownCents, unavailableCalls),
|
|
362
373
|
calls: Number(row.calls ?? 0),
|
|
363
374
|
inputTokens: Number(row.in_tok ?? 0),
|
|
364
375
|
outputTokens: Number(row.out_tok ?? 0),
|
|
@@ -375,29 +386,40 @@ export async function getUsageSummary(options) {
|
|
|
375
386
|
// date functions (SQLite `strftime`, Postgres `to_char`). Cheap enough
|
|
376
387
|
// for a 30-day window; if this grows, swap for a dialect-aware query.
|
|
377
388
|
const dayRows = await client.execute({
|
|
378
|
-
sql: `SELECT created_at, cost_cents_x100 FROM token_usage
|
|
389
|
+
sql: `SELECT created_at, cost_cents_x100, cost_source FROM token_usage
|
|
379
390
|
WHERE owner_email = ? AND created_at >= ?`,
|
|
380
391
|
args: [options.ownerEmail, sinceMs],
|
|
381
392
|
});
|
|
382
393
|
const dayMap = new Map();
|
|
383
394
|
for (const row of dayRows.rows) {
|
|
384
395
|
const date = new Date(Number(row.created_at)).toISOString().slice(0, 10);
|
|
385
|
-
const prev = dayMap.get(date) ?? {
|
|
386
|
-
|
|
396
|
+
const prev = dayMap.get(date) ?? {
|
|
397
|
+
knownCentsX100: 0,
|
|
398
|
+
unavailableCalls: 0,
|
|
399
|
+
calls: 0,
|
|
400
|
+
};
|
|
401
|
+
if (row.cost_source === "unavailable")
|
|
402
|
+
prev.unavailableCalls += 1;
|
|
403
|
+
else
|
|
404
|
+
prev.knownCentsX100 += Number(row.cost_cents_x100 ?? 0);
|
|
387
405
|
prev.calls += 1;
|
|
388
406
|
dayMap.set(date, prev);
|
|
389
407
|
}
|
|
390
408
|
const byDay = [...dayMap.entries()]
|
|
391
|
-
.map(([date, v]) =>
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
409
|
+
.map(([date, v]) => {
|
|
410
|
+
const knownCents = v.knownCentsX100 / 100;
|
|
411
|
+
return {
|
|
412
|
+
date,
|
|
413
|
+
cents: knownCents,
|
|
414
|
+
cost: buildUsageCostAggregate(knownCents, v.unavailableCalls),
|
|
415
|
+
calls: v.calls,
|
|
416
|
+
};
|
|
417
|
+
})
|
|
396
418
|
.sort((a, b) => a.date.localeCompare(b.date));
|
|
397
419
|
const recentRows = await client.execute({
|
|
398
420
|
sql: `SELECT id, created_at, label, app, model,
|
|
399
421
|
input_tokens, output_tokens, cache_read_tokens, cache_write_tokens,
|
|
400
|
-
cost_cents_x100
|
|
422
|
+
cost_cents_x100, cost_source
|
|
401
423
|
FROM token_usage
|
|
402
424
|
WHERE owner_email = ?
|
|
403
425
|
ORDER BY created_at DESC
|
|
@@ -415,10 +437,14 @@ export async function getUsageSummary(options) {
|
|
|
415
437
|
cacheReadTokens: Number(row.cache_read_tokens ?? 0),
|
|
416
438
|
cacheWriteTokens: Number(row.cache_write_tokens ?? 0),
|
|
417
439
|
cents: Number(row.cost_cents_x100 ?? 0) / 100,
|
|
440
|
+
costSource: String(row.cost_source ?? "estimated"),
|
|
418
441
|
}));
|
|
442
|
+
const knownCents = Number(t.known_cents ?? 0) / 100;
|
|
443
|
+
const unavailableCalls = Number(t.unavailable_calls ?? 0);
|
|
419
444
|
return {
|
|
420
445
|
billing: USD_USAGE_BILLING,
|
|
421
|
-
totalCents:
|
|
446
|
+
totalCents: knownCents,
|
|
447
|
+
totalCost: buildUsageCostAggregate(knownCents, unavailableCalls),
|
|
422
448
|
totalCalls: Number(t.calls ?? 0),
|
|
423
449
|
totalInputTokens: Number(t.in_tok ?? 0),
|
|
424
450
|
totalOutputTokens: Number(t.out_tok ?? 0),
|
|
@@ -432,4 +458,13 @@ export async function getUsageSummary(options) {
|
|
|
432
458
|
recent,
|
|
433
459
|
};
|
|
434
460
|
}
|
|
461
|
+
function buildUsageCostAggregate(knownCents, unavailableCalls) {
|
|
462
|
+
if (unavailableCalls === 0) {
|
|
463
|
+
return { status: "known", knownCents, unavailableCalls: 0 };
|
|
464
|
+
}
|
|
465
|
+
if (knownCents === 0) {
|
|
466
|
+
return { status: "unavailable", knownCents: 0, unavailableCalls };
|
|
467
|
+
}
|
|
468
|
+
return { status: "partial", knownCents, unavailableCalls };
|
|
469
|
+
}
|
|
435
470
|
//# sourceMappingURL=store.js.map
|