@cortexkit/opencode-anthropic-auth 1.9.3 → 1.9.4
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/dist/cli.js +1 -1
- package/dist/index-fvzta6xw.js +410 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/index-68qrf9fn.js +0 -410
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as mj,A as xj,Aa as rj,B as Tj,Ba as Pj,C as q1,Ca as p0,D as qj,Da as sj,E as E1,Ea as aj,F as Ej,Fa as tj,G as Rj,Ga as ej,H as vj,Ha as Oj,I as R1,Ia as zj,J as W1,Ja as jJ,K as Sj,Ka as N1,L as U0,La as JJ,M as v1,Ma as $J,N as Aj,Na as y1,O as fj,P as b0,Pa as VJ,Q as h0,R as X1,Ra as _1,S as kj,Sa as b1,T as yj,Ta as WJ,U as bj,Ua as XJ,V as hj,Va as h1,W as gj,X as G1,Y as B0,Z as F0,_ as g0,a as e1,aa as Z1,b as jj,ba as Xj,c as v0,ca as Gj,d as S0,da as S1,e as Jj,ea as Zj,f as E0,fa as Kj,g as Uj,ga as Yj,h as $j,ha as K1,i as Vj,ia as pj,j as Wj,ja as lj,k as C1,ka as dj,l as Bj,la as ij,m as H1,ma as A1,n as x1,na as uj,o as q,oa as cj,p as e,pa as Y1,q as k0,qa as P1,r as T1,ra as nj,s as Fj,sa as f1,t as Cj,ta as m0,u as h,ua as O1,va as z1,w as y0,wa as D1,x as Hj,xa as oj,y as $1,ya as k1,z as V1,za as I1}from"./index-
|
|
1
|
+
import{$ as mj,A as xj,Aa as rj,B as Tj,Ba as Pj,C as q1,Ca as p0,D as qj,Da as sj,E as E1,Ea as aj,F as Ej,Fa as tj,G as Rj,Ga as ej,H as vj,Ha as Oj,I as R1,Ia as zj,J as W1,Ja as jJ,K as Sj,Ka as N1,L as U0,La as JJ,M as v1,Ma as $J,N as Aj,Na as y1,O as fj,P as b0,Pa as VJ,Q as h0,R as X1,Ra as _1,S as kj,Sa as b1,T as yj,Ta as WJ,U as bj,Ua as XJ,V as hj,Va as h1,W as gj,X as G1,Y as B0,Z as F0,_ as g0,a as e1,aa as Z1,b as jj,ba as Xj,c as v0,ca as Gj,d as S0,da as S1,e as Jj,ea as Zj,f as E0,fa as Kj,g as Uj,ga as Yj,h as $j,ha as K1,i as Vj,ia as pj,j as Wj,ja as lj,k as C1,ka as dj,l as Bj,la as ij,m as H1,ma as A1,n as x1,na as uj,o as q,oa as cj,p as e,pa as Y1,q as k0,qa as P1,r as T1,ra as nj,s as Fj,sa as f1,t as Cj,ta as m0,u as h,ua as O1,va as z1,w as y0,wa as D1,x as Hj,xa as oj,y as $1,ya as k1,z as V1,za as I1}from"./index-fvzta6xw.js";import{Za as GJ}from"./index-9yjbmhf1.js";import"./index-agh52sak.js";import{randomUUID as uJ}from"node:crypto";function M0(j){return typeof j==="object"&&j!==null}function zJ(j){if(Array.isArray(j))return j;if(M0(j)&&Array.isArray(j.data))return j.data;return[]}function DJ(j){if(!M0(j)||!M0(j.info))return;return typeof j.info.role==="string"?j.info.role:void 0}function m1(j){if(!M0(j)||!M0(j.info))return null;let J=j.info,$=M0(J.model)?J.model:void 0,W=typeof J.agent==="string"?J.agent:void 0,V=typeof $?.providerID==="string"?$.providerID:typeof J.providerID==="string"?J.providerID:void 0,z=typeof $?.modelID==="string"?$.modelID:typeof J.modelID==="string"?J.modelID:void 0,M=typeof $?.variant==="string"?$.variant:typeof J.variant==="string"?J.variant:void 0;if(!W&&(!V||!z)&&!M)return null;let S={};if(W)S.agent=W;if(V&&z)S.model={providerID:V,modelID:z};if(M)S.variant=M;return S}function p1(j,J){return{agent:j.agent??J.agent,model:j.model??J.model,variant:j.variant??J.variant}}function l1(j){return Boolean(j.agent&&j.model&&j.variant)}async function d1(j,J){if(!j||!J)return null;let $=j;if(typeof $.session?.messages!=="function")return null;let W=[];try{W=zJ(await Promise.resolve($.session.messages({path:{id:J},query:{limit:100}})))}catch{return null}if(W.length===0)return null;let V={};for(let z=W.length-1;z>=0;z--){if(DJ(W[z])!=="assistant")continue;let M=m1(W[z]);if(!M)continue;if(V=p1(V,M),l1(V))return V}for(let z=W.length-1;z>=0;z--){let M=m1(W[z]);if(!M)continue;if(V=p1(V,M),l1(V))return V}if(!V.agent&&!V.model&&!V.variant)return null;return V}function i1(j,J){let $=new Map,W=0,V=0,z=0,M=0,S=0,r=(y)=>{let f=performance.now(),n=j(y);return S+=performance.now()-f,z++,n};return{call:(y)=>{if(!J.enabled())return r(y);let f=$.get(y);if(f!==void 0)return V++,$.delete(y),$.set(y,f),f;let n=r(y),a=y.length+n.length;if(a>J.maxBytes)return n;$.set(y,n),W+=a;while(W>J.maxBytes&&$.size>1){let d=$.keys().next().value,W0=$.get(d)??"";$.delete(d),W-=d.length+W0.length,M++}return n},stats:()=>({hits:V,misses:z,evictions:M,entries:$.size,cacheBytes:W,computeMsTotal:S})}}function u1(j){return`${e1}${j.charAt(0).toUpperCase()}${j.slice(1)}`}function Dj(j){if(j==="StructuredOutput")return j;return`${j.charAt(0).toLowerCase()}${j.slice(1)}`}var IJ=new Set(["callgraph","conflicts","delete","import","inspect","move","navigate","outline","refactor","safety","search","transform","zoom"]);function c1(j){let J=Dj(j);if(J.startsWith("aft_"))return J;if(IJ.has(J))return`aft_${J}`;return null}function w1(j,J){let $=new Headers;if(j instanceof Request)j.headers.forEach((V,z)=>{$.set(z,V)});let W=J?.headers;if(W){if(W instanceof Headers)W.forEach((V,z)=>{$.set(z,V)});else if(Array.isArray(W))for(let V of W){let[z,M]=V;if(typeof M<"u")$.set(z,String(M))}else for(let[V,z]of Object.entries(W))if(typeof z<"u")$.set(V,String(z))}return $}function t0(j){return j.set("anthropic-beta",v0(j.get("anthropic-beta"),[jj])),j}function A0(j,J,$={}){return Kj(j,J,$)}function NJ(j){if(j.tools&&Array.isArray(j.tools))j.tools=j.tools.map((J)=>({...J,name:J.name?u1(J.name):J.name}));if(j.messages&&Array.isArray(j.messages))j.messages=j.messages.map((J)=>{if(J.content&&Array.isArray(J.content))J.content=J.content.map(($)=>{if($.type==="tool_use"&&$.name)return{...$,name:u1($.name)};return $});return J});return JSON.stringify(Yj(j))}function M1(j){return j.replace(/"name"\s*:\s*"(mcp_)?([^"]+)"/g,(J,$,W)=>{if($)return`"name": "${c1(W)??Dj(W)}"`;let V=c1(W);return V?`"name": "${V}"`:J})}function n1(j,J=!1){if(J)return{ready:M1(j),pending:""};let $=j.length,W='"name"',V=Math.max(0,j.length-W.length+1);for(let M=V;M<j.length;M++)if(W.startsWith(j.slice(M))){$=Math.min($,M);break}let z=j.lastIndexOf(W);if(z!==-1){let M=j.slice(z);if(/^"name"\s*(?::\s*(?:"[^"]*)?)?$/.test(M))$=Math.min($,z)}if($<j.length)return{ready:M1(j.slice(0,$)),pending:j.slice($)};return{ready:M1(j),pending:""}}function U1(){if(!process.env.ANTHROPIC_BASE_URL?.trim())return!1;let j=process.env.ANTHROPIC_INSECURE?.trim();return j==="1"||j==="true"}function Ij(j){let J=j?.trim();if(!J)return null;try{let $=new URL(J);if($.protocol!=="http:"&&$.protocol!=="https:"||$.username||$.password)return null;return $}catch{return null}}function _J(){return Ij(process.env.ANTHROPIC_BASE_URL)}function B1(j,J={}){let $=null;try{if(typeof j==="string"||j instanceof URL)$=new URL(j.toString());else if(j instanceof Request)$=new URL(j.url)}catch{$=null}if(!$)return{input:j,url:null};let W=$.href,V=J.baseURL?Ij(J.baseURL):_J();if(V){if($.protocol=V.protocol,$.host=V.host,J.baseURL)$.pathname=`${V.pathname.replace(/\/$/,"")}${$.pathname}`}if($.pathname.endsWith("/v1/messages")&&!$.searchParams.has("beta"))$.searchParams.set("beta","true");if($.href===W)return{input:j,url:$};return{input:j instanceof Request?new Request($.toString(),j):$,url:$}}function LJ(j){let W=j.split(/\n\n+/).filter((V)=>{if(V.includes(Jj))return!1;for(let z of Vj)if(V.includes(z))return!1;return!0}).join(`
|
|
2
2
|
|
|
3
3
|
`);for(let V of Wj)W=W.replace(V.match,V.replacement);return W.trim()}var QJ=8388608;function MJ(){return process.env.OPENCODE_ANTHROPIC_AUTH_MEMO!=="0"}var wJ=i1(LJ,{maxBytes:QJ,enabled:MJ});function o0(j){return wJ.call(j)}function g(j){return j!=null&&typeof j==="object"&&!Array.isArray(j)}function UJ(j){let J={type:"text",text:E0};if(j==null)return[J];if(typeof j==="string"){let W=o0(j);if(W===E0)return[J];return[J,{type:"text",text:W}]}if(g(j)){let W=typeof j.type==="string"?j.type:"text",V=typeof j.text==="string"?j.text:"";return[J,{...j,type:W,text:o0(V)}]}if(!Array.isArray(j))return[J];let $=j.map((W)=>{if(typeof W==="string")return{type:"text",text:o0(W)};if(g(W)&&W.type==="text"&&typeof W.text==="string")return{...W,type:"text",text:o0(W.text)};return{type:"text",text:String(W)}});if($[0]?.text===E0)return $;return[J,...$]}var Nj={type:"ephemeral",ttl:"1h"},BJ=20;function FJ(j){if(g(j.cache_control))return j.cache_control;if(g(j.cacheControl))return j.cacheControl;return null}function R0(j,J){if(!g(j))return!1;return delete j.cacheControl,j.cache_control=J?{...Nj}:{type:"ephemeral"},!0}function o1(j){if(!g(j))return;delete j.cache_control,delete j.cacheControl}function CJ(j){if(Array.isArray(j))return j;if(typeof j==="string")return[{type:"text",text:j}];return null}function r0(j,J){if(!g(j))return;let $=FJ(j);if($?.type!=="ephemeral")return;if(J)$.ttl="1h";else delete $.ttl}function r1(j,J){if(Array.isArray(j.system))for(let $ of j.system)r0($,J);else r0(j.system,J);if(!Array.isArray(j.messages))return;for(let $ of j.messages)if(r0($,J),g($)&&Array.isArray($.content))for(let W of $.content)r0(W,J)}function HJ(j,J){if(Array.isArray(j.system))for(let $ of j.system)J($);else J(j.system);if(!Array.isArray(j.messages))return;for(let $ of j.messages)if(J($),g($)&&Array.isArray($.content))for(let W of $.content)J(W)}function _j(j){o1(j),HJ(j,o1)}function xJ(j){_j(j),j.cache_control={...Nj}}function TJ(j){return g(j)&&j.type!=="thinking"&&j.type!=="redacted_thinking"}function e0(j){let J=CJ(j.content);if(!J?.length)return;let $=J.filter(TJ);if(!$.length)return;return{content:J,cacheableBlocks:$}}function qJ(j){if(!g(j))return!1;let J=e0(j);if(!J)return!1;return j.content=J.content,R0(J.cacheableBlocks[0],!0)}function EJ(j){if(!g(j))return!1;let J=e0(j);if(!J||J.cacheableBlocks.length<2)return!1;return j.content=J.content,R0(J.cacheableBlocks[1],!0)}function s0(j){if(!g(j))return!1;let J=e0(j);if(!J)return!1;let $=J.cacheableBlocks[J.cacheableBlocks.length-1];return j.content=J.content,R0($,!0)}function RJ(j){if(!g(j))return!1;return(e0(j)?.cacheableBlocks.length??0)>1}function vJ(j){if(!g(j))return 0;let J=j.content;if(Array.isArray(J))return J.length;if(J==null)return 0;return 1}function SJ(j){let J=[],$=0;return j.forEach((W,V)=>{let z=vJ(W);if(g(W)&&W.role==="user"&&z>0)J.push({index:V,blockPosition:$+z-1});$+=z}),J}function AJ(j){let J=SJ(j),$=[...J].reverse().find((M)=>M.index>1);if(!$)return{latest:void 0,bridge:void 0};let W=[...J].reverse().find((M)=>M.index<$.index),V=W?$.blockPosition-W.blockPosition+1:0,z=W&&W.index>1&&V>BJ?W:void 0;return{latest:$,bridge:z}}function s1(j){if(Array.isArray(j.system)){let J=j.system.findIndex((V)=>g(V)&&V.text===E0),$=j.system.slice(J>=0?J+1:0).filter(g),W=$[$.length-1];R0(W,!0)}else R0(j.system,!0)}function fJ(j){if(_j(j),!Array.isArray(j.messages)){s1(j);return}let{latest:J,bridge:$}=AJ(j.messages);if(!$)s1(j);if(RJ(j.messages[0]))qJ(j.messages[0]),EJ(j.messages[0]);else s0(j.messages[0]),s0(j.messages[1]);if($)s0(j.messages[$.index]);if(J)s0(j.messages[J.index])}function kJ(j){if(!Array.isArray(j.messages))return 0;let J=0;return j.messages=j.messages.filter(($)=>{if(!g($)||!Array.isArray($.content))return!0;if($.role!=="assistant")return!0;let W=$.content.filter((V)=>{if(!g(V)||V.type!=="thinking")return!0;if(!zj(V.signature))return!0;return J+=1,!1});if(W.length===$.content.length)return!0;return $.content=W,W.length>0}),J}function yJ(j){if(!Oj(j.model))return null;let J=Object.hasOwn(j,"thinking");return j.thinking={...Pj},{replacedExisting:J}}function bJ(j,J){if(!J.enabled){r1(j,!1),delete j.cache_control,delete j.cacheControl;return}if(J.mode==="automatic"){xJ(j);return}if(J.mode==="hybrid"){fJ(j);return}r1(j,!0),delete j.cacheControl}function hJ(j){if(!Array.isArray(j.messages))return;while(j.messages.length){let J=j.messages[j.messages.length-1];if(!g(J)||J.role!=="assistant")break;j.messages.pop()}}function v(){return performance.now()}function J0(j){return Math.round(j*10)/10}function a1(j){let J=0,$=0,W=0,V=Array.isArray(j.messages)?j.messages:[];J=V.length;for(let z of V){if(!z||typeof z!=="object")continue;let M=z.content;if(!Array.isArray(M))continue;$+=M.length;for(let S of M)if(S&&typeof S==="object"&&S.type==="tool_use")W++}return{messageCount:J,contentBlockCount:$,toolDefinitionCount:Array.isArray(j.tools)?j.tools.length:0,toolUseCount:W,systemBlockCount:Array.isArray(j.system)?j.system.length:0}}async function F1(j,J={}){try{let $=v(),W=JSON.parse(j);J.perf?.("parse",{ms:J0(v()-$),inputBytes:j.length,...a1(W)});let V=v(),z=Array.isArray(W.messages)?W.messages.length:void 0;hJ(W);let M=Array.isArray(W.messages)?W.messages.length:void 0;J.perf?.("strip_trailing_assistant",{ms:J0(v()-V),removedMessages:typeof z==="number"&&typeof M==="number"?z-M:void 0});let S=v(),r=kJ(W),u=yJ(W);J.perf?.("model_normalize",{ms:J0(v()-S),model:typeof W.model==="string"?W.model:void 0,fableMythosThinkingDisplay:u?"summarized":void 0,replacedFableMythosThinking:u?.replacedExisting??!1,removedNonAnthropicThinking:r,hasOutputConfig:Object.hasOwn(W,"output_config")});let j0=v(),y=Array.isArray(W.messages)&&W.messages.some((H0)=>H0.role==="user")?Gj(W.messages,void 0,$j):null;J.perf?.("billing_header",{ms:J0(v()-j0),hasBillingHeader:Boolean(y)});let f=v();if(W.system=UJ(W.system),J.perf?.("system_identity",{ms:J0(v()-f),systemBlockCount:Array.isArray(W.system)?W.system.length:0}),y&&Array.isArray(W.system))W.system.unshift({type:"text",text:y});let n=v();if(bJ(W,{enabled:J.cache1hEnabled??!1,mode:J.cache1hMode??"explicit"}),J.perf?.("cache_strategy",{ms:J0(v()-n),enabled:J.cache1hEnabled??!1,mode:J.cache1hMode??"explicit"}),J.fastModeEnabled&&S0(W.model))W.speed="fast";else if(W.speed==="fast")delete W.speed;let a=v();if(J.identity)Zj(W,J.identity);J.perf?.("metadata",{ms:J0(v()-a),hasAccountUuid:Boolean(J.identity?.accountUuid)});let d=v(),W0=NJ(W);J.perf?.("prefix_tools_stringify",{ms:J0(v()-d),outputBytesBeforeSign:W0.length,...a1(W)});let C0=v(),$0=await Xj(W0);return J.perf?.("cch_sign",{ms:J0(v()-C0),outputBytes:$0.length}),$0}catch{return j}}var gJ=new TextEncoder;function mJ(){return{pending:"",events:0,parseErrors:0,eventCounts:{},typeCounts:{},deltaTypeCounts:{},contentBlockTypeCounts:{},textDeltaBytes:0,thinkingDeltaBytes:0,inputJsonDeltaBytes:0,signatureDeltaBytes:0,redactedThinkingBytes:0}}function a0(j,J){if(!J)return;j[J]=(j[J]??0)+1}function z0(j){return gJ.encode(j).byteLength}function w0(j){return j&&typeof j==="object"&&!Array.isArray(j)?j:void 0}function G0(j,J){let $=j?.[J];return typeof $==="string"?$:void 0}function pJ(j,J){let $=j?.[J];return typeof $==="number"?$:void 0}function lJ(j){if(!j.trim())return null;let J,$=[];for(let y of j.split(/\r?\n/)){if(y.startsWith("event:")){J=y.slice(6).trim();continue}if(y.startsWith("data:")){let f=y.slice(5);$.push(f.startsWith(" ")?f.slice(1):f)}}let W=$.join(`
|
|
4
4
|
`),V={event:J,rawBytes:z0(j),dataBytes:z0(W)};if(!W||W==="[DONE]")return V.type=W==="[DONE]"?"done":void 0,V.event??=V.type,V;let z;try{z=JSON.parse(W)}catch{return V}let M=w0(z),S=w0(M?.delta),r=w0(M?.content_block),u=w0(M?.message),j0=w0(M?.usage)??w0(u?.usage);if(V.type=G0(M,"type"),V.event??=V.type,V.index=pJ(M,"index"),V.contentBlockType=G0(r,"type"),V.deltaType=G0(S,"type"),V.stopReason=G0(M,"stop_reason"),V.deltaType==="text_delta")V.textDeltaBytes=z0(G0(S,"text")??"");if(V.deltaType==="thinking_delta")V.thinkingDeltaBytes=z0(G0(S,"thinking")??"");if(V.deltaType==="input_json_delta")V.inputJsonDeltaBytes=z0(G0(S,"partial_json")??"");if(V.deltaType==="signature_delta")V.signatureDeltaBytes=z0(G0(S,"signature")??"");if(V.contentBlockType==="redacted_thinking")V.redactedThinkingBytes=z0(G0(r,"data")??"");if(j0)V.stopReason??=G0(u,"stop_reason");return V}function dJ(j){let J=j.indexOf(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/opencode-anthropic-auth",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@opencode-ai/plugin": "*"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@cortexkit/anthropic-auth-core": "1.9.
|
|
59
|
+
"@cortexkit/anthropic-auth-core": "1.9.4",
|
|
60
60
|
"@opentui/core": ">=0.4.0",
|
|
61
61
|
"@opentui/solid": ">=0.4.0",
|
|
62
62
|
"jsonc-parser": "^3.3.1",
|