opencode-ahp 0.1.11 → 0.1.12
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/README.md +2 -1
- package/package.json +1 -1
- package/src/bridge.ts +39 -1
- package/src/host-chats.ts +4 -8
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -20,7 +20,8 @@ In the Agents window, an `opencode` host with:
|
|
|
20
20
|
agent, changesets, terminal, and file reads are scoped to that
|
|
21
21
|
directory (sessions without one use the plugin's own location).
|
|
22
22
|
- **Model picker** — the real opencode catalog: every provider and model
|
|
23
|
-
your server exposes.
|
|
23
|
+
your server exposes. Models with variants offer a **Reasoning Effort**
|
|
24
|
+
picker; **Default** uses the model without a variant.
|
|
24
25
|
- **Agent picker** — opencode's user-invocable agents (Build, Plan, and
|
|
25
26
|
anything you define) appear as selectable agents; subagent-only agents
|
|
26
27
|
are hidden.
|
package/package.json
CHANGED
package/src/bridge.ts
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
type McpServerCustomization,
|
|
35
35
|
type McpServerState,
|
|
36
36
|
type Message,
|
|
37
|
+
type ModelSelection,
|
|
37
38
|
type SessionActiveClient,
|
|
38
39
|
type SessionState,
|
|
39
40
|
type SessionSummary,
|
|
@@ -52,6 +53,8 @@ export interface FacadeModel {
|
|
|
52
53
|
limit: { context?: number; output?: number; input?: number };
|
|
53
54
|
/** ModelInfo.capabilities.input (e.g. ["text", "image"]). */
|
|
54
55
|
inputModalities: string[];
|
|
56
|
+
/** Selectable OpenCode variant IDs, in catalog order. */
|
|
57
|
+
variants?: readonly string[];
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
export interface FacadeProvider {
|
|
@@ -130,6 +133,23 @@ export interface FacadeModelRef {
|
|
|
130
133
|
variant?: string;
|
|
131
134
|
}
|
|
132
135
|
|
|
136
|
+
// VS Code groups this AHP model config key with the reasoning controls.
|
|
137
|
+
const REASONING_EFFORT = "reasoningEffort";
|
|
138
|
+
const DEFAULT_VARIANT = "";
|
|
139
|
+
|
|
140
|
+
export function modelRefFromSelection(selection?: ModelSelection): FacadeModelRef | undefined {
|
|
141
|
+
const id = selection?.id;
|
|
142
|
+
if (typeof id !== "string") return undefined;
|
|
143
|
+
const sep = id.indexOf("/");
|
|
144
|
+
if (sep <= 0 || sep === id.length - 1) return undefined;
|
|
145
|
+
const variant = selection?.config?.[REASONING_EFFORT];
|
|
146
|
+
return {
|
|
147
|
+
providerID: id.slice(0, sep),
|
|
148
|
+
modelID: id.slice(sep + 1),
|
|
149
|
+
...(typeof variant === "string" && variant !== DEFAULT_VARIANT ? { variant } : {}),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
133
153
|
/** A narrow opencode session (`ctx.session.*` → `SessionInfo`). */
|
|
134
154
|
export interface FacadeSession {
|
|
135
155
|
sessionID: string;
|
|
@@ -749,7 +769,9 @@ export function mapServerTools(
|
|
|
749
769
|
* - SessionModelInfo.id is a "<providerID>/<modelID>" ref;
|
|
750
770
|
* - maxContextWindow ← limit.context · maxOutputTokens ← limit.output
|
|
751
771
|
* · maxPromptTokens ← limit.input;
|
|
752
|
-
* - supportsVision ← capabilities.input contains "image"
|
|
772
|
+
* - supportsVision ← capabilities.input contains "image";
|
|
773
|
+
* - configSchema exposes model variants as reasoning choices, with Default
|
|
774
|
+
* selecting the base model without a variant.
|
|
753
775
|
*
|
|
754
776
|
* With opencode agents + a workspace directory, every
|
|
755
777
|
* AgentInfo also carries the same workspace directory container with the
|
|
@@ -781,6 +803,22 @@ export function mapCatalog(
|
|
|
781
803
|
if (model.limit.context !== undefined) info.maxContextWindow = model.limit.context;
|
|
782
804
|
if (model.limit.output !== undefined) info.maxOutputTokens = model.limit.output;
|
|
783
805
|
if (model.limit.input !== undefined) info.maxPromptTokens = model.limit.input;
|
|
806
|
+
const variants = [...new Set(model.variants)].filter((id) => id !== DEFAULT_VARIANT);
|
|
807
|
+
if (variants.length > 0) {
|
|
808
|
+
info.configSchema = {
|
|
809
|
+
type: "object",
|
|
810
|
+
properties: {
|
|
811
|
+
[REASONING_EFFORT]: {
|
|
812
|
+
type: "string",
|
|
813
|
+
title: "Reasoning Effort",
|
|
814
|
+
description: "Select an OpenCode model variant, or use the model's default settings.",
|
|
815
|
+
default: DEFAULT_VARIANT,
|
|
816
|
+
enum: [DEFAULT_VARIANT, ...variants],
|
|
817
|
+
enumLabels: ["Default", ...variants.map((id) => id.charAt(0).toUpperCase() + id.slice(1))],
|
|
818
|
+
},
|
|
819
|
+
},
|
|
820
|
+
};
|
|
821
|
+
}
|
|
784
822
|
models.push(info);
|
|
785
823
|
}
|
|
786
824
|
out.push({
|
package/src/host-chats.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { HostClientTools } from "./host-client-tools.js";
|
|
6
6
|
import { ActionType, Message } from "@microsoft/agent-host-protocol";
|
|
7
|
-
import { agentIDFromUri, chatChangesetCatalog, chatSummaryOf, initialChatState } from "./bridge.js";
|
|
7
|
+
import { agentIDFromUri, chatChangesetCatalog, chatSummaryOf, initialChatState, modelRefFromSelection } from "./bridge.js";
|
|
8
8
|
import { channelKind, isSessionChannel, sessionIDOf } from "./channels.js";
|
|
9
9
|
import { ERROR_INVALID_PARAMS } from "./handshake.js";
|
|
10
10
|
import { isRecord } from "./options.js";
|
|
@@ -287,13 +287,9 @@ export class HostChats extends HostClientTools {
|
|
|
287
287
|
*/
|
|
288
288
|
protected async applyMessageSelection(chat: ChatRuntime, message: Message): Promise<string | null> {
|
|
289
289
|
try {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
const modelID = message.model.id.slice(sep + 1);
|
|
294
|
-
if (providerID.length > 0 && modelID.length > 0) {
|
|
295
|
-
await this.opts.facade.switchModel({ sessionID: chat.sessionID, model: { providerID, modelID } });
|
|
296
|
-
}
|
|
290
|
+
const model = modelRefFromSelection(message.model);
|
|
291
|
+
if (model !== undefined) {
|
|
292
|
+
await this.opts.facade.switchModel({ sessionID: chat.sessionID, model });
|
|
297
293
|
}
|
|
298
294
|
if (message.agent?.uri !== undefined) {
|
|
299
295
|
const agentID = agentIDFromUri(message.agent.uri);
|