@a1hvdy/cc-openclaw 0.5.2 → 0.7.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.
Files changed (98) hide show
  1. package/dist/src/command-router/cc-handler.js +72 -0
  2. package/dist/src/command-router/cc-handler.js.map +1 -1
  3. package/dist/src/constants.d.ts +9 -0
  4. package/dist/src/constants.js +10 -0
  5. package/dist/src/constants.js.map +1 -1
  6. package/dist/src/engines/persistent-session.d.ts +2 -0
  7. package/dist/src/engines/persistent-session.js +41 -11
  8. package/dist/src/engines/persistent-session.js.map +1 -1
  9. package/dist/src/lib/config.d.ts +2 -0
  10. package/dist/src/lib/config.js +19 -0
  11. package/dist/src/lib/config.js.map +1 -1
  12. package/dist/src/lib/sysprompt-strip.js +12 -12
  13. package/dist/src/lib/sysprompt-strip.js.map +1 -1
  14. package/dist/src/lib/trajectory.d.ts +1 -1
  15. package/dist/src/lib/trajectory.js.map +1 -1
  16. package/dist/src/lib/vendor-paths.d.ts +6 -4
  17. package/dist/src/lib/vendor-paths.js +21 -14
  18. package/dist/src/lib/vendor-paths.js.map +1 -1
  19. package/dist/src/openai-compat/openai-compat.d.ts +7 -1
  20. package/dist/src/openai-compat/openai-compat.js +8 -1
  21. package/dist/src/openai-compat/openai-compat.js.map +1 -1
  22. package/dist/src/openai-compat/sse-translator.d.ts +23 -3
  23. package/dist/src/openai-compat/sse-translator.js +45 -6
  24. package/dist/src/openai-compat/sse-translator.js.map +1 -1
  25. package/dist/src/session-bootstrap/cwd-patch.js +59 -28
  26. package/dist/src/session-bootstrap/cwd-patch.js.map +1 -1
  27. package/dist/src/types.d.ts +1 -0
  28. package/package.json +2 -3
  29. package/vendor/base-oneshot-session.d.ts +0 -87
  30. package/vendor/base-oneshot-session.js +0 -227
  31. package/vendor/base-oneshot-session.js.map +0 -1
  32. package/vendor/circuit-breaker.d.ts +0 -21
  33. package/vendor/circuit-breaker.js +0 -47
  34. package/vendor/circuit-breaker.js.map +0 -1
  35. package/vendor/consensus.d.ts +0 -20
  36. package/vendor/consensus.js +0 -52
  37. package/vendor/consensus.js.map +0 -1
  38. package/vendor/constants.d.ts +0 -130
  39. package/vendor/constants.js +0 -139
  40. package/vendor/constants.js.map +0 -1
  41. package/vendor/council.d.ts +0 -67
  42. package/vendor/council.js +0 -913
  43. package/vendor/council.js.map +0 -1
  44. package/vendor/embedded-server.d.ts +0 -25
  45. package/vendor/embedded-server.js +0 -373
  46. package/vendor/embedded-server.js.map +0 -1
  47. package/vendor/inbox-manager.d.ts +0 -38
  48. package/vendor/inbox-manager.js +0 -111
  49. package/vendor/inbox-manager.js.map +0 -1
  50. package/vendor/index.d.ts +0 -63
  51. package/vendor/index.js +0 -705
  52. package/vendor/index.js.map +0 -1
  53. package/vendor/logger.d.ts +0 -16
  54. package/vendor/logger.js +0 -44
  55. package/vendor/logger.js.map +0 -1
  56. package/vendor/models.d.ts +0 -69
  57. package/vendor/models.js +0 -289
  58. package/vendor/models.js.map +0 -1
  59. package/vendor/openai-compat.d.ts +0 -197
  60. package/vendor/openai-compat.js +0 -765
  61. package/vendor/openai-compat.js.map +0 -1
  62. package/vendor/persistent-codex-session.d.ts +0 -16
  63. package/vendor/persistent-codex-session.js +0 -105
  64. package/vendor/persistent-codex-session.js.map +0 -1
  65. package/vendor/persistent-cursor-session.d.ts +0 -21
  66. package/vendor/persistent-cursor-session.js +0 -241
  67. package/vendor/persistent-cursor-session.js.map +0 -1
  68. package/vendor/persistent-custom-session.d.ts +0 -78
  69. package/vendor/persistent-custom-session.js +0 -937
  70. package/vendor/persistent-custom-session.js.map +0 -1
  71. package/vendor/persistent-gemini-session.d.ts +0 -21
  72. package/vendor/persistent-gemini-session.js +0 -216
  73. package/vendor/persistent-gemini-session.js.map +0 -1
  74. package/vendor/persistent-session.d.ts +0 -74
  75. package/vendor/persistent-session.js +0 -684
  76. package/vendor/persistent-session.js.map +0 -1
  77. package/vendor/proxy/anthropic-adapter.d.ts +0 -136
  78. package/vendor/proxy/anthropic-adapter.js +0 -392
  79. package/vendor/proxy/anthropic-adapter.js.map +0 -1
  80. package/vendor/proxy/handler.d.ts +0 -39
  81. package/vendor/proxy/handler.js +0 -323
  82. package/vendor/proxy/handler.js.map +0 -1
  83. package/vendor/proxy/schema-cleaner.d.ts +0 -11
  84. package/vendor/proxy/schema-cleaner.js +0 -34
  85. package/vendor/proxy/schema-cleaner.js.map +0 -1
  86. package/vendor/proxy/thought-cache.d.ts +0 -19
  87. package/vendor/proxy/thought-cache.js +0 -53
  88. package/vendor/proxy/thought-cache.js.map +0 -1
  89. package/vendor/session-manager.d.ts +0 -211
  90. package/vendor/session-manager.js +0 -1345
  91. package/vendor/session-manager.js.map +0 -1
  92. package/vendor/skill-resolver.js +0 -107
  93. package/vendor/types.d.ts +0 -466
  94. package/vendor/types.js +0 -8
  95. package/vendor/types.js.map +0 -1
  96. package/vendor/validation.d.ts +0 -31
  97. package/vendor/validation.js +0 -104
  98. package/vendor/validation.js.map +0 -1
@@ -1,323 +0,0 @@
1
- /**
2
- * Proxy HTTP Handler — registerHttpRoute handler for OpenClaw Plugin SDK
3
- *
4
- * Receives Anthropic-format requests from Claude Code CLI,
5
- * translates to OpenAI format, forwards to the target provider,
6
- * and translates the response back to Anthropic format.
7
- *
8
- * Supports:
9
- * - Direct Anthropic API passthrough (zero conversion)
10
- * - OpenAI/GPT models via format conversion
11
- * - Gemini models via format conversion + schema cleaning
12
- * - Gateway passthrough (OpenClaw gateway handles routing)
13
- * - Streaming and non-streaming modes
14
- */
15
- import { convertAnthropicToOpenAI, convertOpenAIToAnthropic, convertStreamOpenAIToAnthropic, } from './anthropic-adapter.js';
16
- import { injectThoughtSigs } from './thought-cache.js';
17
- import { resolveProvider } from '../models.js';
18
- import { FETCH_TIMEOUT_MS } from '../constants.js';
19
- /** Create an AbortSignal that fires after the given timeout */
20
- function fetchSignal(ms = FETCH_TIMEOUT_MS) {
21
- return AbortSignal.timeout(ms);
22
- }
23
- // ─── Retry Logic ────────────────────────────────────────────────────────────
24
- const RETRY_STATUS_CODES = new Set([429, 500, 502, 503, 504]);
25
- const MAX_RETRIES = 2;
26
- const RETRY_BASE_DELAY_MS = 1_000;
27
- async function fetchWithRetry(url, init, maxRetries = MAX_RETRIES) {
28
- let lastError = null;
29
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
30
- try {
31
- const resp = await fetch(url, init);
32
- if (!RETRY_STATUS_CODES.has(resp.status) || attempt === maxRetries)
33
- return resp;
34
- // Check Retry-After header
35
- const retryAfter = resp.headers.get('retry-after');
36
- const delayMs = retryAfter
37
- ? Math.min(parseInt(retryAfter, 10) * 1000 || RETRY_BASE_DELAY_MS, 30_000)
38
- : RETRY_BASE_DELAY_MS * Math.pow(2, attempt);
39
- await new Promise((r) => setTimeout(r, delayMs));
40
- }
41
- catch (err) {
42
- lastError = err;
43
- if (attempt === maxRetries)
44
- throw lastError;
45
- await new Promise((r) => setTimeout(r, RETRY_BASE_DELAY_MS * Math.pow(2, attempt)));
46
- }
47
- }
48
- throw lastError || new Error('Fetch failed after retries');
49
- }
50
- // ─── Extract Real Model from URL ─────────────────────────────────────────────
51
- /**
52
- * Claude Code CLI passes the real model via URL path:
53
- * /real/<model>/v1/messages
54
- *
55
- * Extract the model name from the URL (first segment after /real/).
56
- */
57
- function extractRealModel(url) {
58
- const match = url.match(/\/real\/([^/]+)/);
59
- return match ? decodeURIComponent(match[1]) : null;
60
- }
61
- // ─── Handler ─────────────────────────────────────────────────────────────────
62
- export function createProxyHandler(config, env) {
63
- /**
64
- * Main proxy handler — receives Anthropic-format request, returns Anthropic-format response.
65
- */
66
- return async function handleProxy(req, res) {
67
- // HEAD/GET probes from Claude Code CLI (no body) — respond 200
68
- if (req.method === 'HEAD' || req.method === 'GET') {
69
- res.status(200).json({ status: 'ok' });
70
- return true;
71
- }
72
- try {
73
- const body = (await req.json());
74
- // Determine real model from URL path or request body
75
- const urlModel = extractRealModel(req.url);
76
- const requestModel = urlModel || body.model;
77
- body.model = requestModel;
78
- const { provider, apiModel } = resolveProvider(requestModel);
79
- const isStream = body.stream ?? false;
80
- // ─── Direct Anthropic passthrough ─────────────────────────────
81
- if (provider === 'anthropic') {
82
- return await forwardToAnthropic(body, env, res, isStream);
83
- }
84
- // ─── Gateway passthrough ──────────────────────────────────────
85
- if (env.gatewayUrl && env.gatewayKey) {
86
- return await forwardToGateway(body, apiModel, env, res, isStream, requestModel);
87
- }
88
- // ─── Direct provider via format conversion ────────────────────
89
- const openaiReq = convertAnthropicToOpenAI(body);
90
- openaiReq.model = apiModel;
91
- // Inject thought signatures for Gemini round-trip
92
- if (provider === 'google') {
93
- injectThoughtSigs(openaiReq.messages);
94
- }
95
- // Determine API endpoint and key
96
- let apiUrl;
97
- let apiKey;
98
- if (provider === 'google') {
99
- apiUrl = 'https://generativelanguage.googleapis.com/v1beta/chat/completions';
100
- apiKey = env.geminiApiKey || '';
101
- }
102
- else {
103
- apiUrl = 'https://api.openai.com/v1/chat/completions';
104
- apiKey = env.openaiApiKey || '';
105
- }
106
- if (!apiKey) {
107
- res.status(401).json({ error: `No API key configured for provider: ${provider}` });
108
- return true;
109
- }
110
- if (isStream) {
111
- return await handleStreamingResponse(apiUrl, apiKey, openaiReq, res, requestModel);
112
- }
113
- else {
114
- return await handleNonStreamingResponse(apiUrl, apiKey, openaiReq, res, requestModel);
115
- }
116
- }
117
- catch (err) {
118
- console.error('[proxy] Error:', err.message);
119
- const message = err.name === 'TimeoutError' ? 'Upstream request timed out' : 'Internal proxy error';
120
- res.status(500).json({
121
- type: 'error',
122
- error: { type: 'server_error', message },
123
- });
124
- return true;
125
- }
126
- };
127
- }
128
- // ─── Anthropic Passthrough ───────────────────────────────────────────────────
129
- async function forwardToAnthropic(body, env, res, isStream) {
130
- const apiKey = env.anthropicApiKey;
131
- if (!apiKey) {
132
- res.status(401).json({ error: 'No ANTHROPIC_API_KEY configured' });
133
- return true;
134
- }
135
- const fetchInit = {
136
- method: 'POST',
137
- headers: {
138
- 'Content-Type': 'application/json',
139
- 'x-api-key': apiKey,
140
- 'anthropic-version': '2023-06-01',
141
- },
142
- body: JSON.stringify(body),
143
- signal: fetchSignal(),
144
- };
145
- if (isStream) {
146
- const resp = await fetch('https://api.anthropic.com/v1/messages', fetchInit);
147
- res.setHeader('Content-Type', 'text/event-stream');
148
- res.setHeader('Cache-Control', 'no-cache');
149
- res.flushHeaders?.();
150
- const reader = resp.body?.getReader();
151
- if (reader) {
152
- const decoder = new TextDecoder();
153
- try {
154
- while (true) {
155
- const { done, value } = await reader.read();
156
- if (done)
157
- break;
158
- res.write(decoder.decode(value, { stream: true }));
159
- }
160
- }
161
- finally {
162
- reader.cancel().catch(() => { });
163
- }
164
- }
165
- res.end();
166
- }
167
- else {
168
- const resp = await fetchWithRetry('https://api.anthropic.com/v1/messages', fetchInit);
169
- const data = await resp.json();
170
- res.status(resp.status).json(data);
171
- }
172
- return true;
173
- }
174
- // ─── Gateway Passthrough ─────────────────────────────────────────────────────
175
- async function forwardToGateway(body, apiModel, env, res, isStream, originalModel) {
176
- const openaiReq = convertAnthropicToOpenAI(body);
177
- // OpenClaw gateway requires model="openclaw" or "openclaw/<agentId>"
178
- openaiReq.model = apiModel.startsWith('openclaw') ? apiModel : 'openclaw';
179
- // Inject thought signatures for Gemini
180
- injectThoughtSigs(openaiReq.messages);
181
- const gatewayInit = {
182
- method: 'POST',
183
- headers: {
184
- 'Content-Type': 'application/json',
185
- Authorization: `Bearer ${env.gatewayKey}`,
186
- 'x-openclaw-agent-id': 'claude-code-raw',
187
- },
188
- body: JSON.stringify(openaiReq),
189
- signal: fetchSignal(),
190
- };
191
- if (isStream) {
192
- const resp = await fetch(`${env.gatewayUrl}/chat/completions`, gatewayInit);
193
- if (!resp.ok) {
194
- const err = await resp.text();
195
- console.error('[proxy] Gateway error:', resp.status, err);
196
- res
197
- .status(resp.status)
198
- .json({ type: 'error', error: { type: 'gateway_error', message: 'Upstream gateway error' } });
199
- return true;
200
- }
201
- res.setHeader('Content-Type', 'text/event-stream');
202
- res.setHeader('Cache-Control', 'no-cache');
203
- res.flushHeaders?.();
204
- const reader = resp.body?.getReader();
205
- if (!reader) {
206
- res.end();
207
- return true;
208
- }
209
- try {
210
- const lineStream = readSSELines(reader);
211
- for await (const sseChunk of convertStreamOpenAIToAnthropic(lineStream, originalModel)) {
212
- res.write(sseChunk);
213
- }
214
- }
215
- finally {
216
- reader.cancel().catch(() => { });
217
- }
218
- res.end();
219
- }
220
- else {
221
- const resp = await fetchWithRetry(`${env.gatewayUrl}/chat/completions`, gatewayInit);
222
- if (!resp.ok) {
223
- const err = await resp.text();
224
- console.error('[proxy] Gateway error:', resp.status, err);
225
- res
226
- .status(resp.status)
227
- .json({ type: 'error', error: { type: 'gateway_error', message: 'Upstream gateway error' } });
228
- return true;
229
- }
230
- const data = (await resp.json());
231
- const anthropicResp = convertOpenAIToAnthropic(data, originalModel);
232
- res.status(200).json(anthropicResp);
233
- }
234
- return true;
235
- }
236
- // ─── Direct Provider ─────────────────────────────────────────────────────────
237
- async function handleNonStreamingResponse(apiUrl, apiKey, openaiReq, res, originalModel) {
238
- const resp = await fetchWithRetry(apiUrl, {
239
- method: 'POST',
240
- headers: {
241
- 'Content-Type': 'application/json',
242
- Authorization: `Bearer ${apiKey}`,
243
- },
244
- body: JSON.stringify(Object.assign({}, openaiReq, { stream: false })),
245
- signal: fetchSignal(),
246
- });
247
- if (!resp.ok) {
248
- const err = await resp.text();
249
- console.error('[proxy] API error:', resp.status, err);
250
- res.status(resp.status).json({ type: 'error', error: { type: 'api_error', message: 'Upstream API error' } });
251
- return true;
252
- }
253
- const data = (await resp.json());
254
- const anthropicResp = convertOpenAIToAnthropic(data, originalModel);
255
- res.status(200).json(anthropicResp);
256
- return true;
257
- }
258
- async function handleStreamingResponse(apiUrl, apiKey, openaiReq, res, originalModel) {
259
- const resp = await fetchWithRetry(apiUrl, {
260
- method: 'POST',
261
- headers: {
262
- 'Content-Type': 'application/json',
263
- Authorization: `Bearer ${apiKey}`,
264
- },
265
- body: JSON.stringify(Object.assign({}, openaiReq, { stream: true })),
266
- signal: fetchSignal(),
267
- }, 1);
268
- if (!resp.ok) {
269
- const err = await resp.text();
270
- console.error('[proxy] Streaming API error:', resp.status, err);
271
- res.status(resp.status).json({ type: 'error', error: { type: 'api_error', message: 'Upstream API error' } });
272
- return true;
273
- }
274
- res.setHeader('Content-Type', 'text/event-stream');
275
- res.setHeader('Cache-Control', 'no-cache');
276
- res.flushHeaders?.();
277
- const reader = resp.body?.getReader();
278
- if (!reader) {
279
- res.end();
280
- return true;
281
- }
282
- const heartbeat = setInterval(() => {
283
- try {
284
- res.write(':keepalive\n\n');
285
- }
286
- catch {
287
- /* client gone */
288
- }
289
- }, 15_000);
290
- try {
291
- const lineStream = readSSELines(reader);
292
- for await (const sseChunk of convertStreamOpenAIToAnthropic(lineStream, originalModel)) {
293
- res.write(sseChunk);
294
- }
295
- }
296
- finally {
297
- clearInterval(heartbeat);
298
- reader.cancel().catch(() => { });
299
- }
300
- res.end();
301
- return true;
302
- }
303
- // ─── SSE Line Reader ─────────────────────────────────────────────────────────
304
- async function* readSSELines(reader) {
305
- const decoder = new TextDecoder();
306
- let buffer = '';
307
- while (true) {
308
- const { done, value } = await reader.read();
309
- if (done)
310
- break;
311
- buffer += decoder.decode(value, { stream: true });
312
- const lines = buffer.split('\n');
313
- buffer = lines.pop() || '';
314
- for (const line of lines) {
315
- const trimmed = line.trim();
316
- if (trimmed)
317
- yield trimmed;
318
- }
319
- }
320
- if (buffer.trim())
321
- yield buffer.trim();
322
- }
323
- //# sourceMappingURL=handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/proxy/handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,8BAA8B,GAG/B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO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AM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;QAE3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,OAAO;gBAAE,MAAM,OAAO,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,EAAE;QAAE,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Gemini Tool Schema Cleaner
3
- *
4
- * Gemini doesn't support certain JSON Schema fields that Anthropic tools use.
5
- * This recursively cleans schemas for compatibility.
6
- */
7
- /**
8
- * Recursively clean a JSON Schema for Gemini compatibility.
9
- * Removes unsupported fields and string formats.
10
- */
11
- export declare function cleanGeminiSchema(schema: unknown): unknown;
@@ -1,34 +0,0 @@
1
- /**
2
- * Gemini Tool Schema Cleaner
3
- *
4
- * Gemini doesn't support certain JSON Schema fields that Anthropic tools use.
5
- * This recursively cleans schemas for compatibility.
6
- */
7
- const UNSUPPORTED_KEYS = new Set(['additionalProperties', 'default', '$schema']);
8
- const ALLOWED_STRING_FORMATS = new Set(['enum', 'date-time']);
9
- /**
10
- * Recursively clean a JSON Schema for Gemini compatibility.
11
- * Removes unsupported fields and string formats.
12
- */
13
- export function cleanGeminiSchema(schema) {
14
- if (schema === null || schema === undefined || typeof schema !== 'object')
15
- return schema;
16
- if (Array.isArray(schema))
17
- return schema.map(cleanGeminiSchema);
18
- const obj = schema;
19
- const cleaned = {};
20
- for (const [key, value] of Object.entries(obj)) {
21
- // Skip unsupported keys
22
- if (UNSUPPORTED_KEYS.has(key))
23
- continue;
24
- // Clean string format restrictions
25
- if (key === 'format' && obj.type === 'string') {
26
- if (typeof value === 'string' && !ALLOWED_STRING_FORMATS.has(value))
27
- continue;
28
- }
29
- // Recurse into nested objects/arrays
30
- cleaned[key] = cleanGeminiSchema(value);
31
- }
32
- return cleaned;
33
- }
34
- //# sourceMappingURL=schema-cleaner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-cleaner.js","sourceRoot":"","sources":["../../../src/proxy/schema-cleaner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,sBAAsB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AACjF,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAE9D;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IACzF,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAEhE,MAAM,GAAG,GAAG,MAAiC,CAAC;IAC9C,MAAM,OAAO,GAA4B,EAAE,CAAC;IAE5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,wBAAwB;QACxB,IAAI,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAExC,mCAAmC;QACnC,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,SAAS;QAChF,CAAC;QAED,qCAAqC;QACrC,OAAO,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Thought Signature Cache — Gemini round-trip support
3
- *
4
- * Gemini 2.5+ with thinking requires `thought_signature` in tool_calls
5
- * for 2nd+ turns. We cache signatures from responses and inject on next request.
6
- *
7
- * Uses in-memory LRU cache (no file I/O needed in plugin context).
8
- */
9
- /** Cache a thought signature from a tool call response */
10
- export declare function cacheThoughtSig(toolCallId: string, signature: string): void;
11
- /** Get a cached thought signature for a tool call */
12
- export declare function getThoughtSig(toolCallId: string): string;
13
- /**
14
- * Inject cached thought signatures into messages for Gemini round-trip.
15
- * Mutates the messages array in place.
16
- */
17
- export declare function injectThoughtSigs(messages: Array<Record<string, unknown>>): void;
18
- /** Clear the cache (for testing) */
19
- export declare function clearCache(): void;
@@ -1,53 +0,0 @@
1
- /**
2
- * Thought Signature Cache — Gemini round-trip support
3
- *
4
- * Gemini 2.5+ with thinking requires `thought_signature` in tool_calls
5
- * for 2nd+ turns. We cache signatures from responses and inject on next request.
6
- *
7
- * Uses in-memory LRU cache (no file I/O needed in plugin context).
8
- */
9
- const MAX_CACHE_SIZE = 100;
10
- const cache = new Map();
11
- /** Cache a thought signature from a tool call response */
12
- export function cacheThoughtSig(toolCallId, signature) {
13
- if (!toolCallId || !signature)
14
- return;
15
- // Evict oldest if over limit
16
- if (cache.size >= MAX_CACHE_SIZE) {
17
- const oldest = cache.keys().next().value;
18
- if (oldest !== undefined)
19
- cache.delete(oldest);
20
- }
21
- cache.set(toolCallId, signature);
22
- }
23
- /** Get a cached thought signature for a tool call */
24
- export function getThoughtSig(toolCallId) {
25
- return cache.get(toolCallId) || '';
26
- }
27
- /**
28
- * Inject cached thought signatures into messages for Gemini round-trip.
29
- * Mutates the messages array in place.
30
- */
31
- export function injectThoughtSigs(messages) {
32
- for (const msg of messages) {
33
- if (msg.role !== 'assistant')
34
- continue;
35
- const toolCalls = msg.tool_calls;
36
- if (!toolCalls)
37
- continue;
38
- for (const tc of toolCalls) {
39
- const id = tc.id;
40
- if (!id)
41
- continue;
42
- const sig = getThoughtSig(id);
43
- if (sig) {
44
- tc.extra_content = { google: { thought_signature: sig } };
45
- }
46
- }
47
- }
48
- }
49
- /** Clear the cache (for testing) */
50
- export function clearCache() {
51
- cache.clear();
52
- }
53
- //# sourceMappingURL=thought-cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thought-cache.js","sourceRoot":"","sources":["../../../src/proxy/thought-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;AAExC,0DAA0D;AAC1D,MAAM,UAAU,eAAe,CAAC,UAAkB,EAAE,SAAiB;IACnE,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS;QAAE,OAAO;IAEtC,6BAA6B;IAC7B,IAAI,KAAK,CAAC,IAAI,IAAI,cAAc,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;QACzC,IAAI,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AACnC,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAwC;IACxE,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,GAAG,CAAC,IAAI,KAAK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