@columenlabs/lumen-ai 0.1.221 → 0.1.222
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.
|
@@ -49,6 +49,11 @@ export interface AllowanceOptions {
|
|
|
49
49
|
approver?: (caller: Caller) => boolean;
|
|
50
50
|
/** Hears each request and each decision: tell the approvers, then the person. */
|
|
51
51
|
notify?: (n: AllowanceNotice) => void | Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Units a month for one person (`period: 'month'`): their plan's allowance or an admin's override.
|
|
54
|
+
* Nothing (or a throw) falls back to the admin's cap in Settings.
|
|
55
|
+
*/
|
|
56
|
+
cap?: (id: string) => number | null | undefined | Promise<number | null | undefined>;
|
|
52
57
|
}
|
|
53
58
|
/** A request made, or decided. */
|
|
54
59
|
export interface AllowanceNotice {
|
package/dist/assistant/engine.js
CHANGED
|
@@ -140,6 +140,7 @@ export class Assistant {
|
|
|
140
140
|
usd: unit.usd,
|
|
141
141
|
period: al.period ?? 'month',
|
|
142
142
|
starter: al.starter ?? DEFAULT_CAP / unit.usd,
|
|
143
|
+
...(al.cap ? { cap: al.cap } : {}),
|
|
143
144
|
},
|
|
144
145
|
}
|
|
145
146
|
: {}),
|
|
@@ -611,7 +612,7 @@ export class Assistant {
|
|
|
611
612
|
const used = round2(budget.used / u.usd);
|
|
612
613
|
const base = this.state.allowanceConfig?.period === 'once'
|
|
613
614
|
? (this.state.allowanceConfig?.starter ?? total)
|
|
614
|
-
: (await this.state.
|
|
615
|
+
: (await this.state.capFor(caller.id)) / u.usd;
|
|
615
616
|
const waiting = approver
|
|
616
617
|
? (await this.state.requests()).rows.filter((r) => r.status === 'open').length
|
|
617
618
|
: undefined;
|
|
@@ -77,6 +77,8 @@ export interface AllowanceConfig {
|
|
|
77
77
|
period: 'month' | 'once';
|
|
78
78
|
/** Units each person starts with (once); a month's cap is the admin's cap in Settings. */
|
|
79
79
|
starter: number;
|
|
80
|
+
/** Units a month for one person (their plan, an override); nothing falls back to the admin's cap. */
|
|
81
|
+
cap?: (id: string) => number | null | undefined | Promise<number | null | undefined>;
|
|
80
82
|
}
|
|
81
83
|
export interface AllowanceDoc {
|
|
82
84
|
grants: {
|
|
@@ -165,6 +167,9 @@ export declare class State {
|
|
|
165
167
|
total: number;
|
|
166
168
|
used: number;
|
|
167
169
|
}>;
|
|
170
|
+
/** USD a month this person may spend on the app's keys: their own cap when the app names one,
|
|
171
|
+
* else the admin's. A cap that cannot be read falls back too, so an answer never waits on it. */
|
|
172
|
+
capFor(id: string): Promise<number>;
|
|
168
173
|
/** USD a month when nobody set a cap. */
|
|
169
174
|
get defaultCap(): number;
|
|
170
175
|
month(): string;
|
package/dist/assistant/state.js
CHANGED
|
@@ -104,7 +104,14 @@ export class State {
|
|
|
104
104
|
const granted = d.grants
|
|
105
105
|
.filter((g) => monthIn(this.o.timeZone, new Date(g.at)) === month)
|
|
106
106
|
.reduce((a, g) => a + g.amount, 0);
|
|
107
|
-
return { total: (await this.
|
|
107
|
+
return { total: (await this.capFor(id)) + granted * al.usd, used };
|
|
108
|
+
}
|
|
109
|
+
/** USD a month this person may spend on the app's keys: their own cap when the app names one,
|
|
110
|
+
* else the admin's. A cap that cannot be read falls back too, so an answer never waits on it. */
|
|
111
|
+
async capFor(id) {
|
|
112
|
+
const al = this.o.allowance;
|
|
113
|
+
const own = al?.cap ? await Promise.resolve(al.cap(id)).catch(() => null) : null;
|
|
114
|
+
return typeof own === 'number' && own >= 0 ? own * al.usd : this.appCap();
|
|
108
115
|
}
|
|
109
116
|
/** USD a month when nobody set a cap. */
|
|
110
117
|
get defaultCap() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@columenlabs/lumen-ai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.222",
|
|
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.222",
|
|
56
|
+
"@columenlabs/lumen-ui-types": "0.1.222",
|
|
57
57
|
"agents": "0.32.0",
|
|
58
58
|
"ai": "7.0.162",
|
|
59
59
|
"just-bash": "3.6.0",
|