tsunami-code 2.7.0 → 2.8.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/index.js +11 -2
- package/lib/loop.js +7 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import chalk from 'chalk';
|
|
|
4
4
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import os from 'os';
|
|
7
|
-
import { agentLoop, quickCompletion } from './lib/loop.js';
|
|
7
|
+
import { agentLoop, quickCompletion, setModel, getModel } from './lib/loop.js';
|
|
8
8
|
import { buildSystemPrompt } from './lib/prompt.js';
|
|
9
9
|
import { runPreflight, checkServer } from './lib/preflight.js';
|
|
10
10
|
import { setSession, undo, undoStackSize } from './lib/tools.js';
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
getSessionContext
|
|
21
21
|
} from './lib/memory.js';
|
|
22
22
|
|
|
23
|
-
const VERSION = '2.
|
|
23
|
+
const VERSION = '2.8.0';
|
|
24
24
|
const CONFIG_DIR = join(os.homedir(), '.tsunami-code');
|
|
25
25
|
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
26
26
|
const DEFAULT_SERVER = 'https://radiometric-reita-amuck.ngrok-free.dev';
|
|
@@ -369,6 +369,7 @@ async function run() {
|
|
|
369
369
|
['/clear', 'Start new conversation'],
|
|
370
370
|
['/status', 'Show context size and server'],
|
|
371
371
|
['/server <url>', 'Change model server URL'],
|
|
372
|
+
['/model [name]', 'Show or change active model (default: local)'],
|
|
372
373
|
['/exit', 'Exit'],
|
|
373
374
|
];
|
|
374
375
|
for (const [c, desc] of cmds) {
|
|
@@ -437,6 +438,14 @@ async function run() {
|
|
|
437
438
|
console.log(dim(` Current server: ${currentServerUrl}\n`));
|
|
438
439
|
}
|
|
439
440
|
break;
|
|
441
|
+
case 'model':
|
|
442
|
+
if (rest[0]) {
|
|
443
|
+
setModel(rest[0]);
|
|
444
|
+
console.log(green(` Model changed to: ${rest[0]}\n`));
|
|
445
|
+
} else {
|
|
446
|
+
console.log(dim(` Current model: ${getModel()}\n`));
|
|
447
|
+
}
|
|
448
|
+
break;
|
|
440
449
|
case 'memory':
|
|
441
450
|
await handleMemoryCommand(rest);
|
|
442
451
|
break;
|
package/lib/loop.js
CHANGED
|
@@ -29,6 +29,11 @@ function isDangerous(cmd) {
|
|
|
29
29
|
// Skip waitForServer after first successful connection
|
|
30
30
|
let _serverVerified = false;
|
|
31
31
|
|
|
32
|
+
// Current model identifier — changeable at runtime via /model command
|
|
33
|
+
let _currentModel = 'local';
|
|
34
|
+
export function setModel(model) { _currentModel = model; }
|
|
35
|
+
export function getModel() { return _currentModel; }
|
|
36
|
+
|
|
32
37
|
// Parse tool calls from any format the model might produce
|
|
33
38
|
function parseToolCalls(content) {
|
|
34
39
|
const calls = [];
|
|
@@ -199,7 +204,7 @@ async function streamCompletion(serverUrl, messages, onToken, memoryContext = ''
|
|
|
199
204
|
method: 'POST',
|
|
200
205
|
headers: { 'Content-Type': 'application/json' },
|
|
201
206
|
body: JSON.stringify({
|
|
202
|
-
model:
|
|
207
|
+
model: _currentModel,
|
|
203
208
|
messages: finalMessages,
|
|
204
209
|
stream: true,
|
|
205
210
|
temperature: 0.1,
|
|
@@ -254,7 +259,7 @@ export async function quickCompletion(serverUrl, systemPrompt, userMessage) {
|
|
|
254
259
|
signal: controller.signal,
|
|
255
260
|
headers: { 'Content-Type': 'application/json' },
|
|
256
261
|
body: JSON.stringify({
|
|
257
|
-
model:
|
|
262
|
+
model: _currentModel,
|
|
258
263
|
messages: [
|
|
259
264
|
{ role: 'system', content: systemPrompt },
|
|
260
265
|
{ role: 'user', content: userMessage }
|