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.
@@ -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,3 @@
1
+ import type { Plugin } from '@opencode/plugin';
2
+ import type { PendingResumeClient } from './coordinator';
3
+ export declare function createV2ResumeClient(ctx: Plugin.Context): PendingResumeClient;
@@ -0,0 +1 @@
1
+ export { createAnthropic } from '@ai-sdk/anthropic';