opencodekit 0.18.17 → 0.18.18

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/dist/index.js CHANGED
@@ -20,7 +20,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
20
 
21
21
  //#endregion
22
22
  //#region package.json
23
- var version = "0.18.17";
23
+ var version = "0.18.18";
24
24
 
25
25
  //#endregion
26
26
  //#region src/utils/license.ts
Binary file
@@ -161,8 +161,8 @@
161
161
  "claude-haiku-4.5": {
162
162
  "attachment": true,
163
163
  "limit": {
164
- "context": 200000,
165
- "output": 64000
164
+ "context": 144000,
165
+ "output": 32000
166
166
  },
167
167
  "options": {
168
168
  "thinking_budget": 10000,
@@ -174,13 +174,13 @@
174
174
  "variants": {
175
175
  "high": {
176
176
  "options": {
177
- "thinking_budget": 8000,
177
+ "thinking_budget": 16000,
178
178
  "type": "enabled"
179
179
  }
180
180
  },
181
181
  "max": {
182
182
  "options": {
183
- "thinking_budget": 16000,
183
+ "thinking_budget": 32000,
184
184
  "type": "enabled"
185
185
  }
186
186
  }
@@ -189,8 +189,8 @@
189
189
  "claude-opus-4.5": {
190
190
  "attachment": true,
191
191
  "limit": {
192
- "context": 200000,
193
- "output": 64000
192
+ "context": 160000,
193
+ "output": 32000
194
194
  },
195
195
  "options": {
196
196
  "thinking_budget": 10000
@@ -201,12 +201,12 @@
201
201
  "variants": {
202
202
  "high": {
203
203
  "options": {
204
- "thinking_budget": 8000
204
+ "thinking_budget": 16000
205
205
  }
206
206
  },
207
207
  "max": {
208
208
  "options": {
209
- "thinking_budget": 16000
209
+ "thinking_budget": 32000
210
210
  }
211
211
  }
212
212
  }
@@ -214,7 +214,7 @@
214
214
  "claude-opus-4.6": {
215
215
  "attachment": true,
216
216
  "limit": {
217
- "context": 200000,
217
+ "context": 144000,
218
218
  "output": 64000
219
219
  },
220
220
  "options": {
@@ -259,21 +259,33 @@
259
259
  "claude-sonnet-4": {
260
260
  "attachment": true,
261
261
  "limit": {
262
- "context": 200000,
263
- "output": 64000
262
+ "context": 216000,
263
+ "output": 16000
264
264
  },
265
265
  "options": {
266
266
  "thinking_budget": 10000
267
267
  },
268
268
  "reasoning": true,
269
269
  "temperature": true,
270
- "tool_call": true
270
+ "tool_call": true,
271
+ "variants": {
272
+ "high": {
273
+ "options": {
274
+ "thinking_budget": 16000
275
+ }
276
+ },
277
+ "max": {
278
+ "options": {
279
+ "thinking_budget": 32000
280
+ }
281
+ }
282
+ }
271
283
  },
272
284
  "claude-sonnet-4.5": {
273
285
  "attachment": true,
274
286
  "limit": {
275
- "context": 200000,
276
- "output": 64000
287
+ "context": 144000,
288
+ "output": 32000
277
289
  },
278
290
  "options": {
279
291
  "thinking_budget": 10000
@@ -284,12 +296,12 @@
284
296
  "variants": {
285
297
  "high": {
286
298
  "options": {
287
- "thinking_budget": 8000
299
+ "thinking_budget": 16000
288
300
  }
289
301
  },
290
302
  "max": {
291
303
  "options": {
292
- "thinking_budget": 16000
304
+ "thinking_budget": 32000
293
305
  }
294
306
  }
295
307
  }
@@ -298,7 +310,7 @@
298
310
  "attachment": true,
299
311
  "limit": {
300
312
  "context": 200000,
301
- "output": 64000
313
+ "output": 32000
302
314
  },
303
315
  "options": {
304
316
  "thinking": {
@@ -355,20 +355,29 @@ const MAX_RESPONSE_API_ID_LENGTH = 64;
355
355
  * Sanitize an ID to fit within the Responses API 64-char limit.
356
356
  * GitHub Copilot returns proprietary long IDs (400+ chars) that violate
357
357
  * the OpenAI spec. We hash them to a deterministic 64-char string.
358
+ * Preserves the original prefix (e.g., "fc_", "msg_", "call_") so that
359
+ * OpenAI's prefix validation passes.
358
360
  * See: https://github.com/vercel/ai/issues/5171
359
361
  */
360
362
  function sanitizeResponseId(id: string): string {
361
363
  if (!id || id.length <= MAX_RESPONSE_API_ID_LENGTH) return id;
362
- // Use a simple hash: take first 8 chars + hash of full string for uniqueness
363
- // Format: "h_" + first 8 chars + "_" + base36 hash (up to ~50 chars total)
364
+ // Detect and preserve the original prefix (e.g., "fc_", "msg_", "call_", "resp_")
365
+ // The OpenAI Responses API validates that IDs start with specific prefixes
366
+ const prefixMatch = id.match(/^([a-z]+_)/);
367
+ const prefix = prefixMatch ? prefixMatch[1] : "";
368
+ // Hash the full ID for deterministic uniqueness
364
369
  let hash = 0;
365
370
  for (let i = 0; i < id.length; i++) {
366
371
  hash = ((hash << 5) - hash + id.charCodeAt(i)) | 0;
367
372
  }
368
373
  const hashStr = Math.abs(hash).toString(36);
369
- const prefix = id.slice(0, 8);
370
- // Ensure total length <= 64: "h_" (2) + prefix (8) + "_" (1) + hash
371
- return `h_${prefix}_${hashStr}`.slice(0, MAX_RESPONSE_API_ID_LENGTH);
374
+ // Take some chars from after the prefix for additional uniqueness
375
+ const afterPrefix = id.slice(prefix.length);
376
+ const maxMiddleLen =
377
+ MAX_RESPONSE_API_ID_LENGTH - prefix.length - hashStr.length - 1;
378
+ const middle = afterPrefix.slice(0, Math.max(0, maxMiddleLen));
379
+ // Format: prefix + middle + "_" + hash (ensure total <= 64)
380
+ return `${prefix}${middle}_${hashStr}`.slice(0, MAX_RESPONSE_API_ID_LENGTH);
372
381
  }
373
382
 
374
383
  /**
@@ -513,7 +522,12 @@ export const CopilotAuthPlugin: Plugin = async ({ client: sdk }) => {
513
522
  return cleanedMsg;
514
523
  }
515
524
 
516
- // If content is an array, check for thinking blocks
525
+ // If content is an array, strip ALL thinking blocks.
526
+ // Reasoning is communicated via reasoning_text/reasoning_opaque
527
+ // fields, not via thinking blocks in the content array.
528
+ // Even thinking blocks WITH signatures can cause
529
+ // "Invalid signature in thinking block" errors when
530
+ // signatures are expired or from a different context.
517
531
  if (Array.isArray(msg.content)) {
518
532
  const hasThinkingBlock = msg.content.some(
519
533
  (part: any) => part.type === "thinking",
@@ -521,22 +535,10 @@ export const CopilotAuthPlugin: Plugin = async ({ client: sdk }) => {
521
535
  if (hasThinkingBlock) {
522
536
  log(
523
537
  "debug",
524
- `Message ${idx} has thinking blocks in content array`,
538
+ `Stripping all thinking blocks from message ${idx}`,
525
539
  );
526
- // Filter out thinking blocks without signatures
527
540
  const cleanedContent = msg.content.filter(
528
- (part: any) => {
529
- if (part.type === "thinking") {
530
- if (!part.signature) {
531
- log(
532
- "warn",
533
- `Removing thinking block without signature`,
534
- );
535
- return false;
536
- }
537
- }
538
- return true;
539
- },
541
+ (part: any) => part.type !== "thinking",
540
542
  );
541
543
  return {
542
544
  ...msg,
@@ -90,24 +90,51 @@ export function createHooks(deps: HookDeps) {
90
90
  }
91
91
  }
92
92
 
93
- // --- Session error: show actual error details ---
93
+ // --- Session error: classify and guide ---
94
94
  if (event.type === "session.error") {
95
95
  const props = event.properties as Record<string, unknown> | undefined;
96
96
  const errorMsg = props?.error
97
- ? String(props.error).slice(0, 120)
97
+ ? String(props.error).slice(0, 200)
98
98
  : props?.message
99
- ? String(props.message).slice(0, 120)
99
+ ? String(props.message).slice(0, 200)
100
100
  : "Unknown error";
101
101
 
102
- // Classify: match the specific AI SDK error pattern
103
- const isTokenOverflow =
102
+ // Log full error for debugging
103
+ await log(`Session error: ${errorMsg}`, "warn");
104
+
105
+ // Classify error and provide specific guidance
106
+ let guidance: string;
107
+ if (
104
108
  /token.{0,20}(exceed|limit)/i.test(errorMsg) ||
105
- errorMsg.includes("context_length_exceeded");
106
- const guidance = isTokenOverflow
107
- ? "Context too large — use /compact or start a new session"
108
- : "Save important learnings with observation tool";
109
+ errorMsg.includes("context_length_exceeded")
110
+ ) {
111
+ guidance = "Context too large — use /compact or start a new session";
112
+ } else if (
113
+ /rate.?limit|429|too many requests/i.test(errorMsg)
114
+ ) {
115
+ guidance = "Rate limited — wait a moment and retry";
116
+ } else if (
117
+ /unauthorized|401|403|auth/i.test(errorMsg)
118
+ ) {
119
+ guidance = "Auth error — check API key or token";
120
+ } else if (
121
+ /timeout|ETIMEDOUT|ECONNRESET|network|fetch failed/i.test(errorMsg)
122
+ ) {
123
+ guidance = "Network error — check connection and retry";
124
+ } else if (
125
+ /invalid.*signature|thinking block/i.test(errorMsg)
126
+ ) {
127
+ guidance = "API format error — try starting a new session";
128
+ } else if (
129
+ /500|502|503|504|internal server|service unavailable/i.test(errorMsg)
130
+ ) {
131
+ guidance = "Server error — retry in a few seconds";
132
+ } else {
133
+ guidance = "Unexpected error — save work with observation tool if needed";
134
+ }
109
135
 
110
- await showToast("Session Error", `${guidance} (${errorMsg})`, "warning");
136
+ const short = errorMsg.length > 80 ? `${errorMsg.slice(0, 80)}…` : errorMsg;
137
+ await showToast("Session Error", `${guidance} (${short})`, "warning");
111
138
  }
112
139
  },
113
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencodekit",
3
- "version": "0.18.17",
3
+ "version": "0.18.18",
4
4
  "description": "CLI tool for bootstrapping and managing OpenCodeKit projects",
5
5
  "keywords": [
6
6
  "agents",