@cortexkit/opencode-anthropic-auth 1.22.0 → 1.23.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 +37 -20
- package/dist/billing-lineage.d.ts +51 -0
- package/dist/claustrum-enrollment-registry.d.ts +4 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +89 -6
- package/dist/custody-dimensions.d.ts +36 -0
- package/dist/custody-enrollment.d.ts +14 -0
- package/dist/custody-live.d.ts +111 -0
- package/dist/custody-manifest-watcher.d.ts +16 -0
- package/dist/custody-mode.d.ts +186 -0
- package/dist/effort-history.d.ts +5 -1
- package/dist/fable-fallback.d.ts +1 -1
- package/dist/{index-926t2bzc.js → index-0jfsxyn9.js} +1 -1
- package/dist/index-1fq7h6yd.js +430 -0
- package/dist/{index-7f57ewkp.js → index-1gr8v4fn.js} +1 -1
- package/dist/index-797pmamn.js +2 -0
- package/dist/{index-bx5hsgf8.js → index-8y2t4mwz.js} +2 -2
- package/dist/index-a5d6v3ba.js +5 -0
- package/dist/index-n96q8pks.js +2 -0
- package/dist/index-xxhyhp98.js +2 -0
- package/dist/index-xzbhzz0a.js +2 -0
- package/dist/index-z7gfdyv3.js +1 -0
- package/dist/index.js +27 -22
- package/dist/local-login.d.ts +64 -0
- package/dist/{logger-jrkranbz.js → logger-kk9vyem9.js} +1 -1
- package/dist/prime-manager-registry.d.ts +5 -1
- package/dist/rpc/notifications.d.ts +3 -3
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +9 -2
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.d.ts +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/rpc/server-registry.d.ts +10 -0
- package/dist/setup/activation.d.ts +7 -0
- package/dist/setup/claustrum.d.ts +26 -0
- package/dist/setup/command-runner.d.ts +2 -0
- package/dist/setup/command.d.ts +8 -0
- package/dist/setup/detect.d.ts +5 -0
- package/dist/setup/jsonc.d.ts +9 -0
- package/dist/setup/opencode-config.d.ts +18 -0
- package/dist/setup/paths.d.ts +15 -0
- package/dist/setup/pi.d.ts +8 -0
- package/dist/setup/process-fence.d.ts +14 -0
- package/dist/setup/types.d.ts +37 -0
- package/dist/sidebar-state.d.ts +3 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/transform.d.ts +5 -1
- package/dist/tui/command-dialogs.d.ts +27 -2
- package/dist/tui-preferences.js +2 -2
- package/package.json +10 -5
- package/src/rpc/notifications.ts +28 -24
- package/src/rpc/protocol.ts +18 -2
- package/src/rpc/rpc-client.ts +1 -1
- package/src/rpc/rpc-server.ts +18 -5
- package/src/rpc/server-registry.ts +61 -0
- package/src/sidebar-state.ts +26 -2
- package/src/tui/command-dialogs.tsx +273 -68
- package/src/tui-compiled/rpc/protocol.ts +18 -2
- package/src/tui-compiled/rpc/rpc-client.ts +1 -1
- package/src/tui-compiled/sidebar-state.ts +26 -2
- package/src/tui-compiled/tui/command-dialogs.tsx +215 -61
- package/src/tui-compiled/tui.tsx +1 -0
- package/src/tui.tsx +1 -0
- package/dist/index-8aga2zwv.js +0 -4
- package/dist/index-cgez4m0h.js +0 -2
- package/dist/index-d3f8g6ve.js +0 -428
- package/dist/index-sh51yqxs.js +0 -2
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ClaustrumEnrollmentStatus } from '@cortexkit/anthropic-auth-core'
|
|
2
|
+
|
|
1
3
|
export const COMMAND_MODAL_NAMES = [
|
|
2
4
|
'claude-account',
|
|
3
5
|
'claude-cache',
|
|
@@ -17,17 +19,31 @@ export type CommandModalName = (typeof COMMAND_MODAL_NAMES)[number]
|
|
|
17
19
|
export interface AccountDialogAccount {
|
|
18
20
|
id: string
|
|
19
21
|
label: string
|
|
20
|
-
role:
|
|
22
|
+
role: 'main' | 'fallback'
|
|
21
23
|
enabled: boolean
|
|
22
24
|
quotaPercent: number | null
|
|
23
25
|
tierLabel?: string
|
|
24
26
|
claustrumGate: 'on' | 'off' | 'na'
|
|
25
27
|
vaultServed: boolean
|
|
28
|
+
vaultReauth: boolean
|
|
29
|
+
custodyState:
|
|
30
|
+
| 'na'
|
|
31
|
+
| 'off'
|
|
32
|
+
| 'on-vault-served'
|
|
33
|
+
| 'on-vault-reauth'
|
|
34
|
+
| 'on-cold'
|
|
35
|
+
| 'unknown-identity'
|
|
36
|
+
| 'on-identity-mismatch'
|
|
37
|
+
| 'on-corrupt-binding'
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
export interface AccountDialogKnobs {
|
|
29
41
|
accounts: AccountDialogAccount[]
|
|
30
42
|
claustrumDetection: string
|
|
43
|
+
custodyMode?: 'local' | 'claustrum'
|
|
44
|
+
custodyModeKnown?: boolean
|
|
45
|
+
enrollmentStatus?: string
|
|
46
|
+
claustrumEnrollment?: ClaustrumEnrollmentStatus
|
|
31
47
|
[key: string]: unknown
|
|
32
48
|
}
|
|
33
49
|
|
|
@@ -41,7 +57,7 @@ export interface RpcNotification {
|
|
|
41
57
|
id: number
|
|
42
58
|
type: 'open-dialog'
|
|
43
59
|
payload: OpenDialogPayload
|
|
44
|
-
sessionId
|
|
60
|
+
sessionId: string
|
|
45
61
|
}
|
|
46
62
|
|
|
47
63
|
export interface ApplyRequest {
|
|
@@ -4,7 +4,7 @@ import type { ApplyRequest, ApplyResult, RpcNotification } from './protocol'
|
|
|
4
4
|
export interface RpcClient {
|
|
5
5
|
pending: (
|
|
6
6
|
lastReceivedId: number,
|
|
7
|
-
sessionId
|
|
7
|
+
sessionId: string,
|
|
8
8
|
) => Promise<RpcNotification[]>
|
|
9
9
|
apply: (request: ApplyRequest) => Promise<ApplyResult>
|
|
10
10
|
}
|
|
@@ -36,6 +36,16 @@ export interface SidebarAccountState {
|
|
|
36
36
|
needsReauth: boolean
|
|
37
37
|
// True when the vault copy needs re-importing while the sidecar remains usable.
|
|
38
38
|
vaultReauth?: boolean
|
|
39
|
+
// A gate alone does not prove the sidecar can serve a request.
|
|
40
|
+
vaultServed?: boolean
|
|
41
|
+
custodyState?:
|
|
42
|
+
| 'off'
|
|
43
|
+
| 'on-vault-served'
|
|
44
|
+
| 'on-vault-reauth'
|
|
45
|
+
| 'on-cold'
|
|
46
|
+
| 'unknown-identity'
|
|
47
|
+
| 'on-identity-mismatch'
|
|
48
|
+
| 'on-corrupt-binding'
|
|
39
49
|
tierLabel?: string
|
|
40
50
|
}
|
|
41
51
|
|
|
@@ -59,7 +69,7 @@ export interface PrimeSidebarAccountState {
|
|
|
59
69
|
label: string
|
|
60
70
|
nextDueAt?: number | null
|
|
61
71
|
lastPrimedAt?: number | null
|
|
62
|
-
lastResult?: 'ok' | 'error'
|
|
72
|
+
lastResult?: 'ok' | 'error' | 'skipped'
|
|
63
73
|
usage?: PrimeUsageCounters
|
|
64
74
|
estimatedCostUsd?: number
|
|
65
75
|
}
|
|
@@ -180,7 +190,11 @@ function normalizePrimeAccount(
|
|
|
180
190
|
} else if (isFiniteNumber(value.lastPrimedAt)) {
|
|
181
191
|
account.lastPrimedAt = value.lastPrimedAt
|
|
182
192
|
}
|
|
183
|
-
if (
|
|
193
|
+
if (
|
|
194
|
+
value.lastResult === 'ok' ||
|
|
195
|
+
value.lastResult === 'error' ||
|
|
196
|
+
value.lastResult === 'skipped'
|
|
197
|
+
) {
|
|
184
198
|
account.lastResult = value.lastResult
|
|
185
199
|
}
|
|
186
200
|
const usage = normalizePrimeUsage(value.usage)
|
|
@@ -338,6 +352,11 @@ export function normalizeSidebarState(raw: unknown): SidebarState {
|
|
|
338
352
|
needsReauth:
|
|
339
353
|
typeof entry.needsReauth === 'boolean' ? entry.needsReauth : false,
|
|
340
354
|
...(entry.vaultReauth === true && { vaultReauth: true }),
|
|
355
|
+
...(entry.vaultServed === true && { vaultServed: true }),
|
|
356
|
+
...(typeof entry.custodyState === 'string' && {
|
|
357
|
+
custodyState:
|
|
358
|
+
entry.custodyState as SidebarAccountState['custodyState'],
|
|
359
|
+
}),
|
|
341
360
|
tierLabel:
|
|
342
361
|
typeof entry.tierLabel === 'string' && entry.tierLabel.trim()
|
|
343
362
|
? entry.tierLabel.trim()
|
|
@@ -817,6 +836,8 @@ export function formatFallbackModelLabel(modelId: string | undefined): string {
|
|
|
817
836
|
return 'Fable 5.1'
|
|
818
837
|
if (modelId === 'claude-fable-5' || modelId?.startsWith('claude-fable-5-'))
|
|
819
838
|
return 'Fable 5'
|
|
839
|
+
if (modelId === 'claude-opus-5-5' || modelId?.startsWith('claude-opus-5-5-'))
|
|
840
|
+
return 'Opus 5.5'
|
|
820
841
|
if (modelId === 'claude-opus-5' || modelId?.startsWith('claude-opus-5-'))
|
|
821
842
|
return 'Opus 5'
|
|
822
843
|
if (modelId === 'claude-opus-4-8' || modelId?.startsWith('claude-opus-4-8-'))
|
|
@@ -844,6 +865,9 @@ export function formatPrimeAccountValue(account: PrimeSidebarAccountState): {
|
|
|
844
865
|
if (account.lastResult === 'error') {
|
|
845
866
|
return { text: 'err', hasError: true }
|
|
846
867
|
}
|
|
868
|
+
if (account.lastResult === 'skipped') {
|
|
869
|
+
return { text: 'skip', hasError: false }
|
|
870
|
+
}
|
|
847
871
|
if (account.nextDueAt && account.nextDueAt > Date.now()) {
|
|
848
872
|
return { text: formatPrimeTime(account.nextDueAt), hasError: false }
|
|
849
873
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createTextNode as _$createTextNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
|
+
import { effect as _$effect } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
3
|
+
import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
4
|
import { createComponent as _$createComponent } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
3
5
|
import { insertNode as _$insertNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
4
6
|
import { insert as _$insert } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
5
7
|
import { setProp as _$setProp } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
6
8
|
import { createElement as _$createElement } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
7
9
|
/** @jsxImportSource @opentui/solid */
|
|
8
|
-
|
|
10
|
+
import { custodyStatusLabel } from "@cortexkit/anthropic-auth-core";
|
|
9
11
|
import { formatPrimeCost, formatPrimeTime } from "../sidebar-state.js";
|
|
10
12
|
export const PRIME_DIALOG_OPTIONS = [{
|
|
11
13
|
title: 'Enable',
|
|
@@ -42,19 +44,121 @@ export function buildKillswitchThresholdSeed(config, accountIds) {
|
|
|
42
44
|
}
|
|
43
45
|
return seedParts.join(' ');
|
|
44
46
|
}
|
|
47
|
+
function normalizeTuiCustodyMode(value) {
|
|
48
|
+
return value === 'local' || value === 'claustrum' ? value : `mismatch: ${value}`;
|
|
49
|
+
}
|
|
50
|
+
export function normalizeAccountDialogPayload(value) {
|
|
51
|
+
const payload = value && typeof value === 'object' ? value : {};
|
|
52
|
+
const rawAccounts = Array.isArray(payload.accounts) ? payload.accounts : [];
|
|
53
|
+
const accounts = rawAccounts.flatMap(value => {
|
|
54
|
+
if (!value || typeof value !== 'object') return [];
|
|
55
|
+
const account = value;
|
|
56
|
+
const quotaPercent = account.quotaPercent;
|
|
57
|
+
if (typeof account.id !== 'string' || typeof account.label !== 'string' || account.role !== 'main' && account.role !== 'fallback' || typeof account.enabled !== 'boolean' || quotaPercent !== null && (typeof quotaPercent !== 'number' || !Number.isFinite(quotaPercent)) || account.claustrumGate !== 'on' && account.claustrumGate !== 'off' && account.claustrumGate !== 'na' || typeof account.vaultServed !== 'boolean') {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const normalized = {
|
|
61
|
+
id: account.id,
|
|
62
|
+
label: account.label,
|
|
63
|
+
role: account.role,
|
|
64
|
+
enabled: account.enabled,
|
|
65
|
+
quotaPercent,
|
|
66
|
+
...(typeof account.tierLabel === 'string' && {
|
|
67
|
+
tierLabel: account.tierLabel
|
|
68
|
+
}),
|
|
69
|
+
claustrumGate: account.claustrumGate,
|
|
70
|
+
vaultServed: account.vaultServed
|
|
71
|
+
};
|
|
72
|
+
const custodyState = account.custodyState;
|
|
73
|
+
if ((custodyState === 'na' || custodyState === 'off' || custodyState === 'on-vault-served' || custodyState === 'on-vault-reauth' || custodyState === 'on-cold') && typeof account.vaultReauth === 'boolean') {
|
|
74
|
+
return [{
|
|
75
|
+
...normalized,
|
|
76
|
+
custodyState,
|
|
77
|
+
vaultReauth: account.vaultReauth
|
|
78
|
+
}];
|
|
79
|
+
}
|
|
80
|
+
return [normalized];
|
|
81
|
+
});
|
|
82
|
+
const custodyMode = payload.custodyModeKnown === true && typeof payload.custodyMode === 'string' ? normalizeTuiCustodyMode(payload.custodyMode) : undefined;
|
|
83
|
+
return {
|
|
84
|
+
accounts,
|
|
85
|
+
claustrumDetection: typeof payload.claustrumDetection === 'string' ? payload.claustrumDetection : 'unknown',
|
|
86
|
+
...(custodyMode && {
|
|
87
|
+
custodyMode
|
|
88
|
+
}),
|
|
89
|
+
...(typeof payload.enrollmentStatus === 'string' && payload.enrollmentStatus.length <= 2_000 && {
|
|
90
|
+
enrollmentStatus: payload.enrollmentStatus
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
}
|
|
45
94
|
export function buildAccountDialogOption(account) {
|
|
46
95
|
const pct = account.quotaPercent != null ? ` ${Math.round(account.quotaPercent)}%` : ' \u2013%';
|
|
47
96
|
const status = !account.enabled ? ' (disabled)' : '';
|
|
48
|
-
const
|
|
49
|
-
const vault = account.role === 'main' ? ' · vault n/a' : ` · vault ${account.vaultServed ? 'served' : 'cold'}`;
|
|
97
|
+
const custody = account.custodyState ? account.custodyState === 'na' ? undefined : custodyStatusLabel(account.custodyState).replace(' (OpenCode managed)', '') : undefined;
|
|
50
98
|
return {
|
|
51
|
-
title: `${account.label} [${account.role}]${status}${pct}${
|
|
99
|
+
title: `${account.label} [${account.role}]${status}${pct}${custody ? ` · custody ${custody}` : ''}`,
|
|
52
100
|
value: account.id,
|
|
53
101
|
...(account.tierLabel && {
|
|
54
102
|
description: account.tierLabel
|
|
55
103
|
})
|
|
56
104
|
};
|
|
57
105
|
}
|
|
106
|
+
export function buildManageAccountOptions(account) {
|
|
107
|
+
const options = [];
|
|
108
|
+
const toggleLabel = account.enabled ? 'Disable' : 'Enable';
|
|
109
|
+
options.push({
|
|
110
|
+
title: toggleLabel,
|
|
111
|
+
value: account.enabled ? 'disable' : 'enable',
|
|
112
|
+
description: account.enabled ? 'Stop using this fallback account' : 'Allow this fallback account to be used'
|
|
113
|
+
});
|
|
114
|
+
options.push({
|
|
115
|
+
title: 'Move up',
|
|
116
|
+
value: 'move-up',
|
|
117
|
+
description: 'Higher priority in fallback order'
|
|
118
|
+
});
|
|
119
|
+
options.push({
|
|
120
|
+
title: 'Move down',
|
|
121
|
+
value: 'move-down',
|
|
122
|
+
description: 'Lower priority in fallback order'
|
|
123
|
+
});
|
|
124
|
+
options.push({
|
|
125
|
+
title: 'Remove\u2026',
|
|
126
|
+
value: 'remove',
|
|
127
|
+
description: 'Delete this account permanently'
|
|
128
|
+
});
|
|
129
|
+
options.push({
|
|
130
|
+
title: 'Back',
|
|
131
|
+
value: 'back'
|
|
132
|
+
});
|
|
133
|
+
return options;
|
|
134
|
+
}
|
|
135
|
+
export function buildAccountDialogL1(value) {
|
|
136
|
+
const payload = normalizeAccountDialogPayload(value);
|
|
137
|
+
const modeAction = payload.custodyMode === 'local' || payload.custodyMode === 'claustrum' ? {
|
|
138
|
+
command: 'claude-account',
|
|
139
|
+
arguments: payload.custodyMode === 'local' ? 'claustrum' : 'local'
|
|
140
|
+
} : undefined;
|
|
141
|
+
return {
|
|
142
|
+
header: payload.custodyMode ? `Custody mode: ${payload.custodyMode}` : 'Custody mode: unavailable from older server',
|
|
143
|
+
options: [...(modeAction ? [{
|
|
144
|
+
title: payload.custodyMode === 'local' ? 'Use Claustrum custody' : 'Use local custody',
|
|
145
|
+
value: '__custody-mode__'
|
|
146
|
+
}] : []), {
|
|
147
|
+
title: 'Add account…',
|
|
148
|
+
value: '__add__',
|
|
149
|
+
description: 'Add an API key or OAuth fallback account'
|
|
150
|
+
}, ...payload.accounts.map(buildAccountDialogOption)],
|
|
151
|
+
...(payload.enrollmentStatus && {
|
|
152
|
+
enrollmentStatus: payload.enrollmentStatus
|
|
153
|
+
}),
|
|
154
|
+
...(modeAction && {
|
|
155
|
+
modeAction
|
|
156
|
+
})
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export function retainAccountDialogProjection(current, incoming) {
|
|
160
|
+
return Array.isArray(incoming.accounts) ? incoming : current;
|
|
161
|
+
}
|
|
58
162
|
function showText(api, text) {
|
|
59
163
|
api.ui.dialog.setSize('xlarge');
|
|
60
164
|
api.ui.dialog.replace(() => (() => {
|
|
@@ -88,6 +192,8 @@ export function buildPrimeStatusRows(accounts) {
|
|
|
88
192
|
const time = formatPrimeTime(account.lastPrimedAt);
|
|
89
193
|
if (account.lastResult === 'error') {
|
|
90
194
|
rows.push(`${account.label} \u00b7 primed ${time} err`);
|
|
195
|
+
} else if (account.lastResult === 'skipped') {
|
|
196
|
+
rows.push(`${account.label} \u00b7 primed ${time} skipped`);
|
|
91
197
|
} else {
|
|
92
198
|
rows.push(`${account.label} \u00b7 primed ${time} \u2713`);
|
|
93
199
|
}
|
|
@@ -354,42 +460,99 @@ export function openCommandDialog(api, payload, apply) {
|
|
|
354
460
|
return;
|
|
355
461
|
}
|
|
356
462
|
if (payload.command === 'claude-account') {
|
|
357
|
-
|
|
358
|
-
const
|
|
463
|
+
let accountKnobs = payload.knobs;
|
|
464
|
+
const accounts = normalizeAccountDialogPayload(accountKnobs).accounts;
|
|
465
|
+
let statusMessage;
|
|
359
466
|
const updateAccounts = r => {
|
|
360
|
-
|
|
361
|
-
|
|
467
|
+
accountKnobs = retainAccountDialogProjection(accountKnobs, r.knobs);
|
|
468
|
+
const updated = normalizeAccountDialogPayload(accountKnobs).accounts;
|
|
469
|
+
if (updated.length > 0) {
|
|
362
470
|
accounts.length = 0;
|
|
363
471
|
accounts.push(...updated);
|
|
364
472
|
}
|
|
365
473
|
};
|
|
366
474
|
const buildL1 = () => {
|
|
367
475
|
const DialogSelect = api.ui.DialogSelect;
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}, ...accounts.map(buildAccountDialogOption)];
|
|
476
|
+
const l1 = buildAccountDialogL1({
|
|
477
|
+
...accountKnobs,
|
|
478
|
+
accounts
|
|
479
|
+
});
|
|
373
480
|
api.ui.dialog.setSize('xlarge');
|
|
374
481
|
api.ui.dialog.replace(() => (() => {
|
|
375
482
|
var _el$8 = _$createElement("box"),
|
|
376
483
|
_el$9 = _$createElement("text"),
|
|
377
|
-
_el$0 = _$createElement("
|
|
484
|
+
_el$0 = _$createElement("text"),
|
|
485
|
+
_el$1 = _$createElement("box");
|
|
378
486
|
_$insertNode(_el$8, _el$9);
|
|
379
487
|
_$insertNode(_el$8, _el$0);
|
|
488
|
+
_$insertNode(_el$8, _el$1);
|
|
380
489
|
_$setProp(_el$8, "flexDirection", 'column');
|
|
381
490
|
_$setProp(_el$8, "padding", 1);
|
|
382
491
|
_$setProp(_el$8, "width", '100%');
|
|
383
|
-
_$insert(_el$9, `Claustrum: ${claustrumDetection}`);
|
|
384
|
-
_$
|
|
385
|
-
_$insert(_el$
|
|
492
|
+
_$insert(_el$9, () => `Claustrum: ${normalizeAccountDialogPayload(accountKnobs).claustrumDetection}`);
|
|
493
|
+
_$insert(_el$0, () => l1.header);
|
|
494
|
+
_$insert(_el$8, (() => {
|
|
495
|
+
var _c$ = _$memo(() => !!l1.enrollmentStatus);
|
|
496
|
+
return () => _c$() && (() => {
|
|
497
|
+
var _el$10 = _$createElement("box"),
|
|
498
|
+
_el$11 = _$createElement("text");
|
|
499
|
+
_$insertNode(_el$10, _el$11);
|
|
500
|
+
_$setProp(_el$10, "marginTop", 1);
|
|
501
|
+
_$insert(_el$11, () => l1.enrollmentStatus);
|
|
502
|
+
return _el$10;
|
|
503
|
+
})();
|
|
504
|
+
})(), _el$1);
|
|
505
|
+
_$insert(_el$8, statusMessage && (() => {
|
|
506
|
+
var _el$12 = _$createElement("box"),
|
|
507
|
+
_el$13 = _$createElement("text");
|
|
508
|
+
_$insertNode(_el$12, _el$13);
|
|
509
|
+
_$setProp(_el$12, "marginTop", 1);
|
|
510
|
+
_$insert(_el$13, () => statusMessage.text);
|
|
511
|
+
_$effect(_$p => _$setProp(_el$13, "fg", statusMessage.error ? '#ef4444' : '#22c55e', _$p));
|
|
512
|
+
return _el$12;
|
|
513
|
+
})(), _el$1);
|
|
514
|
+
_$setProp(_el$1, "marginTop", 1);
|
|
515
|
+
_$insert(_el$1, _$createComponent(DialogSelect, {
|
|
386
516
|
title: "Claude accounts",
|
|
387
|
-
options
|
|
517
|
+
get options() {
|
|
518
|
+
return l1.options;
|
|
519
|
+
},
|
|
388
520
|
onSelect: option => {
|
|
389
521
|
if (option.value === '__add__') {
|
|
522
|
+
statusMessage = undefined;
|
|
390
523
|
openAddType();
|
|
391
524
|
return;
|
|
392
525
|
}
|
|
526
|
+
if (option.value === '__custody-mode__' && l1.modeAction) {
|
|
527
|
+
void apply(l1.modeAction.command, l1.modeAction.arguments).then(r => {
|
|
528
|
+
const isRefusalOrError = r.text.includes('refused') || r.text.includes('unavailable') || r.text.includes('failed') || r.text.includes('Error') || r.text.includes('error');
|
|
529
|
+
if (isRefusalOrError) {
|
|
530
|
+
statusMessage = {
|
|
531
|
+
text: r.text,
|
|
532
|
+
error: true
|
|
533
|
+
};
|
|
534
|
+
} else {
|
|
535
|
+
statusMessage = {
|
|
536
|
+
text: r.text,
|
|
537
|
+
error: false
|
|
538
|
+
};
|
|
539
|
+
api.ui.toast({
|
|
540
|
+
message: r.text
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
updateAccounts(r);
|
|
544
|
+
buildL1();
|
|
545
|
+
}).catch(err => {
|
|
546
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
547
|
+
statusMessage = {
|
|
548
|
+
text: `Error: ${msg}`,
|
|
549
|
+
error: true
|
|
550
|
+
};
|
|
551
|
+
buildL1();
|
|
552
|
+
});
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
statusMessage = undefined;
|
|
393
556
|
const account = accounts.find(a => a.id === option.value);
|
|
394
557
|
if (!account) return;
|
|
395
558
|
if (account.role === 'main') {
|
|
@@ -445,9 +608,9 @@ export function openCommandDialog(api, payload, apply) {
|
|
|
445
608
|
api.ui.dialog.replace(() => _$createComponent(DialogPrompt, {
|
|
446
609
|
title: "Add API key account \\u2014 API key",
|
|
447
610
|
description: () => (() => {
|
|
448
|
-
var _el$
|
|
449
|
-
_$insertNode(_el$
|
|
450
|
-
return _el$
|
|
611
|
+
var _el$14 = _$createElement("text");
|
|
612
|
+
_$insertNode(_el$14, _$createTextNode(`Paste your API key (required).`));
|
|
613
|
+
return _el$14;
|
|
451
614
|
})(),
|
|
452
615
|
placeholder: "sk-ant-...",
|
|
453
616
|
value: "",
|
|
@@ -469,9 +632,9 @@ export function openCommandDialog(api, payload, apply) {
|
|
|
469
632
|
api.ui.dialog.replace(() => _$createComponent(DialogPrompt, {
|
|
470
633
|
title: "Add API key account \\u2014 base URL",
|
|
471
634
|
description: () => (() => {
|
|
472
|
-
var _el$
|
|
473
|
-
_$insertNode(_el$
|
|
474
|
-
return _el$
|
|
635
|
+
var _el$16 = _$createElement("text");
|
|
636
|
+
_$insertNode(_el$16, _$createTextNode(`Anthropic-compatible API base URL. Default: https://api.kie.ai/claude`));
|
|
637
|
+
return _el$16;
|
|
475
638
|
})(),
|
|
476
639
|
placeholder: "https://api.kie.ai/claude",
|
|
477
640
|
value: "",
|
|
@@ -509,9 +672,9 @@ export function openCommandDialog(api, payload, apply) {
|
|
|
509
672
|
api.ui.dialog.replace(() => _$createComponent(DialogPrompt, {
|
|
510
673
|
title: "Add API key account \\u2014 label",
|
|
511
674
|
description: () => (() => {
|
|
512
|
-
var _el$
|
|
513
|
-
_$insertNode(_el$
|
|
514
|
-
return _el$
|
|
675
|
+
var _el$18 = _$createElement("text");
|
|
676
|
+
_$insertNode(_el$18, _$createTextNode(`A short name for this account (optional).`));
|
|
677
|
+
return _el$18;
|
|
515
678
|
})(),
|
|
516
679
|
placeholder: "e.g. Work API",
|
|
517
680
|
value: "",
|
|
@@ -605,9 +768,9 @@ export function openCommandDialog(api, payload, apply) {
|
|
|
605
768
|
api.ui.dialog.replace(() => _$createComponent(DialogPrompt, {
|
|
606
769
|
title: "OAuth sign-in \\u2014 enter code",
|
|
607
770
|
description: () => (() => {
|
|
608
|
-
var _el$
|
|
609
|
-
_$insertNode(_el$
|
|
610
|
-
return _el$
|
|
771
|
+
var _el$20 = _$createElement("text");
|
|
772
|
+
_$insertNode(_el$20, _$createTextNode(`After signing in you will be redirected. Paste the full callback URL or authorization code below.`));
|
|
773
|
+
return _el$20;
|
|
611
774
|
})(),
|
|
612
775
|
placeholder: "Paste callback URL or code here",
|
|
613
776
|
value: "",
|
|
@@ -628,9 +791,9 @@ export function openCommandDialog(api, payload, apply) {
|
|
|
628
791
|
api.ui.dialog.replace(() => _$createComponent(DialogPrompt, {
|
|
629
792
|
title: "OAuth sign-in \\u2014 label",
|
|
630
793
|
description: () => (() => {
|
|
631
|
-
var _el$
|
|
632
|
-
_$insertNode(_el$
|
|
633
|
-
return _el$
|
|
794
|
+
var _el$22 = _$createElement("text");
|
|
795
|
+
_$insertNode(_el$22, _$createTextNode(`A short name for this account (optional).`));
|
|
796
|
+
return _el$22;
|
|
634
797
|
})(),
|
|
635
798
|
placeholder: "e.g. work",
|
|
636
799
|
value: "",
|
|
@@ -654,34 +817,10 @@ export function openCommandDialog(api, payload, apply) {
|
|
|
654
817
|
const DialogSelect = api.ui.DialogSelect;
|
|
655
818
|
const DialogConfirm = api.ui.DialogConfirm;
|
|
656
819
|
api.ui.dialog.setSize('xlarge');
|
|
657
|
-
const options = [
|
|
658
|
-
if (!isMain) {
|
|
659
|
-
const toggleLabel = account.enabled ? 'Disable' : 'Enable';
|
|
660
|
-
options.push({
|
|
661
|
-
title: toggleLabel,
|
|
662
|
-
value: account.enabled ? 'disable' : 'enable',
|
|
663
|
-
description: account.enabled ? 'Stop using this fallback account' : 'Allow this fallback account to be used'
|
|
664
|
-
});
|
|
665
|
-
options.push({
|
|
666
|
-
title: 'Move up',
|
|
667
|
-
value: 'move-up',
|
|
668
|
-
description: 'Higher priority in fallback order'
|
|
669
|
-
});
|
|
670
|
-
options.push({
|
|
671
|
-
title: 'Move down',
|
|
672
|
-
value: 'move-down',
|
|
673
|
-
description: 'Lower priority in fallback order'
|
|
674
|
-
});
|
|
675
|
-
options.push({
|
|
676
|
-
title: 'Remove\u2026',
|
|
677
|
-
value: 'remove',
|
|
678
|
-
description: 'Delete this account permanently'
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
options.push({
|
|
820
|
+
const options = isMain ? [{
|
|
682
821
|
title: 'Back',
|
|
683
822
|
value: 'back'
|
|
684
|
-
});
|
|
823
|
+
}] : buildManageAccountOptions(account);
|
|
685
824
|
api.ui.dialog.replace(() => _$createComponent(DialogSelect, {
|
|
686
825
|
get title() {
|
|
687
826
|
return `Manage ${account.label}`;
|
|
@@ -707,20 +846,35 @@ export function openCommandDialog(api, payload, apply) {
|
|
|
707
846
|
});
|
|
708
847
|
updateAccounts(r);
|
|
709
848
|
buildL1();
|
|
849
|
+
}).catch(err => {
|
|
850
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
851
|
+
statusMessage = {
|
|
852
|
+
text: `Error: ${msg}`,
|
|
853
|
+
error: true
|
|
854
|
+
};
|
|
855
|
+
buildL1();
|
|
710
856
|
});
|
|
711
857
|
},
|
|
712
858
|
onCancel: () => openManage(account, isMain)
|
|
713
859
|
}));
|
|
714
860
|
return;
|
|
715
861
|
}
|
|
716
|
-
|
|
862
|
+
const args = `${option.value} ${account.id}`;
|
|
863
|
+
void apply('claude-account', args).then(r => {
|
|
717
864
|
api.ui.toast({
|
|
718
865
|
message: r.text
|
|
719
866
|
});
|
|
720
867
|
updateAccounts(r);
|
|
721
|
-
const updatedList = r.knobs.accounts;
|
|
868
|
+
const updatedList = normalizeAccountDialogPayload(r.knobs).accounts;
|
|
722
869
|
const refreshed = (updatedList && updatedList.length > 0 ? updatedList.find(a => a.id === account.id) : undefined) ?? account;
|
|
723
870
|
openManage(refreshed, isMain);
|
|
871
|
+
}).catch(err => {
|
|
872
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
873
|
+
statusMessage = {
|
|
874
|
+
text: `Error: ${msg}`,
|
|
875
|
+
error: true
|
|
876
|
+
};
|
|
877
|
+
buildL1();
|
|
724
878
|
});
|
|
725
879
|
}
|
|
726
880
|
}));
|
package/src/tui-compiled/tui.tsx
CHANGED
|
@@ -1160,6 +1160,7 @@ const tui = async api => {
|
|
|
1160
1160
|
const current = api.route.current;
|
|
1161
1161
|
const resolved = typeof current === 'function' ? current() : current;
|
|
1162
1162
|
const sessionId = resolved?.params?.sessionID;
|
|
1163
|
+
if (!sessionId) return;
|
|
1163
1164
|
rpcInFlight = true;
|
|
1164
1165
|
void rpcClient.pending(lastNotificationId, sessionId).then(messages => {
|
|
1165
1166
|
for (const message of [...messages].sort((a, b) => a.id - b.id)) {
|
package/src/tui.tsx
CHANGED
|
@@ -930,6 +930,7 @@ const tui: TuiPlugin = async (api) => {
|
|
|
930
930
|
const sessionId = (
|
|
931
931
|
resolved as { params?: { sessionID?: string } } | undefined
|
|
932
932
|
)?.params?.sessionID
|
|
933
|
+
if (!sessionId) return
|
|
933
934
|
rpcInFlight = true
|
|
934
935
|
void rpcClient
|
|
935
936
|
.pending(lastNotificationId, sessionId)
|
package/dist/index-8aga2zwv.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import*as j from"node:fs";import*as P from"node:os";import*as V from"node:path";var U={error:0,warn:1,info:2,debug:3,trace:4},O=new Set(Object.keys(U));function F(q){if(!q)return null;let Q=q.trim().toLowerCase();return O.has(Q)?Q:null}var S=F(process.env.OPENCODE_ANTHROPIC_AUTH_LOG_LEVEL),M=S??"info";function L(q){M=q}function i(){return M}function X(q){return U[q]<=U[M]}var J=process.env.OPENCODE_ANTHROPIC_AUTH_LOG_FILE??V.join(P.tmpdir(),"opencode-anthropic-auth.log");function h(){return J}var R=5242880,N=3;function I(){try{if(!j.existsSync(J))return;if(j.statSync(J).size<R)return}catch{return}try{for(let q=N;q>=1;q--){let Q=q===1?J:`${J}.${q-1}`,W=`${J}.${q}`;try{if(q===N)try{j.unlinkSync(W)}catch{}if(j.existsSync(Q))j.renameSync(Q,W)}catch{}}}catch{}}var T=/^(authorization|x-api-key|cookie|set-cookie|refresh|access|token)$/i;function k(q){if(T.test(q))return!0;let Q=q.toLowerCase().replace(/[-_]/g,"");if(Q.includes("apikey"))return!0;if(Q.endsWith("secret")||Q.endsWith("password"))return!0;if(Q.endsWith("token")&&!Q.endsWith("tokens"))return!0;return!1}var f=[/Bearer\s+\S+/,/sk-[A-Za-z0-9-]+/,/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/];function _(q){if(typeof q!=="string")return!1;return f.some((Q)=>Q.test(q))}function G(q){if(q==null||Object.keys(q).length===0)return;let Q=new WeakSet;function W($){if($==null||typeof $!=="object"){if(_($))return"***REDACTED***";return $}if(Q.has($))return"[Circular]";Q.add($);try{if(Array.isArray($))return $.map(W);let x=$,B={};for(let[H,C]of Object.entries(x)){if(k(H)){B[H]="***REDACTED***";continue}B[H]=W(C)}return B}finally{Q.delete($)}}return W(q)}function g(q,Q,W,$){let x=new Date().toISOString(),B=q.toUpperCase().padEnd(5),H=Q?` [${Q}]`:"",C=(()=>{try{let w=G($),A=w?{...w,pid:process.pid}:{pid:process.pid};return` ${JSON.stringify(A)}`}catch{return` {"pid":${process.pid},"payload":"[unserializable]"}`}})();return`[${x}] ${B}${H} ${W}${C}`}var D=null;function E(q){D=q}function Y(q,Q,W,$){if(!X(q))return;if(D)try{D({level:q,channel:Q,message:W,payload:G($)})}catch{}if(Z)return;try{let x=`${g(q,Q,W,$)}
|
|
2
|
-
`;if(K.push(x),K.length>=p)b();else r()}catch{}}var m={error(q,Q,W){Y("error",q,Q,W)},warn(q,Q,W){Y("warn",q,Q,W)},info(q,Q,W){Y("info",q,Q,W)},debug(q,Q,W){Y("debug",q,Q,W)},trace(q,Q,W){Y("trace",q,Q,W)}},Z=!1,c=500,p=50,K=[],z=null;function b(){if(z)clearTimeout(z),z=null;if(K.length===0)return;let q=K.join("");K=[];try{I(),j.appendFileSync(J,q)}catch{}}function r(){if(z)return;z=setTimeout(()=>{z=null,b()},c)}var y=/^\[([\w-]+)\]\s*/;function o(q,Q){if(!X("debug"))return;if(Z)return;try{let W="",$=q,x=q.match(y);if(x)W=x[1]??"",$=q.slice(x[0].length);let B;if(Q!=null){if(Q instanceof Error)B={error:`${Q.message}${Q.stack?`
|
|
3
|
-
${Q.stack}`:""}`};else if(typeof Q==="object")B=Q}Y("debug",W,$,B)}catch{}}function v(q,Q){if(!X("debug"))return;if(Z)return;try{let W;if(Q!=null){if(typeof Q==="object"&&!(Q instanceof Error))W=Q}Y("debug","relay",q,W)}catch{}}if(!Z)process.on("exit",b);
|
|
4
|
-
export{F as ad,L as bd,i as cd,X as dd,h as ed,T as fd,k as gd,G as hd,g as id,E as jd,m as kd,o as ld,v as md};
|
package/dist/index-cgez4m0h.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as q}from"node:module";var j=Object.create;var{getPrototypeOf:k,defineProperty:i,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,r=(a,b,d)=>{var f=a!=null&&typeof a==="object";if(f){var g=b?o??=new WeakMap:p??=new WeakMap,h=g.get(a);if(h)return h}d=a!=null?j(k(a)):{};let c=b||!a||!a.__esModule?i(d,"default",{value:a,enumerable:!0}):d;for(let e of l(a))if(!m.call(c,e))i(c,e,{get:n.bind(a,e),enumerable:!0});if(f)g.set(a,c);return c};var s=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var u=q(import.meta.url);
|
|
2
|
-
export{r as sd,s as td,u as ud};
|