@columenlabs/lumen-ai 0.1.255 → 0.1.256

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.
@@ -109,6 +109,11 @@ export declare function providerOfPart(p: UsagePart): AssistantProvider | undefi
109
109
  * which cost the person nothing. Cache writes count as plain input. Undefined for an unknown model.
110
110
  */
111
111
  export declare function listUsd(p: UsagePart): number | undefined;
112
+ /**
113
+ * An entry with plan calls priced from its stored parts: each $0 part's tokens at API rates. So a
114
+ * chat or run from before `own_plan_usd` was kept, or one that only partly kept it, reads in full.
115
+ */
116
+ export declare function withPlanUsd(e: UsageEntry): UsageEntry;
112
117
  /**
113
118
  * Spend rows with the provider each ran on, so a page can tell a removed key's spend apart, and
114
119
  * a $0 row (a plan's calls) with what it would cost at API rates (`list_usd`).
@@ -25,6 +25,18 @@ export function listUsd(p) {
25
25
  return undefined;
26
26
  return (Math.max(0, p.in - p.read) * m.in + p.read * m.read + p.out * m.out) / 1e6;
27
27
  }
28
+ /**
29
+ * An entry with plan calls priced from its stored parts: each $0 part's tokens at API rates. So a
30
+ * chat or run from before `own_plan_usd` was kept, or one that only partly kept it, reads in full.
31
+ */
32
+ export function withPlanUsd(e) {
33
+ if (!e.own_plan_calls)
34
+ return e;
35
+ const est = e.parts
36
+ .filter((p) => p.calls && p.usd < 0.0005)
37
+ .reduce((a, p) => a + (listUsd(p) ?? 0), 0);
38
+ return est > (e.own_plan_usd ?? 0) ? { ...e, own_plan_usd: est } : e;
39
+ }
28
40
  /**
29
41
  * Spend rows with the provider each ran on, so a page can tell a removed key's spend apart, and
30
42
  * a $0 row (a plan's calls) with what it would cost at API rates (`list_usd`).
@@ -443,7 +455,7 @@ export class State {
443
455
  months,
444
456
  usd: spend.rows.reduce((a, r) => a + r.usd, 0),
445
457
  rows: withProvider(spend.rows),
446
- entries: doc?.entries ?? [],
458
+ entries: (doc?.entries ?? []).map(withPlanUsd),
447
459
  };
448
460
  }
449
461
  /** The payer's key of each provider, those set, and which are plan sign-ins. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ai",
3
- "version": "0.1.255",
3
+ "version": "0.1.256",
4
4
  "description": "Lumen's assistant and agent parts: a chat assistant's server (Claude tiers, tools over MCP, the web, hand off, spend caps), serving an MCP server from a Worker, read-only tool sets and metered tool calls.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,8 +56,8 @@
56
56
  "@ai-sdk/openai": "4.0.108",
57
57
  "@anthropic-ai/sdk": "0.133.0",
58
58
  "@cloudflare/think": "0.23.0",
59
- "@columenlabs/lumen-ops": "0.1.255",
60
- "@columenlabs/lumen-ui-types": "0.1.255",
59
+ "@columenlabs/lumen-ops": "0.1.256",
60
+ "@columenlabs/lumen-ui-types": "0.1.256",
61
61
  "agents": "0.32.0",
62
62
  "ai": "7.0.162",
63
63
  "just-bash": "3.6.0",