@omercnet/paseo-omp 5.6.4-next.495.1 → 5.6.4-next.497.1

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/README.md CHANGED
@@ -35,6 +35,8 @@ Open the **OMP** sidebar to review the provider-profile contract, choose which c
35
35
 
36
36
  Open the **Accounts** tab of the **OMP** sidebar to see the logins in OMP's own credential store with their usage and banked resets, add a login through OMP's own sign-in, sign one out, spend a banked reset, and steer OMP's balancing: prefer a login, keep part of its quota in reserve, and set what OMP does at a limit. Steering is written to OMP's own config. See [OMP accounts](docs/configuration.md#omp-accounts).
37
37
 
38
+ The quota popover groups recorded limits by provider and OMP account, showing an available recorded email across that account's windows. Duplicate and unnamed accounts receive numbers in opaque account-key order, so changing usage does not swap their numbers; accounts are still displayed by highest usage. Duplicate-name suffixes stay visible when long emails truncate, and a lone unnamed account needs no heading. Only a server-side SHA-256 hash of the account key reaches the client; account IDs and enterprise hosts are not returned. **CURRENT PROVIDER** identifies the session's provider, not its active account. Provider summary percentages show the highest recorded usage across that provider's accounts.
39
+
38
40
  Open the **MCPs** tab of the **OMP** sidebar to list the MCP servers OMP connects to, add one by URL or command, test, enable, disable or remove it, and sign a remote server in through your browser, like **Accounts** does for logins. See [OMP MCP servers](docs/configuration.md#omp-mcp-servers).
39
41
 
40
42
  - [Install, update, rollback, and local development](docs/installation.md)
@@ -84,6 +84,15 @@ export function QuotaPopover(props: PluginButtonContentProps) {
84
84
  overflow: "hidden" as const,
85
85
  },
86
86
  detail: { color: theme.colors.foregroundMuted, fontSize: 11 },
87
+ account: { gap: 6, paddingTop: 4 },
88
+ accountHeading: { flexDirection: "row" as const, alignItems: "baseline" as const },
89
+ accountLabel: {
90
+ color: theme.colors.foregroundMuted,
91
+ fontSize: 11,
92
+ flexShrink: 1,
93
+ minWidth: 0,
94
+ },
95
+ accountSuffix: { color: theme.colors.foregroundMuted, fontSize: 11, flexShrink: 0 },
87
96
  }),
88
97
  [layout.compact, theme],
89
98
  );
@@ -104,6 +113,11 @@ export function QuotaPopover(props: PluginButtonContentProps) {
104
113
  <Text style={styles.muted}>
105
114
  Last recorded usage from the local agent database, not read live from the provider.
106
115
  </Text>
116
+ {currentProvider ? (
117
+ <Text style={styles.muted}>
118
+ CURRENT PROVIDER identifies the provider, not the account used by this session.
119
+ </Text>
120
+ ) : null}
107
121
  {currentProvider && !hasCurrent ? (
108
122
  <Text style={styles.muted}>
109
123
  {`No recorded quota yet for ${quotaProviderLabel(currentProvider)} (this session's provider).`}
@@ -120,32 +134,54 @@ export function QuotaPopover(props: PluginButtonContentProps) {
120
134
  color={severityColor(group.severity)}
121
135
  />
122
136
  <Text style={styles.groupLabel}>{quotaProviderLabel(group.provider)}</Text>
123
- <Text style={styles.badge}>{current ? "CURRENT" : "RECORDED"}</Text>
137
+ <Text style={styles.badge}>{current ? "CURRENT PROVIDER" : "RECORDED"}</Text>
124
138
  </View>
125
- {group.quotas.map((quota) => {
126
- const severity = quotaSeverityFromFraction(quota.usedFraction);
127
- const color = severityColor(severity);
128
- const pct =
129
- quota.usedFraction === null
130
- ? 0
131
- : Math.min(100, Math.round(quota.usedFraction * 100));
132
- return (
133
- <View key={`${quota.label}:${quota.windowLabel}`} style={styles.row}>
134
- <View style={styles.rowHeader}>
135
- <Text numberOfLines={1} style={styles.rowLabel}>
136
- {quota.label}
137
- </Text>
138
- <Text style={[styles.rowValue, { color }]}>
139
- {quota.usedFraction === null ? "Unknown" : `${pct}%`}
139
+ {group.accounts.map((account) => (
140
+ <View key={account.accountKey} style={styles.account}>
141
+ {account.label ? (
142
+ <View
143
+ accessibilityRole="header"
144
+ accessibilityLabel={
145
+ account.suffix ? `${account.label} · ${account.suffix}` : account.label
146
+ }
147
+ style={styles.accountHeading}
148
+ >
149
+ <Text numberOfLines={1} ellipsizeMode="middle" style={styles.accountLabel}>
150
+ {account.label}
140
151
  </Text>
152
+ {account.suffix ? (
153
+ <Text style={styles.accountSuffix}>{` · ${account.suffix}`}</Text>
154
+ ) : null}
141
155
  </View>
142
- <View style={styles.track}>
143
- <View style={{ height: "100%", width: `${pct}%`, backgroundColor: color }} />
144
- </View>
145
- <Text style={styles.detail}>{quotaDetailLabel(quota)}</Text>
146
- </View>
147
- );
148
- })}
156
+ ) : null}
157
+ {account.quotas.map((quota) => {
158
+ const severity = quotaSeverityFromFraction(quota.usedFraction);
159
+ const color = severityColor(severity);
160
+ const pct =
161
+ quota.usedFraction === null
162
+ ? 0
163
+ : Math.min(100, Math.round(quota.usedFraction * 100));
164
+ return (
165
+ <View key={quota.limitId} style={styles.row}>
166
+ <View style={styles.rowHeader}>
167
+ <Text numberOfLines={1} style={styles.rowLabel}>
168
+ {quota.label}
169
+ </Text>
170
+ <Text style={[styles.rowValue, { color }]}>
171
+ {quota.usedFraction === null ? "Unknown" : `${pct}%`}
172
+ </Text>
173
+ </View>
174
+ <View style={styles.track}>
175
+ <View
176
+ style={{ height: "100%", width: `${pct}%`, backgroundColor: color }}
177
+ />
178
+ </View>
179
+ <Text style={styles.detail}>{quotaDetailLabel(quota)}</Text>
180
+ </View>
181
+ );
182
+ })}
183
+ </View>
184
+ ))}
149
185
  </View>
150
186
  );
151
187
  })}
@@ -91,9 +91,19 @@ export function quotaSeverityForProvider(
91
91
  return used.length === 0 ? "unknown" : quotaSeverityFromFraction(Math.max(...used));
92
92
  }
93
93
 
94
+ export type QuotaAccountGroup = {
95
+ accountKey: string;
96
+ email: string | null;
97
+ label: string | null;
98
+ suffix: string | null;
99
+ quotas: OmpQuota[];
100
+ peakFraction: number | null;
101
+ severity: QuotaSeverity;
102
+ };
103
+
94
104
  export type QuotaProviderGroup = {
95
105
  provider: string;
96
- quotas: OmpQuota[];
106
+ accounts: QuotaAccountGroup[];
97
107
  peakFraction: number | null;
98
108
  severity: QuotaSeverity;
99
109
  };
@@ -118,7 +128,7 @@ export function quotaProviderGroups(
118
128
  const peakFraction = used.length === 0 ? null : Math.max(...used);
119
129
  return {
120
130
  provider,
121
- quotas: [...providerQuotas].sort((a, b) => (b.usedFraction ?? -1) - (a.usedFraction ?? -1)),
131
+ accounts: quotaAccountGroups(providerQuotas),
122
132
  peakFraction,
123
133
  severity: quotaSeverityFromFraction(peakFraction),
124
134
  };
@@ -131,6 +141,62 @@ export function quotaProviderGroups(
131
141
  return groups;
132
142
  }
133
143
 
144
+ function quotaAccountGroups(quotas: readonly OmpQuota[]): QuotaAccountGroup[] {
145
+ const byAccount = new Map<string, OmpQuota[]>();
146
+ for (const quota of quotas) {
147
+ const group = byAccount.get(quota.accountKey);
148
+ if (group) group.push(quota);
149
+ else byAccount.set(quota.accountKey, [quota]);
150
+ }
151
+ const accounts: QuotaAccountGroup[] = [...byAccount.entries()].map(
152
+ ([accountKey, accountQuotas]) => {
153
+ const used = accountQuotas.flatMap((quota) =>
154
+ quota.usedFraction === null ? [] : [quota.usedFraction],
155
+ );
156
+ const peakFraction = used.length === 0 ? null : Math.max(...used);
157
+ const email = accountQuotas.find((quota) => quota.email?.trim())?.email?.trim() ?? null;
158
+ return {
159
+ accountKey,
160
+ email,
161
+ label: email,
162
+ suffix: null,
163
+ quotas: [...accountQuotas].sort((a, b) => (b.usedFraction ?? -1) - (a.usedFraction ?? -1)),
164
+ peakFraction,
165
+ severity: quotaSeverityFromFraction(peakFraction),
166
+ };
167
+ },
168
+ );
169
+ accounts.sort((a, b) => a.accountKey.localeCompare(b.accountKey));
170
+ const labelCounts = new Map<string, number>();
171
+ for (const account of accounts) {
172
+ if (account.label) {
173
+ labelCounts.set(account.label, (labelCounts.get(account.label) ?? 0) + 1);
174
+ }
175
+ }
176
+ const labelIndexes = new Map<string, number>();
177
+ let unnamedAccounts = 0;
178
+ for (const account of accounts) {
179
+ if (!account.label && accounts.length > 1) {
180
+ account.label = `Account ${++unnamedAccounts}`;
181
+ continue;
182
+ }
183
+ if (!account.label) {
184
+ continue;
185
+ }
186
+ const label = account.label;
187
+ const index = (labelIndexes.get(label) ?? 0) + 1;
188
+ labelIndexes.set(label, index);
189
+ if ((labelCounts.get(label) ?? 0) > 1) {
190
+ account.suffix = `Account ${index}`;
191
+ }
192
+ }
193
+ accounts.sort(
194
+ (a, b) =>
195
+ (b.peakFraction ?? -1) - (a.peakFraction ?? -1) || a.accountKey.localeCompare(b.accountKey),
196
+ );
197
+ return accounts;
198
+ }
199
+
134
200
  export function quotaResetLabel(resetsAtMs: number | null, nowMs: number = Date.now()): string {
135
201
  if (resetsAtMs === null) return "";
136
202
  const remainingMs = Math.max(0, resetsAtMs - nowMs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.6.4-next.495.1",
3
+ "version": "5.6.4-next.497.1",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",
@@ -69,10 +69,13 @@
69
69
  "@tanstack/react-query": "^5.102.3",
70
70
  "@types/node": "^24.10.1",
71
71
  "@types/react": "^19.2.18",
72
+ "@types/react-dom": "^19.1.0",
72
73
  "@vitest/coverage-v8": "^5.0.0",
73
74
  "esbuild": "0.28.2",
75
+ "happy-dom": "^21.0.4",
74
76
  "pino": "10.4.0",
75
77
  "react": "19.1.0",
78
+ "react-dom": "19.1.0",
76
79
  "react-native": "0.81.5",
77
80
  "tsx": "^4.20.6",
78
81
  "typescript": "^7.0.2",
@@ -1,2 +1,2 @@
1
1
  /** Release Please keeps this bundle-safe constant aligned with package.json. */
2
- export const PASEO_OMP_PACKAGE_VERSION = "5.6.4-next.495.1"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.6.4-next.497.1"; // x-release-please-version
package/server/quota.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { createHash } from "node:crypto";
1
2
  import { join } from "node:path";
2
3
  import { DatabaseSync } from "node:sqlite";
3
4
  import type { RpcInput } from "@getpaseo/plugin";
@@ -7,6 +8,9 @@ import { ompDataDir } from "./paths";
7
8
 
8
9
  const QuotaRowSchema = z.object({
9
10
  provider: z.string(),
11
+ accountKey: z.string(),
12
+ limitId: z.string(),
13
+ email: z.string().nullable(),
10
14
  label: z.string(),
11
15
  windowLabel: z.string().nullable(),
12
16
  usedFraction: z.number().min(0).nullable(),
@@ -24,13 +28,18 @@ export function listOmpQuotasFrom(path: string, now = Date.now()): OmpQuota[] {
24
28
  try {
25
29
  const database = new DatabaseSync(path, { readOnly: true, timeout: 500 });
26
30
  try {
31
+ const columns = database.prepare("PRAGMA table_info(usage_history)").all();
32
+ const emailColumn = columns.some((column) => column.name === "email")
33
+ ? "email"
34
+ : "NULL AS email";
27
35
  const rows = database
28
36
  .prepare(
29
- `SELECT provider, label, window_label AS windowLabel, used_fraction AS usedFraction,
37
+ `SELECT provider, account_key AS accountKey, limit_id AS limitId, email, label,
38
+ window_label AS windowLabel, used_fraction AS usedFraction,
30
39
  status, resets_at AS resetsAt, recorded_at AS recordedAt
31
40
  FROM (
32
- SELECT provider, account_key, limit_id, label, window_label, used_fraction, status,
33
- resets_at, recorded_at, id,
41
+ SELECT provider, account_key, ${emailColumn},
42
+ limit_id, label, window_label, used_fraction, status, resets_at, recorded_at, id,
34
43
  ROW_NUMBER() OVER (
35
44
  PARTITION BY provider, account_key, limit_id
36
45
  ORDER BY recorded_at DESC, id DESC
@@ -39,12 +48,19 @@ export function listOmpQuotasFrom(path: string, now = Date.now()): OmpQuota[] {
39
48
  )
40
49
  WHERE position = 1
41
50
  AND (resets_at > ? OR (resets_at IS NULL AND recorded_at > ?))
42
- ORDER BY COALESCE(usedFraction, -1) DESC, provider, label`,
51
+ ORDER BY COALESCE(usedFraction, -1) DESC, provider, label, accountKey, limitId`,
43
52
  )
44
53
  .all(now, now - ABANDONED_AFTER_MS);
45
54
  return rows.flatMap((row) => {
46
55
  const parsed = QuotaRowSchema.safeParse(row);
47
- return parsed.success ? [parsed.data] : [];
56
+ if (!parsed.success) return [];
57
+ const quota = parsed.data;
58
+ return [
59
+ {
60
+ ...quota,
61
+ accountKey: createHash("sha256").update(quota.accountKey).digest("hex"),
62
+ },
63
+ ];
48
64
  });
49
65
  } finally {
50
66
  database.close();
package/shared/quota.ts CHANGED
@@ -7,6 +7,10 @@ import { OmpStoreSchema } from "./omp-store";
7
7
  // Date.now() directly, never Date.now() / 1000.
8
8
  export const OmpQuotaSchema = z.object({
9
9
  provider: z.string(),
10
+ /** Server-side SHA-256 identity; never the raw OMP credential/account key. */
11
+ accountKey: z.string(),
12
+ limitId: z.string(),
13
+ email: z.string().nullable(),
10
14
  label: z.string(),
11
15
  windowLabel: z.string().nullable(),
12
16
  usedFraction: z.number().min(0).nullable(),