opencode-antigravity-auth-remix 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +723 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/src/antigravity/oauth.d.ts +31 -0
- package/dist/src/antigravity/oauth.d.ts.map +1 -0
- package/dist/src/antigravity/oauth.js +168 -0
- package/dist/src/antigravity/oauth.js.map +1 -0
- package/dist/src/constants.d.ts +107 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +138 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
- package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/cache.js +71 -0
- package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
- package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/checker.js +237 -0
- package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/constants.d.ts +9 -0
- package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/constants.js +23 -0
- package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
- package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/index.js +125 -0
- package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
- package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
- package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
- package/dist/src/hooks/auto-update-checker/types.js +1 -0
- package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
- package/dist/src/plugin/accounts.d.ts +58 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -0
- package/dist/src/plugin/accounts.js +350 -0
- package/dist/src/plugin/accounts.js.map +1 -0
- package/dist/src/plugin/auth.d.ts +21 -0
- package/dist/src/plugin/auth.d.ts.map +1 -0
- package/dist/src/plugin/auth.js +46 -0
- package/dist/src/plugin/auth.js.map +1 -0
- 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 +111 -0
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
- package/dist/src/plugin/cache/signature-cache.js +373 -0
- package/dist/src/plugin/cache/signature-cache.js.map +1 -0
- package/dist/src/plugin/cache.d.ts +44 -0
- package/dist/src/plugin/cache.d.ts.map +1 -0
- package/dist/src/plugin/cache.js +200 -0
- package/dist/src/plugin/cache.js.map +1 -0
- package/dist/src/plugin/cli.d.ts +19 -0
- package/dist/src/plugin/cli.d.ts.map +1 -0
- package/dist/src/plugin/cli.js +59 -0
- package/dist/src/plugin/cli.js.map +1 -0
- 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 +178 -0
- package/dist/src/plugin/config/loader.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +257 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/src/plugin/config/schema.js +229 -0
- package/dist/src/plugin/config/schema.js.map +1 -0
- package/dist/src/plugin/core/streaming/index.d.ts +3 -0
- package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/index.js +3 -0
- package/dist/src/plugin/core/streaming/index.js.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts +9 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.js +134 -0
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
- package/dist/src/plugin/core/streaming/types.d.ts +26 -0
- package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/types.js +1 -0
- package/dist/src/plugin/core/streaming/types.js.map +1 -0
- package/dist/src/plugin/debug.d.ts +68 -0
- package/dist/src/plugin/debug.d.ts.map +1 -0
- package/dist/src/plugin/debug.js +321 -0
- package/dist/src/plugin/debug.js.map +1 -0
- package/dist/src/plugin/errors.d.ts +28 -0
- package/dist/src/plugin/errors.d.ts.map +1 -0
- package/dist/src/plugin/errors.js +42 -0
- package/dist/src/plugin/errors.js.map +1 -0
- package/dist/src/plugin/logger.d.ts +54 -0
- package/dist/src/plugin/logger.d.ts.map +1 -0
- package/dist/src/plugin/logger.js +120 -0
- package/dist/src/plugin/logger.js.map +1 -0
- package/dist/src/plugin/project.d.ts +33 -0
- package/dist/src/plugin/project.d.ts.map +1 -0
- package/dist/src/plugin/project.js +239 -0
- package/dist/src/plugin/project.js.map +1 -0
- 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 +376 -0
- package/dist/src/plugin/recovery.js.map +1 -0
- package/dist/src/plugin/refresh-queue.d.ts +101 -0
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
- package/dist/src/plugin/refresh-queue.js +244 -0
- package/dist/src/plugin/refresh-queue.js.map +1 -0
- package/dist/src/plugin/request-helpers.d.ts +270 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/src/plugin/request-helpers.js +2158 -0
- package/dist/src/plugin/request-helpers.js.map +1 -0
- package/dist/src/plugin/request.d.ts +87 -0
- package/dist/src/plugin/request.d.ts.map +1 -0
- package/dist/src/plugin/request.js +1233 -0
- package/dist/src/plugin/request.js.map +1 -0
- package/dist/src/plugin/search.d.ts +19 -0
- package/dist/src/plugin/search.d.ts.map +1 -0
- package/dist/src/plugin/search.js +191 -0
- package/dist/src/plugin/search.js.map +1 -0
- package/dist/src/plugin/server.d.ts +23 -0
- package/dist/src/plugin/server.d.ts.map +1 -0
- package/dist/src/plugin/server.js +222 -0
- package/dist/src/plugin/server.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +77 -0
- package/dist/src/plugin/storage.d.ts.map +1 -0
- package/dist/src/plugin/storage.js +207 -0
- package/dist/src/plugin/storage.js.map +1 -0
- package/dist/src/plugin/stores/signature-store.d.ts +5 -0
- package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
- package/dist/src/plugin/stores/signature-store.js +25 -0
- package/dist/src/plugin/stores/signature-store.js.map +1 -0
- package/dist/src/plugin/thinking-recovery.d.ts +90 -0
- package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
- package/dist/src/plugin/thinking-recovery.js +316 -0
- package/dist/src/plugin/thinking-recovery.js.map +1 -0
- package/dist/src/plugin/token.d.ts +19 -0
- package/dist/src/plugin/token.d.ts.map +1 -0
- package/dist/src/plugin/token.js +128 -0
- package/dist/src/plugin/token.js.map +1 -0
- package/dist/src/plugin/transform/claude.d.ts +80 -0
- package/dist/src/plugin/transform/claude.d.ts.map +1 -0
- package/dist/src/plugin/transform/claude.js +265 -0
- package/dist/src/plugin/transform/claude.js.map +1 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
- package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
- package/dist/src/plugin/transform/gemini.d.ts +63 -0
- package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
- package/dist/src/plugin/transform/gemini.js +142 -0
- package/dist/src/plugin/transform/gemini.js.map +1 -0
- package/dist/src/plugin/transform/index.d.ts +14 -0
- package/dist/src/plugin/transform/index.d.ts.map +1 -0
- package/dist/src/plugin/transform/index.js +14 -0
- package/dist/src/plugin/transform/index.js.map +1 -0
- package/dist/src/plugin/transform/model-resolver.d.ts +78 -0
- package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/src/plugin/transform/model-resolver.js +221 -0
- package/dist/src/plugin/transform/model-resolver.js.map +1 -0
- package/dist/src/plugin/transform/types.d.ts +93 -0
- package/dist/src/plugin/transform/types.d.ts.map +1 -0
- package/dist/src/plugin/transform/types.js +1 -0
- package/dist/src/plugin/transform/types.js.map +1 -0
- package/dist/src/plugin/types.d.ts +97 -0
- package/dist/src/plugin/types.d.ts.map +1 -0
- package/dist/src/plugin/types.js +1 -0
- package/dist/src/plugin/types.js.map +1 -0
- package/dist/src/plugin.d.ts +8 -0
- package/dist/src/plugin.d.ts.map +1 -0
- package/dist/src/plugin.js +1845 -0
- package/dist/src/plugin.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,229 @@
|
|
|
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 const SignatureCacheConfigSchema = z.object({
|
|
16
|
+
/** Enable disk caching of signatures (default: true) */
|
|
17
|
+
enabled: z.boolean().default(true),
|
|
18
|
+
/** In-memory TTL in seconds (default: 3600 = 1 hour) */
|
|
19
|
+
memory_ttl_seconds: z.number().min(60).max(86400).default(3600),
|
|
20
|
+
/** Disk TTL in seconds (default: 172800 = 48 hours) */
|
|
21
|
+
disk_ttl_seconds: z.number().min(3600).max(604800).default(172800),
|
|
22
|
+
/** Background write interval in seconds (default: 60) */
|
|
23
|
+
write_interval_seconds: z.number().min(10).max(600).default(60),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Main configuration schema for the Antigravity OAuth plugin.
|
|
27
|
+
*/
|
|
28
|
+
export const AntigravityConfigSchema = z.object({
|
|
29
|
+
/** JSON Schema reference for IDE support */
|
|
30
|
+
$schema: z.string().optional(),
|
|
31
|
+
// =========================================================================
|
|
32
|
+
// General Settings
|
|
33
|
+
// =========================================================================
|
|
34
|
+
/**
|
|
35
|
+
* Suppress most toast notifications (rate limit, account switching, etc.)
|
|
36
|
+
* Recovery toasts are always shown regardless of this setting.
|
|
37
|
+
* Env override: OPENCODE_ANTIGRAVITY_QUIET=1
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
quiet_mode: z.boolean().default(false),
|
|
41
|
+
/**
|
|
42
|
+
* Enable debug logging to file.
|
|
43
|
+
* Env override: OPENCODE_ANTIGRAVITY_DEBUG=1
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
debug: z.boolean().default(false),
|
|
47
|
+
/**
|
|
48
|
+
* Custom directory for debug logs.
|
|
49
|
+
* Env override: OPENCODE_ANTIGRAVITY_LOG_DIR=/path/to/logs
|
|
50
|
+
* @default OS-specific config dir + "/antigravity-logs"
|
|
51
|
+
*/
|
|
52
|
+
log_dir: z.string().optional(),
|
|
53
|
+
// =========================================================================
|
|
54
|
+
// Thinking Blocks
|
|
55
|
+
// =========================================================================
|
|
56
|
+
/**
|
|
57
|
+
* Preserve thinking blocks for Claude models using signature caching.
|
|
58
|
+
*
|
|
59
|
+
* When false (default): Thinking blocks are stripped for reliability.
|
|
60
|
+
* When true: Full context preserved, but may encounter signature errors.
|
|
61
|
+
*
|
|
62
|
+
* Env override: OPENCODE_ANTIGRAVITY_KEEP_THINKING=1
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
keep_thinking: z.boolean().default(false),
|
|
66
|
+
// =========================================================================
|
|
67
|
+
// Session Recovery
|
|
68
|
+
// =========================================================================
|
|
69
|
+
/**
|
|
70
|
+
* Enable automatic session recovery from tool_result_missing errors.
|
|
71
|
+
* When enabled, shows a toast notification when recoverable errors occur.
|
|
72
|
+
*
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
session_recovery: z.boolean().default(true),
|
|
76
|
+
/**
|
|
77
|
+
* Automatically send a "continue" prompt after successful recovery.
|
|
78
|
+
* Only applies when session_recovery is enabled.
|
|
79
|
+
*
|
|
80
|
+
* When false: Only shows toast notification, user must manually continue.
|
|
81
|
+
* When true: Automatically sends "continue" to resume the session.
|
|
82
|
+
*
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
auto_resume: z.boolean().default(true),
|
|
86
|
+
/**
|
|
87
|
+
* Custom text to send when auto-resuming after recovery.
|
|
88
|
+
* Only used when auto_resume is enabled.
|
|
89
|
+
*
|
|
90
|
+
* @default "continue"
|
|
91
|
+
*/
|
|
92
|
+
resume_text: z.string().default("continue"),
|
|
93
|
+
// =========================================================================
|
|
94
|
+
// Signature Caching
|
|
95
|
+
// =========================================================================
|
|
96
|
+
/**
|
|
97
|
+
* Signature cache configuration for persisting thinking block signatures.
|
|
98
|
+
* Only used when keep_thinking is enabled.
|
|
99
|
+
*/
|
|
100
|
+
signature_cache: SignatureCacheConfigSchema.optional(),
|
|
101
|
+
// =========================================================================
|
|
102
|
+
// Empty Response Retry (ported from LLM-API-Key-Proxy)
|
|
103
|
+
// =========================================================================
|
|
104
|
+
/**
|
|
105
|
+
* Maximum retry attempts when Antigravity returns an empty response.
|
|
106
|
+
* Empty responses occur when no candidates/choices are returned.
|
|
107
|
+
*
|
|
108
|
+
* @default 4
|
|
109
|
+
*/
|
|
110
|
+
empty_response_max_attempts: z.number().min(1).max(10).default(4),
|
|
111
|
+
/**
|
|
112
|
+
* Delay in milliseconds between empty response retries.
|
|
113
|
+
*
|
|
114
|
+
* @default 2000
|
|
115
|
+
*/
|
|
116
|
+
empty_response_retry_delay_ms: z.number().min(500).max(10000).default(2000),
|
|
117
|
+
// =========================================================================
|
|
118
|
+
// Tool ID Recovery (ported from LLM-API-Key-Proxy)
|
|
119
|
+
// =========================================================================
|
|
120
|
+
/**
|
|
121
|
+
* Enable tool ID orphan recovery.
|
|
122
|
+
* When tool responses have mismatched IDs (due to context compaction),
|
|
123
|
+
* attempt to match them by function name or create placeholders.
|
|
124
|
+
*
|
|
125
|
+
* @default true
|
|
126
|
+
*/
|
|
127
|
+
tool_id_recovery: z.boolean().default(true),
|
|
128
|
+
// =========================================================================
|
|
129
|
+
// Tool Hallucination Prevention (ported from LLM-API-Key-Proxy)
|
|
130
|
+
// =========================================================================
|
|
131
|
+
/**
|
|
132
|
+
* Enable tool hallucination prevention for Claude models.
|
|
133
|
+
* When enabled, injects:
|
|
134
|
+
* - Parameter signatures into tool descriptions
|
|
135
|
+
* - System instruction with strict tool usage rules
|
|
136
|
+
*
|
|
137
|
+
* This helps prevent Claude from using parameter names from its training
|
|
138
|
+
* data instead of the actual schema.
|
|
139
|
+
*
|
|
140
|
+
* @default true
|
|
141
|
+
*/
|
|
142
|
+
claude_tool_hardening: z.boolean().default(true),
|
|
143
|
+
// =========================================================================
|
|
144
|
+
// Proactive Token Refresh (ported from LLM-API-Key-Proxy)
|
|
145
|
+
// =========================================================================
|
|
146
|
+
/**
|
|
147
|
+
* Enable proactive background token refresh.
|
|
148
|
+
* When enabled, tokens are refreshed in the background before they expire,
|
|
149
|
+
* ensuring requests never block on token refresh.
|
|
150
|
+
*
|
|
151
|
+
* @default true
|
|
152
|
+
*/
|
|
153
|
+
proactive_token_refresh: z.boolean().default(true),
|
|
154
|
+
/**
|
|
155
|
+
* Seconds before token expiry to trigger proactive refresh.
|
|
156
|
+
* Default is 30 minutes (1800 seconds).
|
|
157
|
+
*
|
|
158
|
+
* @default 1800
|
|
159
|
+
*/
|
|
160
|
+
proactive_refresh_buffer_seconds: z.number().min(60).max(7200).default(1800),
|
|
161
|
+
/**
|
|
162
|
+
* Interval between proactive refresh checks in seconds.
|
|
163
|
+
* Default is 5 minutes (300 seconds).
|
|
164
|
+
*
|
|
165
|
+
* @default 300
|
|
166
|
+
*/
|
|
167
|
+
proactive_refresh_check_interval_seconds: z.number().min(30).max(1800).default(300),
|
|
168
|
+
// =========================================================================
|
|
169
|
+
// Rate Limiting
|
|
170
|
+
// =========================================================================
|
|
171
|
+
/**
|
|
172
|
+
* Maximum time in seconds to wait when all accounts are rate-limited.
|
|
173
|
+
* If the minimum wait time across all accounts exceeds this threshold,
|
|
174
|
+
* the plugin fails fast with an error instead of hanging.
|
|
175
|
+
*
|
|
176
|
+
* Set to 0 to disable (wait indefinitely).
|
|
177
|
+
*
|
|
178
|
+
* @default 300 (5 minutes)
|
|
179
|
+
*/
|
|
180
|
+
max_rate_limit_wait_seconds: z.number().min(0).max(3600).default(300),
|
|
181
|
+
/**
|
|
182
|
+
* Enable quota fallback for Gemini models.
|
|
183
|
+
* When the preferred quota (gemini-cli or antigravity) is exhausted,
|
|
184
|
+
* try the alternate quota on the same account before switching accounts.
|
|
185
|
+
*
|
|
186
|
+
* Only applies when model is requested without explicit quota suffix.
|
|
187
|
+
* Explicit suffixes like `:antigravity` or `:gemini-cli` always use
|
|
188
|
+
* that specific quota and switch accounts if exhausted.
|
|
189
|
+
*
|
|
190
|
+
* @default false
|
|
191
|
+
*/
|
|
192
|
+
quota_fallback: z.boolean().default(false),
|
|
193
|
+
// =========================================================================
|
|
194
|
+
// Auto-Update
|
|
195
|
+
// =========================================================================
|
|
196
|
+
/**
|
|
197
|
+
* Enable automatic plugin updates.
|
|
198
|
+
* @default true
|
|
199
|
+
*/
|
|
200
|
+
auto_update: z.boolean().default(true),
|
|
201
|
+
});
|
|
202
|
+
/**
|
|
203
|
+
* Default configuration values.
|
|
204
|
+
*/
|
|
205
|
+
export const DEFAULT_CONFIG = {
|
|
206
|
+
quiet_mode: false,
|
|
207
|
+
debug: false,
|
|
208
|
+
keep_thinking: false,
|
|
209
|
+
session_recovery: true,
|
|
210
|
+
auto_resume: true,
|
|
211
|
+
resume_text: "continue",
|
|
212
|
+
empty_response_max_attempts: 4,
|
|
213
|
+
empty_response_retry_delay_ms: 2000,
|
|
214
|
+
tool_id_recovery: true,
|
|
215
|
+
claude_tool_hardening: true,
|
|
216
|
+
proactive_token_refresh: true,
|
|
217
|
+
proactive_refresh_buffer_seconds: 1800,
|
|
218
|
+
proactive_refresh_check_interval_seconds: 300,
|
|
219
|
+
max_rate_limit_wait_seconds: 300,
|
|
220
|
+
quota_fallback: false,
|
|
221
|
+
auto_update: true,
|
|
222
|
+
signature_cache: {
|
|
223
|
+
enabled: true,
|
|
224
|
+
memory_ttl_seconds: 3600,
|
|
225
|
+
disk_ttl_seconds: 172800,
|
|
226
|
+
write_interval_seconds: 60,
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=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I;IACtC,wCAAwC,EAAE,GAAG;IAC7C,2BAA2B,EAAE,GAAG;IAChC,cAAc,EAAE,KAAK;IACrB,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE;QACf,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,IAAI;QACxB,gBAAgB,EAAE,MAAM;QACxB,sBAAsB,EAAE,EAAE;KAC3B;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/core/streaming/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/plugin/core/streaming/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SignatureStore, StreamingCallbacks, StreamingOptions, ThoughtBuffer } from './types';
|
|
2
|
+
export declare function createThoughtBuffer(): ThoughtBuffer;
|
|
3
|
+
export declare function transformStreamingPayload(payload: string, transformThinkingParts?: (response: unknown) => unknown): string;
|
|
4
|
+
export declare function transformSseLine(line: string, signatureStore: SignatureStore, thoughtBuffer: ThoughtBuffer, callbacks: StreamingCallbacks, options: StreamingOptions, debugState: {
|
|
5
|
+
injected: boolean;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function cacheThinkingSignaturesFromResponse(response: unknown, signatureSessionKey: string, signatureStore: SignatureStore, thoughtBuffer: ThoughtBuffer, onCacheSignature?: (sessionKey: string, text: string, signature: string) => void): void;
|
|
8
|
+
export declare function createStreamingTransformer(signatureStore: SignatureStore, callbacks: StreamingCallbacks, options?: StreamingOptions): TransformStream<Uint8Array, Uint8Array>;
|
|
9
|
+
//# sourceMappingURL=transformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/core/streaming/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,wBAAgB,mBAAmB,IAAI,aAAa,CAOnD;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,GACtD,MAAM,CAuBR;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,gBAAgB,EACzB,UAAU,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,GAChC,MAAM,CAmCR;AAED,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,OAAO,EACjB,mBAAmB,EAAE,MAAM,EAC3B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,GAC/E,IAAI,CAgDN;AAED,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,kBAAkB,EAC7B,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CA0CzC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export function createThoughtBuffer() {
|
|
2
|
+
const buffer = new Map();
|
|
3
|
+
return {
|
|
4
|
+
get: (index) => buffer.get(index),
|
|
5
|
+
set: (index, text) => buffer.set(index, text),
|
|
6
|
+
clear: () => buffer.clear(),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function transformStreamingPayload(payload, transformThinkingParts) {
|
|
10
|
+
return payload
|
|
11
|
+
.split('\n')
|
|
12
|
+
.map((line) => {
|
|
13
|
+
if (!line.startsWith('data:')) {
|
|
14
|
+
return line;
|
|
15
|
+
}
|
|
16
|
+
const json = line.slice(5).trim();
|
|
17
|
+
if (!json) {
|
|
18
|
+
return line;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(json);
|
|
22
|
+
if (parsed.response !== undefined) {
|
|
23
|
+
const transformed = transformThinkingParts
|
|
24
|
+
? transformThinkingParts(parsed.response)
|
|
25
|
+
: parsed.response;
|
|
26
|
+
return `data: ${JSON.stringify(transformed)}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (_) { }
|
|
30
|
+
return line;
|
|
31
|
+
})
|
|
32
|
+
.join('\n');
|
|
33
|
+
}
|
|
34
|
+
export function transformSseLine(line, signatureStore, thoughtBuffer, callbacks, options, debugState) {
|
|
35
|
+
if (!line.startsWith('data:')) {
|
|
36
|
+
return line;
|
|
37
|
+
}
|
|
38
|
+
const json = line.slice(5).trim();
|
|
39
|
+
if (!json) {
|
|
40
|
+
return line;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(json);
|
|
44
|
+
if (parsed.response !== undefined) {
|
|
45
|
+
if (options.cacheSignatures && options.signatureSessionKey) {
|
|
46
|
+
cacheThinkingSignaturesFromResponse(parsed.response, options.signatureSessionKey, signatureStore, thoughtBuffer, callbacks.onCacheSignature);
|
|
47
|
+
}
|
|
48
|
+
let response = parsed.response;
|
|
49
|
+
if (options.debugText && callbacks.onInjectDebug && !debugState.injected) {
|
|
50
|
+
response = callbacks.onInjectDebug(response, options.debugText);
|
|
51
|
+
debugState.injected = true;
|
|
52
|
+
}
|
|
53
|
+
const transformed = callbacks.transformThinkingParts
|
|
54
|
+
? callbacks.transformThinkingParts(response)
|
|
55
|
+
: response;
|
|
56
|
+
return `data: ${JSON.stringify(transformed)}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (_) { }
|
|
60
|
+
return line;
|
|
61
|
+
}
|
|
62
|
+
export function cacheThinkingSignaturesFromResponse(response, signatureSessionKey, signatureStore, thoughtBuffer, onCacheSignature) {
|
|
63
|
+
if (!response || typeof response !== 'object')
|
|
64
|
+
return;
|
|
65
|
+
const resp = response;
|
|
66
|
+
if (Array.isArray(resp.candidates)) {
|
|
67
|
+
resp.candidates.forEach((candidate, index) => {
|
|
68
|
+
const cand = candidate;
|
|
69
|
+
if (!cand?.content)
|
|
70
|
+
return;
|
|
71
|
+
const content = cand.content;
|
|
72
|
+
if (!Array.isArray(content.parts))
|
|
73
|
+
return;
|
|
74
|
+
content.parts.forEach((part) => {
|
|
75
|
+
const p = part;
|
|
76
|
+
if (p.thought === true || p.type === 'thinking') {
|
|
77
|
+
const text = (p.text || p.thinking || '');
|
|
78
|
+
if (text) {
|
|
79
|
+
const current = thoughtBuffer.get(index) ?? '';
|
|
80
|
+
thoughtBuffer.set(index, current + text);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (p.thoughtSignature) {
|
|
84
|
+
const fullText = thoughtBuffer.get(index) ?? '';
|
|
85
|
+
if (fullText) {
|
|
86
|
+
const signature = p.thoughtSignature;
|
|
87
|
+
onCacheSignature?.(signatureSessionKey, fullText, signature);
|
|
88
|
+
signatureStore.set(signatureSessionKey, { text: fullText, signature });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (Array.isArray(resp.content)) {
|
|
95
|
+
let thinkingText = '';
|
|
96
|
+
resp.content.forEach((block) => {
|
|
97
|
+
const b = block;
|
|
98
|
+
if (b?.type === 'thinking') {
|
|
99
|
+
thinkingText += (b.thinking || b.text || '');
|
|
100
|
+
}
|
|
101
|
+
if (b?.signature && thinkingText) {
|
|
102
|
+
const signature = b.signature;
|
|
103
|
+
onCacheSignature?.(signatureSessionKey, thinkingText, signature);
|
|
104
|
+
signatureStore.set(signatureSessionKey, { text: thinkingText, signature });
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function createStreamingTransformer(signatureStore, callbacks, options = {}) {
|
|
110
|
+
const decoder = new TextDecoder();
|
|
111
|
+
const encoder = new TextEncoder();
|
|
112
|
+
let buffer = '';
|
|
113
|
+
const thoughtBuffer = createThoughtBuffer();
|
|
114
|
+
const debugState = { injected: false };
|
|
115
|
+
return new TransformStream({
|
|
116
|
+
transform(chunk, controller) {
|
|
117
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
118
|
+
const lines = buffer.split('\n');
|
|
119
|
+
buffer = lines.pop() || '';
|
|
120
|
+
for (const line of lines) {
|
|
121
|
+
const transformedLine = transformSseLine(line, signatureStore, thoughtBuffer, callbacks, options, debugState);
|
|
122
|
+
controller.enqueue(encoder.encode(transformedLine + '\n'));
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
flush(controller) {
|
|
126
|
+
buffer += decoder.decode();
|
|
127
|
+
if (buffer) {
|
|
128
|
+
const transformedLine = transformSseLine(buffer, signatureStore, thoughtBuffer, callbacks, options, debugState);
|
|
129
|
+
controller.enqueue(encoder.encode(transformedLine));
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../../../../src/plugin/core/streaming/transformer.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,mBAAmB;IACjC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,OAAO;QACL,GAAG,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;QACzC,GAAG,EAAE,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG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CAAC,KAAK,EAAE,UAAU;YACzB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAElD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;YAE3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,eAAe,GAAG,gBAAgB,CACtC,IAAI,EACJ,cAAc,EACd,aAAa,EACb,SAAS,EACT,OAAO,EACP,UAAU,CACX,CAAC;gBACF,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QACD,KAAK,CAAC,UAAU;YACd,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAE3B,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,eAAe,GAAG,gBAAgB,CACtC,MAAM,EACN,cAAc,EACd,aAAa,EACb,SAAS,EACT,OAAO,EACP,UAAU,CACX,CAAC;gBACF,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface SignedThinking {
|
|
2
|
+
text: string;
|
|
3
|
+
signature: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SignatureStore {
|
|
6
|
+
get(sessionKey: string): SignedThinking | undefined;
|
|
7
|
+
set(sessionKey: string, value: SignedThinking): void;
|
|
8
|
+
has(sessionKey: string): boolean;
|
|
9
|
+
delete(sessionKey: string): void;
|
|
10
|
+
}
|
|
11
|
+
export interface StreamingCallbacks {
|
|
12
|
+
onCacheSignature?: (sessionKey: string, text: string, signature: string) => void;
|
|
13
|
+
onInjectDebug?: (response: unknown, debugText: string) => unknown;
|
|
14
|
+
transformThinkingParts?: (parts: unknown) => unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface StreamingOptions {
|
|
17
|
+
signatureSessionKey?: string;
|
|
18
|
+
debugText?: string;
|
|
19
|
+
cacheSignatures?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ThoughtBuffer {
|
|
22
|
+
get(index: number): string | undefined;
|
|
23
|
+
set(index: number, text: string): void;
|
|
24
|
+
clear(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/core/streaming/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IACpD,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;IACrD,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACjF,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAClE,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;CACtD;AAED,MAAM,WAAW,gBAAgB;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/plugin/core/streaming/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AntigravityConfig } from "./config";
|
|
2
|
+
export declare const DEBUG_MESSAGE_PREFIX = "[opencode-antigravity-auth debug]";
|
|
3
|
+
/**
|
|
4
|
+
* Initialize or reinitialize debug state with the given config.
|
|
5
|
+
* Call this once at plugin startup after loading config.
|
|
6
|
+
*/
|
|
7
|
+
export declare function initializeDebug(config: AntigravityConfig): void;
|
|
8
|
+
export declare function isDebugEnabled(): boolean;
|
|
9
|
+
export declare function isVerboseEnabled(): boolean;
|
|
10
|
+
export declare function getLogFilePath(): string | undefined;
|
|
11
|
+
export interface AntigravityDebugContext {
|
|
12
|
+
id: string;
|
|
13
|
+
streaming: boolean;
|
|
14
|
+
startedAt: number;
|
|
15
|
+
}
|
|
16
|
+
interface AntigravityDebugRequestMeta {
|
|
17
|
+
originalUrl: string;
|
|
18
|
+
resolvedUrl: string;
|
|
19
|
+
method?: string;
|
|
20
|
+
headers?: HeadersInit;
|
|
21
|
+
body?: BodyInit | null;
|
|
22
|
+
streaming: boolean;
|
|
23
|
+
projectId?: string;
|
|
24
|
+
}
|
|
25
|
+
interface AntigravityDebugResponseMeta {
|
|
26
|
+
body?: string;
|
|
27
|
+
note?: string;
|
|
28
|
+
error?: unknown;
|
|
29
|
+
headersOverride?: HeadersInit;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Begins a debug trace for an Antigravity request.
|
|
33
|
+
*/
|
|
34
|
+
export declare function startAntigravityDebugRequest(meta: AntigravityDebugRequestMeta): AntigravityDebugContext | null;
|
|
35
|
+
/**
|
|
36
|
+
* Logs response details for a previously started debug trace.
|
|
37
|
+
*/
|
|
38
|
+
export declare function logAntigravityDebugResponse(context: AntigravityDebugContext | null | undefined, response: Response, meta?: AntigravityDebugResponseMeta): void;
|
|
39
|
+
export interface AccountDebugInfo {
|
|
40
|
+
index: number;
|
|
41
|
+
email?: string;
|
|
42
|
+
family: string;
|
|
43
|
+
totalAccounts: number;
|
|
44
|
+
rateLimitState?: {
|
|
45
|
+
claude?: number;
|
|
46
|
+
gemini?: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export declare function logAccountContext(label: string, info: AccountDebugInfo): void;
|
|
50
|
+
export declare function logRateLimitEvent(accountIndex: number, email: string | undefined, family: string, status: number, retryAfterMs: number, bodyInfo: {
|
|
51
|
+
message?: string;
|
|
52
|
+
quotaResetTime?: string;
|
|
53
|
+
retryDelayMs?: number | null;
|
|
54
|
+
reason?: string;
|
|
55
|
+
}): void;
|
|
56
|
+
export declare function logRateLimitSnapshot(family: string, accounts: Array<{
|
|
57
|
+
index: number;
|
|
58
|
+
email?: string;
|
|
59
|
+
rateLimitResetTimes?: {
|
|
60
|
+
claude?: number;
|
|
61
|
+
gemini?: number;
|
|
62
|
+
};
|
|
63
|
+
}>): void;
|
|
64
|
+
export declare function logResponseBody(context: AntigravityDebugContext | null | undefined, response: Response, status: number): Promise<string | undefined>;
|
|
65
|
+
export declare function logModelFamily(url: string, extractedModel: string | null, family: string): void;
|
|
66
|
+
export declare function debugLogToFile(message: string): void;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d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