opencode-antigravity-auth 1.2.4 → 1.2.5-beta.1
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 +84 -1
- package/dist/src/constants.d.ts +7 -7
- package/dist/src/constants.js +7 -7
- package/dist/src/plugin/cache/index.d.ts +5 -0
- package/dist/src/plugin/cache/index.d.ts.map +1 -0
- package/dist/src/plugin/cache/index.js +5 -0
- package/dist/src/plugin/cache/index.js.map +1 -0
- package/dist/src/plugin/cache/signature-cache.d.ts +87 -0
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
- package/dist/src/plugin/cache/signature-cache.js +325 -0
- package/dist/src/plugin/cache/signature-cache.js.map +1 -0
- package/dist/src/plugin/cache.d.ts +16 -0
- package/dist/src/plugin/cache.d.ts.map +1 -1
- package/dist/src/plugin/cache.js +85 -23
- package/dist/src/plugin/cache.js.map +1 -1
- package/dist/src/plugin/config/index.d.ts +16 -0
- package/dist/src/plugin/config/index.d.ts.map +1 -0
- package/dist/src/plugin/config/index.js +16 -0
- package/dist/src/plugin/config/index.js.map +1 -0
- package/dist/src/plugin/config/loader.d.ts +35 -0
- package/dist/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/src/plugin/config/loader.js +173 -0
- package/dist/src/plugin/config/loader.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +162 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/src/plugin/config/schema.js +128 -0
- package/dist/src/plugin/config/schema.js.map +1 -0
- package/dist/src/plugin/debug.d.ts +8 -2
- package/dist/src/plugin/debug.d.ts.map +1 -1
- package/dist/src/plugin/debug.js +121 -70
- package/dist/src/plugin/debug.js.map +1 -1
- package/dist/src/plugin/recovery/constants.d.ts +22 -0
- package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
- package/dist/src/plugin/recovery/constants.js +43 -0
- package/dist/src/plugin/recovery/constants.js.map +1 -0
- package/dist/src/plugin/recovery/index.d.ts +12 -0
- package/dist/src/plugin/recovery/index.d.ts.map +1 -0
- package/dist/src/plugin/recovery/index.js +12 -0
- package/dist/src/plugin/recovery/index.js.map +1 -0
- package/dist/src/plugin/recovery/storage.d.ts +24 -0
- package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
- package/dist/src/plugin/recovery/storage.js +354 -0
- package/dist/src/plugin/recovery/storage.js.map +1 -0
- package/dist/src/plugin/recovery/types.d.ts +116 -0
- package/dist/src/plugin/recovery/types.d.ts.map +1 -0
- package/dist/src/plugin/recovery/types.js +6 -0
- package/dist/src/plugin/recovery/types.js.map +1 -0
- package/dist/src/plugin/recovery.d.ts +61 -0
- package/dist/src/plugin/recovery.d.ts.map +1 -0
- package/dist/src/plugin/recovery.js +347 -0
- package/dist/src/plugin/recovery.js.map +1 -0
- package/dist/src/plugin/request.d.ts +1 -0
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +37 -0
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/thinking-recovery.d.ts +64 -0
- package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
- package/dist/src/plugin/thinking-recovery.js +245 -0
- package/dist/src/plugin/thinking-recovery.js.map +1 -0
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +80 -4
- package/dist/src/plugin.js.map +1 -1
- package/package.json +4 -2
package/dist/src/plugin/cache.js
CHANGED
|
@@ -54,6 +54,10 @@ export function clearCachedAuth(refresh) {
|
|
|
54
54
|
authCache.delete(key);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// Thinking Signature Cache (for Claude multi-turn conversations)
|
|
59
|
+
// ============================================================================
|
|
60
|
+
import { SignatureCache, createSignatureCache } from "./cache/signature-cache";
|
|
57
61
|
// Map: sessionId -> Map<textHash, SignatureEntry>
|
|
58
62
|
const signatureCache = new Map();
|
|
59
63
|
// Cache entries expire after 1 hour
|
|
@@ -62,6 +66,22 @@ const SIGNATURE_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
|
62
66
|
const MAX_ENTRIES_PER_SESSION = 100;
|
|
63
67
|
// 16 hex chars = 64-bit key space; keeps memory bounded while making collisions extremely unlikely.
|
|
64
68
|
const SIGNATURE_TEXT_HASH_HEX_LEN = 16;
|
|
69
|
+
// Disk cache instance (initialized via initDiskSignatureCache)
|
|
70
|
+
let diskCache = null;
|
|
71
|
+
/**
|
|
72
|
+
* Initialize the disk-based signature cache.
|
|
73
|
+
* Call this from plugin initialization when keep_thinking is enabled.
|
|
74
|
+
*/
|
|
75
|
+
export function initDiskSignatureCache(config) {
|
|
76
|
+
diskCache = createSignatureCache(config);
|
|
77
|
+
return diskCache;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the disk cache instance (for testing/debugging).
|
|
81
|
+
*/
|
|
82
|
+
export function getDiskSignatureCache() {
|
|
83
|
+
return diskCache;
|
|
84
|
+
}
|
|
65
85
|
/**
|
|
66
86
|
* Hashes text content into a stable, Unicode-safe key.
|
|
67
87
|
*
|
|
@@ -70,69 +90,111 @@ const SIGNATURE_TEXT_HASH_HEX_LEN = 16;
|
|
|
70
90
|
function hashText(text) {
|
|
71
91
|
return createHash("sha256").update(text, "utf8").digest("hex").slice(0, SIGNATURE_TEXT_HASH_HEX_LEN);
|
|
72
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a disk cache key from sessionId and textHash.
|
|
95
|
+
*/
|
|
96
|
+
function makeDiskKey(sessionId, textHash) {
|
|
97
|
+
return `${sessionId}:${textHash}`;
|
|
98
|
+
}
|
|
73
99
|
/**
|
|
74
100
|
* Caches a thinking signature for a given session and text.
|
|
75
101
|
* Used for Claude models that require signed thinking blocks in multi-turn conversations.
|
|
102
|
+
* Also writes to disk cache if enabled.
|
|
76
103
|
*/
|
|
77
104
|
export function cacheSignature(sessionId, text, signature) {
|
|
78
105
|
if (!sessionId || !text || !signature)
|
|
79
106
|
return;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
107
|
+
const textHash = hashText(text);
|
|
108
|
+
// Write to memory cache
|
|
109
|
+
let sessionMemCache = signatureCache.get(sessionId);
|
|
110
|
+
if (!sessionMemCache) {
|
|
111
|
+
sessionMemCache = new Map();
|
|
112
|
+
signatureCache.set(sessionId, sessionMemCache);
|
|
84
113
|
}
|
|
85
114
|
// Evict old entries if we're at capacity
|
|
86
|
-
if (
|
|
115
|
+
if (sessionMemCache.size >= MAX_ENTRIES_PER_SESSION) {
|
|
87
116
|
const now = Date.now();
|
|
88
|
-
for (const [key, entry] of
|
|
117
|
+
for (const [key, entry] of sessionMemCache.entries()) {
|
|
89
118
|
if (now - entry.timestamp > SIGNATURE_CACHE_TTL_MS) {
|
|
90
|
-
|
|
119
|
+
sessionMemCache.delete(key);
|
|
91
120
|
}
|
|
92
121
|
}
|
|
93
122
|
// If still at capacity, remove oldest entries
|
|
94
|
-
if (
|
|
95
|
-
const entries = Array.from(
|
|
123
|
+
if (sessionMemCache.size >= MAX_ENTRIES_PER_SESSION) {
|
|
124
|
+
const entries = Array.from(sessionMemCache.entries())
|
|
96
125
|
.sort((a, b) => a[1].timestamp - b[1].timestamp);
|
|
97
126
|
const toRemove = entries.slice(0, Math.floor(MAX_ENTRIES_PER_SESSION / 4));
|
|
98
127
|
for (const [key] of toRemove) {
|
|
99
|
-
|
|
128
|
+
sessionMemCache.delete(key);
|
|
100
129
|
}
|
|
101
130
|
}
|
|
102
131
|
}
|
|
103
|
-
|
|
104
|
-
|
|
132
|
+
sessionMemCache.set(textHash, { signature, timestamp: Date.now() });
|
|
133
|
+
// Write to disk cache if enabled
|
|
134
|
+
if (diskCache) {
|
|
135
|
+
const diskKey = makeDiskKey(sessionId, textHash);
|
|
136
|
+
diskCache.store(diskKey, signature);
|
|
137
|
+
}
|
|
105
138
|
}
|
|
106
139
|
/**
|
|
107
140
|
* Retrieves a cached signature for a given session and text.
|
|
141
|
+
* Checks memory first, then falls back to disk cache.
|
|
108
142
|
* Returns undefined if not found or expired.
|
|
109
143
|
*/
|
|
110
144
|
export function getCachedSignature(sessionId, text) {
|
|
111
145
|
if (!sessionId || !text)
|
|
112
146
|
return undefined;
|
|
113
|
-
const sessionCache = signatureCache.get(sessionId);
|
|
114
|
-
if (!sessionCache)
|
|
115
|
-
return undefined;
|
|
116
147
|
const textHash = hashText(text);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
148
|
+
// Check memory cache first
|
|
149
|
+
const sessionMemCache = signatureCache.get(sessionId);
|
|
150
|
+
if (sessionMemCache) {
|
|
151
|
+
const entry = sessionMemCache.get(textHash);
|
|
152
|
+
if (entry) {
|
|
153
|
+
// Check if expired
|
|
154
|
+
if (Date.now() - entry.timestamp > SIGNATURE_CACHE_TTL_MS) {
|
|
155
|
+
sessionMemCache.delete(textHash);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
return entry.signature;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Fall back to disk cache
|
|
163
|
+
if (diskCache) {
|
|
164
|
+
const diskKey = makeDiskKey(sessionId, textHash);
|
|
165
|
+
const diskValue = diskCache.retrieve(diskKey);
|
|
166
|
+
if (diskValue) {
|
|
167
|
+
// Promote to memory cache for faster subsequent access
|
|
168
|
+
let memCache = signatureCache.get(sessionId);
|
|
169
|
+
if (!memCache) {
|
|
170
|
+
memCache = new Map();
|
|
171
|
+
signatureCache.set(sessionId, memCache);
|
|
172
|
+
}
|
|
173
|
+
memCache.set(textHash, { signature: diskValue, timestamp: Date.now() });
|
|
174
|
+
return diskValue;
|
|
175
|
+
}
|
|
124
176
|
}
|
|
125
|
-
return
|
|
177
|
+
return undefined;
|
|
126
178
|
}
|
|
127
179
|
/**
|
|
128
180
|
* Clears signature cache for a specific session or all sessions.
|
|
181
|
+
* Also clears from disk cache if enabled.
|
|
129
182
|
*/
|
|
130
183
|
export function clearSignatureCache(sessionId) {
|
|
131
184
|
if (sessionId) {
|
|
132
185
|
signatureCache.delete(sessionId);
|
|
186
|
+
// Note: We don't clear individual sessions from disk cache to avoid
|
|
187
|
+
// expensive iteration. Disk cache entries will expire naturally.
|
|
133
188
|
}
|
|
134
189
|
else {
|
|
135
190
|
signatureCache.clear();
|
|
191
|
+
// For full clear, we could clear disk cache, but leaving it for now
|
|
192
|
+
// since entries have TTL and will expire naturally.
|
|
136
193
|
}
|
|
137
194
|
}
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// Disk-Persistent Signature Cache (re-export from cache/ folder)
|
|
197
|
+
// ============================================================================
|
|
198
|
+
// Re-export SignatureCache class and factory for direct use
|
|
199
|
+
export { SignatureCache, createSignatureCache } from "./cache/signature-cache";
|
|
138
200
|
//# sourceMappingURL=cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/plugin/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAC;AAEtD;;GAEG;AACH,SAAS,mBAAmB,CAAC,OAAgB;IAC3C,MAAM,GAAG,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC;IAC5B,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAsB;IACtD,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,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C,IAAI,SAAS,EAAE,CAAC;YACd,uDAAuD;YACvD,IAAI,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;gBACrB,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC1C,CAAC;YACD,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACxE,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAkB;IACpD,IAAI,SAAS,EAAE,CAAC;QACd,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACjC,oEAAoE;QACpE,iEAAiE;IACnE,CAAC;SAAM,CAAC;QACN,cAAc,CAAC,KAAK,EAAE,CAAC;QACvB,oEAAoE;QACpE,oDAAoD;IACtD,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,iEAAiE;AACjE,+EAA+E;AAE/E,4DAA4D;AAC5D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration module for opencode-antigravity-auth plugin.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { loadConfig, type AntigravityConfig } from "./config";
|
|
7
|
+
*
|
|
8
|
+
* const config = loadConfig(directory);
|
|
9
|
+
* if (config.session_recovery) {
|
|
10
|
+
* // Enable session recovery
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export { AntigravityConfigSchema, SignatureCacheConfigSchema, DEFAULT_CONFIG, type AntigravityConfig, type SignatureCacheConfig, } from "./schema";
|
|
15
|
+
export { loadConfig, getUserConfigPath, getProjectConfigPath, getDefaultLogsDir, configExists, } from "./loader";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugin/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GACb,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration module for opencode-antigravity-auth plugin.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { loadConfig, type AntigravityConfig } from "./config";
|
|
7
|
+
*
|
|
8
|
+
* const config = loadConfig(directory);
|
|
9
|
+
* if (config.session_recovery) {
|
|
10
|
+
* // Enable session recovery
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export { AntigravityConfigSchema, SignatureCacheConfigSchema, DEFAULT_CONFIG, } from "./schema";
|
|
15
|
+
export { loadConfig, getUserConfigPath, getProjectConfigPath, getDefaultLogsDir, configExists, } from "./loader";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugin/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,cAAc,GAGf,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GACb,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration loader for opencode-antigravity-auth plugin.
|
|
3
|
+
*
|
|
4
|
+
* Loads config from files with environment variable overrides.
|
|
5
|
+
* Priority (lowest to highest):
|
|
6
|
+
* 1. Schema defaults
|
|
7
|
+
* 2. User config file
|
|
8
|
+
* 3. Project config file
|
|
9
|
+
* 4. Environment variables
|
|
10
|
+
*/
|
|
11
|
+
import { type AntigravityConfig } from "./schema";
|
|
12
|
+
/**
|
|
13
|
+
* Get the user-level config file path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getUserConfigPath(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Get the project-level config file path.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getProjectConfigPath(directory: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Load the complete configuration.
|
|
22
|
+
*
|
|
23
|
+
* @param directory - The project directory (for project-level config)
|
|
24
|
+
* @returns Fully resolved configuration
|
|
25
|
+
*/
|
|
26
|
+
export declare function loadConfig(directory: string): AntigravityConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a config file exists at the given path.
|
|
29
|
+
*/
|
|
30
|
+
export declare function configExists(path: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get the default logs directory.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getDefaultLogsDir(): string;
|
|
35
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/plugin/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAA2C,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAkB3F;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9D;AA2HD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAsB/D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration loader for opencode-antigravity-auth plugin.
|
|
3
|
+
*
|
|
4
|
+
* Loads config from files with environment variable overrides.
|
|
5
|
+
* Priority (lowest to highest):
|
|
6
|
+
* 1. Schema defaults
|
|
7
|
+
* 2. User config file
|
|
8
|
+
* 3. Project config file
|
|
9
|
+
* 4. Environment variables
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { homedir } from "node:os";
|
|
14
|
+
import { AntigravityConfigSchema, DEFAULT_CONFIG } from "./schema";
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// Path Utilities
|
|
17
|
+
// =============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Get the OS-specific config directory.
|
|
20
|
+
*/
|
|
21
|
+
function getConfigDir() {
|
|
22
|
+
const platform = process.platform;
|
|
23
|
+
if (platform === "win32") {
|
|
24
|
+
return join(process.env.APPDATA || join(homedir(), "AppData", "Roaming"), "opencode");
|
|
25
|
+
}
|
|
26
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
|
|
27
|
+
return join(xdgConfig, "opencode");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the user-level config file path.
|
|
31
|
+
*/
|
|
32
|
+
export function getUserConfigPath() {
|
|
33
|
+
return join(getConfigDir(), "antigravity.json");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the project-level config file path.
|
|
37
|
+
*/
|
|
38
|
+
export function getProjectConfigPath(directory) {
|
|
39
|
+
return join(directory, ".opencode", "antigravity.json");
|
|
40
|
+
}
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// Config Loading
|
|
43
|
+
// =============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* Load and parse a config file, returning null if not found or invalid.
|
|
46
|
+
*/
|
|
47
|
+
function loadConfigFile(path) {
|
|
48
|
+
try {
|
|
49
|
+
if (!existsSync(path)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const content = readFileSync(path, "utf-8");
|
|
53
|
+
const rawConfig = JSON.parse(content);
|
|
54
|
+
// Validate with Zod (partial - we'll merge with defaults later)
|
|
55
|
+
const result = AntigravityConfigSchema.partial().safeParse(rawConfig);
|
|
56
|
+
if (!result.success) {
|
|
57
|
+
console.warn(`[opencode-antigravity-auth] Config validation error in ${path}:`, result.error.issues.map(i => `${i.path.join(".")}: ${i.message}`).join(", "));
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return result.data;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (error instanceof SyntaxError) {
|
|
64
|
+
console.warn(`[opencode-antigravity-auth] Invalid JSON in ${path}:`, error.message);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.warn(`[opencode-antigravity-auth] Failed to load config from ${path}:`, error);
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Deep merge two config objects, with override taking precedence.
|
|
74
|
+
*/
|
|
75
|
+
function mergeConfigs(base, override) {
|
|
76
|
+
return {
|
|
77
|
+
...base,
|
|
78
|
+
...override,
|
|
79
|
+
// Deep merge signature_cache if both exist
|
|
80
|
+
signature_cache: override.signature_cache
|
|
81
|
+
? {
|
|
82
|
+
...base.signature_cache,
|
|
83
|
+
...override.signature_cache,
|
|
84
|
+
}
|
|
85
|
+
: base.signature_cache,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Apply environment variable overrides to config.
|
|
90
|
+
* Env vars always take precedence over config file values.
|
|
91
|
+
*/
|
|
92
|
+
function applyEnvOverrides(config) {
|
|
93
|
+
const env = process.env;
|
|
94
|
+
return {
|
|
95
|
+
...config,
|
|
96
|
+
// OPENCODE_ANTIGRAVITY_QUIET=1
|
|
97
|
+
quiet_mode: env.OPENCODE_ANTIGRAVITY_QUIET === "1" || env.OPENCODE_ANTIGRAVITY_QUIET === "true"
|
|
98
|
+
? true
|
|
99
|
+
: config.quiet_mode,
|
|
100
|
+
// OPENCODE_ANTIGRAVITY_DEBUG=1 or any truthy value
|
|
101
|
+
debug: env.OPENCODE_ANTIGRAVITY_DEBUG
|
|
102
|
+
? env.OPENCODE_ANTIGRAVITY_DEBUG !== "0" && env.OPENCODE_ANTIGRAVITY_DEBUG !== "false"
|
|
103
|
+
: config.debug,
|
|
104
|
+
// OPENCODE_ANTIGRAVITY_LOG_DIR=/path/to/logs
|
|
105
|
+
log_dir: env.OPENCODE_ANTIGRAVITY_LOG_DIR || config.log_dir,
|
|
106
|
+
// OPENCODE_ANTIGRAVITY_KEEP_THINKING=1
|
|
107
|
+
keep_thinking: env.OPENCODE_ANTIGRAVITY_KEEP_THINKING === "1" ||
|
|
108
|
+
env.OPENCODE_ANTIGRAVITY_KEEP_THINKING === "true"
|
|
109
|
+
? true
|
|
110
|
+
: config.keep_thinking,
|
|
111
|
+
// OPENCODE_ANTIGRAVITY_SESSION_RECOVERY=0 to disable
|
|
112
|
+
session_recovery: env.OPENCODE_ANTIGRAVITY_SESSION_RECOVERY === "0" ||
|
|
113
|
+
env.OPENCODE_ANTIGRAVITY_SESSION_RECOVERY === "false"
|
|
114
|
+
? false
|
|
115
|
+
: config.session_recovery,
|
|
116
|
+
// OPENCODE_ANTIGRAVITY_AUTO_RESUME=0 to disable auto-continue after recovery
|
|
117
|
+
auto_resume: env.OPENCODE_ANTIGRAVITY_AUTO_RESUME === "0" ||
|
|
118
|
+
env.OPENCODE_ANTIGRAVITY_AUTO_RESUME === "false"
|
|
119
|
+
? false
|
|
120
|
+
: env.OPENCODE_ANTIGRAVITY_AUTO_RESUME === "1" ||
|
|
121
|
+
env.OPENCODE_ANTIGRAVITY_AUTO_RESUME === "true"
|
|
122
|
+
? true
|
|
123
|
+
: config.auto_resume,
|
|
124
|
+
// OPENCODE_ANTIGRAVITY_RESUME_TEXT to customize resume text
|
|
125
|
+
resume_text: env.OPENCODE_ANTIGRAVITY_RESUME_TEXT || config.resume_text,
|
|
126
|
+
// OPENCODE_ANTIGRAVITY_AUTO_UPDATE=0 to disable
|
|
127
|
+
auto_update: env.OPENCODE_ANTIGRAVITY_AUTO_UPDATE === "0" ||
|
|
128
|
+
env.OPENCODE_ANTIGRAVITY_AUTO_UPDATE === "false"
|
|
129
|
+
? false
|
|
130
|
+
: config.auto_update,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// =============================================================================
|
|
134
|
+
// Main Loader
|
|
135
|
+
// =============================================================================
|
|
136
|
+
/**
|
|
137
|
+
* Load the complete configuration.
|
|
138
|
+
*
|
|
139
|
+
* @param directory - The project directory (for project-level config)
|
|
140
|
+
* @returns Fully resolved configuration
|
|
141
|
+
*/
|
|
142
|
+
export function loadConfig(directory) {
|
|
143
|
+
// Start with defaults
|
|
144
|
+
let config = { ...DEFAULT_CONFIG };
|
|
145
|
+
// Load user config file (if exists)
|
|
146
|
+
const userConfigPath = getUserConfigPath();
|
|
147
|
+
const userConfig = loadConfigFile(userConfigPath);
|
|
148
|
+
if (userConfig) {
|
|
149
|
+
config = mergeConfigs(config, userConfig);
|
|
150
|
+
}
|
|
151
|
+
// Load project config file (if exists) - overrides user config
|
|
152
|
+
const projectConfigPath = getProjectConfigPath(directory);
|
|
153
|
+
const projectConfig = loadConfigFile(projectConfigPath);
|
|
154
|
+
if (projectConfig) {
|
|
155
|
+
config = mergeConfigs(config, projectConfig);
|
|
156
|
+
}
|
|
157
|
+
// Apply environment variable overrides (always win)
|
|
158
|
+
config = applyEnvOverrides(config);
|
|
159
|
+
return config;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Check if a config file exists at the given path.
|
|
163
|
+
*/
|
|
164
|
+
export function configExists(path) {
|
|
165
|
+
return existsSync(path);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get the default logs directory.
|
|
169
|
+
*/
|
|
170
|
+
export function getDefaultLogsDir() {
|
|
171
|
+
return join(getConfigDir(), "antigravity-logs");
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../../src/plugin/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAA0B,MAAM,UAAU,CAAC;AAE3F,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;GAEG;AACH,SAAS,YAAY;IACnB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAA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,EAAE,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,oDAAoD;IACpD,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,CAAC,YAAY,EAAE,EAAE,kBAAkB,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration schema for opencode-antigravity-auth plugin.
|
|
3
|
+
*
|
|
4
|
+
* Config file locations (in priority order, highest wins):
|
|
5
|
+
* - Project: .opencode/antigravity.json
|
|
6
|
+
* - User: ~/.config/opencode/antigravity.json (Linux/Mac)
|
|
7
|
+
* %APPDATA%\opencode\antigravity.json (Windows)
|
|
8
|
+
*
|
|
9
|
+
* Environment variables always override config file values.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
/**
|
|
13
|
+
* Signature cache configuration for persisting thinking block signatures to disk.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SignatureCacheConfigSchema: z.ZodObject<{
|
|
16
|
+
/** Enable disk caching of signatures (default: true) */
|
|
17
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
/** In-memory TTL in seconds (default: 3600 = 1 hour) */
|
|
19
|
+
memory_ttl_seconds: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
/** Disk TTL in seconds (default: 172800 = 48 hours) */
|
|
21
|
+
disk_ttl_seconds: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
/** Background write interval in seconds (default: 60) */
|
|
23
|
+
write_interval_seconds: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
memory_ttl_seconds: number;
|
|
27
|
+
disk_ttl_seconds: number;
|
|
28
|
+
write_interval_seconds: number;
|
|
29
|
+
}, {
|
|
30
|
+
enabled?: boolean | undefined;
|
|
31
|
+
memory_ttl_seconds?: number | undefined;
|
|
32
|
+
disk_ttl_seconds?: number | undefined;
|
|
33
|
+
write_interval_seconds?: number | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Main configuration schema for the Antigravity OAuth plugin.
|
|
37
|
+
*/
|
|
38
|
+
export declare const AntigravityConfigSchema: z.ZodObject<{
|
|
39
|
+
/** JSON Schema reference for IDE support */
|
|
40
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
41
|
+
/**
|
|
42
|
+
* Suppress most toast notifications (rate limit, account switching, etc.)
|
|
43
|
+
* Recovery toasts are always shown regardless of this setting.
|
|
44
|
+
* Env override: OPENCODE_ANTIGRAVITY_QUIET=1
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
quiet_mode: z.ZodDefault<z.ZodBoolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Enable debug logging to file.
|
|
50
|
+
* Env override: OPENCODE_ANTIGRAVITY_DEBUG=1
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Custom directory for debug logs.
|
|
56
|
+
* Env override: OPENCODE_ANTIGRAVITY_LOG_DIR=/path/to/logs
|
|
57
|
+
* @default OS-specific config dir + "/antigravity-logs"
|
|
58
|
+
*/
|
|
59
|
+
log_dir: z.ZodOptional<z.ZodString>;
|
|
60
|
+
/**
|
|
61
|
+
* Preserve thinking blocks for Claude models using signature caching.
|
|
62
|
+
*
|
|
63
|
+
* When false (default): Thinking blocks are stripped for reliability.
|
|
64
|
+
* When true: Full context preserved, but may encounter signature errors.
|
|
65
|
+
*
|
|
66
|
+
* Env override: OPENCODE_ANTIGRAVITY_KEEP_THINKING=1
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
keep_thinking: z.ZodDefault<z.ZodBoolean>;
|
|
70
|
+
/**
|
|
71
|
+
* Enable automatic session recovery from tool_result_missing errors.
|
|
72
|
+
* When enabled, shows a toast notification when recoverable errors occur.
|
|
73
|
+
*
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
session_recovery: z.ZodDefault<z.ZodBoolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Automatically send a "continue" prompt after successful recovery.
|
|
79
|
+
* Only applies when session_recovery is enabled.
|
|
80
|
+
*
|
|
81
|
+
* When false: Only shows toast notification, user must manually continue.
|
|
82
|
+
* When true: Automatically sends "continue" to resume the session.
|
|
83
|
+
*
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
auto_resume: z.ZodDefault<z.ZodBoolean>;
|
|
87
|
+
/**
|
|
88
|
+
* Custom text to send when auto-resuming after recovery.
|
|
89
|
+
* Only used when auto_resume is enabled.
|
|
90
|
+
*
|
|
91
|
+
* @default "continue"
|
|
92
|
+
*/
|
|
93
|
+
resume_text: z.ZodDefault<z.ZodString>;
|
|
94
|
+
/**
|
|
95
|
+
* Signature cache configuration for persisting thinking block signatures.
|
|
96
|
+
* Only used when keep_thinking is enabled.
|
|
97
|
+
*/
|
|
98
|
+
signature_cache: z.ZodOptional<z.ZodObject<{
|
|
99
|
+
/** Enable disk caching of signatures (default: true) */
|
|
100
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
101
|
+
/** In-memory TTL in seconds (default: 3600 = 1 hour) */
|
|
102
|
+
memory_ttl_seconds: z.ZodDefault<z.ZodNumber>;
|
|
103
|
+
/** Disk TTL in seconds (default: 172800 = 48 hours) */
|
|
104
|
+
disk_ttl_seconds: z.ZodDefault<z.ZodNumber>;
|
|
105
|
+
/** Background write interval in seconds (default: 60) */
|
|
106
|
+
write_interval_seconds: z.ZodDefault<z.ZodNumber>;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
memory_ttl_seconds: number;
|
|
110
|
+
disk_ttl_seconds: number;
|
|
111
|
+
write_interval_seconds: number;
|
|
112
|
+
}, {
|
|
113
|
+
enabled?: boolean | undefined;
|
|
114
|
+
memory_ttl_seconds?: number | undefined;
|
|
115
|
+
disk_ttl_seconds?: number | undefined;
|
|
116
|
+
write_interval_seconds?: number | undefined;
|
|
117
|
+
}>>;
|
|
118
|
+
/**
|
|
119
|
+
* Enable automatic plugin updates.
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
auto_update: z.ZodDefault<z.ZodBoolean>;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
quiet_mode: boolean;
|
|
125
|
+
debug: boolean;
|
|
126
|
+
keep_thinking: boolean;
|
|
127
|
+
session_recovery: boolean;
|
|
128
|
+
auto_resume: boolean;
|
|
129
|
+
resume_text: string;
|
|
130
|
+
auto_update: boolean;
|
|
131
|
+
$schema?: string | undefined;
|
|
132
|
+
log_dir?: string | undefined;
|
|
133
|
+
signature_cache?: {
|
|
134
|
+
enabled: boolean;
|
|
135
|
+
memory_ttl_seconds: number;
|
|
136
|
+
disk_ttl_seconds: number;
|
|
137
|
+
write_interval_seconds: number;
|
|
138
|
+
} | undefined;
|
|
139
|
+
}, {
|
|
140
|
+
$schema?: string | undefined;
|
|
141
|
+
quiet_mode?: boolean | undefined;
|
|
142
|
+
debug?: boolean | undefined;
|
|
143
|
+
log_dir?: string | undefined;
|
|
144
|
+
keep_thinking?: boolean | undefined;
|
|
145
|
+
session_recovery?: boolean | undefined;
|
|
146
|
+
auto_resume?: boolean | undefined;
|
|
147
|
+
resume_text?: string | undefined;
|
|
148
|
+
signature_cache?: {
|
|
149
|
+
enabled?: boolean | undefined;
|
|
150
|
+
memory_ttl_seconds?: number | undefined;
|
|
151
|
+
disk_ttl_seconds?: number | undefined;
|
|
152
|
+
write_interval_seconds?: number | undefined;
|
|
153
|
+
} | undefined;
|
|
154
|
+
auto_update?: boolean | undefined;
|
|
155
|
+
}>;
|
|
156
|
+
export type AntigravityConfig = z.infer<typeof AntigravityConfigSchema>;
|
|
157
|
+
export type SignatureCacheConfig = z.infer<typeof SignatureCacheConfigSchema>;
|
|
158
|
+
/**
|
|
159
|
+
* Default configuration values.
|
|
160
|
+
*/
|
|
161
|
+
export declare const DEFAULT_CONFIG: AntigravityConfig;
|
|
162
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/plugin/config/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,0BAA0B;IACrC,wDAAwD;;IAGxD,wDAAwD;;IAGxD,uDAAuD;;IAGvD,yDAAyD;;;;;;;;;;;;EAEzD,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB;IAClC,4CAA4C;;IAO5C;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;OAIG;;IAOH;;;;;;;;OAQG;;IAOH;;;;;OAKG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;OAKG;;IAOH;;;OAGG;;QAnGH,wDAAwD;;QAGxD,wDAAwD;;QAGxD,uDAAuD;;QAGvD,yDAAyD;;;;;;;;;;;;;IAiGzD;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,iBAc5B,CAAC"}
|