@xtruder/opencode-claude-max-plugin 2.1.0 → 2.1.2
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/build/index.d.ts +8 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/model.d.ts.map +1 -1
- package/build/prompt.d.ts.map +1 -1
- package/build/provider-metadata.d.ts +15 -0
- package/build/provider-metadata.d.ts.map +1 -0
- package/build/server.d.ts.map +1 -1
- package/build/server.js +3 -2
- package/build/{src-BU2jiU0u.js → src-BALxhaEC.js} +89 -33
- package/build/stream.d.ts.map +1 -1
- package/package.json +2 -2
package/build/index.d.ts
CHANGED
|
@@ -5,14 +5,17 @@ export declare const CLAUDE_CODE_OPUS5_SYSTEM_PROMPT: string;
|
|
|
5
5
|
export declare const CLAUDE_CODE_SONNET5_SYSTEM_PROMPT: string;
|
|
6
6
|
export declare const CLAUDE_CODE_SONNET55_SYSTEM_PROMPT: string;
|
|
7
7
|
export declare const CLAUDE_CODE_FABLE5_SYSTEM_PROMPT: string;
|
|
8
|
+
export declare const CLAUDE_CODE_FABLE51_SYSTEM_PROMPT: string;
|
|
8
9
|
/**
|
|
9
10
|
* Select the Claude Code system prompt that matches the given model.
|
|
10
11
|
*
|
|
11
|
-
* Claude Code ships per-model prompts. Sonnet 5.5
|
|
12
|
-
* without delivery and correction guidance; Sonnet 5 gets
|
|
13
|
-
* harness; Opus 5 gets its condensed scope, delivery, and
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* Claude Code ships per-model prompts. Sonnet 5.5 and Opus 5.5 share the
|
|
13
|
+
* condensed harness without delivery and correction guidance; Sonnet 5 gets
|
|
14
|
+
* its long-form harness; Opus 5 gets its condensed scope, delivery, and
|
|
15
|
+
* correction guidance; Fable 5.1 gets delivery guidance and strict
|
|
16
|
+
* final-message writing rules; Fable 5 gets its communication guidance;
|
|
17
|
+
* Opus 4.8 gets the shorter earlier harness. Older models get the legacy
|
|
18
|
+
* long-form prompt.
|
|
16
19
|
*/
|
|
17
20
|
export declare function selectClaudePromptForModel(modelId: string): string;
|
|
18
21
|
export declare const PROVIDER_ID = "anthropic-sdk";
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/build/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { CLAUDE_CODE_FABLE5_SYSTEM_PROMPT, CLAUDE_CODE_NEW_SYSTEM_PROMPT, CLAUDE_CODE_OPUS5_SYSTEM_PROMPT, CLAUDE_CODE_SONNET55_SYSTEM_PROMPT, CLAUDE_CODE_SONNET5_SYSTEM_PROMPT, CLAUDE_CODE_SYSTEM_PROMPT, PROVIDER_ID, buildPluginModels, createAnthropicSDK, createAnthropicSDK as default, resolveAuth, selectClaudePromptForModel };
|
|
1
|
+
import { a as CLAUDE_CODE_SONNET55_SYSTEM_PROMPT, c as PROVIDER_ID, d as resolveAuth, f as selectClaudePromptForModel, i as CLAUDE_CODE_OPUS5_SYSTEM_PROMPT, l as buildPluginModels, n as CLAUDE_CODE_FABLE5_SYSTEM_PROMPT, o as CLAUDE_CODE_SONNET5_SYSTEM_PROMPT, r as CLAUDE_CODE_NEW_SYSTEM_PROMPT, s as CLAUDE_CODE_SYSTEM_PROMPT, t as CLAUDE_CODE_FABLE51_SYSTEM_PROMPT, u as createAnthropicSDK } from "./src-BALxhaEC.js";
|
|
2
|
+
export { CLAUDE_CODE_FABLE51_SYSTEM_PROMPT, CLAUDE_CODE_FABLE5_SYSTEM_PROMPT, CLAUDE_CODE_NEW_SYSTEM_PROMPT, CLAUDE_CODE_OPUS5_SYSTEM_PROMPT, CLAUDE_CODE_SONNET55_SYSTEM_PROMPT, CLAUDE_CODE_SONNET5_SYSTEM_PROMPT, CLAUDE_CODE_SYSTEM_PROMPT, PROVIDER_ID, buildPluginModels, createAnthropicSDK, createAnthropicSDK as default, resolveAuth, selectClaudePromptForModel };
|
package/build/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAG1B,6BAA6B,EAE7B,2BAA2B,EAE5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAG1B,6BAA6B,EAE7B,2BAA2B,EAE5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;AAe9C,KAAK,gBAAgB,GAAG,6BAA6B,CAAA;AACrD,KAAK,cAAc,GAAG,2BAA2B,CAAA;AAkDjD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAExE;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,SAAW,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAS9F;AAmBD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,mCAAmC,CAAA;AAqFrE,qBAAa,iBAAkB,YAAW,eAAe;IAUrD,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,OAAO;IAXjB,QAAQ,CAAC,oBAAoB,EAAG,IAAI,CAAS;IAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAK;IAErD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;gBAGjC,OAAO,EAAE,MAAM,EACP,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,OAAe;IAOlC,OAAO,CAAC,WAAW;IA+NnB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAUrB,UAAU,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0L1E,QAAQ,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,cAAc,CAAC;CA+F7E"}
|
package/build/prompt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;AAI9C,KAAK,gBAAgB,GAAG,SAAS,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzE,KAAK,oBAAoB,GAAG,SAAS,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAA;AAEnE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,oBAAoB,CAAA;IAC5B,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAC7B;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,CAiC5E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode v2 persists part metadata only under the route's provider key —
|
|
3
|
+
* the providerID ("anthropic-sdk") for non-@ai-sdk packages — and hands it
|
|
4
|
+
* back on replay under that same key. Direct AI SDK callers use "anthropic".
|
|
5
|
+
* Writing both keys keeps thinking signatures and fallback blocks alive in
|
|
6
|
+
* OpenCode history without breaking direct usage.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PROVIDER_METADATA_KEY = "anthropic-sdk";
|
|
9
|
+
export declare function anthropicMetadata(meta: Record<string, any>): {
|
|
10
|
+
"anthropic-sdk": Record<string, any>;
|
|
11
|
+
anthropic: Record<string, any>;
|
|
12
|
+
};
|
|
13
|
+
/** Read our metadata from a replayed prompt part (providerOptions) or a generated one (providerMetadata). */
|
|
14
|
+
export declare function readAnthropicMetadata(part: any): Record<string, any> | undefined;
|
|
15
|
+
//# sourceMappingURL=provider-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-metadata.d.ts","sourceRoot":"","sources":["../src/provider-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,kBAAkB,CAAA;AAEpD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;EAE1D;AAED,6GAA6G;AAC7G,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAMhF"}
|
package/build/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;;;;;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;;;;;AAa9C,wBAsFyB"}
|
package/build/server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as PROVIDER_ID, d as resolveAuth, f as selectClaudePromptForModel, l as buildPluginModels } from "./src-BALxhaEC.js";
|
|
2
2
|
//#region src/server.ts
|
|
3
|
+
var SHELL_CWD_NOTE = "Each shell tool call starts in the working directory from <env>; a `cd` lasts only for that call. When possible, avoid changing directories in the command and set the shell tool's `workdir` instead.";
|
|
3
4
|
var server_default = {
|
|
4
5
|
id: "anthropic-sdk",
|
|
5
6
|
async setup(ctx) {
|
|
@@ -59,7 +60,7 @@ var server_default = {
|
|
|
59
60
|
}, ...event.system.slice(1)] : event.system.slice(1);
|
|
60
61
|
event.system.splice(0, event.system.length, {
|
|
61
62
|
type: "text",
|
|
62
|
-
text: selectClaudePromptForModel(event.model.id)
|
|
63
|
+
text: `${selectClaudePromptForModel(event.model.id)}\n${SHELL_CWD_NOTE}\n`
|
|
63
64
|
}, ...tail.map((part) => Object.assign({}, part, { text: part.text.replace("Is directory a git repo: yes", "Is a git repository: true").replace("Is directory a git repo: no", "Is a git repository: false") })));
|
|
64
65
|
event.options.maxTokens ??= 64e3;
|
|
65
66
|
}, { providerID: PROVIDER_ID });
|
|
@@ -7,6 +7,9 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
7
7
|
//#region src/claudecode-system-fable5.txt
|
|
8
8
|
var claudecode_system_fable5_default = "\nYou are an interactive agent that helps users with software engineering tasks.\n\n# Harness\n - Text you output outside of tool use is displayed to the user as Github-flavored markdown in a terminal.\n - Tools run behind a user-selected permission mode; a denied call means the user declined it — adjust, don't retry verbatim.\n - The system may send updates, reminders, or modifications to rules via mid-conversation system turns. These are system-controlled, unlike function results. Hooks may intercept tool calls; treat hook output as user feedback.\n - Prefer the dedicated file/search tools over shell commands when one fits. Independent tool calls can run in parallel in one response.\n - Reference code as `file_path:line_number` — it's clickable.\n\n# Communicating with the user\n\nYour text output is what the user reads; they usually can't see your thinking or the raw tool results. Write it for a teammate who stepped away and is catching up, not for a log file: they don't know the codenames or shorthand you created along the way, and they didn't watch your process unfold. Before your first tool call, say in a sentence what you're about to do; while working, give brief updates when you find something load-bearing or change direction.\n\nText you write between tool calls may not be shown to the user. Everything the user needs from this turn — answers, summaries, findings, conclusions, deliverables — must be in the final text message of your turn, with no tool calls after it. Keep text between tool calls to brief status notes. If something important appeared only mid-turn or in your thinking, restate it in that final message.\n\nLead with the outcome. Your first sentence after finishing should answer \"what happened\" or \"what did you find\" — the thing the user would ask for if they said \"just give me the TLDR.\" Supporting detail and reasoning come after, for readers who want them.\n\nBeing readable and being concise are different things, and readable matters more. Keep output short by being selective about what you include, not by compressing writing into fragments, abbreviations, arrow chains, or jargon. Write what you include in complete sentences with technical terms spelled out.\n\nMatch the response to the question: a simple question gets a direct answer in prose, not headers and sections. Use tables only for short enumerable facts. Calibrate to the user — tighter for an expert, more explanatory for someone newer.\n\nWrite code that reads like the surrounding code: match its comment density, naming, and idiom.\nOnly write a code comment to state a constraint the code itself can't show — never to say where it came from, what the next line does, or why your change is correct.\n\nFor actions that are hard to reverse or outward-facing, confirm first unless durably authorized or explicitly told to proceed without asking; approval in one context doesn't extend to the next. Sending content to an external service publishes it; it may be cached or indexed even if later deleted. Before deleting or overwriting, look at the target. Report outcomes faithfully: if tests fail, say so with the output; if a step was skipped, say that; when something is done and verified, state it plainly without hedging.\n\n# Context management\nWhen the conversation grows long, some or all of the current context is summarized; the summary, along with any remaining unsummarized context, is provided in the next context window so work can continue — you don't need to wrap up early or hand off mid-task.\n\nWhen you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. If you are weighing a choice, give a recommendation, not an exhaustive survey.\n";
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/claudecode-system-fable51.txt
|
|
11
|
+
var claudecode_system_fable51_default = "\nYou are an interactive agent that helps users with software engineering tasks.\n\n# Harness\n - Text you output outside of tool use is displayed to the user as Github-flavored markdown in a terminal.\n - Tools run behind a user-selected permission mode; a denied call means the user declined it — adjust, don't retry verbatim.\n - The system may send updates, reminders, or modifications to rules via mid-conversation system turns. These are system-controlled, unlike function results. Hooks may intercept tool calls; treat hook output as user feedback.\n - Prefer the dedicated file/search tools over shell commands when one fits. Independent tool calls can run in parallel in one response.\n - Reference code as `file_path:line_number` — it's clickable.\n\nBefore you start, say in a line what you're about to do; brief updates while you work help the user follow along. Close with a short recap that stands on its own — what you found, what you did, and what's next — so a reader who only sees the last message has the full picture.\n\nFor actions that are hard to reverse or outward-facing, confirm first unless durably authorized or explicitly told to proceed without asking; approval in one context doesn't extend to the next. Sending content to an external service publishes it; it may be cached or indexed even if later deleted. Before deleting or overwriting, look at the target. Report outcomes faithfully: if tests fail, say so with the output; if a step was skipped, say that; when something is done and verified, state it plainly without hedging.\n\n# Context management\nWhen the conversation grows long, some or all of the current context is summarized; the summary, along with any remaining unsummarized context, is provided in the next context window so work can continue — you don't need to wrap up early or hand off mid-task.\n\nWhen you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. If you are weighing a choice, give a recommendation, not an exhaustive survey.\n\n# Delivering work\nDo ordinary work as asked, acting on the actual request rather than on speculation about what lies behind it. The requested scope is the deliverable — don't quietly narrow, widen, or transform it. Interpret ambiguity the way a careful colleague would: make routine judgment calls yourself, and check in only when different readings would lead to materially different work. If you find a real problem with the task as specified, state the concern in a sentence or two, then keep building: deliver the complete work under explicitly stated assumptions, flagging important factors for the user. Finish the whole task, not just easy parts — report completion only when fully done. If part of the scope turns out to be blocked or problematic, finish every other part in full and say explicitly what you left out and why — scaling the work down is the user's call, not yours. Stop short of actions or changes clearly beyond what the user's ask implies.\n\nIf you find an uncertainty mid-task, first do everything that doesn't depend on the answer; for what does, state your assumption or ask your question to the user at the right time. Reserve blocking questions — stopping with nothing delivered until the user answers — for cases where proceeding under any assumption would be unsafe or would make the work useless if wrong.\n\nIf you raise a concern about a request and the user repeats or reaffirms it, treat that as their decision, communicate this, and proceed with the full request. Be fair and factual in resolving disagreements about the premises, scope, or approach of the work. Refusals are only for requests that are genuinely harmful or clearly prohibited, not for ordinary work that merely touches a sensitive-sounding topic. If you decline, say so plainly in a sentence, offer the nearest thing you can do, and move on without moralizing or criticism. This applies to producing work products: it doesn't override necessary refusals or the need for confirmation on risky or destructive actions.\n\n# Writing for the user\nThe user may not see your tool calls, tool results, or the text you write between them. Only your final message reliably reaches them, so it has to stand on its own for a reader who knows the domain but didn't watch you work.\n\nRules for that message:\n- Lead with the answer or outcome. If something could not be verified, say so first. Keep it short by leaving things out, not by packing them in.\n- One idea per sentence, about 20 words, with a verb. Short does not mean clipped: a sentence beats a label with a colon. Start a new sentence instead of joining clauses with a semicolon.\n- No em-dashes, no parentheticals, no arrows.\n- State facts and conclusions. Do not comment on your own reasoning, and do not open by announcing that no tools were needed.\n- Do not refer to anything by a name you made up during the session. Expand uncommon acronyms the first time you use them. Say who wrote a message and what it said, not by number or label.\n- Keep code out of prose. Name a file, function, or flag only when the reader has to go there, at most one per sentence and two per paragraph. Describe the rest in words. Commands, snippets, and error text go in a fenced code block.\n- Keep numbers out of prose. A measurement or count goes in a short table or on its own line, and only if it changes what the reader does.\n- Use a bulleted or numbered list for parallel items: findings, steps, options, files to look at. One or two sentences per bullet, never a paragraph. Bold the first few words of a bullet or paragraph, never a whole sentence. A single point or a line of argument stays in prose.\n- No headers in a message under about 500 words. Above that, at most three. If the user asks for no formatting, use none.\n- Stop when the content stops. No closing offer, no restating what you did.\n";
|
|
12
|
+
//#endregion
|
|
10
13
|
//#region src/claudecode-system-new.txt
|
|
11
14
|
var claudecode_system_new_default = "\nYou are an interactive agent that helps users with software engineering tasks.\n\n# Harness\n - Text you output outside of tool use is displayed to the user as Github-flavored markdown in a terminal.\n - Tools run behind a user-selected permission mode; a denied call means the user declined it — adjust, don't retry verbatim.\n - `<system-reminder>` tags in messages and tool results are injected by the harness, not the user. Hooks may intercept tool calls; treat hook output as user feedback.\n - Prefer the dedicated file/search tools over shell commands when one fits. Independent tool calls can run in parallel in one response.\n - Reference code as `file_path:line_number` — it's clickable.\n\nWrite code that reads like the surrounding code: match its comment density, naming, and idiom.\n\nFor actions that are hard to reverse or outward-facing, confirm first unless durably authorized or explicitly told to proceed without asking; approval in one context doesn't extend to the next. Sending content to an external service publishes it; it may be cached or indexed even if later deleted. Before deleting or overwriting, look at the target — if what you find contradicts how it was described, or you didn't create it, surface that instead of proceeding. Report outcomes faithfully: if tests fail, say so with the output; if a step was skipped, say that; when something is done and verified, state it plainly without hedging.\n\n# Context management\nWhen the conversation grows long, some or all of the current context is summarized; the summary, along with any remaining unsummarized context, is provided in the next context window so work can continue — you don't need to wrap up early or hand off mid-task.\n\nWhen you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. If you are weighing a choice, give a recommendation, not an exhaustive survey.\n";
|
|
12
15
|
//#endregion
|
|
@@ -101,6 +104,29 @@ async function* withPauseTurnContinuation(initial, params, request, maxContinuat
|
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
//#endregion
|
|
107
|
+
//#region src/provider-metadata.ts
|
|
108
|
+
/**
|
|
109
|
+
* OpenCode v2 persists part metadata only under the route's provider key —
|
|
110
|
+
* the providerID ("anthropic-sdk") for non-@ai-sdk packages — and hands it
|
|
111
|
+
* back on replay under that same key. Direct AI SDK callers use "anthropic".
|
|
112
|
+
* Writing both keys keeps thinking signatures and fallback blocks alive in
|
|
113
|
+
* OpenCode history without breaking direct usage.
|
|
114
|
+
*/
|
|
115
|
+
var PROVIDER_METADATA_KEY = "anthropic-sdk";
|
|
116
|
+
function anthropicMetadata(meta) {
|
|
117
|
+
return {
|
|
118
|
+
[PROVIDER_METADATA_KEY]: meta,
|
|
119
|
+
anthropic: meta
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Read our metadata from a replayed prompt part (providerOptions) or a generated one (providerMetadata). */
|
|
123
|
+
function readAnthropicMetadata(part) {
|
|
124
|
+
for (const source of [part?.providerOptions, part?.providerMetadata]) {
|
|
125
|
+
const meta = source?.["anthropic-sdk"] ?? source?.anthropic;
|
|
126
|
+
if (meta) return meta;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
104
130
|
//#region src/tool-names.ts
|
|
105
131
|
/**
|
|
106
132
|
* Maps OpenCode tool names ↔ Claude Code tool names.
|
|
@@ -266,7 +292,7 @@ function convertUserMessage(message) {
|
|
|
266
292
|
function convertAssistantMessage(message) {
|
|
267
293
|
const content = [];
|
|
268
294
|
for (const part of message.content) {
|
|
269
|
-
const fallback = part
|
|
295
|
+
const fallback = readAnthropicMetadata(part)?.fallback;
|
|
270
296
|
if (fallback?.from?.model && fallback?.to?.model) content.push({
|
|
271
297
|
type: "fallback",
|
|
272
298
|
from: { model: fallback.from.model },
|
|
@@ -280,7 +306,7 @@ function convertAssistantMessage(message) {
|
|
|
280
306
|
});
|
|
281
307
|
break;
|
|
282
308
|
case "reasoning": {
|
|
283
|
-
const signature = part
|
|
309
|
+
const signature = readAnthropicMetadata(part)?.signature ?? "";
|
|
284
310
|
if (signature) content.push({
|
|
285
311
|
type: "thinking",
|
|
286
312
|
thinking: part.text,
|
|
@@ -481,7 +507,7 @@ function processEvent(event, blockStates, modelId, ctx) {
|
|
|
481
507
|
parts.push({
|
|
482
508
|
type: "text-start",
|
|
483
509
|
id,
|
|
484
|
-
...meta ? { providerMetadata:
|
|
510
|
+
...meta ? { providerMetadata: anthropicMetadata(meta) } : {}
|
|
485
511
|
});
|
|
486
512
|
} else if (block.type === "thinking") {
|
|
487
513
|
const id = generateId();
|
|
@@ -494,7 +520,7 @@ function processEvent(event, blockStates, modelId, ctx) {
|
|
|
494
520
|
parts.push({
|
|
495
521
|
type: "reasoning-start",
|
|
496
522
|
id,
|
|
497
|
-
...meta ? { providerMetadata:
|
|
523
|
+
...meta ? { providerMetadata: anthropicMetadata(meta) } : {}
|
|
498
524
|
});
|
|
499
525
|
} else if (block.type === "tool_use") {
|
|
500
526
|
const toolId = block.id;
|
|
@@ -557,7 +583,7 @@ function processEvent(event, blockStates, modelId, ctx) {
|
|
|
557
583
|
parts.push({
|
|
558
584
|
type: "reasoning-end",
|
|
559
585
|
id: state.id,
|
|
560
|
-
...Object.keys(meta).length > 0 ? { providerMetadata:
|
|
586
|
+
...Object.keys(meta).length > 0 ? { providerMetadata: anthropicMetadata(meta) } : {}
|
|
561
587
|
});
|
|
562
588
|
} else if (state.type === "tool_use") {
|
|
563
589
|
parts.push({
|
|
@@ -569,7 +595,7 @@ function processEvent(event, blockStates, modelId, ctx) {
|
|
|
569
595
|
toolCallId: state.toolUseId,
|
|
570
596
|
toolName: state.toolName,
|
|
571
597
|
input: state.argsText || "{}",
|
|
572
|
-
...state.fallbackMeta ? { providerMetadata:
|
|
598
|
+
...state.fallbackMeta ? { providerMetadata: anthropicMetadata(state.fallbackMeta) } : {}
|
|
573
599
|
});
|
|
574
600
|
}
|
|
575
601
|
blockStates.delete(index);
|
|
@@ -693,7 +719,7 @@ var FALLBACK_BETAS_HEADER = "x-anthropic-sdk-fallback-betas";
|
|
|
693
719
|
*/
|
|
694
720
|
var BILLING_SYSTEM_BLOCK = {
|
|
695
721
|
type: "text",
|
|
696
|
-
text: "x-anthropic-billing-header: cc_version=2.1.
|
|
722
|
+
text: "x-anthropic-billing-header: cc_version=2.1.286.ee5; cc_entrypoint=sdk-cli;"
|
|
697
723
|
};
|
|
698
724
|
/**
|
|
699
725
|
* Claude Code identity block — always sent as system[1].
|
|
@@ -965,7 +991,7 @@ var AnthropicSDKModel = class {
|
|
|
965
991
|
content.push({
|
|
966
992
|
type: "text",
|
|
967
993
|
text: block.text,
|
|
968
|
-
...meta ? { providerMetadata:
|
|
994
|
+
...meta ? { providerMetadata: anthropicMetadata(meta) } : {}
|
|
969
995
|
});
|
|
970
996
|
break;
|
|
971
997
|
}
|
|
@@ -976,7 +1002,7 @@ var AnthropicSDKModel = class {
|
|
|
976
1002
|
toolCallId: block.id,
|
|
977
1003
|
toolName: toOpencodeToolName(block.name),
|
|
978
1004
|
input: JSON.stringify(block.input),
|
|
979
|
-
...meta ? { providerMetadata:
|
|
1005
|
+
...meta ? { providerMetadata: anthropicMetadata(meta) } : {}
|
|
980
1006
|
});
|
|
981
1007
|
break;
|
|
982
1008
|
}
|
|
@@ -992,7 +1018,7 @@ var AnthropicSDKModel = class {
|
|
|
992
1018
|
content.push({
|
|
993
1019
|
type: "reasoning",
|
|
994
1020
|
text: anyBlock.thinking,
|
|
995
|
-
providerMetadata: Object.keys(meta).length > 0 ?
|
|
1021
|
+
providerMetadata: Object.keys(meta).length > 0 ? anthropicMetadata(meta) : void 0
|
|
996
1022
|
});
|
|
997
1023
|
}
|
|
998
1024
|
break;
|
|
@@ -1108,34 +1134,43 @@ var CLAUDE_CODE_OPUS5_SYSTEM_PROMPT = claudecode_system_opus5_default;
|
|
|
1108
1134
|
var CLAUDE_CODE_SONNET5_SYSTEM_PROMPT = claudecode_system_sonnet5_default;
|
|
1109
1135
|
var CLAUDE_CODE_SONNET55_SYSTEM_PROMPT = claudecode_system_sonnet55_default;
|
|
1110
1136
|
var CLAUDE_CODE_FABLE5_SYSTEM_PROMPT = claudecode_system_fable5_default;
|
|
1137
|
+
var CLAUDE_CODE_FABLE51_SYSTEM_PROMPT = claudecode_system_fable51_default;
|
|
1111
1138
|
/**
|
|
1112
1139
|
* Select the Claude Code system prompt that matches the given model.
|
|
1113
1140
|
*
|
|
1114
|
-
* Claude Code ships per-model prompts. Sonnet 5.5
|
|
1115
|
-
* without delivery and correction guidance; Sonnet 5 gets
|
|
1116
|
-
* harness; Opus 5 gets its condensed scope, delivery, and
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1141
|
+
* Claude Code ships per-model prompts. Sonnet 5.5 and Opus 5.5 share the
|
|
1142
|
+
* condensed harness without delivery and correction guidance; Sonnet 5 gets
|
|
1143
|
+
* its long-form harness; Opus 5 gets its condensed scope, delivery, and
|
|
1144
|
+
* correction guidance; Fable 5.1 gets delivery guidance and strict
|
|
1145
|
+
* final-message writing rules; Fable 5 gets its communication guidance;
|
|
1146
|
+
* Opus 4.8 gets the shorter earlier harness. Older models get the legacy
|
|
1147
|
+
* long-form prompt.
|
|
1119
1148
|
*/
|
|
1120
1149
|
function selectClaudePromptForModel(modelId) {
|
|
1121
|
-
if (modelId.includes("sonnet-5-5")) return claudecode_system_sonnet55_default;
|
|
1150
|
+
if (modelId.includes("sonnet-5-5") || modelId.includes("opus-5-5")) return claudecode_system_sonnet55_default;
|
|
1122
1151
|
if (modelId.includes("sonnet-5")) return claudecode_system_sonnet5_default;
|
|
1123
1152
|
if (modelId.includes("opus-5")) return claudecode_system_opus5_default;
|
|
1153
|
+
if (modelId.includes("fable-5-1")) return claudecode_system_fable51_default;
|
|
1124
1154
|
if (modelId.includes("fable-5")) return claudecode_system_fable5_default;
|
|
1125
1155
|
if (modelId.includes("opus-4-8")) return claudecode_system_new_default;
|
|
1126
1156
|
return claudecode_system_default;
|
|
1127
1157
|
}
|
|
1128
1158
|
/**
|
|
1129
|
-
* Claude Code CLI version to impersonate.
|
|
1130
|
-
*
|
|
1159
|
+
* Claude Code CLI version to impersonate in the user-agent. The billing
|
|
1160
|
+
* block in model.ts must report the same version.
|
|
1161
|
+
*/
|
|
1162
|
+
var CLAUDE_CODE_VERSION = "2.1.286";
|
|
1163
|
+
/**
|
|
1164
|
+
* @anthropic-ai/sdk version bundled with CLAUDE_CODE_VERSION, sent as
|
|
1165
|
+
* x-stainless-package-version. Keep the package.json pin in sync.
|
|
1131
1166
|
*/
|
|
1132
|
-
var
|
|
1167
|
+
var CLAUDE_CODE_SDK_VERSION = "0.127.0";
|
|
1133
1168
|
/**
|
|
1134
1169
|
* Beta flags that Claude Code sends on every OAuth request.
|
|
1135
1170
|
* Order and exact values must match what Claude Code sends.
|
|
1136
1171
|
*
|
|
1137
|
-
* Captured from Claude Code 2.1.
|
|
1138
|
-
*
|
|
1172
|
+
* Captured from Claude Code 2.1.286. Model-conditional flags are appended in
|
|
1173
|
+
* wrappedFetch so their order matches the CLI.
|
|
1139
1174
|
* - thinking-token-count-2026-05-13: estimated_tokens in thinking_delta
|
|
1140
1175
|
* stream events (progress hint when display="omitted")
|
|
1141
1176
|
*/
|
|
@@ -1147,6 +1182,33 @@ var OAUTH_BETAS = [
|
|
|
1147
1182
|
"context-management-2025-06-27",
|
|
1148
1183
|
"prompt-caching-scope-2026-01-05"
|
|
1149
1184
|
];
|
|
1185
|
+
/** Claude Code sends Haiku the same base flags with its own gate moved last. */
|
|
1186
|
+
var HAIKU_OAUTH_BETAS = [...OAUTH_BETAS.slice(1), "claude-code-20250219"];
|
|
1187
|
+
/**
|
|
1188
|
+
* Model-conditional OAuth flags in the order Claude Code 2.1.286 appends
|
|
1189
|
+
* them after the base flags.
|
|
1190
|
+
*/
|
|
1191
|
+
function modelOAuthBetas(model) {
|
|
1192
|
+
const isClaude5 = [
|
|
1193
|
+
"opus-4-8",
|
|
1194
|
+
"opus-5",
|
|
1195
|
+
"sonnet-5",
|
|
1196
|
+
"fable-5"
|
|
1197
|
+
].some((m) => model.includes(m));
|
|
1198
|
+
const isLatest = [
|
|
1199
|
+
"opus-5-5",
|
|
1200
|
+
"sonnet-5-5",
|
|
1201
|
+
"fable-5-1"
|
|
1202
|
+
].some((m) => model.includes(m));
|
|
1203
|
+
return [
|
|
1204
|
+
...isClaude5 ? ["mid-conversation-system-2026-04-07"] : [],
|
|
1205
|
+
...isLatest ? ["per-turn-control-2026-07-01"] : [],
|
|
1206
|
+
...isClaude5 && !model.includes("sonnet") ? ["mid-conversation-tool-changes-2026-07-01"] : [],
|
|
1207
|
+
"advisor-tool-2026-03-01",
|
|
1208
|
+
...!model.includes("haiku") ? ["effort-2025-11-24"] : [],
|
|
1209
|
+
"extended-cache-ttl-2025-04-11"
|
|
1210
|
+
];
|
|
1211
|
+
}
|
|
1150
1212
|
/**
|
|
1151
1213
|
* Beta flags for regular API key auth (no OAuth).
|
|
1152
1214
|
*/
|
|
@@ -1469,7 +1531,7 @@ function createAnthropicSDK(options = {}) {
|
|
|
1469
1531
|
defaultHeaders["user-agent"] = `claude-cli/${CLAUDE_CODE_VERSION} (external, sdk-cli)`;
|
|
1470
1532
|
defaultHeaders["x-app"] = "cli";
|
|
1471
1533
|
defaultHeaders["anthropic-dangerous-direct-browser-access"] = "true";
|
|
1472
|
-
defaultHeaders["x-stainless-package-version"] =
|
|
1534
|
+
defaultHeaders["x-stainless-package-version"] = CLAUDE_CODE_SDK_VERSION;
|
|
1473
1535
|
}
|
|
1474
1536
|
const baseFetch = customFetch ?? globalThis.fetch;
|
|
1475
1537
|
const wrappedFetch = async (url, init) => {
|
|
@@ -1494,16 +1556,10 @@ function createAnthropicSDK(options = {}) {
|
|
|
1494
1556
|
if (filtered.length !== betas.length) betas.splice(0, betas.length, ...filtered);
|
|
1495
1557
|
}
|
|
1496
1558
|
const model = init.body.match(/"model"\s*:\s*"([^"]+)"/)?.[1] ?? "";
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
"advisor-tool-2026-03-01",
|
|
1502
|
-
...!model.includes("haiku") ? ["effort-2025-11-24"] : [],
|
|
1503
|
-
"fallback-credit-2026-06-01",
|
|
1504
|
-
"extended-cache-ttl-2025-04-11"
|
|
1505
|
-
]) if (!betas.includes(beta)) betas.push(beta);
|
|
1506
|
-
reqHeaders.set("anthropic-beta", betas.join(","));
|
|
1559
|
+
const base = model.includes("haiku") ? HAIKU_OAUTH_BETAS : OAUTH_BETAS;
|
|
1560
|
+
const ordered = [...base, ...betas.filter((beta) => !base.includes(beta))];
|
|
1561
|
+
for (const beta of modelOAuthBetas(model)) if (!ordered.includes(beta)) ordered.push(beta);
|
|
1562
|
+
reqHeaders.set("anthropic-beta", ordered.join(","));
|
|
1507
1563
|
init = {
|
|
1508
1564
|
...init,
|
|
1509
1565
|
headers: reqHeaders
|
|
@@ -1560,4 +1616,4 @@ function createAnthropicSDK(options = {}) {
|
|
|
1560
1616
|
} };
|
|
1561
1617
|
}
|
|
1562
1618
|
//#endregion
|
|
1563
|
-
export {
|
|
1619
|
+
export { CLAUDE_CODE_SONNET55_SYSTEM_PROMPT as a, PROVIDER_ID as c, resolveAuth as d, selectClaudePromptForModel as f, CLAUDE_CODE_OPUS5_SYSTEM_PROMPT as i, buildPluginModels as l, CLAUDE_CODE_FABLE5_SYSTEM_PROMPT as n, CLAUDE_CODE_SONNET5_SYSTEM_PROMPT as o, CLAUDE_CODE_NEW_SYSTEM_PROMPT as r, CLAUDE_CODE_SYSTEM_PROMPT as s, CLAUDE_CODE_FABLE51_SYSTEM_PROMPT as t, createAnthropicSDK as u };
|
package/build/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA+B,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC9F,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA+B,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC9F,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;AAI9C,KAAK,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,CAAA;AAetD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,UAAU,aAAa;IACrB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB,uDAAuD;IACvD,gBAAgB,EAAE,OAAO,CAAA;IACzB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAClC;AAwCD,wBAAgB,aAAa,CAC3B,eAAe,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAClD,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC/B,cAAc,CAAC,yBAAyB,CAAC,CAuF3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xtruder/opencode-claude-max-plugin",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "OpenCode plugin for Claude Max/Pro subscription via @anthropic-ai/sdk - uses Claude Code OAuth credentials",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-sdk",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"prepare": "simple-git-hooks"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@anthropic-ai/sdk": "0.
|
|
53
|
+
"@anthropic-ai/sdk": "0.127.0",
|
|
54
54
|
"@opentui/core": "0.5.10",
|
|
55
55
|
"@opentui/solid": "0.5.10",
|
|
56
56
|
"solid-js": "1.9.12",
|