@myrialabs/clopen 0.4.45 → 0.4.46
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/backend/artifacts/project/sources.ts +2 -2
- package/backend/engine/adapters/claude/models.test.ts +49 -0
- package/backend/engine/adapters/claude/models.ts +81 -562
- package/backend/engine/adapters/claude/stream.ts +5 -4
- package/backend/engine/adapters/cline/credential.ts +42 -18
- package/backend/engine/adapters/cline/message-converter.ts +31 -1
- package/backend/engine/adapters/cline/models.test.ts +77 -0
- package/backend/engine/adapters/cline/models.ts +89 -3
- package/backend/engine/adapters/cline/presets.ts +5 -0
- package/backend/engine/adapters/cline/stream.ts +9 -2
- package/backend/engine/adapters/codex/message-converter.ts +1 -1
- package/backend/engine/adapters/codex/models.ts +54 -31
- package/backend/engine/adapters/codex/patch-rollout.test.ts +36 -1
- package/backend/engine/adapters/codex/patch-rollout.ts +60 -29
- package/backend/engine/adapters/codex/session-fork.ts +5 -0
- package/backend/engine/adapters/codex/stream.ts +8 -7
- package/backend/engine/adapters/copilot/models.test.ts +40 -0
- package/backend/engine/adapters/copilot/models.ts +51 -24
- package/backend/engine/adapters/copilot/permissions.test.ts +47 -0
- package/backend/engine/adapters/copilot/permissions.ts +72 -0
- package/backend/engine/adapters/copilot/stream.ts +77 -67
- package/backend/engine/adapters/cursor/stream.ts +8 -4
- package/backend/engine/adapters/pi/credential.test.ts +83 -0
- package/backend/engine/adapters/pi/credential.ts +68 -12
- package/backend/engine/adapters/pi/environment.ts +9 -5
- package/backend/engine/adapters/pi/mcp.test.ts +194 -0
- package/backend/engine/adapters/pi/mcp.ts +88 -0
- package/backend/engine/adapters/pi/message-converter.ts +6 -4
- package/backend/engine/adapters/pi/presets.ts +10 -5
- package/backend/engine/adapters/pi/stream.ts +42 -38
- package/backend/engine/adapters/qwen/environment.ts +39 -2
- package/backend/engine/adapters/qwen/message-converter.test.ts +64 -0
- package/backend/engine/adapters/qwen/message-converter.ts +40 -23
- package/backend/engine/adapters/qwen/models.test.ts +25 -0
- package/backend/engine/adapters/qwen/models.ts +42 -5
- package/backend/engine/adapters/qwen/session-store.test.ts +39 -0
- package/backend/engine/adapters/qwen/session-store.ts +66 -0
- package/backend/engine/adapters/qwen/stream.ts +110 -87
- package/backend/engine/docs/adapter-contract.md +7 -4
- package/backend/engine/docs/lessons-learned.md +405 -62
- package/backend/engine/docs/quick-reference.md +2 -2
- package/backend/engine/docs/stack.md +17 -4
- package/backend/engine/docs/websocket-routes.md +5 -5
- package/backend/engine/install-recipes.test.ts +105 -5
- package/backend/engine/install-recipes.ts +102 -42
- package/backend/engine/install-runner.ts +56 -2
- package/backend/engine/stack-project.ts +71 -1
- package/backend/index.ts +5 -0
- package/backend/mcp/README.md +2 -2
- package/backend/mcp/external/config.ts +18 -0
- package/backend/mcp/external/proxy.ts +2 -2
- package/backend/mcp/index.ts +8 -0
- package/backend/mcp/internal/config.ts +42 -3
- package/backend/memory/embedding/install.ts +29 -1
- package/backend/utils/keyed-lock.test.ts +33 -0
- package/backend/utils/keyed-lock.ts +17 -0
- package/backend/utils/port-utils.test.ts +29 -0
- package/backend/utils/port-utils.ts +19 -0
- package/backend/ws/engine/cline/accounts.ts +26 -6
- package/backend/ws/engine/codex/accounts.test.ts +49 -0
- package/backend/ws/engine/codex/accounts.ts +17 -13
- package/backend/ws/engine/pi/accounts.ts +61 -6
- package/dist/assets/{index-D-Ad1N96.js → index-BTcR1byF.js} +1 -1
- package/dist/assets/{index-Am-rJRxA.js → index-CwuKQelV.js} +1 -1
- package/dist/assets/{main--PLCDxSy.css → main-BiDNMWb3.css} +1 -1
- package/dist/assets/{main-DelPm2Xt.js → main-BlhKWz2B.js} +595 -593
- package/dist/index.html +2 -2
- package/package.json +19 -15
- package/backend/engine/adapters/pi/mcp-tools.ts +0 -153
- package/backend/engine/adapters/qwen/session-fork.ts +0 -109
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* (README §10.12).
|
|
19
19
|
*
|
|
20
20
|
* AskUserQuestion: Qwen's `canUseTool` callback signature does NOT include
|
|
21
|
-
* the tool_use_id (
|
|
21
|
+
* the tool_use_id (`CanUseTool` in `@qwen-code/sdk`'s `dist/index.d.ts`),
|
|
22
22
|
* so we cannot key pending answers by id at the moment the SDK invokes the
|
|
23
23
|
* callback. The SDK serialises AskUserQuestion — only one can be pending at
|
|
24
24
|
* a time — so we keep a single slot and recover the real tool_use_id from
|
|
@@ -35,16 +35,17 @@ import type {
|
|
|
35
35
|
SDKUserMessage,
|
|
36
36
|
PermissionResult,
|
|
37
37
|
ToolInput,
|
|
38
|
+
EffortTier,
|
|
38
39
|
} from '@qwen-code/sdk';
|
|
39
40
|
import { loadEngineSdk } from '$backend/engine/sdk-loader';
|
|
40
|
-
import type { EngineOutput, EngineModel } from '$shared/types/unified';
|
|
41
|
+
import type { EngineOutput, EngineModel, AskUserQuestion } from '$shared/types/unified';
|
|
41
42
|
import type { AIEngine, EngineQueryOptions, StructuredGenerationOptions } from '../../types';
|
|
42
43
|
import { buildJsonPrompt, extractJson, emptyGenerationError } from '../../structured-helpers';
|
|
43
44
|
import { resolveOsPath } from '$backend/utils/paths';
|
|
44
45
|
import { debug } from '$shared/utils/logger';
|
|
45
46
|
import { getEngineEnv } from './environment';
|
|
46
47
|
import { handleStreamError } from './error-handler';
|
|
47
|
-
import { createSdkMessageConverter, toSdkUserMessage, type SdkMessageConverter } from './message-converter';
|
|
48
|
+
import { createSdkMessageConverter, toSdkUserMessage, toQwenAnswers, type SdkMessageConverter } from './message-converter';
|
|
48
49
|
import { fetchQwenModels } from './models';
|
|
49
50
|
import { getQwenMcpConfig } from '../../../mcp';
|
|
50
51
|
import { EngineRuns } from '../run-registry';
|
|
@@ -53,7 +54,44 @@ import { syncSkills } from '$backend/skills';
|
|
|
53
54
|
import { syncEngineArtifacts } from '$backend/engine/artifact-sync';
|
|
54
55
|
import { resolveProjectBridge, buildProjectPromptContext } from '$backend/artifacts/project';
|
|
55
56
|
import { resolvePermissionsFromDb, isToolAllowed, excludedBuiltinTools } from '$backend/permissions';
|
|
56
|
-
import {
|
|
57
|
+
import { sessionStateExists } from './session-store';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Every tier the SDK's `effort` option accepts. Typed against the SDK union so
|
|
61
|
+
* a tier it drops is a compile error here. The picker only offers what the
|
|
62
|
+
* model advertises (see ./models.ts); this guards against a stale per-model
|
|
63
|
+
* default from another engine reaching the CLI.
|
|
64
|
+
*/
|
|
65
|
+
const QWEN_EFFORTS: ReadonlySet<string> = new Set<EffortTier>(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
66
|
+
|
|
67
|
+
function toQwenEffort(reasoningEffort: string | undefined): EffortTier | undefined {
|
|
68
|
+
return reasoningEffort && QWEN_EFFORTS.has(reasoningEffort) ? reasoningEffort as EffortTier : undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The CLI's `MAX_CAN_USE_TOOL_TIMEOUT_MS`; anything larger is ignored for its 60 s default. */
|
|
72
|
+
const QWEN_MAX_CAN_USE_TOOL_TIMEOUT_MS = 600_000;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The prompt for one turn, as a stream that stays OPEN until the turn ends.
|
|
76
|
+
*
|
|
77
|
+
* When the prompt iterable completes, the SDK waits for the first `result`
|
|
78
|
+
* or its `streamClose` timeout (60 s) and then closes the CLI's stdin. The
|
|
79
|
+
* CLI answers that by rejecting every pending and future control request
|
|
80
|
+
* with "Input closed" — so in any turn longer than a minute, AskUserQuestion,
|
|
81
|
+
* write-tool approvals and interrupt all failed ("The host could not present
|
|
82
|
+
* the required approval"). Holding the stream open until `end()` (called on
|
|
83
|
+
* `result`, on abort, and in `finally`) keeps stdin alive for the whole turn.
|
|
84
|
+
*/
|
|
85
|
+
function openPromptStream(message: SDKUserMessage, signal: AbortSignal): { iterable: AsyncIterable<SDKUserMessage>; end: () => void } {
|
|
86
|
+
let end!: () => void;
|
|
87
|
+
const ended = new Promise<void>((resolve) => { end = resolve; });
|
|
88
|
+
signal.addEventListener('abort', () => end(), { once: true });
|
|
89
|
+
const iterable = (async function* (): AsyncIterable<SDKUserMessage> {
|
|
90
|
+
yield message;
|
|
91
|
+
await ended;
|
|
92
|
+
})();
|
|
93
|
+
return { iterable, end };
|
|
94
|
+
}
|
|
57
95
|
|
|
58
96
|
interface PendingAskUserQuestion {
|
|
59
97
|
resolve: (result: PermissionResult) => void;
|
|
@@ -80,11 +118,8 @@ interface QwenRun {
|
|
|
80
118
|
query: Query | null;
|
|
81
119
|
/**
|
|
82
120
|
* Live converter for this run — used by `resolveUserAnswer` to push the
|
|
83
|
-
* user's answers into the converter state so the
|
|
84
|
-
*
|
|
85
|
-
* AUQ tool execution path drops `answers` on the floor; see the comment
|
|
86
|
-
* block at the top of `message-converter.ts` and the analysis in
|
|
87
|
-
* `qwen/stream.ts::canUseTool` for AskUserQuestion).
|
|
121
|
+
* user's answers into the converter state so the AUQ tool_result is shown
|
|
122
|
+
* in the same wording every engine uses (see `convertUserMessage`).
|
|
88
123
|
*/
|
|
89
124
|
converter: SdkMessageConverter | null;
|
|
90
125
|
pendingAskUserQuestion: PendingAskUserQuestion | null;
|
|
@@ -140,6 +175,7 @@ export class QwenEngine implements AIEngine {
|
|
|
140
175
|
resume,
|
|
141
176
|
maxTurns,
|
|
142
177
|
modelId,
|
|
178
|
+
reasoningEffort,
|
|
143
179
|
includePartialMessages = true,
|
|
144
180
|
abortController,
|
|
145
181
|
accountId,
|
|
@@ -177,30 +213,29 @@ export class QwenEngine implements AIEngine {
|
|
|
177
213
|
// (Qwen otherwise auto-allows everything). Tool names arrive snake_cased.
|
|
178
214
|
const permissions = resolvePermissionsFromDb('qwen', options.mcpContext?.projectId, profileId);
|
|
179
215
|
|
|
180
|
-
//
|
|
181
|
-
// (`forkSession: true`)
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (forkQwenSessionState(resolvedProjectPath, resume, forkId)) {
|
|
194
|
-
resumeId = forkId;
|
|
195
|
-
debug.log('engine', `Qwen resumed session: ${forkId} (forked from ${resume})`);
|
|
196
|
-
}
|
|
216
|
+
// Native fork on EVERY resume — same semantics as Claude
|
|
217
|
+
// (`forkSession: true`) and OpenCode (`client.session.fork()`): each
|
|
218
|
+
// turn gets a brand-new session id so the original branch's history is
|
|
219
|
+
// never mutated and the multi-branch checkpoint tree stays consistent.
|
|
220
|
+
// The CLI picks the fork id itself (`--session-id` is rejected next to
|
|
221
|
+
// `--resume`), and reports it on the stream like any other session id.
|
|
222
|
+
// `--fork-session` exits the CLI when the source chat is missing, so a
|
|
223
|
+
// vanished source falls through to a plain resume (best-effort recovery).
|
|
224
|
+
const forkOnResume = !!resume && sessionStateExists(resolvedProjectPath, resume);
|
|
225
|
+
if (resume) {
|
|
226
|
+
debug.log('engine', forkOnResume
|
|
227
|
+
? `Qwen resuming session ${resume} as a fork`
|
|
228
|
+
: `Qwen resume source ${resume} not found on disk, resuming without fork`);
|
|
197
229
|
}
|
|
230
|
+
const effort = toQwenEffort(reasoningEffort);
|
|
198
231
|
|
|
199
232
|
// Capture the last few stderr lines from the bundled CLI so we can
|
|
200
233
|
// surface them when the SDK reports a generic "CLI process exited
|
|
201
234
|
// with code N" error. Otherwise the underlying cause (bad model,
|
|
202
235
|
// bad endpoint, MCP timeout, …) is invisible to the user.
|
|
203
236
|
const stderrLines: string[] = [];
|
|
237
|
+
// Closes the prompt stream; set once the query is built (see openPromptStream).
|
|
238
|
+
let endPrompt = (): void => {};
|
|
204
239
|
const STDERR_KEEP = 20;
|
|
205
240
|
|
|
206
241
|
// Optional verbose SDK logging when CLOPEN_DEBUG_QWEN is set — useful
|
|
@@ -228,54 +263,27 @@ export class QwenEngine implements AIEngine {
|
|
|
228
263
|
debug.warn('engine', 'qwen stderr:', trimmed);
|
|
229
264
|
},
|
|
230
265
|
...(verbose ? { logLevel: 'debug' as const, debug: true } : {}),
|
|
231
|
-
// Lift the SDK's defaults: AskUserQuestion
|
|
232
|
-
//
|
|
233
|
-
// behaviour). MCP requests get a longer ceiling for slow
|
|
266
|
+
// Lift the SDK's defaults: AskUserQuestion blocks while the user
|
|
267
|
+
// thinks, and MCP requests get a longer ceiling for slow
|
|
234
268
|
// browser-automation calls. Other timeouts keep the default.
|
|
235
269
|
//
|
|
236
|
-
// `canUseTool` is
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
//
|
|
241
|
-
// the practical maximum and is effectively unbounded for AUQ.
|
|
270
|
+
// `canUseTool` is ALSO forwarded to the CLI, which ignores any
|
|
271
|
+
// value above its own `MAX_CAN_USE_TOOL_TIMEOUT_MS` (10 min) and
|
|
272
|
+
// silently falls back to 60 s — so a larger "unbounded" value
|
|
273
|
+
// cancelled every question answered after a minute. 10 min is
|
|
274
|
+
// the longest wait the CLI allows.
|
|
242
275
|
timeout: {
|
|
243
|
-
canUseTool:
|
|
276
|
+
canUseTool: QWEN_MAX_CAN_USE_TOOL_TIMEOUT_MS,
|
|
244
277
|
mcpRequest: 600_000,
|
|
245
278
|
},
|
|
246
279
|
// 'default' lets `canUseTool` decide; non-write tools auto-execute.
|
|
247
280
|
permissionMode: 'default',
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
//
|
|
251
|
-
//
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
// `handleOutgoingPermissionRequest` (cli.js:486478-486485) calls
|
|
255
|
-
// `onConfirm(ProceedOnce)` WITHOUT forwarding the `updatedInput`
|
|
256
|
-
// payload we resolve `canUseTool` with — so the user's `answers`
|
|
257
|
-
// are dropped and the AUQ tool executes with `userAnswers: {}`,
|
|
258
|
-
// emitting `"User has provided the following answers:\n\n"` and
|
|
259
|
-
// closing the UI dialog before the user can respond. The
|
|
260
|
-
// converter has a rewrite workaround (recordUserAnswer +
|
|
261
|
-
// convertUserMessage interception) but it depends on a race
|
|
262
|
-
// between the empty tool_result and `resolveUserAnswer` landing —
|
|
263
|
-
// not reliable enough for production use.
|
|
264
|
-
//
|
|
265
|
-
// TODO(qwen-sdk): re-enable AUQ once the upstream SDK forwards
|
|
266
|
-
// `updatedInput` from `canUseTool` into the tool execution
|
|
267
|
-
// payload. Verify by checking `handleOutgoingPermissionRequest`
|
|
268
|
-
// in the bundled CLI — when it stops calling
|
|
269
|
-
// `onConfirm(ProceedOnce)` without the payload (or starts
|
|
270
|
-
// passing the resolved `updatedInput`), drop this excludeTools
|
|
271
|
-
// entry. The AUQ flow code (canUseTool handler, converter
|
|
272
|
-
// state, resolveUserAnswer, recordUserAnswer) is intentionally
|
|
273
|
-
// kept in place so reverting is a one-line change.
|
|
274
|
-
// `canUseTool` (permissionMode 'default') only fires for WRITE tools,
|
|
275
|
-
// so read-only tools can't be blocked there. `excludeTools` has the
|
|
276
|
-
// highest permission priority, so denied/non-allowlisted built-ins are
|
|
277
|
-
// hidden from the model entirely. MCP tools are filtered at the bridge.
|
|
278
|
-
excludeTools: ['ask_user_question', ...excludedBuiltinTools(permissions, 'qwen')],
|
|
281
|
+
// `canUseTool` (permissionMode 'default') only fires for WRITE tools
|
|
282
|
+
// and `ask_user_question`, so read-only tools can't be blocked there.
|
|
283
|
+
// `excludeTools` has the highest permission priority, so
|
|
284
|
+
// denied/non-allowlisted built-ins are hidden from the model
|
|
285
|
+
// entirely. MCP tools are filtered at the bridge.
|
|
286
|
+
excludeTools: excludedBuiltinTools(permissions, 'qwen'),
|
|
279
287
|
canUseTool: async (toolName, input, ctx) => {
|
|
280
288
|
// Qwen SDK passes the registered (snake_case) tool name here —
|
|
281
289
|
// `ToolNames.ASK_USER_QUESTION = "ask_user_question"` — NOT the
|
|
@@ -322,17 +330,16 @@ export class QwenEngine implements AIEngine {
|
|
|
322
330
|
},
|
|
323
331
|
...(projectContext ? { systemPrompt: { type: 'preset' as const, preset: 'qwen_code' as const, append: projectContext } } : {}),
|
|
324
332
|
...(maxTurns !== undefined ? { maxSessionTurns: maxTurns } : {}),
|
|
325
|
-
...(
|
|
333
|
+
...(resume ? { resume, ...(forkOnResume ? { forkSession: true } : {}) } : {}),
|
|
334
|
+
...(effort ? { effort } : {}),
|
|
326
335
|
...(Object.keys(mcpConfig).length > 0 ? { mcpServers: mcpConfig } : {}),
|
|
327
336
|
};
|
|
328
337
|
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
yield sdkPrompt;
|
|
332
|
-
})();
|
|
338
|
+
const promptStream = openPromptStream(toSdkUserMessage(prompt), controller.signal);
|
|
339
|
+
endPrompt = promptStream.end;
|
|
333
340
|
|
|
334
341
|
const { query } = await loadEngineSdk<typeof import('@qwen-code/sdk')>('qwen', '@qwen-code/sdk');
|
|
335
|
-
const queryInstance = query({ prompt:
|
|
342
|
+
const queryInstance = query({ prompt: promptStream.iterable, options: sdkOptions });
|
|
336
343
|
run.query = queryInstance;
|
|
337
344
|
|
|
338
345
|
const converter = createSdkMessageConverter(modelId, {
|
|
@@ -348,12 +355,27 @@ export class QwenEngine implements AIEngine {
|
|
|
348
355
|
},
|
|
349
356
|
});
|
|
350
357
|
run.converter = converter;
|
|
358
|
+
// The CLI may decline the requested effort (thinking disabled for the
|
|
359
|
+
// model, or a higher-priority wire override); log it once so a
|
|
360
|
+
// selector that "does nothing" is explainable from the server log.
|
|
361
|
+
let effortChecked = !effort;
|
|
351
362
|
for await (const sdkMessage of queryInstance) {
|
|
363
|
+
if (!effortChecked) {
|
|
364
|
+
const status = queryInstance.getInitialEffortStatus();
|
|
365
|
+
if (status) {
|
|
366
|
+
effortChecked = true;
|
|
367
|
+
if (!status.applied) {
|
|
368
|
+
debug.warn('engine', `Qwen effort "${effort}" not applied for ${modelId}: ${status.reason ?? (status.override ? `overridden by ${status.override.source}.${status.override.field}` : 'thinking disabled')}`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (sdkMessage.type === 'result') endPrompt();
|
|
352
373
|
yield* converter.convert(sdkMessage);
|
|
353
374
|
}
|
|
354
375
|
} catch (error) {
|
|
355
376
|
handleStreamError(error, stderrLines.join('\n'));
|
|
356
377
|
} finally {
|
|
378
|
+
endPrompt();
|
|
357
379
|
// Retire THIS run only — another chat session of the same project may
|
|
358
380
|
// still be streaming on this instance.
|
|
359
381
|
this.runs.remove(run);
|
|
@@ -450,25 +472,23 @@ export class QwenEngine implements AIEngine {
|
|
|
450
472
|
maxSessionTurns: 1,
|
|
451
473
|
};
|
|
452
474
|
|
|
453
|
-
const
|
|
475
|
+
const promptStream = openPromptStream({
|
|
454
476
|
type: 'user',
|
|
455
477
|
uuid: crypto.randomUUID(),
|
|
456
478
|
session_id: '',
|
|
457
479
|
parent_tool_use_id: null,
|
|
458
480
|
message: { role: 'user', content: jsonPrompt },
|
|
459
|
-
};
|
|
460
|
-
const promptIterable = (async function* (): AsyncIterable<SDKUserMessage> {
|
|
461
|
-
yield sdkPrompt;
|
|
462
|
-
})();
|
|
481
|
+
}, controller.signal);
|
|
463
482
|
|
|
464
483
|
const { query } = await loadEngineSdk<typeof import('@qwen-code/sdk')>('qwen', '@qwen-code/sdk');
|
|
465
|
-
const queryInstance = query({ prompt:
|
|
484
|
+
const queryInstance = query({ prompt: promptStream.iterable, options: sdkOptions });
|
|
466
485
|
|
|
467
486
|
let resultText = '';
|
|
468
487
|
let errorMessage = '';
|
|
469
488
|
try {
|
|
470
489
|
for await (const message of queryInstance) {
|
|
471
490
|
if (message.type === 'result') {
|
|
491
|
+
promptStream.end();
|
|
472
492
|
if (message.subtype === 'success') {
|
|
473
493
|
resultText = message.result || '';
|
|
474
494
|
} else {
|
|
@@ -481,6 +501,8 @@ export class QwenEngine implements AIEngine {
|
|
|
481
501
|
throw new Error('Generation was cancelled');
|
|
482
502
|
}
|
|
483
503
|
throw error;
|
|
504
|
+
} finally {
|
|
505
|
+
promptStream.end();
|
|
484
506
|
}
|
|
485
507
|
|
|
486
508
|
if (!resultText) {
|
|
@@ -510,18 +532,19 @@ export class QwenEngine implements AIEngine {
|
|
|
510
532
|
return false;
|
|
511
533
|
}
|
|
512
534
|
|
|
513
|
-
// Push the answers into converter state FIRST so
|
|
514
|
-
//
|
|
515
|
-
//
|
|
516
|
-
//
|
|
517
|
-
//
|
|
518
|
-
// (empty). The converter intercepts that tool_result and replaces its
|
|
519
|
-
// content with the proper formatted answers we just stored.
|
|
535
|
+
// Push the answers into converter state FIRST so they are in place by
|
|
536
|
+
// the time the AUQ tool_result arrives. The CLI forwards `answers`
|
|
537
|
+
// from `updatedInput` to the tool, so the model sees the real answers;
|
|
538
|
+
// the converter only rewrites the tool_result into the cross-engine
|
|
539
|
+
// wording for the UI.
|
|
520
540
|
run.converter?.recordUserAnswer(toolUseId, answers);
|
|
521
541
|
|
|
542
|
+
// The frontend keys answers by question text; the CLI only reads
|
|
543
|
+
// question-index keys and drops the rest (see toQwenAnswers).
|
|
544
|
+
const questions = Array.isArray(pending.input['questions']) ? pending.input['questions'] as AskUserQuestion[] : [];
|
|
522
545
|
pending.resolve({
|
|
523
546
|
behavior: 'allow',
|
|
524
|
-
updatedInput: { ...pending.input, answers },
|
|
547
|
+
updatedInput: { ...pending.input, answers: toQwenAnswers(questions, answers) },
|
|
525
548
|
});
|
|
526
549
|
run.pendingAskUserQuestion = null;
|
|
527
550
|
return true;
|
|
@@ -239,12 +239,14 @@ Where each engine's knob lives:
|
|
|
239
239
|
|
|
240
240
|
| Engine | SDK knob | Levels |
|
|
241
241
|
|---------------|-----------------------------------------|--------------------------------------------|
|
|
242
|
-
| `claude-code` | `thinking` + `effort` on `query()` | `off, auto, low, medium, high, xhigh, max` (
|
|
243
|
-
| `codex` | `modelReasoningEffort` (thread option) |
|
|
242
|
+
| `claude-code` | `thinking` + `effort` on `query()` | per model from the static catalog, out of `off, auto, low, medium, high, xhigh, max` — no `off` where the model rejects disabled thinking, no `xhigh` before Opus 4.7, no effort tiers on Opus 4.5 (`resolveClaudeReasoning` gates the value; `off` → `thinking: { type: 'disabled' }`, `auto` → adaptive with no `effort`) |
|
|
243
|
+
| `codex` | `modelReasoningEffort` (thread option) | per model from the static catalog: `low…xhigh`, `low…max` or `low…ultra` (`resolveCodexEffort` gates the value) |
|
|
244
244
|
| `copilot` | `SessionConfig.reasoningEffort` | from `ModelInfo.supportedReasoningEfforts` (dynamic) |
|
|
245
245
|
| `pi` | agent `thinkingLevel` | from `getSupportedThinkingLevels(model)` (dynamic; `clampThinkingLevel` on apply) |
|
|
246
246
|
| `cursor` | `ModelSelection.params[]` | from the model's reasoning-ish `ModelParameterDefinition` (dynamic) |
|
|
247
|
-
| `qwen
|
|
247
|
+
| `qwen` | `effort` on `query()` | `low…xhigh` only when the `/models` entry lists `reasoning_effort` in `supported_parameters` (OpenRouter); hidden on DashScope/Fireworks |
|
|
248
|
+
| `cline` | `thinking` + `reasoningEffort` on `Agent` | per model from the catalog's `reasoningOptions` (dynamic): `off` (toggle or `none` effort), `auto`, the advertised `minimal…max` tiers, `on` for toggle-only; budget-only models get none (`resolveClineReasoning` gates the value) |
|
|
249
|
+
| `opencode` | — (none exposed) | no `reasoningControl` → selector hidden |
|
|
248
250
|
|
|
249
251
|
Cursor is the one engine whose token is **not** a bare level: it encodes the
|
|
250
252
|
model-parameter id as `"<paramId>::<value>"` so `stream.ts` can rebuild a
|
|
@@ -292,7 +294,8 @@ adapters/<name>/
|
|
|
292
294
|
├── server.ts? ← OPTIONAL subprocess + client lifecycle (opencode)
|
|
293
295
|
├── config.ts? ← OPTIONAL runtime config builder (opencode)
|
|
294
296
|
├── presets.ts? ← OPTIONAL multi-provider/region preset catalog (qwen, opencode)
|
|
295
|
-
|
|
297
|
+
├── session-store.ts? ← OPTIONAL on-disk session lookup for a native fork (qwen)
|
|
298
|
+
└── session-fork.ts? ← OPTIONAL on-disk session fork workaround (codex)
|
|
296
299
|
```
|
|
297
300
|
|
|
298
301
|
Naming rules — strict, even when an SDK's local jargon differs:
|