@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.
- package/OVERVIEW.md +2 -0
- package/README.md +3 -1
- package/client/omp-accounts-section.tsx +894 -0
- package/client/omp-accounts-state.ts +67 -0
- package/client/omp-config-surface.tsx +5 -0
- package/client/omp-config-views.ts +6 -1
- package/index.server.ts +54 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/omp-accounts.ts +1088 -0
- package/server/omp-settings.ts +1 -1
- package/server/package-version.ts +1 -1
- package/shared/omp-accounts.ts +196 -0
package/server/omp-settings.ts
CHANGED
|
@@ -200,7 +200,7 @@ export function parseOmpSettingsList(raw: unknown): ParsedOmpSettings {
|
|
|
200
200
|
return { settings, droppedCount };
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
async function resolveOmpExecutable(): Promise<string | null> {
|
|
203
|
+
export async function resolveOmpExecutable(): Promise<string | null> {
|
|
204
204
|
return resolveExecutablePath(
|
|
205
205
|
currentOmpEnvironment().OMP_COMMAND ?? "omp",
|
|
206
206
|
(currentOmpEnvironment().PATH ?? "").split(delimiter),
|
|
@@ -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.
|
|
2
|
+
export const PASEO_OMP_PACKAGE_VERSION = "5.3.0"; // x-release-please-version
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { OmpStoreSchema } from "./omp-store";
|
|
4
|
+
|
|
5
|
+
/** OMP provider ids such as `anthropic` or `openai-codex`; never a leading `-`, they end up in argv. */
|
|
6
|
+
export const OmpAccountProviderIdSchema = z.string().regex(/^[a-z0-9][a-z0-9.-]*$/u);
|
|
7
|
+
|
|
8
|
+
export const OmpAccountRefSchema = z.object({
|
|
9
|
+
store: OmpStoreSchema.optional(),
|
|
10
|
+
provider: OmpAccountProviderIdSchema,
|
|
11
|
+
credentialId: z.number().int().nonnegative(),
|
|
12
|
+
});
|
|
13
|
+
export type OmpAccountRef = z.infer<typeof OmpAccountRefSchema>;
|
|
14
|
+
|
|
15
|
+
/** One rate-limit window as OMP reports it; `resetsAt` is epoch milliseconds like `OmpQuota`. */
|
|
16
|
+
export const OmpAccountLimitSchema = z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
label: z.string(),
|
|
19
|
+
usedFraction: z.number().min(0),
|
|
20
|
+
resetsAt: z.number().int().nullable(),
|
|
21
|
+
});
|
|
22
|
+
export type OmpAccountLimit = z.infer<typeof OmpAccountLimitSchema>;
|
|
23
|
+
|
|
24
|
+
export const OmpAccountResetsSchema = z.object({
|
|
25
|
+
available: z.number().int(),
|
|
26
|
+
/** OMP can spend one right now; otherwise `blockedReason` says why not. */
|
|
27
|
+
usableNow: z.boolean(),
|
|
28
|
+
blockedReason: z.string().nullable(),
|
|
29
|
+
soonestExpiry: z.string().nullable(),
|
|
30
|
+
});
|
|
31
|
+
export type OmpAccountResets = z.infer<typeof OmpAccountResetsSchema>;
|
|
32
|
+
|
|
33
|
+
/** The account policy OMP's config holds for this login (`auth.accountPolicies`). */
|
|
34
|
+
export const OmpAccountSteeringSchema = z.object({
|
|
35
|
+
/** New agents prefer this login for its provider while it has room. */
|
|
36
|
+
preferred: z.boolean(),
|
|
37
|
+
/** Quota kept unused on this login; null uses `retry.usageReservePct`. */
|
|
38
|
+
reservePct: z.number().nullable(),
|
|
39
|
+
});
|
|
40
|
+
export type OmpAccountSteering = z.infer<typeof OmpAccountSteeringSchema>;
|
|
41
|
+
|
|
42
|
+
/** One login in OMP's own credential store. OMP picks between them itself. */
|
|
43
|
+
export const OmpAccountSchema = z.object({
|
|
44
|
+
provider: OmpAccountProviderIdSchema,
|
|
45
|
+
credentialId: z.number().int(),
|
|
46
|
+
/** OAuth logins have usage and resets; API keys have neither. */
|
|
47
|
+
oauth: z.boolean(),
|
|
48
|
+
label: z.string(),
|
|
49
|
+
limits: z.array(OmpAccountLimitSchema),
|
|
50
|
+
/** When OMP read the limits shown (epoch ms); null when it has no reading for this login. */
|
|
51
|
+
usageAt: z.number().int().nullable(),
|
|
52
|
+
/** The reading is OMP's last recorded one, not live: the provider gave none in the latest fetch. */
|
|
53
|
+
usageIsRecorded: z.boolean(),
|
|
54
|
+
resets: OmpAccountResetsSchema.nullable(),
|
|
55
|
+
/** Null when OMP gives no account id for this login, so its policies cannot select it. */
|
|
56
|
+
steering: OmpAccountSteeringSchema.nullable(),
|
|
57
|
+
});
|
|
58
|
+
export type OmpAccount = z.infer<typeof OmpAccountSchema>;
|
|
59
|
+
|
|
60
|
+
export const OmpLoginStepSchema = z.enum([
|
|
61
|
+
"starting",
|
|
62
|
+
"waiting",
|
|
63
|
+
"verifying",
|
|
64
|
+
"done",
|
|
65
|
+
"failed",
|
|
66
|
+
"canceled",
|
|
67
|
+
]);
|
|
68
|
+
export type OmpLoginStep = z.infer<typeof OmpLoginStepSchema>;
|
|
69
|
+
|
|
70
|
+
export const OmpLoginSchema = z.object({
|
|
71
|
+
id: z.string(),
|
|
72
|
+
provider: OmpAccountProviderIdSchema,
|
|
73
|
+
step: OmpLoginStepSchema,
|
|
74
|
+
url: z.string().nullable(),
|
|
75
|
+
/** OMP's own hint, such as a device code to enter on the page. */
|
|
76
|
+
instructions: z.string().nullable(),
|
|
77
|
+
/** OMP is waiting for the authorization code or redirect URL to be pasted back. */
|
|
78
|
+
codePrompt: z.string().nullable(),
|
|
79
|
+
message: z.string().nullable(),
|
|
80
|
+
});
|
|
81
|
+
export type OmpLogin = z.infer<typeof OmpLoginSchema>;
|
|
82
|
+
|
|
83
|
+
export const OmpAccountProviderSchema = z.object({
|
|
84
|
+
id: OmpAccountProviderIdSchema,
|
|
85
|
+
name: z.string(),
|
|
86
|
+
authenticated: z.boolean(),
|
|
87
|
+
});
|
|
88
|
+
export type OmpAccountProvider = z.infer<typeof OmpAccountProviderSchema>;
|
|
89
|
+
|
|
90
|
+
/** Where OMP's balancer would start new sessions right now (`omp dry-balance`). */
|
|
91
|
+
export const OmpBalancePreviewSchema = z.object({
|
|
92
|
+
provider: OmpAccountProviderIdSchema,
|
|
93
|
+
model: z.string(),
|
|
94
|
+
shares: z.array(z.object({ label: z.string(), percent: z.number() })),
|
|
95
|
+
});
|
|
96
|
+
export type OmpBalancePreview = z.infer<typeof OmpBalancePreviewSchema>;
|
|
97
|
+
|
|
98
|
+
/** OMP settings that steer how it uses its logins, each with OMP's current value. */
|
|
99
|
+
export const OMP_ACCOUNTS_SETTING_PATHS = [
|
|
100
|
+
"retry.usageReservePct",
|
|
101
|
+
"retry.usageReservePolicy",
|
|
102
|
+
"retry.waitForUsageReset",
|
|
103
|
+
"codexResets.autoRedeem",
|
|
104
|
+
"codexResets.keepCredits",
|
|
105
|
+
"claudeResets.autoRedeem",
|
|
106
|
+
"claudeResets.keepCredits",
|
|
107
|
+
] as const;
|
|
108
|
+
export const OmpAccountsSettingPathSchema = z.enum(OMP_ACCOUNTS_SETTING_PATHS);
|
|
109
|
+
export type OmpAccountsSettingPath = z.infer<typeof OmpAccountsSettingPathSchema>;
|
|
110
|
+
export const OmpAccountsSettingsSchema = z.partialRecord(
|
|
111
|
+
OmpAccountsSettingPathSchema,
|
|
112
|
+
z.union([z.string(), z.number(), z.boolean()]),
|
|
113
|
+
);
|
|
114
|
+
export type OmpAccountsSettings = z.infer<typeof OmpAccountsSettingsSchema>;
|
|
115
|
+
export const OmpAccountsViewSchema = z.object({
|
|
116
|
+
/** `omp` is on this host's PATH; everything else is empty when it is not. */
|
|
117
|
+
installed: z.boolean(),
|
|
118
|
+
/** Providers with a login plus the ones OMP offers sign-in for. */
|
|
119
|
+
providers: z.array(OmpAccountProviderSchema),
|
|
120
|
+
accounts: z.array(OmpAccountSchema),
|
|
121
|
+
logins: z.array(OmpLoginSchema),
|
|
122
|
+
balance: z.array(OmpBalancePreviewSchema),
|
|
123
|
+
settings: OmpAccountsSettingsSchema,
|
|
124
|
+
fetchedAt: z.number().int().nullable(),
|
|
125
|
+
error: z.string().nullable(),
|
|
126
|
+
});
|
|
127
|
+
export type OmpAccountsView = z.infer<typeof OmpAccountsViewSchema>;
|
|
128
|
+
|
|
129
|
+
export const listOmpAccounts = defineRpc({
|
|
130
|
+
name: "paseo-omp.list-accounts",
|
|
131
|
+
input: z.object({
|
|
132
|
+
store: OmpStoreSchema.optional(),
|
|
133
|
+
/** Ask the providers again instead of answering from OMP's usage cache. */
|
|
134
|
+
refresh: z.boolean().optional(),
|
|
135
|
+
}),
|
|
136
|
+
output: OmpAccountsViewSchema,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export const startOmpAccountLogin = defineRpc({
|
|
140
|
+
name: "paseo-omp.start-account-login",
|
|
141
|
+
input: z.object({ store: OmpStoreSchema.optional(), provider: OmpAccountProviderIdSchema }),
|
|
142
|
+
output: OmpLoginSchema,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export const submitOmpAccountLoginCode = defineRpc({
|
|
146
|
+
name: "paseo-omp.submit-account-login-code",
|
|
147
|
+
input: z.object({
|
|
148
|
+
store: OmpStoreSchema.optional(),
|
|
149
|
+
loginId: z.string(),
|
|
150
|
+
code: z.string().trim().min(1).max(4096),
|
|
151
|
+
}),
|
|
152
|
+
output: OmpLoginSchema,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export const cancelOmpAccountLogin = defineRpc({
|
|
156
|
+
name: "paseo-omp.cancel-account-login",
|
|
157
|
+
input: z.object({ store: OmpStoreSchema.optional(), loginId: z.string() }),
|
|
158
|
+
output: OmpLoginSchema.nullable(),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
/** Signs one login out of OMP's store (`omp` rpc `logout`). */
|
|
162
|
+
export const removeOmpAccount = defineRpc({
|
|
163
|
+
name: "paseo-omp.remove-account",
|
|
164
|
+
input: OmpAccountRefSchema,
|
|
165
|
+
output: z.object({ ok: z.literal(true) }),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
/** Spends one banked reset (`omp usage reset <provider>/<credentialId>`). */
|
|
169
|
+
export const redeemOmpAccountReset = defineRpc({
|
|
170
|
+
name: "paseo-omp.redeem-account-reset",
|
|
171
|
+
input: OmpAccountRefSchema,
|
|
172
|
+
output: z.object({ ok: z.boolean(), message: z.string() }),
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
/** Whether an account's steering can change or spend money is OMP's call; these only edit its config. */
|
|
176
|
+
export const setOmpAccountSteering = defineRpc({
|
|
177
|
+
name: "paseo-omp.set-account-steering",
|
|
178
|
+
input: OmpAccountRefSchema.extend({
|
|
179
|
+
/** Make this the login new agents prefer for its provider, or drop that preference. */
|
|
180
|
+
preferred: z.boolean().optional(),
|
|
181
|
+
/** Quota OMP keeps unused on this login; null goes back to OMP's default reserve. */
|
|
182
|
+
reservePct: z.number().int().min(0).max(90).nullable().optional(),
|
|
183
|
+
}),
|
|
184
|
+
output: z.object({ ok: z.literal(true) }),
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
export const setOmpAccountsSetting = defineRpc({
|
|
188
|
+
name: "paseo-omp.set-accounts-setting",
|
|
189
|
+
input: z.object({
|
|
190
|
+
store: OmpStoreSchema.optional(),
|
|
191
|
+
path: OmpAccountsSettingPathSchema,
|
|
192
|
+
/** null resets the setting to OMP's default. */
|
|
193
|
+
value: z.union([z.string(), z.number(), z.boolean()]).nullable(),
|
|
194
|
+
}),
|
|
195
|
+
output: z.object({ ok: z.literal(true) }),
|
|
196
|
+
});
|