@vellumai/cli 0.11.9 → 0.11.10-dev.202609090222.f16830b

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.
Files changed (19) hide show
  1. package/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/package.json +3 -1
  2. package/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
  3. package/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
  4. package/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
  5. package/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  6. package/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
  7. package/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
  8. package/node_modules/@vellumai/service-contracts/package.json +3 -1
  9. package/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
  10. package/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
  11. package/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
  12. package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  13. package/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
  14. package/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
  15. package/package.json +1 -1
  16. package/src/lib/live-voice/client.test.ts +1 -0
  17. package/src/lib/live-voice/client.ts +1 -0
  18. package/src/lib/live-voice/protocol.ts +5 -0
  19. package/src/lib/provider-secrets.ts +4 -1
@@ -10,6 +10,7 @@
10
10
  "./conversation-handle": "./src/conversation-handle.ts",
11
11
  "./client-metadata": "./src/client-metadata.ts",
12
12
  "./credential-rpc": "./src/credential-rpc.ts",
13
+ "./desktop-presence": "./src/desktop-presence.ts",
13
14
  "./ingress": "./src/ingress.ts",
14
15
  "./no-response": "./src/no-response.ts",
15
16
  "./remote-web-pairing": "./src/remote-web-pairing.ts",
@@ -25,7 +26,8 @@
25
26
  "./error": "./src/error.ts",
26
27
  "./reactions": "./src/reactions.ts",
27
28
  "./guardian-requests": "./src/guardian-requests.ts",
28
- "./platform-credential": "./src/platform-credential.ts"
29
+ "./platform-credential": "./src/platform-credential.ts",
30
+ "./plan-credit": "./src/plan-credit.ts"
29
31
  },
30
32
  "scripts": {
31
33
  "typecheck": "bunx tsc --noEmit",
@@ -0,0 +1,51 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import {
4
+ extraCreditUsd,
5
+ planCreditUsedFraction,
6
+ usageGrantRatio,
7
+ } from "../plan-credit.js";
8
+
9
+ describe("usageGrantRatio", () => {
10
+ test("reads the used share and clamps to 0..1", () => {
11
+ expect(usageGrantRatio(20, 9.1)).toBeCloseTo(0.545);
12
+ expect(usageGrantRatio(20, 0)).toBe(1);
13
+ expect(usageGrantRatio(20, 25)).toBe(0);
14
+ });
15
+
16
+ test("has no reading without both figures or with nothing granted", () => {
17
+ expect(usageGrantRatio(null, 5)).toBeNull();
18
+ expect(usageGrantRatio(20, null)).toBeNull();
19
+ expect(usageGrantRatio(0, 0)).toBeNull();
20
+ });
21
+ });
22
+
23
+ describe("planCreditUsedFraction", () => {
24
+ test("prefers the ratio whatever the plan", () => {
25
+ expect(planCreditUsedFraction(20, 9.1, "base")).toBeCloseTo(0.545);
26
+ expect(planCreditUsedFraction(20, 9.1, null)).toBeCloseTo(0.545);
27
+ });
28
+
29
+ test("treats a Pro plan with nothing granted as fully spent", () => {
30
+ expect(planCreditUsedFraction(0, 0, "pro")).toBe(1);
31
+ expect(planCreditUsedFraction(0, null, "pro")).toBe(1);
32
+ });
33
+
34
+ test("gives a base or unknown plan with nothing granted no reading", () => {
35
+ expect(planCreditUsedFraction(0, 0, "base")).toBeNull();
36
+ expect(planCreditUsedFraction(0, 0, null)).toBeNull();
37
+ expect(planCreditUsedFraction(null, null, "pro")).toBeNull();
38
+ });
39
+ });
40
+
41
+ describe("extraCreditUsd", () => {
42
+ test("nets unused grant credit out of the balance to the cent", () => {
43
+ expect(extraCreditUsd(42.17, 9.1)).toBe(33.07);
44
+ expect(extraCreditUsd(34.65, 9.1)).toBe(25.55);
45
+ });
46
+
47
+ test("never goes below zero", () => {
48
+ expect(extraCreditUsd(5, 9.1)).toBe(0);
49
+ expect(extraCreditUsd(-2.5, 0)).toBe(0);
50
+ });
51
+ });
@@ -38,6 +38,8 @@ const FIXTURES: Record<string, string> = {
38
38
  "GitLab Token": `glpat-${filler(20)}`,
39
39
  "Stripe Secret Key": `sk_live_${filler(24)}`,
40
40
  "Stripe Restricted Key": `rk_live_${filler(24)}`,
41
+ "Link Access Token": `liwltoken_${filler(24)}`,
42
+ "Link Refresh Token": `liwlrefresh_${filler(24)}`,
41
43
  "Slack Bot Token": `xoxb-1234567890-1234567890-${filler(24)}`,
42
44
  "Slack User Token": `xoxp-1234567890-1234567890-1234567890-${"0123456789abcdef".repeat(2)}`,
43
45
  "Slack App Token": "xapp-1-abc123-4567-defghij890",
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The presence states a desktop client may report. Single runtime source for
3
+ * the daemon's stored type, the client route's wire enum, and the Electron
4
+ * presence monitor.
5
+ *
6
+ * Member order is load-bearing: the route feeds this tuple to `z.enum`, so
7
+ * reordering rewrites the generated `assistant/openapi.yaml`.
8
+ */
9
+ export const DESKTOP_PRESENCE_STATES = ["active", "idle", "away"] as const;
10
+
11
+ export type DesktopPresenceState = (typeof DESKTOP_PRESENCE_STATES)[number];
@@ -28,6 +28,7 @@ export * from "./rpc.js";
28
28
  export * from "./trust-rules.js";
29
29
  export * from "./ingress.js";
30
30
  export * from "./no-response.js";
31
+ export * from "./plan-credit.js";
31
32
  export * from "./platform-credential.js";
32
33
  export * from "./remote-web-pairing.js";
33
34
  export * from "./twilio-ingress.js";
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Plan-credit derivations shared by the assistant runtime's `platform credits`
3
+ * route and the web client's usage meter, so both read the billing summary's
4
+ * grant figures the same way and can never quote different readings.
5
+ */
6
+
7
+ export type BillingPlanId = "base" | "pro";
8
+
9
+ function clamp01(value: number): number {
10
+ if (!Number.isFinite(value) || value < 0) {
11
+ return 0;
12
+ }
13
+ return value > 1 ? 1 : value;
14
+ }
15
+
16
+ /**
17
+ * How much of the usage credit an account was granted it has already used:
18
+ * the granted total less what is still unused, over that total. The initial
19
+ * $5 grant burns 0 to 100% as it is spent, and a further grant grows the total
20
+ * so the bar drops back. Null when nothing was ever granted, or when the
21
+ * platform reports neither figure, which has no honest reading rather than a
22
+ * full or empty bar.
23
+ */
24
+ export function usageGrantRatio(
25
+ totalUsd: number | null,
26
+ availableUsd: number | null,
27
+ ): number | null {
28
+ if (totalUsd == null || availableUsd == null || totalUsd <= 0) {
29
+ return null;
30
+ }
31
+ return clamp01((totalUsd - availableUsd) / totalUsd);
32
+ }
33
+
34
+ /**
35
+ * The plan-credit reading with the plan's fallback applied. The grant figures
36
+ * count only unexpired grants, so a Pro subscription whose grants total
37
+ * nothing has used or expired everything it was granted (a full bar, with
38
+ * nothing scheduled to refill it), while a base plan in that position was
39
+ * never granted anything (no reading). An unknown plan gets the ratio when
40
+ * the figures allow one and no fallback otherwise.
41
+ */
42
+ export function planCreditUsedFraction(
43
+ totalUsd: number | null,
44
+ availableUsd: number | null,
45
+ planId: BillingPlanId | null,
46
+ ): number | null {
47
+ const ratio = usageGrantRatio(totalUsd, availableUsd);
48
+ if (ratio != null) {
49
+ return ratio;
50
+ }
51
+ if (planId === "pro" && totalUsd != null && totalUsd <= 0) {
52
+ return 1;
53
+ }
54
+ return null;
55
+ }
56
+
57
+ /**
58
+ * Credit bought or earned on top of the plan-included grants: the balance less
59
+ * whatever is still unused on those grants, never below zero, to the cent.
60
+ */
61
+ export function extraCreditUsd(
62
+ balanceUsd: number,
63
+ availableUsd: number,
64
+ ): number {
65
+ return Math.round(Math.max(0, balanceUsd - availableUsd) * 100) / 100;
66
+ }
@@ -143,6 +143,13 @@ export const PREFIX_PATTERNS: SecretPrefixPattern[] = [
143
143
  // -- Stripe --
144
144
  { label: "Stripe Secret Key", regex: /sk_live_[A-Za-z0-9]{24,}/ },
145
145
  { label: "Stripe Restricted Key", regex: /rk_live_[A-Za-z0-9]{24,}/ },
146
+ // Link (Stripe's wallet) issues prefixed OAuth tokens rather than opaque
147
+ // ones, and its own docs tell users to export the access token as
148
+ // LINK_ACCESS_TOKEN to drive link-cli, so these do get pasted by hand. A
149
+ // leaked one can spend from the wallet. The `lwlpk_` client id is public
150
+ // (it ships in the CLI bundle) and is deliberately not matched here.
151
+ { label: "Link Access Token", regex: /liwltoken_[A-Za-z0-9]{16,}/ },
152
+ { label: "Link Refresh Token", regex: /liwlrefresh_[A-Za-z0-9]{16,}/ },
146
153
 
147
154
  // -- Slack --
148
155
  {
@@ -10,6 +10,7 @@
10
10
  "./conversation-handle": "./src/conversation-handle.ts",
11
11
  "./client-metadata": "./src/client-metadata.ts",
12
12
  "./credential-rpc": "./src/credential-rpc.ts",
13
+ "./desktop-presence": "./src/desktop-presence.ts",
13
14
  "./ingress": "./src/ingress.ts",
14
15
  "./no-response": "./src/no-response.ts",
15
16
  "./remote-web-pairing": "./src/remote-web-pairing.ts",
@@ -25,7 +26,8 @@
25
26
  "./error": "./src/error.ts",
26
27
  "./reactions": "./src/reactions.ts",
27
28
  "./guardian-requests": "./src/guardian-requests.ts",
28
- "./platform-credential": "./src/platform-credential.ts"
29
+ "./platform-credential": "./src/platform-credential.ts",
30
+ "./plan-credit": "./src/plan-credit.ts"
29
31
  },
30
32
  "scripts": {
31
33
  "typecheck": "bunx tsc --noEmit",
@@ -0,0 +1,51 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import {
4
+ extraCreditUsd,
5
+ planCreditUsedFraction,
6
+ usageGrantRatio,
7
+ } from "../plan-credit.js";
8
+
9
+ describe("usageGrantRatio", () => {
10
+ test("reads the used share and clamps to 0..1", () => {
11
+ expect(usageGrantRatio(20, 9.1)).toBeCloseTo(0.545);
12
+ expect(usageGrantRatio(20, 0)).toBe(1);
13
+ expect(usageGrantRatio(20, 25)).toBe(0);
14
+ });
15
+
16
+ test("has no reading without both figures or with nothing granted", () => {
17
+ expect(usageGrantRatio(null, 5)).toBeNull();
18
+ expect(usageGrantRatio(20, null)).toBeNull();
19
+ expect(usageGrantRatio(0, 0)).toBeNull();
20
+ });
21
+ });
22
+
23
+ describe("planCreditUsedFraction", () => {
24
+ test("prefers the ratio whatever the plan", () => {
25
+ expect(planCreditUsedFraction(20, 9.1, "base")).toBeCloseTo(0.545);
26
+ expect(planCreditUsedFraction(20, 9.1, null)).toBeCloseTo(0.545);
27
+ });
28
+
29
+ test("treats a Pro plan with nothing granted as fully spent", () => {
30
+ expect(planCreditUsedFraction(0, 0, "pro")).toBe(1);
31
+ expect(planCreditUsedFraction(0, null, "pro")).toBe(1);
32
+ });
33
+
34
+ test("gives a base or unknown plan with nothing granted no reading", () => {
35
+ expect(planCreditUsedFraction(0, 0, "base")).toBeNull();
36
+ expect(planCreditUsedFraction(0, 0, null)).toBeNull();
37
+ expect(planCreditUsedFraction(null, null, "pro")).toBeNull();
38
+ });
39
+ });
40
+
41
+ describe("extraCreditUsd", () => {
42
+ test("nets unused grant credit out of the balance to the cent", () => {
43
+ expect(extraCreditUsd(42.17, 9.1)).toBe(33.07);
44
+ expect(extraCreditUsd(34.65, 9.1)).toBe(25.55);
45
+ });
46
+
47
+ test("never goes below zero", () => {
48
+ expect(extraCreditUsd(5, 9.1)).toBe(0);
49
+ expect(extraCreditUsd(-2.5, 0)).toBe(0);
50
+ });
51
+ });
@@ -38,6 +38,8 @@ const FIXTURES: Record<string, string> = {
38
38
  "GitLab Token": `glpat-${filler(20)}`,
39
39
  "Stripe Secret Key": `sk_live_${filler(24)}`,
40
40
  "Stripe Restricted Key": `rk_live_${filler(24)}`,
41
+ "Link Access Token": `liwltoken_${filler(24)}`,
42
+ "Link Refresh Token": `liwlrefresh_${filler(24)}`,
41
43
  "Slack Bot Token": `xoxb-1234567890-1234567890-${filler(24)}`,
42
44
  "Slack User Token": `xoxp-1234567890-1234567890-1234567890-${"0123456789abcdef".repeat(2)}`,
43
45
  "Slack App Token": "xapp-1-abc123-4567-defghij890",
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The presence states a desktop client may report. Single runtime source for
3
+ * the daemon's stored type, the client route's wire enum, and the Electron
4
+ * presence monitor.
5
+ *
6
+ * Member order is load-bearing: the route feeds this tuple to `z.enum`, so
7
+ * reordering rewrites the generated `assistant/openapi.yaml`.
8
+ */
9
+ export const DESKTOP_PRESENCE_STATES = ["active", "idle", "away"] as const;
10
+
11
+ export type DesktopPresenceState = (typeof DESKTOP_PRESENCE_STATES)[number];
@@ -28,6 +28,7 @@ export * from "./rpc.js";
28
28
  export * from "./trust-rules.js";
29
29
  export * from "./ingress.js";
30
30
  export * from "./no-response.js";
31
+ export * from "./plan-credit.js";
31
32
  export * from "./platform-credential.js";
32
33
  export * from "./remote-web-pairing.js";
33
34
  export * from "./twilio-ingress.js";
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Plan-credit derivations shared by the assistant runtime's `platform credits`
3
+ * route and the web client's usage meter, so both read the billing summary's
4
+ * grant figures the same way and can never quote different readings.
5
+ */
6
+
7
+ export type BillingPlanId = "base" | "pro";
8
+
9
+ function clamp01(value: number): number {
10
+ if (!Number.isFinite(value) || value < 0) {
11
+ return 0;
12
+ }
13
+ return value > 1 ? 1 : value;
14
+ }
15
+
16
+ /**
17
+ * How much of the usage credit an account was granted it has already used:
18
+ * the granted total less what is still unused, over that total. The initial
19
+ * $5 grant burns 0 to 100% as it is spent, and a further grant grows the total
20
+ * so the bar drops back. Null when nothing was ever granted, or when the
21
+ * platform reports neither figure, which has no honest reading rather than a
22
+ * full or empty bar.
23
+ */
24
+ export function usageGrantRatio(
25
+ totalUsd: number | null,
26
+ availableUsd: number | null,
27
+ ): number | null {
28
+ if (totalUsd == null || availableUsd == null || totalUsd <= 0) {
29
+ return null;
30
+ }
31
+ return clamp01((totalUsd - availableUsd) / totalUsd);
32
+ }
33
+
34
+ /**
35
+ * The plan-credit reading with the plan's fallback applied. The grant figures
36
+ * count only unexpired grants, so a Pro subscription whose grants total
37
+ * nothing has used or expired everything it was granted (a full bar, with
38
+ * nothing scheduled to refill it), while a base plan in that position was
39
+ * never granted anything (no reading). An unknown plan gets the ratio when
40
+ * the figures allow one and no fallback otherwise.
41
+ */
42
+ export function planCreditUsedFraction(
43
+ totalUsd: number | null,
44
+ availableUsd: number | null,
45
+ planId: BillingPlanId | null,
46
+ ): number | null {
47
+ const ratio = usageGrantRatio(totalUsd, availableUsd);
48
+ if (ratio != null) {
49
+ return ratio;
50
+ }
51
+ if (planId === "pro" && totalUsd != null && totalUsd <= 0) {
52
+ return 1;
53
+ }
54
+ return null;
55
+ }
56
+
57
+ /**
58
+ * Credit bought or earned on top of the plan-included grants: the balance less
59
+ * whatever is still unused on those grants, never below zero, to the cent.
60
+ */
61
+ export function extraCreditUsd(
62
+ balanceUsd: number,
63
+ availableUsd: number,
64
+ ): number {
65
+ return Math.round(Math.max(0, balanceUsd - availableUsd) * 100) / 100;
66
+ }
@@ -143,6 +143,13 @@ export const PREFIX_PATTERNS: SecretPrefixPattern[] = [
143
143
  // -- Stripe --
144
144
  { label: "Stripe Secret Key", regex: /sk_live_[A-Za-z0-9]{24,}/ },
145
145
  { label: "Stripe Restricted Key", regex: /rk_live_[A-Za-z0-9]{24,}/ },
146
+ // Link (Stripe's wallet) issues prefixed OAuth tokens rather than opaque
147
+ // ones, and its own docs tell users to export the access token as
148
+ // LINK_ACCESS_TOKEN to drive link-cli, so these do get pasted by hand. A
149
+ // leaked one can spend from the wallet. The `lwlpk_` client id is public
150
+ // (it ships in the CLI bundle) and is deliberately not matched here.
151
+ { label: "Link Access Token", regex: /liwltoken_[A-Za-z0-9]{16,}/ },
152
+ { label: "Link Refresh Token", regex: /liwlrefresh_[A-Za-z0-9]{16,}/ },
146
153
 
147
154
  // -- Slack --
148
155
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/cli",
3
- "version": "0.11.9",
3
+ "version": "0.11.10-dev.202609090222.f16830b",
4
4
  "description": "CLI tools for vellum-assistant",
5
5
  "type": "module",
6
6
  "exports": {
@@ -70,6 +70,7 @@ describe("start frame", () => {
70
70
  const start = socket.sentFrames()[0]!;
71
71
 
72
72
  expect(start.type).toBe("start");
73
+ expect(start.entry).toBe("cli");
73
74
  // Load-bearing: without it the daemon refuses a session whose speech-to-text
74
75
  // credential is missing, which is the case this client exists to survive.
75
76
  expect(start.textInput).toBe(true);
@@ -205,6 +205,7 @@ export class CliLiveVoiceClient {
205
205
  type: "start",
206
206
  audio: LIVE_VOICE_AUDIO_FORMAT,
207
207
  textInput: true,
208
+ entry: "cli",
208
209
  ...(this.options.conversationId
209
210
  ? { conversationId: this.options.conversationId }
210
211
  : {}),
@@ -43,6 +43,11 @@ export interface LiveVoiceStartFrame {
43
43
  * loses nothing: it was never going to listen.
44
44
  */
45
45
  readonly textInput: true;
46
+ /**
47
+ * Where the session was started from, for the daemon's telemetry. There is
48
+ * one way in from a terminal, so the value is a constant.
49
+ */
50
+ readonly entry: "cli";
46
51
  }
47
52
 
48
53
  export interface LiveVoiceTextFrame {
@@ -223,7 +223,10 @@ export function inferProviderFromModel(model: string): string | undefined {
223
223
  if (model.startsWith("accounts/fireworks/models/")) {
224
224
  return "fireworks";
225
225
  }
226
- if (model.startsWith("openai/gpt-5.6")) {
226
+ if (
227
+ model.startsWith("openai/gpt-5.6") ||
228
+ model.startsWith("openai/gpt-6-astra")
229
+ ) {
227
230
  // Listed by OpenRouter (#37856), the earlier catalog entry; the Vercel
228
231
  // AI Gateway does not carry these IDs.
229
232
  return "openrouter";