@columenlabs/lumen-ai 0.1.250 → 0.1.251
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/dist/assistant/engine.js
CHANGED
|
@@ -15,7 +15,7 @@ import { aiModel, turnSettings } from '../agent/models.js';
|
|
|
15
15
|
import { bearings } from './bearings.js';
|
|
16
16
|
import { CHATGPT_REDIRECT, SigninError, finishChatgpt, startChatgpt, testChatgpt, } from './chatgpt.js';
|
|
17
17
|
import { ALL_MODELS, DEFAULT_OUT, Meter, PROVIDERS, XAI_BASE_URL, effortParams, } from './models.js';
|
|
18
|
-
import { DEFAULT_CAP, State, keyDocName, keyState, ownKeyUsd, planDocName, waitText, withProvider, } from './state.js';
|
|
18
|
+
import { DEFAULT_CAP, State, keyDocName, keyState, ownKeyUsd, ownPlanCalls, planDocName, waitText, withProvider, } from './state.js';
|
|
19
19
|
import { Docs } from './store.js';
|
|
20
20
|
import { toolName, withDeadline } from './tools.js';
|
|
21
21
|
import { scrapeqlTools, webFetchTools } from './web.js';
|
|
@@ -408,6 +408,7 @@ export class Assistant {
|
|
|
408
408
|
kind: 'chat',
|
|
409
409
|
title: message.split('\n')[0] || 'Chat',
|
|
410
410
|
own_usd: ownKeyUsd(paying, onPayer),
|
|
411
|
+
own_plan_calls: ownPlanCalls(paying, onPayer),
|
|
411
412
|
}, end.parts)
|
|
412
413
|
.catch(() => undefined);
|
|
413
414
|
const total = end.parts.reduce((a, m) => ({
|
|
@@ -1076,6 +1077,7 @@ export class Assistant {
|
|
|
1076
1077
|
task: o.task,
|
|
1077
1078
|
title: o.run?.title ?? task?.label ?? o.task,
|
|
1078
1079
|
own_usd: ownKeyUsd(paying, [part]),
|
|
1080
|
+
own_plan_calls: ownPlanCalls(paying, [part]),
|
|
1079
1081
|
}, [part])
|
|
1080
1082
|
.catch(() => undefined);
|
|
1081
1083
|
}
|
|
@@ -1164,6 +1166,7 @@ export class Assistant {
|
|
|
1164
1166
|
task: o.task,
|
|
1165
1167
|
title: o.run?.title ?? task?.label ?? o.task,
|
|
1166
1168
|
own_usd: ownKeyUsd(paying, [part]),
|
|
1169
|
+
own_plan_calls: ownPlanCalls(paying, [part]),
|
|
1167
1170
|
}, [part])
|
|
1168
1171
|
.catch(() => undefined);
|
|
1169
1172
|
}
|
|
@@ -111,6 +111,11 @@ export declare function ownKeyUsd(paying: {
|
|
|
111
111
|
payer: AssistantPayer;
|
|
112
112
|
plans: Paying['plans'];
|
|
113
113
|
}, parts: UsagePart[]): number;
|
|
114
|
+
/** Calls in `parts` a plan sign-in of the person's answered (their own payer, a plan provider). */
|
|
115
|
+
export declare function ownPlanCalls(paying: {
|
|
116
|
+
payer: AssistantPayer;
|
|
117
|
+
plans: Paying['plans'];
|
|
118
|
+
}, parts: UsagePart[]): number;
|
|
114
119
|
/**
|
|
115
120
|
* What counts toward the person's own cap: own rows paid by an API key (a plan sign-in costs
|
|
116
121
|
* nothing per call), on a provider they can still pay with. A row from before ways were recorded
|
|
@@ -276,7 +281,8 @@ export declare class State {
|
|
|
276
281
|
/**
|
|
277
282
|
* Adds one answer's use to a chat or run in this month's history (`usage:YYYY-MM`): one entry a
|
|
278
283
|
* chat or run, its parts merged, the newest `USAGE_KEPT` kept. `title` names a new entry only;
|
|
279
|
-
* `own_usd` is what of this answer the person's own key or plan paid, added to the entry's
|
|
284
|
+
* `own_usd` is what of this answer the person's own key or plan paid, added to the entry's;
|
|
285
|
+
* `own_plan_calls` the calls their plan sign-in answered (free to them, so counted, not priced).
|
|
280
286
|
*/
|
|
281
287
|
addUsage(id: string, e: {
|
|
282
288
|
id: string;
|
|
@@ -284,6 +290,7 @@ export declare class State {
|
|
|
284
290
|
task?: string;
|
|
285
291
|
title: string;
|
|
286
292
|
own_usd?: number;
|
|
293
|
+
own_plan_calls?: number;
|
|
287
294
|
}, parts: UsagePart[]): Promise<void>;
|
|
288
295
|
/** One month's history (this month by default) beside its spend, and the months that have one. */
|
|
289
296
|
usage(id: string, month?: string): Promise<UsageHistory>;
|
package/dist/assistant/state.js
CHANGED
|
@@ -32,6 +32,17 @@ export function ownKeyUsd(paying, parts) {
|
|
|
32
32
|
})
|
|
33
33
|
.reduce((a, p) => a + p.usd, 0);
|
|
34
34
|
}
|
|
35
|
+
/** Calls in `parts` a plan sign-in of the person's answered (their own payer, a plan provider). */
|
|
36
|
+
export function ownPlanCalls(paying, parts) {
|
|
37
|
+
if (paying.payer !== 'own')
|
|
38
|
+
return 0;
|
|
39
|
+
return parts
|
|
40
|
+
.filter((p) => {
|
|
41
|
+
const prov = providerOfPart(p);
|
|
42
|
+
return !!(prov && paying.plans[prov]);
|
|
43
|
+
})
|
|
44
|
+
.reduce((a, p) => a + p.calls, 0);
|
|
45
|
+
}
|
|
35
46
|
/**
|
|
36
47
|
* What counts toward the person's own cap: own rows paid by an API key (a plan sign-in costs
|
|
37
48
|
* nothing per call), on a provider they can still pay with. A row from before ways were recorded
|
|
@@ -352,7 +363,8 @@ export class State {
|
|
|
352
363
|
/**
|
|
353
364
|
* Adds one answer's use to a chat or run in this month's history (`usage:YYYY-MM`): one entry a
|
|
354
365
|
* chat or run, its parts merged, the newest `USAGE_KEPT` kept. `title` names a new entry only;
|
|
355
|
-
* `own_usd` is what of this answer the person's own key or plan paid, added to the entry's
|
|
366
|
+
* `own_usd` is what of this answer the person's own key or plan paid, added to the entry's;
|
|
367
|
+
* `own_plan_calls` the calls their plan sign-in answered (free to them, so counted, not priced).
|
|
356
368
|
*/
|
|
357
369
|
async addUsage(id, e, parts) {
|
|
358
370
|
if (!parts.some((p) => p.calls))
|
|
@@ -365,6 +377,7 @@ export class State {
|
|
|
365
377
|
const merged = mergeParts(prev?.parts ?? [], parts);
|
|
366
378
|
const sum = (k) => merged.reduce((a, p) => a + p[k], 0);
|
|
367
379
|
const own = (prev?.own_usd ?? 0) + (e.own_usd ?? 0);
|
|
380
|
+
const plan = (prev?.own_plan_calls ?? 0) + (e.own_plan_calls ?? 0);
|
|
368
381
|
entries.unshift({
|
|
369
382
|
id: e.id,
|
|
370
383
|
kind: e.kind,
|
|
@@ -378,6 +391,7 @@ export class State {
|
|
|
378
391
|
out: sum('out'),
|
|
379
392
|
usd: sum('usd'),
|
|
380
393
|
...(own > 0 ? { own_usd: own } : {}),
|
|
394
|
+
...(plan > 0 ? { own_plan_calls: plan } : {}),
|
|
381
395
|
parts: merged,
|
|
382
396
|
});
|
|
383
397
|
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.
|
|
3
|
+
"version": "0.1.251",
|
|
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.
|
|
56
|
-
"@columenlabs/lumen-ui-types": "0.1.
|
|
55
|
+
"@columenlabs/lumen-ops": "0.1.251",
|
|
56
|
+
"@columenlabs/lumen-ui-types": "0.1.251",
|
|
57
57
|
"agents": "0.32.0",
|
|
58
58
|
"ai": "7.0.162",
|
|
59
59
|
"just-bash": "3.6.0",
|