@columenlabs/lumen-ai 0.1.233 → 0.1.235

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.
@@ -384,7 +384,12 @@ export class Assistant {
384
384
  .catch(() => undefined);
385
385
  if (input.chat)
386
386
  await this.state
387
- .addUsage(caller.id, { id: `chat:${input.chat}`, kind: 'chat', title: message.split('\n')[0] || 'Chat' }, end.parts)
387
+ .addUsage(caller.id, {
388
+ id: `chat:${input.chat}`,
389
+ kind: 'chat',
390
+ title: message.split('\n')[0] || 'Chat',
391
+ own_usd: paying.payer === 'own' ? onPayer.reduce((a, x) => a + x.usd, 0) : 0,
392
+ }, end.parts)
388
393
  .catch(() => undefined);
389
394
  const total = end.parts.reduce((a, m) => ({
390
395
  calls: a.calls + m.calls,
@@ -1037,6 +1042,7 @@ export class Assistant {
1037
1042
  kind: 'task',
1038
1043
  task: o.task,
1039
1044
  title: o.run?.title ?? task?.label ?? o.task,
1045
+ own_usd: paying.payer === 'own' ? part.usd : 0,
1040
1046
  }, [part])
1041
1047
  .catch(() => undefined);
1042
1048
  }
@@ -1119,6 +1125,7 @@ export class Assistant {
1119
1125
  kind: 'task',
1120
1126
  task: o.task,
1121
1127
  title: o.run?.title ?? task?.label ?? o.task,
1128
+ own_usd: paying.payer === 'own' ? part.usd : 0,
1122
1129
  }, [part])
1123
1130
  .catch(() => undefined);
1124
1131
  }
@@ -253,13 +253,15 @@ export declare class State {
253
253
  }): Promise<void>;
254
254
  /**
255
255
  * Adds one answer's use to a chat or run in this month's history (`usage:YYYY-MM`): one entry a
256
- * chat or run, its parts merged, the newest `USAGE_KEPT` kept. `title` names a new entry only.
256
+ * chat or run, its parts merged, the newest `USAGE_KEPT` kept. `title` names a new entry only;
257
+ * `own_usd` is what of this answer the person's own key or plan paid, added to the entry's.
257
258
  */
258
259
  addUsage(id: string, e: {
259
260
  id: string;
260
261
  kind: UsageEntry['kind'];
261
262
  task?: string;
262
263
  title: string;
264
+ own_usd?: number;
263
265
  }, parts: UsagePart[]): Promise<void>;
264
266
  /** One month's history (this month by default) beside its spend, and the months that have one. */
265
267
  usage(id: string, month?: string): Promise<UsageHistory>;
@@ -302,7 +302,8 @@ export class State {
302
302
  }
303
303
  /**
304
304
  * Adds one answer's use to a chat or run in this month's history (`usage:YYYY-MM`): one entry a
305
- * chat or run, its parts merged, the newest `USAGE_KEPT` kept. `title` names a new entry only.
305
+ * chat or run, its parts merged, the newest `USAGE_KEPT` kept. `title` names a new entry only;
306
+ * `own_usd` is what of this answer the person's own key or plan paid, added to the entry's.
306
307
  */
307
308
  async addUsage(id, e, parts) {
308
309
  if (!parts.some((p) => p.calls))
@@ -314,6 +315,7 @@ export class State {
314
315
  const prev = i >= 0 ? entries.splice(i, 1)[0] : undefined;
315
316
  const merged = mergeParts(prev?.parts ?? [], parts);
316
317
  const sum = (k) => merged.reduce((a, p) => a + p[k], 0);
318
+ const own = (prev?.own_usd ?? 0) + (e.own_usd ?? 0);
317
319
  entries.unshift({
318
320
  id: e.id,
319
321
  kind: e.kind,
@@ -326,6 +328,7 @@ export class State {
326
328
  read: sum('read'),
327
329
  out: sum('out'),
328
330
  usd: sum('usd'),
331
+ ...(own > 0 ? { own_usd: own } : {}),
329
332
  parts: merged,
330
333
  });
331
334
  return { entries: entries.slice(0, USAGE_KEPT) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ai",
3
- "version": "0.1.233",
3
+ "version": "0.1.235",
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",
@@ -52,8 +52,8 @@
52
52
  "@ai-sdk/openai": "4.0.108",
53
53
  "@anthropic-ai/sdk": "0.133.0",
54
54
  "@cloudflare/think": "0.23.0",
55
- "@columenlabs/lumen-ops": "0.1.233",
56
- "@columenlabs/lumen-ui-types": "0.1.233",
55
+ "@columenlabs/lumen-ops": "0.1.235",
56
+ "@columenlabs/lumen-ui-types": "0.1.235",
57
57
  "agents": "0.32.0",
58
58
  "ai": "7.0.162",
59
59
  "just-bash": "3.6.0",