cursor-opencode-provider 0.8.0 → 0.8.3
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/CHANGELOG.md +174 -0
- package/README.md +230 -44
- package/SECURITY.md +60 -12
- package/dist/activity.d.ts +73 -1
- package/dist/activity.js +231 -5
- package/dist/agent-url.js +37 -9
- package/dist/auth-renewal.d.ts +1 -1
- package/dist/auth-renewal.js +58 -26
- package/dist/billing.d.ts +105 -0
- package/dist/billing.js +212 -0
- package/dist/classic-tool-results.d.ts +1 -0
- package/dist/classic-tool-results.js +42 -0
- package/dist/context/build.d.ts +23 -4
- package/dist/context/build.js +65 -10
- package/dist/context/dynamic-catalog.js +6 -1
- package/dist/context/env.js +27 -3
- package/dist/context/epoch.js +9 -5
- package/dist/context/frozen.js +6 -2
- package/dist/context/git.d.ts +5 -2
- package/dist/context/git.js +17 -7
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +2 -0
- package/dist/context/paths.d.ts +45 -18
- package/dist/context/paths.js +72 -22
- package/dist/context/skills-bridge.d.ts +22 -0
- package/dist/context/skills-bridge.js +20 -0
- package/dist/context/skills.d.ts +34 -0
- package/dist/context/skills.js +211 -0
- package/dist/debug.js +13 -2
- package/dist/early-tool-rows.d.ts +60 -0
- package/dist/early-tool-rows.js +96 -0
- package/dist/errors.d.ts +49 -7
- package/dist/errors.js +163 -8
- package/dist/host-agent-mode.d.ts +53 -4
- package/dist/host-agent-mode.js +117 -13
- package/dist/host-interrupt.d.ts +12 -0
- package/dist/host-interrupt.js +18 -0
- package/dist/host-plan-file.d.ts +28 -0
- package/dist/host-plan-file.js +76 -0
- package/dist/host-steer.d.ts +71 -0
- package/dist/host-steer.js +232 -0
- package/dist/image-input.d.ts +18 -0
- package/dist/image-input.js +122 -30
- package/dist/image-save.d.ts +10 -2
- package/dist/image-save.js +33 -21
- package/dist/index.d.ts +2 -2
- package/dist/language-model.d.ts +149 -30
- package/dist/language-model.js +3127 -673
- package/dist/lost-request.d.ts +39 -0
- package/dist/lost-request.js +111 -0
- package/dist/model-config.d.ts +12 -1
- package/dist/model-config.js +78 -30
- package/dist/models.d.ts +26 -3
- package/dist/models.js +101 -45
- package/dist/opencode2/catalog.d.ts +1 -0
- package/dist/opencode2/catalog.js +2 -0
- package/dist/opencode2/image-save-tool.d.ts +8 -0
- package/dist/opencode2/image-save-tool.js +84 -0
- package/dist/opencode2/tool-results.d.ts +18 -0
- package/dist/opencode2/tool-results.js +66 -0
- package/dist/opencode2/types.d.ts +15 -0
- package/dist/parallel-step.d.ts +65 -0
- package/dist/parallel-step.js +102 -0
- package/dist/plugin-opencode2.js +233 -65
- package/dist/plugin.js +97 -23
- package/dist/pricing-data.d.ts +40 -3
- package/dist/pricing-data.js +40 -3
- package/dist/pricing.d.ts +1 -1
- package/dist/pricing.js +7 -4
- package/dist/process-shared.d.ts +14 -0
- package/dist/process-shared.js +18 -0
- package/dist/protocol/apply-patch.d.ts +25 -13
- package/dist/protocol/apply-patch.js +79 -30
- package/dist/protocol/ask-question.d.ts +12 -1
- package/dist/protocol/ask-question.js +77 -3
- package/dist/protocol/blob-store.d.ts +5 -1
- package/dist/protocol/blob-store.js +10 -6
- package/dist/protocol/client-version.js +6 -4
- package/dist/protocol/conversation-cache-header.d.ts +23 -0
- package/dist/protocol/conversation-cache-header.js +149 -0
- package/dist/protocol/conversation-persistence.d.ts +27 -1
- package/dist/protocol/conversation-persistence.js +628 -126
- package/dist/protocol/conversation-state.d.ts +8 -1
- package/dist/protocol/conversation-state.js +28 -7
- package/dist/protocol/create-plan.d.ts +47 -25
- package/dist/protocol/create-plan.js +33 -23
- package/dist/protocol/host-notes.d.ts +31 -0
- package/dist/protocol/host-notes.js +85 -0
- package/dist/protocol/interactions.d.ts +26 -17
- package/dist/protocol/interactions.js +80 -31
- package/dist/protocol/messages.js +164 -21
- package/dist/protocol/request.d.ts +40 -19
- package/dist/protocol/request.js +55 -28
- package/dist/protocol/sent-history-images.d.ts +49 -0
- package/dist/protocol/sent-history-images.js +102 -0
- package/dist/protocol/switch-mode.d.ts +66 -27
- package/dist/protocol/switch-mode.js +147 -73
- package/dist/protocol/token-details.d.ts +2 -0
- package/dist/protocol/token-details.js +11 -1
- package/dist/protocol/tool-call-bridge.d.ts +6 -0
- package/dist/protocol/tool-call-bridge.js +24 -0
- package/dist/protocol/tools.d.ts +90 -9
- package/dist/protocol/tools.js +543 -151
- package/dist/protocol/turn-provenance.d.ts +19 -4
- package/dist/protocol/turn-provenance.js +77 -20
- package/dist/replay-safety.d.ts +22 -4
- package/dist/replay-safety.js +86 -27
- package/dist/retry-budget.d.ts +21 -0
- package/dist/retry-budget.js +94 -0
- package/dist/runtime-files.d.ts +23 -0
- package/dist/runtime-files.js +581 -0
- package/dist/session.d.ts +129 -10
- package/dist/session.js +198 -35
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +1 -1
- package/dist/shell-timeout.d.ts +54 -10
- package/dist/shell-timeout.js +362 -92
- package/dist/stream-write.d.ts +20 -0
- package/dist/stream-write.js +87 -0
- package/dist/terminal-runner.d.ts +15 -0
- package/dist/terminal-runner.js +528 -0
- package/dist/todo-store.d.ts +2 -0
- package/dist/todo-store.js +19 -0
- package/dist/transport/connect.d.ts +10 -1
- package/dist/transport/connect.js +124 -27
- package/dist/usage.d.ts +37 -17
- package/dist/usage.js +85 -34
- package/package.json +5 -3
- package/dist/plan-execution-kickoff.d.ts +0 -57
- package/dist/plan-execution-kickoff.js +0 -186
- package/dist/protocol/thinking.d.ts +0 -15
- package/dist/protocol/thinking.js +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursor-opencode-provider",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Use Cursor subscription models from OpenCode via Cursor's Connect-RPC agent protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,13 +70,15 @@
|
|
|
70
70
|
"LICENSE",
|
|
71
71
|
"DISCLAIMER.md",
|
|
72
72
|
"SECURITY.md",
|
|
73
|
-
"README.md"
|
|
73
|
+
"README.md",
|
|
74
|
+
"CHANGELOG.md"
|
|
74
75
|
],
|
|
75
76
|
"scripts": {
|
|
76
77
|
"build": "tsc",
|
|
77
78
|
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
78
79
|
"test": "bun test",
|
|
79
|
-
"test:
|
|
80
|
+
"test:coverage": "bun test --coverage --coverage-reporter=lcov && bun scripts/strip-copied-coverage.ts",
|
|
81
|
+
"test:node-http2": "bun run build && node test/node-http2-cleanup.mjs && node test/node-http2-drain.mjs && node test/node-http2-session-memory.mjs",
|
|
80
82
|
"test:watch": "bun test --watch",
|
|
81
83
|
"generate:pricing": "bun run scripts/generate-cursor-pricing.ts",
|
|
82
84
|
"generate:pricing:check": "bun run scripts/generate-cursor-pricing.ts -- --check",
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queue OpenCode's post-plan-exit kickoff after CreatePlan approval.
|
|
3
|
-
*
|
|
4
|
-
* Native `plan_exit` asks the user, then injects a synthetic user message with
|
|
5
|
-
* `agent: "build"` so a new turn starts implementing. Our CreatePlan → question
|
|
6
|
-
* path already asks; this module is the missing second half. A host plugin
|
|
7
|
-
* installs the prompt handler; the language model records a request after Yes,
|
|
8
|
-
* and the outer stream wrapper flushes it only after the current `doStream`
|
|
9
|
-
* result stream has settled. This prevents a second generation from starting
|
|
10
|
-
* while the continuation Run is still live.
|
|
11
|
-
*/
|
|
12
|
-
export type PlanExecutionKickoffInput = {
|
|
13
|
-
sessionID: string;
|
|
14
|
-
/** Filesystem path (or relative display path) of the approved plan. */
|
|
15
|
-
planPath: string;
|
|
16
|
-
/** Concrete Cursor Run that owns the approval. Guards recovery/supersession. */
|
|
17
|
-
cursorSessionID?: string;
|
|
18
|
-
};
|
|
19
|
-
export type PlanExecutionKickoffFn = (input: PlanExecutionKickoffInput) => void | Promise<void>;
|
|
20
|
-
/** Upstream `PlanExitTool` wording — keep verbatim so behaviour matches OpenCode. */
|
|
21
|
-
export declare function createPlanExecutionKickoffText(planPath: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Prefer a worktree-relative label when the plan sits under `workspaceRoot`,
|
|
24
|
-
* matching OpenCode's `path.relative(instance.worktree, Session.plan(...))`.
|
|
25
|
-
* Otherwise keep the absolute path (global data `plans/` is outside the tree).
|
|
26
|
-
*/
|
|
27
|
-
export declare function formatPlanKickoffPath(planPath: string, workspaceRoot?: string): string;
|
|
28
|
-
/** Decode a `file://` plan URI to a filesystem path; pass other strings through. */
|
|
29
|
-
export declare function planPathFromUri(planUri: string): string;
|
|
30
|
-
export type PlanExecutionKickoffState = PlanExecutionKickoffInput & {
|
|
31
|
-
status: "pending" | "failed";
|
|
32
|
-
attempts: number;
|
|
33
|
-
lastError?: string;
|
|
34
|
-
};
|
|
35
|
-
/** Install (or clear) the host kickoff. */
|
|
36
|
-
export declare function setPlanExecutionKickoff(fn: PlanExecutionKickoffFn | undefined): void;
|
|
37
|
-
export declare function hasPlanExecutionKickoff(): boolean;
|
|
38
|
-
/** Record the approved plan; execution is flushed after the stream settles. */
|
|
39
|
-
export declare function queuePlanExecutionKickoff(input: PlanExecutionKickoffInput): boolean;
|
|
40
|
-
/** Drop any approval state owned by a deleted host session. */
|
|
41
|
-
export declare function cancelPlanExecutionKickoff(sessionID: string | undefined): void;
|
|
42
|
-
/**
|
|
43
|
-
* Run one pending kickoff only after the owning Cursor Run reached a terminal,
|
|
44
|
-
* idle state. Returns true only after successful host handoff.
|
|
45
|
-
*/
|
|
46
|
-
export declare function flushPlanExecutionKickoff(sessionID: string | undefined, options?: {
|
|
47
|
-
cursorSessionID?: string;
|
|
48
|
-
terminal?: boolean;
|
|
49
|
-
pumpActive?: boolean;
|
|
50
|
-
pendingExecs?: number;
|
|
51
|
-
}): Promise<boolean>;
|
|
52
|
-
/** Consume a user-visible warning on the next provider turn. */
|
|
53
|
-
export declare function takePlanExecutionKickoffWarning(sessionID: string | undefined): string | undefined;
|
|
54
|
-
/** Retry state remains explicit; no timer or automatic loop fires it. */
|
|
55
|
-
export declare function planExecutionKickoffState(sessionID: string | undefined): PlanExecutionKickoffState | undefined;
|
|
56
|
-
/** Test helper: clear the registered kickoff and pending approvals. */
|
|
57
|
-
export declare function resetPlanExecutionKickoffForTests(): void;
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queue OpenCode's post-plan-exit kickoff after CreatePlan approval.
|
|
3
|
-
*
|
|
4
|
-
* Native `plan_exit` asks the user, then injects a synthetic user message with
|
|
5
|
-
* `agent: "build"` so a new turn starts implementing. Our CreatePlan → question
|
|
6
|
-
* path already asks; this module is the missing second half. A host plugin
|
|
7
|
-
* installs the prompt handler; the language model records a request after Yes,
|
|
8
|
-
* and the outer stream wrapper flushes it only after the current `doStream`
|
|
9
|
-
* result stream has settled. This prevents a second generation from starting
|
|
10
|
-
* while the continuation Run is still live.
|
|
11
|
-
*/
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
14
|
-
import { errorMessage, trace } from "./debug.js";
|
|
15
|
-
/** Upstream `PlanExitTool` wording — keep verbatim so behaviour matches OpenCode. */
|
|
16
|
-
export function createPlanExecutionKickoffText(planPath) {
|
|
17
|
-
const where = planPath.trim() || "the plan";
|
|
18
|
-
return `The plan at ${where} has been approved, you can now edit files. Execute the plan`;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Prefer a worktree-relative label when the plan sits under `workspaceRoot`,
|
|
22
|
-
* matching OpenCode's `path.relative(instance.worktree, Session.plan(...))`.
|
|
23
|
-
* Otherwise keep the absolute path (global data `plans/` is outside the tree).
|
|
24
|
-
*/
|
|
25
|
-
export function formatPlanKickoffPath(planPath, workspaceRoot) {
|
|
26
|
-
const absolute = planPath.trim();
|
|
27
|
-
if (!absolute)
|
|
28
|
-
return absolute;
|
|
29
|
-
const root = workspaceRoot?.trim();
|
|
30
|
-
if (!root)
|
|
31
|
-
return absolute;
|
|
32
|
-
const relative = path.relative(root, absolute);
|
|
33
|
-
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
34
|
-
return absolute;
|
|
35
|
-
}
|
|
36
|
-
return relative;
|
|
37
|
-
}
|
|
38
|
-
/** Decode a `file://` plan URI to a filesystem path; pass other strings through. */
|
|
39
|
-
export function planPathFromUri(planUri) {
|
|
40
|
-
const raw = planUri.trim();
|
|
41
|
-
if (!raw)
|
|
42
|
-
return "";
|
|
43
|
-
if (raw.startsWith("file:")) {
|
|
44
|
-
try {
|
|
45
|
-
return fileURLToPath(raw);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return raw;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return raw;
|
|
52
|
-
}
|
|
53
|
-
let kickoff;
|
|
54
|
-
const pending = new Map();
|
|
55
|
-
const warnings = new Map();
|
|
56
|
-
const MAX_PENDING_PLAN_KICKOFFS = 256;
|
|
57
|
-
/** Install (or clear) the host kickoff. */
|
|
58
|
-
export function setPlanExecutionKickoff(fn) {
|
|
59
|
-
kickoff = fn;
|
|
60
|
-
if (!fn) {
|
|
61
|
-
pending.clear();
|
|
62
|
-
warnings.clear();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export function hasPlanExecutionKickoff() {
|
|
66
|
-
return kickoff !== undefined;
|
|
67
|
-
}
|
|
68
|
-
/** Record the approved plan; execution is flushed after the stream settles. */
|
|
69
|
-
export function queuePlanExecutionKickoff(input) {
|
|
70
|
-
const sessionID = input.sessionID.trim();
|
|
71
|
-
const planPath = input.planPath.trim();
|
|
72
|
-
if (!sessionID || !planPath || !kickoff) {
|
|
73
|
-
trace(`plan-execution-kickoff: not queued sessionID=${JSON.stringify(sessionID)} ` +
|
|
74
|
-
`planPath=${JSON.stringify(planPath)} handler=${Boolean(kickoff)}`);
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
pending.set(sessionID, {
|
|
78
|
-
sessionID,
|
|
79
|
-
planPath,
|
|
80
|
-
...(input.cursorSessionID ? { cursorSessionID: input.cursorSessionID } : {}),
|
|
81
|
-
status: "pending",
|
|
82
|
-
attempts: 0,
|
|
83
|
-
});
|
|
84
|
-
warnings.delete(sessionID);
|
|
85
|
-
while (pending.size > MAX_PENDING_PLAN_KICKOFFS) {
|
|
86
|
-
const oldest = pending.keys().next().value;
|
|
87
|
-
if (!oldest)
|
|
88
|
-
break;
|
|
89
|
-
pending.delete(oldest);
|
|
90
|
-
warnings.delete(oldest);
|
|
91
|
-
}
|
|
92
|
-
trace(`plan-execution-kickoff: pending sessionID=${sessionID} ` +
|
|
93
|
-
`cursorSessionID=${input.cursorSessionID ?? ""} planPath=${planPath}`);
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
/** Drop any approval state owned by a deleted host session. */
|
|
97
|
-
export function cancelPlanExecutionKickoff(sessionID) {
|
|
98
|
-
const key = sessionID?.trim();
|
|
99
|
-
if (!key)
|
|
100
|
-
return;
|
|
101
|
-
pending.delete(key);
|
|
102
|
-
warnings.delete(key);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Run one pending kickoff only after the owning Cursor Run reached a terminal,
|
|
106
|
-
* idle state. Returns true only after successful host handoff.
|
|
107
|
-
*/
|
|
108
|
-
export async function flushPlanExecutionKickoff(sessionID, options = {}) {
|
|
109
|
-
const key = sessionID?.trim();
|
|
110
|
-
if (!key)
|
|
111
|
-
return false;
|
|
112
|
-
const state = pending.get(key);
|
|
113
|
-
if (!state)
|
|
114
|
-
return false;
|
|
115
|
-
if (options.terminal !== true || options.pumpActive || (options.pendingExecs ?? 0) > 0) {
|
|
116
|
-
trace(`plan-execution-kickoff: deferred sessionID=${key} terminal=${Boolean(options.terminal)} ` +
|
|
117
|
-
`pumpActive=${Boolean(options.pumpActive)} pending=${options.pendingExecs ?? 0}`);
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
if (state.cursorSessionID
|
|
121
|
-
&& options.cursorSessionID
|
|
122
|
-
&& state.cursorSessionID !== options.cursorSessionID) {
|
|
123
|
-
// The owning Run was superseded before the handoff could happen. Applying
|
|
124
|
-
// it from a later Run would execute a stale approval in the wrong turn.
|
|
125
|
-
pending.delete(key);
|
|
126
|
-
warnings.delete(key);
|
|
127
|
-
trace(`plan-execution-kickoff: discarded stale Run sessionID=${key} ` +
|
|
128
|
-
`owner=${state.cursorSessionID} terminal=${options.cursorSessionID}`);
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
const run = kickoff;
|
|
132
|
-
if (!run) {
|
|
133
|
-
const message = "The plan was approved, but this host cannot start its execution turn.";
|
|
134
|
-
state.status = "failed";
|
|
135
|
-
state.lastError = message;
|
|
136
|
-
warnings.set(key, message);
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
state.attempts += 1;
|
|
140
|
-
try {
|
|
141
|
-
await run({
|
|
142
|
-
sessionID: state.sessionID,
|
|
143
|
-
planPath: state.planPath,
|
|
144
|
-
...(state.cursorSessionID ? { cursorSessionID: state.cursorSessionID } : {}),
|
|
145
|
-
});
|
|
146
|
-
pending.delete(key);
|
|
147
|
-
warnings.delete(key);
|
|
148
|
-
trace(`plan-execution-kickoff: queued sessionID=${key} planPath=${state.planPath}`);
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
const detail = errorMessage(error);
|
|
153
|
-
const message = `The approved plan could not start execution: ${detail}. ` +
|
|
154
|
-
"The plan remains active and can be retried.";
|
|
155
|
-
state.status = "failed";
|
|
156
|
-
state.lastError = detail;
|
|
157
|
-
// A later explicit provider turn may retry after its own terminal boundary;
|
|
158
|
-
// do not keep pinning the retry to the now-finished Cursor Run.
|
|
159
|
-
delete state.cursorSessionID;
|
|
160
|
-
warnings.set(key, message);
|
|
161
|
-
trace(`plan-execution-kickoff: FAILED sessionID=${key} attempts=${state.attempts} err=${detail}`);
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/** Consume a user-visible warning on the next provider turn. */
|
|
166
|
-
export function takePlanExecutionKickoffWarning(sessionID) {
|
|
167
|
-
const key = sessionID?.trim();
|
|
168
|
-
if (!key)
|
|
169
|
-
return undefined;
|
|
170
|
-
const message = warnings.get(key);
|
|
171
|
-
if (message)
|
|
172
|
-
warnings.delete(key);
|
|
173
|
-
return message;
|
|
174
|
-
}
|
|
175
|
-
/** Retry state remains explicit; no timer or automatic loop fires it. */
|
|
176
|
-
export function planExecutionKickoffState(sessionID) {
|
|
177
|
-
const key = sessionID?.trim();
|
|
178
|
-
const state = key ? pending.get(key) : undefined;
|
|
179
|
-
return state ? { ...state } : undefined;
|
|
180
|
-
}
|
|
181
|
-
/** Test helper: clear the registered kickoff and pending approvals. */
|
|
182
|
-
export function resetPlanExecutionKickoffForTests() {
|
|
183
|
-
kickoff = undefined;
|
|
184
|
-
pending.clear();
|
|
185
|
-
warnings.clear();
|
|
186
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type EffortConfig = {
|
|
2
|
-
reasoningEffort?: string;
|
|
3
|
-
maxMode?: boolean;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Build RequestedModel parameter list from a model's variant parameters
|
|
7
|
-
* and optional overrides from providerOptions.
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildRequestedModelParams(variantParameters: Array<{
|
|
10
|
-
id: string;
|
|
11
|
-
value: string;
|
|
12
|
-
}>, options?: EffortConfig): Array<{
|
|
13
|
-
id: string;
|
|
14
|
-
value: string;
|
|
15
|
-
}>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Reasoning effort / max mode → RequestedModel parameters
|
|
2
|
-
/**
|
|
3
|
-
* Build RequestedModel parameter list from a model's variant parameters
|
|
4
|
-
* and optional overrides from providerOptions.
|
|
5
|
-
*/
|
|
6
|
-
export function buildRequestedModelParams(variantParameters, options) {
|
|
7
|
-
// Start with variant's parameters as base
|
|
8
|
-
const params = variantParameters.map((p) => ({ ...p }));
|
|
9
|
-
// Override effort if specified
|
|
10
|
-
if (options?.reasoningEffort) {
|
|
11
|
-
const effortIdx = params.findIndex((p) => p.id === "effort" || p.id === "reasoning");
|
|
12
|
-
if (effortIdx >= 0) {
|
|
13
|
-
params[effortIdx] = { ...params[effortIdx], value: options.reasoningEffort };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return params;
|
|
17
|
-
}
|