@visorcraft/idlehands 2.3.5 → 3.0.0
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/dist/agent.js +42 -1
- package/dist/agent.js.map +1 -1
- package/dist/bot/runtime-model-picker.js +4 -0
- package/dist/bot/runtime-model-picker.js.map +1 -1
- package/dist/client.js +15 -0
- package/dist/client.js.map +1 -1
- package/dist/runtime/store.js +10 -0
- package/dist/runtime/store.js.map +1 -1
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -1289,6 +1289,7 @@ export async function createSession(opts) {
|
|
|
1289
1289
|
let runtimeRoutingModules = null;
|
|
1290
1290
|
let runtimeRoutingUnavailable = false;
|
|
1291
1291
|
let runtimeModelIdsCache = null;
|
|
1292
|
+
let runtimeModelThinkingModeCache = null;
|
|
1292
1293
|
const loadRuntimeRoutingModules = async () => {
|
|
1293
1294
|
if (runtimeRoutingUnavailable)
|
|
1294
1295
|
return null;
|
|
@@ -1319,10 +1320,14 @@ export async function createSession(opts) {
|
|
|
1319
1320
|
try {
|
|
1320
1321
|
const runtimes = await mods.store.loadRuntimes();
|
|
1321
1322
|
runtimeModelIdsCache = new Set(runtimes.models.filter((m) => m.enabled !== false).map((m) => m.id));
|
|
1323
|
+
runtimeModelThinkingModeCache = new Map(runtimes.models
|
|
1324
|
+
.filter((m) => m.enabled !== false)
|
|
1325
|
+
.map((m) => [m.id, m.thinking_mode]));
|
|
1322
1326
|
return runtimeModelIdsCache;
|
|
1323
1327
|
}
|
|
1324
1328
|
catch {
|
|
1325
1329
|
runtimeModelIdsCache = new Set();
|
|
1330
|
+
runtimeModelThinkingModeCache = new Map();
|
|
1326
1331
|
return runtimeModelIdsCache;
|
|
1327
1332
|
}
|
|
1328
1333
|
};
|
|
@@ -1332,6 +1337,9 @@ export async function createSession(opts) {
|
|
|
1332
1337
|
throw new Error('Runtime routing is unavailable in this build/environment');
|
|
1333
1338
|
const runtimes = await mods.store.loadRuntimes();
|
|
1334
1339
|
runtimeModelIdsCache = new Set(runtimes.models.filter((m) => m.enabled !== false).map((m) => m.id));
|
|
1340
|
+
runtimeModelThinkingModeCache = new Map(runtimes.models
|
|
1341
|
+
.filter((m) => m.enabled !== false)
|
|
1342
|
+
.map((m) => [m.id, m.thinking_mode]));
|
|
1335
1343
|
const modelExists = runtimes.models.some((m) => m.enabled !== false && m.id === runtimeModelId);
|
|
1336
1344
|
if (!modelExists) {
|
|
1337
1345
|
throw new Error(`Runtime model not found or disabled: ${runtimeModelId}`);
|
|
@@ -1366,6 +1374,35 @@ export async function createSession(opts) {
|
|
|
1366
1374
|
const wireCaptureHook = () => {
|
|
1367
1375
|
attachCaptureHook(client);
|
|
1368
1376
|
};
|
|
1377
|
+
const getRuntimeModelThinkingMode = async (runtimeModelId) => {
|
|
1378
|
+
if (!runtimeModelThinkingModeCache) {
|
|
1379
|
+
await loadRuntimeModelIds();
|
|
1380
|
+
}
|
|
1381
|
+
return runtimeModelThinkingModeCache?.get(runtimeModelId);
|
|
1382
|
+
};
|
|
1383
|
+
const applyThinkingDirectiveToMessages = (input, mode) => {
|
|
1384
|
+
if (!mode || mode === 'default')
|
|
1385
|
+
return input;
|
|
1386
|
+
const directive = mode === 'no_think' ? '/no_think' : '/think';
|
|
1387
|
+
let lastUserIdx = -1;
|
|
1388
|
+
for (let i = input.length - 1; i >= 0; i--) {
|
|
1389
|
+
if (input[i]?.role === 'user') {
|
|
1390
|
+
lastUserIdx = i;
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
if (lastUserIdx < 0)
|
|
1395
|
+
return input;
|
|
1396
|
+
const target = input[lastUserIdx];
|
|
1397
|
+
if (!target || typeof target.content !== 'string')
|
|
1398
|
+
return input;
|
|
1399
|
+
const text = String(target.content);
|
|
1400
|
+
if (text.startsWith('/no_think') || text.startsWith('/think'))
|
|
1401
|
+
return input;
|
|
1402
|
+
const cloned = input.slice();
|
|
1403
|
+
cloned[lastUserIdx] = { ...target, content: `${directive}\n${text}` };
|
|
1404
|
+
return cloned;
|
|
1405
|
+
};
|
|
1369
1406
|
wireCaptureHook();
|
|
1370
1407
|
const replayEnabled = cfg.trifecta?.enabled !== false && cfg.trifecta?.replay?.enabled !== false;
|
|
1371
1408
|
const replay = replayEnabled ? (opts.runtime?.replay ?? new ReplayStore()) : undefined;
|
|
@@ -2476,8 +2513,12 @@ export async function createSession(opts) {
|
|
|
2476
2513
|
}
|
|
2477
2514
|
}
|
|
2478
2515
|
if (!resp) {
|
|
2516
|
+
const runtimeThinkingMode = primaryUsesRuntimeModel && primaryRoute?.model
|
|
2517
|
+
? await getRuntimeModelThinkingMode(primaryRoute.model)
|
|
2518
|
+
: undefined;
|
|
2519
|
+
const effectiveMessages = applyThinkingDirectiveToMessages(messages, runtimeThinkingMode);
|
|
2479
2520
|
const chatOptsBase = {
|
|
2480
|
-
messages,
|
|
2521
|
+
messages: effectiveMessages,
|
|
2481
2522
|
tools: toolsForTurn,
|
|
2482
2523
|
tool_choice: toolChoiceForTurn,
|
|
2483
2524
|
temperature,
|