@kapybara/zerosub 1.5.1 → 1.18.3
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 +220 -26
- package/client/accounts-surface.tsx +344 -110
- package/client/add-account.tsx +335 -23
- package/client/api-account.tsx +250 -0
- package/client/azure-account.tsx +311 -0
- package/client/commands.ts +44 -8
- package/client/composer-item.tsx +203 -0
- package/client/fork-confirm.tsx +71 -0
- package/client/fork-settings.tsx +148 -0
- package/client/pace.tsx +196 -0
- package/client/pi-accounts.tsx +571 -0
- package/client/pills.ts +63 -25
- package/client/reset-confirm.tsx +12 -3
- package/client/settings-screen.tsx +48 -9
- package/client/store.ts +148 -19
- package/client/switch-row.tsx +28 -8
- package/client/ui.tsx +11 -0
- package/index.client.tsx +4 -1
- package/index.server.ts +53 -10
- package/package.json +5 -2
- package/server/account-identity.ts +11 -0
- package/server/adapter.ts +115 -8
- package/server/api-usage.ts +144 -0
- package/server/azure.ts +346 -0
- package/server/binaries.ts +41 -3
- package/server/claude.ts +276 -21
- package/server/codex-same-conversation.ts +71 -0
- package/server/codex.ts +35 -7
- package/server/continuations.ts +67 -17
- package/server/cursor.ts +222 -0
- package/server/families.ts +105 -8
- package/server/grok.ts +225 -0
- package/server/handoff.ts +211 -29
- package/server/homes.ts +1263 -35
- package/server/json-file.ts +39 -8
- package/server/launchers.ts +319 -0
- package/server/limits.ts +80 -3
- package/server/main-proxy.ts +238 -0
- package/server/modes.ts +20 -4
- package/server/paths.ts +81 -1
- package/server/pi.ts +528 -0
- package/server/placement.ts +133 -0
- package/server/process.ts +18 -1
- package/server/processes.ts +66 -0
- package/server/provider-env.ts +28 -0
- package/server/proxy.ts +282 -0
- package/server/reopen.ts +50 -8
- package/server/routing.ts +337 -30
- package/server/service.ts +4320 -805
- package/server/state.ts +303 -24
- package/server/usage.ts +2 -0
- package/shared/format.ts +170 -2
- package/shared/model.ts +339 -2
- package/shared/preferences.ts +22 -1
- package/shared/rpc.ts +130 -8
- package/shared/timeline.ts +11 -0
|
@@ -3,8 +3,8 @@ import { Icon, Modal, TextInput, useToast } from "@getpaseo/plugin/client/react-
|
|
|
3
3
|
import { SettingsCard, SettingsSwitch } from "@getpaseo/plugin/client/ui";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
import { ScrollView, Text, View } from "react-native";
|
|
6
|
-
import { accountSubtitle, formatAge, formatCredits, formatPlan, usageSummary } from "../shared/format";
|
|
7
|
-
import { FAMILY_LABEL, type AccountView, type Family } from "../shared/model";
|
|
6
|
+
import { accountSubtitle, describeReopen, egressText, formatAge, formatCredits, formatExtraUsage, formatPlan, staleNotice, usageSummary } from "../shared/format";
|
|
7
|
+
import { FAMILY_LABEL, HAND_OFF, shownFamilies, type AccountView, type Family, type StateView } from "../shared/model";
|
|
8
8
|
import { preferences } from "../shared/preferences";
|
|
9
9
|
import {
|
|
10
10
|
clearAccountLimit,
|
|
@@ -12,18 +12,23 @@ import {
|
|
|
12
12
|
renameAccount,
|
|
13
13
|
setAccountEnabled,
|
|
14
14
|
setDefaultAccount,
|
|
15
|
-
|
|
15
|
+
setNextAgentAccount,
|
|
16
16
|
} from "../shared/rpc";
|
|
17
17
|
import { AddAccountModal } from "./add-account";
|
|
18
|
+
import { ApiAccountModal } from "./api-account";
|
|
19
|
+
import { AzureAccountModal, AzureUsage, azureCardDetails } from "./azure-account";
|
|
20
|
+
import { ForkDestinationRows, OpenCodeForkRows } from "./fork-settings";
|
|
21
|
+
import { AddPiAccountModal, ApiKeyModal, HomesHint, PiSectionNotes, ProxyModal, ShellHint, piCardDetails } from "./pi-accounts";
|
|
22
|
+
import { PaceSection } from "./pace";
|
|
18
23
|
import { ResetConfirm, redeemToast, resetBadge } from "./reset-confirm";
|
|
19
|
-
import { describe, useStore, VISIBLE_POLL_MS, type ZeroSubStore } from "./store";
|
|
24
|
+
import { describe, stoppedWaiting, useStore, VISIBLE_POLL_MS, type ZeroSubStore } from "./store";
|
|
20
25
|
import { Badge, Button, Card, IconButton, UsageBar, useText } from "./ui";
|
|
21
26
|
|
|
22
27
|
type Theme = PluginSurfaceProps["theme"];
|
|
23
28
|
|
|
24
29
|
export function AccountsSurface(props: PluginSurfaceProps & { store: ZeroSubStore }) {
|
|
25
30
|
const { theme, layout, host, store } = props;
|
|
26
|
-
const { state, error } = useStore(store);
|
|
31
|
+
const { state, error, updatedAt } = useStore(store);
|
|
27
32
|
const text = useText(theme);
|
|
28
33
|
const [adding, setAdding] = useState<{ family: Family; accountId?: string } | null>(null);
|
|
29
34
|
const [refreshing, setRefreshing] = useState(false);
|
|
@@ -43,7 +48,9 @@ export function AccountsSurface(props: PluginSurfaceProps & { store: ZeroSubStor
|
|
|
43
48
|
// Keep usage moving while the screen is open.
|
|
44
49
|
useEffect(() => store.watch(VISIBLE_POLL_MS), [store]);
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
// An optional provider (Pi, Grok, Cursor) shows once its CLI login is registered (its CLI is there,
|
|
52
|
+
// and for Grok and Cursor a Paseo provider runs it) or an account of it was added.
|
|
53
|
+
const families = shownFamilies(state?.accounts ?? []);
|
|
47
54
|
return (
|
|
48
55
|
<View style={{ flex: 1, backgroundColor: theme.colors.surface0 }}>
|
|
49
56
|
<ScrollView
|
|
@@ -74,8 +81,8 @@ export function AccountsSurface(props: PluginSurfaceProps & { store: ZeroSubStor
|
|
|
74
81
|
) : null}
|
|
75
82
|
</View>
|
|
76
83
|
<Text style={text.muted}>
|
|
77
|
-
Keep several Claude and
|
|
78
|
-
hits its limit, agents move to another and keep going.
|
|
84
|
+
Keep several Claude, ChatGPT, Grok and Cursor accounts signed in, and run Pi on several Anthropic API keys.
|
|
85
|
+
Each agent uses one; when a Claude or ChatGPT account hits its limit, agents move to another and keep going.
|
|
79
86
|
</Text>
|
|
80
87
|
</View>
|
|
81
88
|
|
|
@@ -101,6 +108,11 @@ export function AccountsSurface(props: PluginSurfaceProps & { store: ZeroSubStor
|
|
|
101
108
|
</Card>
|
|
102
109
|
) : null}
|
|
103
110
|
|
|
111
|
+
{/* The daemon stopped answering, or answered with an error: say how old what's shown is. */}
|
|
112
|
+
{error && state && !offline ? (
|
|
113
|
+
<StaleNotice theme={theme} message={staleNotice(updatedAt, error)} onRetry={() => void store.refresh()} />
|
|
114
|
+
) : null}
|
|
115
|
+
|
|
104
116
|
{state?.warnings.map((warning) => (
|
|
105
117
|
<Card theme={theme} key={warning}>
|
|
106
118
|
<Text style={text.warning}>{warning}</Text>
|
|
@@ -115,6 +127,7 @@ export function AccountsSurface(props: PluginSurfaceProps & { store: ZeroSubStor
|
|
|
115
127
|
key={family}
|
|
116
128
|
family={family}
|
|
117
129
|
accounts={state.accounts.filter((account) => account.family === family)}
|
|
130
|
+
state={state}
|
|
118
131
|
theme={theme}
|
|
119
132
|
compact={layout.compact}
|
|
120
133
|
store={store}
|
|
@@ -124,10 +137,12 @@ export function AccountsSurface(props: PluginSurfaceProps & { store: ZeroSubStor
|
|
|
124
137
|
))
|
|
125
138
|
: null}
|
|
126
139
|
|
|
127
|
-
<AutomationSettings theme={theme} />
|
|
140
|
+
<AutomationSettings theme={theme} compact={layout.compact} />
|
|
128
141
|
</ScrollView>
|
|
129
142
|
|
|
130
|
-
{adding ? (
|
|
143
|
+
{adding?.family === "pi" ? (
|
|
144
|
+
<AddPiAccountModal theme={theme} store={store} onClose={() => setAdding(null)} />
|
|
145
|
+
) : adding ? (
|
|
131
146
|
<AddAccountModal
|
|
132
147
|
theme={theme}
|
|
133
148
|
layout={layout}
|
|
@@ -143,6 +158,41 @@ export function AccountsSurface(props: PluginSurfaceProps & { store: ZeroSubStor
|
|
|
143
158
|
);
|
|
144
159
|
}
|
|
145
160
|
|
|
161
|
+
/** Over the last state shown while the daemon doesn't answer; it goes once a refresh works again. */
|
|
162
|
+
function StaleNotice({ theme, message, onRetry }: { theme: Theme; message: string; onRetry(): void }) {
|
|
163
|
+
const text = useText(theme);
|
|
164
|
+
return (
|
|
165
|
+
<View
|
|
166
|
+
accessibilityRole="alert"
|
|
167
|
+
accessibilityLiveRegion="polite"
|
|
168
|
+
style={{
|
|
169
|
+
flexDirection: "row",
|
|
170
|
+
flexWrap: "wrap",
|
|
171
|
+
alignItems: "center",
|
|
172
|
+
gap: 10,
|
|
173
|
+
paddingVertical: 8,
|
|
174
|
+
paddingHorizontal: 12,
|
|
175
|
+
borderRadius: 10,
|
|
176
|
+
borderWidth: 1,
|
|
177
|
+
borderColor: theme.colors.border,
|
|
178
|
+
backgroundColor: theme.colors.surface1,
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
<Icon name="CircleAlert" size={16} color={theme.colors.statusWarning} />
|
|
182
|
+
<Text style={[text.small, { flex: 1, minWidth: 160 }]}>{message}</Text>
|
|
183
|
+
<Button
|
|
184
|
+
theme={theme}
|
|
185
|
+
size="small"
|
|
186
|
+
icon="RefreshCw"
|
|
187
|
+
label="Try again"
|
|
188
|
+
tooltip="Ask this host for its accounts again"
|
|
189
|
+
tooltipAlign="end"
|
|
190
|
+
onPress={onRetry}
|
|
191
|
+
/>
|
|
192
|
+
</View>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
146
196
|
/** Says whose accounts these are when the app knows several hosts. */
|
|
147
197
|
function HostScope({ theme, label }: { theme: Theme; label: string }) {
|
|
148
198
|
const text = useText(theme);
|
|
@@ -172,9 +222,12 @@ function HostScope({ theme, label }: { theme: Theme; label: string }) {
|
|
|
172
222
|
);
|
|
173
223
|
}
|
|
174
224
|
|
|
225
|
+
const SECTION_TITLE: Record<Family, string> = { claude: "Claude", codex: "ChatGPT (Codex)", pi: "Pi", grok: "Grok", cursor: "Cursor" };
|
|
226
|
+
|
|
175
227
|
function FamilySection({
|
|
176
228
|
family,
|
|
177
229
|
accounts,
|
|
230
|
+
state,
|
|
178
231
|
theme,
|
|
179
232
|
compact,
|
|
180
233
|
store,
|
|
@@ -183,6 +236,7 @@ function FamilySection({
|
|
|
183
236
|
}: {
|
|
184
237
|
family: Family;
|
|
185
238
|
accounts: AccountView[];
|
|
239
|
+
state: StateView;
|
|
186
240
|
theme: Theme;
|
|
187
241
|
compact: boolean;
|
|
188
242
|
store: ZeroSubStore;
|
|
@@ -194,14 +248,20 @@ function FamilySection({
|
|
|
194
248
|
<View style={{ gap: 10 }}>
|
|
195
249
|
<View style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between" }}>
|
|
196
250
|
<Text style={text.heading} accessibilityRole="header">
|
|
197
|
-
{family
|
|
251
|
+
{SECTION_TITLE[family]}
|
|
198
252
|
</Text>
|
|
199
253
|
<Button
|
|
200
254
|
theme={theme}
|
|
201
255
|
icon="Plus"
|
|
202
256
|
label={compact ? "Add" : "Add account"}
|
|
203
257
|
accessibilityLabel={`Add ${FAMILY_LABEL[family]} account`}
|
|
204
|
-
tooltip={
|
|
258
|
+
tooltip={
|
|
259
|
+
family === "pi"
|
|
260
|
+
? "Add a Pi account with an Anthropic API key and its own proxy"
|
|
261
|
+
: family === "codex"
|
|
262
|
+
? "Sign in another ChatGPT account, or add an Azure OpenAI key"
|
|
263
|
+
: `Sign in another ${FAMILY_LABEL[family]} account`
|
|
264
|
+
}
|
|
205
265
|
tooltipAlign="end"
|
|
206
266
|
onPress={onAdd}
|
|
207
267
|
/>
|
|
@@ -209,6 +269,23 @@ function FamilySection({
|
|
|
209
269
|
{accounts.length === 0 ? (
|
|
210
270
|
<Text style={text.muted}>No {FAMILY_LABEL[family]} accounts yet.</Text>
|
|
211
271
|
) : null}
|
|
272
|
+
{family === "pi" ? <PiSectionNotes theme={theme} state={state} accounts={accounts} store={store} /> : null}
|
|
273
|
+
{family === "claude" && state.launchers ? (
|
|
274
|
+
<ShellHint
|
|
275
|
+
theme={theme}
|
|
276
|
+
directory={state.launchers}
|
|
277
|
+
accounts={accounts}
|
|
278
|
+
example="claude-<account>.sh"
|
|
279
|
+
note="Each runs claude on its account, with its settings and proxy, whatever your shell exports."
|
|
280
|
+
/>
|
|
281
|
+
) : null}
|
|
282
|
+
{family === "claude" && state.claudeHomes ? <HomesHint theme={theme} family="claude" homes={state.claudeHomes} store={store} /> : null}
|
|
283
|
+
{!HAND_OFF[family] ? (
|
|
284
|
+
<Text style={text.small}>
|
|
285
|
+
A {FAMILY_LABEL[family]} conversation stays on the account it started on. New agents use the default account, or the
|
|
286
|
+
one you pick for them.
|
|
287
|
+
</Text>
|
|
288
|
+
) : null}
|
|
212
289
|
{chunk(accounts, compact ? 1 : 2).map((row) => (
|
|
213
290
|
<View key={row.map((account) => account.id).join()} style={{ flexDirection: "row", gap: 10 }}>
|
|
214
291
|
{row.map((account) => (
|
|
@@ -217,6 +294,7 @@ function FamilySection({
|
|
|
217
294
|
account={account}
|
|
218
295
|
theme={theme}
|
|
219
296
|
store={store}
|
|
297
|
+
paidFallback={state.paidApiFallback ?? false}
|
|
220
298
|
onSignIn={() => onSignIn(account)}
|
|
221
299
|
/>
|
|
222
300
|
))}
|
|
@@ -231,22 +309,33 @@ function AccountCard({
|
|
|
231
309
|
account,
|
|
232
310
|
theme,
|
|
233
311
|
store,
|
|
312
|
+
paidFallback,
|
|
234
313
|
onSignIn,
|
|
235
314
|
}: {
|
|
236
315
|
account: AccountView;
|
|
237
316
|
theme: Theme;
|
|
238
317
|
store: ZeroSubStore;
|
|
318
|
+
/** Paid API accounts (Azure) may take work over by themselves once every subscription is out. */
|
|
319
|
+
paidFallback: boolean;
|
|
239
320
|
onSignIn(): void;
|
|
240
321
|
}) {
|
|
241
322
|
const text = useText(theme);
|
|
242
323
|
const toast = useToast();
|
|
243
|
-
const [busy, setBusy] = useState<"default" | "remove" | "clear" | "toggle" | null>(null);
|
|
324
|
+
const [busy, setBusy] = useState<"default" | "remove" | "clear" | "toggle" | "next" | null>(null);
|
|
244
325
|
const [renaming, setRenaming] = useState(false);
|
|
326
|
+
const [editingApi, setEditingApi] = useState(false);
|
|
327
|
+
const [editingProxy, setEditingProxy] = useState(false);
|
|
328
|
+
const api = account.auth === "api";
|
|
329
|
+
// An Azure OpenAI account's endpoint, key and prices have a form of their own.
|
|
330
|
+
const azure = account.azure !== null;
|
|
331
|
+
const [editingAzure, setEditingAzure] = useState(false);
|
|
332
|
+
const details = piCardDetails(account) ?? claudeCardDetails(account) ?? azureCardDetails(account);
|
|
245
333
|
const [confirmRemove, setConfirmRemove] = useState(false);
|
|
246
334
|
const [confirmReset, setConfirmReset] = useState(false);
|
|
247
335
|
const resets = account.usage?.resets ?? null;
|
|
248
336
|
const credits = account.usage?.credits ?? null;
|
|
249
|
-
const
|
|
337
|
+
const extraUsage = account.usage?.extraUsage ? formatExtraUsage(account.usage.extraUsage) : null;
|
|
338
|
+
const plan = azure ? null : formatPlan(account.plan);
|
|
250
339
|
const summary = usageSummary(account);
|
|
251
340
|
const subtitle = accountSubtitle(account);
|
|
252
341
|
const signedOut = account.status === "signed_out";
|
|
@@ -265,11 +354,12 @@ function AccountCard({
|
|
|
265
354
|
const message = describeReopen(`${account.label} is ${enabling ? "enabled" : "disabled"}`, result);
|
|
266
355
|
const stayed =
|
|
267
356
|
result.stayed > 0
|
|
268
|
-
? ` · ${result.stayed}
|
|
357
|
+
? ` · ${result.stayed} ${FAMILY_LABEL[account.family]} conversation${result.stayed === 1 ? " stays" : "s stay"} on it (they can't change accounts)`
|
|
269
358
|
: "";
|
|
270
|
-
toast.show(`${message}${stayed}`, { variant: "success", durationMs: 5_000 });
|
|
359
|
+
toast.show(`${message}${stayed}`, { variant: result.failed.length > 0 ? "warning" : "success", durationMs: 5_000 });
|
|
271
360
|
} catch (error) {
|
|
272
|
-
toast.
|
|
361
|
+
if (stoppedWaiting(error)) toast.show(stillMoving(account.label), { variant: "info", durationMs: 5_000 });
|
|
362
|
+
else toast.error(describe(error));
|
|
273
363
|
} finally {
|
|
274
364
|
setBusy(null);
|
|
275
365
|
}
|
|
@@ -279,7 +369,22 @@ function AccountCard({
|
|
|
279
369
|
setBusy("default");
|
|
280
370
|
try {
|
|
281
371
|
const summary = await store.rpc(setDefaultAccount, { accountId: account.id });
|
|
282
|
-
toast.show(describeReopen(`${account.label} is now the default`, summary), { variant: "success" });
|
|
372
|
+
toast.show(describeReopen(`${account.label} is now the default`, summary), { variant: summary.failed.length > 0 ? "warning" : "success" });
|
|
373
|
+
await store.refresh();
|
|
374
|
+
} catch (error) {
|
|
375
|
+
if (stoppedWaiting(error)) toast.show(stillMoving(account.label), { variant: "info", durationMs: 5_000 });
|
|
376
|
+
else toast.error(describe(error));
|
|
377
|
+
} finally {
|
|
378
|
+
setBusy(null);
|
|
379
|
+
}
|
|
380
|
+
}, [account, store, toast]);
|
|
381
|
+
|
|
382
|
+
const nextAgent = useCallback(async () => {
|
|
383
|
+
setBusy("next");
|
|
384
|
+
const enabled = !account.nextAgentUntil;
|
|
385
|
+
try {
|
|
386
|
+
await store.rpc(setNextAgentAccount, { accountId: account.id, enabled });
|
|
387
|
+
toast.show(enabled ? `Your next new agent starts on ${account.label} (for the next 10 minutes)` : "Next new agent: back to the default", { variant: "success" });
|
|
283
388
|
await store.refresh();
|
|
284
389
|
} catch (error) {
|
|
285
390
|
toast.error(describe(error));
|
|
@@ -305,15 +410,25 @@ function AccountCard({
|
|
|
305
410
|
setBusy("remove");
|
|
306
411
|
try {
|
|
307
412
|
const result = await store.rpc(removeAccount, { accountId: account.id });
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
413
|
+
const removed = `Removed ${account.label}`;
|
|
414
|
+
// An older server only says how many agents ran on it, not how moving them went.
|
|
415
|
+
const message = result.moves
|
|
416
|
+
? describeReopen(removed, result.moves)
|
|
417
|
+
: result.movedAgents > 0
|
|
418
|
+
? `${removed}; ${result.movedAgents} agent(s) move off it`
|
|
419
|
+
: removed;
|
|
420
|
+
toast.show(message, { variant: result.moves?.failed.length ? "warning" : "success" });
|
|
314
421
|
await store.refresh();
|
|
315
422
|
} catch (error) {
|
|
316
|
-
|
|
423
|
+
if (stoppedWaiting(error)) {
|
|
424
|
+
toast.show(`Still removing ${account.label} and moving its agents off it. Their timelines say when each has switched.`, {
|
|
425
|
+
variant: "info",
|
|
426
|
+
durationMs: 5_000,
|
|
427
|
+
});
|
|
428
|
+
void store.refresh();
|
|
429
|
+
} else {
|
|
430
|
+
toast.error(describe(error));
|
|
431
|
+
}
|
|
317
432
|
} finally {
|
|
318
433
|
setBusy(null);
|
|
319
434
|
setConfirmRemove(false);
|
|
@@ -347,6 +462,21 @@ function AccountCard({
|
|
|
347
462
|
onPress={() => void markAvailable()}
|
|
348
463
|
/>
|
|
349
464
|
) : null}
|
|
465
|
+
{/* A pick waiting here can always be canceled, whatever has become of the account since. */}
|
|
466
|
+
{account.nextAgentUntil || (!signedOut && !disabled) ? (
|
|
467
|
+
<IconButton
|
|
468
|
+
theme={theme}
|
|
469
|
+
icon={account.nextAgentUntil ? "CircleX" : "SquarePlus"}
|
|
470
|
+
label={account.nextAgentUntil ? "Cancel: next new agent goes back to the default" : "Use for the next new agent"}
|
|
471
|
+
tooltip={
|
|
472
|
+
account.nextAgentUntil
|
|
473
|
+
? "Your next new agent starts here. Click to cancel"
|
|
474
|
+
: "Next new agent: the next agent you start (new workspace or tab) uses this account, once"
|
|
475
|
+
}
|
|
476
|
+
busy={busy === "next"}
|
|
477
|
+
onPress={() => void nextAgent()}
|
|
478
|
+
/>
|
|
479
|
+
) : null}
|
|
350
480
|
{!account.isDefault && !signedOut && !disabled ? (
|
|
351
481
|
<IconButton
|
|
352
482
|
theme={theme}
|
|
@@ -357,25 +487,43 @@ function AccountCard({
|
|
|
357
487
|
onPress={() => void makeDefault()}
|
|
358
488
|
/>
|
|
359
489
|
) : null}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
disabled
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
490
|
+
{/* No Pi account stands in for another, so one can't be disabled (see setAccountEnabled). */}
|
|
491
|
+
{account.family === "pi" && !disabled ? null : (
|
|
492
|
+
<IconButton
|
|
493
|
+
theme={theme}
|
|
494
|
+
icon={disabled ? "CirclePlay" : "CirclePause"}
|
|
495
|
+
label={disabled ? "Enable account" : "Disable for now (agents won't use it)"}
|
|
496
|
+
tooltip={
|
|
497
|
+
disabled
|
|
498
|
+
? "Enable: agents can use this account again"
|
|
499
|
+
: "Disable for now: agents stop using it and move to your other accounts"
|
|
500
|
+
}
|
|
501
|
+
busy={busy === "toggle"}
|
|
502
|
+
onPress={() => void toggle()}
|
|
503
|
+
/>
|
|
504
|
+
)}
|
|
505
|
+
{account.apiEditable ? (
|
|
506
|
+
<IconButton theme={theme} icon="KeyRound" label="API settings" tooltip="API settings: key and base URL" onPress={() => setEditingApi(true)} />
|
|
507
|
+
) : null}
|
|
508
|
+
{azure ? (
|
|
509
|
+
<IconButton theme={theme} icon="KeyRound" label="Azure settings" tooltip="Azure settings: endpoint, key and prices" onPress={() => setEditingAzure(true)} />
|
|
510
|
+
) : null}
|
|
511
|
+
{account.proxyEditable ? (
|
|
512
|
+
<IconButton theme={theme} icon="Globe" label="Proxy" tooltip="Proxy: the network this account uses" onPress={() => setEditingProxy(true)} />
|
|
513
|
+
) : null}
|
|
372
514
|
<IconButton theme={theme} icon="Pencil" label="Rename" tooltip="Rename this account" onPress={() => setRenaming(true)} />
|
|
373
515
|
{account.kind !== "main" ? (
|
|
374
516
|
<IconButton
|
|
375
517
|
theme={theme}
|
|
376
518
|
icon="Trash2"
|
|
377
519
|
label="Remove"
|
|
378
|
-
tooltip=
|
|
520
|
+
tooltip={
|
|
521
|
+
account.externalHome
|
|
522
|
+
? "Remove from ZeroSub only: its folder, key and script stay"
|
|
523
|
+
: api
|
|
524
|
+
? "Remove: delete its saved key"
|
|
525
|
+
: "Remove: sign it out and delete its saved login"
|
|
526
|
+
}
|
|
379
527
|
tone="danger"
|
|
380
528
|
busy={busy === "remove"}
|
|
381
529
|
onPress={() => setConfirmRemove(true)}
|
|
@@ -388,21 +536,46 @@ function AccountCard({
|
|
|
388
536
|
{account.isDefault ? <Badge theme={theme} label="Default" tone="accent" /> : null}
|
|
389
537
|
{disabled ? <Badge theme={theme} label="Disabled" /> : null}
|
|
390
538
|
{plan ? <Badge theme={theme} label={plan} /> : null}
|
|
539
|
+
{azure ? <Badge theme={theme} label="Azure · API" /> : api ? <Badge theme={theme} label="API" /> : null}
|
|
391
540
|
{account.kind === "main" ? <Badge theme={theme} label="CLI login" /> : null}
|
|
392
541
|
{account.status === "limited" ? <Badge theme={theme} label="Limit reached" tone="danger" /> : null}
|
|
393
542
|
{account.status === "signed_out" ? <Badge theme={theme} label="Signed out" tone="warning" /> : null}
|
|
543
|
+
{account.pace?.gated ? <Badge theme={theme} label="Held back" tone="warning" /> : null}
|
|
394
544
|
{resets && !signedOut ? <Badge theme={theme} label={resetBadge(resets)} tone="accent" /> : null}
|
|
395
545
|
</View>
|
|
396
546
|
|
|
547
|
+
{details ? (
|
|
548
|
+
<Text selectable style={[text.small, faded]} numberOfLines={3}>
|
|
549
|
+
{details}
|
|
550
|
+
</Text>
|
|
551
|
+
) : null}
|
|
552
|
+
{account.moving ? (
|
|
553
|
+
<Text style={[account.moving.error ? text.danger : text.small, faded]}>
|
|
554
|
+
{account.moving.error
|
|
555
|
+
? `Couldn't move its folder to ${account.moving.to}: ${account.moving.error}`
|
|
556
|
+
: `Moving its folder to ${account.moving.to}${account.moving.waiting ? `: ${account.moving.waiting}` : "…"}`}
|
|
557
|
+
</Text>
|
|
558
|
+
) : null}
|
|
559
|
+
|
|
397
560
|
<View style={[{ gap: 10 }, faded]}>
|
|
398
561
|
{signedOut ? (
|
|
399
|
-
<Text style={text.small}>Sign in again to use this account
|
|
562
|
+
<Text style={text.small}>{api ? "The key was refused. Enter a working one to use this account." : "Sign in again to use this account."}</Text>
|
|
563
|
+
) : azure ? (
|
|
564
|
+
<AzureUsage theme={theme} account={account} paidFallback={paidFallback} />
|
|
565
|
+
) : api ? (
|
|
566
|
+
<Text style={text.small}>Billed per use · used only as the default or when picked for an agent</Text>
|
|
400
567
|
) : windows.length > 0 ? (
|
|
401
568
|
windows.map((limit) => <UsageBar key={limit.id} theme={theme} limit={limit} />)
|
|
402
569
|
) : (
|
|
403
570
|
<Text style={text.small}>{account.usage?.error ?? summary ?? "Checking usage…"}</Text>
|
|
404
571
|
)}
|
|
572
|
+
{account.pace ? (
|
|
573
|
+
<View style={{ borderTopWidth: 1, borderTopColor: theme.colors.border, paddingTop: 10 }}>
|
|
574
|
+
<PaceSection theme={theme} pace={account.pace} />
|
|
575
|
+
</View>
|
|
576
|
+
) : null}
|
|
405
577
|
{!signedOut && credits ? <Text style={text.small}>{formatCredits(credits)}</Text> : null}
|
|
578
|
+
{!signedOut && extraUsage ? <Text style={text.small}>{extraUsage}</Text> : null}
|
|
406
579
|
{!signedOut && windows.length > 0 && account.usage?.error ? <Text style={text.small}>{account.usage.error}</Text> : null}
|
|
407
580
|
{!signedOut && resets?.blockedReason ? <Text style={text.small}>{resets.blockedReason}</Text> : null}
|
|
408
581
|
</View>
|
|
@@ -431,11 +604,11 @@ function AccountCard({
|
|
|
431
604
|
theme={theme}
|
|
432
605
|
size="small"
|
|
433
606
|
tone="primary"
|
|
434
|
-
icon="LogIn"
|
|
435
|
-
label="Sign in"
|
|
436
|
-
tooltip="Sign this account in again"
|
|
607
|
+
icon={api ? "KeyRound" : "LogIn"}
|
|
608
|
+
label={api ? "Fix key" : "Sign in"}
|
|
609
|
+
tooltip={api ? "Enter a working key for this account" : "Sign this account in again"}
|
|
437
610
|
tooltipAlign="end"
|
|
438
|
-
onPress={onSignIn}
|
|
611
|
+
onPress={azure ? () => setEditingAzure(true) : api ? () => setEditingApi(true) : onSignIn}
|
|
439
612
|
/>
|
|
440
613
|
) : disabled ? (
|
|
441
614
|
<Button
|
|
@@ -484,12 +657,29 @@ function AccountCard({
|
|
|
484
657
|
{renaming ? (
|
|
485
658
|
<RenameModal theme={theme} account={account} store={store} onClose={() => setRenaming(false)} />
|
|
486
659
|
) : null}
|
|
660
|
+
{editingApi ? (
|
|
661
|
+
account.family === "claude" ? (
|
|
662
|
+
<ApiAccountModal theme={theme} store={store} account={account} onClose={() => setEditingApi(false)} />
|
|
663
|
+
) : (
|
|
664
|
+
<ApiKeyModal theme={theme} store={store} account={account} onClose={() => setEditingApi(false)} />
|
|
665
|
+
)
|
|
666
|
+
) : null}
|
|
667
|
+
{editingAzure ? (
|
|
668
|
+
<AzureAccountModal theme={theme} store={store} account={account} paidFallback={paidFallback} onClose={() => setEditingAzure(false)} />
|
|
669
|
+
) : null}
|
|
670
|
+
{editingProxy ? <ProxyModal theme={theme} store={store} account={account} onClose={() => setEditingProxy(false)} /> : null}
|
|
487
671
|
<Modal title={`Remove ${account.label}?`} open={confirmRemove} onOpenChange={setConfirmRemove}>
|
|
488
672
|
<Modal.Content>
|
|
489
673
|
<Text style={text.body}>
|
|
490
|
-
{account.
|
|
491
|
-
?
|
|
492
|
-
:
|
|
674
|
+
{account.externalHome
|
|
675
|
+
? `This only removes the account from ZeroSub. Its folder${account.home ? ` (${account.home})` : ""}, its key${account.launcher ? ` and its terminal script ${account.launcher}` : ""} stay as they are, and you can add it back from Add account. Agents using it move to the default account; their conversations are kept.`
|
|
676
|
+
: account.family === "pi"
|
|
677
|
+
? "This deletes the account's folder and saved key on this machine. Agents using it move to the default account; their conversations are kept."
|
|
678
|
+
: azure
|
|
679
|
+
? "This deletes the account's saved key and endpoint on this machine, and its token counts. New agents use the default account. Existing ChatGPT conversations on it can't move, so start new agents for them."
|
|
680
|
+
: account.family === "claude"
|
|
681
|
+
? "This signs the account out on this machine and deletes its saved login. Agents using it move to the default account; their conversations are kept."
|
|
682
|
+
: `This signs the account out on this machine and deletes its saved login. New agents use the default account. Existing ${FAMILY_LABEL[account.family]} conversations on it can't move, so start new agents for them.`}
|
|
493
683
|
</Text>
|
|
494
684
|
<View style={{ flexDirection: "row", gap: 8, justifyContent: "flex-end" }}>
|
|
495
685
|
<Button theme={theme} label="Cancel" tooltip="Keep this account" tooltipAlign="end" onPress={() => setConfirmRemove(false)} />
|
|
@@ -498,7 +688,13 @@ function AccountCard({
|
|
|
498
688
|
tone="danger"
|
|
499
689
|
icon="Trash2"
|
|
500
690
|
label="Remove"
|
|
501
|
-
tooltip=
|
|
691
|
+
tooltip={
|
|
692
|
+
account.externalHome
|
|
693
|
+
? "Remove it from ZeroSub only; its agents move to the default"
|
|
694
|
+
: api
|
|
695
|
+
? "Delete its saved key; its agents move to the default"
|
|
696
|
+
: "Sign it out and delete its saved login; its agents move to the default"
|
|
697
|
+
}
|
|
502
698
|
tooltipAlign="end"
|
|
503
699
|
busy={busy === "remove"}
|
|
504
700
|
onPress={() => void remove()}
|
|
@@ -605,7 +801,7 @@ function Avatar({ theme, label }: { theme: Theme; label: string }) {
|
|
|
605
801
|
);
|
|
606
802
|
}
|
|
607
803
|
|
|
608
|
-
function AutomationSettings({ theme }: { theme: Theme }) {
|
|
804
|
+
function AutomationSettings({ theme, compact }: { theme: Theme; compact: boolean }) {
|
|
609
805
|
const settings = useSettings(preferences);
|
|
610
806
|
const text = useText(theme);
|
|
611
807
|
if (settings.status === "loading") return null;
|
|
@@ -615,73 +811,111 @@ function AutomationSettings({ theme }: { theme: Theme }) {
|
|
|
615
811
|
const save = (patch: Partial<typeof settings.values>) =>
|
|
616
812
|
void settings.save({ ...settings.values, ...patch }, settings.revision);
|
|
617
813
|
return (
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
814
|
+
// Same gap as the page's other sections, so the OpenCode card reads as its own section.
|
|
815
|
+
<View style={{ gap: compact ? 20 : 28 }}>
|
|
816
|
+
<View style={{ gap: 10 }}>
|
|
817
|
+
<Text style={text.heading} accessibilityRole="header">
|
|
818
|
+
Automatic switching
|
|
819
|
+
</Text>
|
|
820
|
+
<SettingsCard>
|
|
821
|
+
<SettingsSwitch
|
|
822
|
+
label="Switch accounts when one hits its limit"
|
|
823
|
+
hint="Agents move to the account with the most room left."
|
|
824
|
+
value={settings.values.autoSwitch}
|
|
825
|
+
disabled={settings.saving}
|
|
826
|
+
onValueChange={(autoSwitch) => save({ autoSwitch })}
|
|
827
|
+
/>
|
|
828
|
+
<SettingsSwitch
|
|
829
|
+
label="Keep going after a switch"
|
|
830
|
+
hint="Sends a short follow-up so the interrupted task continues."
|
|
831
|
+
value={settings.values.autoContinue}
|
|
832
|
+
disabled={settings.saving || !settings.values.autoSwitch}
|
|
833
|
+
onValueChange={(autoContinue) => save({ autoContinue })}
|
|
834
|
+
/>
|
|
835
|
+
<SettingsSwitch
|
|
836
|
+
label="Spread new agents across accounts"
|
|
837
|
+
hint="New ChatGPT agents prefer a weekly reset within one day when both limits have at least 20% left. Otherwise, new agents use the account with the most room."
|
|
838
|
+
value={settings.values.balanceNewAgents}
|
|
839
|
+
disabled={settings.saving}
|
|
840
|
+
onValueChange={(balanceNewAgents) => save({ balanceNewAgents })}
|
|
841
|
+
/>
|
|
842
|
+
<SettingsSwitch
|
|
843
|
+
label="Move open agents when the default changes"
|
|
844
|
+
hint="Off: open agents stay on the account they're using, even after they reopen. New agents, and agents that aren't open at the time, use the new default."
|
|
845
|
+
value={settings.values.moveAgentsOnDefaultChange}
|
|
846
|
+
disabled={settings.saving}
|
|
847
|
+
onValueChange={(moveAgentsOnDefaultChange) => save({ moveAgentsOnDefaultChange })}
|
|
848
|
+
/>
|
|
849
|
+
<SettingsSwitch
|
|
850
|
+
label="Use banked resets when every account is out"
|
|
851
|
+
hint="Spends one of the account's banked resets instead of stopping. Resets are scarce, so this is off unless you turn it on."
|
|
852
|
+
value={settings.values.autoRedeem}
|
|
853
|
+
disabled={settings.saving || !settings.values.autoSwitch}
|
|
854
|
+
onValueChange={(autoRedeem) => save({ autoRedeem })}
|
|
855
|
+
/>
|
|
856
|
+
<SettingsSwitch
|
|
857
|
+
label="Use ChatGPT credits when a limit is reached"
|
|
858
|
+
hint="A ChatGPT account at its limit stays in use while it has credits, so new agents may spend paid credits even while another account still has room."
|
|
859
|
+
value={settings.values.useCredits}
|
|
860
|
+
disabled={settings.saving}
|
|
861
|
+
onValueChange={(useCredits) => save({ useCredits })}
|
|
862
|
+
/>
|
|
863
|
+
<SettingsSwitch
|
|
864
|
+
label="Use paid API accounts when every subscription is out"
|
|
865
|
+
hint="Off unless you turn it on. When every ChatGPT subscription account is at its limit, signed out or disabled, agents may move to an Azure OpenAI account, billed per token (after a banked reset, if those are used automatically). Off, it's used only as the default or when you pick it for an agent."
|
|
866
|
+
value={settings.values.paidApiFallback}
|
|
867
|
+
disabled={settings.saving}
|
|
868
|
+
onValueChange={(paidApiFallback) => save({ paidApiFallback })}
|
|
869
|
+
/>
|
|
870
|
+
<SettingsSwitch
|
|
871
|
+
label="When every account is out, fork the chat to the other provider"
|
|
872
|
+
hint="A stopped Claude chat carries on in a new ChatGPT or OpenCode agent (pick the destination below) with the conversation so far. ChatGPT gets a mode no looser than this agent's. OpenCode gets Plan or Build under the host's own permission policy, which can allow more than Claude does. The original stays as it was."
|
|
873
|
+
value={settings.values.forkOtherProvider}
|
|
874
|
+
disabled={settings.saving || !settings.values.autoSwitch}
|
|
875
|
+
onValueChange={(forkOtherProvider) => save({ forkOtherProvider })}
|
|
876
|
+
/>
|
|
877
|
+
<ForkDestinationRows values={settings.values} saving={settings.saving} onSave={save} />
|
|
878
|
+
<SettingsSwitch
|
|
879
|
+
label="Keep a Codex chat in the same conversation"
|
|
880
|
+
hint="Off unless you turn it on. Two ChatGPT accounts in one workspace reload this agent on the other account instead of opening a new tab. A different workspace, an email-only account, or a workspace that is out of credits still opens a new tab. If the first turn cannot resume the thread, this agent goes back and the new tab opens."
|
|
881
|
+
value={settings.values.codexSameConversation}
|
|
882
|
+
disabled={settings.saving || !settings.values.autoSwitch}
|
|
883
|
+
onValueChange={(codexSameConversation) => save({ codexSameConversation })}
|
|
884
|
+
/>
|
|
885
|
+
</SettingsCard>
|
|
886
|
+
</View>
|
|
887
|
+
<View style={{ gap: 10 }}>
|
|
888
|
+
<Text style={text.heading} accessibilityRole="header">
|
|
889
|
+
Continue on OpenCode
|
|
890
|
+
</Text>
|
|
891
|
+
<SettingsCard>
|
|
892
|
+
<OpenCodeForkRows values={settings.values} saving={settings.saving} onSave={save} />
|
|
893
|
+
</SettingsCard>
|
|
894
|
+
</View>
|
|
673
895
|
{settings.saveError ? <Text style={text.danger}>{settings.saveError}</Text> : null}
|
|
674
896
|
</View>
|
|
675
897
|
);
|
|
676
898
|
}
|
|
677
899
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
900
|
+
/** Paseo stopped waiting for a change that moves agents; the daemon carries on with it. */
|
|
901
|
+
/**
|
|
902
|
+
* A Claude card's line about its key (an API account's) and its network: its own proxy and the
|
|
903
|
+
* address Anthropic sees its requests come from.
|
|
904
|
+
*/
|
|
905
|
+
function claudeCardDetails(account: AccountView): string | null {
|
|
906
|
+
if (account.family !== "claude") return null;
|
|
907
|
+
const api = account.api;
|
|
908
|
+
const parts = [
|
|
909
|
+
api ? `${api.keyKind === "api_key" ? "Key" : "Token"}${api.keyHint ? ` …${api.keyHint}` : ""} · ${api.baseUrl ?? "Anthropic API"}` : null,
|
|
910
|
+
account.proxy ? `Via ${account.proxy}` : null,
|
|
911
|
+
egressText(account.egress),
|
|
912
|
+
account.launcher ? `Terminal: ${account.launcher}` : null,
|
|
913
|
+
].filter(Boolean);
|
|
914
|
+
return parts.length > 0 ? parts.join(" · ") : null;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
function stillMoving(label: string): string {
|
|
918
|
+
return `Still moving agents for ${label}. Their timelines say when each has switched.`;
|
|
685
919
|
}
|
|
686
920
|
|
|
687
921
|
function chunk<T>(items: T[], size: number): T[][] {
|