@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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type CustodyHandleAccount, type CustodyHandleManifestRemovalResult } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
export type CompletedLocalLogin = {
|
|
3
|
+
accountId: string;
|
|
4
|
+
credentialId: string;
|
|
5
|
+
authFingerprint: string;
|
|
6
|
+
completedAt: number;
|
|
7
|
+
};
|
|
8
|
+
export type CustodyDivergence = {
|
|
9
|
+
minimumRecordVersion: number;
|
|
10
|
+
observedAt: number;
|
|
11
|
+
};
|
|
12
|
+
export type CustodyDivergenceState = {
|
|
13
|
+
claustrumDivergence?: Record<string, CustodyDivergence>;
|
|
14
|
+
};
|
|
15
|
+
export declare function lastVaultServedRecordVersion(input: {
|
|
16
|
+
accountId: string;
|
|
17
|
+
servedVersion?: number;
|
|
18
|
+
cacheVersion?: number;
|
|
19
|
+
warn?: (accountId: string) => void;
|
|
20
|
+
}): number;
|
|
21
|
+
export declare function custodyDivergenceMarker(lastVaultServedRecordVersion: number, observedAt: number): CustodyDivergence;
|
|
22
|
+
export declare function custodyPreflightDivergenceCheck(binding: {
|
|
23
|
+
credentialId: string;
|
|
24
|
+
recordVersion: number;
|
|
25
|
+
}, state: CustodyDivergenceState): {
|
|
26
|
+
ok: true;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
message: 'missing fresh vault import';
|
|
30
|
+
};
|
|
31
|
+
export declare class CustodyLoginObservationUnavailableError extends Error {
|
|
32
|
+
readonly code = "custody_login_observation_unavailable";
|
|
33
|
+
constructor();
|
|
34
|
+
}
|
|
35
|
+
export declare function assertLocalLoginObservationAvailable(env: Record<string, string | undefined>): void;
|
|
36
|
+
export type ObservedLocalAuth = {
|
|
37
|
+
type: string;
|
|
38
|
+
access?: string;
|
|
39
|
+
refresh?: string;
|
|
40
|
+
};
|
|
41
|
+
export declare function localAuthFingerprint(access: string, refresh: string): string;
|
|
42
|
+
export type AcknowledgeLocalOAuthLoginOptions = {
|
|
43
|
+
manifestPath: string;
|
|
44
|
+
entry: CustodyHandleAccount;
|
|
45
|
+
remove?: (input: {
|
|
46
|
+
path: string;
|
|
47
|
+
entry: CustodyHandleAccount;
|
|
48
|
+
}) => Promise<CustodyHandleManifestRemovalResult>;
|
|
49
|
+
beforeRemove?: () => Promise<void>;
|
|
50
|
+
divergence?: {
|
|
51
|
+
statePath: string;
|
|
52
|
+
lastVaultServedRecordVersion: number;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export type AcknowledgeLocalOAuthLoginFromStorageOptions = {
|
|
56
|
+
accountStoragePath: string;
|
|
57
|
+
manifestPath: string;
|
|
58
|
+
remove?: AcknowledgeLocalOAuthLoginOptions['remove'];
|
|
59
|
+
divergence?: AcknowledgeLocalOAuthLoginOptions['divergence'];
|
|
60
|
+
};
|
|
61
|
+
export type AcknowledgeLocalOAuthLoginResult = 'cleared' | 'not-cleared' | 'refused' | 'refused-transient';
|
|
62
|
+
export declare function acknowledgeLocalOAuthLogin(completion: CompletedLocalLogin | undefined, observedAuth: ObservedLocalAuth | undefined, options: AcknowledgeLocalOAuthLoginOptions): Promise<AcknowledgeLocalOAuthLoginResult>;
|
|
63
|
+
export declare function persistCustodyDivergenceState(statePath: string, credentialId: string, lastVaultServedRecordVersion: number, observedAt: number): Promise<void>;
|
|
64
|
+
export declare function acknowledgeLocalOAuthLoginFromStorage(completion: CompletedLocalLogin | undefined, options: AcknowledgeLocalOAuthLoginFromStorageOptions): Promise<AcknowledgeLocalOAuthLoginResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ah as a,bh as b,ch as c,dh as d,eh as e,fh as f,gh as g,hh as h,ih as i,jh as j,kh as k,lh as l,mh as m}from"./index-a5d6v3ba.js";import"./index-n96q8pks.js";export{d as shouldEmit,b as setLogLevel,m as relayLog,h as redactPayload,a as parseLogLevel,k as logger,l as log,g as isSecretKey,c as getLogLevel,e as getLogFilePath,i as formatLogLine,j as __setLogTestSink,f as SECRET_KEY_EXACT};
|
|
@@ -3,5 +3,9 @@ type PrimeManagerAdoption = {
|
|
|
3
3
|
slot: string;
|
|
4
4
|
rebind: (manager: PrimeManager) => void;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export interface AdoptedPrimeManager {
|
|
7
|
+
manager: PrimeManager;
|
|
8
|
+
release: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function adoptPrimeManager(storagePath: string, create: () => PrimeManager, adoption: PrimeManagerAdoption): AdoptedPrimeManager;
|
|
7
11
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OpenDialogPayload, RpcNotification } from './protocol';
|
|
2
|
-
export declare function pushNotification(payload: OpenDialogPayload, sessionId
|
|
3
|
-
export declare function drainNotifications(lastReceivedId
|
|
4
|
-
export declare function isTuiConnected(sessionId
|
|
2
|
+
export declare function pushNotification(payload: OpenDialogPayload, sessionId: string): void;
|
|
3
|
+
export declare function drainNotifications(lastReceivedId: number, sessionId: string): RpcNotification[];
|
|
4
|
+
export declare function isTuiConnected(sessionId: string): boolean;
|
|
5
5
|
export declare function resetNotificationsForTest(): void;
|
package/dist/rpc/port-file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{oh as a,ph as b}from"../index-0jfsxyn9.js";import"../index-n96q8pks.js";export{a as writePortFile,b as discoverPortFile};
|
package/dist/rpc/protocol.d.ts
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
+
import type { ClaustrumEnrollmentStatus } from '@cortexkit/anthropic-auth-core';
|
|
1
2
|
export declare const COMMAND_MODAL_NAMES: readonly ['claude-account', 'claude-cache', 'claude-cachekeep', 'claude-prime', 'claude-start', 'claude-quota', 'claude-dump', 'claude-fast', 'claude-routing', 'claude-killswitch', 'claude-logging'];
|
|
2
3
|
export type CommandModalName = (typeof COMMAND_MODAL_NAMES)[number];
|
|
3
4
|
export interface AccountDialogAccount {
|
|
4
5
|
id: string;
|
|
5
6
|
label: string;
|
|
6
|
-
role:
|
|
7
|
+
role: 'main' | 'fallback';
|
|
7
8
|
enabled: boolean;
|
|
8
9
|
quotaPercent: number | null;
|
|
9
10
|
tierLabel?: string;
|
|
10
11
|
claustrumGate: 'on' | 'off' | 'na';
|
|
11
12
|
vaultServed: boolean;
|
|
13
|
+
vaultReauth: boolean;
|
|
14
|
+
custodyState: 'na' | 'off' | 'on-vault-served' | 'on-vault-reauth' | 'on-cold' | 'unknown-identity' | 'on-identity-mismatch' | 'on-corrupt-binding';
|
|
12
15
|
}
|
|
13
16
|
export interface AccountDialogKnobs {
|
|
14
17
|
accounts: AccountDialogAccount[];
|
|
15
18
|
claustrumDetection: string;
|
|
19
|
+
custodyMode?: 'local' | 'claustrum';
|
|
20
|
+
custodyModeKnown?: boolean;
|
|
21
|
+
enrollmentStatus?: string;
|
|
22
|
+
claustrumEnrollment?: ClaustrumEnrollmentStatus;
|
|
16
23
|
[key: string]: unknown;
|
|
17
24
|
}
|
|
18
25
|
export interface OpenDialogPayload {
|
|
@@ -24,7 +31,7 @@ export interface RpcNotification {
|
|
|
24
31
|
id: number;
|
|
25
32
|
type: 'open-dialog';
|
|
26
33
|
payload: OpenDialogPayload;
|
|
27
|
-
sessionId
|
|
34
|
+
sessionId: string;
|
|
28
35
|
}
|
|
29
36
|
export interface ApplyRequest {
|
|
30
37
|
command: CommandModalName;
|
package/dist/rpc/protocol.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{qh as a}from"../index-8y2t4mwz.js";import"../index-n96q8pks.js";export{a as COMMAND_MODAL_NAMES};
|
package/dist/rpc/rpc-client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ApplyRequest, ApplyResult, RpcNotification } from './protocol';
|
|
2
2
|
export interface RpcClient {
|
|
3
|
-
pending: (lastReceivedId: number, sessionId
|
|
3
|
+
pending: (lastReceivedId: number, sessionId: string) => Promise<RpcNotification[]>;
|
|
4
4
|
apply: (request: ApplyRequest) => Promise<ApplyResult>;
|
|
5
5
|
}
|
|
6
6
|
export declare function createRpcClient(dir: string, expectedPid?: number): RpcClient;
|
package/dist/rpc/rpc-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ph as l}from"../index-0jfsxyn9.js";import"../index-n96q8pks.js";async function a(n,e,t,o){let r=await l(n,o);if(!r)return null;let i=new AbortController,p=setTimeout(()=>i.abort(),2000);try{let s=await fetch(`http://127.0.0.1:${r.port}/rpc/${e}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${r.token}`},body:JSON.stringify(t),signal:i.signal});if(!s.ok)return null;return await s.json()}catch{return null}finally{clearTimeout(p)}}function u(n,e){return{async pending(t,o){return(await a(n,"pending-notifications",{lastReceivedId:t,sessionId:o},e))?.messages??[]},async apply(t){return await a(n,"apply",{...t},e)??{text:"apply failed",knobs:{}}}}}export{u as createRpcClient};
|
package/dist/rpc/rpc-dir.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{rh as a,sh as b}from"../index-1gr8v4fn.js";import"../index-n96q8pks.js";export{a as tmpdir,b as getRpcDir};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RpcServerHandle } from './rpc-server';
|
|
2
|
+
export interface RpcServerAdoption {
|
|
3
|
+
server: RpcServerHandle;
|
|
4
|
+
release: () => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Serializes same-directory replacement and returns an identity-fenced lease.
|
|
8
|
+
* Distinct project directories remain independent.
|
|
9
|
+
*/
|
|
10
|
+
export declare function adoptRpcServer(rpcDir: string, create: () => Promise<RpcServerHandle>): Promise<RpcServerAdoption>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ProcessFence } from './types.ts';
|
|
2
|
+
export interface WriteOpenCodeTombstoneOptions {
|
|
3
|
+
authPath: string;
|
|
4
|
+
fence?: ProcessFence;
|
|
5
|
+
beforeRename?: () => Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare function writeOpenCodeTombstoneAuth(options: WriteOpenCodeTombstoneOptions): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ClaustrumEnrollmentClient, type ClaustrumScopedClient } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
import type { CommandRunner, HarnessKind } from './types.ts';
|
|
3
|
+
export interface SetupClaustrumOptions {
|
|
4
|
+
paths?: {
|
|
5
|
+
tokenPath: string;
|
|
6
|
+
statePath: string;
|
|
7
|
+
};
|
|
8
|
+
ckBinary?: string;
|
|
9
|
+
runner?: CommandRunner;
|
|
10
|
+
enrollmentClient?: ClaustrumEnrollmentClient & {
|
|
11
|
+
close?: () => void;
|
|
12
|
+
};
|
|
13
|
+
scopedClient?: ClaustrumScopedClient & {
|
|
14
|
+
close?: () => void;
|
|
15
|
+
};
|
|
16
|
+
env?: NodeJS.ProcessEnv;
|
|
17
|
+
}
|
|
18
|
+
export interface SetupClaustrumResult {
|
|
19
|
+
ok: boolean;
|
|
20
|
+
message: string;
|
|
21
|
+
discoveredAccounts: Array<{
|
|
22
|
+
credentialId: string;
|
|
23
|
+
accountId: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export declare function setupClaustrumForHost(host: HarnessKind, options?: SetupClaustrumOptions): Promise<SetupClaustrumResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommandRunner, ProcessFence } from './types.ts';
|
|
2
|
+
export interface SetupCommandOptions {
|
|
3
|
+
runner?: CommandRunner;
|
|
4
|
+
fence?: ProcessFence;
|
|
5
|
+
env?: NodeJS.ProcessEnv;
|
|
6
|
+
isInteractive?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function runSetupCommand(argv?: string[], options?: SetupCommandOptions): Promise<number>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ClaustrumDetection, CommandRunner, HostDetection, SetupDetection } from './types.ts';
|
|
2
|
+
export declare function detectOpenCode(env?: NodeJS.ProcessEnv, runner?: CommandRunner): Promise<HostDetection>;
|
|
3
|
+
export declare function detectPi(env?: NodeJS.ProcessEnv, runner?: CommandRunner): Promise<HostDetection>;
|
|
4
|
+
export declare function detectClaustrum(env?: NodeJS.ProcessEnv, runner?: CommandRunner): Promise<ClaustrumDetection>;
|
|
5
|
+
export declare function detectAll(env?: NodeJS.ProcessEnv, runner?: CommandRunner): Promise<SetupDetection>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function readJsonc<T = unknown>(path: string): {
|
|
2
|
+
value: T | null;
|
|
3
|
+
text: string;
|
|
4
|
+
exists: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function updateJsoncArray(originalText: string, arrayPath: (string | number)[], entryToInsertOrUpdate: string, matcher: (existing: string) => boolean): {
|
|
7
|
+
text: string;
|
|
8
|
+
changed: boolean;
|
|
9
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function detectOpenCodeConfigFile(configDir: string): {
|
|
2
|
+
path: string;
|
|
3
|
+
exists: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function detectOpenCodeTuiConfigFile(configDir: string): {
|
|
6
|
+
path: string;
|
|
7
|
+
exists: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function ensureOpenCodePluginConfig(version: string, env?: NodeJS.ProcessEnv): Promise<{
|
|
10
|
+
configPath: string;
|
|
11
|
+
changed: boolean;
|
|
12
|
+
created: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function ensureOpenCodeTuiConfig(version: string, env?: NodeJS.ProcessEnv): Promise<{
|
|
15
|
+
configPath: string;
|
|
16
|
+
changed: boolean;
|
|
17
|
+
created: boolean;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const OPENCODE_PACKAGE_NAME = "@cortexkit/opencode-anthropic-auth";
|
|
2
|
+
export declare const PI_PACKAGE_NAME = "@cortexkit/pi-anthropic-auth";
|
|
3
|
+
export declare function getOpenCodeConfigDir(env?: NodeJS.ProcessEnv): string;
|
|
4
|
+
export declare function getOpenCodeDataDir(env?: NodeJS.ProcessEnv): string;
|
|
5
|
+
export declare function getOpenCodeAuthPath(env?: NodeJS.ProcessEnv): string;
|
|
6
|
+
export declare function getPiAgentDir(env?: NodeJS.ProcessEnv): string;
|
|
7
|
+
export declare function getPiAuthPath(env?: NodeJS.ProcessEnv): string;
|
|
8
|
+
export declare function opencodePluginEntry(version: string): string;
|
|
9
|
+
export declare function opencodeTuiEntry(version: string): string;
|
|
10
|
+
export declare function piPluginEntry(version: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Robustly resolve the package version from both source (src/setup/paths.ts)
|
|
13
|
+
* and bundled layouts (dist/cli.js, dist/index.js, etc.).
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSetupPackageVersion(): Promise<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommandRunner } from './types.ts';
|
|
2
|
+
export declare function isPiPackageInstalled(env?: NodeJS.ProcessEnv): boolean;
|
|
3
|
+
export declare function hasPiLocalAnthropicAuth(env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
4
|
+
export declare function cleanPiLocalAnthropicAuth(env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
5
|
+
export declare function installPiExtension(version: string, runner?: CommandRunner, env?: NodeJS.ProcessEnv): Promise<{
|
|
6
|
+
ok: boolean;
|
|
7
|
+
message: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandRunner, ProcessFence } from './types.ts';
|
|
2
|
+
export declare class ProcessFenceViolationError extends Error {
|
|
3
|
+
readonly activeHosts: Array<{
|
|
4
|
+
pid: number;
|
|
5
|
+
command: string;
|
|
6
|
+
}>;
|
|
7
|
+
constructor(activeHosts: Array<{
|
|
8
|
+
pid: number;
|
|
9
|
+
command: string;
|
|
10
|
+
}>);
|
|
11
|
+
}
|
|
12
|
+
export declare function createProcessFence(runner?: CommandRunner): ProcessFence;
|
|
13
|
+
export declare const defaultProcessFence: ProcessFence;
|
|
14
|
+
export declare function assertHostsStopped(fence?: ProcessFence): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type HarnessKind = 'opencode' | 'pi';
|
|
2
|
+
export interface HostDetection {
|
|
3
|
+
kind: HarnessKind;
|
|
4
|
+
installed: boolean;
|
|
5
|
+
version: string | null;
|
|
6
|
+
configPath: string;
|
|
7
|
+
pluginInstalled: boolean;
|
|
8
|
+
hasLocalAuth?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ClaustrumDetection {
|
|
11
|
+
ckInstalled: boolean;
|
|
12
|
+
ckVersion: string | null;
|
|
13
|
+
daemonRunning: boolean;
|
|
14
|
+
connectionPath: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface SetupDetection {
|
|
17
|
+
opencode: HostDetection;
|
|
18
|
+
pi: HostDetection;
|
|
19
|
+
claustrum: ClaustrumDetection;
|
|
20
|
+
}
|
|
21
|
+
export interface CommandRunnerResult {
|
|
22
|
+
exitCode: number;
|
|
23
|
+
stdout: string;
|
|
24
|
+
stderr: string;
|
|
25
|
+
}
|
|
26
|
+
export interface CommandRunner {
|
|
27
|
+
run(command: string, args: string[], options?: {
|
|
28
|
+
env?: Record<string, string | undefined>;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
}): Promise<CommandRunnerResult>;
|
|
31
|
+
}
|
|
32
|
+
export interface ProcessFence {
|
|
33
|
+
listRunningHosts(env?: Record<string, string | undefined>): Promise<Array<{
|
|
34
|
+
pid: number;
|
|
35
|
+
command: string;
|
|
36
|
+
}>>;
|
|
37
|
+
}
|
package/dist/sidebar-state.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface SidebarAccountState {
|
|
|
38
38
|
enabled: boolean;
|
|
39
39
|
needsReauth: boolean;
|
|
40
40
|
vaultReauth?: boolean;
|
|
41
|
+
vaultServed?: boolean;
|
|
42
|
+
custodyState?: 'off' | 'on-vault-served' | 'on-vault-reauth' | 'on-cold' | 'unknown-identity' | 'on-identity-mismatch' | 'on-corrupt-binding';
|
|
41
43
|
tierLabel?: string;
|
|
42
44
|
}
|
|
43
45
|
export interface FableRecoverySidebarState {
|
|
@@ -59,7 +61,7 @@ export interface PrimeSidebarAccountState {
|
|
|
59
61
|
label: string;
|
|
60
62
|
nextDueAt?: number | null;
|
|
61
63
|
lastPrimedAt?: number | null;
|
|
62
|
-
lastResult?: 'ok' | 'error';
|
|
64
|
+
lastResult?: 'ok' | 'error' | 'skipped';
|
|
63
65
|
usage?: PrimeUsageCounters;
|
|
64
66
|
estimatedCostUsd?: number;
|
|
65
67
|
}
|
package/dist/sidebar-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s
|
|
1
|
+
import{A as t,B as u,h as a,i as b,j as c,k as d,l as e,m as f,n as g,o as h,p as i,q as j,r as k,s as l,t as m,u as n,v as o,w as p,x as q,y as r,z as s}from"./index-xzbhzz0a.js";import"./index-1fq7h6yd.js";import"./index-a5d6v3ba.js";import"./index-n96q8pks.js";export{i as setSidebarState,k as resolveActiveAccount,c as normalizeSidebarState,a as getSidebarStateFile,h as getSidebarState,f as getInitialSidebarRoutingTestHooks,q as getFableRecoverySummary,r as getCollapsedQuotaSummary,l as formatScopedQuotaLabel,n as formatPrimeTime,o as formatPrimeCost,p as formatPrimeAccountValue,m as formatFallbackModelLabel,j as drainSidebarWrites,u as computeQuotaPacing,d as __setSidebarStateWriteTestHooks,e as __setInitialSidebarRoutingTestHooks,g as __acquireSidebarStateLockForTest,t as SEVEN_DAY_MS,s as FIVE_HOUR_MS,b as DEFAULT_SIDEBAR_STATE};
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type Cache1hMode, type ClaudeCodeIdentity, type ThinkingPrefixMismatchBehavior } from '@cortexkit/anthropic-auth-core';
|
|
1
|
+
import { type BillingLineageFields, type Cache1hMode, type ClaudeCodeIdentity, type ThinkingPrefixMismatchBehavior } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
import { type OpenCodeEffortMarkerPlan } from './effort-history';
|
|
2
3
|
import { type ServerSideFallbackOutcome } from './server-fallback';
|
|
3
4
|
export declare const NON_STREAMING_DIAGNOSTICS_MAX_BYTES: number;
|
|
4
5
|
export type FetchInput = string | URL | Request;
|
|
@@ -91,10 +92,13 @@ export declare function rewriteRequestBody(body: string, options?: {
|
|
|
91
92
|
thinkingPrefixMismatchBehavior?: ThinkingPrefixMismatchBehavior;
|
|
92
93
|
midConversationEffortEnabled?: boolean;
|
|
93
94
|
midConversationEffortPlan?: string;
|
|
95
|
+
midConversationEffortResolvedPlan?: OpenCodeEffortMarkerPlan;
|
|
94
96
|
perf?: RewritePerfCallback;
|
|
95
97
|
hybridStandbyAnchor?: HybridMessageCacheAnchor;
|
|
96
98
|
serverSideFallbackEnabled?: boolean;
|
|
99
|
+
modelRemapEnabled?: boolean;
|
|
97
100
|
laneStart?: boolean;
|
|
101
|
+
billingLineage?: BillingLineageFields;
|
|
98
102
|
cacheDiagnosticsPreviousMessageId?: string | null;
|
|
99
103
|
}): Promise<string>;
|
|
100
104
|
type RelayUpstreamStatus = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
|
-
import type
|
|
2
|
+
import { type PrimeAccountStatus } from '@cortexkit/anthropic-auth-core';
|
|
3
3
|
import type { TuiPluginApi } from '@opencode-ai/plugin/tui';
|
|
4
4
|
import type { AccountDialogAccount } from '../rpc/protocol';
|
|
5
5
|
import type { OpenDialogPayload } from '../rpc/protocol.js';
|
|
@@ -12,6 +12,19 @@ type KillswitchDialogConfig = {
|
|
|
12
12
|
main?: Record<string, number>;
|
|
13
13
|
accounts?: Record<string, Record<string, number>>;
|
|
14
14
|
};
|
|
15
|
+
type TuiAccountDialogAccount = Omit<AccountDialogAccount, 'vaultReauth' | 'custodyState'> & Partial<Pick<AccountDialogAccount, 'vaultReauth' | 'custodyState'>>;
|
|
16
|
+
type TuiAccountDialogPayload = {
|
|
17
|
+
accounts: TuiAccountDialogAccount[];
|
|
18
|
+
claustrumDetection: string;
|
|
19
|
+
custodyMode?: TuiCustodyMode;
|
|
20
|
+
enrollmentStatus?: string;
|
|
21
|
+
};
|
|
22
|
+
type TuiCustodyMode = 'local' | 'claustrum' | `mismatch: ${string}`;
|
|
23
|
+
type AccountDialogOption = {
|
|
24
|
+
title: string;
|
|
25
|
+
value: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
};
|
|
15
28
|
export declare const PRIME_DIALOG_OPTIONS: {
|
|
16
29
|
title: string;
|
|
17
30
|
value: string;
|
|
@@ -20,11 +33,23 @@ export declare function handlePrimeStatusOption(option: {
|
|
|
20
33
|
value: string;
|
|
21
34
|
}, renderMain: () => void): void;
|
|
22
35
|
export declare function buildKillswitchThresholdSeed(config: KillswitchDialogConfig, accountIds: string[]): string;
|
|
23
|
-
export declare function
|
|
36
|
+
export declare function normalizeAccountDialogPayload(value: unknown): TuiAccountDialogPayload;
|
|
37
|
+
export declare function buildAccountDialogOption(account: TuiAccountDialogAccount): {
|
|
24
38
|
title: string;
|
|
25
39
|
value: string;
|
|
26
40
|
description?: string | undefined;
|
|
27
41
|
};
|
|
42
|
+
export declare function buildManageAccountOptions(account: TuiAccountDialogAccount): AccountDialogOption[];
|
|
43
|
+
export declare function buildAccountDialogL1(value: unknown): {
|
|
44
|
+
header: string;
|
|
45
|
+
options: AccountDialogOption[];
|
|
46
|
+
enrollmentStatus?: string;
|
|
47
|
+
modeAction?: {
|
|
48
|
+
command: 'claude-account';
|
|
49
|
+
arguments: 'local' | 'claustrum';
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare function retainAccountDialogProjection(current: Record<string, unknown>, incoming: Record<string, unknown>): Record<string, unknown>;
|
|
28
53
|
/**
|
|
29
54
|
* Format the per-account status lines shown in the Claude prime Status
|
|
30
55
|
* view. Pure: consumed by the dialog's Status pane; the sidebar uses a
|
package/dist/tui-preferences.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{nh as _}from"./index-xxhyhp98.js";import{th as C}from"./index-n96q8pks.js";var W=C(_(),1);import{readFileSync as E,watch as b}from"node:fs";import{mkdir as g,readFile as A,rename as F,writeFile as T}from"node:fs/promises";import{homedir as y}from"node:os";import{basename as f,dirname as x,join as D}from"node:path";import{clearTimeout as U,setTimeout as R}from"node:timers";var v="OPENCODE_TUI_PREFERENCES_FILE",h="tui-preferences.jsonc";function K(){let J=process.env[v];if(J)return J;let z=process.env.OPENCODE_CONFIG_DIR||D(process.env.XDG_CONFIG_HOME||D(y(),".config"),"opencode");return D(z,h)}function H(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}async function e(){try{let J=await A(K(),"utf8"),z=[],q=W.parse(J,z,{allowTrailingComma:!0});if(z.length>0)return{};return H(q)?q:{}}catch{return{}}}var m="anthropic-auth",p=160,w={forceToTop:!1,order:p,startCollapsed:!1,rememberCollapsed:!0,collapsed:null,pollMs:1500,refreshDebounceMs:200,header:{label:"CLAUDE",showVersion:!0},sections:{quota:!0,fallbackAccounts:!0,routing:!0,cache:!0,health:!0,pacing:!0},appearance:{barWidth:10,barFilledChar:"█",barEmptyChar:"░",warnThreshold:50,errorThreshold:80}};function $(J,z){return typeof J==="boolean"?J:z}function Y(J,z,q,X){if(typeof J!=="number"||!Number.isFinite(J))return z;return Math.min(Math.max(Math.round(J),q),X)}function c(J,z,q){if(typeof J!=="string"||J.length===0)return z;return J.slice(0,q)}function P(J,z){if(typeof J!=="string")return z;return[...J][0]??z}function qq(J){let z=J[m];if(!H(z))return structuredClone(w);let q=w,X=H(z.header)?z.header:{},Q=H(z.sections)?z.sections:{},Z=H(z.appearance)?z.appearance:{},G=Y(Z.warnThreshold,q.appearance.warnThreshold,0,99),V=Math.max(Y(Z.errorThreshold,q.appearance.errorThreshold,0,100),Math.min(G+1,100));return{forceToTop:$(z.forceToTop,q.forceToTop),order:Y(z.order,q.order,-1e4,1e4),startCollapsed:$(z.startCollapsed,q.startCollapsed),rememberCollapsed:$(z.rememberCollapsed,q.rememberCollapsed),collapsed:typeof z.collapsed==="boolean"?z.collapsed:null,pollMs:Y(z.pollMs,q.pollMs,500,30000),refreshDebounceMs:Y(z.refreshDebounceMs,q.refreshDebounceMs,50,5000),header:{label:c(X.label,q.header.label,20),showVersion:$(X.showVersion,q.header.showVersion)},sections:{quota:$(Q.quota,q.sections.quota),fallbackAccounts:$(Q.fallbackAccounts,q.sections.fallbackAccounts),routing:$(Q.routing,q.sections.routing),cache:$(Q.cache,q.sections.cache),health:$(Q.health,q.sections.health),pacing:$(Q.pacing,q.sections.pacing)},appearance:{barWidth:Y(Z.barWidth,q.appearance.barWidth,4,40),barFilledChar:P(Z.barFilledChar,q.appearance.barFilledChar),barEmptyChar:P(Z.barEmptyChar,q.appearance.barEmptyChar),warnThreshold:G,errorThreshold:V}}}var u=-1e5;function zq(J,z,q){let X=J[z];if(!H(X))return q;if(X.forceToTop===!0)return u+Object.keys(J).indexOf(z);return Y(X.order,q,-1e4,1e4)}var s=`// Shared preferences for opencode TUI plugins.
|
|
2
2
|
// One top-level key per plugin (short name). See each plugin's README for
|
|
3
3
|
// its supported settings. This file is safe to hand-edit; plugins update
|
|
4
4
|
// individual keys in place and preserve comments.
|
|
5
5
|
{}
|
|
6
|
-
`;async function
|
|
6
|
+
`;async function d(J,z,q){let X=K();await g(x(X),{recursive:!0});let Q;try{Q=await A(X,"utf8")}catch{Q=""}if(Q.trim()==="")Q=s;let Z=W.modify(Q,[J,...z],q,{formattingOptions:{insertSpaces:!0,tabSize:2}}),G=W.applyEdits(Q,Z),V=`${X}.${process.pid}.tmp`;await T(V,G,"utf8"),await F(V,X)}var I=Promise.resolve();function Jq(J,z,q){return I=I.then(()=>d(J,z,q)).catch(()=>{}),I}var o=150,n=100;function Qq(J,z={}){let q=K(),X=f(q),Q=null,Z=null;try{Z=E(q,"utf8")}catch{}let G=!1,V=async()=>{let j=await A(q,"utf8").catch(()=>null);if(G||j===null)return;if(j===Z)return;Z=j,J()},S=()=>{if(Q)U(Q);Q=R(()=>{Q=null,V()},o)},O=null;try{O=(z.watchDirectory??b)(x(q),(j,M)=>{let k=M===X||M?.startsWith(`${X}.`)&&M.endsWith(".tmp");if(M!=null&&!k)return;S()})}catch{if(Z===null)return()=>{}}let B=null,N=!1,L=()=>{if(G||B)return;B=R(()=>{if(B=null,G||N)return;N=!0,V().finally(()=>{N=!1,L()})},n),B.unref?.()};return L(),()=>{if(G=!0,Q)U(Q);if(B)U(B);O?.close()}}export{Qq as watchTuiPreferences,qq as resolveAnthropicAuthPrefs,e as readTuiPreferencesFile,Jq as queueTuiPreferenceUpdate,K as getTuiPreferencesFile,zq as computeEffectiveOrder,v as TUI_PREFS_FILE_ENV,m as PLUGIN_KEY,p as DEFAULT_SLOT_ORDER,w as DEFAULT_PREFS};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/opencode-anthropic-auth",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -45,9 +45,10 @@
|
|
|
45
45
|
"LICENSE"
|
|
46
46
|
],
|
|
47
47
|
"scripts": {
|
|
48
|
-
"build": "rm -rf dist && bun build src/index.ts src/cli.ts src/sidebar-state.ts src/tui-preferences.ts src/rpc/rpc-client.ts src/rpc/port-file.ts src/rpc/protocol.ts src/rpc/rpc-dir.ts --outdir dist --target node --format esm --splitting --external @opencode-ai/plugin --minify && tsc -p tsconfig.build.json --emitDeclarationOnly && bun run build:tui",
|
|
48
|
+
"build": "rm -rf dist && bun build src/index.ts src/cli.ts src/sidebar-state.ts src/tui-preferences.ts src/rpc/rpc-client.ts src/rpc/port-file.ts src/rpc/protocol.ts src/rpc/rpc-dir.ts --outdir dist --target node --format esm --splitting --external @opencode-ai/plugin --minify && tsc -p tsconfig.build.json --emitDeclarationOnly && bun run build:tui && bun run check:bundle",
|
|
49
49
|
"build:tui": "bun scripts/build-tui.ts",
|
|
50
50
|
"smoke:tui": "bun scripts/smoke-tui-pack-install.ts",
|
|
51
|
+
"check:bundle": "bun scripts/check-bundle-globals.ts",
|
|
51
52
|
"build:dev": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
52
53
|
"dev": "bun ../../scripts/dev.ts",
|
|
53
54
|
"dev:clean": "bun ../../scripts/dev-clean.ts",
|
|
@@ -61,10 +62,14 @@
|
|
|
61
62
|
"@opencode-ai/plugin": "*"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"@opentui/
|
|
65
|
+
"@clack/prompts": "^1.6.0",
|
|
66
|
+
"@cortexkit/anthropic-auth-core": "1.23.0",
|
|
67
|
+
"@opentui/core": "0.5.11",
|
|
68
|
+
"@opentui/solid": "0.5.11",
|
|
67
69
|
"jsonc-parser": "^3.3.1",
|
|
68
70
|
"solid-js": "1.9.12"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@ai-sdk/anthropic": "3.0.111"
|
|
69
74
|
}
|
|
70
75
|
}
|
package/src/rpc/notifications.ts
CHANGED
|
@@ -3,52 +3,56 @@ import type { OpenDialogPayload, RpcNotification } from './protocol'
|
|
|
3
3
|
const QUEUE_CAP = 100
|
|
4
4
|
const TUI_CONNECTED_WINDOW_MS = 3_000
|
|
5
5
|
|
|
6
|
+
// One queue serves every RPC server in the process, and a process can hold one
|
|
7
|
+
// server per project directory. Session ids are globally unique, so both
|
|
8
|
+
// producers and drains require one: an unscoped drain could otherwise expose
|
|
9
|
+
// another project's pending command dialog.
|
|
6
10
|
let queue: RpcNotification[] = []
|
|
7
11
|
let nextId = 1
|
|
8
|
-
let lastDrainAtAny = 0
|
|
9
12
|
const lastDrainAtBySession = new Map<string, number>()
|
|
10
13
|
|
|
14
|
+
function assertSessionId(sessionId: string): void {
|
|
15
|
+
if (typeof sessionId !== 'string' || sessionId.length === 0) {
|
|
16
|
+
throw new TypeError('sessionId is required')
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
export function pushNotification(
|
|
12
21
|
payload: OpenDialogPayload,
|
|
13
|
-
sessionId
|
|
22
|
+
sessionId: string,
|
|
14
23
|
): void {
|
|
24
|
+
assertSessionId(sessionId)
|
|
15
25
|
queue.push({ id: nextId++, type: 'open-dialog', payload, sessionId })
|
|
16
26
|
if (queue.length > QUEUE_CAP) queue = queue.slice(queue.length - QUEUE_CAP)
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
export function drainNotifications(
|
|
20
|
-
lastReceivedId
|
|
21
|
-
sessionId
|
|
30
|
+
lastReceivedId: number,
|
|
31
|
+
sessionId: string,
|
|
22
32
|
): RpcNotification[] {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (sessionId !== undefined) lastDrainAtBySession.set(sessionId, now)
|
|
26
|
-
const matches = (n: RpcNotification) =>
|
|
27
|
-
sessionId === undefined ||
|
|
28
|
-
n.sessionId === undefined ||
|
|
29
|
-
n.sessionId === sessionId
|
|
33
|
+
assertSessionId(sessionId)
|
|
34
|
+
lastDrainAtBySession.set(sessionId, Date.now())
|
|
30
35
|
if (lastReceivedId > 0) {
|
|
31
|
-
queue = queue.filter(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
queue = queue.filter(
|
|
37
|
+
(notification) =>
|
|
38
|
+
notification.id > lastReceivedId ||
|
|
39
|
+
notification.sessionId !== sessionId,
|
|
40
|
+
)
|
|
36
41
|
}
|
|
37
|
-
return queue.filter(
|
|
42
|
+
return queue.filter(
|
|
43
|
+
(notification) =>
|
|
44
|
+
notification.id > lastReceivedId && notification.sessionId === sessionId,
|
|
45
|
+
)
|
|
38
46
|
}
|
|
39
47
|
|
|
40
|
-
export function isTuiConnected(sessionId
|
|
48
|
+
export function isTuiConnected(sessionId: string): boolean {
|
|
41
49
|
const now = Date.now()
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return at > 0 && now - at < TUI_CONNECTED_WINDOW_MS
|
|
45
|
-
}
|
|
46
|
-
return lastDrainAtAny > 0 && now - lastDrainAtAny < TUI_CONNECTED_WINDOW_MS
|
|
50
|
+
const at = lastDrainAtBySession.get(sessionId) ?? 0
|
|
51
|
+
return at > 0 && now - at < TUI_CONNECTED_WINDOW_MS
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
export function resetNotificationsForTest(): void {
|
|
50
55
|
queue = []
|
|
51
56
|
nextId = 1
|
|
52
|
-
lastDrainAtAny = 0
|
|
53
57
|
lastDrainAtBySession.clear()
|
|
54
58
|
}
|