@cortexkit/opencode-anthropic-auth 1.22.0 → 2.0.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 +259 -198
- package/dist/billing-lineage.d.ts +51 -0
- package/dist/cli-failure.d.ts +69 -0
- package/dist/cli.d.ts +16 -10
- package/dist/cli.js +111 -6
- package/dist/custody-dimensions.d.ts +19 -0
- package/dist/custody-mode.d.ts +46 -0
- package/dist/effort-history.d.ts +11 -2
- package/dist/fable-fallback.d.ts +1 -1
- package/dist/index-1jkyhgyr.js +2 -0
- package/dist/{index-bx5hsgf8.js → index-2arfb1y3.js} +2 -2
- package/dist/{index-926t2bzc.js → index-4ya27n12.js} +1 -1
- package/dist/{index-cgez4m0h.js → index-aaajxwzd.js} +1 -1
- package/dist/index-ae3fq4n6.js +42 -0
- package/dist/index-fds0s2j4.js +2 -0
- package/dist/index-nngmvczq.js +450 -0
- package/dist/index-pn597b6f.js +2 -0
- package/dist/{index-7f57ewkp.js → index-rqync0pc.js} +1 -1
- package/dist/index.js +1 -33
- package/dist/native-command.d.ts +19 -0
- package/dist/prime-manager-registry.d.ts +5 -1
- package/dist/rpc/notifications.d.ts +4 -3
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +15 -4
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.d.ts +3 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/rpc/rpc-server.d.ts +5 -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 +20 -0
- package/dist/setup/command.test.d.ts +1 -0
- package/dist/setup/detect.d.ts +5 -0
- package/dist/setup/jsonc.d.ts +9 -0
- package/dist/setup/native-activation.d.ts +29 -0
- package/dist/setup/native-enrollment.d.ts +26 -0
- package/dist/setup/native-enrollment.test.d.ts +1 -0
- package/dist/setup/native-local.d.ts +20 -0
- package/dist/setup/native-login.d.ts +3 -0
- package/dist/setup/native-paths.d.ts +15 -0
- package/dist/setup/native-paths.test.d.ts +1 -0
- package/dist/setup/opencode-config.d.ts +18 -0
- package/dist/setup/paths.d.ts +15 -0
- package/dist/setup/pi.d.ts +18 -0
- package/dist/setup/process-fence.d.ts +20 -0
- package/dist/setup/process-fence.test.d.ts +1 -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 +32 -2
- package/dist/tui-preferences.js +2 -2
- package/dist/v2/activation.d.ts +7 -0
- package/dist/v2/adapter.d.ts +276 -0
- package/dist/v2/install.d.ts +13 -0
- package/dist/v2/lifecycle.d.ts +8 -0
- package/dist/v2/menu-contract.d.ts +8 -0
- package/dist/v2/menu.d.ts +10 -0
- package/dist/v2/models.d.ts +6 -0
- package/dist/v2/ownership.d.ts +11 -0
- package/dist/v2/prime.d.ts +12 -0
- package/dist/v2/rpc.d.ts +50 -0
- package/dist/v2/server.d.ts +8 -0
- package/dist/v2/server.js +4 -0
- package/dist/v2/setup.d.ts +58 -0
- package/dist/v2/source.d.ts +41 -0
- package/dist/v2/tui.d.ts +13 -0
- package/dist/v2/tui.js +2 -0
- package/dist/v2/wire.d.ts +36 -0
- package/package.json +26 -6
- package/src/rpc/notifications.ts +37 -26
- package/src/rpc/protocol.ts +24 -7
- package/src/rpc/rpc-client.ts +18 -1
- package/src/rpc/rpc-server.ts +38 -8
- package/src/rpc/server-registry.ts +61 -0
- package/src/sidebar-state.ts +26 -2
- package/src/tui/command-dialogs.tsx +537 -68
- package/src/tui/entry.mjs +44 -18
- package/src/tui-compiled/rpc/protocol.ts +24 -7
- package/src/tui-compiled/rpc/rpc-client.ts +18 -1
- package/src/tui-compiled/sidebar-state.ts +26 -2
- package/src/tui-compiled/tui/command-dialogs.tsx +488 -95
- package/src/tui-compiled/tui.tsx +25 -7
- package/src/tui.tsx +38 -9
- package/dist/index-8aga2zwv.js +0 -4
- package/dist/index-d3f8g6ve.js +0 -428
- package/dist/index-sh51yqxs.js +0 -2
- package/dist/logger-jrkranbz.js +0 -1
package/src/tui/entry.mjs
CHANGED
|
@@ -12,26 +12,52 @@ function isMissingRuntimeRegistry(error) {
|
|
|
12
12
|
)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
await import(runtimeProbe)
|
|
18
|
-
} catch (error) {
|
|
19
|
-
if (!isMissingRuntimeRegistry(error)) {
|
|
20
|
-
console.error('Anthropic Auth TUI runtime registry probe failed', error)
|
|
21
|
-
throw error
|
|
22
|
-
}
|
|
23
|
-
// Older hosts and bare Bun do not provide the virtual registry. Their source
|
|
24
|
-
// loader still applies the Solid transform, so retain the raw TSX fallback.
|
|
25
|
-
mod = await import('../tui.tsx')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!mod) {
|
|
15
|
+
async function loadLegacyTui() {
|
|
16
|
+
let mod
|
|
29
17
|
try {
|
|
30
|
-
|
|
18
|
+
await import(runtimeProbe)
|
|
31
19
|
} catch (error) {
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
if (!isMissingRuntimeRegistry(error)) {
|
|
21
|
+
console.error('Anthropic Auth TUI runtime registry probe failed', error)
|
|
22
|
+
throw error
|
|
23
|
+
}
|
|
24
|
+
// Older hosts and bare Bun do not provide the virtual registry. Their source
|
|
25
|
+
// loader still applies the Solid transform, so retain the raw TSX fallback.
|
|
26
|
+
mod = await import('../tui.tsx')
|
|
34
27
|
}
|
|
28
|
+
|
|
29
|
+
if (!mod) {
|
|
30
|
+
try {
|
|
31
|
+
mod = await import('../tui-compiled/tui.tsx')
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Anthropic Auth compiled TUI failed to load', error)
|
|
34
|
+
throw error
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return mod.default
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let legacyModule
|
|
41
|
+
|
|
42
|
+
// OpenCode 1 reads id and tui from the default definition; OpenCode 2 reads
|
|
43
|
+
// its setup method. Both use this package subpath, so these methods must be
|
|
44
|
+
// on the default export, not only exported as separate named bindings.
|
|
45
|
+
export const id = 'cortexkit.anthropic-auth'
|
|
46
|
+
|
|
47
|
+
/** @type {import('@opencode-ai/plugin/tui').TuiPlugin} */
|
|
48
|
+
export const tui = async (...args) => {
|
|
49
|
+
legacyModule ??= loadLegacyTui()
|
|
50
|
+
const plugin = await legacyModule
|
|
51
|
+
return plugin.tui(...args)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @type {import('@opencode/plugin/tui').Plugin.Definition['setup']} */
|
|
55
|
+
export const setup = async (context) => {
|
|
56
|
+
// OpenCode 2 already routes RPC through the active project. Importing its
|
|
57
|
+
// TUI must not load the OpenCode 1 renderer or start that renderer's separate
|
|
58
|
+
// loopback notification poller.
|
|
59
|
+
const { setupAnthropicTui } = await import('../../dist/v2/tui.js')
|
|
60
|
+
return setupAnthropicTui(context)
|
|
35
61
|
}
|
|
36
62
|
|
|
37
|
-
export default
|
|
63
|
+
export default { id, tui, setup }
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ClaustrumEnrollmentStatus,
|
|
3
|
+
CommandDialogPayload,
|
|
4
|
+
} from '@cortexkit/anthropic-auth-core'
|
|
5
|
+
|
|
1
6
|
export const COMMAND_MODAL_NAMES = [
|
|
2
7
|
'claude-account',
|
|
3
8
|
'claude-cache',
|
|
@@ -17,17 +22,31 @@ export type CommandModalName = (typeof COMMAND_MODAL_NAMES)[number]
|
|
|
17
22
|
export interface AccountDialogAccount {
|
|
18
23
|
id: string
|
|
19
24
|
label: string
|
|
20
|
-
role:
|
|
25
|
+
role: 'main' | 'fallback'
|
|
21
26
|
enabled: boolean
|
|
22
27
|
quotaPercent: number | null
|
|
23
28
|
tierLabel?: string
|
|
24
29
|
claustrumGate: 'on' | 'off' | 'na'
|
|
25
30
|
vaultServed: boolean
|
|
31
|
+
vaultReauth: boolean
|
|
32
|
+
custodyState:
|
|
33
|
+
| 'na'
|
|
34
|
+
| 'off'
|
|
35
|
+
| 'on-vault-served'
|
|
36
|
+
| 'on-vault-reauth'
|
|
37
|
+
| 'on-cold'
|
|
38
|
+
| 'unknown-identity'
|
|
39
|
+
| 'on-identity-mismatch'
|
|
40
|
+
| 'on-corrupt-binding'
|
|
26
41
|
}
|
|
27
42
|
|
|
28
43
|
export interface AccountDialogKnobs {
|
|
29
44
|
accounts: AccountDialogAccount[]
|
|
30
45
|
claustrumDetection: string
|
|
46
|
+
custodyMode?: 'local' | 'claustrum'
|
|
47
|
+
custodyModeKnown?: boolean
|
|
48
|
+
enrollmentStatus?: string
|
|
49
|
+
claustrumEnrollment?: ClaustrumEnrollmentStatus
|
|
31
50
|
[key: string]: unknown
|
|
32
51
|
}
|
|
33
52
|
|
|
@@ -37,12 +56,10 @@ export interface OpenDialogPayload {
|
|
|
37
56
|
knobs: Record<string, unknown>
|
|
38
57
|
}
|
|
39
58
|
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
type: 'open-
|
|
43
|
-
|
|
44
|
-
sessionId?: string
|
|
45
|
-
}
|
|
59
|
+
export type RpcNotification = { id: number; sessionId: string } & (
|
|
60
|
+
| { type: 'open-dialog'; payload: OpenDialogPayload }
|
|
61
|
+
| { type: 'open-menu'; payload: CommandDialogPayload }
|
|
62
|
+
)
|
|
46
63
|
|
|
47
64
|
export interface ApplyRequest {
|
|
48
65
|
command: CommandModalName
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CommandApplyRequest,
|
|
3
|
+
CommandApplyResult,
|
|
4
|
+
} from '@cortexkit/anthropic-auth-core'
|
|
1
5
|
import { discoverPortFile } from './port-file'
|
|
2
6
|
import type { ApplyRequest, ApplyResult, RpcNotification } from './protocol'
|
|
3
7
|
|
|
4
8
|
export interface RpcClient {
|
|
5
9
|
pending: (
|
|
6
10
|
lastReceivedId: number,
|
|
7
|
-
sessionId
|
|
11
|
+
sessionId: string,
|
|
8
12
|
) => Promise<RpcNotification[]>
|
|
9
13
|
apply: (request: ApplyRequest) => Promise<ApplyResult>
|
|
14
|
+
applyMenu: (request: CommandApplyRequest) => Promise<CommandApplyResult>
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
async function call<T>(
|
|
@@ -58,5 +63,17 @@ export function createRpcClient(dir: string, expectedPid?: number): RpcClient {
|
|
|
58
63
|
)
|
|
59
64
|
return out ?? { text: 'apply failed', knobs: {} }
|
|
60
65
|
},
|
|
66
|
+
async applyMenu(request) {
|
|
67
|
+
if (request.command !== 'claude' || !request.sessionId?.trim())
|
|
68
|
+
throw new TypeError('A claude menu sessionId is required')
|
|
69
|
+
const out = await call<CommandApplyResult>(
|
|
70
|
+
dir,
|
|
71
|
+
'apply-menu',
|
|
72
|
+
{ ...request },
|
|
73
|
+
expectedPid,
|
|
74
|
+
)
|
|
75
|
+
if (!out) throw new Error('Menu apply unavailable; outcome unknown')
|
|
76
|
+
return out
|
|
77
|
+
},
|
|
61
78
|
}
|
|
62
79
|
}
|
|
@@ -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
|
}
|