opencode-anthropic-multi-account 0.2.2 → 0.2.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/anthropic-prompt.d.ts +1 -0
- package/dist/auth-handler.d.ts +3 -2
- package/dist/constants.d.ts +0 -1
- package/dist/executor.d.ts +8 -2
- package/dist/index.js +1438 -496
- package/dist/pi-ai-adapter.d.ts +16 -0
- package/dist/pool-chain-executor.d.ts +11 -0
- package/dist/request-transform.d.ts +2 -0
- package/dist/runtime-factory.d.ts +3 -6
- package/dist/token.d.ts +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OAuthCredentials as PiAiOAuthCredentials, OAuthPrompt } from "@mariozechner/pi-ai/oauth";
|
|
2
|
+
import type { StoredAccount, CredentialRefreshPatch } from "./types";
|
|
3
|
+
export declare function toPiAiCredentials(account: Pick<StoredAccount, "accessToken" | "refreshToken" | "expiresAt">): PiAiOAuthCredentials;
|
|
4
|
+
export declare function fromPiAiCredentials(creds: PiAiOAuthCredentials): Pick<StoredAccount, "accessToken" | "refreshToken" | "expiresAt">;
|
|
5
|
+
export interface LoginWithPiAiCallbacks {
|
|
6
|
+
onAuth: (info: {
|
|
7
|
+
url: string;
|
|
8
|
+
instructions?: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
|
|
11
|
+
onProgress?: (message: string) => void;
|
|
12
|
+
onManualCodeInput?: () => Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
export declare function loginWithPiAi(callbacks: LoginWithPiAiCallbacks): Promise<Partial<StoredAccount>>;
|
|
15
|
+
export declare function refreshWithPiAi(currentRefreshToken: string): Promise<CredentialRefreshPatch>;
|
|
16
|
+
export declare const PI_AI_ADAPTER_SERVICE: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CascadeStateManager, ExecutorAccountManager, ExecutorRuntimeFactory, PoolChainConfig, PoolManager } from "opencode-multi-account-core";
|
|
2
|
+
import { handleRateLimitResponse as handleRateLimitResponseForProvider } from "./rate-limit";
|
|
3
|
+
import type { ManagedAccount, PluginClient } from "./types";
|
|
4
|
+
type RateLimitManager = Parameters<typeof handleRateLimitResponseForProvider>[0];
|
|
5
|
+
export interface PoolChainAccountManager extends ExecutorAccountManager, RateLimitManager {
|
|
6
|
+
getAccounts(): ManagedAccount[];
|
|
7
|
+
isRateLimited(account: ManagedAccount): boolean;
|
|
8
|
+
getActiveAccount(): ManagedAccount | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function executeWithPoolChainRotation(manager: PoolChainAccountManager, runtimeFactory: ExecutorRuntimeFactory, poolManager: PoolManager, cascadeStateManager: CascadeStateManager, poolChainConfig: PoolChainConfig, client: PluginClient, input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
11
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare function getSystemPrompt(): string;
|
|
2
|
+
export declare function buildBillingHeader(firstUserMessage: string): string;
|
|
1
3
|
export declare function buildRequestHeaders(input: RequestInfo | URL, init: RequestInit | undefined, accessToken: string): Headers;
|
|
2
4
|
export declare function transformRequestBody(body: string | undefined): string | undefined;
|
|
3
5
|
export declare function transformRequestUrl(input: RequestInfo | URL): RequestInfo | URL;
|
|
@@ -4,20 +4,17 @@ type BaseFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Respo
|
|
|
4
4
|
interface AccountRuntime {
|
|
5
5
|
fetch: BaseFetch;
|
|
6
6
|
}
|
|
7
|
-
/** Per-account base plugin instances — delegates all auth mechanics to AnthropicAuthPlugin. */
|
|
8
7
|
export declare class AccountRuntimeFactory {
|
|
9
|
-
private readonly pluginCtx;
|
|
10
8
|
private readonly store;
|
|
11
9
|
private readonly client;
|
|
12
|
-
private readonly provider;
|
|
13
10
|
private runtimes;
|
|
14
11
|
private initLocks;
|
|
15
|
-
constructor(
|
|
12
|
+
constructor(store: AccountStore, client: PluginClient);
|
|
16
13
|
getRuntime(uuid: string): Promise<AccountRuntime>;
|
|
17
14
|
invalidate(uuid: string): void;
|
|
18
15
|
invalidateAll(): void;
|
|
16
|
+
private ensureFreshToken;
|
|
17
|
+
private executeTransformedFetch;
|
|
19
18
|
private createRuntime;
|
|
20
|
-
private createScopedGetAuth;
|
|
21
|
-
private createScopedClient;
|
|
22
19
|
}
|
|
23
20
|
export {};
|
package/dist/token.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ManagedAccount, PluginClient, TokenRefreshResult } from "./types";
|
|
2
2
|
export declare function isTokenExpired(account: Pick<ManagedAccount, "accessToken" | "expiresAt">): boolean;
|
|
3
3
|
export declare function refreshToken(currentRefreshToken: string, accountId: string, client: PluginClient): Promise<TokenRefreshResult>;
|
|
4
4
|
export declare function clearRefreshMutex(accountId?: string): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-anthropic-multi-account",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "OpenCode plugin for Anthropic multi-account management with automatic rate limit switching",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"directory": "packages/anthropic-multi-account"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"opencode-multi-account-core": "^0.2.
|
|
43
|
-
"
|
|
42
|
+
"opencode-multi-account-core": "^0.2.4",
|
|
43
|
+
"@mariozechner/pi-ai": "^0.61.0",
|
|
44
44
|
"valibot": "^1.2.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|