antigravity-auth 1.6.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 +61 -0
- package/dist/antigravity/oauth.d.ts +30 -0
- package/dist/antigravity/oauth.js +170 -0
- package/dist/claude/login.d.ts +7 -0
- package/dist/claude/login.js +480 -0
- package/dist/claude/menu-helpers.d.ts +22 -0
- package/dist/claude/menu-helpers.js +281 -0
- package/dist/claude/proxy-manager.d.ts +11 -0
- package/dist/claude/proxy-manager.js +129 -0
- package/dist/claude/proxy.d.ts +1 -0
- package/dist/claude/proxy.js +733 -0
- package/dist/constants.d.ts +138 -0
- package/dist/constants.js +216 -0
- package/dist/hooks/auto-update-checker/cache.d.ts +2 -0
- package/dist/hooks/auto-update-checker/cache.js +70 -0
- package/dist/hooks/auto-update-checker/checker.d.ts +15 -0
- package/dist/hooks/auto-update-checker/checker.js +233 -0
- package/dist/hooks/auto-update-checker/constants.d.ts +8 -0
- package/dist/hooks/auto-update-checker/constants.js +22 -0
- package/dist/hooks/auto-update-checker/index.d.ts +33 -0
- package/dist/hooks/auto-update-checker/index.js +121 -0
- package/dist/hooks/auto-update-checker/logging.d.ts +2 -0
- package/dist/hooks/auto-update-checker/logging.js +8 -0
- package/dist/hooks/auto-update-checker/types.d.ts +24 -0
- package/dist/hooks/auto-update-checker/types.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/opencode/hooks/auto-update-checker/cache.d.ts +2 -0
- package/dist/opencode/hooks/auto-update-checker/cache.js +70 -0
- package/dist/opencode/hooks/auto-update-checker/checker.d.ts +15 -0
- package/dist/opencode/hooks/auto-update-checker/checker.js +233 -0
- package/dist/opencode/hooks/auto-update-checker/constants.d.ts +8 -0
- package/dist/opencode/hooks/auto-update-checker/constants.js +22 -0
- package/dist/opencode/hooks/auto-update-checker/index.d.ts +33 -0
- package/dist/opencode/hooks/auto-update-checker/index.js +121 -0
- package/dist/opencode/hooks/auto-update-checker/logging.d.ts +2 -0
- package/dist/opencode/hooks/auto-update-checker/logging.js +8 -0
- package/dist/opencode/hooks/auto-update-checker/types.d.ts +24 -0
- package/dist/opencode/hooks/auto-update-checker/types.js +1 -0
- package/dist/opencode/plugin.d.ts +29 -0
- package/dist/opencode/plugin.js +2954 -0
- package/dist/plugin/accounts.d.ts +173 -0
- package/dist/plugin/accounts.js +966 -0
- package/dist/plugin/auth.d.ts +20 -0
- package/dist/plugin/auth.js +44 -0
- package/dist/plugin/cache/index.d.ts +4 -0
- package/dist/plugin/cache/index.js +4 -0
- package/dist/plugin/cache/signature-cache.d.ts +110 -0
- package/dist/plugin/cache/signature-cache.js +347 -0
- package/dist/plugin/cache.d.ts +43 -0
- package/dist/plugin/cache.js +180 -0
- package/dist/plugin/cli.d.ts +26 -0
- package/dist/plugin/cli.js +126 -0
- package/dist/plugin/config/index.d.ts +15 -0
- package/dist/plugin/config/index.js +15 -0
- package/dist/plugin/config/loader.d.ts +38 -0
- package/dist/plugin/config/loader.js +150 -0
- package/dist/plugin/config/models.d.ts +26 -0
- package/dist/plugin/config/models.js +95 -0
- package/dist/plugin/config/schema.d.ts +144 -0
- package/dist/plugin/config/schema.js +458 -0
- package/dist/plugin/config/updater.d.ts +76 -0
- package/dist/plugin/config/updater.js +205 -0
- package/dist/plugin/core/streaming/index.d.ts +2 -0
- package/dist/plugin/core/streaming/index.js +2 -0
- package/dist/plugin/core/streaming/transformer.d.ts +9 -0
- package/dist/plugin/core/streaming/transformer.js +301 -0
- package/dist/plugin/core/streaming/types.d.ts +28 -0
- package/dist/plugin/core/streaming/types.js +1 -0
- package/dist/plugin/debug.d.ts +93 -0
- package/dist/plugin/debug.js +375 -0
- package/dist/plugin/errors.d.ts +27 -0
- package/dist/plugin/errors.js +41 -0
- package/dist/plugin/fingerprint.d.ts +69 -0
- package/dist/plugin/fingerprint.js +137 -0
- package/dist/plugin/image-saver.d.ts +24 -0
- package/dist/plugin/image-saver.js +78 -0
- package/dist/plugin/logger.d.ts +35 -0
- package/dist/plugin/logger.js +67 -0
- package/dist/plugin/logging-utils.d.ts +22 -0
- package/dist/plugin/logging-utils.js +91 -0
- package/dist/plugin/project.d.ts +32 -0
- package/dist/plugin/project.js +229 -0
- package/dist/plugin/quota.d.ts +34 -0
- package/dist/plugin/quota.js +261 -0
- package/dist/plugin/recovery/constants.d.ts +21 -0
- package/dist/plugin/recovery/constants.js +42 -0
- package/dist/plugin/recovery/index.d.ts +11 -0
- package/dist/plugin/recovery/index.js +11 -0
- package/dist/plugin/recovery/storage.d.ts +23 -0
- package/dist/plugin/recovery/storage.js +340 -0
- package/dist/plugin/recovery/types.d.ts +115 -0
- package/dist/plugin/recovery/types.js +6 -0
- package/dist/plugin/recovery.d.ts +60 -0
- package/dist/plugin/recovery.js +360 -0
- package/dist/plugin/refresh-queue.d.ts +99 -0
- package/dist/plugin/refresh-queue.js +235 -0
- package/dist/plugin/request-helpers.d.ts +281 -0
- package/dist/plugin/request-helpers.js +2200 -0
- package/dist/plugin/request.d.ts +110 -0
- package/dist/plugin/request.js +1489 -0
- package/dist/plugin/rotation.d.ts +182 -0
- package/dist/plugin/rotation.js +364 -0
- package/dist/plugin/search.d.ts +31 -0
- package/dist/plugin/search.js +185 -0
- package/dist/plugin/server.d.ts +22 -0
- package/dist/plugin/server.js +306 -0
- package/dist/plugin/storage.d.ts +136 -0
- package/dist/plugin/storage.js +599 -0
- package/dist/plugin/stores/signature-store.d.ts +4 -0
- package/dist/plugin/stores/signature-store.js +24 -0
- package/dist/plugin/thinking-recovery.d.ts +89 -0
- package/dist/plugin/thinking-recovery.js +289 -0
- package/dist/plugin/token.d.ts +18 -0
- package/dist/plugin/token.js +127 -0
- package/dist/plugin/transform/claude.d.ts +79 -0
- package/dist/plugin/transform/claude.js +256 -0
- package/dist/plugin/transform/cross-model-sanitizer.d.ts +34 -0
- package/dist/plugin/transform/cross-model-sanitizer.js +224 -0
- package/dist/plugin/transform/gemini.d.ts +132 -0
- package/dist/plugin/transform/gemini.js +659 -0
- package/dist/plugin/transform/index.d.ts +14 -0
- package/dist/plugin/transform/index.js +9 -0
- package/dist/plugin/transform/model-resolver.d.ts +98 -0
- package/dist/plugin/transform/model-resolver.js +320 -0
- package/dist/plugin/transform/types.d.ts +110 -0
- package/dist/plugin/transform/types.js +1 -0
- package/dist/plugin/types.d.ts +95 -0
- package/dist/plugin/types.js +1 -0
- package/dist/plugin/ui/ansi.d.ts +31 -0
- package/dist/plugin/ui/ansi.js +45 -0
- package/dist/plugin/ui/auth-menu.d.ts +47 -0
- package/dist/plugin/ui/auth-menu.js +199 -0
- package/dist/plugin/ui/confirm.d.ts +1 -0
- package/dist/plugin/ui/confirm.js +14 -0
- package/dist/plugin/ui/select.d.ts +22 -0
- package/dist/plugin/ui/select.js +243 -0
- package/dist/plugin/version.d.ts +18 -0
- package/dist/plugin/version.js +79 -0
- package/dist/src/antigravity/oauth.d.ts +30 -0
- package/dist/src/antigravity/oauth.js +170 -0
- package/dist/src/constants.d.ts +138 -0
- package/dist/src/constants.js +216 -0
- package/dist/src/hooks/auto-update-checker/cache.d.ts +2 -0
- package/dist/src/hooks/auto-update-checker/cache.js +70 -0
- package/dist/src/hooks/auto-update-checker/checker.d.ts +15 -0
- package/dist/src/hooks/auto-update-checker/checker.js +233 -0
- package/dist/src/hooks/auto-update-checker/constants.d.ts +8 -0
- package/dist/src/hooks/auto-update-checker/constants.js +22 -0
- package/dist/src/hooks/auto-update-checker/index.d.ts +33 -0
- package/dist/src/hooks/auto-update-checker/index.js +121 -0
- package/dist/src/hooks/auto-update-checker/logging.d.ts +2 -0
- package/dist/src/hooks/auto-update-checker/logging.js +8 -0
- package/dist/src/hooks/auto-update-checker/types.d.ts +24 -0
- package/dist/src/hooks/auto-update-checker/types.js +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +5 -0
- package/dist/src/plugin/accounts.d.ts +173 -0
- package/dist/src/plugin/accounts.js +966 -0
- package/dist/src/plugin/auth.d.ts +20 -0
- package/dist/src/plugin/auth.js +44 -0
- package/dist/src/plugin/cache/index.d.ts +4 -0
- package/dist/src/plugin/cache/index.js +4 -0
- package/dist/src/plugin/cache/signature-cache.d.ts +110 -0
- package/dist/src/plugin/cache/signature-cache.js +347 -0
- package/dist/src/plugin/cache.d.ts +43 -0
- package/dist/src/plugin/cache.js +180 -0
- package/dist/src/plugin/cli.d.ts +26 -0
- package/dist/src/plugin/cli.js +126 -0
- package/dist/src/plugin/config/index.d.ts +15 -0
- package/dist/src/plugin/config/index.js +15 -0
- package/dist/src/plugin/config/loader.d.ts +38 -0
- package/dist/src/plugin/config/loader.js +150 -0
- package/dist/src/plugin/config/models.d.ts +26 -0
- package/dist/src/plugin/config/models.js +95 -0
- package/dist/src/plugin/config/schema.d.ts +144 -0
- package/dist/src/plugin/config/schema.js +458 -0
- package/dist/src/plugin/config/updater.d.ts +76 -0
- package/dist/src/plugin/config/updater.js +205 -0
- package/dist/src/plugin/core/streaming/index.d.ts +2 -0
- package/dist/src/plugin/core/streaming/index.js +2 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts +9 -0
- package/dist/src/plugin/core/streaming/transformer.js +301 -0
- package/dist/src/plugin/core/streaming/types.d.ts +28 -0
- package/dist/src/plugin/core/streaming/types.js +1 -0
- package/dist/src/plugin/debug.d.ts +93 -0
- package/dist/src/plugin/debug.js +375 -0
- package/dist/src/plugin/errors.d.ts +27 -0
- package/dist/src/plugin/errors.js +41 -0
- package/dist/src/plugin/fingerprint.d.ts +69 -0
- package/dist/src/plugin/fingerprint.js +137 -0
- package/dist/src/plugin/image-saver.d.ts +24 -0
- package/dist/src/plugin/image-saver.js +78 -0
- package/dist/src/plugin/logger.d.ts +35 -0
- package/dist/src/plugin/logger.js +67 -0
- package/dist/src/plugin/logging-utils.d.ts +22 -0
- package/dist/src/plugin/logging-utils.js +91 -0
- package/dist/src/plugin/project.d.ts +32 -0
- package/dist/src/plugin/project.js +229 -0
- package/dist/src/plugin/quota.d.ts +34 -0
- package/dist/src/plugin/quota.js +261 -0
- package/dist/src/plugin/recovery/constants.d.ts +21 -0
- package/dist/src/plugin/recovery/constants.js +42 -0
- package/dist/src/plugin/recovery/index.d.ts +11 -0
- package/dist/src/plugin/recovery/index.js +11 -0
- package/dist/src/plugin/recovery/storage.d.ts +23 -0
- package/dist/src/plugin/recovery/storage.js +340 -0
- package/dist/src/plugin/recovery/types.d.ts +115 -0
- package/dist/src/plugin/recovery/types.js +6 -0
- package/dist/src/plugin/recovery.d.ts +60 -0
- package/dist/src/plugin/recovery.js +360 -0
- package/dist/src/plugin/refresh-queue.d.ts +99 -0
- package/dist/src/plugin/refresh-queue.js +235 -0
- package/dist/src/plugin/request-helpers.d.ts +281 -0
- package/dist/src/plugin/request-helpers.js +2200 -0
- package/dist/src/plugin/request.d.ts +110 -0
- package/dist/src/plugin/request.js +1489 -0
- package/dist/src/plugin/rotation.d.ts +182 -0
- package/dist/src/plugin/rotation.js +364 -0
- package/dist/src/plugin/search.d.ts +31 -0
- package/dist/src/plugin/search.js +185 -0
- package/dist/src/plugin/server.d.ts +22 -0
- package/dist/src/plugin/server.js +306 -0
- package/dist/src/plugin/storage.d.ts +136 -0
- package/dist/src/plugin/storage.js +599 -0
- package/dist/src/plugin/stores/signature-store.d.ts +4 -0
- package/dist/src/plugin/stores/signature-store.js +24 -0
- package/dist/src/plugin/thinking-recovery.d.ts +89 -0
- package/dist/src/plugin/thinking-recovery.js +289 -0
- package/dist/src/plugin/token.d.ts +18 -0
- package/dist/src/plugin/token.js +127 -0
- package/dist/src/plugin/transform/claude.d.ts +79 -0
- package/dist/src/plugin/transform/claude.js +256 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +34 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js +224 -0
- package/dist/src/plugin/transform/gemini.d.ts +132 -0
- package/dist/src/plugin/transform/gemini.js +659 -0
- package/dist/src/plugin/transform/index.d.ts +14 -0
- package/dist/src/plugin/transform/index.js +9 -0
- package/dist/src/plugin/transform/model-resolver.d.ts +98 -0
- package/dist/src/plugin/transform/model-resolver.js +320 -0
- package/dist/src/plugin/transform/types.d.ts +110 -0
- package/dist/src/plugin/transform/types.js +1 -0
- package/dist/src/plugin/types.d.ts +95 -0
- package/dist/src/plugin/types.js +1 -0
- package/dist/src/plugin/ui/ansi.d.ts +31 -0
- package/dist/src/plugin/ui/ansi.js +45 -0
- package/dist/src/plugin/ui/auth-menu.d.ts +47 -0
- package/dist/src/plugin/ui/auth-menu.js +199 -0
- package/dist/src/plugin/ui/confirm.d.ts +1 -0
- package/dist/src/plugin/ui/confirm.js +14 -0
- package/dist/src/plugin/ui/select.d.ts +22 -0
- package/dist/src/plugin/ui/select.js +243 -0
- package/dist/src/plugin/version.d.ts +18 -0
- package/dist/src/plugin/version.js +79 -0
- package/package.json +54 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME = "opencode-antigravity-auth";
|
|
2
|
+
export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org/-/package/opencode-antigravity-auth/dist-tags";
|
|
3
|
+
export declare const NPM_FETCH_TIMEOUT = 5000;
|
|
4
|
+
export declare const CACHE_DIR: string;
|
|
5
|
+
export declare const INSTALLED_PACKAGE_JSON: string;
|
|
6
|
+
export declare const USER_CONFIG_DIR: string;
|
|
7
|
+
export declare const USER_OPENCODE_CONFIG: string;
|
|
8
|
+
export declare const USER_OPENCODE_CONFIG_JSONC: string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
export const PACKAGE_NAME = "opencode-antigravity-auth";
|
|
4
|
+
export const NPM_REGISTRY_URL = `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags`;
|
|
5
|
+
export const NPM_FETCH_TIMEOUT = 5000;
|
|
6
|
+
function getCacheDir() {
|
|
7
|
+
if (process.platform === "win32") {
|
|
8
|
+
return path.join(process.env.LOCALAPPDATA ?? os.homedir(), "opencode");
|
|
9
|
+
}
|
|
10
|
+
return path.join(os.homedir(), ".cache", "opencode");
|
|
11
|
+
}
|
|
12
|
+
export const CACHE_DIR = getCacheDir();
|
|
13
|
+
export const INSTALLED_PACKAGE_JSON = path.join(CACHE_DIR, "node_modules", PACKAGE_NAME, "package.json");
|
|
14
|
+
function getUserConfigDir() {
|
|
15
|
+
if (process.platform === "win32") {
|
|
16
|
+
return process.env.APPDATA ?? path.join(os.homedir(), "AppData", "Roaming");
|
|
17
|
+
}
|
|
18
|
+
return process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config");
|
|
19
|
+
}
|
|
20
|
+
export const USER_CONFIG_DIR = getUserConfigDir();
|
|
21
|
+
export const USER_OPENCODE_CONFIG = path.join(USER_CONFIG_DIR, "opencode", "opencode.json");
|
|
22
|
+
export const USER_OPENCODE_CONFIG_JSONC = path.join(USER_CONFIG_DIR, "opencode", "opencode.jsonc");
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AutoUpdateCheckerOptions } from "./types";
|
|
2
|
+
interface PluginClient {
|
|
3
|
+
tui: {
|
|
4
|
+
showToast(options: {
|
|
5
|
+
body: {
|
|
6
|
+
title?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
variant: "info" | "warning" | "success" | "error";
|
|
9
|
+
duration?: number;
|
|
10
|
+
};
|
|
11
|
+
}): Promise<unknown>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface SessionCreatedEvent {
|
|
15
|
+
type: "session.created";
|
|
16
|
+
properties?: {
|
|
17
|
+
info?: {
|
|
18
|
+
parentID?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
type PluginEvent = SessionCreatedEvent | {
|
|
23
|
+
type: string;
|
|
24
|
+
properties?: unknown;
|
|
25
|
+
};
|
|
26
|
+
export declare function createAutoUpdateCheckerHook(client: PluginClient, directory: string, options?: AutoUpdateCheckerOptions): {
|
|
27
|
+
event: ({ event }: {
|
|
28
|
+
event: PluginEvent;
|
|
29
|
+
}) => void;
|
|
30
|
+
};
|
|
31
|
+
export type { UpdateCheckResult, AutoUpdateCheckerOptions } from "./types";
|
|
32
|
+
export { checkForUpdate, getCachedVersion, getLatestVersion } from "./checker";
|
|
33
|
+
export { invalidatePackage, invalidateCache } from "./cache";
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { getCachedVersion, getLocalDevVersion, findPluginEntry, getLatestVersion, updatePinnedVersion } from "./checker";
|
|
2
|
+
import { invalidatePackage } from "./cache";
|
|
3
|
+
import { PACKAGE_NAME } from "./constants";
|
|
4
|
+
import { logAutoUpdate } from "./logging";
|
|
5
|
+
export function createAutoUpdateCheckerHook(client, directory, options = {}) {
|
|
6
|
+
const { showStartupToast = true, autoUpdate = true } = options;
|
|
7
|
+
let hasChecked = false;
|
|
8
|
+
return {
|
|
9
|
+
event: ({ event }) => {
|
|
10
|
+
if (event.type !== "session.created")
|
|
11
|
+
return;
|
|
12
|
+
if (hasChecked)
|
|
13
|
+
return;
|
|
14
|
+
const props = event.properties;
|
|
15
|
+
if (props?.info?.parentID)
|
|
16
|
+
return;
|
|
17
|
+
hasChecked = true;
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
const localDevVersion = getLocalDevVersion(directory);
|
|
20
|
+
if (localDevVersion) {
|
|
21
|
+
if (showStartupToast) {
|
|
22
|
+
showLocalDevToast(client, localDevVersion).catch(() => { });
|
|
23
|
+
}
|
|
24
|
+
logAutoUpdate("Local development mode");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
runBackgroundUpdateCheck(client, directory, autoUpdate).catch((err) => {
|
|
28
|
+
logAutoUpdate(`Background update check failed: ${err}`);
|
|
29
|
+
});
|
|
30
|
+
}, 0);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function runBackgroundUpdateCheck(client, directory, autoUpdate) {
|
|
35
|
+
const pluginInfo = findPluginEntry(directory);
|
|
36
|
+
if (!pluginInfo) {
|
|
37
|
+
logAutoUpdate("Plugin not found in config");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const cachedVersion = getCachedVersion();
|
|
41
|
+
const currentVersion = cachedVersion ?? pluginInfo.pinnedVersion;
|
|
42
|
+
if (!currentVersion) {
|
|
43
|
+
logAutoUpdate("No version found (cached or pinned)");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (currentVersion.includes('-')) {
|
|
47
|
+
logAutoUpdate(`Prerelease version (${currentVersion}), skipping auto-update`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const latestVersion = await getLatestVersion();
|
|
51
|
+
if (!latestVersion) {
|
|
52
|
+
logAutoUpdate("Failed to fetch latest version");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (currentVersion === latestVersion) {
|
|
56
|
+
logAutoUpdate("Already on latest version");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
logAutoUpdate(`Update available: ${currentVersion} → ${latestVersion}`);
|
|
60
|
+
if (!autoUpdate) {
|
|
61
|
+
await showUpdateAvailableToast(client, latestVersion);
|
|
62
|
+
logAutoUpdate("Auto-update disabled, notification only");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (pluginInfo.isPinned) {
|
|
66
|
+
const updated = updatePinnedVersion(pluginInfo.configPath, pluginInfo.entry, latestVersion);
|
|
67
|
+
if (updated) {
|
|
68
|
+
invalidatePackage(PACKAGE_NAME);
|
|
69
|
+
await showAutoUpdatedToast(client, currentVersion, latestVersion);
|
|
70
|
+
logAutoUpdate(`Config updated: ${pluginInfo.entry} → ${PACKAGE_NAME}@${latestVersion}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
await showUpdateAvailableToast(client, latestVersion);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
invalidatePackage(PACKAGE_NAME);
|
|
78
|
+
await showUpdateAvailableToast(client, latestVersion);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function showUpdateAvailableToast(client, latestVersion) {
|
|
82
|
+
await client.tui
|
|
83
|
+
.showToast({
|
|
84
|
+
body: {
|
|
85
|
+
title: `Antigravity Auth Update`,
|
|
86
|
+
message: `v${latestVersion} available. Restart OpenCode to apply.`,
|
|
87
|
+
variant: "info",
|
|
88
|
+
duration: 8000,
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
.catch(() => { });
|
|
92
|
+
logAutoUpdate(`Update available toast shown: v${latestVersion}`);
|
|
93
|
+
}
|
|
94
|
+
async function showAutoUpdatedToast(client, oldVersion, newVersion) {
|
|
95
|
+
await client.tui
|
|
96
|
+
.showToast({
|
|
97
|
+
body: {
|
|
98
|
+
title: `Antigravity Auth Updated!`,
|
|
99
|
+
message: `v${oldVersion} → v${newVersion}\nRestart OpenCode to apply.`,
|
|
100
|
+
variant: "success",
|
|
101
|
+
duration: 8000,
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
.catch(() => { });
|
|
105
|
+
logAutoUpdate(`Auto-updated toast shown: v${oldVersion} → v${newVersion}`);
|
|
106
|
+
}
|
|
107
|
+
async function showLocalDevToast(client, version) {
|
|
108
|
+
await client.tui
|
|
109
|
+
.showToast({
|
|
110
|
+
body: {
|
|
111
|
+
title: `Antigravity Auth ${version} (dev)`,
|
|
112
|
+
message: "Running in local development mode.",
|
|
113
|
+
variant: "warning",
|
|
114
|
+
duration: 5000,
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
.catch(() => { });
|
|
118
|
+
logAutoUpdate(`Local dev toast shown: v${version}`);
|
|
119
|
+
}
|
|
120
|
+
export { checkForUpdate, getCachedVersion, getLatestVersion } from "./checker";
|
|
121
|
+
export { invalidatePackage, invalidateCache } from "./cache";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { debugLogToFile } from "../../plugin/debug";
|
|
2
|
+
const AUTO_UPDATE_LOG_PREFIX = "[auto-update-checker]";
|
|
3
|
+
export function formatAutoUpdateLogMessage(message) {
|
|
4
|
+
return `${AUTO_UPDATE_LOG_PREFIX} ${message}`;
|
|
5
|
+
}
|
|
6
|
+
export function logAutoUpdate(message) {
|
|
7
|
+
debugLogToFile(formatAutoUpdateLogMessage(message));
|
|
8
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface NpmDistTags {
|
|
2
|
+
latest: string;
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
}
|
|
5
|
+
export interface OpencodeConfig {
|
|
6
|
+
plugin?: string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface PackageJson {
|
|
10
|
+
version: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface UpdateCheckResult {
|
|
15
|
+
needsUpdate: boolean;
|
|
16
|
+
currentVersion: string | null;
|
|
17
|
+
latestVersion: string | null;
|
|
18
|
+
isLocalDev: boolean;
|
|
19
|
+
isPinned: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface AutoUpdateCheckerOptions {
|
|
22
|
+
showStartupToast?: boolean;
|
|
23
|
+
autoUpdate?: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin } from "./plugin";
|
|
2
|
+
export { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin };
|
|
3
|
+
export { authorizeAntigravity, exchangeAntigravity, } from "./antigravity/oauth";
|
|
4
|
+
export type { AntigravityAuthorization, AntigravityTokenExchangeResult, } from "./antigravity/oauth";
|
|
5
|
+
export default AntigravityCLIOAuthPlugin;
|
|
6
|
+
export declare const server: any;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin } from "./plugin";
|
|
2
|
+
export { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin };
|
|
3
|
+
export { authorizeAntigravity, exchangeAntigravity, } from "./antigravity/oauth";
|
|
4
|
+
export default AntigravityCLIOAuthPlugin;
|
|
5
|
+
export const server = AntigravityCLIOAuthPlugin;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { CACHE_DIR, PACKAGE_NAME } from "./constants";
|
|
4
|
+
function stripTrailingCommas(json) {
|
|
5
|
+
return json.replace(/,(\s*[}\]])/g, "$1");
|
|
6
|
+
}
|
|
7
|
+
function removeFromBunLock(packageName) {
|
|
8
|
+
const lockPath = path.join(CACHE_DIR, "bun.lock");
|
|
9
|
+
if (!fs.existsSync(lockPath))
|
|
10
|
+
return false;
|
|
11
|
+
try {
|
|
12
|
+
const content = fs.readFileSync(lockPath, "utf-8");
|
|
13
|
+
const lock = JSON.parse(stripTrailingCommas(content));
|
|
14
|
+
let modified = false;
|
|
15
|
+
if (lock.workspaces?.[""]?.dependencies?.[packageName]) {
|
|
16
|
+
delete lock.workspaces[""].dependencies[packageName];
|
|
17
|
+
modified = true;
|
|
18
|
+
}
|
|
19
|
+
if (lock.packages?.[packageName]) {
|
|
20
|
+
delete lock.packages[packageName];
|
|
21
|
+
modified = true;
|
|
22
|
+
}
|
|
23
|
+
if (modified) {
|
|
24
|
+
fs.writeFileSync(lockPath, JSON.stringify(lock, null, 2));
|
|
25
|
+
console.log(`[auto-update-checker] Removed from bun.lock: ${packageName}`);
|
|
26
|
+
}
|
|
27
|
+
return modified;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function invalidatePackage(packageName = PACKAGE_NAME) {
|
|
34
|
+
try {
|
|
35
|
+
const pkgDir = path.join(CACHE_DIR, "node_modules", packageName);
|
|
36
|
+
const pkgJsonPath = path.join(CACHE_DIR, "package.json");
|
|
37
|
+
let packageRemoved = false;
|
|
38
|
+
let dependencyRemoved = false;
|
|
39
|
+
let lockRemoved = false;
|
|
40
|
+
if (fs.existsSync(pkgDir)) {
|
|
41
|
+
fs.rmSync(pkgDir, { recursive: true, force: true });
|
|
42
|
+
console.log(`[auto-update-checker] Package removed: ${pkgDir}`);
|
|
43
|
+
packageRemoved = true;
|
|
44
|
+
}
|
|
45
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
46
|
+
const content = fs.readFileSync(pkgJsonPath, "utf-8");
|
|
47
|
+
const pkgJson = JSON.parse(content);
|
|
48
|
+
if (pkgJson.dependencies?.[packageName]) {
|
|
49
|
+
delete pkgJson.dependencies[packageName];
|
|
50
|
+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
51
|
+
console.log(`[auto-update-checker] Dependency removed from package.json: ${packageName}`);
|
|
52
|
+
dependencyRemoved = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
lockRemoved = removeFromBunLock(packageName);
|
|
56
|
+
if (!packageRemoved && !dependencyRemoved && !lockRemoved) {
|
|
57
|
+
console.log(`[auto-update-checker] Package not found, nothing to invalidate: ${packageName}`);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.error("[auto-update-checker] Failed to invalidate package:", err);
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function invalidateCache() {
|
|
68
|
+
console.warn("[auto-update-checker] WARNING: invalidateCache is deprecated, use invalidatePackage");
|
|
69
|
+
return invalidatePackage();
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UpdateCheckResult } from "./types";
|
|
2
|
+
export declare function isLocalDevMode(directory: string): boolean;
|
|
3
|
+
export declare function getLocalDevPath(directory: string): string | null;
|
|
4
|
+
export declare function getLocalDevVersion(directory: string): string | null;
|
|
5
|
+
export interface PluginEntryInfo {
|
|
6
|
+
entry: string;
|
|
7
|
+
isPinned: boolean;
|
|
8
|
+
pinnedVersion: string | null;
|
|
9
|
+
configPath: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function findPluginEntry(directory: string): PluginEntryInfo | null;
|
|
12
|
+
export declare function getCachedVersion(): string | null;
|
|
13
|
+
export declare function updatePinnedVersion(configPath: string, oldEntry: string, newVersion: string): boolean;
|
|
14
|
+
export declare function getLatestVersion(): Promise<string | null>;
|
|
15
|
+
export declare function checkForUpdate(directory: string): Promise<UpdateCheckResult>;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { PACKAGE_NAME, NPM_REGISTRY_URL, NPM_FETCH_TIMEOUT, INSTALLED_PACKAGE_JSON, USER_OPENCODE_CONFIG, USER_OPENCODE_CONFIG_JSONC, } from "./constants";
|
|
5
|
+
import { logAutoUpdate } from "./logging";
|
|
6
|
+
export function isLocalDevMode(directory) {
|
|
7
|
+
return getLocalDevPath(directory) !== null;
|
|
8
|
+
}
|
|
9
|
+
function stripJsonComments(json) {
|
|
10
|
+
return json
|
|
11
|
+
.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => (g ? "" : m))
|
|
12
|
+
.replace(/,(\s*[}\]])/g, "$1");
|
|
13
|
+
}
|
|
14
|
+
function getConfigPaths(directory) {
|
|
15
|
+
return [
|
|
16
|
+
path.join(directory, ".opencode", "opencode.json"),
|
|
17
|
+
path.join(directory, ".opencode", "opencode.jsonc"),
|
|
18
|
+
path.join(directory, ".opencode.json"),
|
|
19
|
+
USER_OPENCODE_CONFIG,
|
|
20
|
+
USER_OPENCODE_CONFIG_JSONC,
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
export function getLocalDevPath(directory) {
|
|
24
|
+
for (const configPath of getConfigPaths(directory)) {
|
|
25
|
+
try {
|
|
26
|
+
if (!fs.existsSync(configPath))
|
|
27
|
+
continue;
|
|
28
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
29
|
+
const config = JSON.parse(stripJsonComments(content));
|
|
30
|
+
const plugins = config.plugin ?? [];
|
|
31
|
+
for (const entry of plugins) {
|
|
32
|
+
if (entry.startsWith("file://") && entry.includes(PACKAGE_NAME)) {
|
|
33
|
+
try {
|
|
34
|
+
return fileURLToPath(entry);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return entry.replace("file://", "");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function findPackageJsonUp(startPath) {
|
|
49
|
+
try {
|
|
50
|
+
const stat = fs.statSync(startPath);
|
|
51
|
+
let dir = stat.isDirectory() ? startPath : path.dirname(startPath);
|
|
52
|
+
for (let i = 0; i < 10; i++) {
|
|
53
|
+
const pkgPath = path.join(dir, "package.json");
|
|
54
|
+
if (fs.existsSync(pkgPath)) {
|
|
55
|
+
try {
|
|
56
|
+
const content = fs.readFileSync(pkgPath, "utf-8");
|
|
57
|
+
const pkg = JSON.parse(content);
|
|
58
|
+
if (pkg.name === PACKAGE_NAME)
|
|
59
|
+
return pkgPath;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const parent = path.dirname(dir);
|
|
66
|
+
if (parent === dir)
|
|
67
|
+
break;
|
|
68
|
+
dir = parent;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
export function getLocalDevVersion(directory) {
|
|
77
|
+
const localPath = getLocalDevPath(directory);
|
|
78
|
+
if (!localPath)
|
|
79
|
+
return null;
|
|
80
|
+
try {
|
|
81
|
+
const pkgPath = findPackageJsonUp(localPath);
|
|
82
|
+
if (!pkgPath)
|
|
83
|
+
return null;
|
|
84
|
+
const content = fs.readFileSync(pkgPath, "utf-8");
|
|
85
|
+
const pkg = JSON.parse(content);
|
|
86
|
+
return pkg.version ?? null;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export function findPluginEntry(directory) {
|
|
93
|
+
for (const configPath of getConfigPaths(directory)) {
|
|
94
|
+
try {
|
|
95
|
+
if (!fs.existsSync(configPath))
|
|
96
|
+
continue;
|
|
97
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
98
|
+
const config = JSON.parse(stripJsonComments(content));
|
|
99
|
+
const plugins = config.plugin ?? [];
|
|
100
|
+
for (const entry of plugins) {
|
|
101
|
+
if (entry === PACKAGE_NAME) {
|
|
102
|
+
return { entry, isPinned: false, pinnedVersion: null, configPath };
|
|
103
|
+
}
|
|
104
|
+
if (entry.startsWith(`${PACKAGE_NAME}@`)) {
|
|
105
|
+
const pinnedVersion = entry.slice(PACKAGE_NAME.length + 1);
|
|
106
|
+
const isPinned = pinnedVersion !== "latest";
|
|
107
|
+
return { entry, isPinned, pinnedVersion: isPinned ? pinnedVersion : null, configPath };
|
|
108
|
+
}
|
|
109
|
+
if (entry.startsWith("file://") && entry.includes(PACKAGE_NAME)) {
|
|
110
|
+
return { entry, isPinned: false, pinnedVersion: null, configPath };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
export function getCachedVersion() {
|
|
121
|
+
try {
|
|
122
|
+
if (fs.existsSync(INSTALLED_PACKAGE_JSON)) {
|
|
123
|
+
const content = fs.readFileSync(INSTALLED_PACKAGE_JSON, "utf-8");
|
|
124
|
+
const pkg = JSON.parse(content);
|
|
125
|
+
if (pkg.version)
|
|
126
|
+
return pkg.version;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
134
|
+
const pkgPath = findPackageJsonUp(currentDir);
|
|
135
|
+
if (pkgPath) {
|
|
136
|
+
const content = fs.readFileSync(pkgPath, "utf-8");
|
|
137
|
+
const pkg = JSON.parse(content);
|
|
138
|
+
if (pkg.version)
|
|
139
|
+
return pkg.version;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
logAutoUpdate(`Failed to resolve version from current directory: ${err}`);
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
export function updatePinnedVersion(configPath, oldEntry, newVersion) {
|
|
148
|
+
try {
|
|
149
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
150
|
+
const newEntry = `${PACKAGE_NAME}@${newVersion}`;
|
|
151
|
+
const pluginMatch = content.match(/"plugin"\s*:\s*\[/);
|
|
152
|
+
if (!pluginMatch || pluginMatch.index === undefined) {
|
|
153
|
+
logAutoUpdate(`No "plugin" array found in ${configPath}`);
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const startIdx = pluginMatch.index + pluginMatch[0].length;
|
|
157
|
+
let bracketCount = 1;
|
|
158
|
+
let endIdx = startIdx;
|
|
159
|
+
for (let i = startIdx; i < content.length && bracketCount > 0; i++) {
|
|
160
|
+
if (content[i] === "[")
|
|
161
|
+
bracketCount++;
|
|
162
|
+
else if (content[i] === "]")
|
|
163
|
+
bracketCount--;
|
|
164
|
+
endIdx = i;
|
|
165
|
+
}
|
|
166
|
+
const before = content.slice(0, startIdx);
|
|
167
|
+
const pluginArrayContent = content.slice(startIdx, endIdx);
|
|
168
|
+
const after = content.slice(endIdx);
|
|
169
|
+
const escapedOldEntry = oldEntry.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
170
|
+
const regex = new RegExp(`["']${escapedOldEntry}["']`);
|
|
171
|
+
if (!regex.test(pluginArrayContent)) {
|
|
172
|
+
logAutoUpdate(`Entry "${oldEntry}" not found in plugin array of ${configPath}`);
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
const updatedPluginArray = pluginArrayContent.replace(regex, `"${newEntry}"`);
|
|
176
|
+
const updatedContent = before + updatedPluginArray + after;
|
|
177
|
+
if (updatedContent === content) {
|
|
178
|
+
logAutoUpdate(`No changes made to ${configPath}`);
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
fs.writeFileSync(configPath, updatedContent, "utf-8");
|
|
182
|
+
logAutoUpdate(`Updated ${configPath}: ${oldEntry} → ${newEntry}`);
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
console.error(`[auto-update-checker] Failed to update config file ${configPath}:`, err);
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
export async function getLatestVersion() {
|
|
191
|
+
const controller = new AbortController();
|
|
192
|
+
const timeoutId = setTimeout(() => controller.abort(), NPM_FETCH_TIMEOUT);
|
|
193
|
+
try {
|
|
194
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
195
|
+
signal: controller.signal,
|
|
196
|
+
headers: { Accept: "application/json" },
|
|
197
|
+
});
|
|
198
|
+
if (!response.ok)
|
|
199
|
+
return null;
|
|
200
|
+
const data = (await response.json());
|
|
201
|
+
return data.latest ?? null;
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
clearTimeout(timeoutId);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
export async function checkForUpdate(directory) {
|
|
211
|
+
if (isLocalDevMode(directory)) {
|
|
212
|
+
logAutoUpdate("Local dev mode detected, skipping update check");
|
|
213
|
+
return { needsUpdate: false, currentVersion: null, latestVersion: null, isLocalDev: true, isPinned: false };
|
|
214
|
+
}
|
|
215
|
+
const pluginInfo = findPluginEntry(directory);
|
|
216
|
+
if (!pluginInfo) {
|
|
217
|
+
logAutoUpdate("Plugin not found in config");
|
|
218
|
+
return { needsUpdate: false, currentVersion: null, latestVersion: null, isLocalDev: false, isPinned: false };
|
|
219
|
+
}
|
|
220
|
+
const currentVersion = getCachedVersion() ?? pluginInfo.pinnedVersion;
|
|
221
|
+
if (!currentVersion) {
|
|
222
|
+
logAutoUpdate("No version found (cached or pinned)");
|
|
223
|
+
return { needsUpdate: false, currentVersion: null, latestVersion: null, isLocalDev: false, isPinned: pluginInfo.isPinned };
|
|
224
|
+
}
|
|
225
|
+
const latestVersion = await getLatestVersion();
|
|
226
|
+
if (!latestVersion) {
|
|
227
|
+
logAutoUpdate("Failed to fetch latest version");
|
|
228
|
+
return { needsUpdate: false, currentVersion, latestVersion: null, isLocalDev: false, isPinned: pluginInfo.isPinned };
|
|
229
|
+
}
|
|
230
|
+
const needsUpdate = currentVersion !== latestVersion;
|
|
231
|
+
logAutoUpdate(`Current: ${currentVersion}, Latest: ${latestVersion}, NeedsUpdate: ${needsUpdate}`);
|
|
232
|
+
return { needsUpdate, currentVersion, latestVersion, isLocalDev: false, isPinned: pluginInfo.isPinned };
|
|
233
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME = "opencode-antigravity-auth";
|
|
2
|
+
export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org/-/package/opencode-antigravity-auth/dist-tags";
|
|
3
|
+
export declare const NPM_FETCH_TIMEOUT = 5000;
|
|
4
|
+
export declare const CACHE_DIR: string;
|
|
5
|
+
export declare const INSTALLED_PACKAGE_JSON: string;
|
|
6
|
+
export declare const USER_CONFIG_DIR: string;
|
|
7
|
+
export declare const USER_OPENCODE_CONFIG: string;
|
|
8
|
+
export declare const USER_OPENCODE_CONFIG_JSONC: string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
export const PACKAGE_NAME = "opencode-antigravity-auth";
|
|
4
|
+
export const NPM_REGISTRY_URL = `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags`;
|
|
5
|
+
export const NPM_FETCH_TIMEOUT = 5000;
|
|
6
|
+
function getCacheDir() {
|
|
7
|
+
if (process.platform === "win32") {
|
|
8
|
+
return path.join(process.env.LOCALAPPDATA ?? os.homedir(), "opencode");
|
|
9
|
+
}
|
|
10
|
+
return path.join(os.homedir(), ".cache", "opencode");
|
|
11
|
+
}
|
|
12
|
+
export const CACHE_DIR = getCacheDir();
|
|
13
|
+
export const INSTALLED_PACKAGE_JSON = path.join(CACHE_DIR, "node_modules", PACKAGE_NAME, "package.json");
|
|
14
|
+
function getUserConfigDir() {
|
|
15
|
+
if (process.platform === "win32") {
|
|
16
|
+
return process.env.APPDATA ?? path.join(os.homedir(), "AppData", "Roaming");
|
|
17
|
+
}
|
|
18
|
+
return process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config");
|
|
19
|
+
}
|
|
20
|
+
export const USER_CONFIG_DIR = getUserConfigDir();
|
|
21
|
+
export const USER_OPENCODE_CONFIG = path.join(USER_CONFIG_DIR, "opencode", "opencode.json");
|
|
22
|
+
export const USER_OPENCODE_CONFIG_JSONC = path.join(USER_CONFIG_DIR, "opencode", "opencode.jsonc");
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AutoUpdateCheckerOptions } from "./types";
|
|
2
|
+
interface PluginClient {
|
|
3
|
+
tui: {
|
|
4
|
+
showToast(options: {
|
|
5
|
+
body: {
|
|
6
|
+
title?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
variant: "info" | "warning" | "success" | "error";
|
|
9
|
+
duration?: number;
|
|
10
|
+
};
|
|
11
|
+
}): Promise<unknown>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface SessionCreatedEvent {
|
|
15
|
+
type: "session.created";
|
|
16
|
+
properties?: {
|
|
17
|
+
info?: {
|
|
18
|
+
parentID?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
type PluginEvent = SessionCreatedEvent | {
|
|
23
|
+
type: string;
|
|
24
|
+
properties?: unknown;
|
|
25
|
+
};
|
|
26
|
+
export declare function createAutoUpdateCheckerHook(client: PluginClient, directory: string, options?: AutoUpdateCheckerOptions): {
|
|
27
|
+
event: ({ event }: {
|
|
28
|
+
event: PluginEvent;
|
|
29
|
+
}) => void;
|
|
30
|
+
};
|
|
31
|
+
export type { UpdateCheckResult, AutoUpdateCheckerOptions } from "./types";
|
|
32
|
+
export { checkForUpdate, getCachedVersion, getLatestVersion } from "./checker";
|
|
33
|
+
export { invalidatePackage, invalidateCache } from "./cache";
|