@anthonyhaussman/opencode-agy-auth 0.0.0-test.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/LICENSE +176 -0
- package/README.md +178 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +22014 -0
- package/dist/index.js.map +1 -0
- package/dist/src/constants.d.ts +9 -0
- package/dist/src/fetch.d.ts +1 -0
- package/dist/src/plugin/auth.d.ts +14 -0
- package/dist/src/plugin/cache.d.ts +35 -0
- package/dist/src/plugin/dynamic-models.d.ts +26 -0
- package/dist/src/plugin/headers.d.ts +7 -0
- package/dist/src/plugin/notify.d.ts +9 -0
- package/dist/src/plugin/oauth-authorize.d.ts +26 -0
- package/dist/src/plugin/pricing.d.ts +10 -0
- package/dist/src/plugin/project/context.d.ts +13 -0
- package/dist/src/plugin/project/index.d.ts +2 -0
- package/dist/src/plugin/project/types.d.ts +84 -0
- package/dist/src/plugin/project/utils.d.ts +35 -0
- package/dist/src/plugin/provider.d.ts +12 -0
- package/dist/src/plugin/quota-summary.d.ts +16 -0
- package/dist/src/plugin/quota-utils.d.ts +5 -0
- package/dist/src/plugin/quota.d.ts +16 -0
- package/dist/src/plugin/tier.d.ts +25 -0
- package/dist/src/plugin/token.d.ts +2 -0
- package/dist/src/plugin/traffic.d.ts +47 -0
- package/dist/src/plugin/types.d.ts +83 -0
- package/dist/src/plugin/v2-fetch.d.ts +7 -0
- package/dist/src/plugin/v2-session.d.ts +10 -0
- package/dist/src/plugin/v2-storage.d.ts +3 -0
- package/dist/src/plugin/v2.d.ts +15 -0
- package/dist/src/plugin.d.ts +8 -0
- package/dist/src/sdk/activity-request-id.d.ts +5 -0
- package/dist/src/sdk/agy-cli-version.d.ts +1 -0
- package/dist/src/sdk/cache/signature-cache.d.ts +130 -0
- package/dist/src/sdk/chat-logger.d.ts +8 -0
- package/dist/src/sdk/fetch_models.d.ts +48 -0
- package/dist/src/sdk/fetch_project.d.ts +9 -0
- package/dist/src/sdk/fetch_quota.d.ts +9 -0
- package/dist/src/sdk/oauth.d.ts +26 -0
- package/dist/src/sdk/request/identifiers.d.ts +16 -0
- package/dist/src/sdk/request/index.d.ts +12 -0
- package/dist/src/sdk/request/openai.d.ts +17 -0
- package/dist/src/sdk/request/prepare.d.ts +19 -0
- package/dist/src/sdk/request/response.d.ts +5 -0
- package/dist/src/sdk/request/shared.d.ts +20 -0
- package/dist/src/sdk/request/thinking.d.ts +129 -0
- package/dist/src/sdk/request/tool-mapper.d.ts +47 -0
- package/dist/src/sdk/request/turn-state-tracker.d.ts +21 -0
- package/dist/src/sdk/request-helpers/errors.d.ts +9 -0
- package/dist/src/sdk/request-helpers/index.d.ts +4 -0
- package/dist/src/sdk/request-helpers/parsing.d.ts +9 -0
- package/dist/src/sdk/request-helpers/thinking.d.ts +5 -0
- package/dist/src/sdk/request-helpers/types.d.ts +65 -0
- package/dist/src/sdk/retry/cooldown-store.d.ts +14 -0
- package/dist/src/sdk/retry/helpers.d.ts +19 -0
- package/dist/src/sdk/retry/index.d.ts +9 -0
- package/dist/src/sdk/retry/quota.d.ts +37 -0
- package/dist/src/sdk/terminal-hyperlink.d.ts +3 -0
- package/dist/src/sdk/user-agent.d.ts +5 -0
- package/package.json +60 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const AGY_PROVIDER_ID = "google-agy";
|
|
2
|
+
export declare const AGY_AUTH_URL = "https://accounts.google.com/o/oauth2/auth";
|
|
3
|
+
export declare const AGY_TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
4
|
+
export declare const AGY_CLIENT_ID = "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com";
|
|
5
|
+
export declare const AGY_CLIENT_SECRET = "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";
|
|
6
|
+
export declare const AGY_SCOPES: readonly string[];
|
|
7
|
+
export declare const AGY_REDIRECT_URI = "https://antigravity.google/oauth-callback";
|
|
8
|
+
export declare const AGY_CODE_ASSIST_ENDPOINT: string;
|
|
9
|
+
export declare const AGY_GENERATIVE_LANGUAGE_ENDPOINT = "https://generativelanguage.googleapis.com/v1beta";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function agyFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthDetails, OAuthAuthDetails, RefreshParts } from './types';
|
|
2
|
+
export declare function isOAuthAuth(auth: AuthDetails | undefined | null): auth is OAuthAuthDetails;
|
|
3
|
+
/**
|
|
4
|
+
* Splits the packed refresh string into the corresponding refresh token and project ID.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseRefreshParts(refresh: string): RefreshParts;
|
|
7
|
+
/**
|
|
8
|
+
* Serializes the parts of a refresh token into the stored string format.
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatRefreshParts(parts: RefreshParts): string;
|
|
11
|
+
/**
|
|
12
|
+
* Determines whether the access token has expired or is missing, with a buffer for clock skew.
|
|
13
|
+
*/
|
|
14
|
+
export declare function accessTokenExpired(auth: OAuthAuthDetails): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { OAuthAuthDetails } from "./types";
|
|
2
|
+
import { SignatureCache, type SignatureCacheConfig } from "../sdk/cache/signature-cache";
|
|
3
|
+
/**
|
|
4
|
+
* Extracts valid OAuthAuthDetails from cache. Reuses an available and unexpired Token if present, otherwise prioritizes the latest provided value.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveCachedAuth(auth: OAuthAuthDetails): OAuthAuthDetails;
|
|
7
|
+
/**
|
|
8
|
+
* Explicitly updates or saves authorized token details to the cache.
|
|
9
|
+
*/
|
|
10
|
+
export declare function storeCachedAuth(auth: OAuthAuthDetails): void;
|
|
11
|
+
/**
|
|
12
|
+
* Clears cached login authorization details. If no refresh token is provided, clears the global cache.
|
|
13
|
+
*/
|
|
14
|
+
export declare function clearCachedAuth(refresh?: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Initializes the disk-level signature storage manager.
|
|
17
|
+
*/
|
|
18
|
+
export declare function initDiskSignatureCache(config: SignatureCacheConfig | undefined): SignatureCache | null;
|
|
19
|
+
/**
|
|
20
|
+
* Caches a thought chain fragment and its corresponding service signature, synchronously saving it to disk.
|
|
21
|
+
*/
|
|
22
|
+
export declare function cacheSignature(sessionId: string, text: string, signature: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Recovers and retrieves the most recently cached signature for a session (supports signature recovery).
|
|
25
|
+
*/
|
|
26
|
+
export declare function getLatestSignature(sessionId: string): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves a cached signature for a specific text in a session.
|
|
29
|
+
* Checks memory cache first, then falls back to disk cache.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSignatureForText(sessionId: string, text: string): string | undefined;
|
|
32
|
+
export declare function getDiskSignatureCache(): SignatureCache | null;
|
|
33
|
+
export declare function resetDiskSignatureCacheForTesting(): void;
|
|
34
|
+
export type { SignatureCache } from "../sdk/cache/signature-cache";
|
|
35
|
+
export type { SignatureCacheConfig } from "../sdk/cache/signature-cache";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type FetchAvailableModelsResponse } from '../sdk/fetch_models';
|
|
2
|
+
import { type SimpleStaticModel, type TierMap } from './tier';
|
|
3
|
+
import type { OpenCodeV2PluginContext } from './types';
|
|
4
|
+
export interface NormalizedModelCatalog {
|
|
5
|
+
models: Record<string, SimpleStaticModel>;
|
|
6
|
+
tierMapping: Record<string, TierMap>;
|
|
7
|
+
enums: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export type DiscoveredModelCatalog = NormalizedModelCatalog;
|
|
10
|
+
export interface AccountModelInventory extends NormalizedModelCatalog {
|
|
11
|
+
connection: {
|
|
12
|
+
type: 'credential';
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export type AccountModelsContext = Partial<OpenCodeV2PluginContext>;
|
|
17
|
+
/**
|
|
18
|
+
* Normalizes an Antigravity fetchAvailableModels payload into OpenCode base models,
|
|
19
|
+
* dynamic tier mappings, and full server model enum lookup entries.
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeDiscoveredModels(response: FetchAvailableModelsResponse): NormalizedModelCatalog;
|
|
22
|
+
/**
|
|
23
|
+
* Loads and normalizes account-specific models from the Antigravity Code Assist server
|
|
24
|
+
* for the currently active OpenCode v2 OAuth credential connection.
|
|
25
|
+
*/
|
|
26
|
+
export declare function loadAccountModels(ctx: AccountModelsContext): Promise<AccountModelInventory | undefined>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP header and URL manipulation utilities.
|
|
3
|
+
* Shared between OpenCode v1 and v2 runtimes.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getSafeHeader(headers: unknown, key: string): string | undefined;
|
|
6
|
+
export declare function setSafeHeaders(initHeaders: unknown, newHeaders: Record<string, string>): unknown;
|
|
7
|
+
export declare function toUrlString(value: RequestInfo): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PluginClient } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Shows a Toast notification to the user when the server-side Agy model capacity is exhausted.
|
|
4
|
+
*/
|
|
5
|
+
export declare function maybeShowAgyCapacityToast(client: PluginClient, response: Response, projectId: string, requestedModel?: string): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Temporary smoke test Toast, only enabled when OPENCODE_AGY_TEST_TOAST=1.
|
|
8
|
+
*/
|
|
9
|
+
export declare function maybeShowAgyTestToast(client: PluginClient, projectId: string): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgyTokenExchangeResult } from '../sdk/oauth';
|
|
2
|
+
import type { PluginClient } from './types';
|
|
3
|
+
export interface OAuthAuthorizeOptions {
|
|
4
|
+
client?: PluginClient;
|
|
5
|
+
getConfiguredProjectId?: () => Promise<string | undefined> | string | undefined;
|
|
6
|
+
getUserAgentModel?: () => Promise<string | undefined> | string | undefined;
|
|
7
|
+
openBrowser?: (url: string) => void;
|
|
8
|
+
onConnected?: () => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Builds the OAuth authorization callback for the plugin authentication method.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createOAuthAuthorizeMethod(options?: OAuthAuthorizeOptions): () => Promise<{
|
|
14
|
+
url: string;
|
|
15
|
+
instructions: string;
|
|
16
|
+
method: 'code';
|
|
17
|
+
callback: (callbackUrl: string) => Promise<AgyTokenExchangeResult>;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function parseOAuthCallbackInput(input: string): {
|
|
20
|
+
code?: string;
|
|
21
|
+
state?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function setOpenBrowserLauncherForTesting(launcher: typeof openBrowserLauncher | null): void;
|
|
24
|
+
export declare function defaultOpenBrowserLauncher(command: string, args: string[]): void;
|
|
25
|
+
declare let openBrowserLauncher: typeof defaultOpenBrowserLauncher;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProviderModel } from './types';
|
|
2
|
+
import type { SimpleStaticModel } from './tier';
|
|
3
|
+
/**
|
|
4
|
+
* Mutates the STATIC_MODELS object by injecting dynamic costs from models.dev
|
|
5
|
+
*/
|
|
6
|
+
export declare function updateStaticModelsWithPricing(staticModels: Record<string, ProviderModel>): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Enriches SimpleStaticModel entries with dynamic costs from models.dev when available.
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyPricingToSimpleModels<T extends Record<string, SimpleStaticModel>>(models: T): Promise<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OAuthAuthDetails, PluginClient, ProjectContextResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Clears cached project context results and pending Promises.
|
|
4
|
+
*/
|
|
5
|
+
export declare function invalidateProjectContextCache(refresh?: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the project context corresponding to the access token, optionally persisting updated auth details.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveProjectContextFromAccessToken(auth: OAuthAuthDetails, accessToken: string, configuredProjectId?: string, persistAuth?: (auth: OAuthAuthDetails) => Promise<void>, userAgentModel?: string): Promise<ProjectContextResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the effective project ID for the current auth state and caches the result by refresh token.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ensureProjectContext(auth: OAuthAuthDetails, client: PluginClient, configuredProjectId?: string, userAgentModel?: string): Promise<ProjectContextResult>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export declare const FREE_TIER_ID = "free-tier";
|
|
2
|
+
export declare const LEGACY_TIER_ID = "legacy-tier";
|
|
3
|
+
export declare const CODE_ASSIST_METADATA: {
|
|
4
|
+
readonly ideType: "ANTIGRAVITY";
|
|
5
|
+
};
|
|
6
|
+
export interface AgyUserTier {
|
|
7
|
+
id?: string;
|
|
8
|
+
isDefault?: boolean;
|
|
9
|
+
userDefinedCloudaicompanionProject?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CloudAiCompanionProject {
|
|
14
|
+
id?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AgyIneligibleTier {
|
|
17
|
+
reasonCode?: string;
|
|
18
|
+
reasonMessage?: string;
|
|
19
|
+
validationUrl?: string;
|
|
20
|
+
validationLearnMoreUrl?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface LoadCodeAssistPayload {
|
|
23
|
+
cloudaicompanionProject?: string | CloudAiCompanionProject;
|
|
24
|
+
currentTier?: {
|
|
25
|
+
id?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
};
|
|
28
|
+
allowedTiers?: AgyUserTier[];
|
|
29
|
+
ineligibleTiers?: AgyIneligibleTier[];
|
|
30
|
+
}
|
|
31
|
+
export interface OnboardUserPayload {
|
|
32
|
+
name?: string;
|
|
33
|
+
done?: boolean;
|
|
34
|
+
response?: {
|
|
35
|
+
cloudaicompanionProject?: {
|
|
36
|
+
id?: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface RetrieveUserQuotaBucket {
|
|
41
|
+
remainingAmount?: string;
|
|
42
|
+
remainingFraction?: number;
|
|
43
|
+
resetTime?: string;
|
|
44
|
+
tokenType?: string;
|
|
45
|
+
modelId?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface RetrieveUserQuotaResponse {
|
|
48
|
+
buckets?: RetrieveUserQuotaBucket[];
|
|
49
|
+
}
|
|
50
|
+
export interface QuotaSummaryBucket {
|
|
51
|
+
bucketId?: string;
|
|
52
|
+
displayName?: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
window?: string;
|
|
55
|
+
remaining?: string;
|
|
56
|
+
remainingFraction?: number;
|
|
57
|
+
remainingAmount?: string;
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
resetTime?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface QuotaSummaryGroup {
|
|
62
|
+
displayName?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
buckets?: QuotaSummaryBucket[];
|
|
65
|
+
}
|
|
66
|
+
export interface RetrieveUserQuotaSummaryResponse {
|
|
67
|
+
groups?: QuotaSummaryGroup[];
|
|
68
|
+
buckets?: QuotaSummaryBucket[];
|
|
69
|
+
description?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Thrown during Gemini enablement if the required Google Cloud project is missing.
|
|
73
|
+
*/
|
|
74
|
+
export declare class ProjectIdRequiredError extends Error {
|
|
75
|
+
constructor();
|
|
76
|
+
}
|
|
77
|
+
export declare class ProjectAccessDeniedError extends Error {
|
|
78
|
+
constructor(projectId: string | undefined, backendMessage: string | undefined);
|
|
79
|
+
}
|
|
80
|
+
export declare class AccountValidationRequiredError extends Error {
|
|
81
|
+
validationUrl?: string;
|
|
82
|
+
validationLearnMoreUrl?: string;
|
|
83
|
+
constructor(message: string, validationUrl?: string, validationLearnMoreUrl?: string);
|
|
84
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { OAuthAuthDetails } from "../types";
|
|
2
|
+
import { type CloudAiCompanionProject, type AgyIneligibleTier, type AgyUserTier } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Builds the metadata headers required for the Code Assist API.
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildMetadata(projectId?: string, includeDuetProject?: boolean): Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes project identifiers from API payloads or configuration.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeProjectId(value?: string | CloudAiCompanionProject): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Selects the default hierarchy ID from the allowed hierarchy list.
|
|
13
|
+
*/
|
|
14
|
+
export declare function pickOnboardTier(allowedTiers?: AgyUserTier[]): AgyUserTier;
|
|
15
|
+
/**
|
|
16
|
+
* Builds a concise error message for non-compliant hierarchy payloads.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildIneligibleTierMessage(tiers?: AgyIneligibleTier[]): string | undefined;
|
|
19
|
+
export declare function throwIfValidationRequired(tiers?: AgyIneligibleTier[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Detects VPC-SC errors from Cloud Code responses.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isVpcScError(payload: unknown): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Safely parses JSON, returning null on failure.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseJsonSafe(text: string): unknown;
|
|
28
|
+
/**
|
|
29
|
+
* Promise-based delay utility.
|
|
30
|
+
*/
|
|
31
|
+
export declare function wait(ms: number): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a cache key for the project context based on the refresh token.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getCacheKey(auth: OAuthAuthDetails): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config } from "./types";
|
|
2
|
+
import type { PluginClient, Provider } from "./types";
|
|
3
|
+
interface ResolveConfiguredProjectIdInput {
|
|
4
|
+
provider?: Provider | null;
|
|
5
|
+
config?: Config | null;
|
|
6
|
+
configProjectId?: string;
|
|
7
|
+
env?: NodeJS.ProcessEnv;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveConfiguredProjectId(input?: ResolveConfiguredProjectIdInput): string | undefined;
|
|
10
|
+
export declare function resolveConfiguredProjectIdFromConfig(config: Config | null | undefined): string | undefined;
|
|
11
|
+
export declare function resolveConfiguredProjectIdFromClient(client: PluginClient | null | undefined): Promise<string | undefined>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GetAuth, PluginClient } from "./types";
|
|
2
|
+
export declare const AGY_QUOTA_SUMMARY_TOOL_NAME = "agy_quota_summary";
|
|
3
|
+
export declare const AGY_V2_QUOTA_SUMMARY_COMMAND = "agy-quota-summary";
|
|
4
|
+
export declare const AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE = "Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.\n\nImmediately call `agy_quota_summary` with no arguments and return its output verbatim.\nDo not call other tools.\n";
|
|
5
|
+
interface AgyQuotaSummaryToolDependencies {
|
|
6
|
+
client: PluginClient;
|
|
7
|
+
getAuthResolver: () => GetAuth | undefined;
|
|
8
|
+
getConfiguredProjectId: () => string | undefined;
|
|
9
|
+
getUserAgentModel: () => string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function createAgyQuotaSummaryTool({ client, getAuthResolver, getConfiguredProjectId, getUserAgentModel, }: AgyQuotaSummaryToolDependencies): {
|
|
12
|
+
description: string;
|
|
13
|
+
args: {};
|
|
14
|
+
execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
2
|
+
export declare function pad(value: string, width: number): string;
|
|
3
|
+
export declare function buildProgressBar(fraction: number, width?: number): string;
|
|
4
|
+
export declare function formatRemainingAmount(value: string | undefined): string | undefined;
|
|
5
|
+
export declare function formatRelativeResetTime(resetTime: string | undefined): string | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GetAuth, PluginClient } from "./types";
|
|
2
|
+
export declare const AGY_QUOTA_TOOL_NAME = "agy_quota";
|
|
3
|
+
export declare const AGY_V2_QUOTA_COMMAND = "agy-quota";
|
|
4
|
+
export declare const AGY_V2_QUOTA_COMMAND_TEMPLATE = "Retrieve Agy Code Assist quota usage for the current authenticated account.\n\nImmediately call `agy_quota` with no arguments and return its output verbatim.\nDo not call other tools.\n";
|
|
5
|
+
interface AgyQuotaToolDependencies {
|
|
6
|
+
client: PluginClient;
|
|
7
|
+
getAuthResolver: () => GetAuth | undefined;
|
|
8
|
+
getConfiguredProjectId: () => string | undefined;
|
|
9
|
+
getUserAgentModel: () => string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function createAgyQuotaTool({ client, getAuthResolver, getConfiguredProjectId, getUserAgentModel, }: AgyQuotaToolDependencies): {
|
|
12
|
+
description: string;
|
|
13
|
+
args: {};
|
|
14
|
+
execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface SimpleStaticModel {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
maxTokens: number;
|
|
5
|
+
maxOutputTokens: number;
|
|
6
|
+
toolCall: boolean;
|
|
7
|
+
reasoning: boolean;
|
|
8
|
+
attachment: boolean;
|
|
9
|
+
cost?: {
|
|
10
|
+
input: number;
|
|
11
|
+
output: number;
|
|
12
|
+
cache?: {
|
|
13
|
+
read: number;
|
|
14
|
+
write: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare const STATIC_MODELS_SIMPLE: Record<string, SimpleStaticModel>;
|
|
19
|
+
export type TierName = 'minimal' | 'low' | 'medium' | 'high';
|
|
20
|
+
export type TierMap = Partial<Record<TierName, string>> & Record<string, string | undefined>;
|
|
21
|
+
export declare const TIER_MAPPING: Record<string, TierMap>;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves a model ID and optional request headers or suffix into the appropriate tier variant.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveModelTier(baseModelId: string, headersOrInit?: RequestInit | unknown, customTierMapping?: Readonly<Record<string, TierMap>>): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simulates the experimental fetch and metric telemetry traffic sent periodically by the official Agy client in the background to prevent API bans or anomaly detection.
|
|
3
|
+
*/
|
|
4
|
+
export declare function simulateClientBackgroundTraffic(accessToken: string, projectId: string, userAgentModel?: string): void;
|
|
5
|
+
export declare function buildTrajectoryAnalyticsBody(cascadeId?: `${string}-${string}-${string}-${string}-${string}`, platform?: string): {
|
|
6
|
+
trajectory: {
|
|
7
|
+
cascadeId: `${string}-${string}-${string}-${string}-${string}`;
|
|
8
|
+
executorMetadatas: {
|
|
9
|
+
cascadeConfig: {
|
|
10
|
+
agentApiConfig: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
};
|
|
13
|
+
checkpointConfig: {
|
|
14
|
+
checkpointModel: string;
|
|
15
|
+
strategy: string;
|
|
16
|
+
maxTokenLimit: string;
|
|
17
|
+
tokenThreshold: string;
|
|
18
|
+
maxOverheadRatio: string;
|
|
19
|
+
movingWindowSize: string;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
maxOutputTokens: string;
|
|
22
|
+
useLastPlannerModel: boolean;
|
|
23
|
+
isSync: boolean;
|
|
24
|
+
maxUserRequests: number;
|
|
25
|
+
includeLastUserMessage: boolean;
|
|
26
|
+
includeConversationLog: boolean;
|
|
27
|
+
includeRunningTaskSnapshots: boolean;
|
|
28
|
+
includeSubagentSnapshots: boolean;
|
|
29
|
+
includeArtifactSnapshots: boolean;
|
|
30
|
+
retryConfig: {
|
|
31
|
+
maxRetries: number;
|
|
32
|
+
initialSleepDurationMs: number;
|
|
33
|
+
exponentialMultiplier: number;
|
|
34
|
+
includeErrorFeedback: boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
mendelExperimentIds: never[];
|
|
41
|
+
metadata: {
|
|
42
|
+
ideType: string;
|
|
43
|
+
ideVersion: string;
|
|
44
|
+
platform: string;
|
|
45
|
+
};
|
|
46
|
+
startStepIndex: string;
|
|
47
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { OpencodeClient, Auth } from '@opencode-ai/sdk';
|
|
2
|
+
import type { Provider as ProviderV1 } from '@opencode-ai/sdk';
|
|
3
|
+
import type { Model as ModelV2 } from '@opencode-ai/sdk/v2';
|
|
4
|
+
import type { Hooks, Config as PluginConfig } from '@opencode-ai/plugin';
|
|
5
|
+
export type OAuthAuthDetails = Extract<Auth, {
|
|
6
|
+
type: 'oauth';
|
|
7
|
+
}>;
|
|
8
|
+
export type AuthDetails = Auth;
|
|
9
|
+
export type GetAuth = () => Promise<AuthDetails>;
|
|
10
|
+
export type Provider = ProviderV1;
|
|
11
|
+
export type ProviderModel = ModelV2;
|
|
12
|
+
export type Config = PluginConfig;
|
|
13
|
+
export interface LoaderResult {
|
|
14
|
+
apiKey: string;
|
|
15
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
16
|
+
}
|
|
17
|
+
export type PluginClient = OpencodeClient;
|
|
18
|
+
export interface PluginContext {
|
|
19
|
+
client: PluginClient;
|
|
20
|
+
}
|
|
21
|
+
export type PluginResult = Hooks;
|
|
22
|
+
export interface RefreshParts {
|
|
23
|
+
refreshToken: string;
|
|
24
|
+
projectId?: string;
|
|
25
|
+
managedProjectId?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ProjectContextResult {
|
|
28
|
+
auth: OAuthAuthDetails;
|
|
29
|
+
effectiveProjectId: string;
|
|
30
|
+
}
|
|
31
|
+
export type { Provider as ProviderV2, Model as ModelV2 } from '@opencode-ai/sdk/v2';
|
|
32
|
+
export interface OpenCodeV2TransformRegistry<T = any> {
|
|
33
|
+
transform: (fn: (target: T) => Promise<void> | void) => void;
|
|
34
|
+
reload?: () => Promise<void> | void;
|
|
35
|
+
}
|
|
36
|
+
export interface OpenCodeV2SessionRegistry {
|
|
37
|
+
hook: (name: string, handler: (...args: any[]) => any, options?: {
|
|
38
|
+
providerID?: string;
|
|
39
|
+
}) => void;
|
|
40
|
+
prompt?: (input: any) => Promise<any> | any;
|
|
41
|
+
}
|
|
42
|
+
export interface OpenCodeV2PluginLocation {
|
|
43
|
+
root?: string;
|
|
44
|
+
workspace?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface OpenCodeV2ConnectionService {
|
|
47
|
+
active?: (providerId: string) => Promise<any> | any;
|
|
48
|
+
resolve?: (connection: any) => Promise<any> | any;
|
|
49
|
+
}
|
|
50
|
+
export interface OpenCodeV2PluginContext {
|
|
51
|
+
catalog?: OpenCodeV2TransformRegistry;
|
|
52
|
+
provider?: OpenCodeV2TransformRegistry;
|
|
53
|
+
model?: OpenCodeV2TransformRegistry;
|
|
54
|
+
tool: OpenCodeV2TransformRegistry;
|
|
55
|
+
command: OpenCodeV2TransformRegistry;
|
|
56
|
+
session: OpenCodeV2SessionRegistry;
|
|
57
|
+
aisdk?: {
|
|
58
|
+
hook: (name: 'sdk' | 'language', handler: (event: any) => Promise<void> | void) => void;
|
|
59
|
+
};
|
|
60
|
+
integration?: (OpenCodeV2TransformRegistry | {
|
|
61
|
+
transform?: (transformer: (editor: any) => void) => void;
|
|
62
|
+
}) & {
|
|
63
|
+
connection?: OpenCodeV2ConnectionService;
|
|
64
|
+
};
|
|
65
|
+
event?: {
|
|
66
|
+
subscribe?: (fn: (event: any) => void) => (() => void) | void;
|
|
67
|
+
};
|
|
68
|
+
logger?: {
|
|
69
|
+
warn?: (...args: any[]) => void;
|
|
70
|
+
info?: (...args: any[]) => void;
|
|
71
|
+
error?: (...args: any[]) => void;
|
|
72
|
+
debug?: (...args: any[]) => void;
|
|
73
|
+
};
|
|
74
|
+
location: OpenCodeV2PluginLocation;
|
|
75
|
+
}
|
|
76
|
+
export interface OpenCodeV2PluginDefinition {
|
|
77
|
+
id: string;
|
|
78
|
+
setup: (ctx: OpenCodeV2PluginContext) => Promise<(() => void) | void> | (() => void) | void;
|
|
79
|
+
}
|
|
80
|
+
export interface DualOpenCodePlugin extends OpenCodeV2PluginDefinition {
|
|
81
|
+
server: (options: any) => Promise<any>;
|
|
82
|
+
}
|
|
83
|
+
export declare function defineOpenCodeV2Plugin(def: OpenCodeV2PluginDefinition): OpenCodeV2PluginDefinition;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type TierMap } from './tier';
|
|
2
|
+
export interface V2RuntimeCatalog {
|
|
3
|
+
enums?: Readonly<Record<string, string>>;
|
|
4
|
+
tierMapping?: Readonly<Record<string, TierMap>>;
|
|
5
|
+
variant?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createV2FetchInterceptor(getAuthSnapshot?: () => Promise<any> | any, getRuntimeCatalog?: () => Promise<V2RuntimeCatalog | undefined> | V2RuntimeCatalog | undefined): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { V2RuntimeCatalog } from './v2-fetch';
|
|
2
|
+
export type { V2RuntimeCatalog } from './v2-fetch';
|
|
3
|
+
export interface V2SessionHooksState {
|
|
4
|
+
lastInterceptedModel?: string;
|
|
5
|
+
lastSessionId?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createV2HttpRequestHook(state?: V2SessionHooksState, getRuntimeCatalog?: () => Promise<V2RuntimeCatalog | undefined> | V2RuntimeCatalog | undefined): (event: any) => Promise<void>;
|
|
8
|
+
export declare function createV2HttpResponseHook(state?: V2SessionHooksState): (event: any) => Promise<void>;
|
|
9
|
+
export declare function createV2RetryHook(): (event: any) => Promise<void>;
|
|
10
|
+
export declare function registerV2SessionHooks(ctx: any, getRuntimeCatalog?: () => Promise<V2RuntimeCatalog | undefined> | V2RuntimeCatalog | undefined): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AGY_V2_QUOTA_COMMAND, AGY_V2_QUOTA_COMMAND_TEMPLATE } from './quota';
|
|
2
|
+
import { AGY_V2_QUOTA_SUMMARY_COMMAND, AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE } from './quota-summary';
|
|
3
|
+
import { type OpenCodeV2PluginContext, type OpenCodeV2PluginDefinition } from './types';
|
|
4
|
+
export { getSafeHeader, setSafeHeaders, toUrlString } from './headers';
|
|
5
|
+
export { resolveModelTier } from './tier';
|
|
6
|
+
export { getDiskSignatureCache, resetDiskSignatureCacheForTesting } from './cache';
|
|
7
|
+
export { loadStoredAuthFromJson, saveStoredAuthToJson, setStoredAuthOverrideForTesting, } from './v2-storage';
|
|
8
|
+
export { createV2FetchInterceptor } from './v2-fetch';
|
|
9
|
+
export { AGY_V2_QUOTA_COMMAND, AGY_V2_QUOTA_SUMMARY_COMMAND, AGY_V2_QUOTA_COMMAND_TEMPLATE, AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE, };
|
|
10
|
+
/**
|
|
11
|
+
* Setup adapter for OpenCode v2 plugin architecture.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setupOpenCodeV2(ctx: OpenCodeV2PluginContext): Promise<(() => void) | void>;
|
|
14
|
+
export declare const v2PluginDefinition: OpenCodeV2PluginDefinition;
|
|
15
|
+
export declare const createV2PluginDefinition: () => OpenCodeV2PluginDefinition;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PluginContext, PluginResult } from './plugin/types';
|
|
2
|
+
import { STATIC_MODELS_SIMPLE, TIER_MAPPING, resolveModelTier, type SimpleStaticModel } from './plugin/tier';
|
|
3
|
+
export { STATIC_MODELS_SIMPLE, TIER_MAPPING, resolveModelTier, type SimpleStaticModel };
|
|
4
|
+
/**
|
|
5
|
+
* Registers the Agy OAuth provider for Opencode.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AgyCLIOAuthPlugin: ({ client }: PluginContext) => Promise<PluginResult>;
|
|
8
|
+
export declare const GoogleOAuthPlugin: typeof AgyCLIOAuthPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AGY_CLI_VERSION = "1.5.3";
|