@omercnet/paseo-omp 5.6.4 → 5.7.0

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 or, when absent, the Copilot account ID (GitHub username) 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. Copilot accounts also show **GitHub** or **GHE · host**, using the enterprise URL in OMP's recorded account key; unrecognized keys show neither. Only a server-side SHA-256 hash of the account key reaches the client. **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,61 @@ 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.accountService ? (
158
+ <Text style={styles.detail}>
159
+ {account.accountService === "github"
160
+ ? "GitHub"
161
+ : `GHE · ${account.accountHost}`}
162
+ </Text>
163
+ ) : null}
164
+ {account.quotas.map((quota) => {
165
+ const severity = quotaSeverityFromFraction(quota.usedFraction);
166
+ const color = severityColor(severity);
167
+ const pct =
168
+ quota.usedFraction === null
169
+ ? 0
170
+ : Math.min(100, Math.round(quota.usedFraction * 100));
171
+ return (
172
+ <View key={quota.limitId} style={styles.row}>
173
+ <View style={styles.rowHeader}>
174
+ <Text numberOfLines={1} style={styles.rowLabel}>
175
+ {quota.label}
176
+ </Text>
177
+ <Text style={[styles.rowValue, { color }]}>
178
+ {quota.usedFraction === null ? "Unknown" : `${pct}%`}
179
+ </Text>
180
+ </View>
181
+ <View style={styles.track}>
182
+ <View
183
+ style={{ height: "100%", width: `${pct}%`, backgroundColor: color }}
184
+ />
185
+ </View>
186
+ <Text style={styles.detail}>{quotaDetailLabel(quota)}</Text>
187
+ </View>
188
+ );
189
+ })}
190
+ </View>
191
+ ))}
149
192
  </View>
150
193
  );
151
194
  })}
@@ -91,9 +91,21 @@ 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
+ accountService: OmpQuota["accountService"];
98
+ accountHost: string | null;
99
+ label: string | null;
100
+ suffix: string | null;
101
+ quotas: OmpQuota[];
102
+ peakFraction: number | null;
103
+ severity: QuotaSeverity;
104
+ };
105
+
94
106
  export type QuotaProviderGroup = {
95
107
  provider: string;
96
- quotas: OmpQuota[];
108
+ accounts: QuotaAccountGroup[];
97
109
  peakFraction: number | null;
98
110
  severity: QuotaSeverity;
99
111
  };
@@ -118,7 +130,7 @@ export function quotaProviderGroups(
118
130
  const peakFraction = used.length === 0 ? null : Math.max(...used);
119
131
  return {
120
132
  provider,
121
- quotas: [...providerQuotas].sort((a, b) => (b.usedFraction ?? -1) - (a.usedFraction ?? -1)),
133
+ accounts: quotaAccountGroups(providerQuotas),
122
134
  peakFraction,
123
135
  severity: quotaSeverityFromFraction(peakFraction),
124
136
  };
@@ -131,6 +143,67 @@ export function quotaProviderGroups(
131
143
  return groups;
132
144
  }
133
145
 
146
+ function quotaAccountGroups(quotas: readonly OmpQuota[]): QuotaAccountGroup[] {
147
+ const byAccount = new Map<string, OmpQuota[]>();
148
+ for (const quota of quotas) {
149
+ const group = byAccount.get(quota.accountKey);
150
+ if (group) group.push(quota);
151
+ else byAccount.set(quota.accountKey, [quota]);
152
+ }
153
+ const accounts: QuotaAccountGroup[] = [...byAccount.entries()].map(
154
+ ([accountKey, accountQuotas]) => {
155
+ const used = accountQuotas.flatMap((quota) =>
156
+ quota.usedFraction === null ? [] : [quota.usedFraction],
157
+ );
158
+ const peakFraction = used.length === 0 ? null : Math.max(...used);
159
+ const email = accountQuotas.find((quota) => quota.email?.trim())?.email?.trim() ?? null;
160
+ const accountId =
161
+ accountQuotas.find((quota) => quota.accountId?.trim())?.accountId?.trim() ?? null;
162
+ const service = accountQuotas.find((quota) => quota.accountService !== null);
163
+ return {
164
+ accountKey,
165
+ email,
166
+ accountService: service?.accountService ?? null,
167
+ accountHost: service?.accountHost ?? null,
168
+ label: email ?? accountId,
169
+ suffix: null,
170
+ quotas: [...accountQuotas].sort((a, b) => (b.usedFraction ?? -1) - (a.usedFraction ?? -1)),
171
+ peakFraction,
172
+ severity: quotaSeverityFromFraction(peakFraction),
173
+ };
174
+ },
175
+ );
176
+ accounts.sort((a, b) => a.accountKey.localeCompare(b.accountKey));
177
+ const labelCounts = new Map<string, number>();
178
+ for (const account of accounts) {
179
+ if (account.label) {
180
+ labelCounts.set(account.label, (labelCounts.get(account.label) ?? 0) + 1);
181
+ }
182
+ }
183
+ const labelIndexes = new Map<string, number>();
184
+ let unnamedAccounts = 0;
185
+ for (const account of accounts) {
186
+ if (!account.label && accounts.length > 1) {
187
+ account.label = `Account ${++unnamedAccounts}`;
188
+ continue;
189
+ }
190
+ if (!account.label) {
191
+ continue;
192
+ }
193
+ const label = account.label;
194
+ const index = (labelIndexes.get(label) ?? 0) + 1;
195
+ labelIndexes.set(label, index);
196
+ if ((labelCounts.get(label) ?? 0) > 1) {
197
+ account.suffix = `Account ${index}`;
198
+ }
199
+ }
200
+ accounts.sort(
201
+ (a, b) =>
202
+ (b.peakFraction ?? -1) - (a.peakFraction ?? -1) || a.accountKey.localeCompare(b.accountKey),
203
+ );
204
+ return accounts;
205
+ }
206
+
134
207
  export function quotaResetLabel(resetsAtMs: number | null, nowMs: number = Date.now()): string {
135
208
  if (resetsAtMs === null) return "";
136
209
  const remainingMs = Math.max(0, resetsAtMs - nowMs);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.6.4",
3
+ "version": "5.7.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@omercnet/paseo-omp",
9
- "version": "5.6.4",
9
+ "version": "5.7.0",
10
10
  "dependencies": {
11
11
  "@getpaseo/protocol": "0.16.0-beta.2",
12
12
  "@modelcontextprotocol/sdk": "1.32.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.6.4",
3
+ "version": "5.7.0",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",
@@ -64,14 +64,17 @@
64
64
  "@getpaseo/client": "0.16.0-beta.2",
65
65
  "@getpaseo/plugin": "0.16.0-beta.2",
66
66
  "@getpaseo/server": "0.16.0-beta.2",
67
- "@oh-my-pi/pi-agent-core": "18.18.8",
68
- "@oh-my-pi/pi-coding-agent": "18.18.8",
67
+ "@oh-my-pi/pi-agent-core": "18.20.0",
68
+ "@oh-my-pi/pi-coding-agent": "18.20.0",
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
  "react": "19.1.0",
77
+ "react-dom": "19.1.0",
75
78
  "react-native": "0.81.5",
76
79
  "pino": "10.4.0",
77
80
  "tsx": "^4.20.6",
@@ -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"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.7.0"; // 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,10 @@ 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(),
14
+ accountId: z.string().nullable(),
10
15
  label: z.string(),
11
16
  windowLabel: z.string().nullable(),
12
17
  usedFraction: z.number().min(0).nullable(),
@@ -18,19 +23,51 @@ const QuotaRowSchema = z.object({
18
23
  // Reset-less rows (no resets_at) refresh on every OMP poll, so one this old is an inactive provider.
19
24
  const ABANDONED_AFTER_MS = 30 * 86_400_000;
20
25
 
26
+ type CopilotAccount = Pick<OmpQuota, "accountService" | "accountHost">;
27
+ const UNKNOWN_SERVICE: CopilotAccount = { accountService: null, accountHost: null };
28
+
29
+ /** OMP usageCacheIdentity records enterpriseUrl separately from its opaque credential fingerprint. */
30
+ function copilotAccount(accountKey: string): CopilotAccount {
31
+ if (!accountKey.startsWith("oauth|") && !accountKey.startsWith("api_key|")) {
32
+ return UNKNOWN_SERVICE;
33
+ }
34
+ const enterprise = accountKey.split("|").find((part) => part.startsWith("enterprise:"));
35
+ if (!enterprise) return { accountService: "github", accountHost: null };
36
+ const value = enterprise.slice("enterprise:".length);
37
+ if (!value) return UNKNOWN_SERVICE;
38
+ try {
39
+ const url = new URL(value.includes("://") ? value : `https://${value}`);
40
+ if (!["https:", "http:"].includes(url.protocol) || url.username || url.password) {
41
+ return UNKNOWN_SERVICE;
42
+ }
43
+ return url.hostname ? { accountService: "ghe", accountHost: url.hostname } : UNKNOWN_SERVICE;
44
+ } catch {
45
+ return UNKNOWN_SERVICE;
46
+ }
47
+ }
48
+
21
49
  // Only live windows are returned: a series whose newest row already reset (or never resets and was
22
50
  // abandoned) would otherwise pin the pill at its last exhausted value and bloat the popover.
23
51
  export function listOmpQuotasFrom(path: string, now = Date.now()): OmpQuota[] {
24
52
  try {
25
53
  const database = new DatabaseSync(path, { readOnly: true, timeout: 500 });
26
54
  try {
55
+ const columns = database.prepare("PRAGMA table_info(usage_history)").all();
56
+ const emailColumn = columns.some((column) => column.name === "email")
57
+ ? "email"
58
+ : "NULL AS email";
59
+ const accountIdColumn = columns.some((column) => column.name === "account_id")
60
+ ? "account_id"
61
+ : "NULL AS account_id";
27
62
  const rows = database
28
63
  .prepare(
29
- `SELECT provider, label, window_label AS windowLabel, used_fraction AS usedFraction,
64
+ `SELECT provider, account_key AS accountKey, limit_id AS limitId, email,
65
+ account_id AS accountId, label,
66
+ window_label AS windowLabel, used_fraction AS usedFraction,
30
67
  status, resets_at AS resetsAt, recorded_at AS recordedAt
31
68
  FROM (
32
- SELECT provider, account_key, limit_id, label, window_label, used_fraction, status,
33
- resets_at, recorded_at, id,
69
+ SELECT provider, account_key, ${emailColumn}, ${accountIdColumn},
70
+ limit_id, label, window_label, used_fraction, status, resets_at, recorded_at, id,
34
71
  ROW_NUMBER() OVER (
35
72
  PARTITION BY provider, account_key, limit_id
36
73
  ORDER BY recorded_at DESC, id DESC
@@ -39,12 +76,23 @@ export function listOmpQuotasFrom(path: string, now = Date.now()): OmpQuota[] {
39
76
  )
40
77
  WHERE position = 1
41
78
  AND (resets_at > ? OR (resets_at IS NULL AND recorded_at > ?))
42
- ORDER BY COALESCE(usedFraction, -1) DESC, provider, label`,
79
+ ORDER BY COALESCE(usedFraction, -1) DESC, provider, label, accountKey, limitId`,
43
80
  )
44
81
  .all(now, now - ABANDONED_AFTER_MS);
45
82
  return rows.flatMap((row) => {
46
83
  const parsed = QuotaRowSchema.safeParse(row);
47
- return parsed.success ? [parsed.data] : [];
84
+ if (!parsed.success) return [];
85
+ const quota = parsed.data;
86
+ const copilot = quota.provider === "github-copilot";
87
+ return [
88
+ {
89
+ ...quota,
90
+ accountKey: createHash("sha256").update(quota.accountKey).digest("hex"),
91
+ // account_id is only known to be a username for Copilot; other providers keep it private.
92
+ accountId: copilot ? quota.accountId : null,
93
+ ...(copilot ? copilotAccount(quota.accountKey) : UNKNOWN_SERVICE),
94
+ },
95
+ ];
48
96
  });
49
97
  } finally {
50
98
  database.close();
package/shared/quota.ts CHANGED
@@ -7,6 +7,15 @@ 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(),
14
+ accountId: z.string().nullable(),
15
+ /** Copilot login service: public GitHub or a GitHub Enterprise (GHE) host. */
16
+ accountService: z.enum(["github", "ghe"]).nullable(),
17
+ /** GHE hostname; null for public GitHub and every other provider. */
18
+ accountHost: z.string().nullable(),
10
19
  label: z.string(),
11
20
  windowLabel: z.string().nullable(),
12
21
  usedFraction: z.number().min(0).nullable(),