@cortexkit/opencode-openai-auth 0.6.5 → 0.7.1
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/config.d.ts +13 -1
- package/dist/core/oauth.d.ts +1 -1
- package/dist/core/reset-credits.d.ts +5 -3
- package/dist/{index-7tsnfb8g.js → index-9jpc8yct.js} +1 -1
- package/dist/index-nrvjr97q.js +3 -0
- package/dist/{index-00rp531h.js → index-qaggaze1.js} +1 -1
- package/dist/{index-zbpt7v1a.js → index-sdcpzbnk.js} +1 -1
- package/dist/{index-kmy1bsj7.js → index-zf3axndm.js} +5 -5
- package/dist/{index-4agbg1ec.js → index-zg1x8sty.js} +1 -1
- package/dist/{index-x55z0b3y.js → index-zxqb5ydj.js} +1 -1
- package/dist/index.js +79 -79
- package/dist/logger.d.ts +10 -0
- package/dist/{quota-normalize-s27mex1w.js → quota-normalize-dvwtmy7f.js} +1 -1
- package/dist/raw-ws-bun.d.ts +5 -0
- package/dist/raw-ws-node.d.ts +5 -0
- package/dist/response-stream-error.d.ts +8 -10
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/{token-tag90anp.js → token-bvp0y166.js} +1 -1
- package/dist/token-util-jcj7k7pa.js +1 -0
- package/dist/tui-preferences.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/ws.d.ts +2 -0
- package/package.json +1 -1
- package/src/logger.ts +35 -0
- package/src/tui/command-dialogs.tsx +3 -3
- package/src/tui-compiled/logger.ts +35 -0
- package/src/tui-compiled/tui/command-dialogs.tsx +3 -3
- package/dist/index-80gqxa1f.js +0 -3
- package/dist/token-util-by7nbdh3.js +0 -1
package/dist/logger.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
type Level = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
2
2
|
export declare function setLogLevel(l: Level | undefined): void;
|
|
3
3
|
export declare function redact(value: unknown): unknown;
|
|
4
|
+
/**
|
|
5
|
+
* Scrub credential-shaped strings without redacting by key name.
|
|
6
|
+
*
|
|
7
|
+
* For regions where a key names a piece of data rather than holding a secret —
|
|
8
|
+
* a JSON Schema property called `api_key` describes an argument, it does not
|
|
9
|
+
* carry one — replacing the node by name destroys the structure while removing
|
|
10
|
+
* nothing sensitive. A credential pasted into a description is still caught,
|
|
11
|
+
* because that is a string.
|
|
12
|
+
*/
|
|
13
|
+
export declare function redactStrings(value: unknown): unknown;
|
|
4
14
|
export declare function createLogger(channel: string): {
|
|
5
15
|
error: (m: string, d?: unknown) => void;
|
|
6
16
|
warn: (m: string, d?: unknown) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a,d as b,e as c,f as d,g as e}from"./index-87145jkw.js";import"./index-
|
|
1
|
+
import{c as a,d as b,e as c,f as d,g as e}from"./index-87145jkw.js";import"./index-zxqb5ydj.js";export{a as toResetIso,d as normalizeWsFrame,e as normalizeWham,b as normalizeQuotaHeaders,c as isCompleteQuotaHeaderFrame};
|
package/dist/raw-ws-bun.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export declare class RawWebSocket {
|
|
|
19
19
|
once?: boolean;
|
|
20
20
|
}): void;
|
|
21
21
|
removeEventListener(type: string, fn: Listener): void;
|
|
22
|
+
/** Close code and reason from the peer's close frame, if one arrived. */
|
|
23
|
+
private peerClose;
|
|
24
|
+
private closeEmitted;
|
|
25
|
+
/** Emit at most one close event, so the first reported code is the one kept. */
|
|
26
|
+
private emitClose;
|
|
22
27
|
private emit;
|
|
23
28
|
private connect;
|
|
24
29
|
private onData;
|
package/dist/raw-ws-node.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export declare class RawWebSocket {
|
|
|
18
18
|
once?: boolean;
|
|
19
19
|
}): void;
|
|
20
20
|
removeEventListener(type: string, fn: Listener): void;
|
|
21
|
+
/** Close code and reason from the peer's close frame, if one arrived. */
|
|
22
|
+
private peerClose;
|
|
23
|
+
private closeEmitted;
|
|
24
|
+
/** Emit at most one close event, so the first reported code is the one kept. */
|
|
25
|
+
private emitClose;
|
|
21
26
|
private emit;
|
|
22
27
|
private connect;
|
|
23
28
|
private onData;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { APICallError } from 'ai';
|
|
2
|
-
/**
|
|
3
|
-
* Retryable stream-level provider failure.
|
|
4
|
-
*
|
|
5
|
-
* OpenCode's retry loop recognizes AI SDK APICallError instances and converts
|
|
6
|
-
* retryable ones into SessionRetry attempts. A plain plugin-local Error with
|
|
7
|
-
* the same name as OpenCode's internal ProviderResponseStreamError does not
|
|
8
|
-
* pass that instanceof/marker check across package boundaries, so websocket
|
|
9
|
-
* transport failures must surface as APICallError.
|
|
10
|
-
*/
|
|
11
2
|
export declare class ResponseStreamError extends APICallError {
|
|
12
3
|
readonly name = "ProviderResponseStreamError";
|
|
13
|
-
|
|
4
|
+
/**
|
|
5
|
+
* `retryable` defaults to true because most stream failures are transient.
|
|
6
|
+
* Pass false for a failure the same request will hit again — resending then
|
|
7
|
+
* only repeats the cost and the wait.
|
|
8
|
+
*/
|
|
9
|
+
constructor(message: string, options?: ErrorOptions & {
|
|
10
|
+
retryable?: boolean;
|
|
11
|
+
});
|
|
14
12
|
}
|
package/dist/rpc/port-file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{xa as a,ya as b,za as c}from"../index-
|
|
1
|
+
import{xa as a,ya as b,za as c}from"../index-qaggaze1.js";import"../index-nrvjr97q.js";import"../index-zxqb5ydj.js";export{a as writePortFile,b as sweepRpcState,c as discoverPortFile};
|
package/dist/rpc/rpc-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{za as c}from"../index-
|
|
1
|
+
import{za as c}from"../index-qaggaze1.js";import"../index-nrvjr97q.js";import"../index-zxqb5ydj.js";var y=2000;async function p(n,r,s,o,i,e=y){let t=await c(n,r);if(s?.(t),!t)return null;let l=new AbortController,u=setTimeout(()=>l.abort(),e);try{let a=await fetch(`http://127.0.0.1:${t.port}/rpc/${o}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t.token}`},body:JSON.stringify(i),signal:l.signal});if(!a.ok)return null;return await a.json()}catch{return null}finally{clearTimeout(u)}}function m(n,r,s){let o=!1,i=(e)=>{if(o)return;o=!0,s?.(e)};return{async pending(e,t){return(await p(n,r,i,"pending-notifications",{lastReceivedId:e,sessionId:t}))?.messages??[]},async apply(e,t){return await p(n,r,i,"apply",{...e},t)??{text:"apply failed",knobs:{}}}}}export{m as createRpcClient,y as DEFAULT_RPC_TIMEOUT_MS};
|
package/dist/rpc/rpc-dir.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ea as a,Fa as b,Ga as c}from"../index-zg1x8sty.js";import"../index-zxqb5ydj.js";export{a as tmpdir,c as resolveRpcDir,b as getRpcDir};
|
package/dist/sidebar-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as i,T as a,U as b,V as c,W as d,X as e,Y as f,Z as g,_ as h,aa as j,ba as k,ca as l,da as m,ea as n,fa as o,ga as p,ha as q,ia as r,ja as s,ka as t,la as u,ma as v,na as w,oa as x,pa as y,qa as z,ra as A,sa as B,ta as C}from"./index-
|
|
1
|
+
import{$ as i,T as a,U as b,V as c,W as d,X as e,Y as f,Z as g,_ as h,aa as j,ba as k,ca as l,da as m,ea as n,fa as o,ga as p,ha as q,ia as r,ja as s,ka as t,la as u,ma as v,na as w,oa as x,pa as y,qa as z,ra as A,sa as B,ta as C}from"./index-sdcpzbnk.js";import"./index-8f1200qx.js";import"./index-nrvjr97q.js";import"./index-zxqb5ydj.js";export{u as upsertSidebarActiveRouting,s as setSidebarState,t as setSidebarMachineState,v as setSidebarLegacyRouting,x as resolveSidebarStickyAssignment,o as resolveSessionStickyAccount,p as resolveSessionSidebarRouting,A as resolveActiveAccount,w as removeSidebarActiveRouting,r as pruneStickyAssignments,q as pruneActiveRouting,h as normalizeSidebarState,l as isUsableRoutingEntry,n as isQuotaExhausted,e as hashSidebarSessionId,f as getSidebarStateFile,i as getSidebarState,b as getPresentQuotaWindows,B as getCollapsedQuotaSummary,a as formatWindowLabel,m as exhaustedQuotaResetAt,z as drainSidebarWrites,C as computeQuotaPacing,y as clearSidebarStickyAssignment,d as STICKY_ASSIGNMENT_MAX_ENTRIES,c as STICKY_ASSIGNMENT_MAX_AGE_MS,g as DEFAULT_SIDEBAR_STATE,k as ACTIVE_ROUTING_MAX_ENTRIES,j as ACTIVE_ROUTING_MAX_AGE_MS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as U,b as V}from"./index-
|
|
1
|
+
import{a as U,b as V}from"./index-9jpc8yct.js";import{Ia as R}from"./index-zxqb5ydj.js";var E=R((M,Q)=>{var{defineProperty:H,getOwnPropertyDescriptor:W,getOwnPropertyNames:X}=Object,Y=Object.prototype.hasOwnProperty,Z=(z,q)=>{for(var B in q)H(z,B,{get:q[B],enumerable:!0})},$=(z,q,B,F)=>{if(q&&typeof q==="object"||typeof q==="function"){for(let v of X(q))if(!Y.call(z,v)&&v!==B)H(z,v,{get:()=>q[v],enumerable:!(F=W(q,v))||F.enumerable})}return z},A=(z)=>$(H({},"__esModule",{value:!0}),z),L={};Z(L,{refreshToken:()=>D});Q.exports=A(L);var K=U(),G=V();async function D(z){let q=z?.project,B=z?.team;if(!q&&!B){let v=(0,G.findProjectInfo)();q=v.projectId,B=v.teamId}else if(!q||!B){let v=(0,G.findProjectInfo)();q=q??v.projectId,B=B??v.teamId}if(!q)throw new K.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let F=(0,G.loadToken)(q);if(!F||(0,G.isExpired)((0,G.getTokenPayload)(F.token),z?.expirationBufferMs)){let v=await(0,G.getVercelToken)({expirationBufferMs:z?.expirationBufferMs});if(F=await(0,G.getVercelOidcToken)(v,q,B),!F)throw new K.VercelOidcTokenError("Failed to refresh OIDC token");(0,G.saveToken)(F,q)}process.env.VERCEL_OIDC_TOKEN=F.token;return}});export default E();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a}from"./index-9jpc8yct.js";import"./index-zxqb5ydj.js";export default a();
|
package/dist/tui-preferences.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ha as P,Ia as C,Ka as _}from"./index-zxqb5ydj.js";var g=C((T,L)=>{(function(Q){if(typeof L==="object"&&typeof L.exports==="object"){var J=Q(_,T);if(J!==void 0)L.exports=J}else if(typeof define==="function"&&define.amd)define(["require","exports","./impl/format","./impl/edit","./impl/scanner","./impl/parser"],Q)})(function(Q,J){Object.defineProperty(J,"__esModule",{value:!0}),J.applyEdits=J.modify=J.format=J.printParseErrorCode=J.ParseErrorCode=J.stripComments=J.visit=J.getNodeValue=J.getNodePath=J.findNodeAtOffset=J.findNodeAtLocation=J.parseTree=J.parse=J.getLocation=J.SyntaxKind=J.ScanError=J.createScanner=void 0;let X=Q("./impl/format"),Z=Q("./impl/edit"),G=Q("./impl/scanner"),$=Q("./impl/parser");J.createScanner=G.createScanner;var W;(function(z){z[z.None=0]="None",z[z.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",z[z.UnexpectedEndOfString=2]="UnexpectedEndOfString",z[z.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",z[z.InvalidUnicode=4]="InvalidUnicode",z[z.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",z[z.InvalidCharacter=6]="InvalidCharacter"})(W||(J.ScanError=W={}));var H;(function(z){z[z.OpenBraceToken=1]="OpenBraceToken",z[z.CloseBraceToken=2]="CloseBraceToken",z[z.OpenBracketToken=3]="OpenBracketToken",z[z.CloseBracketToken=4]="CloseBracketToken",z[z.CommaToken=5]="CommaToken",z[z.ColonToken=6]="ColonToken",z[z.NullKeyword=7]="NullKeyword",z[z.TrueKeyword=8]="TrueKeyword",z[z.FalseKeyword=9]="FalseKeyword",z[z.StringLiteral=10]="StringLiteral",z[z.NumericLiteral=11]="NumericLiteral",z[z.LineCommentTrivia=12]="LineCommentTrivia",z[z.BlockCommentTrivia=13]="BlockCommentTrivia",z[z.LineBreakTrivia=14]="LineBreakTrivia",z[z.Trivia=15]="Trivia",z[z.Unknown=16]="Unknown",z[z.EOF=17]="EOF"})(H||(J.SyntaxKind=H={})),J.getLocation=$.getLocation,J.parse=$.parse,J.parseTree=$.parseTree,J.findNodeAtLocation=$.findNodeAtLocation,J.findNodeAtOffset=$.findNodeAtOffset,J.getNodePath=$.getNodePath,J.getNodeValue=$.getNodeValue,J.visit=$.visit,J.stripComments=$.stripComments;var q;(function(z){z[z.InvalidSymbol=1]="InvalidSymbol",z[z.InvalidNumberFormat=2]="InvalidNumberFormat",z[z.PropertyNameExpected=3]="PropertyNameExpected",z[z.ValueExpected=4]="ValueExpected",z[z.ColonExpected=5]="ColonExpected",z[z.CommaExpected=6]="CommaExpected",z[z.CloseBraceExpected=7]="CloseBraceExpected",z[z.CloseBracketExpected=8]="CloseBracketExpected",z[z.EndOfFileExpected=9]="EndOfFileExpected",z[z.InvalidCommentToken=10]="InvalidCommentToken",z[z.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",z[z.UnexpectedEndOfString=12]="UnexpectedEndOfString",z[z.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",z[z.InvalidUnicode=14]="InvalidUnicode",z[z.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",z[z.InvalidCharacter=16]="InvalidCharacter"})(q||(J.ParseErrorCode=q={}));function D(z){switch(z){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}J.printParseErrorCode=D;function m(z,U,j){return X.format(z,U,j)}J.format=m;function f(z,U,j,A){return Z.setProperty(z,U,j,A)}J.modify=f;function u(z,U){let j=U.slice(0).sort((I,Y)=>{let F=I.offset-Y.offset;if(F===0)return I.length-Y.length;return F}),A=z.length;for(let I=j.length-1;I>=0;I--){let Y=j[I];if(Y.offset+Y.length<=A)z=Z.applyEdit(z,Y);else throw Error("Overlapping edit");A=Y.offset}return z}J.applyEdits=u})});var M=P(g(),1);import{watch as K}from"node:fs";import{mkdir as c,readFile as O,rename as y,writeFile as S}from"node:fs/promises";import{homedir as E}from"node:os";import{basename as l,dirname as v,join as k}from"node:path";var p="OPENCODE_TUI_PREFERENCES_FILE",x="tui-preferences.jsonc";function w(){let Q=process.env[p];if(Q)return Q;let J=process.env.OPENCODE_CONFIG_DIR||k(process.env.XDG_CONFIG_HOME||k(E(),".config"),"opencode");return k(J,x)}function N(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}async function Xz(){try{let Q=await O(w(),"utf8"),J=[],X=M.parse(Q,J,{allowTrailingComma:!0});if(J.length>0)return{};return N(X)?X:{}}catch{return{}}}var i="openai-auth",s=160,b={forceToTop:!1,order:s,startCollapsed:!1,rememberCollapsed:!0,collapsed:null,pollMs:1500,refreshDebounceMs:200,header:{label:"OPENAI",showVersion:!0},sections:{quota:!0,fallbackAccounts:!0,routing:!0,health:!0,pacing:!0},appearance:{barWidth:10,barFilledChar:"█",barEmptyChar:"░",warnThreshold:50,errorThreshold:80}};function V(Q,J){return typeof Q==="boolean"?Q:J}function B(Q,J,X,Z){if(typeof Q!=="number"||!Number.isFinite(Q))return J;return Math.min(Math.max(Math.round(Q),X),Z)}function d(Q,J,X){if(typeof Q!=="string"||Q.length===0)return J;return Q.slice(0,X)}function h(Q,J){if(typeof Q!=="string")return J;return[...Q][0]??J}function Zz(Q){let J=Q[i];if(!N(J))return structuredClone(b);let X=b,Z=N(J.header)?J.header:{},G=N(J.sections)?J.sections:{},$=N(J.appearance)?J.appearance:{},W=B($.warnThreshold,X.appearance.warnThreshold,0,99),H=Math.max(B($.errorThreshold,X.appearance.errorThreshold,0,100),Math.min(W+1,100));return{forceToTop:V(J.forceToTop,X.forceToTop),order:B(J.order,X.order,-1e4,1e4),startCollapsed:V(J.startCollapsed,X.startCollapsed),rememberCollapsed:V(J.rememberCollapsed,X.rememberCollapsed),collapsed:typeof J.collapsed==="boolean"?J.collapsed:null,pollMs:B(J.pollMs,X.pollMs,500,30000),refreshDebounceMs:B(J.refreshDebounceMs,X.refreshDebounceMs,50,5000),header:{label:d(Z.label,X.header.label,20),showVersion:V(Z.showVersion,X.header.showVersion)},sections:{quota:V(G.quota,X.sections.quota),fallbackAccounts:V(G.fallbackAccounts,X.sections.fallbackAccounts),routing:V(G.routing,X.sections.routing),health:V(G.health,X.sections.health),pacing:V(G.pacing,X.sections.pacing)},appearance:{barWidth:B($.barWidth,X.appearance.barWidth,4,40),barFilledChar:h($.barFilledChar,X.appearance.barFilledChar),barEmptyChar:h($.barEmptyChar,X.appearance.barEmptyChar),warnThreshold:W,errorThreshold:H}}}var n=-1e5;function $z(Q,J,X){let Z=Q[J];if(!N(Z))return X;if(Z.forceToTop===!0)return n+Object.keys(Q).indexOf(J);return B(Z.order,X,-1e4,1e4)}var t=`// 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/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PackageVersion = "0.
|
|
1
|
+
export declare const PackageVersion = "0.7.1";
|
package/dist/ws.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export declare function toWebSocketUrl(url: string): string;
|
|
|
42
42
|
export declare function normalizeHeaders(headers: HeadersInit | undefined): Record<string, string>;
|
|
43
43
|
export declare function isAbortError(error: unknown): error is DOMException;
|
|
44
44
|
export declare function isUpgradeFailure(error: unknown): boolean;
|
|
45
|
+
export declare function isOversizedFrame(error: unknown): boolean;
|
|
46
|
+
export declare function markOversizedFrame<T extends object>(error: T): T;
|
|
45
47
|
export declare function connectResponsesWebSocket(options: ConnectResponsesWebSocketOptions): Promise<WebSocket>;
|
|
46
48
|
export declare function streamResponsesWebSocket(options: StreamResponsesWebSocketOptions): Response;
|
|
47
49
|
export declare function parseRateLimitSignal(value: unknown): {
|
package/package.json
CHANGED
package/src/logger.ts
CHANGED
|
@@ -56,6 +56,41 @@ const TOKEN_VALUE = /\b(Bearer\s+[\w.-]+|sk-[\w-]+|eyJ[\w.-]+)\b/g
|
|
|
56
56
|
export function redact(value: unknown): unknown {
|
|
57
57
|
return redactInner(value, new WeakSet<object>())
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Scrub credential-shaped strings without redacting by key name.
|
|
62
|
+
*
|
|
63
|
+
* For regions where a key names a piece of data rather than holding a secret —
|
|
64
|
+
* a JSON Schema property called `api_key` describes an argument, it does not
|
|
65
|
+
* carry one — replacing the node by name destroys the structure while removing
|
|
66
|
+
* nothing sensitive. A credential pasted into a description is still caught,
|
|
67
|
+
* because that is a string.
|
|
68
|
+
*/
|
|
69
|
+
export function redactStrings(value: unknown): unknown {
|
|
70
|
+
return redactStringsInner(value, new WeakSet<object>())
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function redactStringsInner(value: unknown, seen: WeakSet<object>): unknown {
|
|
74
|
+
if (typeof value === 'string')
|
|
75
|
+
return value.replace(TOKEN_VALUE, '***REDACTED***')
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
if (seen.has(value)) return '[Circular]'
|
|
78
|
+
seen.add(value)
|
|
79
|
+
const arr = value.map((v) => redactStringsInner(v, seen))
|
|
80
|
+
seen.delete(value)
|
|
81
|
+
return arr
|
|
82
|
+
}
|
|
83
|
+
if (value && typeof value === 'object') {
|
|
84
|
+
if (seen.has(value)) return '[Circular]'
|
|
85
|
+
seen.add(value)
|
|
86
|
+
const out: Record<string, unknown> = {}
|
|
87
|
+
for (const [k, v] of Object.entries(value))
|
|
88
|
+
out[k] = redactStringsInner(v, seen)
|
|
89
|
+
seen.delete(value)
|
|
90
|
+
return out
|
|
91
|
+
}
|
|
92
|
+
return value
|
|
93
|
+
}
|
|
59
94
|
function redactInner(value: unknown, seen: WeakSet<object>): unknown {
|
|
60
95
|
if (typeof value === 'string')
|
|
61
96
|
return value.replace(TOKEN_VALUE, '***REDACTED***')
|
|
@@ -142,7 +142,7 @@ function resetAccountOptions(payload: OpenDialogPayload): ResetDialogOption[] {
|
|
|
142
142
|
account.usedPercent === undefined
|
|
143
143
|
? 'quota unavailable'
|
|
144
144
|
: `${account.usedPercent}%`
|
|
145
|
-
const counts = `${account.applicableAvailableCount
|
|
145
|
+
const counts = `${account.applicableAvailableCount === undefined ? '?' : account.applicableAvailableCount}/${account.availableCount ?? '?'}`
|
|
146
146
|
const status = account.eligible
|
|
147
147
|
? 'eligible'
|
|
148
148
|
: (account.reason ?? 'unavailable')
|
|
@@ -278,12 +278,12 @@ function openResetDialog(
|
|
|
278
278
|
const preview = state.knobs.preview as ResetPreviewKnob | undefined
|
|
279
279
|
const accountKey = preview?.accountKey
|
|
280
280
|
const chatgptAccountId = preview?.chatgptAccountId
|
|
281
|
-
const
|
|
281
|
+
const availableCount = preview?.availableCount ?? 'unknown'
|
|
282
282
|
const DialogConfirm = api.ui.DialogConfirm
|
|
283
283
|
api.ui.dialog.replace(() => (
|
|
284
284
|
<DialogConfirm
|
|
285
285
|
title='Reset quota window'
|
|
286
|
-
message={`${state.text}\n\nThis SPENDS 1 of ${
|
|
286
|
+
message={`${state.text}\n\nThis SPENDS 1 of ${availableCount} reset credits — irreversible.\n\nChoose Reset to continue or Cancel to return.\n\nEnter = Cancel (host default). Press Tab then Enter to Reset.`}
|
|
287
287
|
onConfirm={() => {
|
|
288
288
|
if (!accountKey || !chatgptAccountId) return
|
|
289
289
|
applyAndRender(
|
|
@@ -56,6 +56,41 @@ const TOKEN_VALUE = /\b(Bearer\s+[\w.-]+|sk-[\w-]+|eyJ[\w.-]+)\b/g
|
|
|
56
56
|
export function redact(value: unknown): unknown {
|
|
57
57
|
return redactInner(value, new WeakSet<object>())
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Scrub credential-shaped strings without redacting by key name.
|
|
62
|
+
*
|
|
63
|
+
* For regions where a key names a piece of data rather than holding a secret —
|
|
64
|
+
* a JSON Schema property called `api_key` describes an argument, it does not
|
|
65
|
+
* carry one — replacing the node by name destroys the structure while removing
|
|
66
|
+
* nothing sensitive. A credential pasted into a description is still caught,
|
|
67
|
+
* because that is a string.
|
|
68
|
+
*/
|
|
69
|
+
export function redactStrings(value: unknown): unknown {
|
|
70
|
+
return redactStringsInner(value, new WeakSet<object>())
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function redactStringsInner(value: unknown, seen: WeakSet<object>): unknown {
|
|
74
|
+
if (typeof value === 'string')
|
|
75
|
+
return value.replace(TOKEN_VALUE, '***REDACTED***')
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
if (seen.has(value)) return '[Circular]'
|
|
78
|
+
seen.add(value)
|
|
79
|
+
const arr = value.map((v) => redactStringsInner(v, seen))
|
|
80
|
+
seen.delete(value)
|
|
81
|
+
return arr
|
|
82
|
+
}
|
|
83
|
+
if (value && typeof value === 'object') {
|
|
84
|
+
if (seen.has(value)) return '[Circular]'
|
|
85
|
+
seen.add(value)
|
|
86
|
+
const out: Record<string, unknown> = {}
|
|
87
|
+
for (const [k, v] of Object.entries(value))
|
|
88
|
+
out[k] = redactStringsInner(v, seen)
|
|
89
|
+
seen.delete(value)
|
|
90
|
+
return out
|
|
91
|
+
}
|
|
92
|
+
return value
|
|
93
|
+
}
|
|
59
94
|
function redactInner(value: unknown, seen: WeakSet<object>): unknown {
|
|
60
95
|
if (typeof value === 'string')
|
|
61
96
|
return value.replace(TOKEN_VALUE, '***REDACTED***')
|
|
@@ -66,7 +66,7 @@ function resetAccountOptions(payload) {
|
|
|
66
66
|
const accounts = Array.isArray(payload.knobs.accounts) ? payload.knobs.accounts : [];
|
|
67
67
|
return [...accounts.map(account => {
|
|
68
68
|
const used = account.usedPercent === undefined ? 'quota unavailable' : `${account.usedPercent}%`;
|
|
69
|
-
const counts = `${account.applicableAvailableCount
|
|
69
|
+
const counts = `${account.applicableAvailableCount === undefined ? '?' : account.applicableAvailableCount}/${account.availableCount ?? '?'}`;
|
|
70
70
|
const status = account.eligible ? 'eligible' : account.reason ?? 'unavailable';
|
|
71
71
|
const details = `${used} · ${counts}`;
|
|
72
72
|
const shortDate = account.selectedCreditExpiresAt?.slice(0, 10) ?? 'unknown';
|
|
@@ -167,12 +167,12 @@ function openResetDialog(api, payload, apply) {
|
|
|
167
167
|
const preview = state.knobs.preview;
|
|
168
168
|
const accountKey = preview?.accountKey;
|
|
169
169
|
const chatgptAccountId = preview?.chatgptAccountId;
|
|
170
|
-
const
|
|
170
|
+
const availableCount = preview?.availableCount ?? 'unknown';
|
|
171
171
|
const DialogConfirm = api.ui.DialogConfirm;
|
|
172
172
|
api.ui.dialog.replace(() => _$createComponent(DialogConfirm, {
|
|
173
173
|
title: "Reset quota window",
|
|
174
174
|
get message() {
|
|
175
|
-
return `${state.text}\n\nThis SPENDS 1 of ${
|
|
175
|
+
return `${state.text}\n\nThis SPENDS 1 of ${availableCount} reset credits — irreversible.\n\nChoose Reset to continue or Cancel to return.\n\nEnter = Cancel (host default). Press Tab then Enter to Reset.`;
|
|
176
176
|
},
|
|
177
177
|
onConfirm: () => {
|
|
178
178
|
if (!accountKey || !chatgptAccountId) return;
|
package/dist/index-80gqxa1f.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{appendFileSync as Y,chmodSync as w,existsSync as B,renameSync as N,statSync as C}from"node:fs";import{tmpdir as F}from"node:os";import{join as x}from"node:path";var $={error:0,warn:1,info:2,debug:3,trace:4},A=!1,D=5242880;function X(){return process.env.OPENCODE_OPENAI_AUTH_LOG_FILE??x(F(),"opencode-openai-auth.log")}var G;function k(q){if(q===void 0||q in $)G=q}function I(){if(G)return G;let q=process.env.OPENCODE_OPENAI_AUTH_LOG_LEVEL;if(q&&q in $)return q;return"info"}var K=/^(authorization|x-api-key|cookie|set-cookie|refresh|access|token)$/i;function b(q){if(K.test(q))return!0;let H=q.toLowerCase().replace(/[-_]/g,"");if(H==="chatgptaccountid")return!0;if(H.includes("apikey"))return!0;if(H.endsWith("secret")||H.endsWith("password"))return!0;if(H.endsWith("token")&&!H.endsWith("tokens"))return!0;return!1}var L=/\b(Bearer\s+[\w.-]+|sk-[\w-]+|eyJ[\w.-]+)\b/g;function P(q){return M(q,new WeakSet)}function M(q,H){if(typeof q==="string")return q.replace(L,"***REDACTED***");if(Array.isArray(q)){if(H.has(q))return"[Circular]";H.add(q);let J=q.map((Q)=>M(Q,H));return H.delete(q),J}if(q&&typeof q==="object"){if(H.has(q))return"[Circular]";H.add(q);let J={};for(let[Q,j]of Object.entries(q))J[Q]=b(Q)?"***REDACTED***":M(j,H);return H.delete(q),J}return q}var Z=[],z,_=3;function U(q){try{w(q,384)}catch{}}function g(){try{let q=X();if(!(B(q)&&C(q).size>D))return;for(let J=_-1;J>=1;J--)if(B(`${q}.${J}`)){let Q=`${q}.${J+1}`;N(`${q}.${J}`,Q),U(Q)}let H=`${q}.1`;N(q,H),U(H)}catch{}}function V(){if(!Z.length)return;let q=Z.join("");Z=[];try{g();let H=X();if(B(H))U(H);Y(H,q,{encoding:"utf8",mode:384})}catch{}}function O(){if(!z)z=setTimeout(()=>{z=void 0,V()},500)}if(!A)process.on("exit",V);function p(q){try{return` ${JSON.stringify(P(q))}`}catch{return" [unserializable]"}}function W(q,H,J,Q){if($[H]>$[I()])return;let j=`[${new Date().toISOString()}] ${H.toUpperCase()} [${q}] ${J}`+(Q===void 0?"":p(Q))+`
|
|
2
|
-
`;if(Z.push(j),Z.length>=50)V();else O()}function y(q){return{error:(H,J)=>W(q,"error",H,J),warn:(H,J)=>W(q,"warn",H,J),info:(H,J)=>W(q,"info",H,J),debug:(H,J)=>W(q,"debug",H,J),trace:(H,J)=>W(q,"trace",H,J)}}
|
|
3
|
-
export{k as Aa,P as Ba,y as Ca};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as a}from"./index-7tsnfb8g.js";import"./index-x55z0b3y.js";export default a();
|