opencode-auth-load-balancer 0.6.0 → 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/README.md +61 -9
- package/dist/index.d.ts +7 -12
- package/dist/index.js +46285 -16486
- package/dist/legacy.d.ts +25 -0
- package/dist/pending/coordinator.d.ts +5 -1
- package/dist/pending/v2.d.ts +3 -0
- package/dist/sdk/anthropic.d.ts +1 -0
- package/dist/sdk/anthropic.js +19420 -0
- package/dist/sdk/kimi.d.ts +1 -0
- package/dist/sdk/kimi.js +15254 -0
- package/dist/sdk/openai.d.ts +1 -0
- package/dist/sdk/openai.js +20991 -0
- package/dist/v1.d.ts +1 -0
- package/dist/v1.js +18393 -0
- package/dist/v2-rpc.d.ts +62 -0
- package/dist/v2.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +46 -8
- package/tui/auth-load-balancer-rpc.ts +60 -0
- package/tui/auth-load-balancer-v2.ts +10 -0
- package/tui/auth-load-balancer-v2.view.tsx +242 -0
- package/tui.ts +2 -0
package/dist/legacy.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AuthHook, Plugin } from '@opencode-ai/plugin';
|
|
2
|
+
import { type ToastClient } from './notify';
|
|
3
|
+
import { PendingCoordinator } from './pending/coordinator';
|
|
4
|
+
import type { ProviderAdapter } from './providers/types';
|
|
5
|
+
/**
|
|
6
|
+
* Build an opencode auth hook for one provider:
|
|
7
|
+
* - `loader`: seeds the pool from any existing opencode credential, then returns
|
|
8
|
+
* the load-balanced fetch so every request flows through the scheduler.
|
|
9
|
+
* - `methods`: logins that APPEND each account to the pool (instead of
|
|
10
|
+
* overwriting opencode's single auth slot) — a pasted OAuth code for
|
|
11
|
+
* Claude/Codex, then for Claude a pasted `claude setup-token` token; for
|
|
12
|
+
* Kimi Code a device-code OAuth login, then a pasted key.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildAuthHook(adapter: ProviderAdapter, client: ToastClient, pending: PendingCoordinator): AuthHook;
|
|
15
|
+
export declare const AnthropicLoadBalancerPlugin: Plugin;
|
|
16
|
+
export declare const OpenAILoadBalancerPlugin: Plugin;
|
|
17
|
+
export declare const KimiCodeLoadBalancerPlugin: Plugin;
|
|
18
|
+
export declare const KimiCodeGlobalLoadBalancerPlugin: Plugin;
|
|
19
|
+
/**
|
|
20
|
+
* A standalone plugin that registers the `auth_lb_status` tool — an on-demand
|
|
21
|
+
* dashboard (in-use account per provider, each account's weekly/5h usage,
|
|
22
|
+
* cooldowns, and the ranked next candidates) across ALL providers. Registered once
|
|
23
|
+
* (not per provider) so the tool name doesn't collide.
|
|
24
|
+
*/
|
|
25
|
+
export declare const AuthLoadBalancerStatusPlugin: (input: Pick<Parameters<Plugin>[0], 'directory' | 'worktree'>) => ReturnType<Plugin>;
|
|
@@ -76,6 +76,10 @@ export interface PendingRestoreClient {
|
|
|
76
76
|
prompt(options: RestorePromptOptions): Promise<RestoreResult<unknown>>;
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
+
/** Hosts with durable inboxes resume the original prompt by its stable ID. */
|
|
80
|
+
export interface PendingResumeClient {
|
|
81
|
+
resumePending(turn: PendingTurn): Promise<'resumed' | 'obsolete'>;
|
|
82
|
+
}
|
|
79
83
|
export interface PendingCoordinatorDependencies {
|
|
80
84
|
now(): number;
|
|
81
85
|
sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
@@ -126,7 +130,7 @@ export declare class PendingCoordinator {
|
|
|
126
130
|
private restoreOnce;
|
|
127
131
|
private restoreWithRetry;
|
|
128
132
|
/** Restore this workspace/provider's durable references independently. */
|
|
129
|
-
restore(client: PendingRestoreClient): Promise<void>;
|
|
133
|
+
restore(client: PendingRestoreClient | PendingResumeClient): Promise<void>;
|
|
130
134
|
/** Remove all pending providers for a deleted session in this workspace. */
|
|
131
135
|
removeSession(sessionID: string): Promise<number>;
|
|
132
136
|
/** Mark shutdown before aborting sleepers so their abort path preserves rows. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createAnthropic } from '@ai-sdk/anthropic';
|