opencode-anthropic-fix 0.1.14 → 0.1.15
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/index.mjs +26 -0
- package/lib/config.mjs +11 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2882,6 +2882,32 @@ export async function AnthropicAuthPlugin({ client, project, directory, worktree
|
|
|
2882
2882
|
}
|
|
2883
2883
|
}
|
|
2884
2884
|
|
|
2885
|
+
// Opt-in: dump outgoing request bodies to disk so the user can
|
|
2886
|
+
// diff them across turns and see what's invalidating the cache.
|
|
2887
|
+
// Rotates at 10 files to cap disk usage. Files live under
|
|
2888
|
+
// ~/.opencode/opencode-anthropic-fix/request-dumps/.
|
|
2889
|
+
if (config.token_economy?.debug_dump_bodies === true && typeof body === "string") {
|
|
2890
|
+
try {
|
|
2891
|
+
const fs = await import("node:fs");
|
|
2892
|
+
const path = await import("node:path");
|
|
2893
|
+
const os = await import("node:os");
|
|
2894
|
+
const dir = path.join(os.homedir(), ".opencode", "opencode-anthropic-fix", "request-dumps");
|
|
2895
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
2896
|
+
// Rotate: keep last 10
|
|
2897
|
+
const existing = fs
|
|
2898
|
+
.readdirSync(dir)
|
|
2899
|
+
.filter((f) => f.startsWith("req-") && f.endsWith(".json"))
|
|
2900
|
+
.sort();
|
|
2901
|
+
while (existing.length >= 10) {
|
|
2902
|
+
fs.unlinkSync(path.join(dir, existing.shift()));
|
|
2903
|
+
}
|
|
2904
|
+
const ts = new Date().toISOString().replace(/[:.]/g, "-");
|
|
2905
|
+
fs.writeFileSync(path.join(dir, `req-${ts}.json`), body);
|
|
2906
|
+
} catch {
|
|
2907
|
+
// Disk full, permissions, whatever — never block the request.
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2885
2911
|
// Build headers with the selected account's token
|
|
2886
2912
|
const requestHeaders = buildRequestHeaders(
|
|
2887
2913
|
input,
|
package/lib/config.mjs
CHANGED
|
@@ -201,6 +201,13 @@ export const DEFAULT_CONFIG = {
|
|
|
201
201
|
* classified as "main-thread" (see classifyRequestRole). */
|
|
202
202
|
context_hint: false,
|
|
203
203
|
|
|
204
|
+
/** Dump outgoing request bodies to
|
|
205
|
+
* `~/.opencode/opencode-anthropic-fix/request-dumps/` (rotating, last 10).
|
|
206
|
+
* Diagnostic tool — enable, run 3-4 conversation turns, ship the files
|
|
207
|
+
* so we can diff what's changing between turns. Writes raw JSON bodies,
|
|
208
|
+
* so contains user conversation content — don't enable on a shared host. */
|
|
209
|
+
debug_dump_bodies: false,
|
|
210
|
+
|
|
204
211
|
/** Conservative mode (default ON). Disables every history-rewriting and
|
|
205
212
|
* tool-array transform below that can invalidate the prompt-cache prefix
|
|
206
213
|
* turn-to-turn. Rationale: every rewrite risks breaking the 1h cache,
|
|
@@ -656,6 +663,10 @@ function validateConfig(raw) {
|
|
|
656
663
|
typeof te.redact_thinking === "boolean" ? te.redact_thinking : DEFAULT_CONFIG.token_economy.redact_thinking,
|
|
657
664
|
context_hint: typeof te.context_hint === "boolean" ? te.context_hint : DEFAULT_CONFIG.token_economy.context_hint,
|
|
658
665
|
conservative: typeof te.conservative === "boolean" ? te.conservative : DEFAULT_CONFIG.token_economy.conservative,
|
|
666
|
+
debug_dump_bodies:
|
|
667
|
+
typeof te.debug_dump_bodies === "boolean"
|
|
668
|
+
? te.debug_dump_bodies
|
|
669
|
+
: DEFAULT_CONFIG.token_economy.debug_dump_bodies,
|
|
659
670
|
ttl_thinking_strip:
|
|
660
671
|
typeof te.ttl_thinking_strip === "boolean"
|
|
661
672
|
? te.ttl_thinking_strip
|