opencodekit 0.18.11 → 0.18.13
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 +343 -6
- package/dist/template/.opencode/memory.db +0 -0
- package/dist/template/.opencode/memory.db-shm +0 -0
- package/dist/template/.opencode/memory.db-wal +0 -0
- package/dist/template/.opencode/opencode.json +1932 -1430
- package/dist/template/.opencode/plugin/copilot-auth.ts +61 -2
- package/package.json +3 -1
|
@@ -87,8 +87,47 @@ const RATE_LIMIT_CONFIG = {
|
|
|
87
87
|
maxDelayMs: 30000, // Cap at 30 seconds
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
// Maximum length for item IDs in the OpenAI Responses API
|
|
91
|
+
const MAX_RESPONSE_API_ID_LENGTH = 64;
|
|
92
|
+
/**
|
|
93
|
+
* Sanitize an ID to fit within the Responses API 64-char limit.
|
|
94
|
+
* GitHub Copilot returns proprietary long IDs (400+ chars) that violate
|
|
95
|
+
* the OpenAI spec. We hash them to a deterministic 64-char string.
|
|
96
|
+
* See: https://github.com/vercel/ai/issues/5171
|
|
97
|
+
*/
|
|
98
|
+
function sanitizeResponseId(id: string): string {
|
|
99
|
+
if (!id || id.length <= MAX_RESPONSE_API_ID_LENGTH) return id;
|
|
100
|
+
// Use a simple hash: take first 8 chars + hash of full string for uniqueness
|
|
101
|
+
// Format: "h_" + first 8 chars + "_" + base36 hash (up to ~50 chars total)
|
|
102
|
+
let hash = 0;
|
|
103
|
+
for (let i = 0; i < id.length; i++) {
|
|
104
|
+
hash = ((hash << 5) - hash + id.charCodeAt(i)) | 0;
|
|
105
|
+
}
|
|
106
|
+
const hashStr = Math.abs(hash).toString(36);
|
|
107
|
+
const prefix = id.slice(0, 8);
|
|
108
|
+
// Ensure total length <= 64: "h_" (2) + prefix (8) + "_" (1) + hash
|
|
109
|
+
return `h_${prefix}_${hashStr}`.slice(0, MAX_RESPONSE_API_ID_LENGTH);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Sanitize all IDs in a Responses API input array.
|
|
114
|
+
* Recursively checks `id` and `call_id` fields on each input item.
|
|
115
|
+
*/
|
|
116
|
+
function sanitizeResponseInputIds(input: any[]): any[] {
|
|
117
|
+
return input.map((item: any) => {
|
|
118
|
+
if (!item || typeof item !== "object") return item;
|
|
119
|
+
const sanitized = { ...item };
|
|
120
|
+
if (typeof sanitized.id === "string" && sanitized.id.length > MAX_RESPONSE_API_ID_LENGTH) {
|
|
121
|
+
sanitized.id = sanitizeResponseId(sanitized.id);
|
|
122
|
+
}
|
|
123
|
+
if (typeof sanitized.call_id === "string" && sanitized.call_id.length > MAX_RESPONSE_API_ID_LENGTH) {
|
|
124
|
+
sanitized.call_id = sanitizeResponseId(sanitized.call_id);
|
|
125
|
+
}
|
|
126
|
+
return sanitized;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
90
130
|
/**
|
|
91
|
-
* Calculate delay with exponential backoff and jitter
|
|
92
131
|
* Retries: 2s, 4s, 8s (with jitter)
|
|
93
132
|
*/
|
|
94
133
|
function calculateRetryDelay(attempt: number): number {
|
|
@@ -291,7 +330,27 @@ export const CopilotAuthPlugin: Plugin = async ({ client: sdk }) => {
|
|
|
291
330
|
|
|
292
331
|
// Responses API
|
|
293
332
|
if (body?.input) {
|
|
294
|
-
|
|
333
|
+
// Sanitize long IDs from Copilot backend (can be 400+ chars)
|
|
334
|
+
// OpenAI Responses API enforces a 64-char max on item IDs
|
|
335
|
+
const sanitizedInput = sanitizeResponseInputIds(body.input);
|
|
336
|
+
const inputWasSanitized = sanitizedInput !== body.input &&
|
|
337
|
+
JSON.stringify(sanitizedInput) !== JSON.stringify(body.input);
|
|
338
|
+
|
|
339
|
+
if (inputWasSanitized) {
|
|
340
|
+
log("info", "Sanitized long IDs in Responses API input", {
|
|
341
|
+
original_count: body.input.filter(
|
|
342
|
+
(item: any) =>
|
|
343
|
+
(typeof item?.id === "string" && item.id.length > MAX_RESPONSE_API_ID_LENGTH) ||
|
|
344
|
+
(typeof item?.call_id === "string" && item.call_id.length > MAX_RESPONSE_API_ID_LENGTH),
|
|
345
|
+
).length,
|
|
346
|
+
});
|
|
347
|
+
modifiedBody = {
|
|
348
|
+
...(modifiedBody || body),
|
|
349
|
+
input: sanitizedInput,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
isAgentCall = (sanitizedInput || body.input).some(
|
|
295
354
|
(item: any) =>
|
|
296
355
|
item?.role === "assistant" ||
|
|
297
356
|
(item?.type &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencodekit",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.13",
|
|
4
4
|
"description": "CLI tool for bootstrapping and managing OpenCodeKit projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -51,6 +51,8 @@
|
|
|
51
51
|
"cac": "^6.7.14",
|
|
52
52
|
"cli-table3": "^0.6.5",
|
|
53
53
|
"diff": "^8.0.3",
|
|
54
|
+
"env-paths": "^4.0.0",
|
|
55
|
+
"node-machine-id": "^1.1.12",
|
|
54
56
|
"ora": "^9.3.0",
|
|
55
57
|
"picocolors": "^1.1.1",
|
|
56
58
|
"zod": "^3.25.76"
|