@cortexkit/opencode-anthropic-auth 1.20.0 → 1.22.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 +42 -8
- package/dist/cli.js +1 -1
- package/dist/effort-history.d.ts +58 -0
- package/dist/fable-fallback.d.ts +6 -7
- package/dist/{index-hmebes3f.js → index-7f57ewkp.js} +1 -1
- package/dist/{index-vkecgsm3.js → index-8aga2zwv.js} +1 -1
- package/dist/{index-jjx6dbj3.js → index-926t2bzc.js} +1 -1
- package/dist/{index-j3323dyj.js → index-bx5hsgf8.js} +1 -1
- package/dist/{index-nqs7chg0.js → index-cgez4m0h.js} +1 -1
- package/dist/index-d3f8g6ve.js +428 -0
- package/dist/index-sh51yqxs.js +2 -0
- package/dist/index.d.ts +0 -38
- package/dist/index.js +23 -21
- package/dist/{logger-8b9bz0g8.js → logger-jrkranbz.js} +1 -1
- package/dist/request-policy.d.ts +25 -0
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +15 -0
- 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/sidebar-state.d.ts +2 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/transform.d.ts +17 -1
- package/dist/tui/command-dialogs.d.ts +2 -8
- package/dist/tui-preferences.js +1 -1
- package/package.json +4 -4
- package/src/rpc/protocol.ts +17 -0
- package/src/sidebar-state.ts +16 -1
- package/src/tui/command-dialogs.tsx +40 -41
- package/src/tui-compiled/rpc/protocol.ts +17 -0
- package/src/tui-compiled/sidebar-state.ts +16 -1
- package/src/tui-compiled/tui/command-dialogs.tsx +49 -33
- package/src/tui-compiled/tui.tsx +7 -3
- package/src/tui.tsx +17 -3
- package/dist/index-afyr2g77.js +0 -2
- package/dist/index-ebq5g321.js +0 -427
package/README.md
CHANGED
|
@@ -33,12 +33,13 @@ This repo is a Bun workspace monorepo with two user-facing integrations and one
|
|
|
33
33
|
- **Quota window priming**: opt in with `/claude-prime on` to start each 5-hour quota window about one minute after it resets instead of waiting for the next normal prompt.
|
|
34
34
|
- **Lane start (OpenCode only)**: use `/claude-start` to fire one synthetic, one-token turn through the current session's normal model, agent, variant, quota, routing, cache, and request pipeline.
|
|
35
35
|
- **Fast mode toggle**: use `/claude-fast on|off` to request Anthropic fast mode for supported Opus models.
|
|
36
|
-
- **Adaptive reasoning visibility**: request summarized adaptive thinking for Claude Fable 5, Mythos 5, and Opus 5. OpenCode
|
|
36
|
+
- **Adaptive reasoning visibility**: request summarized adaptive thinking for Claude Fable 5/5.1, Mythos 5/5.1, and Opus 5. OpenCode exposes native `low`, `medium`, `high`, `xhigh`, and `max` effort variants for Fable 5.1 and Opus 5. OAuth Fable 5.1 sessions can change effort between turns without rewriting the cached prefix.
|
|
37
37
|
- **Fable/Opus 5 safety fallback**: eligible OAuth requests try Anthropic's server-side safety fallback first. The plugin preserves Anthropic's fallback conversation boundary across OpenCode history and automatically starts its deterministic 10-response Opus 4.8 recovery if the response still ends in refusal. The TUI sidebar and OpenCode Desktop report the active target model and restoration. Set `OPENCODE_ANTHROPIC_AUTH_FALLBACK_MODE=legacy` to bypass the server policy and use client-side recovery exclusively.
|
|
38
38
|
- **Live quota visibility**: use `/claude-quota` to see main and fallback quota state, reset times, and refresh errors.
|
|
39
|
+
- **Host-local quota feed**: optionally publish sanitized response-header quota observations so another local CortexKit process can reuse fresh account state without polling Anthropic's rate-limited usage endpoint.
|
|
39
40
|
- **Killswitch**: per-account hard-block thresholds that stop requests before hitting Anthropic's rate limits, with synthetic 429 retry-after when all accounts are exhausted.
|
|
40
41
|
- **User-owned Cloudflare relay**: optionally provision your own Worker relay to reduce repeated client upload bytes for large OpenCode or Pi requests.
|
|
41
|
-
- **Claude-compatible request hardening**: final-body billing signing, safer token refresh persistence, replay-safe fallback retries, and subagent cache isolation.
|
|
42
|
+
- **Claude-compatible request hardening**: Claude Code 2.1.258 identity and final-body billing signing, live-session-stable billing suffixes, Fable 5.1 thinking-prefix recovery, safer token refresh persistence, replay-safe fallback retries, and subagent cache isolation.
|
|
42
43
|
|
|
43
44
|
## What these integrations do
|
|
44
45
|
|
|
@@ -180,6 +181,12 @@ Example:
|
|
|
180
181
|
"failClosedOnUnknownQuota": true,
|
|
181
182
|
"showToasts": false
|
|
182
183
|
},
|
|
184
|
+
"quotaHeaderFeed": {
|
|
185
|
+
"enabled": false
|
|
186
|
+
},
|
|
187
|
+
"claustrum": {
|
|
188
|
+
"accounts": {}
|
|
189
|
+
},
|
|
183
190
|
"killswitch": {
|
|
184
191
|
"enabled": false,
|
|
185
192
|
"main": { "five_hour": 5, "seven_day": 10, "scoped": 0 },
|
|
@@ -201,6 +208,9 @@ Example:
|
|
|
201
208
|
"claudeFast": {
|
|
202
209
|
"enabled": false
|
|
203
210
|
},
|
|
211
|
+
"thinkingBinding": {
|
|
212
|
+
"prefixMismatchBehavior": "account-default"
|
|
213
|
+
},
|
|
204
214
|
"costZeroing": {
|
|
205
215
|
"enabled": true
|
|
206
216
|
},
|
|
@@ -217,6 +227,12 @@ Example:
|
|
|
217
227
|
|
|
218
228
|
The `routing` block controls `/claude-routing`, `claudeCache` controls `/claude-cache`, `cacheKeep` controls `/claude-cachekeep`, and `claudeFast` controls `/claude-fast`. OpenCode zeroes Anthropic OAuth model costs by default because OAuth usage is quota-based; set `costZeroing.enabled` to `false` only if you want OpenCode to display the provider's model pricing instead. Set `quota.showToasts` to `true` to opt into OpenCode quota toast notifications after quota refreshes. The `main` field identifies OpenCode's primary auth entry; Pi keeps primary OAuth credentials in Pi's own credential store, but uses the same sidecar shape for CortexKit settings and fallback account labels.
|
|
219
229
|
|
|
230
|
+
`thinkingBinding.prefixMismatchBehavior` controls replayed signed/redacted thinking on OAuth Fable 5.1 requests. `account-default` (the default) sends no explicit prefix-mismatch override. Use `error` to make prefix changes fail deterministically during compaction testing, or `drop_block` to ask Anthropic to discard mismatched thinking blocks. The beta header is added only when an explicit behavior is configured and replayable thinking is present.
|
|
231
|
+
|
|
232
|
+
`quotaHeaderFeed.enabled` is an OpenCode-only, restart-required opt-in. It publishes only allowlisted quota-window values, an opaque account reference, an observation timestamp, and the configured OAuth-account count; it never publishes tokens, raw headers, request bodies, model IDs, or refresh errors. Per-process lease files use owner-only permissions under `$TMPDIR/opencode-anthropic-auth/quota-header-feed`, expire after three minutes, and can be redirected with `OPENCODE_ANTHROPIC_AUTH_QUOTA_FEED_DIR`.
|
|
233
|
+
|
|
234
|
+
`claustrum.accounts.<fallback-account-id>.enabled` is a per-account opt-in for fallback credential custody. It is inert unless that account's capability handle has been provisioned in `anthropic-auth-state.json`; handles are bearer credentials and must not be copied into the public config file.
|
|
235
|
+
|
|
220
236
|
Runtime data is stored separately in `anthropic-auth-state.json`: fallback OAuth tokens, API-route keys, token refresh backoff, quota snapshots, and quota API backoff. Sticky session assignments use `anthropic-auth-routing-state.json` and store only SHA-256 hashes of session IDs. Background refresh and quota checks write only runtime state, so editing `anthropic-auth.json` does not get overwritten by another running plugin instance.
|
|
221
237
|
|
|
222
238
|
## OpenCode lane-start setting
|
|
@@ -263,9 +279,27 @@ Fallback retries are only attempted when the request body is safely replayable.
|
|
|
263
279
|
|
|
264
280
|
### Token refresh
|
|
265
281
|
|
|
266
|
-
Fallback OAuth tokens refresh in the background so idle accounts do not expire before they are needed. Refresh token rotation is persisted immediately. The plugin also re-reads the latest sidecar account before refreshing, which avoids using stale refresh-token snapshots when multiple background paths run close together.
|
|
282
|
+
Fallback OAuth tokens refresh in the background so idle accounts do not expire before they are needed. Refresh token rotation is persisted immediately. The plugin also re-reads the latest sidecar account before refreshing, which avoids using stale refresh-token snapshots when multiple background paths run close together. Persisted refresh backoffs are bound to the refresh token that produced them, so replacing a rejected credential immediately clears its stale latch.
|
|
283
|
+
|
|
284
|
+
If Anthropic reports `invalid_grant`, that account must be logged in again. `/claude-account reset-backoff` manually clears the main account's refresh backoff and its matching quota backoff.
|
|
285
|
+
|
|
286
|
+
### Optional Claustrum custody
|
|
287
|
+
|
|
288
|
+
OpenCode can obtain an opted-in fallback OAuth account's access credential from a local [Claustrum](https://github.com/cortexkit/claustrum) daemon instead of refreshing that account independently. After provisioning the account's runtime handle, enable custody by account ID:
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"claustrum": {
|
|
293
|
+
"accounts": {
|
|
294
|
+
"personal-alt": { "enabled": true }
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
The request path reads only a resident in-memory credential. Startup warming and periodic custody ticks perform vault I/O and keep idle credentials refreshed; a cold or unavailable vault falls back to the sidecar credential path. Vault-served 401 reports carry the exact record version and response provenance, including relay-stream 401s, so a sidecar-served failure cannot invalidate a healthy vault credential. `/claude-account` and the account modal show the gate, current vault service, and vault reauthentication state without exposing capability handles.
|
|
267
301
|
|
|
268
|
-
|
|
302
|
+
Custody currently applies only to fallback OAuth accounts. Main-account vault service is not implemented. If Claustrum has replaced the main host credential with its provider-bound tombstone, the plugin rejects refresh locally without contacting Anthropic or persisting a permanent `invalid_grant` state.
|
|
269
303
|
|
|
270
304
|
## Quota-aware routing
|
|
271
305
|
|
|
@@ -296,7 +330,7 @@ Reset times are rendered as relative durations, such as `resets in 10m` or `rese
|
|
|
296
330
|
|
|
297
331
|
## Safety fallback
|
|
298
332
|
|
|
299
|
-
Eligible Fable 5 and Opus 5 OAuth requests try Anthropic's server-side safety fallback first. The plugin sends `fallbacks: "default"` with Anthropic's server-side fallback beta, preserves fallback conversation boundaries in OpenCode history, and reports model handoffs and restoration in the TUI sidebar or OpenCode Desktop. Follow-up requests may remain on Anthropic's selected fallback model for approximately one hour.
|
|
333
|
+
Eligible Fable 5/5.1 and Opus 5 OAuth requests try Anthropic's server-side safety fallback first. The plugin sends `fallbacks: "default"` with Anthropic's server-side fallback beta, preserves fallback conversation boundaries in OpenCode history, and reports model handoffs and restoration in the TUI sidebar or OpenCode Desktop. Follow-up requests may remain on Anthropic's selected fallback model for approximately one hour.
|
|
300
334
|
|
|
301
335
|
If an eligible OAuth response still ends in refusal, CortexKit automatically starts its deterministic 10-successful-response Opus 4.8 recovery, prewarms the selected source model without the server-fallback opt-in, and then restores that model. If the refused response already completed a tool call, the plugin preserves that call and continues with its existing tool result instead of replaying the tool.
|
|
302
336
|
|
|
@@ -308,7 +342,7 @@ To bypass Anthropic's server policy and use deterministic client recovery from t
|
|
|
308
342
|
OPENCODE_ANTHROPIC_AUTH_FALLBACK_MODE=legacy opencode
|
|
309
343
|
```
|
|
310
344
|
|
|
311
|
-
Legacy mode routes a refused Fable 5 or Opus 5 session through Opus 4.8 for 10 successful responses, prewarms the selected source model's cache, and then restores that model without first opting into Anthropic's server policy. Unset the variable and restart OpenCode to return to the default server-first policy with the same client recovery as a backstop.
|
|
345
|
+
Legacy mode routes a refused Fable 5/5.1 or Opus 5 session through Opus 4.8 for 10 successful responses, prewarms the selected source model's cache, and then restores that model without first opting into Anthropic's server policy. Unset the variable and restart OpenCode to return to the default server-first policy with the same client recovery as a backstop.
|
|
312
346
|
|
|
313
347
|
## Killswitch
|
|
314
348
|
|
|
@@ -514,7 +548,7 @@ Both OpenCode and Pi packages can persistently request Anthropic fast mode for s
|
|
|
514
548
|
/claude-fast off
|
|
515
549
|
```
|
|
516
550
|
|
|
517
|
-
When enabled, supported requests add `speed: "fast"` to the Anthropic JSON body and include the `fast-mode-2026-02-01` beta header. Unsupported models are left at standard speed. Anthropic currently documents fast mode for `claude-opus-4-6`, `claude-opus-4-7`, `claude-opus-4-8`, and `claude-opus-5`; Claude Fable
|
|
551
|
+
When enabled, supported requests add `speed: "fast"` to the Anthropic JSON body and include the `fast-mode-2026-02-01` beta header. Unsupported models are left at standard speed. Anthropic currently documents fast mode for `claude-opus-4-6`, `claude-opus-4-7`, `claude-opus-4-8`, and `claude-opus-5`; Claude Fable and Mythos 5/5.1 are not fast-mode models.
|
|
518
552
|
|
|
519
553
|
Fast and standard speeds do not share prompt-cache prefixes, so switching this setting can cause cache misses.
|
|
520
554
|
|
|
@@ -660,7 +694,7 @@ For Claude Pro/Max OAuth requests, the plugin works at the final Anthropic wire-
|
|
|
660
694
|
4. Prepends Claude Code identity and billing-header blocks.
|
|
661
695
|
5. Rewrites cache controls according to `/claude-cache` mode.
|
|
662
696
|
6. Renames MCP tool names into Claude-compatible PascalCase form.
|
|
663
|
-
7. Opts eligible Fable 5 and Opus 5 OAuth requests into Anthropic's server-side safety fallback, restores stored fallback boundaries, and activates replay-safe client recovery if the response still refuses.
|
|
697
|
+
7. Opts eligible Fable 5/5.1 and Opus 5 OAuth requests into Anthropic's server-side safety fallback, restores stored fallback boundaries, and activates replay-safe client recovery if the response still refuses.
|
|
664
698
|
8. Computes final-body `cch` over the fully serialized request body.
|
|
665
699
|
|
|
666
700
|
The sanitizer is anchor-based: it removes paragraphs containing known OpenCode documentation or source anchors, performs a small set of inline replacements, and preserves the rest of the prompt including user/project instructions, tool policy, environment context, and file paths.
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{$ as S,Fc as T,Hc as q,L as z,M as N,O as P,Q as L,T as E,Wa as U,X as K}from"./index-d3f8g6ve.js";import"./index-8aga2zwv.js";import{ud as w}from"./index-cgez4m0h.js";import{stdin as x,stdout as v}from"node:process";import{createInterface as y}from"node:readline/promises";function R(){return{version:1,main:{type:"opencode",provider:"anthropic"},fallbackOn:[401,403,429],refresh:{enabled:!0,intervalMinutes:10,refreshBeforeExpiryMinutes:240},quota:{enabled:!0,checkIntervalMinutes:5,minimumRemaining:{five_hour:10,seven_day:20},failClosedOnUnknownQuota:!0},accounts:[]}}function _(){console.log(`Usage:
|
|
3
3
|
opencode-anthropic-auth login [label]
|
|
4
4
|
opencode-anthropic-auth api add [label]
|
|
5
5
|
opencode-anthropic-auth list
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type AdaptiveEffort } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
export declare const EFFORT_MARKER_PREFIX = "<cortexkit-internal-effort-v2 ";
|
|
3
|
+
export declare const EFFORT_PLAN_REQUEST_HEADER = "x-cortexkit-effort-plan";
|
|
4
|
+
export type OpenCodeEffortMarkerPlan = {
|
|
5
|
+
scope: string;
|
|
6
|
+
baseline: AdaptiveEffort;
|
|
7
|
+
markerCount: number;
|
|
8
|
+
digest: string;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
messageId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class EffortMarkerCorrelationError extends Error {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
type OpenCodeMessageInfo = {
|
|
16
|
+
id?: unknown;
|
|
17
|
+
sessionID?: unknown;
|
|
18
|
+
role?: unknown;
|
|
19
|
+
model?: {
|
|
20
|
+
providerID?: unknown;
|
|
21
|
+
modelID?: unknown;
|
|
22
|
+
variant?: unknown;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type MutableOpenCodePart = Record<string, unknown> & {
|
|
26
|
+
type?: unknown;
|
|
27
|
+
text?: unknown;
|
|
28
|
+
ignored?: unknown;
|
|
29
|
+
mime?: unknown;
|
|
30
|
+
};
|
|
31
|
+
type MutableOpenCodeMessage = {
|
|
32
|
+
info?: OpenCodeMessageInfo;
|
|
33
|
+
parts?: MutableOpenCodePart[];
|
|
34
|
+
};
|
|
35
|
+
export declare function encodeOpenCodeEffortPlan(plan: OpenCodeEffortMarkerPlan): string;
|
|
36
|
+
/**
|
|
37
|
+
* Annotate effort-changing user turns before OpenCode lowers its internal
|
|
38
|
+
* message records. Markers are stable by session/message identity so later
|
|
39
|
+
* transforms may persist and restore them without changing request lineage.
|
|
40
|
+
*/
|
|
41
|
+
export declare function markOpenCodeEffortTransitions(messages: MutableOpenCodeMessage[]): OpenCodeEffortMarkerPlan | null;
|
|
42
|
+
/** Consume request-correlated markers and insert Anthropic effort system messages. */
|
|
43
|
+
export declare function applyOpenCodeEffortMarkers(body: Record<string, unknown>, enabled: boolean, requestPlanHeader?: string): {
|
|
44
|
+
found: number;
|
|
45
|
+
inserted: number;
|
|
46
|
+
};
|
|
47
|
+
export declare class OpenCodeEffortPlanTracker {
|
|
48
|
+
private readonly plans;
|
|
49
|
+
record(plan: OpenCodeEffortMarkerPlan): void;
|
|
50
|
+
clear(sessionId: string, messageId: string): void;
|
|
51
|
+
markHeaders(input: {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
messageId: string;
|
|
54
|
+
headers: Record<string, string>;
|
|
55
|
+
}): boolean;
|
|
56
|
+
private key;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
package/dist/fable-fallback.d.ts
CHANGED
|
@@ -21,14 +21,13 @@ export type FableFallbackPlan = {
|
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* Models whose content-filter refusal we recover from by downgrading to Opus 4.8
|
|
24
|
-
* for a short window. Fable 5
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* source models, so the recovery period is uniform.
|
|
24
|
+
* for a short window. Fable 5, Fable 5.1, and Opus 5 each have a separate
|
|
25
|
+
* source family because recovery state must not cross-contaminate distinct
|
|
26
|
+
* requested models. All three use Anthropic's `claude-opus-4-8` fallback for
|
|
27
|
+
* the same classifier refusal shape and recovery period. Mythos has no
|
|
28
|
+
* classifiers and Sonnet 5 is not flagged — both stay outside this gate.
|
|
30
29
|
*/
|
|
31
|
-
export type RecoverableRefusalFamily = 'fable-5' | 'opus-5';
|
|
30
|
+
export type RecoverableRefusalFamily = 'fable-5' | 'fable-5-1' | 'opus-5';
|
|
32
31
|
export declare function recoverableRefusalFamily(model: unknown): RecoverableRefusalFamily | null;
|
|
33
32
|
export declare function isRecoverableRefusalModel(model: unknown): model is string;
|
|
34
33
|
export declare class FableFallbackManager {
|
|
@@ -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 qd,T as rd};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
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
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
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
|
|
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};
|
|
@@ -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 nd,h as od};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var e=["claude-account","claude-cache","claude-cachekeep","claude-prime","claude-start","claude-quota","claude-dump","claude-fast","claude-routing","claude-killswitch","claude-logging"];
|
|
2
|
-
export{e as
|
|
2
|
+
export{e as pd};
|
|
@@ -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 sd,s as td,u as ud};
|