opencode-antigravity-auth 1.6.0 → 2.0.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 +36 -12
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/src/antigravity/oauth.d.ts.map +1 -1
- package/dist/src/antigravity/oauth.js +25 -29
- package/dist/src/antigravity/oauth.js.map +1 -1
- package/dist/src/constants.d.ts +53 -25
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +66 -47
- package/dist/src/constants.js.map +1 -1
- package/dist/src/hooks/auto-update-checker/cache.js +1 -1
- package/dist/src/hooks/auto-update-checker/checker.d.ts +1 -1
- package/dist/src/hooks/auto-update-checker/checker.js +2 -2
- package/dist/src/hooks/auto-update-checker/index.d.ts +4 -4
- package/dist/src/hooks/auto-update-checker/index.js +6 -6
- package/dist/src/hooks/auto-update-checker/logging.js +1 -1
- package/dist/src/plugin/accounts.d.ts +8 -8
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +13 -7
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/auth.d.ts +1 -1
- package/dist/src/plugin/cache/index.d.ts +1 -1
- package/dist/src/plugin/cache/index.js +1 -1
- package/dist/src/plugin/cache/signature-cache.d.ts +1 -1
- package/dist/src/plugin/cache/signature-cache.js +1 -1
- package/dist/src/plugin/cache.d.ts +7 -5
- package/dist/src/plugin/cache.d.ts.map +1 -1
- package/dist/src/plugin/cache.js +20 -3
- package/dist/src/plugin/cache.js.map +1 -1
- package/dist/src/plugin/cli.d.ts +3 -3
- package/dist/src/plugin/cli.js +3 -3
- package/dist/src/plugin/config/index.d.ts +2 -2
- package/dist/src/plugin/config/index.js +2 -2
- package/dist/src/plugin/config/loader.d.ts +1 -1
- package/dist/src/plugin/config/loader.js +2 -2
- package/dist/src/plugin/config/models-v2.d.ts +36 -0
- package/dist/src/plugin/config/models-v2.d.ts.map +1 -0
- package/dist/src/plugin/config/models-v2.js +51 -0
- package/dist/src/plugin/config/models-v2.js.map +1 -0
- package/dist/src/plugin/config/models.d.ts +1 -1
- package/dist/src/plugin/config/updater.d.ts +16 -3
- package/dist/src/plugin/config/updater.d.ts.map +1 -1
- package/dist/src/plugin/config/updater.js +53 -10
- package/dist/src/plugin/config/updater.js.map +1 -1
- package/dist/src/plugin/core/streaming/index.d.ts +2 -2
- package/dist/src/plugin/core/streaming/index.js +2 -2
- package/dist/src/plugin/core/streaming/transformer.d.ts +1 -1
- package/dist/src/plugin/core/streaming/transformer.js +1 -1
- package/dist/src/plugin/debug.d.ts +1 -1
- package/dist/src/plugin/debug.js +2 -2
- package/dist/src/plugin/fingerprint.d.ts +8 -5
- package/dist/src/plugin/fingerprint.d.ts.map +1 -1
- package/dist/src/plugin/fingerprint.js +23 -41
- package/dist/src/plugin/fingerprint.js.map +1 -1
- package/dist/src/plugin/logger.d.ts +1 -1
- package/dist/src/plugin/logger.js +2 -2
- package/dist/src/plugin/project.d.ts +4 -4
- package/dist/src/plugin/project.d.ts.map +1 -1
- package/dist/src/plugin/project.js +95 -94
- package/dist/src/plugin/project.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +2 -2
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +12 -8
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/recovery/index.d.ts +3 -3
- package/dist/src/plugin/recovery/index.js +3 -3
- package/dist/src/plugin/recovery/storage.d.ts +1 -1
- package/dist/src/plugin/recovery/storage.js +1 -1
- package/dist/src/plugin/recovery.d.ts +3 -3
- package/dist/src/plugin/recovery.js +3 -3
- package/dist/src/plugin/refresh-queue.d.ts +2 -2
- package/dist/src/plugin/refresh-queue.js +2 -2
- package/dist/src/plugin/request-helpers.d.ts +1 -1
- package/dist/src/plugin/request-helpers.js +5 -5
- package/dist/src/plugin/request.d.ts +9 -6
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +23 -23
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/search.js +7 -7
- package/dist/src/plugin/search.js.map +1 -1
- package/dist/src/plugin/server.js +1 -1
- package/dist/src/plugin/storage.d.ts +3 -3
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +56 -67
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/stores/signature-store.d.ts +1 -1
- package/dist/src/plugin/token.d.ts +1 -1
- package/dist/src/plugin/token.js +5 -5
- package/dist/src/plugin/transform/claude.d.ts +1 -1
- package/dist/src/plugin/transform/claude.js +1 -1
- package/dist/src/plugin/transform/cross-model-sanitizer.js +2 -2
- package/dist/src/plugin/transform/gemini.d.ts +1 -1
- package/dist/src/plugin/transform/index.d.ts +9 -9
- package/dist/src/plugin/transform/index.js +4 -4
- package/dist/src/plugin/transform/model-resolver.d.ts +12 -1
- package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -1
- package/dist/src/plugin/transform/model-resolver.js +26 -4
- package/dist/src/plugin/transform/model-resolver.js.map +1 -1
- package/dist/src/plugin/transform/types.d.ts +1 -1
- package/dist/src/plugin/types.d.ts +26 -2
- package/dist/src/plugin/types.d.ts.map +1 -1
- package/dist/src/plugin/ui/auth-menu.d.ts +1 -1
- package/dist/src/plugin/ui/auth-menu.js +4 -4
- package/dist/src/plugin/ui/confirm.js +1 -1
- package/dist/src/plugin/ui/select.js +1 -1
- package/dist/src/plugin/version.d.ts +35 -6
- package/dist/src/plugin/version.d.ts.map +1 -1
- package/dist/src/plugin/version.js +138 -42
- package/dist/src/plugin/version.js.map +1 -1
- package/dist/src/plugin.d.ts +11 -7
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +89 -54
- package/dist/src/plugin.js.map +1 -1
- package/dist/src/v2.d.ts +4 -0
- package/dist/src/v2.d.ts.map +1 -0
- package/dist/src/v2.js +391 -0
- package/dist/src/v2.js.map +1 -0
- package/index.js +4 -0
- package/package.json +15 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models-v2.js","sourceRoot":"","sources":["../../../../src/plugin/config/models-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAiC,MAAM,aAAa,CAAA;AAEvF,4EAA4E;AAC5E,iFAAiF;AACjF,qEAAqE;AACrE,MAAM,kBAAkB,GAA6B;IACnD,kCAAkC,EAAE;QAClC,IAAI,EAAE,oCAAoC;QAC1C,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;QAC3C,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE;KAClE;IACD,oCAAoC,EAAE;QACpC,IAAI,EAAE,sCAAsC;QAC5C,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;QAC3C,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE;KAClE;IACD,iCAAiC,EAAE;QACjC,IAAI,EAAE,mCAAmC;QACzC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;QAC1C,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE;KAClE;IACD,mCAAmC,EAAE;QACnC,IAAI,EAAE,qCAAqC;QAC3C,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;QAC1C,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,E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,EAAE,EAAE,CAAC;QAC7D,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3E,EAAE,EAAE,OAAO;YACX,QAAQ,EAAE,QAAQ,CAAC,aAAa;gBAC9B,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,EAAE;gBAC/D,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE;SACpB,CAAC,CAAC;KACJ,CAAC,CAAC,CACJ,CAAA"}
|
|
@@ -8,9 +8,18 @@ export interface UpdateConfigResult {
|
|
|
8
8
|
configPath: string;
|
|
9
9
|
error?: string;
|
|
10
10
|
}
|
|
11
|
+
type PluginEntry = string | {
|
|
12
|
+
package: string;
|
|
13
|
+
options?: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
type LegacyPluginEntry = PluginEntry | [string, Record<string, unknown>];
|
|
11
16
|
export interface OpencodeConfig {
|
|
12
17
|
$schema?: string;
|
|
13
|
-
plugin?:
|
|
18
|
+
plugin?: LegacyPluginEntry[];
|
|
19
|
+
plugins?: PluginEntry[];
|
|
20
|
+
providers?: Record<string, Record<string, unknown> & {
|
|
21
|
+
models?: Record<string, unknown>;
|
|
22
|
+
}>;
|
|
14
23
|
provider?: {
|
|
15
24
|
google?: {
|
|
16
25
|
models?: Record<string, unknown>;
|
|
@@ -23,6 +32,8 @@ export interface OpencodeConfig {
|
|
|
23
32
|
export interface UpdateConfigOptions {
|
|
24
33
|
/** Override the config file path (for testing) */
|
|
25
34
|
configPath?: string;
|
|
35
|
+
/** V1 remains available for callers using the legacy entrypoint. */
|
|
36
|
+
version?: 1 | 2;
|
|
26
37
|
}
|
|
27
38
|
/**
|
|
28
39
|
* Get the opencode config directory path.
|
|
@@ -40,16 +51,18 @@ export declare function getOpencodeConfigPath(): string;
|
|
|
40
51
|
*
|
|
41
52
|
* This function:
|
|
42
53
|
* 1. Reads existing opencode.json/opencode.jsonc (or creates default structure)
|
|
43
|
-
* 2.
|
|
54
|
+
* 2. Ensures a plugin entry; V1 also writes its model definitions
|
|
44
55
|
* 3. Writes back to disk with proper formatting
|
|
45
56
|
*
|
|
46
57
|
* Preserves:
|
|
47
58
|
* - $schema and other top-level config keys
|
|
48
59
|
* - Non-google provider sections
|
|
49
|
-
* - Other settings within google provider (
|
|
60
|
+
* - Other settings within google provider (V1 replaces models)
|
|
61
|
+
* - All provider objects in V2, whose catalog is registered at runtime
|
|
50
62
|
*
|
|
51
63
|
* @param options - Optional configuration (e.g., custom configPath for testing)
|
|
52
64
|
* @returns UpdateConfigResult with success status and path
|
|
53
65
|
*/
|
|
54
66
|
export declare function updateOpencodeConfig(options?: UpdateConfigOptions): Promise<UpdateConfigResult>;
|
|
67
|
+
export {};
|
|
55
68
|
//# sourceMappingURL=updater.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../../../../src/plugin/config/updater.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../../../../src/plugin/config/updater.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,WAAW,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AACnF,KAAK,iBAAiB,GAAG,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAwBzE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC3F,QAAQ,CAAC,EAAE;QACT,MAAM,CAAC,EAAE;YACP,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CACjB;AAoBD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAa9C;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAoF7B"}
|
|
@@ -4,9 +4,33 @@
|
|
|
4
4
|
* Updates ~/.config/opencode/opencode.json(c) with plugin models.
|
|
5
5
|
*/
|
|
6
6
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
7
|
-
import { join, dirname } from "node:path";
|
|
7
|
+
import { join, dirname, isAbsolute, resolve } from "node:path";
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
|
-
import {
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { OPENCODE_MODEL_DEFINITIONS } from "./models.js";
|
|
11
|
+
function pluginPackage(entry) {
|
|
12
|
+
return typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : entry.package;
|
|
13
|
+
}
|
|
14
|
+
function isAntigravityEntry(entry, configPath) {
|
|
15
|
+
const name = pluginPackage(entry).replace(/^-/, "");
|
|
16
|
+
if (name === "opencode-antigravity-auth" || name.startsWith("opencode-antigravity-auth@"))
|
|
17
|
+
return true;
|
|
18
|
+
const path = name.startsWith("file:") ? fileURLToPath(name)
|
|
19
|
+
: isAbsolute(name) || name.startsWith(".") ? resolve(dirname(configPath), name) : undefined;
|
|
20
|
+
if (!path)
|
|
21
|
+
return false;
|
|
22
|
+
const manifest = join(path, "package.json");
|
|
23
|
+
if (existsSync(manifest)) {
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(readFileSync(manifest, "utf8")).name === "opencode-antigravity-auth";
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// An unrelated checkout's malformed manifest must not block config writes.
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return path.includes("opencode-antigravity-auth");
|
|
33
|
+
}
|
|
10
34
|
// =============================================================================
|
|
11
35
|
// Constants
|
|
12
36
|
// =============================================================================
|
|
@@ -23,6 +47,8 @@ function stripJsonCommentsAndTrailingCommas(json) {
|
|
|
23
47
|
* Get the opencode config directory path.
|
|
24
48
|
*/
|
|
25
49
|
export function getOpencodeConfigDir() {
|
|
50
|
+
if (process.env.OPENCODE_CONFIG_DIR)
|
|
51
|
+
return process.env.OPENCODE_CONFIG_DIR;
|
|
26
52
|
const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
|
|
27
53
|
return join(xdgConfig, "opencode");
|
|
28
54
|
}
|
|
@@ -52,13 +78,14 @@ export function getOpencodeConfigPath() {
|
|
|
52
78
|
*
|
|
53
79
|
* This function:
|
|
54
80
|
* 1. Reads existing opencode.json/opencode.jsonc (or creates default structure)
|
|
55
|
-
* 2.
|
|
81
|
+
* 2. Ensures a plugin entry; V1 also writes its model definitions
|
|
56
82
|
* 3. Writes back to disk with proper formatting
|
|
57
83
|
*
|
|
58
84
|
* Preserves:
|
|
59
85
|
* - $schema and other top-level config keys
|
|
60
86
|
* - Non-google provider sections
|
|
61
|
-
* - Other settings within google provider (
|
|
87
|
+
* - Other settings within google provider (V1 replaces models)
|
|
88
|
+
* - All provider objects in V2, whose catalog is registered at runtime
|
|
62
89
|
*
|
|
63
90
|
* @param options - Optional configuration (e.g., custom configPath for testing)
|
|
64
91
|
* @returns UpdateConfigResult with success status and path
|
|
@@ -74,22 +101,38 @@ export async function updateOpencodeConfig(options = {}) {
|
|
|
74
101
|
}
|
|
75
102
|
else {
|
|
76
103
|
// Create default config structure
|
|
77
|
-
config =
|
|
78
|
-
$schema: SCHEMA_URL,
|
|
79
|
-
plugin: [],
|
|
80
|
-
provider: {},
|
|
81
|
-
};
|
|
104
|
+
config = options.version === 2
|
|
105
|
+
? { $schema: SCHEMA_URL, plugins: [] }
|
|
106
|
+
: { $schema: SCHEMA_URL, plugin: [], provider: {} };
|
|
82
107
|
}
|
|
83
108
|
// Ensure $schema is set
|
|
84
109
|
if (!config.$schema) {
|
|
85
110
|
config.$schema = SCHEMA_URL;
|
|
86
111
|
}
|
|
112
|
+
if (options.version === 2) {
|
|
113
|
+
const legacyPlugins = Array.isArray(config.plugin) ? config.plugin : [];
|
|
114
|
+
// Ordered enable/disable entries can repeat intentionally in V2.
|
|
115
|
+
config.plugins = [
|
|
116
|
+
...legacyPlugins.map((entry) => Array.isArray(entry) ? { package: entry[0], options: entry[1] } : entry),
|
|
117
|
+
...(config.plugins ?? []),
|
|
118
|
+
];
|
|
119
|
+
delete config.plugin;
|
|
120
|
+
const hasPlugin = config.plugins.some((entry) => isAntigravityEntry(entry, configPath));
|
|
121
|
+
if (!hasPlugin)
|
|
122
|
+
config.plugins.push(PLUGIN_NAME);
|
|
123
|
+
// V2 contributes its catalog at runtime. Let Core migrate legacy provider
|
|
124
|
+
// objects: creating providers.google here would take precedence over the
|
|
125
|
+
// entire legacy Google provider and hide its settings and custom models.
|
|
126
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
127
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
128
|
+
return { success: true, configPath };
|
|
129
|
+
}
|
|
87
130
|
// Ensure plugin array exists and contains our plugin
|
|
88
131
|
if (!Array.isArray(config.plugin)) {
|
|
89
132
|
config.plugin = [];
|
|
90
133
|
}
|
|
91
134
|
// Check if plugin is already in the list (any version)
|
|
92
|
-
const hasPlugin = config.plugin.some((p) => p.includes("opencode-antigravity-auth"));
|
|
135
|
+
const hasPlugin = config.plugin.some((p) => pluginPackage(p).includes("opencode-antigravity-auth"));
|
|
93
136
|
if (!hasPlugin) {
|
|
94
137
|
config.plugin.push(PLUGIN_NAME);
|
|
95
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updater.js","sourceRoot":"","sources":["../../../../src/plugin/config/updater.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"updater.js","sourceRoot":"","sources":["../../../../src/plugin/config/updater.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM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CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC5B,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAC;QAC9B,CAAC;QAED,2CAA2C;QAC3C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,GAAG,0BAA0B,EAAE,CAAC;QAElE,iCAAiC;QACjC,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,uDAAuD;QACvD,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAEpE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,UAAU;SACX,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,UAAU;YACV,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './transformer';
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './transformer.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './transformer';
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './transformer.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SignatureStore, StreamingCallbacks, StreamingOptions, ThoughtBuffer } from './types';
|
|
1
|
+
import type { SignatureStore, StreamingCallbacks, StreamingOptions, ThoughtBuffer } from './types.js';
|
|
2
2
|
export declare function createThoughtBuffer(): ThoughtBuffer;
|
|
3
3
|
export declare function transformStreamingPayload(payload: string, transformThinkingParts?: (response: unknown) => unknown): string;
|
|
4
4
|
export declare function deduplicateThinkingText(response: unknown, sentBuffer: ThoughtBuffer, displayedThinkingHashes?: Set<string>): unknown;
|
package/dist/src/plugin/debug.js
CHANGED
|
@@ -2,8 +2,8 @@ import { createWriteStream, mkdirSync, readdirSync, statSync, unlinkSync } from
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { env } from "node:process";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
|
-
import { deriveDebugPolicy, formatAccountContextLabel, formatAccountLabel, formatBodyPreviewForLog, formatErrorForLog, isTruthyFlag, truncateTextForLog, } from "./logging-utils";
|
|
6
|
-
import { ensureGitignoreSync } from "./storage";
|
|
5
|
+
import { deriveDebugPolicy, formatAccountContextLabel, formatAccountLabel, formatBodyPreviewForLog, formatErrorForLog, isTruthyFlag, truncateTextForLog, } from "./logging-utils.js";
|
|
6
|
+
import { ensureGitignoreSync } from "./storage.js";
|
|
7
7
|
const MAX_BODY_PREVIEW_CHARS = 12000;
|
|
8
8
|
const MAX_BODY_LOG_CHARS = 50000;
|
|
9
9
|
export const DEBUG_MESSAGE_PREFIX = "[opencode-antigravity-auth debug]";
|
|
@@ -38,23 +38,26 @@ export interface FingerprintHeaders {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Generate a randomized device fingerprint.
|
|
41
|
-
* Each fingerprint represents a unique "device" identity.
|
|
41
|
+
* Each fingerprint represents a unique "device" identity. The userAgent is the
|
|
42
|
+
* shared Hub User-Agent because Cloud Code ties it to the release and build CL.
|
|
42
43
|
*/
|
|
43
44
|
export declare function generateFingerprint(): Fingerprint;
|
|
44
45
|
/**
|
|
45
46
|
* Collect fingerprint based on actual current system.
|
|
46
|
-
* Uses real OS info
|
|
47
|
+
* Uses real OS info for stored metadata; the userAgent is still the Hub User-Agent.
|
|
47
48
|
*/
|
|
48
49
|
export declare function collectCurrentFingerprint(): Fingerprint;
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
51
|
+
* Migrate a fingerprint's userAgent to the current Hub User-Agent.
|
|
52
|
+
* Saved fingerprints may carry a legacy `antigravity/<version> <os>/<arch>` agent or
|
|
53
|
+
* an older Hub release. Requests never send the stored value; this keeps storage in sync.
|
|
52
54
|
* Returns true if the userAgent was changed.
|
|
53
55
|
*/
|
|
54
56
|
export declare function updateFingerprintVersion(fingerprint: Fingerprint): boolean;
|
|
55
57
|
/**
|
|
56
58
|
* Build HTTP headers from a fingerprint object.
|
|
57
|
-
*
|
|
59
|
+
* The User-Agent is resolved at call time from the current Hub version, so a stale
|
|
60
|
+
* stored fingerprint userAgent is never sent.
|
|
58
61
|
*/
|
|
59
62
|
export declare function buildFingerprintHeaders(fingerprint: Fingerprint | null): Partial<FingerprintHeaders>;
|
|
60
63
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../../src/plugin/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../../src/plugin/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;CAChD;AAED,iEAAiE;AACjE,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;CACtB;AAkBD;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,CAajD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,WAAW,CAavD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAQ1E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAQpG;AAQD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CAKnD;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,IAAI,WAAW,CAG1D"}
|
|
@@ -9,31 +9,23 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import * as crypto from "node:crypto";
|
|
11
11
|
import * as os from "node:os";
|
|
12
|
-
import {
|
|
13
|
-
const OS_VERSIONS = {
|
|
14
|
-
darwin: ["10.15.7", "11.6.8", "12.6.3", "13.5.2", "14.2.1", "14.5"],
|
|
15
|
-
win32: ["10.0.19041", "10.0.19042", "10.0.19043", "10.0.22000", "10.0.22621", "10.0.22631"],
|
|
16
|
-
linux: ["5.15.0", "5.19.0", "6.1.0", "6.2.0", "6.5.0", "6.6.0"],
|
|
17
|
-
};
|
|
18
|
-
const ARCHITECTURES = ["x64", "arm64"];
|
|
19
|
-
const IDE_TYPES = [
|
|
20
|
-
"ANTIGRAVITY",
|
|
21
|
-
];
|
|
22
|
-
const PLATFORMS = [
|
|
23
|
-
"WINDOWS",
|
|
24
|
-
"MACOS",
|
|
25
|
-
];
|
|
12
|
+
import { getAntigravityUserAgent } from "../constants.js";
|
|
26
13
|
const SDK_CLIENTS = [
|
|
27
14
|
"google-cloud-sdk vscode_cloudshelleditor/0.1",
|
|
28
15
|
"google-cloud-sdk vscode/1.86.0",
|
|
29
16
|
"google-cloud-sdk vscode/1.87.0",
|
|
30
17
|
"google-cloud-sdk vscode/1.96.0",
|
|
31
18
|
];
|
|
19
|
+
/** Matches the Hub User-Agent, which always reports the darwin/arm64 manifest build. */
|
|
20
|
+
const HUB_METADATA_PLATFORM = "MACOS";
|
|
32
21
|
/** Maximum number of fingerprint versions to keep per account */
|
|
33
22
|
export const MAX_FINGERPRINT_HISTORY = 5;
|
|
34
23
|
function randomFrom(arr) {
|
|
35
24
|
return arr[Math.floor(Math.random() * arr.length)];
|
|
36
25
|
}
|
|
26
|
+
function platformToDisplayName(platform) {
|
|
27
|
+
return platform === "win32" ? "WINDOWS" : "MACOS";
|
|
28
|
+
}
|
|
37
29
|
function generateDeviceId() {
|
|
38
30
|
return crypto.randomUUID();
|
|
39
31
|
}
|
|
@@ -42,23 +34,18 @@ function generateSessionToken() {
|
|
|
42
34
|
}
|
|
43
35
|
/**
|
|
44
36
|
* Generate a randomized device fingerprint.
|
|
45
|
-
* Each fingerprint represents a unique "device" identity.
|
|
37
|
+
* Each fingerprint represents a unique "device" identity. The userAgent is the
|
|
38
|
+
* shared Hub User-Agent because Cloud Code ties it to the release and build CL.
|
|
46
39
|
*/
|
|
47
40
|
export function generateFingerprint() {
|
|
48
|
-
const platform = randomFrom(["darwin", "win32"]);
|
|
49
|
-
const arch = randomFrom(ARCHITECTURES);
|
|
50
|
-
const osVersion = randomFrom(OS_VERSIONS[platform] ?? OS_VERSIONS.darwin);
|
|
51
|
-
const matchingPlatform = platform === "win32"
|
|
52
|
-
? "WINDOWS"
|
|
53
|
-
: "MACOS";
|
|
54
41
|
return {
|
|
55
42
|
deviceId: generateDeviceId(),
|
|
56
43
|
sessionToken: generateSessionToken(),
|
|
57
|
-
userAgent:
|
|
44
|
+
userAgent: getAntigravityUserAgent(),
|
|
58
45
|
apiClient: randomFrom(SDK_CLIENTS),
|
|
59
46
|
clientMetadata: {
|
|
60
|
-
ideType:
|
|
61
|
-
platform:
|
|
47
|
+
ideType: "ANTIGRAVITY",
|
|
48
|
+
platform: HUB_METADATA_PLATFORM,
|
|
62
49
|
pluginType: "GEMINI",
|
|
63
50
|
},
|
|
64
51
|
createdAt: Date.now(),
|
|
@@ -66,52 +53,47 @@ export function generateFingerprint() {
|
|
|
66
53
|
}
|
|
67
54
|
/**
|
|
68
55
|
* Collect fingerprint based on actual current system.
|
|
69
|
-
* Uses real OS info
|
|
56
|
+
* Uses real OS info for stored metadata; the userAgent is still the Hub User-Agent.
|
|
70
57
|
*/
|
|
71
58
|
export function collectCurrentFingerprint() {
|
|
72
|
-
const platform = os.platform();
|
|
73
|
-
const arch = os.arch();
|
|
74
|
-
const matchingPlatform = platform === "win32"
|
|
75
|
-
? "WINDOWS"
|
|
76
|
-
: "MACOS";
|
|
77
59
|
return {
|
|
78
60
|
deviceId: generateDeviceId(),
|
|
79
61
|
sessionToken: generateSessionToken(),
|
|
80
|
-
userAgent:
|
|
62
|
+
userAgent: getAntigravityUserAgent(),
|
|
81
63
|
apiClient: "google-cloud-sdk vscode_cloudshelleditor/0.1",
|
|
82
64
|
clientMetadata: {
|
|
83
65
|
ideType: "ANTIGRAVITY",
|
|
84
|
-
platform:
|
|
66
|
+
platform: platformToDisplayName(os.platform()),
|
|
85
67
|
pluginType: "GEMINI",
|
|
86
68
|
},
|
|
87
69
|
createdAt: Date.now(),
|
|
88
70
|
};
|
|
89
71
|
}
|
|
90
72
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
73
|
+
* Migrate a fingerprint's userAgent to the current Hub User-Agent.
|
|
74
|
+
* Saved fingerprints may carry a legacy `antigravity/<version> <os>/<arch>` agent or
|
|
75
|
+
* an older Hub release. Requests never send the stored value; this keeps storage in sync.
|
|
93
76
|
* Returns true if the userAgent was changed.
|
|
94
77
|
*/
|
|
95
78
|
export function updateFingerprintVersion(fingerprint) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const match = fingerprint.userAgent.match(versionPattern);
|
|
99
|
-
if (!match || match[2] === currentVersion) {
|
|
79
|
+
const currentUserAgent = getAntigravityUserAgent();
|
|
80
|
+
if (fingerprint.userAgent === currentUserAgent) {
|
|
100
81
|
return false;
|
|
101
82
|
}
|
|
102
|
-
fingerprint.userAgent =
|
|
83
|
+
fingerprint.userAgent = currentUserAgent;
|
|
103
84
|
return true;
|
|
104
85
|
}
|
|
105
86
|
/**
|
|
106
87
|
* Build HTTP headers from a fingerprint object.
|
|
107
|
-
*
|
|
88
|
+
* The User-Agent is resolved at call time from the current Hub version, so a stale
|
|
89
|
+
* stored fingerprint userAgent is never sent.
|
|
108
90
|
*/
|
|
109
91
|
export function buildFingerprintHeaders(fingerprint) {
|
|
110
92
|
if (!fingerprint) {
|
|
111
93
|
return {};
|
|
112
94
|
}
|
|
113
95
|
return {
|
|
114
|
-
"User-Agent":
|
|
96
|
+
"User-Agent": getAntigravityUserAgent(),
|
|
115
97
|
};
|
|
116
98
|
}
|
|
117
99
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../../src/plugin/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../../src/plugin/fingerprint.ts"],"names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led independently
|
|
8
8
|
* - OPENCODE_ANTIGRAVITY_CONSOLE_LOG=1 → console output (independent of debug flags)
|
|
9
9
|
*/
|
|
10
|
-
import type { PluginClient } from "./types";
|
|
10
|
+
import type { PluginClient } from "./types.js";
|
|
11
11
|
export interface Logger {
|
|
12
12
|
debug(message: string, extra?: Record<string, unknown>): void;
|
|
13
13
|
info(message: string, extra?: Record<string, unknown>): void;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* - either sink can be enabled independently
|
|
8
8
|
* - OPENCODE_ANTIGRAVITY_CONSOLE_LOG=1 → console output (independent of debug flags)
|
|
9
9
|
*/
|
|
10
|
-
import { isDebugTuiEnabled } from "./debug";
|
|
11
|
-
import { isTruthyFlag, writeConsoleLog, } from "./logging-utils";
|
|
10
|
+
import { isDebugTuiEnabled } from "./debug.js";
|
|
11
|
+
import { isTruthyFlag, writeConsoleLog, } from "./logging-utils.js";
|
|
12
12
|
const ENV_CONSOLE_LOG = "OPENCODE_ANTIGRAVITY_CONSOLE_LOG";
|
|
13
13
|
let _client = null;
|
|
14
14
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OAuthAuthDetails, ProjectContextResult } from "./types";
|
|
1
|
+
import type { OAuthAuthDetails, ProjectContextResult } from "./types.js";
|
|
2
2
|
interface AntigravityUserTier {
|
|
3
3
|
id?: string;
|
|
4
4
|
isDefault?: boolean;
|
|
@@ -18,11 +18,11 @@ interface LoadCodeAssistPayload {
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function invalidateProjectContextCache(refresh?: string): void;
|
|
20
20
|
/**
|
|
21
|
-
* Loads managed project information for the given access token
|
|
21
|
+
* Loads managed project information for the given access token from the Antigravity host.
|
|
22
22
|
*/
|
|
23
|
-
export declare function loadManagedProject(accessToken: string
|
|
23
|
+
export declare function loadManagedProject(accessToken: string): Promise<LoadCodeAssistPayload | null>;
|
|
24
24
|
/**
|
|
25
|
-
* Onboards a managed project for the user,
|
|
25
|
+
* Onboards a managed project for the user, polling until the operation completes.
|
|
26
26
|
*/
|
|
27
27
|
export declare function onboardManagedProject(accessToken: string, tierId: string, projectId?: string, attempts?: number, delayMs?: number): Promise<string | undefined>;
|
|
28
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/plugin/project.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/plugin/project.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAmBtE,UAAU,mBAAmB;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C;AAED,UAAU,qBAAqB;IAC7B,uBAAuB,CAAC,EAAE,MAAM,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,WAAW,CAAC,EAAE;QACZ,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;IACF,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACtC;AA6ED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAQpE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CA0BnG;AAGD;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,SAAK,EACb,OAAO,SAAO,GACb,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA4C7B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA+FhG"}
|