opencode-claude-code-acpbridge 0.9.0 → 0.10.1

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 (62) hide show
  1. package/CHANGELOG.md +314 -191
  2. package/LICENSE +21 -0
  3. package/README.md +596 -279
  4. package/dist/acp/claude-config.d.ts +52 -0
  5. package/dist/acp/claude-config.d.ts.map +1 -1
  6. package/dist/acp/claude-config.js +6 -2
  7. package/dist/acp/claude-config.js.map +1 -1
  8. package/dist/acp/mcp-host.d.ts +10 -0
  9. package/dist/acp/mcp-host.d.ts.map +1 -1
  10. package/dist/acp/mcp-host.js +17 -4
  11. package/dist/acp/mcp-host.js.map +1 -1
  12. package/dist/acp/mcp-runtime.js +21 -4
  13. package/dist/acp/mcp-runtime.js.map +1 -1
  14. package/dist/log.d.ts +11 -0
  15. package/dist/log.d.ts.map +1 -0
  16. package/dist/log.js +50 -0
  17. package/dist/log.js.map +1 -0
  18. package/dist/plugin/compat.d.ts +14 -0
  19. package/dist/plugin/compat.d.ts.map +1 -0
  20. package/dist/plugin/compat.js +45 -0
  21. package/dist/plugin/compat.js.map +1 -0
  22. package/dist/plugin/index.d.ts +3 -0
  23. package/dist/plugin/index.d.ts.map +1 -1
  24. package/dist/plugin/index.js +80 -14
  25. package/dist/plugin/index.js.map +1 -1
  26. package/dist/plugin/sessions.d.ts +11 -8
  27. package/dist/plugin/sessions.d.ts.map +1 -1
  28. package/dist/plugin/sessions.js +37 -4
  29. package/dist/plugin/sessions.js.map +1 -1
  30. package/dist/provider/factory.d.ts.map +1 -1
  31. package/dist/provider/factory.js +5 -3
  32. package/dist/provider/factory.js.map +1 -1
  33. package/dist/provider/history.d.ts +44 -0
  34. package/dist/provider/history.d.ts.map +1 -0
  35. package/dist/provider/history.js +145 -0
  36. package/dist/provider/history.js.map +1 -0
  37. package/dist/provider/model.d.ts +160 -23
  38. package/dist/provider/model.d.ts.map +1 -1
  39. package/dist/provider/model.js +1373 -480
  40. package/dist/provider/model.js.map +1 -1
  41. package/dist/provider/recorder.d.ts +5 -0
  42. package/dist/provider/recorder.d.ts.map +1 -0
  43. package/dist/provider/recorder.js +63 -0
  44. package/dist/provider/recorder.js.map +1 -0
  45. package/docs/DEVELOPMENT.md +413 -127
  46. package/examples/01-minimal.jsonc +12 -9
  47. package/examples/02-per-agent-permissions.jsonc +39 -0
  48. package/examples/03-opencode-fidelity.jsonc +21 -0
  49. package/examples/04-model-and-effort.jsonc +35 -0
  50. package/examples/05-custom-agents.jsonc +32 -0
  51. package/examples/06-claude-ecosystem.jsonc +28 -0
  52. package/examples/07-manual-provider.jsonc +55 -0
  53. package/examples/08-permission-bridge.jsonc +42 -0
  54. package/examples/README.md +35 -17
  55. package/package.json +35 -29
  56. package/examples/02-permisos-por-agente.jsonc +0 -34
  57. package/examples/03-fidelidad-opencode.jsonc +0 -21
  58. package/examples/04-modelo-y-esfuerzo.jsonc +0 -36
  59. package/examples/05-agentes-personalizados.jsonc +0 -29
  60. package/examples/06-ecosistema-claude.jsonc +0 -24
  61. package/examples/07-provider-manual.jsonc +0 -42
  62. package/examples/08-puente-permisos.jsonc +0 -50
@@ -0,0 +1,145 @@
1
+ export function hashText(s) {
2
+ let h = 5381;
3
+ for (let i = 0; i < s.length; i++)
4
+ h = ((h << 5) + h) ^ s.charCodeAt(i);
5
+ return (h >>> 0).toString(36);
6
+ }
7
+ /** Text of the first user message — stable identifier for the conversation. Tags other
8
+ * plugins inject (DCP) are not part of it: they come and go between requests. */
9
+ export function firstUserText(prompt) {
10
+ for (const m of prompt) {
11
+ if (m.role !== "user")
12
+ continue;
13
+ if (typeof m.content === "string")
14
+ return stripInjected(m.content).trim();
15
+ return stripInjected(m.content.filter((p) => p.type === "text").map((p) => p.text).join("")).trim();
16
+ }
17
+ return "";
18
+ }
19
+ /** The conversation proper: system messages are excluded because they're forwarded
20
+ * separately (or not at all) and OpenCode rewrites them every turn — including them
21
+ * would make every history comparison look like a divergence. */
22
+ export function historyOf(prompt) {
23
+ return prompt.filter((m) => m.role !== "system");
24
+ }
25
+ /** Cheap, stable per-message identity. Deliberately keyed on tool-call IDs rather
26
+ * than payloads: it must survive re-serialization but change if the turn changes. */
27
+ export function msgKey(msg) {
28
+ let body = "";
29
+ if (typeof msg.content === "string")
30
+ body = msg.content;
31
+ else if (Array.isArray(msg.content)) {
32
+ for (const p of msg.content) {
33
+ if (p?.type === "text")
34
+ body += `t:${p.text}`;
35
+ else if (p?.type === "tool-call")
36
+ body += `c:${p.toolCallId}`;
37
+ else if (p?.type === "tool-result")
38
+ body += `r:${p.toolCallId}`;
39
+ else if (p?.type === "file")
40
+ body += `f:${p.filename ?? p.mediaType ?? ""}`;
41
+ else
42
+ body += `?${p?.type}`;
43
+ }
44
+ }
45
+ return `${msg.role}:${hashText(body)}`;
46
+ }
47
+ /** How the incoming history relates to what the agent already knows.
48
+ * - append → normal turn (or another agent ran turns meanwhile): send the tail.
49
+ * - revert → the user rewound: the agent can't unremember, so it needs a new session.
50
+ * - diverged → compaction/rollback replaced the middle: same, a new session. */
51
+ export function classifyHistory(sent, keys) {
52
+ let i = 0;
53
+ while (i < sent.length && i < keys.length && sent[i] === keys[i])
54
+ i++;
55
+ if (i === sent.length)
56
+ return { kind: "append", fromIndex: i };
57
+ // Prefijo estricto = revert SOLO si incoming es más corto; si son iguales no hay
58
+ // mensajes nuevos → append desde el final (evita falsos revert).
59
+ if (i === keys.length)
60
+ return keys.length < sent.length
61
+ ? { kind: "revert", fromIndex: i }
62
+ : { kind: "append", fromIndex: keys.length };
63
+ return { kind: "diverged", fromIndex: i };
64
+ }
65
+ export function systemText(prompt) {
66
+ const parts = [];
67
+ for (const m of prompt) {
68
+ if (m.role !== "system")
69
+ continue;
70
+ parts.push(typeof m.content === "string"
71
+ ? m.content
72
+ : m.content.filter((p) => p.type === "text").map((p) => p.text).join(""));
73
+ }
74
+ return parts.join("\n").trim();
75
+ }
76
+ // ---- anchor fingerprint (historyMode "shadow" | "v2") -----------------------------
77
+ //
78
+ // The legacy key hashes every part of every message. OpenCode V2 re-renders OLD
79
+ // assistant messages in ways that don't change the conversation — reasoning dropped or
80
+ // turned into text after a model switch or an error, providerOptions stripped — and other
81
+ // plugins tag message text (DCP). Each of those looked like a divergence → new session +
82
+ // cold replay. Anchors keep only what identifies the conversation: what the USER wrote
83
+ // and the ids of every tool round-trip. Assistant prose is left out; whether the agent
84
+ // already has it is decided separately (own-output detection).
85
+ /** Tags other plugins inject into message text (DCP's ids and nudges). */
86
+ const INJECTED_TAGS = /<(dcp-[a-z-]+)\b[^>]*>[\s\S]*?<\/\1>/g;
87
+ /** What V2 puts in place of an old image once the request exceeds its media budget. */
88
+ const IMAGE_REMOVED = /^\[This image was removed to reduce the request size[^\]]*\]$/;
89
+ export function stripInjected(text) {
90
+ return text.replace(INJECTED_TAGS, "");
91
+ }
92
+ /** A user message that only carries a `<system-reminder>`: V2's plan plugin inserts one
93
+ * for a single request and persists a copy that lands later — it moves around, so it
94
+ * can't be part of the identity of the history. */
95
+ export function isTransient(msg) {
96
+ if (msg?.role !== "user")
97
+ return false;
98
+ const parts = typeof msg.content === "string" ? [{ type: "text", text: msg.content }] : msg.content ?? [];
99
+ const text = parts.filter((p) => p?.type === "text").map((p) => String(p.text ?? "")).join("").trim();
100
+ return parts.every((p) => p?.type === "text") && /^<system-reminder>[\s\S]*<\/system-reminder>$/.test(text);
101
+ }
102
+ /** Normalized text of a user message (injected tags and V2's media placeholders out). */
103
+ export function userText(msg) {
104
+ const parts = typeof msg.content === "string" ? [{ type: "text", text: msg.content }] : msg.content ?? [];
105
+ return parts
106
+ .filter((p) => p?.type === "text")
107
+ .map((p) => stripInjected(String(p.text ?? "")).trim())
108
+ .filter((t) => t && !IMAGE_REMOVED.test(t))
109
+ .join("\n");
110
+ }
111
+ export function anchorsOf(hist) {
112
+ const out = [];
113
+ hist.forEach((m, at) => {
114
+ if (m.role === "user") {
115
+ if (!isTransient(m))
116
+ out.push({ key: `u:${hashText(userText(m))}`, at });
117
+ return;
118
+ }
119
+ if (!Array.isArray(m.content))
120
+ return;
121
+ for (const p of m.content) {
122
+ if (p?.type === "tool-call")
123
+ out.push({ key: `c:${p.toolCallId}`, at });
124
+ else if (p?.type === "tool-result")
125
+ out.push({ key: `r:${p.toolCallId}`, at });
126
+ }
127
+ });
128
+ return out;
129
+ }
130
+ /** `classifyHistory` over anchors. `fromIndex` is a MESSAGE index: the tail starts after
131
+ * the message of the last anchor already known. */
132
+ export function classifyAnchors(sent, incoming) {
133
+ let i = 0;
134
+ while (i < sent.length && i < incoming.length && sent[i] === incoming[i].key)
135
+ i++;
136
+ const after = i > 0 ? incoming[i - 1].at + 1 : 0;
137
+ if (i === sent.length)
138
+ return { kind: "append", fromIndex: after };
139
+ if (i === incoming.length)
140
+ return incoming.length < sent.length
141
+ ? { kind: "revert", fromIndex: after }
142
+ : { kind: "append", fromIndex: after };
143
+ return { kind: "diverged", fromIndex: after };
144
+ }
145
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/provider/history.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,IAAI,CAAC,GAAG,IAAI,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED;kFACkF;AAClF,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAAE,SAAS;QAChC,IAAI,OAAQ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Q,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM;YAC7D,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE;YACtC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACzC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAChD,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { APICallError } from "@ai-sdk/provider";
1
2
  import type { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3StreamPart, LanguageModelV3GenerateResult } from "@ai-sdk/provider";
2
3
  import { type ClaudeCodeControl } from "../acp/claude-config.js";
3
4
  export interface ACPModelConfig {
@@ -9,7 +10,17 @@ export interface ACPModelConfig {
9
10
  claudeCode?: ClaudeCodeControl;
10
11
  streamCloseTimeoutMs?: number;
11
12
  claudeExecutable?: string;
13
+ /** Test seam: an in-process agent instead of spawning `command`. */
14
+ transport?: () => {
15
+ input: WritableStream<Uint8Array>;
16
+ output: ReadableStream<Uint8Array>;
17
+ close?: () => void;
18
+ };
12
19
  }
20
+ /** Claude's usage/rate limit, rewritten so the user knows to switch models — and in
21
+ * words OpenCode's retry classifier doesn't match ("try again", "overloaded"…), so it
22
+ * isn't retried in a loop against an exhausted subscription. */
23
+ export declare function limitError(err: unknown): APICallError | undefined;
13
24
  export declare class ACPOrchestratorModel implements LanguageModelV3 {
14
25
  private readonly config;
15
26
  readonly specificationVersion: "v3";
@@ -17,6 +28,7 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
17
28
  readonly modelId: string;
18
29
  readonly supportedUrls: Record<string, RegExp[]>;
19
30
  private agent;
31
+ private closeTransport;
20
32
  private connection;
21
33
  private connecting;
22
34
  /** Live conversations, keyed by OpenCode sessionID (or the conversation hash).
@@ -25,10 +37,19 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
25
37
  private readonly sessions;
26
38
  /** Same states indexed by ACP sessionId, to route agent-initiated callbacks. */
27
39
  private readonly byAcpSession;
40
+ /** Per-conversation lock for session lookup/creation (see `startFresh`). */
41
+ private readonly locks;
42
+ /** Per-call model override (see `doStream`). */
43
+ private readonly callModel;
28
44
  private idSeq;
29
45
  private promptCaps;
46
+ /** The agent merges a prompt sent mid-turn into the running turn (claude-agent-acp). */
47
+ private promptQueueing;
30
48
  constructor(config: ACPModelConfig);
31
- doStream(options: LanguageModelV3CallOptions): Promise<{
49
+ doStream(options: LanguageModelV3CallOptions,
50
+ /** Model for THIS call when one orchestrator (one agent process) serves several
51
+ * OpenCode models — see `ACPModelView`. */
52
+ modelId?: string): Promise<{
32
53
  stream: ReadableStream<LanguageModelV3StreamPart>;
33
54
  warnings: never[];
34
55
  }>;
@@ -39,11 +60,83 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
39
60
  * (independent) ACP stdio channel meanwhile — dropping them truncated answers and
40
61
  * hid the reasoning block entirely. */
41
62
  private emit;
63
+ /** A turn that is not a continuation: reuse the live session (append), or create /
64
+ * resume one. Runs under the conversation lock. */
65
+ private startFresh;
66
+ /** Swap `t` onto a fork of its ACP session created with the current profile. The
67
+ * fork carries the whole transcript, so what `t` knows (sentKeys, own output) still
68
+ * holds; it gets its own MCP host. The old session is closed. */
69
+ private forkInPlace;
70
+ /** Remember where this turn starts (index of its first user message) and Claude's
71
+ * last transcript entry before it. */
72
+ private recordCheckpoint;
73
+ /** uuid of the last main-thread assistant entry in the session's transcript
74
+ * (`<configDir>/projects/<cwd as slug>/<sessionId>.jsonl`), read from its tail. */
75
+ private lastAssistantUuid;
76
+ /** Free the agent-side session (its Claude Code process and MCP servers). The client
77
+ * SDK has no method for it; the agent implements `session/close`. */
78
+ private closeAcpSession;
79
+ /** Answer OpenCode's compaction request inside the live session (it already holds
80
+ * the conversation and its cache): only the summary instruction is sent. In v2 the
81
+ * session then compacts itself natively, so the checkpoint can be adopted next turn.
82
+ * Returns false when the session is busy (V2 can compact mid tool loop). */
83
+ private serveCompaction;
84
+ /** Native `/compact` of the live session, output hidden. */
85
+ private nativeCompact;
86
+ private withLock;
87
+ /** Remember the text of every block we emit: OpenCode stores each block as one part of
88
+ * the assistant message it sends back next turn, which is how `dropOwnLead` knows the
89
+ * agent already has it. */
90
+ private trackOwnText;
91
+ private isOwnId;
92
+ /** Strip the agent's own output from the head of a tail: the assistant/tool messages
93
+ * before the next user message, as long as they carry only our ids and (when this
94
+ * process emitted them) only text we emitted. A message that fails the check — another
95
+ * model's turn — stops the skip, so it still reaches the agent. After a restart there
96
+ * is no emitted text to compare, and the position alone decides. */
97
+ private dropOwnLead;
98
+ /** Everything in `hist` is now known to the agent (both fingerprints). */
99
+ private markKnown;
100
+ private historyMode;
101
+ /** Legacy per-message keys or anchors, per `historyMode`. In `shadow` (the default
102
+ * while the anchor fingerprint proves itself on real sessions) both are computed, the
103
+ * legacy one decides, and every disagreement is logged for review. */
104
+ private classify;
105
+ /** Send a prompt as the session's newest generation. Completions of older ones — a
106
+ * cancelled turn, or the original prompt the agent resolves early when it merges a
107
+ * queued one — are ignored instead of closing the stream of the current turn. */
108
+ private sendPrompt;
109
+ /** Wait (bounded) for the running prompt to settle — e.g. after a cancel. */
110
+ private settle;
111
+ /** Stop the current turn for good: cancel it agent-side, unblock everything it waits
112
+ * on (deferred tool calls, bridged permissions) and drop what it still produces. */
113
+ private abortTurn;
114
+ /** The prompt completed while no stream was attached: close the current one with it. */
115
+ private finishFromDone;
42
116
  private flushPending;
43
117
  private onPromptDone;
44
118
  private onPromptError;
45
- /** Fired by the MCP host when the agent calls an OpenCode tool. */
119
+ /** Fired by the MCP host when the agent calls an OpenCode tool. The call is NOT
120
+ * resolved here: it waits for OpenCode to run the tool and send the continuation. */
46
121
  private onToolCall;
122
+ /** The agent cancelled a call: if OpenCode hasn't been given it yet, it never will be.
123
+ * (An already emitted one stays pending so its continuation is still recognised.) */
124
+ private onToolCancelled;
125
+ private parallelTools;
126
+ /** Collect a call into the current step. Serial tools close the step at once; a
127
+ * read-only one waits TOOL_BATCH_MS for the siblings Claude Code issues in parallel,
128
+ * so OpenCode gets them in ONE step and runs them in parallel too. With no stream
129
+ * attached the call is queued for the next continuation — never dropped. */
130
+ private addStepItem;
131
+ /** Usage for a `finish`: the CURRENT context size (OpenCode reads input + cache +
132
+ * output of the last step as the prompt size when deciding to compact), split into
133
+ * cache read/write/no-cache with the ratios of the turn's totals. The turn totals
134
+ * themselves are a sum over all its requests — reporting them inflated the context
135
+ * N-fold and triggered compactions early. */
136
+ private usageNow;
137
+ /** Emit the collected calls and end the stream with ONE `tool-calls` finish (OpenCode
138
+ * rejects a second finish in a step). */
139
+ private closeStep;
47
140
  /** Map approve/reject to one of the options the agent offered (by kind/optionId). */
48
141
  private permOutcome;
49
142
  /** Tool name the agent wants permission for. The ACP toolCall carries NO bare
@@ -58,6 +151,11 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
58
151
  * Deferred: returns a Promise the agent awaits until the verdict comes back as
59
152
  * the `question` tool-result (resolved in onStart's continuation branch). */
60
153
  private onRequestPermission;
154
+ /** ExitPlanMode: offer the agent's OWN choices (auto / accept edits / approve each
155
+ * edit / keep planning) instead of a generic allow/deny that always meant "approve
156
+ * each edit". A typed answer means "keep planning, and here's why": the plan is
157
+ * rejected and the text reaches the agent as a message, so it revises the plan. */
158
+ private askPlanApproval;
61
159
  /** Action target of a native request (command / skill / path), plus the glob an
62
160
  * "Always allow" would persist. Shell commands collapse to their first token
63
161
  * (`git status` → `git *`); a request with no real target persists nothing, so
@@ -70,6 +168,14 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
70
168
  private emitPermissionCall;
71
169
  /** Fired by the ACP client on session/update. */
72
170
  private onSessionUpdate;
171
+ /** Native Claude Code tools run INSIDE the agent: OpenCode never sees them, so after a
172
+ * switch to another model what Claude read, searched or delegated was simply gone.
173
+ * Each one that completes is written into the answer as a short text block — plain
174
+ * text, the only form every model accepts (tools marked provider-executed would be
175
+ * replayed to other providers as calls they don't know). OpenCode's own tools
176
+ * (mcp__opencode__*) are skipped: they're already in the history. */
177
+ private onNativeTool;
178
+ private nativeResultText;
73
179
  private closeBlocks;
74
180
  private endTurn;
75
181
  /** Keep at most MAX_LIVE_SESSIONS conversations alive; tear down the oldest idle ones
@@ -89,14 +195,25 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
89
195
  private applySessionConfig;
90
196
  private ensureConnected;
91
197
  private connect;
198
+ private openTransport;
199
+ private spawnAgent;
200
+ /** V2 reads every stream to its end; a cancel only comes from an error or the user
201
+ * aborting (V1 also cancelled to PAUSE for a permission prompt — not anymore). So a
202
+ * cancel ends the turn: the agent stops, deferred calls are released, leftovers are
203
+ * dropped. The session itself — and its prompt cache — stays for the next message. */
92
204
  private onCancel;
93
- /** If a cancel was ignored (deferred work in flight) but no continuation comes,
94
- * force teardown so the agent doesn't stay blocked. Cleared by a continuation. */
95
- private armCancelWatchdog;
96
- /** Barre TODOS los watchdogs del turno (cada `onCancel` ignorado arma uno);
97
- * llamado desde endTurn/cleanup y al continuar el turno. */
98
- private clearCancelWatchdog;
205
+ private sweeper;
206
+ private startSweeper;
207
+ /** Close sessions nobody is using. Only resumable ones (an OpenCode session id, so
208
+ * the registry can bring them back without a replay); a turn left waiting on
209
+ * OpenCode for hours is treated as abandoned. */
210
+ private sweepIdle;
99
211
  cleanup(): void;
212
+ /** Conversation id for logs/recordings: OpenCode's sessionID, else the first-message hash. */
213
+ private convId;
214
+ /** One line per turn decision (file log + recording): the evidence needed to tell a
215
+ * genuine divergence from a false one after the fact. */
216
+ private decide;
100
217
  private convertTools;
101
218
  /** Nudges the agent can only get from the tool description. Under the default
102
219
  * `systemPromptMode: "preset"` OpenCode's system prompt never reaches the agent,
@@ -105,21 +222,19 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
105
222
  * agent silently assumes instead of asking. A tool description is NOT a system
106
223
  * prompt, so this doesn't affect how Anthropic bills the session. */
107
224
  private toolDescription;
108
- /** Text of the first user message — stable identifier for the conversation. */
109
- private firstUserText;
110
- /** The conversation proper: system messages are excluded because they're forwarded
111
- * separately (or not at all) and OpenCode rewrites them every turn — including them
112
- * would make every history comparison look like a divergence. */
113
- private history;
114
- /** Cheap, stable per-message identity. Deliberately keyed on tool-call IDs rather
115
- * than payloads: it must survive re-serialization but change if the turn changes. */
116
- private msgKey;
117
- /** How the incoming history relates to what the agent already knows.
118
- * - append → normal turn (or another agent ran turns meanwhile): send the tail.
119
- * - revert → the user rewound: the agent can't unremember, so it needs a new session.
120
- * - diverged → compaction/rollback replaced the middle: same, a new session. */
121
- private classifyHistory;
225
+ /** Messages the agent hasn't seen, as prompt blocks.
226
+ * - `tail` (live or resumed session): the user's messages verbatim; every run of
227
+ * assistant/tool messages between them was produced by ANOTHER model or agent in
228
+ * OpenCode (the agent's own output is dropped beforehand), and is labelled so —
229
+ * as a bare "Assistant:" the agent took those actions for its own.
230
+ * - `replay` (brand-new session): everything before the current request becomes a
231
+ * bounded `<conversation_history>`; the request itself follows on its own. */
122
232
  private blocksFor;
233
+ private replayBlocks;
234
+ /** One message as tagged blocks (for history and other models' turns). Reasoning and
235
+ * the agent's own tool traffic are left out: neither is something to re-read. */
236
+ private renderMessage;
237
+ /** A user message verbatim (text + attachments), minus tags other plugins inject. */
123
238
  private messageToBlocks;
124
239
  /** A foreign tool-result is replayed only so the agent can follow the thread —
125
240
  * the full payload isn't worth the tokens. */
@@ -129,7 +244,6 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
129
244
  private toBase64;
130
245
  /** OpenCode's system text → `_meta.systemPrompt` per mode. */
131
246
  private buildSystemPromptMeta;
132
- private systemText;
133
247
  /** The FACTUAL part of OpenCode's system prompt: where we are, what the workspace is,
134
248
  * what references exist. Under `preset` the system prompt itself never reaches the
135
249
  * agent (forwarding it would get the session billed as extra usage), but this
@@ -142,6 +256,12 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
142
256
  * small delta at the END of the conversation is cache-safe (the cached prefix is
143
257
  * untouched); resending the whole block every turn would not be. */
144
258
  private contextBlocks;
259
+ /** What OpenCode appended after the results of a continuation, as prompt blocks:
260
+ * user text verbatim (a steered message, a subagent result, a `<system-update>`), and
261
+ * any assistant prefill (V2's max-steps notice) as an explicit notice. */
262
+ private midTurnBlocks;
263
+ /** Fallback when the agent can't queue a prompt: the extras ride on a tool result. */
264
+ private appendToResult;
145
265
  /** Only the last user message (delta for a persistent session). */
146
266
  private lastUserBlocks;
147
267
  /** Find the live conversation whose deferred tool-calls/permissions this prompt
@@ -171,4 +291,21 @@ export declare class ACPOrchestratorModel implements LanguageModelV3 {
171
291
  * the agent sees what OpenCode actually returned. */
172
292
  private toMcpResult;
173
293
  }
294
+ /** One OpenCode model served by a shared orchestrator. Every model of the provider
295
+ * talks to the SAME agent process and session map: switching opus ↔ sonnet mid-
296
+ * conversation is a `session/set_model` on the live session, not a second process
297
+ * resuming a session that is still open in the first one. */
298
+ export declare class ACPModelView implements LanguageModelV3 {
299
+ private readonly core;
300
+ readonly modelId: string;
301
+ readonly specificationVersion: "v3";
302
+ readonly provider = "acp";
303
+ readonly supportedUrls: Record<string, RegExp[]>;
304
+ constructor(core: ACPOrchestratorModel, modelId: string);
305
+ doStream(options: LanguageModelV3CallOptions): Promise<{
306
+ stream: ReadableStream<LanguageModelV3StreamPart>;
307
+ warnings: never[];
308
+ }>;
309
+ doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
310
+ }
174
311
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/provider/model.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAG9B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAoBjC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC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