@omercnet/paseo-omp 5.2.4 → 5.3.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.
@@ -0,0 +1,67 @@
1
+ import type {
2
+ OmpAccount,
3
+ OmpAccountProvider,
4
+ OmpAccountsView,
5
+ OmpBalancePreview,
6
+ OmpLogin,
7
+ } from "../shared/omp-accounts";
8
+
9
+ export interface OmpAccountGroup {
10
+ provider: OmpAccountProvider;
11
+ accounts: OmpAccount[];
12
+ }
13
+
14
+ const OPEN_LOGIN_POLL_MS = 1_000;
15
+ const IDLE_POLL_MS = 30_000;
16
+
17
+ /** Providers that have at least one login, in OMP's provider order; a login's own id names an unlisted provider. */
18
+ export function accountGroups(view: OmpAccountsView): OmpAccountGroup[] {
19
+ const known = new Map(view.providers.map((provider) => [provider.id, provider]));
20
+ const ids = [...new Set(view.accounts.map((account) => account.provider))];
21
+ const order = new Map(view.providers.map((provider, index) => [provider.id, index]));
22
+ const sorted = ids.sort((a, b) => (order.get(a) ?? 0) - (order.get(b) ?? 0));
23
+ return sorted.map((id) => ({
24
+ provider: known.get(id) ?? { id, name: id, authenticated: true },
25
+ accounts: view.accounts.filter((account) => account.provider === id),
26
+ }));
27
+ }
28
+
29
+ /** Signed-in providers first, because adding a second login to one is the common case. */
30
+ export function signInProviders(
31
+ providers: readonly OmpAccountProvider[],
32
+ query: string,
33
+ ): OmpAccountProvider[] {
34
+ const needle = query.trim().toLocaleLowerCase();
35
+ const matching = providers.filter(
36
+ (provider) =>
37
+ needle === "" ||
38
+ provider.name.toLocaleLowerCase().includes(needle) ||
39
+ provider.id.includes(needle),
40
+ );
41
+ return matching.toSorted(
42
+ (a, b) => Number(b.authenticated) - Number(a.authenticated) || a.name.localeCompare(b.name),
43
+ );
44
+ }
45
+
46
+ export function loginIsOpen(login: OmpLogin): boolean {
47
+ return login.step === "starting" || login.step === "waiting" || login.step === "verifying";
48
+ }
49
+
50
+ /** Polls quickly while a sign-in is moving, otherwise slowly: the server already caches reads. */
51
+ export function accountsPollInterval(view: OmpAccountsView | undefined): number {
52
+ return view?.logins.some(loginIsOpen) ? OPEN_LOGIN_POLL_MS : IDLE_POLL_MS;
53
+ }
54
+
55
+ export function usedPercent(usedFraction: number): number {
56
+ return Math.min(100, Math.round(usedFraction * 100));
57
+ }
58
+
59
+ export function balanceLine(preview: OmpBalancePreview): string {
60
+ const shares = preview.shares.map((share) => `${share.label} ${share.percent}%`);
61
+ return `New agents on ${preview.model} go to ${shares.length > 0 ? shares.join(", ") : "no login"}`;
62
+ }
63
+
64
+ export function resetsLabel(resets: NonNullable<OmpAccount["resets"]>): string {
65
+ const noun = resets.available === 1 ? "reset" : "resets";
66
+ return `${resets.available} banked ${noun}`;
67
+ }
@@ -29,6 +29,7 @@ import { getOmpProviderHealth, type OmpProviderHealth } from "../shared/provider
29
29
  import { getOmpSupportReport, OMP_SUPPORT_ISSUE_URL } from "../shared/support-diagnostics";
30
30
  import { ComposerPillSettingsSection } from "./composer-pill-settings";
31
31
  import { openOmpExternalUrl } from "./external-url";
32
+ import { OmpAccountsSection } from "./omp-accounts-section";
32
33
  import { type OmpConfigStyles, useConfigStyles } from "./omp-config-styles";
33
34
  import { type OmpConfigSurfaceView as SurfaceView, surfaceViewsForScope } from "./omp-config-views";
34
35
  import {
@@ -1145,6 +1146,10 @@ function OmpConfigContent({
1145
1146
  </>
1146
1147
  ) : null}
1147
1148
 
1149
+ {view === "accounts" && !cwd ? (
1150
+ <OmpAccountsSection theme={theme} styles={styles} store={store} />
1151
+ ) : null}
1152
+
1148
1153
  {view === "plugin" ? (
1149
1154
  <>
1150
1155
  <PluginConfigurationSection styles={styles} />
@@ -1,5 +1,6 @@
1
1
  export type OmpConfigSurfaceView =
2
2
  | "overview"
3
+ | "accounts"
3
4
  | "plugin"
4
5
  | "plugins"
5
6
  | "composer"
@@ -9,6 +10,7 @@ export type OmpConfigSurfaceView =
9
10
 
10
11
  const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
11
12
  { id: "overview", label: "Overview" },
13
+ { id: "accounts", label: "Accounts" },
12
14
  { id: "plugin", label: "Plugin" },
13
15
  { id: "plugins", label: "OMP plugins" },
14
16
  { id: "composer", label: "Composer" },
@@ -17,8 +19,11 @@ const SURFACE_VIEWS: readonly { id: OmpConfigSurfaceView; label: string }[] = [
17
19
  { id: "help", label: "Help" },
18
20
  ];
19
21
 
22
+ /** Views that belong to the OMP store, not to a workspace's project settings. */
23
+ const STORE_ONLY_VIEWS: readonly OmpConfigSurfaceView[] = ["composer", "accounts"];
24
+
20
25
  export function surfaceViewsForScope(workspaceScoped: boolean) {
21
26
  return workspaceScoped
22
- ? SURFACE_VIEWS.filter((candidate) => candidate.id !== "composer")
27
+ ? SURFACE_VIEWS.filter((candidate) => !STORE_ONLY_VIEWS.includes(candidate.id))
23
28
  : SURFACE_VIEWS;
24
29
  }
package/index.server.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  resolveOpenOmpMcpAuthorizationInPaseoBrowser,
6
6
  } from "./server/mcp-browser";
7
7
  import { resolveListOmpMemory } from "./server/memory";
8
+ import { OmpAccounts } from "./server/omp-accounts";
8
9
  import { resolveListOmpConfig } from "./server/omp-config";
9
10
  import { resolveListOmpModels } from "./server/omp-models";
10
11
  import {
@@ -40,6 +41,16 @@ import { composerPillSettings } from "./shared/composer-pill-settings";
40
41
  import { listHubProcesses, tailHubLog } from "./shared/hub";
41
42
  import { openOmpMcpAuthorizationInPaseoBrowser } from "./shared/mcp";
42
43
  import { listOmpMemory } from "./shared/memory";
44
+ import {
45
+ cancelOmpAccountLogin,
46
+ listOmpAccounts,
47
+ redeemOmpAccountReset,
48
+ removeOmpAccount,
49
+ setOmpAccountSteering,
50
+ setOmpAccountsSetting,
51
+ startOmpAccountLogin,
52
+ submitOmpAccountLoginCode,
53
+ } from "./shared/omp-accounts";
43
54
  import { listOmpConfig } from "./shared/omp-config";
44
55
  import { listOmpModels } from "./shared/omp-models";
45
56
  import {
@@ -79,6 +90,7 @@ export default function contribute(server: PluginServerContext) {
79
90
  const subagentControlRegistry = new OmpSubagentControlRegistry();
80
91
  const protocolViolations = new OmpProtocolViolationCollector();
81
92
  const operationalFailures = new OmpOperationalFailureCollector();
93
+ const accounts = new OmpAccounts();
82
94
  const profiles = discoverOmpProfilesSync();
83
95
  server.handle(listOmpStores, async () => ({ profiles: await discoverOmpProfiles() }));
84
96
  for (const profile of profiles) {
@@ -96,6 +108,47 @@ export default function contribute(server: PluginServerContext) {
96
108
  server.handle(listHubProcesses, resolveListHubProcesses);
97
109
  server.handle(tailHubLog, resolveTailHubLog);
98
110
  server.handle(listOmpQuotas, scoped(resolveListOmpQuotas));
111
+ server.handle(
112
+ listOmpAccounts,
113
+ scoped(({ store, refresh }) => accounts.list(store, refresh ?? false)),
114
+ );
115
+ server.handle(
116
+ startOmpAccountLogin,
117
+ scoped(({ store, provider }) => accounts.startLogin(store, provider)),
118
+ );
119
+ server.handle(
120
+ submitOmpAccountLoginCode,
121
+ scoped(({ loginId, code }) => accounts.submitCode(loginId, code)),
122
+ );
123
+ server.handle(
124
+ cancelOmpAccountLogin,
125
+ scoped(({ loginId }) => accounts.cancelLogin(loginId)),
126
+ );
127
+ server.handle(
128
+ removeOmpAccount,
129
+ scoped(async ({ store, provider, credentialId }) => {
130
+ await accounts.remove(store, provider, credentialId);
131
+ return { ok: true as const };
132
+ }),
133
+ );
134
+ server.handle(
135
+ redeemOmpAccountReset,
136
+ scoped(({ store, provider, credentialId }) => accounts.redeem(store, provider, credentialId)),
137
+ );
138
+ server.handle(
139
+ setOmpAccountSteering,
140
+ scoped(async ({ store, provider, credentialId, preferred, reservePct }) => {
141
+ await accounts.setSteering(store, provider, credentialId, { preferred, reservePct });
142
+ return { ok: true as const };
143
+ }),
144
+ );
145
+ server.handle(
146
+ setOmpAccountsSetting,
147
+ scoped(async ({ store, path, value }) => {
148
+ await accounts.setSetting(store, path, value);
149
+ return { ok: true as const };
150
+ }),
151
+ );
99
152
  server.handle(listOmpMemory, scoped(resolveListOmpMemory));
100
153
  server.handle(listOmpSessions, scoped(resolveListOmpSessions));
101
154
  server.handle(listOmpConfig, scoped(resolveListOmpConfig));
@@ -137,6 +190,7 @@ export default function contribute(server: PluginServerContext) {
137
190
  );
138
191
  return () => {
139
192
  browserAuthorizationRegistry.clear();
193
+ accounts.stop();
140
194
  removeSessionLimitListener();
141
195
  subagentControlRegistry.clear();
142
196
  removeSessionOpenHook();
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-omp",
3
- "version": "5.2.4",
3
+ "version": "5.3.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@omercnet/paseo-omp",
9
- "version": "5.2.4",
9
+ "version": "5.3.0",
10
10
  "dependencies": {
11
11
  "@getpaseo/protocol": "0.15.0",
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.2.4",
3
+ "version": "5.3.0",
4
4
  "type": "module",
5
5
  "description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
6
6
  "license": "MIT",