opencode-antigravity-auth-mf 11.3.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/LICENSE +21 -0
- package/README.md +630 -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 +99 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +135 -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 +86 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -0
- package/dist/src/plugin/accounts.js +609 -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 +375 -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 +37 -0
- package/dist/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/src/plugin/config/loader.js +206 -0
- package/dist/src/plugin/config/loader.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +411 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/src/plugin/config/schema.js +339 -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 +10 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.js +255 -0
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
- package/dist/src/plugin/core/streaming/types.d.ts +35 -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 +325 -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/image-saver.d.ts +25 -0
- package/dist/src/plugin/image-saver.d.ts.map +1 -0
- package/dist/src/plugin/image-saver.js +86 -0
- package/dist/src/plugin/image-saver.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 +234 -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 +278 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/src/plugin/request-helpers.js +2268 -0
- package/dist/src/plugin/request-helpers.js.map +1 -0
- package/dist/src/plugin/request.d.ts +91 -0
- package/dist/src/plugin/request.d.ts.map +1 -0
- package/dist/src/plugin/request.js +1302 -0
- package/dist/src/plugin/request.js.map +1 -0
- package/dist/src/plugin/rotation.d.ts +168 -0
- package/dist/src/plugin/rotation.d.ts.map +1 -0
- package/dist/src/plugin/rotation.js +302 -0
- package/dist/src/plugin/rotation.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 +324 -0
- package/dist/src/plugin/server.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +92 -0
- package/dist/src/plugin/storage.d.ts.map +1 -0
- package/dist/src/plugin/storage.js +417 -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 +112 -0
- package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
- package/dist/src/plugin/transform/gemini.js +409 -0
- package/dist/src/plugin/transform/gemini.js.map +1 -0
- package/dist/src/plugin/transform/index.d.ts +15 -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 +101 -0
- package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/src/plugin/transform/model-resolver.js +356 -0
- package/dist/src/plugin/transform/model-resolver.js.map +1 -0
- package/dist/src/plugin/transform/types.d.ts +106 -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 +96 -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/usage-reporter.d.ts +23 -0
- package/dist/src/plugin/usage-reporter.d.ts.map +1 -0
- package/dist/src/plugin/usage-reporter.js +43 -0
- package/dist/src/plugin/usage-reporter.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 +1708 -0
- package/dist/src/plugin.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,339 @@
|
|
|
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
|
+
* Account selection strategy for distributing requests across accounts.
|
|
14
|
+
*
|
|
15
|
+
* - `sticky`: Use same account until rate-limited. Preserves prompt cache.
|
|
16
|
+
* - `round-robin`: Rotate to next account on every request. Maximum throughput.
|
|
17
|
+
* - `hybrid` (default): Deterministic selection based on health score + token bucket + LRU freshness.
|
|
18
|
+
*/
|
|
19
|
+
export const AccountSelectionStrategySchema = z.enum(['sticky', 'round-robin', 'hybrid']);
|
|
20
|
+
/**
|
|
21
|
+
* Signature cache configuration for persisting thinking block signatures to disk.
|
|
22
|
+
*/
|
|
23
|
+
export const SignatureCacheConfigSchema = z.object({
|
|
24
|
+
/** Enable disk caching of signatures (default: true) */
|
|
25
|
+
enabled: z.boolean().default(true),
|
|
26
|
+
/** In-memory TTL in seconds (default: 3600 = 1 hour) */
|
|
27
|
+
memory_ttl_seconds: z.number().min(60).max(86400).default(3600),
|
|
28
|
+
/** Disk TTL in seconds (default: 172800 = 48 hours) */
|
|
29
|
+
disk_ttl_seconds: z.number().min(3600).max(604800).default(172800),
|
|
30
|
+
/** Background write interval in seconds (default: 60) */
|
|
31
|
+
write_interval_seconds: z.number().min(10).max(600).default(60),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Main configuration schema for the Antigravity OAuth plugin.
|
|
35
|
+
*/
|
|
36
|
+
export const AntigravityConfigSchema = z.object({
|
|
37
|
+
/** JSON Schema reference for IDE support */
|
|
38
|
+
$schema: z.string().optional(),
|
|
39
|
+
// =========================================================================
|
|
40
|
+
// General Settings
|
|
41
|
+
// =========================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Suppress most toast notifications (rate limit, account switching, etc.)
|
|
44
|
+
* Recovery toasts are always shown regardless of this setting.
|
|
45
|
+
* Env override: OPENCODE_ANTIGRAVITY_QUIET=1
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
quiet_mode: z.boolean().default(false),
|
|
49
|
+
/**
|
|
50
|
+
* Enable debug logging to file.
|
|
51
|
+
* Env override: OPENCODE_ANTIGRAVITY_DEBUG=1
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
debug: z.boolean().default(false),
|
|
55
|
+
/**
|
|
56
|
+
* Custom directory for debug logs.
|
|
57
|
+
* Env override: OPENCODE_ANTIGRAVITY_LOG_DIR=/path/to/logs
|
|
58
|
+
* @default OS-specific config dir + "/antigravity-logs"
|
|
59
|
+
*/
|
|
60
|
+
log_dir: z.string().optional(),
|
|
61
|
+
// =========================================================================
|
|
62
|
+
// Thinking Blocks
|
|
63
|
+
// =========================================================================
|
|
64
|
+
/**
|
|
65
|
+
* Preserve thinking blocks for Claude models using signature caching.
|
|
66
|
+
*
|
|
67
|
+
* When false (default): Thinking blocks are stripped for reliability.
|
|
68
|
+
* When true: Full context preserved, but may encounter signature errors.
|
|
69
|
+
*
|
|
70
|
+
* Env override: OPENCODE_ANTIGRAVITY_KEEP_THINKING=1
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
keep_thinking: z.boolean().default(false),
|
|
74
|
+
// =========================================================================
|
|
75
|
+
// Session Recovery
|
|
76
|
+
// =========================================================================
|
|
77
|
+
/**
|
|
78
|
+
* Enable automatic session recovery from tool_result_missing errors.
|
|
79
|
+
* When enabled, shows a toast notification when recoverable errors occur.
|
|
80
|
+
*
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
session_recovery: z.boolean().default(true),
|
|
84
|
+
/**
|
|
85
|
+
* Automatically send a "continue" prompt after successful recovery.
|
|
86
|
+
* Only applies when session_recovery is enabled.
|
|
87
|
+
*
|
|
88
|
+
* When false: Only shows toast notification, user must manually continue.
|
|
89
|
+
* When true: Automatically sends "continue" to resume the session.
|
|
90
|
+
*
|
|
91
|
+
* @default false
|
|
92
|
+
*/
|
|
93
|
+
auto_resume: z.boolean().default(false),
|
|
94
|
+
/**
|
|
95
|
+
* Custom text to send when auto-resuming after recovery.
|
|
96
|
+
* Only used when auto_resume is enabled.
|
|
97
|
+
*
|
|
98
|
+
* @default "continue"
|
|
99
|
+
*/
|
|
100
|
+
resume_text: z.string().default("continue"),
|
|
101
|
+
// =========================================================================
|
|
102
|
+
// Signature Caching
|
|
103
|
+
// =========================================================================
|
|
104
|
+
/**
|
|
105
|
+
* Signature cache configuration for persisting thinking block signatures.
|
|
106
|
+
* Only used when keep_thinking is enabled.
|
|
107
|
+
*/
|
|
108
|
+
signature_cache: SignatureCacheConfigSchema.optional(),
|
|
109
|
+
// =========================================================================
|
|
110
|
+
// Empty Response Retry (ported from LLM-API-Key-Proxy)
|
|
111
|
+
// =========================================================================
|
|
112
|
+
/**
|
|
113
|
+
* Maximum retry attempts when Antigravity returns an empty response.
|
|
114
|
+
* Empty responses occur when no candidates/choices are returned.
|
|
115
|
+
*
|
|
116
|
+
* @default 4
|
|
117
|
+
*/
|
|
118
|
+
empty_response_max_attempts: z.number().min(1).max(10).default(4),
|
|
119
|
+
/**
|
|
120
|
+
* Delay in milliseconds between empty response retries.
|
|
121
|
+
*
|
|
122
|
+
* @default 2000
|
|
123
|
+
*/
|
|
124
|
+
empty_response_retry_delay_ms: z.number().min(500).max(10000).default(2000),
|
|
125
|
+
// =========================================================================
|
|
126
|
+
// Tool ID Recovery (ported from LLM-API-Key-Proxy)
|
|
127
|
+
// =========================================================================
|
|
128
|
+
/**
|
|
129
|
+
* Enable tool ID orphan recovery.
|
|
130
|
+
* When tool responses have mismatched IDs (due to context compaction),
|
|
131
|
+
* attempt to match them by function name or create placeholders.
|
|
132
|
+
*
|
|
133
|
+
* @default true
|
|
134
|
+
*/
|
|
135
|
+
tool_id_recovery: z.boolean().default(true),
|
|
136
|
+
// =========================================================================
|
|
137
|
+
// Tool Hallucination Prevention (ported from LLM-API-Key-Proxy)
|
|
138
|
+
// =========================================================================
|
|
139
|
+
/**
|
|
140
|
+
* Enable tool hallucination prevention for Claude models.
|
|
141
|
+
* When enabled, injects:
|
|
142
|
+
* - Parameter signatures into tool descriptions
|
|
143
|
+
* - System instruction with strict tool usage rules
|
|
144
|
+
*
|
|
145
|
+
* This helps prevent Claude from using parameter names from its training
|
|
146
|
+
* data instead of the actual schema.
|
|
147
|
+
*
|
|
148
|
+
* @default true
|
|
149
|
+
*/
|
|
150
|
+
claude_tool_hardening: z.boolean().default(true),
|
|
151
|
+
// =========================================================================
|
|
152
|
+
// Proactive Token Refresh (ported from LLM-API-Key-Proxy)
|
|
153
|
+
// =========================================================================
|
|
154
|
+
/**
|
|
155
|
+
* Enable proactive background token refresh.
|
|
156
|
+
* When enabled, tokens are refreshed in the background before they expire,
|
|
157
|
+
* ensuring requests never block on token refresh.
|
|
158
|
+
*
|
|
159
|
+
* @default true
|
|
160
|
+
*/
|
|
161
|
+
proactive_token_refresh: z.boolean().default(true),
|
|
162
|
+
/**
|
|
163
|
+
* Seconds before token expiry to trigger proactive refresh.
|
|
164
|
+
* Default is 30 minutes (1800 seconds).
|
|
165
|
+
*
|
|
166
|
+
* @default 1800
|
|
167
|
+
*/
|
|
168
|
+
proactive_refresh_buffer_seconds: z.number().min(60).max(7200).default(1800),
|
|
169
|
+
/**
|
|
170
|
+
* Interval between proactive refresh checks in seconds.
|
|
171
|
+
* Default is 5 minutes (300 seconds).
|
|
172
|
+
*
|
|
173
|
+
* @default 300
|
|
174
|
+
*/
|
|
175
|
+
proactive_refresh_check_interval_seconds: z.number().min(30).max(1800).default(300),
|
|
176
|
+
// =========================================================================
|
|
177
|
+
// Rate Limiting
|
|
178
|
+
// =========================================================================
|
|
179
|
+
/**
|
|
180
|
+
* Maximum time in seconds to wait when all accounts are rate-limited.
|
|
181
|
+
* If the minimum wait time across all accounts exceeds this threshold,
|
|
182
|
+
* the plugin fails fast with an error instead of hanging.
|
|
183
|
+
*
|
|
184
|
+
* Set to 0 to disable (wait indefinitely).
|
|
185
|
+
*
|
|
186
|
+
* @default 300 (5 minutes)
|
|
187
|
+
*/
|
|
188
|
+
max_rate_limit_wait_seconds: z.number().min(0).max(3600).default(300),
|
|
189
|
+
/**
|
|
190
|
+
* Enable quota fallback for Gemini models.
|
|
191
|
+
* When the preferred quota (gemini-cli or antigravity) is exhausted,
|
|
192
|
+
* try the alternate quota on the same account before switching accounts.
|
|
193
|
+
*
|
|
194
|
+
* Only applies when model is requested without explicit quota suffix.
|
|
195
|
+
* Explicit suffixes like `:antigravity` or `:gemini-cli` always use
|
|
196
|
+
* that specific quota and switch accounts if exhausted.
|
|
197
|
+
*
|
|
198
|
+
* @default false
|
|
199
|
+
*/
|
|
200
|
+
quota_fallback: z.boolean().default(false),
|
|
201
|
+
/**
|
|
202
|
+
* Strategy for selecting accounts when making requests.
|
|
203
|
+
* Env override: OPENCODE_ANTIGRAVITY_ACCOUNT_SELECTION_STRATEGY
|
|
204
|
+
* @default "hybrid"
|
|
205
|
+
*/
|
|
206
|
+
account_selection_strategy: AccountSelectionStrategySchema.default('hybrid'),
|
|
207
|
+
/**
|
|
208
|
+
* Enable PID-based account offset for multi-session distribution.
|
|
209
|
+
*
|
|
210
|
+
* When enabled, different sessions (PIDs) will prefer different starting
|
|
211
|
+
* accounts, which helps distribute load when running multiple parallel agents.
|
|
212
|
+
*
|
|
213
|
+
* When disabled (default), accounts start from the same index, which preserves
|
|
214
|
+
* Anthropic's prompt cache across restarts (recommended for single-session use).
|
|
215
|
+
*
|
|
216
|
+
* Env override: OPENCODE_ANTIGRAVITY_PID_OFFSET_ENABLED=1
|
|
217
|
+
* @default false
|
|
218
|
+
*/
|
|
219
|
+
pid_offset_enabled: z.boolean().default(false),
|
|
220
|
+
/**
|
|
221
|
+
* Switch to another account immediately on first rate limit (after 1s delay).
|
|
222
|
+
* When disabled, retries same account first, then switches on second rate limit.
|
|
223
|
+
*
|
|
224
|
+
* @default true
|
|
225
|
+
*/
|
|
226
|
+
switch_on_first_rate_limit: z.boolean().default(true),
|
|
227
|
+
// =========================================================================
|
|
228
|
+
// Health Score (used by hybrid strategy)
|
|
229
|
+
// =========================================================================
|
|
230
|
+
health_score: z.object({
|
|
231
|
+
initial: z.number().min(0).max(100).default(70),
|
|
232
|
+
success_reward: z.number().min(0).max(10).default(1),
|
|
233
|
+
rate_limit_penalty: z.number().min(-50).max(0).default(-10),
|
|
234
|
+
failure_penalty: z.number().min(-100).max(0).default(-20),
|
|
235
|
+
recovery_rate_per_hour: z.number().min(0).max(20).default(2),
|
|
236
|
+
min_usable: z.number().min(0).max(100).default(50),
|
|
237
|
+
max_score: z.number().min(50).max(100).default(100),
|
|
238
|
+
}).optional(),
|
|
239
|
+
// =========================================================================
|
|
240
|
+
// Token Bucket (for hybrid strategy)
|
|
241
|
+
// =========================================================================
|
|
242
|
+
token_bucket: z.object({
|
|
243
|
+
max_tokens: z.number().min(1).max(1000).default(50),
|
|
244
|
+
regeneration_rate_per_minute: z.number().min(0.1).max(60).default(6),
|
|
245
|
+
initial_tokens: z.number().min(1).max(1000).default(50),
|
|
246
|
+
}).optional(),
|
|
247
|
+
// =========================================================================
|
|
248
|
+
// Auto-Update
|
|
249
|
+
// =========================================================================
|
|
250
|
+
/**
|
|
251
|
+
* Enable automatic plugin updates.
|
|
252
|
+
* @default true
|
|
253
|
+
*/
|
|
254
|
+
auto_update: z.boolean().default(true),
|
|
255
|
+
// =========================================================================
|
|
256
|
+
// Web Search (Gemini Grounding)
|
|
257
|
+
// =========================================================================
|
|
258
|
+
web_search: z.object({
|
|
259
|
+
/**
|
|
260
|
+
* Default mode for web search when not specified by variant.
|
|
261
|
+
* - `auto`: Model decides when to search (dynamic retrieval).
|
|
262
|
+
* - `off`: Search is disabled by default.
|
|
263
|
+
* @default "off"
|
|
264
|
+
*/
|
|
265
|
+
default_mode: z.enum(['auto', 'off']).default('off'),
|
|
266
|
+
/**
|
|
267
|
+
* Dynamic retrieval threshold (0.0 to 1.0).
|
|
268
|
+
* Higher values make the model search LESS often (requires higher confidence to trigger search).
|
|
269
|
+
* Only applies in 'auto' mode.
|
|
270
|
+
* @default 0.3
|
|
271
|
+
*/
|
|
272
|
+
grounding_threshold: z.number().min(0).max(1).default(0.3),
|
|
273
|
+
}).optional(),
|
|
274
|
+
// =========================================================================
|
|
275
|
+
// Remote Account Service
|
|
276
|
+
// =========================================================================
|
|
277
|
+
/**
|
|
278
|
+
* Remote account service endpoint URL.
|
|
279
|
+
* When configured with api_key, accounts are loaded from remote service
|
|
280
|
+
* instead of local file.
|
|
281
|
+
* Env override: OPENCODE_ANTIGRAVITY_API_ENDPOINT
|
|
282
|
+
*/
|
|
283
|
+
api_endpoint: z.string().url().optional(),
|
|
284
|
+
/**
|
|
285
|
+
* API key for authenticating with remote account service.
|
|
286
|
+
* Required when api_endpoint is configured.
|
|
287
|
+
* Env override: OPENCODE_ANTIGRAVITY_API_KEY
|
|
288
|
+
*/
|
|
289
|
+
api_key: z.string().optional(),
|
|
290
|
+
});
|
|
291
|
+
/**
|
|
292
|
+
* Default configuration values.
|
|
293
|
+
*/
|
|
294
|
+
export const DEFAULT_CONFIG = {
|
|
295
|
+
quiet_mode: false,
|
|
296
|
+
debug: false,
|
|
297
|
+
keep_thinking: false,
|
|
298
|
+
session_recovery: true,
|
|
299
|
+
auto_resume: true,
|
|
300
|
+
resume_text: "continue",
|
|
301
|
+
empty_response_max_attempts: 4,
|
|
302
|
+
empty_response_retry_delay_ms: 2000,
|
|
303
|
+
tool_id_recovery: true,
|
|
304
|
+
claude_tool_hardening: true,
|
|
305
|
+
proactive_token_refresh: true,
|
|
306
|
+
proactive_refresh_buffer_seconds: 1800,
|
|
307
|
+
proactive_refresh_check_interval_seconds: 300,
|
|
308
|
+
max_rate_limit_wait_seconds: 300,
|
|
309
|
+
quota_fallback: false,
|
|
310
|
+
account_selection_strategy: 'hybrid',
|
|
311
|
+
pid_offset_enabled: false,
|
|
312
|
+
switch_on_first_rate_limit: true,
|
|
313
|
+
auto_update: true,
|
|
314
|
+
signature_cache: {
|
|
315
|
+
enabled: true,
|
|
316
|
+
memory_ttl_seconds: 3600,
|
|
317
|
+
disk_ttl_seconds: 172800,
|
|
318
|
+
write_interval_seconds: 60,
|
|
319
|
+
},
|
|
320
|
+
health_score: {
|
|
321
|
+
initial: 70,
|
|
322
|
+
success_reward: 1,
|
|
323
|
+
rate_limit_penalty: -10,
|
|
324
|
+
failure_penalty: -20,
|
|
325
|
+
recovery_rate_per_hour: 2,
|
|
326
|
+
min_usable: 50,
|
|
327
|
+
max_score: 100,
|
|
328
|
+
},
|
|
329
|
+
token_bucket: {
|
|
330
|
+
max_tokens: 50,
|
|
331
|
+
regeneration_rate_per_minute: 6,
|
|
332
|
+
initial_tokens: 50,
|
|
333
|
+
},
|
|
334
|
+
web_search: {
|
|
335
|
+
default_mode: 'off',
|
|
336
|
+
grounding_threshold: 0.3,
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/plugin/config/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,MA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AChC,cAAc,EAAE,KAAK;IACrB,0BAA0B,EAAE,QAAQ;IACpC,kBAAkB,EAAE,KAAK;IACzB,0BAA0B,EAAE,IAAI;IAChC,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE;QACf,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,IAAI;QACxB,gBAAgB,EAAE,MAAM;QACxB,sBAAsB,EAAE,EAAE;KAC3B;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,cAAc,EAAE,CAAC;QACjB,kBAAkB,EAAE,CAAC,EAAE;QACvB,eAAe,EAAE,CAAC,EAAE;QACpB,sBAAsB,EAAE,CAAC;QACzB,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,GAAG;KACf;IACD,YAAY,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,4BAA4B,EAAE,CAAC;QAC/B,cAAc,EAAE,EAAE;KACnB;IACD,UAAU,EAAE;QACV,YAAY,EAAE,KAAK;QACnB,mBAAmB,EAAE,GAAG;KACzB;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,10 @@
|
|
|
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 deduplicateThinkingText(response: unknown, sentBuffer: ThoughtBuffer, displayedThinkingHashes?: Set<string>): unknown;
|
|
5
|
+
export declare function transformSseLine(line: string, signatureStore: SignatureStore, thoughtBuffer: ThoughtBuffer, sentThinkingBuffer: ThoughtBuffer, callbacks: StreamingCallbacks, options: StreamingOptions, debugState: {
|
|
6
|
+
injected: boolean;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function cacheThinkingSignaturesFromResponse(response: unknown, signatureSessionKey: string, signatureStore: SignatureStore, thoughtBuffer: ThoughtBuffer, onCacheSignature?: (sessionKey: string, text: string, signature: string) => void): void;
|
|
9
|
+
export declare function createStreamingTransformer(signatureStore: SignatureStore, callbacks: StreamingCallbacks, options?: StreamingOptions): TransformStream<Uint8Array, Uint8Array>;
|
|
10
|
+
//# 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,EAEd,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,uBAAuB,CACrC,QAAQ,EAAE,OAAO,EACjB,UAAU,EAAE,aAAa,EACzB,uBAAuB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACpC,OAAO,CA+GT;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,aAAa,EACjC,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,gBAAgB,EACzB,UAAU,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,GAChC,MAAM,CAyDR;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,CA6CzC"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { processImageData } from '../../image-saver';
|
|
2
|
+
/**
|
|
3
|
+
* Simple string hash for thinking deduplication.
|
|
4
|
+
* Uses DJB2-like algorithm.
|
|
5
|
+
*/
|
|
6
|
+
function hashString(str) {
|
|
7
|
+
let hash = 5381;
|
|
8
|
+
for (let i = 0; i < str.length; i++) {
|
|
9
|
+
hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */
|
|
10
|
+
}
|
|
11
|
+
return (hash >>> 0).toString(16);
|
|
12
|
+
}
|
|
13
|
+
export function createThoughtBuffer() {
|
|
14
|
+
const buffer = new Map();
|
|
15
|
+
return {
|
|
16
|
+
get: (index) => buffer.get(index),
|
|
17
|
+
set: (index, text) => buffer.set(index, text),
|
|
18
|
+
clear: () => buffer.clear(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function transformStreamingPayload(payload, transformThinkingParts) {
|
|
22
|
+
return payload
|
|
23
|
+
.split('\n')
|
|
24
|
+
.map((line) => {
|
|
25
|
+
if (!line.startsWith('data:')) {
|
|
26
|
+
return line;
|
|
27
|
+
}
|
|
28
|
+
const json = line.slice(5).trim();
|
|
29
|
+
if (!json) {
|
|
30
|
+
return line;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const parsed = JSON.parse(json);
|
|
34
|
+
if (parsed.response !== undefined) {
|
|
35
|
+
const transformed = transformThinkingParts
|
|
36
|
+
? transformThinkingParts(parsed.response)
|
|
37
|
+
: parsed.response;
|
|
38
|
+
return `data: ${JSON.stringify(transformed)}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (_) { }
|
|
42
|
+
return line;
|
|
43
|
+
})
|
|
44
|
+
.join('\n');
|
|
45
|
+
}
|
|
46
|
+
export function deduplicateThinkingText(response, sentBuffer, displayedThinkingHashes) {
|
|
47
|
+
if (!response || typeof response !== 'object')
|
|
48
|
+
return response;
|
|
49
|
+
const resp = response;
|
|
50
|
+
if (Array.isArray(resp.candidates)) {
|
|
51
|
+
const newCandidates = resp.candidates.map((candidate, index) => {
|
|
52
|
+
const cand = candidate;
|
|
53
|
+
if (!cand?.content)
|
|
54
|
+
return candidate;
|
|
55
|
+
const content = cand.content;
|
|
56
|
+
if (!Array.isArray(content.parts))
|
|
57
|
+
return candidate;
|
|
58
|
+
const newParts = content.parts.map((part) => {
|
|
59
|
+
const p = part;
|
|
60
|
+
// Handle image data - save to disk and return file path
|
|
61
|
+
if (p.inlineData) {
|
|
62
|
+
const inlineData = p.inlineData;
|
|
63
|
+
const result = processImageData({
|
|
64
|
+
mimeType: inlineData.mimeType,
|
|
65
|
+
data: inlineData.data,
|
|
66
|
+
});
|
|
67
|
+
if (result) {
|
|
68
|
+
return { text: result };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (p.thought === true || p.type === 'thinking') {
|
|
72
|
+
const fullText = (p.text || p.thinking || '');
|
|
73
|
+
if (displayedThinkingHashes) {
|
|
74
|
+
const hash = hashString(fullText);
|
|
75
|
+
if (displayedThinkingHashes.has(hash)) {
|
|
76
|
+
sentBuffer.set(index, fullText);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
displayedThinkingHashes.add(hash);
|
|
80
|
+
}
|
|
81
|
+
const sentText = sentBuffer.get(index) ?? '';
|
|
82
|
+
if (fullText.startsWith(sentText)) {
|
|
83
|
+
const delta = fullText.slice(sentText.length);
|
|
84
|
+
sentBuffer.set(index, fullText);
|
|
85
|
+
if (delta) {
|
|
86
|
+
return { ...p, text: delta, thinking: delta };
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
sentBuffer.set(index, fullText);
|
|
91
|
+
return part;
|
|
92
|
+
}
|
|
93
|
+
return part;
|
|
94
|
+
});
|
|
95
|
+
const filteredParts = newParts.filter((p) => p !== null);
|
|
96
|
+
return {
|
|
97
|
+
...cand,
|
|
98
|
+
content: { ...content, parts: filteredParts },
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
return { ...resp, candidates: newCandidates };
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(resp.content)) {
|
|
104
|
+
let thinkingIndex = 0;
|
|
105
|
+
const newContent = resp.content.map((block) => {
|
|
106
|
+
const b = block;
|
|
107
|
+
if (b?.type === 'thinking') {
|
|
108
|
+
const fullText = (b.thinking || b.text || '');
|
|
109
|
+
if (displayedThinkingHashes) {
|
|
110
|
+
const hash = hashString(fullText);
|
|
111
|
+
if (displayedThinkingHashes.has(hash)) {
|
|
112
|
+
sentBuffer.set(thinkingIndex, fullText);
|
|
113
|
+
thinkingIndex++;
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
displayedThinkingHashes.add(hash);
|
|
117
|
+
}
|
|
118
|
+
const sentText = sentBuffer.get(thinkingIndex) ?? '';
|
|
119
|
+
if (fullText.startsWith(sentText)) {
|
|
120
|
+
const delta = fullText.slice(sentText.length);
|
|
121
|
+
sentBuffer.set(thinkingIndex, fullText);
|
|
122
|
+
thinkingIndex++;
|
|
123
|
+
if (delta) {
|
|
124
|
+
return { ...b, thinking: delta, text: delta };
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
sentBuffer.set(thinkingIndex, fullText);
|
|
129
|
+
thinkingIndex++;
|
|
130
|
+
return block;
|
|
131
|
+
}
|
|
132
|
+
return block;
|
|
133
|
+
});
|
|
134
|
+
const filteredContent = newContent.filter((b) => b !== null);
|
|
135
|
+
return { ...resp, content: filteredContent };
|
|
136
|
+
}
|
|
137
|
+
return response;
|
|
138
|
+
}
|
|
139
|
+
export function transformSseLine(line, signatureStore, thoughtBuffer, sentThinkingBuffer, callbacks, options, debugState) {
|
|
140
|
+
if (!line.startsWith('data:')) {
|
|
141
|
+
return line;
|
|
142
|
+
}
|
|
143
|
+
const json = line.slice(5).trim();
|
|
144
|
+
if (!json) {
|
|
145
|
+
return line;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const parsed = JSON.parse(json);
|
|
149
|
+
if (parsed.response !== undefined) {
|
|
150
|
+
// Extract and report usage metadata if present (usually in the final chunk)
|
|
151
|
+
if (callbacks.onUsage) {
|
|
152
|
+
const resp = parsed.response;
|
|
153
|
+
const usageMeta = resp.usageMetadata;
|
|
154
|
+
if (usageMeta && typeof usageMeta === 'object') {
|
|
155
|
+
const toNumber = (v) => typeof v === 'number' && Number.isFinite(v) ? v : undefined;
|
|
156
|
+
callbacks.onUsage({
|
|
157
|
+
totalTokenCount: toNumber(usageMeta.totalTokenCount),
|
|
158
|
+
promptTokenCount: toNumber(usageMeta.promptTokenCount),
|
|
159
|
+
candidatesTokenCount: toNumber(usageMeta.candidatesTokenCount),
|
|
160
|
+
cachedContentTokenCount: toNumber(usageMeta.cachedContentTokenCount),
|
|
161
|
+
thoughtsTokenCount: toNumber(usageMeta.thoughtsTokenCount),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (options.cacheSignatures && options.signatureSessionKey) {
|
|
166
|
+
cacheThinkingSignaturesFromResponse(parsed.response, options.signatureSessionKey, signatureStore, thoughtBuffer, callbacks.onCacheSignature);
|
|
167
|
+
}
|
|
168
|
+
let response = deduplicateThinkingText(parsed.response, sentThinkingBuffer, options.displayedThinkingHashes);
|
|
169
|
+
if (options.debugText && callbacks.onInjectDebug && !debugState.injected) {
|
|
170
|
+
response = callbacks.onInjectDebug(response, options.debugText);
|
|
171
|
+
debugState.injected = true;
|
|
172
|
+
}
|
|
173
|
+
const transformed = callbacks.transformThinkingParts
|
|
174
|
+
? callbacks.transformThinkingParts(response)
|
|
175
|
+
: response;
|
|
176
|
+
return `data: ${JSON.stringify(transformed)}`;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch (_) { }
|
|
180
|
+
return line;
|
|
181
|
+
}
|
|
182
|
+
export function cacheThinkingSignaturesFromResponse(response, signatureSessionKey, signatureStore, thoughtBuffer, onCacheSignature) {
|
|
183
|
+
if (!response || typeof response !== 'object')
|
|
184
|
+
return;
|
|
185
|
+
const resp = response;
|
|
186
|
+
if (Array.isArray(resp.candidates)) {
|
|
187
|
+
resp.candidates.forEach((candidate, index) => {
|
|
188
|
+
const cand = candidate;
|
|
189
|
+
if (!cand?.content)
|
|
190
|
+
return;
|
|
191
|
+
const content = cand.content;
|
|
192
|
+
if (!Array.isArray(content.parts))
|
|
193
|
+
return;
|
|
194
|
+
content.parts.forEach((part) => {
|
|
195
|
+
const p = part;
|
|
196
|
+
if (p.thought === true || p.type === 'thinking') {
|
|
197
|
+
const text = (p.text || p.thinking || '');
|
|
198
|
+
if (text) {
|
|
199
|
+
const current = thoughtBuffer.get(index) ?? '';
|
|
200
|
+
thoughtBuffer.set(index, current + text);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (p.thoughtSignature) {
|
|
204
|
+
const fullText = thoughtBuffer.get(index) ?? '';
|
|
205
|
+
if (fullText) {
|
|
206
|
+
const signature = p.thoughtSignature;
|
|
207
|
+
onCacheSignature?.(signatureSessionKey, fullText, signature);
|
|
208
|
+
signatureStore.set(signatureSessionKey, { text: fullText, signature });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
if (Array.isArray(resp.content)) {
|
|
215
|
+
let thinkingText = '';
|
|
216
|
+
resp.content.forEach((block) => {
|
|
217
|
+
const b = block;
|
|
218
|
+
if (b?.type === 'thinking') {
|
|
219
|
+
thinkingText += (b.thinking || b.text || '');
|
|
220
|
+
}
|
|
221
|
+
if (b?.signature && thinkingText) {
|
|
222
|
+
const signature = b.signature;
|
|
223
|
+
onCacheSignature?.(signatureSessionKey, thinkingText, signature);
|
|
224
|
+
signatureStore.set(signatureSessionKey, { text: thinkingText, signature });
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
export function createStreamingTransformer(signatureStore, callbacks, options = {}) {
|
|
230
|
+
const decoder = new TextDecoder();
|
|
231
|
+
const encoder = new TextEncoder();
|
|
232
|
+
let buffer = '';
|
|
233
|
+
const thoughtBuffer = createThoughtBuffer();
|
|
234
|
+
const sentThinkingBuffer = createThoughtBuffer();
|
|
235
|
+
const debugState = { injected: false };
|
|
236
|
+
return new TransformStream({
|
|
237
|
+
transform(chunk, controller) {
|
|
238
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
239
|
+
const lines = buffer.split('\n');
|
|
240
|
+
buffer = lines.pop() || '';
|
|
241
|
+
for (const line of lines) {
|
|
242
|
+
const transformedLine = transformSseLine(line, signatureStore, thoughtBuffer, sentThinkingBuffer, callbacks, options, debugState);
|
|
243
|
+
controller.enqueue(encoder.encode(transformedLine + '\n'));
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
flush(controller) {
|
|
247
|
+
buffer += decoder.decode();
|
|
248
|
+
if (buffer) {
|
|
249
|
+
const transformedLine = transformSseLine(buffer, signatureStore, thoughtBuffer, sentThinkingBuffer, callbacks, options, debugState);
|
|
250
|
+
controller.enqueue(encoder.encode(transformedLine));
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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