@anthonyhaussman/opencode-agy-auth 1.5.9-alpha.0 → 1.5.18-alpha.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 +49 -17
- package/agy-plugin/agents/opencode.md +14 -0
- package/agy-plugin/bridge-proxy.mjs +92 -0
- package/agy-plugin/mcp_config.json +1 -0
- package/agy-plugin/plugin.json +5 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +7591 -6009
- package/dist/index.js.map +1 -1
- package/dist/sdk-placeholder.js +15 -0
- package/dist/sdk-placeholder.js.map +1 -0
- package/dist/src/acp/agy-plugin.d.ts +43 -0
- package/dist/src/acp/binary.d.ts +40 -0
- package/dist/src/acp/constants.d.ts +32 -0
- package/dist/src/acp/debug.d.ts +11 -0
- package/dist/src/acp/errors.d.ts +14 -0
- package/dist/src/acp/language-model.d.ts +35 -0
- package/dist/src/acp/live-session.d.ts +99 -0
- package/dist/src/acp/mcp-bridge.d.ts +66 -0
- package/dist/src/acp/permission.d.ts +9 -0
- package/dist/src/acp/process.d.ts +178 -0
- package/dist/src/acp/register-auth.d.ts +60 -0
- package/dist/src/acp/register-catalog.d.ts +32 -0
- package/dist/src/acp/register.d.ts +34 -0
- package/dist/src/acp/rpc.d.ts +35 -0
- package/dist/src/acp/sdk-placeholder.d.ts +4 -0
- package/dist/src/acp/session-lock.d.ts +16 -0
- package/dist/src/acp/session-sync.d.ts +40 -0
- package/dist/src/acp/stream-map.d.ts +40 -0
- package/dist/src/plugin/tos-warning.d.ts +4 -1
- package/dist/src/plugin/types.d.ts +55 -20
- package/dist/src/sdk/agy-cli-version.d.ts +1 -1
- package/package.json +11 -7
- package/dist/src/plugin.d.ts +0 -8
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { OpenCodeV2PluginContext, PluginClient } from "../plugin/types";
|
|
2
|
+
import { createAgyPluginInstaller } from "./agy-plugin";
|
|
3
|
+
import { listAgyModels, probeAgy } from "./binary";
|
|
4
|
+
import { type AgyAcpDeps } from "./language-model";
|
|
5
|
+
import { type AgyAcpStatus } from "./register-auth";
|
|
6
|
+
export type { AgyAcpStatus } from "./register-auth";
|
|
7
|
+
export type AgyAcpRegisterOverrides = Partial<AgyAcpDeps> & {
|
|
8
|
+
probe?: typeof probeAgy;
|
|
9
|
+
installer?: () => Promise<void>;
|
|
10
|
+
/** Model discovery via `agy models` (tests). */
|
|
11
|
+
listModels?: typeof listAgyModels;
|
|
12
|
+
/** Upper bound for how long setup waits for the first model discovery (tests). */
|
|
13
|
+
modelsStartupWaitMs?: number;
|
|
14
|
+
/** Extra options for the default agy plugin installer (tests). */
|
|
15
|
+
installerOptions?: Omit<Parameters<typeof createAgyPluginInstaller>[0], "agyPath" | "notify">;
|
|
16
|
+
/** Toast channel; defaults to `ctx.client` when the host provides one. */
|
|
17
|
+
client?: PluginClient;
|
|
18
|
+
};
|
|
19
|
+
export interface AgyAcpRegistration {
|
|
20
|
+
dispose(): Promise<void>;
|
|
21
|
+
/** Settles once the registration-time binary probe has finished. */
|
|
22
|
+
ready: Promise<void>;
|
|
23
|
+
/** Settles after the first `agy models` discovery attempt. */
|
|
24
|
+
modelsReady: Promise<void>;
|
|
25
|
+
status(): AgyAcpStatus;
|
|
26
|
+
deps: AgyAcpDeps;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Registers the google-agy-acp provider with OpenCode v2: catalog entries,
|
|
30
|
+
* auth integration, the AI SDK hook that supplies AgyAcpLanguageModel, and the
|
|
31
|
+
* session hooks. The binary probe runs here and on credential switch only; the
|
|
32
|
+
* agy plugin install runs lazily on the first turn.
|
|
33
|
+
*/
|
|
34
|
+
export declare function registerAgyAcpProvider(ctx: OpenCodeV2PluginContext, overrides?: AgyAcpRegisterOverrides): Promise<AgyAcpRegistration>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Readable, Writable } from "node:stream";
|
|
2
|
+
export declare class JsonRpcError extends Error {
|
|
3
|
+
code: number;
|
|
4
|
+
data?: unknown;
|
|
5
|
+
constructor(code: number, message: string, data?: unknown);
|
|
6
|
+
}
|
|
7
|
+
export interface RequestOptions {
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
/** Minimal JSON-RPC 2.0 connection over newline-delimited JSON streams. */
|
|
12
|
+
export declare class JsonRpcConnection {
|
|
13
|
+
private readonly output;
|
|
14
|
+
private readonly trace?;
|
|
15
|
+
readonly closed: Promise<Error | undefined>;
|
|
16
|
+
private nextId;
|
|
17
|
+
private isClosed;
|
|
18
|
+
private buffer;
|
|
19
|
+
private readonly pending;
|
|
20
|
+
private readonly notificationHandlers;
|
|
21
|
+
private readonly requestHandlers;
|
|
22
|
+
private resolveClosed;
|
|
23
|
+
constructor(input: Readable, output: Writable, trace?: ((direction: "out" | "in", line: string) => void) | undefined);
|
|
24
|
+
request<T>(method: string, params: unknown, opts?: RequestOptions): Promise<T>;
|
|
25
|
+
notify(method: string, params: unknown): void;
|
|
26
|
+
onNotification(method: string, handler: (params: any) => void): () => void;
|
|
27
|
+
onRequest(method: string, handler: (params: any) => unknown | Promise<unknown>): void;
|
|
28
|
+
close(reason?: Error): void;
|
|
29
|
+
private write;
|
|
30
|
+
private onData;
|
|
31
|
+
private onLine;
|
|
32
|
+
private dispatchNotification;
|
|
33
|
+
private dispatchRequest;
|
|
34
|
+
private dispatchResponse;
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type Waited<T> = {
|
|
2
|
+
kind: "done";
|
|
3
|
+
value: T;
|
|
4
|
+
} | {
|
|
5
|
+
kind: "aborted";
|
|
6
|
+
} | {
|
|
7
|
+
kind: "timeout";
|
|
8
|
+
};
|
|
9
|
+
/** Waits for `p`, bounded by an optional timeout and abort signal. */
|
|
10
|
+
export declare function waitBounded<T>(p: Promise<T>, signal: AbortSignal | undefined, timeoutMs?: number): Promise<Waited<T>>;
|
|
11
|
+
/**
|
|
12
|
+
* Serializes steps on one OpenCode session. Resolves with a release function,
|
|
13
|
+
* or undefined when `signal` aborted while waiting for the previous step.
|
|
14
|
+
*/
|
|
15
|
+
export declare function lockSession(owner: object, key: string, signal: AbortSignal | undefined): Promise<(() => void) | undefined>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { LanguageModelV3Message, LanguageModelV3Prompt } from "@ai-sdk/provider";
|
|
2
|
+
import type { BridgeToolDef, ToolOutcome } from "./mcp-bridge";
|
|
3
|
+
import type { AcpContentBlock } from "./process";
|
|
4
|
+
export interface SessionRecord {
|
|
5
|
+
agySessionId: string;
|
|
6
|
+
fingerprint: string;
|
|
7
|
+
messageHashes: string[];
|
|
8
|
+
interrupted: boolean;
|
|
9
|
+
updatedAt: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class SessionStore {
|
|
12
|
+
readonly filePath: string;
|
|
13
|
+
private chain;
|
|
14
|
+
constructor(filePath?: string);
|
|
15
|
+
private load;
|
|
16
|
+
private save;
|
|
17
|
+
private serialize;
|
|
18
|
+
get(id: string): Promise<SessionRecord | undefined>;
|
|
19
|
+
set(id: string, r: SessionRecord): Promise<void>;
|
|
20
|
+
delete(id: string): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare function hashMessage(m: LanguageModelV3Message): string;
|
|
23
|
+
export declare function fingerprintOf(system: string, tools: BridgeToolDef[], auth: {
|
|
24
|
+
method: string;
|
|
25
|
+
identity: string;
|
|
26
|
+
}, modelId: string, tier: string | undefined): string;
|
|
27
|
+
export declare function renderToolIndex(tools: BridgeToolDef[]): string;
|
|
28
|
+
export declare function renderCheckpoint(messages: LanguageModelV3Message[]): string;
|
|
29
|
+
export type SyncDecision = {
|
|
30
|
+
kind: "fresh" | "catch-up" | "changed";
|
|
31
|
+
blocks: AcpContentBlock[];
|
|
32
|
+
} | {
|
|
33
|
+
kind: "continue";
|
|
34
|
+
blocks: AcpContentBlock[];
|
|
35
|
+
toolResults: Array<{
|
|
36
|
+
toolCallId: string;
|
|
37
|
+
outcome: ToolOutcome;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
export declare function decideSync(record: SessionRecord | undefined, prompt: LanguageModelV3Prompt, fingerprint: string): SyncDecision;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { LanguageModelV3FinishReason, LanguageModelV3StreamPart, LanguageModelV3Usage } from "@ai-sdk/provider";
|
|
2
|
+
import type { BridgeCall } from "./mcp-bridge";
|
|
3
|
+
import type { AcpSessionUpdate, AcpToolCall, AcpUsage, PromptResult } from "./process";
|
|
4
|
+
export type ToolCallClass = {
|
|
5
|
+
kind: "bridge";
|
|
6
|
+
call: BridgeCall;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "builtin";
|
|
9
|
+
toolName: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "foreign-mcp";
|
|
12
|
+
serverName: string;
|
|
13
|
+
toolName: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "violation";
|
|
16
|
+
toolName: string;
|
|
17
|
+
};
|
|
18
|
+
export type MappedEvent = {
|
|
19
|
+
parts: LanguageModelV3StreamPart[];
|
|
20
|
+
bridgeCall?: BridgeCall;
|
|
21
|
+
violation?: {
|
|
22
|
+
toolName: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare function stripToolSummary(input: unknown): unknown;
|
|
26
|
+
export declare function classifyToolCall(tc: AcpToolCall): ToolCallClass;
|
|
27
|
+
export declare class StreamMapper {
|
|
28
|
+
private open?;
|
|
29
|
+
private counter;
|
|
30
|
+
private readonly seen;
|
|
31
|
+
private readonly providerCalls;
|
|
32
|
+
map(update: AcpSessionUpdate): MappedEvent;
|
|
33
|
+
flush(): LanguageModelV3StreamPart[];
|
|
34
|
+
private close;
|
|
35
|
+
private chunk;
|
|
36
|
+
private toolCall;
|
|
37
|
+
private toolUpdate;
|
|
38
|
+
}
|
|
39
|
+
export declare function mapStopReason(r: PromptResult["stopReason"]): LanguageModelV3FinishReason;
|
|
40
|
+
export declare function mapUsage(u?: AcpUsage): LanguageModelV3Usage;
|
|
@@ -2,12 +2,15 @@ import type { PluginClient } from "./types";
|
|
|
2
2
|
export declare const AGY_TOS_APPEAL_URL = "https://docs.google.com/forms/d/e/1FAIpQLScOJWibQ_-hYuVv63kJTgEqlgAaOwRLGFTbXm-QY1gz8U0CGA/viewform";
|
|
3
3
|
export declare const AGY_TOS_WARNING_TITLE = "Antigravity Terms of Service Risk";
|
|
4
4
|
export declare const AGY_TOS_WARNING: string;
|
|
5
|
+
export declare const AGY_ACP_TOS_WARNING: string;
|
|
5
6
|
/**
|
|
6
7
|
* Emits the Antigravity Terms of Service warning once per process.
|
|
7
8
|
* Always logs to the console; also shows an error toast when the client supports it.
|
|
8
9
|
*/
|
|
9
10
|
export declare function emitAgyTosWarning(client?: PluginClient): void;
|
|
11
|
+
/** Emits the google-agy-acp variant of the Terms of Service warning once per process. */
|
|
12
|
+
export declare function emitAgyAcpTosWarning(client?: PluginClient): void;
|
|
10
13
|
/**
|
|
11
|
-
* Resets the once-per-process
|
|
14
|
+
* Resets the once-per-process guards. Test-only.
|
|
12
15
|
*/
|
|
13
16
|
export declare function resetAgyTosWarningForTesting(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OpencodeClient, Auth } from '@opencode-ai/sdk';
|
|
2
2
|
import type { Provider as ProviderV1 } from '@opencode-ai/sdk';
|
|
3
3
|
import type { Model as ModelV2 } from '@opencode-ai/sdk/v2';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Config as PluginConfig } from '@opencode-ai/plugin';
|
|
5
5
|
export type OAuthAuthDetails = Extract<Auth, {
|
|
6
6
|
type: 'oauth';
|
|
7
7
|
}>;
|
|
@@ -10,15 +10,7 @@ export type GetAuth = () => Promise<AuthDetails>;
|
|
|
10
10
|
export type Provider = ProviderV1;
|
|
11
11
|
export type ProviderModel = ModelV2;
|
|
12
12
|
export type Config = PluginConfig;
|
|
13
|
-
export interface LoaderResult {
|
|
14
|
-
apiKey: string;
|
|
15
|
-
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
16
|
-
}
|
|
17
13
|
export type PluginClient = OpencodeClient;
|
|
18
|
-
export interface PluginContext {
|
|
19
|
-
client: PluginClient;
|
|
20
|
-
}
|
|
21
|
-
export type PluginResult = Hooks;
|
|
22
14
|
export interface RefreshParts {
|
|
23
15
|
refreshToken: string;
|
|
24
16
|
projectId?: string;
|
|
@@ -32,28 +24,74 @@ export type { Provider as ProviderV2, Model as ModelV2 } from '@opencode-ai/sdk/
|
|
|
32
24
|
export interface OpenCodeV2TransformRegistry<T = any> {
|
|
33
25
|
transform: (fn: (target: T) => Promise<void> | void) => void;
|
|
34
26
|
}
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
/**
|
|
28
|
+
* `session.hook("model.request")` event. OpenCode 2.3 triggers it before each
|
|
29
|
+
* model call; the published typings do not declare it yet, so it is typed here.
|
|
30
|
+
*/
|
|
31
|
+
export interface ModelRequestEvent {
|
|
32
|
+
sessionID: string;
|
|
33
|
+
kind: string;
|
|
34
|
+
baseURL: string;
|
|
35
|
+
headers: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
export interface OpenCodeV2SessionHook {
|
|
38
|
+
(name: 'model.request', handler: (ev: ModelRequestEvent) => void | Promise<void>, options?: {
|
|
37
39
|
providerID?: string;
|
|
38
|
-
})
|
|
40
|
+
}): unknown;
|
|
41
|
+
(name: string, handler: (...args: any[]) => any, options?: {
|
|
42
|
+
providerID?: string;
|
|
43
|
+
}): unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface OpenCodeV2SessionRegistry {
|
|
46
|
+
hook: OpenCodeV2SessionHook;
|
|
39
47
|
prompt?: (input: any) => Promise<any> | any;
|
|
40
48
|
}
|
|
41
49
|
export interface OpenCodeV2PluginLocation {
|
|
42
50
|
root?: string;
|
|
43
51
|
workspace?: string;
|
|
52
|
+
directory?: string;
|
|
53
|
+
/** Set when the session runs in a remote workspace. */
|
|
54
|
+
workspaceID?: string;
|
|
55
|
+
}
|
|
56
|
+
/** OpenCode 2.3 connection status: only `needs_auth` exists; `undefined` clears it. */
|
|
57
|
+
export interface OpenCodeV2ConnectionStatus {
|
|
58
|
+
status: 'needs_auth';
|
|
59
|
+
message: string;
|
|
60
|
+
url?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface OpenCodeV2IntegrationConnection {
|
|
63
|
+
active?: (integrationID: string) => Promise<any>;
|
|
64
|
+
resolve?: (connection: any) => Promise<any>;
|
|
65
|
+
status?: (input: {
|
|
66
|
+
integrationID: string;
|
|
67
|
+
connection: any;
|
|
68
|
+
status?: OpenCodeV2ConnectionStatus;
|
|
69
|
+
}) => Promise<void> | void;
|
|
44
70
|
}
|
|
45
71
|
export interface OpenCodeV2PluginContext {
|
|
46
|
-
catalog
|
|
47
|
-
|
|
48
|
-
|
|
72
|
+
/** `reload()` re-runs every catalog transform (OpenCode v2 promise plugins). */
|
|
73
|
+
catalog?: OpenCodeV2TransformRegistry & {
|
|
74
|
+
reload?: () => Promise<void> | void;
|
|
75
|
+
};
|
|
76
|
+
/** OpenCode 2.3.x exposes `reload()` here instead of on `catalog`. */
|
|
77
|
+
provider?: OpenCodeV2TransformRegistry & {
|
|
78
|
+
reload?: () => Promise<void> | void;
|
|
79
|
+
};
|
|
80
|
+
model?: OpenCodeV2TransformRegistry & {
|
|
81
|
+
reload?: () => Promise<void> | void;
|
|
82
|
+
};
|
|
49
83
|
tool: OpenCodeV2TransformRegistry;
|
|
50
84
|
command: OpenCodeV2TransformRegistry;
|
|
51
85
|
session: OpenCodeV2SessionRegistry;
|
|
52
86
|
aisdk?: {
|
|
53
|
-
hook: (name: 'sdk' | 'language', handler: (event: any) => Promise<void> | void) =>
|
|
87
|
+
hook: (name: 'sdk' | 'language', handler: (event: any) => Promise<void> | void) => Promise<{
|
|
88
|
+
dispose(): void;
|
|
89
|
+
} | void> | void;
|
|
54
90
|
};
|
|
55
|
-
integration?: OpenCodeV2TransformRegistry | {
|
|
91
|
+
integration?: (OpenCodeV2TransformRegistry | {
|
|
56
92
|
transform?: (transformer: (editor: any) => void) => void;
|
|
93
|
+
}) & {
|
|
94
|
+
connection?: OpenCodeV2IntegrationConnection;
|
|
57
95
|
};
|
|
58
96
|
location: OpenCodeV2PluginLocation;
|
|
59
97
|
}
|
|
@@ -61,7 +99,4 @@ export interface OpenCodeV2PluginDefinition {
|
|
|
61
99
|
id: string;
|
|
62
100
|
setup: (ctx: OpenCodeV2PluginContext) => Promise<void> | void;
|
|
63
101
|
}
|
|
64
|
-
export interface DualOpenCodePlugin extends OpenCodeV2PluginDefinition {
|
|
65
|
-
server: (options: any) => Promise<any>;
|
|
66
|
-
}
|
|
67
102
|
export declare function defineOpenCodeV2Plugin(def: OpenCodeV2PluginDefinition): OpenCodeV2PluginDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGY_CLI_VERSION = "1.5.
|
|
1
|
+
export declare const AGY_CLI_VERSION = "1.5.18";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthonyhaussman/opencode-agy-auth",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.18-alpha.0",
|
|
4
4
|
"author": "antigravity",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist",
|
|
22
|
+
"agy-plugin/",
|
|
22
23
|
"README.md"
|
|
23
24
|
],
|
|
24
25
|
"keywords": [
|
|
@@ -45,16 +46,19 @@
|
|
|
45
46
|
"prepack": "npm run build"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@opencode-ai/sdk": "^1.19.
|
|
49
|
-
"@types/node": "^26.6.
|
|
50
|
-
"@vitest/coverage-v8": "^5.1.
|
|
49
|
+
"@opencode-ai/sdk": "^1.19.6",
|
|
50
|
+
"@types/node": "^26.6.11",
|
|
51
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
51
52
|
"tsup": "^9.0.0",
|
|
52
53
|
"typescript": "^7.0.2",
|
|
53
|
-
"vitest": "^5.1.
|
|
54
|
+
"vitest": "^5.1.2"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@ai-sdk/google": "^4.0.
|
|
57
|
+
"@ai-sdk/google": "^4.0.128",
|
|
58
|
+
"@ai-sdk/provider": "4.0.39",
|
|
59
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
57
60
|
"@openauthjs/openauth": "^0.4.3",
|
|
58
|
-
"@opencode-ai/plugin": "^1.19.
|
|
61
|
+
"@opencode-ai/plugin": "^1.19.6",
|
|
62
|
+
"ajv": "^8.20.0"
|
|
59
63
|
}
|
|
60
64
|
}
|
package/dist/src/plugin.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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;
|