@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-compiled/tui.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import { createEffect, createSignal, For, onCleanup, Show } from "opentui:runtim
|
|
|
16
16
|
import { createRpcClient } from "./rpc/rpc-client.js";
|
|
17
17
|
import { getRpcDir } from "./rpc/rpc-dir.js";
|
|
18
18
|
import { computeQuotaPacing, DEFAULT_SIDEBAR_STATE, FIVE_HOUR_MS, formatPrimeAccountValue, formatScopedQuotaLabel, getCollapsedQuotaSummary, getFableRecoverySummary, getSidebarState, resolveActiveAccount, SEVEN_DAY_MS } from "./sidebar-state.js";
|
|
19
|
-
import { openCommandDialog } from "./tui/command-dialogs.js";
|
|
19
|
+
import { openCommandDialog, openNativeMenuDialog } from "./tui/command-dialogs.js";
|
|
20
20
|
import { computeEffectiveOrder, DEFAULT_SLOT_ORDER, PLUGIN_KEY, queueTuiPreferenceUpdate, readTuiPreferencesFile, resolveAnthropicAuthPrefs, watchTuiPreferences } from "./tui-preferences.js";
|
|
21
21
|
const RPC_POLL_MS = 500;
|
|
22
22
|
let rpcPollStarted = false;
|
|
@@ -1153,17 +1153,35 @@ const tui = async api => {
|
|
|
1153
1153
|
if (!rpcPollStarted) {
|
|
1154
1154
|
rpcPollStarted = true;
|
|
1155
1155
|
const rpcClient = createRpcClient(getRpcDir(api.state.path.directory ?? ''), process.pid);
|
|
1156
|
-
|
|
1156
|
+
const lastNotificationIdBySession = new Map();
|
|
1157
1157
|
let rpcInFlight = false;
|
|
1158
|
-
|
|
1159
|
-
if (rpcInFlight) return;
|
|
1158
|
+
const currentSessionId = () => {
|
|
1160
1159
|
const current = api.route.current;
|
|
1161
1160
|
const resolved = typeof current === 'function' ? current() : current;
|
|
1162
|
-
|
|
1161
|
+
return resolved?.params?.sessionID;
|
|
1162
|
+
};
|
|
1163
|
+
setInterval(() => {
|
|
1164
|
+
if (rpcInFlight) return;
|
|
1165
|
+
const sessionId = currentSessionId();
|
|
1166
|
+
if (!sessionId) return;
|
|
1163
1167
|
rpcInFlight = true;
|
|
1164
|
-
void rpcClient.pending(
|
|
1168
|
+
void rpcClient.pending(lastNotificationIdBySession.get(sessionId) ?? 0, sessionId).then(messages => {
|
|
1169
|
+
// A route change while draining must not open a different session's
|
|
1170
|
+
// dialog or acknowledge notices that were never displayed.
|
|
1171
|
+
if (currentSessionId() !== sessionId) return;
|
|
1165
1172
|
for (const message of [...messages].sort((a, b) => a.id - b.id)) {
|
|
1166
|
-
|
|
1173
|
+
if (message.sessionId !== sessionId) continue;
|
|
1174
|
+
lastNotificationIdBySession.set(sessionId, Math.max(lastNotificationIdBySession.get(sessionId) ?? 0, message.id));
|
|
1175
|
+
if (message.type === 'open-menu') {
|
|
1176
|
+
openNativeMenuDialog(api, message.payload, request => {
|
|
1177
|
+
if (currentSessionId() !== sessionId) return Promise.reject(new Error('Menu session changed'));
|
|
1178
|
+
return rpcClient.applyMenu({
|
|
1179
|
+
...request,
|
|
1180
|
+
sessionId
|
|
1181
|
+
});
|
|
1182
|
+
}, () => currentSessionId() === sessionId);
|
|
1183
|
+
continue;
|
|
1184
|
+
}
|
|
1167
1185
|
if (message.payload.command === 'claude-quota') {
|
|
1168
1186
|
api.ui.dialog.setSize('xlarge');
|
|
1169
1187
|
api.ui.dialog.replace(() => _$createComponent(QuotaDialogContent, {
|
package/src/tui.tsx
CHANGED
|
@@ -34,7 +34,10 @@ import {
|
|
|
34
34
|
SEVEN_DAY_MS,
|
|
35
35
|
type SidebarState,
|
|
36
36
|
} from './sidebar-state.js'
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
openCommandDialog,
|
|
39
|
+
openNativeMenuDialog,
|
|
40
|
+
} from './tui/command-dialogs.js'
|
|
38
41
|
import {
|
|
39
42
|
type AnthropicAuthTuiPrefs,
|
|
40
43
|
type AppearancePrefs,
|
|
@@ -920,22 +923,48 @@ const tui: TuiPlugin = async (api) => {
|
|
|
920
923
|
getRpcDir(api.state.path.directory ?? ''),
|
|
921
924
|
process.pid,
|
|
922
925
|
)
|
|
923
|
-
|
|
926
|
+
const lastNotificationIdBySession = new Map<string, number>()
|
|
924
927
|
let rpcInFlight = false
|
|
925
|
-
|
|
926
|
-
if (rpcInFlight) return
|
|
928
|
+
const currentSessionId = () => {
|
|
927
929
|
const current = (api.route as { current?: unknown }).current
|
|
928
930
|
const resolved =
|
|
929
931
|
typeof current === 'function' ? (current as () => unknown)() : current
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
932
|
+
return (resolved as { params?: { sessionID?: string } } | undefined)
|
|
933
|
+
?.params?.sessionID
|
|
934
|
+
}
|
|
935
|
+
setInterval(() => {
|
|
936
|
+
if (rpcInFlight) return
|
|
937
|
+
const sessionId = currentSessionId()
|
|
938
|
+
if (!sessionId) return
|
|
933
939
|
rpcInFlight = true
|
|
934
940
|
void rpcClient
|
|
935
|
-
.pending(
|
|
941
|
+
.pending(lastNotificationIdBySession.get(sessionId) ?? 0, sessionId)
|
|
936
942
|
.then((messages) => {
|
|
943
|
+
// A route change while draining must not open a different session's
|
|
944
|
+
// dialog or acknowledge notices that were never displayed.
|
|
945
|
+
if (currentSessionId() !== sessionId) return
|
|
937
946
|
for (const message of [...messages].sort((a, b) => a.id - b.id)) {
|
|
938
|
-
|
|
947
|
+
if (message.sessionId !== sessionId) continue
|
|
948
|
+
lastNotificationIdBySession.set(
|
|
949
|
+
sessionId,
|
|
950
|
+
Math.max(
|
|
951
|
+
lastNotificationIdBySession.get(sessionId) ?? 0,
|
|
952
|
+
message.id,
|
|
953
|
+
),
|
|
954
|
+
)
|
|
955
|
+
if (message.type === 'open-menu') {
|
|
956
|
+
openNativeMenuDialog(
|
|
957
|
+
api,
|
|
958
|
+
message.payload,
|
|
959
|
+
(request) => {
|
|
960
|
+
if (currentSessionId() !== sessionId)
|
|
961
|
+
return Promise.reject(new Error('Menu session changed'))
|
|
962
|
+
return rpcClient.applyMenu({ ...request, sessionId })
|
|
963
|
+
},
|
|
964
|
+
() => currentSessionId() === sessionId,
|
|
965
|
+
)
|
|
966
|
+
continue
|
|
967
|
+
}
|
|
939
968
|
if (message.payload.command === 'claude-quota') {
|
|
940
969
|
api.ui.dialog.setSize('xlarge')
|
|
941
970
|
api.ui.dialog.replace(() => (
|
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};
|