@cortexkit/opencode-anthropic-auth 2.0.2 → 2.1.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 +35 -845
- package/dist/cli-failure.d.ts +38 -7
- package/dist/cli.js +50 -102
- package/dist/custody-mode.d.ts +1 -0
- package/dist/fable-fallback.d.ts +6 -2
- package/dist/index-0kxy8k2c.js +2 -0
- package/dist/index-1nwcnxp8.js +42 -0
- package/dist/index-53nnxq39.js +2 -0
- package/dist/{index-2arfb1y3.js → index-6chd6jnr.js} +1 -1
- package/dist/{index-1tbpt45x.js → index-ah5s0bew.js} +1 -1
- package/dist/index-b1dvkp15.js +2 -0
- package/dist/{index-mge0rw54.js → index-f2ne65w4.js} +1 -1
- package/dist/{index-rqync0pc.js → index-hazrk5c3.js} +1 -1
- package/dist/{index-1jkyhgyr.js → index-jexctf5w.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/quota-preflight.d.ts +1 -0
- package/dist/request-class.d.ts +10 -0
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/setup/command.d.ts +5 -14
- package/dist/setup/native-activation.d.ts +21 -8
- package/dist/setup/native-enrollment.d.ts +21 -0
- package/dist/setup/native-local.d.ts +31 -1
- package/dist/setup/native-login.d.ts +12 -1
- package/dist/setup/process-fence.d.ts +0 -6
- package/dist/setup/types.d.ts +9 -0
- package/dist/sidebar-state.d.ts +20 -2
- package/dist/sidebar-state.js +1 -1
- package/dist/transform.d.ts +2 -8
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +0 -2
- package/dist/v2/activation.d.ts +2 -0
- package/dist/v2/adapter.d.ts +11 -1
- package/dist/v2/cachekeep.d.ts +19 -0
- package/dist/v2/menu.d.ts +2 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/setup.d.ts +2 -0
- package/dist/v2/source.d.ts +1 -0
- package/dist/v2/tui.js +1 -1
- package/package.json +10 -6
- package/src/sidebar-state.ts +105 -30
- package/src/tui-compiled/sidebar-state.ts +105 -30
- package/src/tui-compiled/tui.tsx +395 -241
- package/src/tui.tsx +199 -58
- package/dist/index-227rsmfv.js +0 -42
- package/dist/index-74r84r5f.js +0 -1
- package/dist/index-b3mxpp4w.js +0 -2
- package/dist/index-fn0zqnnw.js +0 -3
- package/dist/index-j0wsgy54.js +0 -449
- package/dist/index-jc8p0tkv.js +0 -2
- package/dist/setup/activation.d.ts +0 -7
- package/dist/setup/command.test.d.ts +0 -1
- package/dist/setup/detect.d.ts +0 -8
- package/dist/setup/host-executable.d.ts +0 -3
- package/dist/setup/jsonc.d.ts +0 -9
- package/dist/setup/opencode-config.d.ts +0 -18
- package/dist/setup/pi.d.ts +0 -18
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var t=["claude-account","claude-cache","claude-cachekeep","claude-prime","claude-start","claude-quota","claude-dump","claude-fast","claude-routing","claude-killswitch","claude-logging"];
|
|
2
|
-
export{t as
|
|
2
|
+
export{t as q};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{mkdir as l,readdir as u,readFile as c,rename as p,unlink as m,writeFile as d}from"node:fs/promises";import{join as a}from"node:path";function f(t){try{return process.kill(t,0),!0}catch(r){return r.code==="EPERM"}}async function b(t,r){await l(t,{recursive:!0});let s={...r,startedAt:Date.now()},e=a(t,`port-${r.pid}.json`),i=`${e}.${process.pid}.tmp`;return await d(i,JSON.stringify(s),{encoding:"utf8",mode:384}),await p(i,e),e}async function h(t,r){let s;try{s=await u(t)}catch{return null}let e=[];for(let n of s){if(!n.startsWith("port-")||!n.endsWith(".json"))continue;try{let o=JSON.parse(await c(a(t,n),"utf8"));if(Number.isFinite(o.port))if(f(o.pid))e.push(o);else m(a(t,n)).catch(()=>{})}catch{}}if(e.length===0)return null;let i=r&&r>=1?e.filter((n)=>n.pid===r):[];return(i.length>0?i:e).sort((n,o)=>o.startedAt-n.startedAt)[0]??null}
|
|
2
|
-
export{b as
|
|
2
|
+
export{b as aa,h as ba};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{existsSync as $,readFileSync as F}from"node:fs";import{homedir as Y}from"node:os";import{dirname as X,join as J,resolve as V}from"node:path";import{fileURLToPath as Z}from"node:url";var b="@cortexkit/opencode-anthropic-auth",G="@cortexkit/pi-anthropic-auth";function W(q=process.env,w=process.platform){return(w==="win32"?q.USERPROFILE||q.HOME:q.HOME)||Y()}function K(q=process.env,w=process.platform){let B=q.OPENCODE_CONFIG_DIR?.trim();if(B)return V(B);return J(q.XDG_CONFIG_HOME||J(W(q,w),".config"),"opencode")}function I(q=process.env){let w=q.XDG_DATA_HOME?.trim();if(w)return J(V(w),"opencode");return J(Y(),".local","share","opencode")}function M(q=process.env){return J(I(q),"auth.json")}function R(q=process.env,w=process.platform){let B=q.PI_CODING_AGENT_DIR?.trim()||q.PI_AGENT_DIR?.trim();if(B)return V(B);return J(W(q,w),".pi","agent")}function k(q=process.env){let w=q.PI_CODING_AGENT_DIR,B=W(q),z=w||J(B,".pi","agent");if(z==="~")z=B;else if(z.startsWith("~/")||process.platform==="win32"&&z.startsWith("~\\"))z=J(B,z.slice(2));if(z.startsWith("file://"))z=Z(z);return J(z,"auth.json")}async function x(){let q=X(Z(import.meta.url));for(let w=0;w<5;w++){let B=J(q,"package.json");if($(B))try{let Q=JSON.parse(F(B,"utf8"));if(typeof Q.version==="string"&&Q.version.trim())return Q.version.trim()}catch{}let z=X(q);if(z===q)break;q=z}return"1.22.0"}
|
|
2
|
+
export{b as z,G as A,K as B,M as C,R as D,k as E,x as F};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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
|
|
2
|
+
export{r as ca,s as da,u as ea};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as z}from"node:crypto";import{homedir as F,tmpdir as O}from"node:os";import{join as q,resolve as G}from"node:path";var J="OPENCODE_ANTHROPIC_AUTH_RPC_DIR";function T(g){let k=process.env[J]?.trim();if(k)return G(g,k);let w=z("sha256").update(g).digest("hex").slice(0,16),x=process.env.XDG_STATE_HOME||q(F(),".local","state");return q(x,"cortexkit","anthropic-auth","rpc",w)}export{O as
|
|
1
|
+
import{createHash as z}from"node:crypto";import{homedir as F,tmpdir as O}from"node:os";import{join as q,resolve as G}from"node:path";var J="OPENCODE_ANTHROPIC_AUTH_RPC_DIR";function T(g){let k=process.env[J]?.trim();if(k)return G(g,k);let w=z("sha256").update(g).digest("hex").slice(0,16),x=process.env.XDG_STATE_HOME||q(F(),".local","state");return q(x,"cortexkit","anthropic-auth","rpc",w)}export{O as r,T as s};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var z=(f)=>f!==null&&typeof f==="object"&&!Array.isArray(f),G=(f)=>z(f)&&typeof f.sessionId==="string"&&f.sessionId.length>0,Z=(f)=>{if(!G(f)||!z(f)||f.command!=="claude"||typeof f.sectionId!=="string"||typeof f.actionId!=="string")return!1;if(f.itemId!==void 0&&typeof f.itemId!=="string")return!1;if(f.confirmed!==void 0&&typeof f.confirmed!=="boolean")return!1;if(f.values!==void 0&&(!z(f.values)||!Object.values(f.values).every((q)=>q===null||typeof q==="string"||typeof q==="boolean"||typeof q==="number"&&Number.isFinite(q))))return!1;return!0};function B(f){return{"~standard":{version:1,vendor:"cortexkit-native",validate:(q)=>f(q)?{value:q}:{issues:[{message:"Invalid native menu payload"}]}}}}var W=(f)=>z(f)&&f.command==="claude"&&z(f.menu)&&f.menu.command==="claude"&&typeof f.menu.title==="string"&&Array.isArray(f.menu.sections),$=(f)=>z(f)&&f.command==="claude"&&typeof f.ok==="boolean"&&typeof f.text==="string"&&z(f.menu)&&Array.isArray(f.menu.sections),A={id:"cortexkit-anthropic-native",methods:{open:{input:B(G),output:B(W)},apply:{input:B(Z),output:B($)}},events:{opened:{schema:B((f)=>G(f)&&W(f.payload))},notification:{schema:B((f)=>G(f)&&typeof f.message==="string"&&["info","warning","error"].includes(String(f.kind)))}}};async function L(f,q,X){let K=new AbortController,H=(j)=>({sessionId:j,notify(F,J="info"){D.events.emit("notification",{sessionId:j,message:F,kind:J}).catch(()=>{})}}),D=await f.rpc.register(A,{open:(j)=>q.open(H(j.sessionId)),apply:(j)=>q.apply(j,H(j.sessionId))}),Q;try{Q=await f.command.transform((j)=>j.add({name:"claude",description:"Native Claude accounts and settings",async execute(F){let J=await q.open(H(F.sessionID));await D.events.emit("opened",{sessionId:F.sessionID,payload:J})}}))}catch(j){throw await D.dispose(),j}let Y=(async()=>{try{for await(let j of f.event.subscribe({signal:K.signal}))if(j.type==="session.deleted")X.forgetSession(j.data.sessionID)}catch{}})(),S=!1;return{async dispose(){if(S)return;S=!0,K.abort(),await Promise.all([D.dispose(),Q.dispose(),Y])}}}
|
|
2
|
-
export{A as
|
|
2
|
+
export{A as t,L as u};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{p as a}from"./index-1nwcnxp8.js";import"./index-6chd6jnr.js";import"./index-hazrk5c3.js";import"./index-b1dvkp15.js";import"./index-53nnxq39.js";import"./index-ah5s0bew.js";import"./index-f2ne65w4.js";export{a as AnthropicAuthPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logFallbackQuotaPreflightWarning(accountId: string, requiredByPolicy: boolean, error: unknown): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ClaudeCodeRequestClass } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
/**
|
|
3
|
+
* Plugin-internal header that carries a request's Claude Code request class
|
|
4
|
+
* from the host's per-message hook to the fetch wrapper. It is removed before
|
|
5
|
+
* the request leaves.
|
|
6
|
+
*/
|
|
7
|
+
export declare const REQUEST_CLASS_REQUEST_HEADER = "x-cortexkit-request-class";
|
|
8
|
+
export declare function isAuxiliaryAgent(agent: unknown): boolean;
|
|
9
|
+
/** Read and remove the internal request-class header. */
|
|
10
|
+
export declare function takeRequestClassHeader(headers: Headers): ClaudeCodeRequestClass;
|
package/dist/rpc/port-file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aa as a,ba as b}from"../index-ah5s0bew.js";import"../index-f2ne65w4.js";export{a as writePortFile,b as discoverPortFile};
|
package/dist/rpc/protocol.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{q as a}from"../index-6chd6jnr.js";import"../index-f2ne65w4.js";export{a as COMMAND_MODAL_NAMES};
|
package/dist/rpc/rpc-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ba as s}from"../index-ah5s0bew.js";import"../index-f2ne65w4.js";async function i(e,o,t,n){let r=await s(e,n);if(!r)return null;let a=new AbortController,l=setTimeout(()=>a.abort(),2000);try{let p=await fetch(`http://127.0.0.1:${r.port}/rpc/${o}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${r.token}`},body:JSON.stringify(t),signal:a.signal});if(!p.ok)return null;return await p.json()}catch{return null}finally{clearTimeout(l)}}function c(e,o){return{async pending(t,n){return(await i(e,"pending-notifications",{lastReceivedId:t,sessionId:n},o))?.messages??[]},async apply(t){return await i(e,"apply",{...t},o)??{text:"apply failed",knobs:{}}},async applyMenu(t){if(t.command!=="claude"||!t.sessionId?.trim())throw TypeError("A claude menu sessionId is required");let n=await i(e,"apply-menu",{...t},o);if(!n)throw Error("Menu apply unavailable; outcome unknown");return n}}}export{c as createRpcClient};
|
package/dist/rpc/rpc-dir.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as a,s as b}from"../index-hazrk5c3.js";import"../index-f2ne65w4.js";export{a as tmpdir,b as getRpcDir};
|
package/dist/setup/command.d.ts
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import { activateNativeVaultForHost } from './native-activation.ts';
|
|
1
|
+
import { type SetupIO } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
import { completeNativeVaultActivation, preflightNativeVaultForHost } from './native-activation.ts';
|
|
4
3
|
import { migrateNativeLocalForHost } from './native-local.ts';
|
|
5
4
|
import { loginNativeOffline } from './native-login.ts';
|
|
6
|
-
|
|
7
|
-
export interface SetupCommandOptions {
|
|
8
|
-
runner?: CommandRunner;
|
|
9
|
-
fence?: ProcessFence;
|
|
10
|
-
env?: NodeJS.ProcessEnv;
|
|
11
|
-
isInteractive?: boolean;
|
|
12
|
-
/** Let tests substitute host detection and per-host vault activation. */
|
|
13
|
-
detect?: typeof detectAll;
|
|
14
|
-
activate?: typeof activateNativeVaultForHost;
|
|
5
|
+
export interface SetupCommandOptions extends SetupIO {
|
|
15
6
|
migrateLocal?: typeof migrateNativeLocalForHost;
|
|
16
7
|
localLogin?: typeof loginNativeOffline;
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
vaultPreflight?: typeof preflightNativeVaultForHost;
|
|
9
|
+
vaultActivate?: typeof completeNativeVaultActivation;
|
|
19
10
|
}
|
|
20
11
|
export declare function runSetupCommand(argv?: string[], options?: SetupCommandOptions): Promise<number>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type NativeCustodyActivationHooks, type NativeCustodyInventory } from '@cortexkit/anthropic-auth-core';
|
|
2
2
|
import { type NativeVaultEnrollmentOptions } from './native-enrollment.ts';
|
|
3
3
|
import { type NativeSetupPaths } from './native-paths.ts';
|
|
4
|
-
import type
|
|
4
|
+
import { type CommandRunner, type HarnessKind, type ProcessFence } from './types.ts';
|
|
5
|
+
type HostIndependentActivationCode = 'auth-content-refused' | 'host-auth-invalid' | 'primary-conflict' | 'consent-required' | 'primary-unverified';
|
|
6
|
+
/** Activation codes whose remedy names the host, so the host is required. */
|
|
7
|
+
type HostActivationCode = 'no-read-grant' | 'grant-reaches-nothing';
|
|
5
8
|
export declare class NativeVaultActivationError extends Error {
|
|
6
|
-
readonly code:
|
|
7
|
-
constructor(code:
|
|
9
|
+
readonly code: HostIndependentActivationCode | HostActivationCode;
|
|
10
|
+
constructor(code: HostIndependentActivationCode);
|
|
11
|
+
constructor(code: HostActivationCode, host: HarnessKind);
|
|
8
12
|
}
|
|
9
13
|
export interface NativeVaultActivationOptions {
|
|
10
14
|
env: NodeJS.ProcessEnv;
|
|
@@ -17,13 +21,22 @@ export interface NativeVaultActivationOptions {
|
|
|
17
21
|
* production resolves them from the host's environment.
|
|
18
22
|
*/
|
|
19
23
|
paths?: NativeSetupPaths;
|
|
24
|
+
/** Set false for OpenCode 2, whose setup must not read the OpenCode 1 auth file. */
|
|
25
|
+
inspectOpenCodeAuth?: boolean;
|
|
20
26
|
enrollment?: Pick<NativeVaultEnrollmentOptions, 'paths' | 'client' | 'ckBinary' | 'connectionFile'>;
|
|
21
27
|
discover?: () => Promise<NativeCustodyInventory>;
|
|
22
28
|
hooks?: NativeCustodyActivationHooks;
|
|
23
29
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
export interface NativeVaultPreflight {
|
|
31
|
+
priorMode: 'local' | 'claustrum';
|
|
32
|
+
fingerprint: string;
|
|
33
|
+
separateOpenCodeLogin?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function fingerprintNativeVaultInputs(host: HarnessKind, options: NativeVaultActivationOptions): Promise<string>;
|
|
36
|
+
/** Validate vault inputs before the runner enrolls any selected host. */
|
|
37
|
+
export declare function preflightNativeVaultForHost(host: HarnessKind, options: NativeVaultActivationOptions): Promise<NativeVaultPreflight>;
|
|
38
|
+
/** Grant native-account read access and require a vault-backed default Claude account with an account identity before moving Pi's login aside. */
|
|
39
|
+
export declare function completeNativeVaultActivation(host: HarnessKind, options: NativeVaultActivationOptions, preflight: NativeVaultPreflight): Promise<'committed' | 'already-vault'>;
|
|
40
|
+
/** Outside runSetup, check inputs, enroll the host, then grant and activate vault access. runSetup owns enrollment and calls preflight and completion separately. */
|
|
29
41
|
export declare function activateNativeVaultForHost(host: HarnessKind, options: NativeVaultActivationOptions): Promise<'committed' | 'already-vault'>;
|
|
42
|
+
export {};
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { type ClaustrumEnrollmentClient, type ClaustrumEnrollmentPaths } from '@cortexkit/common-auth/claustrum';
|
|
2
2
|
import type { CommandRunner, HarnessKind } from './types.ts';
|
|
3
|
+
export declare const NATIVE_VAULT_HOST_NAMES: {
|
|
4
|
+
readonly opencode: "anthropic-auth-opencode";
|
|
5
|
+
readonly pi: "anthropic-auth-pi";
|
|
6
|
+
};
|
|
7
|
+
/** Convert the token file resolved by getHostClaustrumEnrollmentPaths into runSetup's path inputs; the runner derives the matching state file itself. */
|
|
8
|
+
export declare function nativeVaultHostPaths(host: HarnessKind, env: NodeJS.ProcessEnv): {
|
|
9
|
+
stateDir: string;
|
|
10
|
+
host: HarnessKind;
|
|
11
|
+
override: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function nativeVaultConnectionFile(host: HarnessKind, env: NodeJS.ProcessEnv): string;
|
|
3
14
|
export interface NativeVaultEnrollmentOptions {
|
|
4
15
|
env: NodeJS.ProcessEnv;
|
|
5
16
|
runner: CommandRunner;
|
|
@@ -13,6 +24,8 @@ export interface NativeVaultEnrollmentOptions {
|
|
|
13
24
|
client?: ClaustrumEnrollmentClient;
|
|
14
25
|
ckBinary?: string;
|
|
15
26
|
connectionFile?: string;
|
|
27
|
+
/** Defaults to granting native-account read access after enrollment. False leaves that grant to completeNativeVaultActivation, avoiding a duplicate grant. */
|
|
28
|
+
grantPermissions?: boolean;
|
|
16
29
|
}
|
|
17
30
|
export declare class NativeVaultEnrollmentError extends Error {
|
|
18
31
|
readonly code: 'enrollment-refused' | 'enrollment-reset' | 'approval-refused' | 'permission-refused';
|
|
@@ -24,3 +37,11 @@ export declare class NativeVaultEnrollmentError extends Error {
|
|
|
24
37
|
* account discovery and the credential-store switch are separate setup steps.
|
|
25
38
|
*/
|
|
26
39
|
export declare function enrollNativeVaultForHost(host: HarnessKind, options: NativeVaultEnrollmentOptions): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* The `ck` arguments that grant this host's enrolled principal read access to
|
|
42
|
+
* the vault's anthropic-native category. Setup runs them, and the empty-vault
|
|
43
|
+
* message shows the same command so the user can run it by hand.
|
|
44
|
+
*/
|
|
45
|
+
export declare function nativeVaultGrantArgs(host: HarnessKind): string[];
|
|
46
|
+
/** Grant this OpenCode or Pi principal read access to the vault's anthropic-native category; enrollment alone grants no provider access. */
|
|
47
|
+
export declare function grantNativeVaultForHost(host: HarnessKind, options: Pick<NativeVaultEnrollmentOptions, 'env' | 'runner' | 'processFence' | 'ckBinary'>): Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type NativeMigrationPreflight, readNativeMigrationJournal } from '@cortexkit/anthropic-auth-core';
|
|
1
2
|
import { type NativeSetupPaths } from './native-paths';
|
|
2
|
-
import type
|
|
3
|
+
import { type HarnessKind, type ProcessFence } from './types';
|
|
3
4
|
export interface NativeOfflineLogin {
|
|
4
5
|
credential: {
|
|
5
6
|
type: 'oauth';
|
|
@@ -15,6 +16,35 @@ export interface NativeLocalSetupOptions {
|
|
|
15
16
|
paths?: NativeSetupPaths;
|
|
16
17
|
removePiAnthropicAuth: boolean;
|
|
17
18
|
login?: (host: HarnessKind) => Promise<NativeOfflineLogin>;
|
|
19
|
+
preflight?: NativeMigrationPreflight;
|
|
20
|
+
skipMigration?: boolean;
|
|
21
|
+
beforeCommit?: () => Promise<void>;
|
|
18
22
|
}
|
|
23
|
+
export declare const SEPARATE_HOST_LOGIN_NOTICE = "OpenCode's separate Anthropic login is not used. Add that account through /claude Accounts if needed, or remove the separate login from OpenCode.";
|
|
24
|
+
export declare function requireNativeLocalEnrollment(hosts: readonly HarnessKind[], env: NodeJS.ProcessEnv): Promise<void>;
|
|
25
|
+
export declare function nativeLocalProcessFence(host: HarnessKind, options: NativeLocalSetupOptions): () => Promise<void>;
|
|
26
|
+
export declare function nativeSetupFileFingerprint(path: string): Promise<string>;
|
|
27
|
+
export declare function inspectSetupHostAuth(host: HarnessKind, path: string): Promise<{
|
|
28
|
+
kind: 'absent' | 'oauth' | 'api' | 'api_key' | 'activation';
|
|
29
|
+
digest: string;
|
|
30
|
+
realLogin: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
export interface NativeLocalPlan {
|
|
33
|
+
paths: NativeSetupPaths;
|
|
34
|
+
generation2: boolean;
|
|
35
|
+
action: 'migration' | 'skip' | 'empty-init' | 'reuse';
|
|
36
|
+
slot?: Awaited<ReturnType<typeof inspectSetupHostAuth>>;
|
|
37
|
+
notice: boolean;
|
|
38
|
+
preflight?: NativeMigrationPreflight;
|
|
39
|
+
fingerprint: string;
|
|
40
|
+
authorityPhase: NonNullable<Awaited<ReturnType<typeof readNativeMigrationJournal>>>['phase'] | 'absent';
|
|
41
|
+
poolPopulation: boolean | 'not-evaluated';
|
|
42
|
+
}
|
|
43
|
+
/** Hash pool, journal and routing bytes and the host's Anthropic entry, so a credential replacement cannot hide behind an unchanged account count. */
|
|
44
|
+
export declare function fingerprintNativeLocalPlan(plan: NativeLocalPlan, env: NodeJS.ProcessEnv): Promise<string>;
|
|
45
|
+
/** Record journal status, the host's Anthropic entry and whether setup will import, skip import or initialize a new pool, without writing. */
|
|
46
|
+
export declare function planNativeLocalSetup(host: HarnessKind, options: NativeLocalSetupOptions, generation2: boolean): Promise<NativeLocalPlan>;
|
|
47
|
+
export declare function revalidateNativeLocalPlan(plan: NativeLocalPlan, options: NativeLocalSetupOptions): Promise<void>;
|
|
48
|
+
export declare function installAbsentNativePlaceholder(plan: Pick<NativeLocalPlan, 'paths' | 'slot'>, options: NativeLocalSetupOptions): Promise<void>;
|
|
19
49
|
/** Transfer local credentials while hosts are stopped, before telling the user to restart. */
|
|
20
50
|
export declare function migrateNativeLocalForHost(host: HarnessKind, options: NativeLocalSetupOptions): Promise<void>;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import { isCancel, text } from '@clack/prompts';
|
|
2
|
+
import { authorize, exchange, resolveClaudeCodeIdentity } from '@cortexkit/anthropic-auth-core';
|
|
1
3
|
import type { NativeOfflineLogin } from './native-local';
|
|
2
4
|
import type { HarnessKind } from './types';
|
|
3
|
-
|
|
5
|
+
interface NativeLoginDependencies {
|
|
6
|
+
authorize: typeof authorize;
|
|
7
|
+
exchange: typeof exchange;
|
|
8
|
+
resolveClaudeCodeIdentity: typeof resolveClaudeCodeIdentity;
|
|
9
|
+
text: typeof text;
|
|
10
|
+
isCancel: typeof isCancel;
|
|
11
|
+
print: (line: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function loginNativeOffline(host: HarnessKind, dependencies?: NativeLoginDependencies): Promise<NativeOfflineLogin>;
|
|
14
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CommandRunner, ProcessFence } from './types.ts';
|
|
2
1
|
export declare class ProcessInspectionError extends Error {
|
|
3
2
|
readonly code = "process-inspection-failed";
|
|
4
3
|
constructor();
|
|
@@ -13,8 +12,3 @@ export declare class ProcessFenceViolationError extends Error {
|
|
|
13
12
|
command: string;
|
|
14
13
|
}>);
|
|
15
14
|
}
|
|
16
|
-
export declare function createProcessFence(runner?: CommandRunner, options?: {
|
|
17
|
-
platform?: NodeJS.Platform;
|
|
18
|
-
}): ProcessFence;
|
|
19
|
-
export declare const defaultProcessFence: ProcessFence;
|
|
20
|
-
export declare function assertHostsStopped(fence?: ProcessFence): Promise<void>;
|
package/dist/setup/types.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export type HarnessKind = 'opencode' | 'pi';
|
|
2
|
+
export declare function setupRefusalMessage(error: unknown): string | undefined;
|
|
3
|
+
/** runSetup prints failures from its own stopped-host checks; provider callbacks need a displayable refusal for their separate process checks. */
|
|
4
|
+
export declare function setupProcessInspectionMessage(error: unknown): string | undefined;
|
|
5
|
+
/** A setup refusal whose message is safe to show on the terminal. */
|
|
6
|
+
export declare class SetupRefusal extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
2
9
|
export interface HostDetection {
|
|
3
10
|
kind: HarnessKind;
|
|
4
11
|
installed: boolean;
|
|
@@ -22,6 +29,8 @@ export interface CommandRunnerResult {
|
|
|
22
29
|
exitCode: number;
|
|
23
30
|
stdout: string;
|
|
24
31
|
stderr: string;
|
|
32
|
+
signal?: NodeJS.Signals | null;
|
|
33
|
+
spawnError?: boolean;
|
|
25
34
|
}
|
|
26
35
|
export interface CommandRunner {
|
|
27
36
|
run(command: string, args: string[], options?: {
|
package/dist/sidebar-state.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface QuotaWindow {
|
|
|
2
2
|
usedPercent: number;
|
|
3
3
|
remainingPercent: number;
|
|
4
4
|
resetsAt?: string;
|
|
5
|
+
checkedAt?: number;
|
|
5
6
|
}
|
|
6
7
|
export interface ScopedQuotaWindow extends QuotaWindow {
|
|
7
8
|
id: string;
|
|
@@ -10,6 +11,7 @@ export interface ScopedQuotaWindow extends QuotaWindow {
|
|
|
10
11
|
modelName: string;
|
|
11
12
|
}
|
|
12
13
|
export interface AccountQuota {
|
|
14
|
+
checkedAt?: number;
|
|
13
15
|
five_hour?: QuotaWindow;
|
|
14
16
|
seven_day?: QuotaWindow;
|
|
15
17
|
scoped?: ScopedQuotaWindow[];
|
|
@@ -36,6 +38,8 @@ export interface SidebarAccountState {
|
|
|
36
38
|
label: string | undefined;
|
|
37
39
|
quota: AccountQuota | null;
|
|
38
40
|
enabled: boolean;
|
|
41
|
+
stateLine?: string;
|
|
42
|
+
quotaDated?: boolean;
|
|
39
43
|
needsReauth: boolean;
|
|
40
44
|
vaultReauth?: boolean;
|
|
41
45
|
vaultServed?: boolean;
|
|
@@ -68,7 +72,10 @@ export interface PrimeSidebarAccountState {
|
|
|
68
72
|
export interface SidebarState {
|
|
69
73
|
main: {
|
|
70
74
|
quota: AccountQuota | null;
|
|
75
|
+
enabled?: boolean;
|
|
71
76
|
tierLabel?: string;
|
|
77
|
+
stateLine?: string;
|
|
78
|
+
quotaDated?: boolean;
|
|
72
79
|
quotaBackedOff?: boolean;
|
|
73
80
|
quotaBackoffUntil?: number;
|
|
74
81
|
refreshBackedOff?: boolean;
|
|
@@ -140,8 +147,9 @@ export declare function resolveActiveAccount(state: SidebarState): {
|
|
|
140
147
|
id: string;
|
|
141
148
|
name: string;
|
|
142
149
|
quota: AccountQuota | null;
|
|
150
|
+
stateLine?: string;
|
|
151
|
+
quotaDated?: boolean;
|
|
143
152
|
};
|
|
144
|
-
export declare function formatScopedQuotaLabel(title: string): string;
|
|
145
153
|
/**
|
|
146
154
|
* Pretty label for a recoverable-refusal source model (Fable 5/5.1 or Opus 5).
|
|
147
155
|
* Falls back to the raw id for unrecognized ids so the sidebar never goes
|
|
@@ -155,12 +163,22 @@ export declare function formatPrimeAccountValue(account: PrimeSidebarAccountStat
|
|
|
155
163
|
hasError: boolean;
|
|
156
164
|
};
|
|
157
165
|
export declare function getFableRecoverySummary(state: SidebarState, sessionId: string): string | undefined;
|
|
158
|
-
|
|
166
|
+
/** Keep full shared names when they fit; truncate only to preserve row columns. */
|
|
167
|
+
export declare function formatQuotaRowLabel(name: string, width?: number): string;
|
|
168
|
+
export declare function getCollapsedQuotaSummary(quota: AccountQuota | null, now?: number): {
|
|
159
169
|
fiveHourUsedPercent: number | null;
|
|
160
170
|
sevenDayUsedPercent: number | null;
|
|
161
171
|
scopedUsedPercents: number[];
|
|
162
172
|
text: string | null;
|
|
173
|
+
stale: boolean;
|
|
163
174
|
};
|
|
175
|
+
export declare function getCollapsedAccounts(state: SidebarState, showFallbacks?: boolean): {
|
|
176
|
+
id: string;
|
|
177
|
+
name: string;
|
|
178
|
+
quota: AccountQuota | null;
|
|
179
|
+
quotaDated: boolean | undefined;
|
|
180
|
+
active: boolean;
|
|
181
|
+
}[];
|
|
164
182
|
export declare const FIVE_HOUR_MS: number;
|
|
165
183
|
export declare const SEVEN_DAY_MS: number;
|
|
166
184
|
export interface QuotaPacing {
|
package/dist/sidebar-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{$ as v,G as a,H as b,I as c,J as d,K as e,L as f,M as g,N as h,O as i,P as j,Q as k,R as l,S as m,T as n,U as o,V as p,W as q,X as r,Y as s,Z as t,_ as u}from"./index-53nnxq39.js";import"./index-f2ne65w4.js";export{i as setSidebarState,k as resolveActiveAccount,c as normalizeSidebarState,a as getSidebarStateFile,h as getSidebarState,f as getInitialSidebarRoutingTestHooks,p as getFableRecoverySummary,r as getCollapsedQuotaSummary,s as getCollapsedAccounts,q as formatQuotaRowLabel,m as formatPrimeTime,n as formatPrimeCost,o as formatPrimeAccountValue,l as formatFallbackModelLabel,j as drainSidebarWrites,v as computeQuotaPacing,d as __setSidebarStateWriteTestHooks,e as __setInitialSidebarRoutingTestHooks,g as __acquireSidebarStateLockForTest,u as SEVEN_DAY_MS,t as FIVE_HOUR_MS,b as DEFAULT_SIDEBAR_STATE};
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BillingLineageFields, type Cache1hMode, type ClaudeCodeIdentity, type ThinkingPrefixMismatchBehavior } from '@cortexkit/anthropic-auth-core';
|
|
1
|
+
import { type BillingLineageFields, type Cache1hMode, type ClaudeCodeIdentity, type ClaudeCodeRequestClass, type ThinkingPrefixMismatchBehavior } from '@cortexkit/anthropic-auth-core';
|
|
2
2
|
import { type OpenCodeEffortMarkerPlan } from './effort-history';
|
|
3
3
|
import { type ServerSideFallbackOutcome } from './server-fallback';
|
|
4
4
|
export declare const NON_STREAMING_DIAGNOSTICS_MAX_BYTES: number;
|
|
@@ -31,6 +31,7 @@ export declare function addFastModeBetaHeader(headers: Headers): Headers;
|
|
|
31
31
|
export declare function setOAuthHeaders(headers: Headers, accessToken: string, options?: {
|
|
32
32
|
body?: Record<string, unknown> | null;
|
|
33
33
|
identity?: ClaudeCodeIdentity;
|
|
34
|
+
requestClass?: ClaudeCodeRequestClass;
|
|
34
35
|
}): Headers;
|
|
35
36
|
/**
|
|
36
37
|
* Add TOOL_PREFIX to tool names in the request body.
|
|
@@ -81,13 +82,6 @@ export type HybridMessageCacheAnchor = {
|
|
|
81
82
|
messageCount: number;
|
|
82
83
|
};
|
|
83
84
|
export declare function extractLatestHybridMessageCacheAnchor(bodyText: string): HybridMessageCacheAnchor | undefined;
|
|
84
|
-
export declare function prepareFableCacheWarmSource(bodyText: string, fableModel?: string): {
|
|
85
|
-
ok: true;
|
|
86
|
-
bodyText: string;
|
|
87
|
-
} | {
|
|
88
|
-
ok: false;
|
|
89
|
-
reason: string;
|
|
90
|
-
};
|
|
91
85
|
/**
|
|
92
86
|
* Rewrite the full request body: sanitize system prompt and prefix tool names.
|
|
93
87
|
*/
|
package/dist/tui-preferences.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./index-
|
|
1
|
+
import"./index-f2ne65w4.js";import{readFileSync as k,watch as C}from"node:fs";import{mkdir as _,readFile as I,rename as E,writeFile as b}from"node:fs/promises";import{homedir as g}from"node:os";import{basename as F,dirname as P,join as N}from"node:path";import{clearTimeout as D,setTimeout as L}from"node:timers";import{applyEdits as T,modify as y,parse as f}from"jsonc-parser";var v="OPENCODE_TUI_PREFERENCES_FILE",h="tui-preferences.jsonc";function A(){let J=process.env[v];if(J)return J;let z=process.env.OPENCODE_CONFIG_DIR||N(process.env.XDG_CONFIG_HOME||N(g(),".config"),"opencode");return N(z,h)}function H(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}async function qq(){try{let J=await I(A(),"utf8"),z=[],q=f(J,z,{allowTrailingComma:!0});if(z.length>0)return{};return H(q)?q:{}}catch{return{}}}var m="anthropic-auth",p=160,R={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 w(J,z){if(typeof J!=="string")return z;return[...J][0]??z}function zq(J){let z=J[m];if(!H(z))return structuredClone(R);let q=R,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:w(Z.barFilledChar,q.appearance.barFilledChar),barEmptyChar:w(Z.barEmptyChar,q.appearance.barEmptyChar),warnThreshold:G,errorThreshold:V}}}var u=-1e5;function Jq(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.
|
package/dist/tui.d.ts
CHANGED
package/dist/v2/activation.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Explicit sign-in to the native Claude account pool creates this OAuth connection. Startup leaves existing OpenCode connections unchanged. */
|
|
2
2
|
export declare const CLAUDE_POOL_LOGIN_METHOD_ID = "native-claude-oauth";
|
|
3
|
+
export declare const CLAUDE_POOL_LOGIN_METHOD_LABEL = "Claude Pro / Max (native account pool)";
|
|
4
|
+
export declare const CLAUDE_POOL_LOGIN_STEP = "In OpenCode, sign in to Anthropic with \"Claude Pro / Max (native account pool)\".";
|
|
3
5
|
/**
|
|
4
6
|
* Connects OpenCode to the Claude accounts held in the vault. It signs in to
|
|
5
7
|
* nothing and stores no local account; only the host's placeholder is written.
|
package/dist/v2/adapter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ClaudeCodeIdentity, TrailingAssistantHistoryError } from '@cortexkit/anthropic-auth-core';
|
|
1
|
+
import { type ClaudeCodeIdentity, type RequestGzipLatch, TrailingAssistantHistoryError } from '@cortexkit/anthropic-auth-core';
|
|
2
2
|
import type { AccountRequest, AttemptOutcome, ChooseAccountInput, HeaderEdits, HostError, LimitSignal, OpenCode2AuthAdapter, RequestScope, Transport } from '@cortexkit/common-auth/opencode2';
|
|
3
3
|
import { EffortMarkerCorrelationError } from '../effort-history';
|
|
4
4
|
import { createStrippedStream, rewriteRequestBody } from '../transform';
|
|
@@ -161,6 +161,11 @@ export interface NativeAnthropicSource<Q, P> {
|
|
|
161
161
|
readonly requestOptions?: (input: NativeAnthropicRequestContext<P>) => Promise<NativeAnthropicBodyOptions> | NativeAnthropicBodyOptions;
|
|
162
162
|
/** Rechecks policy after asynchronous rewriting, immediately before dispatch. */
|
|
163
163
|
readonly admitRequest?: (input: NativeAnthropicAttemptContext<P>) => Promise<void> | void;
|
|
164
|
+
/** Observe the admitted OAuth wire body before any relay envelope is added. */
|
|
165
|
+
readonly onRequestPrepared?: (input: NativeAnthropicAttemptContext<P> & {
|
|
166
|
+
readonly url: string;
|
|
167
|
+
readonly bodyText: string;
|
|
168
|
+
}) => Promise<void> | void;
|
|
164
169
|
/** Response observers for an OAuth response. */
|
|
165
170
|
readonly responseOptions?: (input: NativeAnthropicResponseContext<P>) => NativeAnthropicResponseOptions | undefined;
|
|
166
171
|
/** Quota carried by the upstream response headers, read once per response. */
|
|
@@ -206,6 +211,11 @@ export interface NativeAnthropicAdapterDeps<Q, P> {
|
|
|
206
211
|
* ended; the source's work is not cancelled.
|
|
207
212
|
*/
|
|
208
213
|
readonly attemptEndTimeoutMs?: number;
|
|
214
|
+
/**
|
|
215
|
+
* Remembers a rejected gzipped body. Defaults to the latch next to the
|
|
216
|
+
* OpenCode account storage file.
|
|
217
|
+
*/
|
|
218
|
+
readonly requestGzipLatch?: RequestGzipLatch;
|
|
209
219
|
}
|
|
210
220
|
export interface NativeAnthropicAdapter<Q, P> {
|
|
211
221
|
readonly adapter: OpenCode2AuthAdapter<Q, NativeAnthropicAttemptData<P>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CacheKeepSessionRegistry, type NativeAccountRuntime } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
import type { NativeSource } from './source';
|
|
3
|
+
export interface NativeCacheKeepOptions {
|
|
4
|
+
readonly now?: () => number;
|
|
5
|
+
readonly setIntervalImpl?: typeof globalThis.setInterval;
|
|
6
|
+
readonly clearIntervalImpl?: typeof globalThis.clearInterval;
|
|
7
|
+
readonly registryDirectory?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Keep admitted hybrid-cache prefixes warm using fresh native authorization for each send. */
|
|
10
|
+
export declare function createNativeCacheKeep(options: NativeCacheKeepOptions & {
|
|
11
|
+
runtime: NativeAccountRuntime;
|
|
12
|
+
source: NativeSource;
|
|
13
|
+
fetch?: typeof fetch;
|
|
14
|
+
isSubagent?: (sessionID: string) => Promise<boolean>;
|
|
15
|
+
}): {
|
|
16
|
+
track(input: Parameters<NonNullable<NativeSource['onRequestPrepared']>>[0]): Promise<void>;
|
|
17
|
+
registry: CacheKeepSessionRegistry;
|
|
18
|
+
dispose(): Promise<void>;
|
|
19
|
+
};
|
package/dist/v2/menu.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NativeAccountRuntime } from '@cortexkit/anthropic-auth-core';
|
|
1
|
+
import { type CacheKeepSessionRegistry, type NativeAccountRuntime } from '@cortexkit/anthropic-auth-core';
|
|
2
2
|
import type { NativeMenuCapabilities } from './menu-contract';
|
|
3
3
|
import type { NativeSource } from './source';
|
|
4
4
|
export type { NativeMenuCapabilities } from './menu-contract';
|
|
@@ -6,5 +6,6 @@ export type { NativeMenuCapabilities } from './menu-contract';
|
|
|
6
6
|
export declare function createNativeMenuCapabilities(options: {
|
|
7
7
|
readonly runtime: NativeAccountRuntime;
|
|
8
8
|
readonly source: NativeSource;
|
|
9
|
+
readonly cacheKeepRegistry?: CacheKeepSessionRegistry;
|
|
9
10
|
readonly start: (sessionID: string, text: string) => Promise<void>;
|
|
10
11
|
}): NativeMenuCapabilities;
|