orquesta-cli 0.2.14 → 0.2.15
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.
|
@@ -36,6 +36,8 @@ import { closeJsonStreamLogger } from '../../utils/json-stream-logger.js';
|
|
|
36
36
|
import { configManager } from '../../core/config/config-manager.js';
|
|
37
37
|
import { logger } from '../../utils/logger.js';
|
|
38
38
|
import { usageTracker } from '../../core/usage-tracker.js';
|
|
39
|
+
import { UpdateNotification } from '../UpdateNotification.js';
|
|
40
|
+
import { checkForCliUpdate, runCliUpdate } from '../../utils/update-checker.js';
|
|
39
41
|
import { setToolExecutionCallback, setTellToUserCallback, setToolResponseCallback, setPlanCreatedCallback, setTodoStartCallback, setTodoCompleteCallback, setTodoFailCallback, setCompactCallback, setAssistantResponseCallback, setToolApprovalCallback, setReasoningCallback, } from '../../tools/llm/simple/file-tools.js';
|
|
40
42
|
import { createRequire } from 'module';
|
|
41
43
|
const require = createRequire(import.meta.url);
|
|
@@ -89,6 +91,10 @@ export const PlanExecuteApp = ({ llmClient: initialLlmClient, modelInfo }) => {
|
|
|
89
91
|
const [messages, setMessages] = useState([]);
|
|
90
92
|
const { input, setInput, handleHistoryPrev, handleHistoryNext, addToHistory } = useInputHistory();
|
|
91
93
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
94
|
+
const [updatePhase, setUpdatePhase] = useState('hidden');
|
|
95
|
+
const [updateLatest, setUpdateLatest] = useState('');
|
|
96
|
+
const [updateProgress, setUpdateProgress] = useState('');
|
|
97
|
+
const [updateError, setUpdateError] = useState('');
|
|
92
98
|
const planningMode = 'auto';
|
|
93
99
|
const [llmClient, setLlmClient] = useState(initialLlmClient);
|
|
94
100
|
const [activityType, setActivityType] = useState('thinking');
|
|
@@ -172,6 +178,16 @@ export const PlanExecuteApp = ({ llmClient: initialLlmClient, modelInfo }) => {
|
|
|
172
178
|
logger.exit('PlanExecuteApp', { messageCount: messages.length });
|
|
173
179
|
};
|
|
174
180
|
}, []);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
let cancelled = false;
|
|
183
|
+
checkForCliUpdate(VERSION).then(info => {
|
|
184
|
+
if (!cancelled && info) {
|
|
185
|
+
setUpdateLatest(info.latest);
|
|
186
|
+
setUpdatePhase('available');
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
return () => { cancelled = true; };
|
|
190
|
+
}, []);
|
|
175
191
|
useEffect(() => {
|
|
176
192
|
setToolExecutionCallback((toolName, reason, args) => {
|
|
177
193
|
lastToolArgsRef.current = args;
|
|
@@ -488,6 +504,32 @@ export const PlanExecuteApp = ({ llmClient: initialLlmClient, modelInfo }) => {
|
|
|
488
504
|
logger.debug('Ctrl+C pressed - waiting for double-tap to exit');
|
|
489
505
|
return;
|
|
490
506
|
}
|
|
507
|
+
if (updatePhase === 'available' && !isProcessing && input.trim() === '') {
|
|
508
|
+
if (inputChar === 'y' || inputChar === 'Y') {
|
|
509
|
+
setUpdateError('');
|
|
510
|
+
setUpdateProgress('');
|
|
511
|
+
setUpdatePhase('updating');
|
|
512
|
+
runCliUpdate(updateLatest, (line) => setUpdateProgress(line.slice(0, 100)))
|
|
513
|
+
.then(res => {
|
|
514
|
+
if (res.success) {
|
|
515
|
+
setUpdatePhase('done');
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
setUpdateError(res.error || 'Update failed');
|
|
519
|
+
setUpdatePhase('error');
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (key.escape || inputChar === 'n' || inputChar === 'N' || inputChar === 's' || inputChar === 'S') {
|
|
525
|
+
setUpdatePhase('hidden');
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if ((updatePhase === 'done' || updatePhase === 'error') && key.escape) {
|
|
530
|
+
setUpdatePhase('hidden');
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
491
533
|
if (key.escape && (isProcessing || planExecutionState.isInterrupted)) {
|
|
492
534
|
logger.flow('ESC pressed');
|
|
493
535
|
if (llmClient) {
|
|
@@ -1260,6 +1302,14 @@ export const PlanExecuteApp = ({ llmClient: initialLlmClient, modelInfo }) => {
|
|
|
1260
1302
|
isDocsSearching && (React.createElement(DocsSearchProgress, { logs: docsSearchLogs, isSearching: isDocsSearching })),
|
|
1261
1303
|
planExecutionState.todos.length > 0 && (React.createElement(Box, { marginTop: 2, marginBottom: 1 },
|
|
1262
1304
|
React.createElement(TodoPanel, { todos: planExecutionState.todos, currentTodoId: planExecutionState.currentTodoId, isProcessing: isProcessing }))),
|
|
1305
|
+
updatePhase === 'available' && (React.createElement(UpdateNotification, { currentVersion: VERSION, latestVersion: updateLatest })),
|
|
1306
|
+
updatePhase === 'updating' && (React.createElement(UpdateNotification, { currentVersion: VERSION, latestVersion: updateLatest, isUpdating: true, updateProgress: updateProgress })),
|
|
1307
|
+
updatePhase === 'error' && (React.createElement(UpdateNotification, { currentVersion: VERSION, latestVersion: updateLatest, error: updateError })),
|
|
1308
|
+
updatePhase === 'done' && (React.createElement(Box, { borderStyle: "round", borderColor: "green", paddingX: 1, marginY: 1, flexDirection: "column" },
|
|
1309
|
+
React.createElement(Text, { color: "green", bold: true },
|
|
1310
|
+
"\u2705 Updated to orquesta-cli v",
|
|
1311
|
+
updateLatest),
|
|
1312
|
+
React.createElement(Text, { color: "gray" }, "Restart orquesta to use the new version. (Esc to dismiss)"))),
|
|
1263
1313
|
React.createElement(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1, flexDirection: "column" },
|
|
1264
1314
|
React.createElement(Box, null,
|
|
1265
1315
|
React.createElement(Text, { color: "green", bold: true }, "> "),
|
|
@@ -20,6 +20,10 @@ export const SLASH_COMMANDS = [
|
|
|
20
20
|
name: '/model',
|
|
21
21
|
description: 'Switch between LLM models',
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
name: '/route',
|
|
25
|
+
description: 'Pin Batuta Auto tier: auto | fast | balanced | premium',
|
|
26
|
+
},
|
|
23
27
|
{
|
|
24
28
|
name: '/sync',
|
|
25
29
|
description: 'Sync LLM configs with Orquesta dashboard',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function checkForCliUpdate(currentVersion: string, timeoutMs?: number): Promise<{
|
|
2
|
+
current: string;
|
|
3
|
+
latest: string;
|
|
4
|
+
} | null>;
|
|
5
|
+
export declare function runCliUpdate(version: string, onProgress?: (line: string) => void): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=update-checker.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { logger } from './logger.js';
|
|
3
|
+
const REGISTRY_URL = 'https://registry.npmjs.org/orquesta-cli/latest';
|
|
4
|
+
function isNewer(a, b) {
|
|
5
|
+
const pa = a.split('.').map(n => parseInt(n, 10) || 0);
|
|
6
|
+
const pb = b.split('.').map(n => parseInt(n, 10) || 0);
|
|
7
|
+
for (let i = 0; i < 3; i++) {
|
|
8
|
+
if ((pa[i] || 0) > (pb[i] || 0))
|
|
9
|
+
return true;
|
|
10
|
+
if ((pa[i] || 0) < (pb[i] || 0))
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
export async function checkForCliUpdate(currentVersion, timeoutMs = 3500) {
|
|
16
|
+
try {
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
19
|
+
const res = await fetch(REGISTRY_URL, {
|
|
20
|
+
signal: controller.signal,
|
|
21
|
+
headers: { Accept: 'application/json' },
|
|
22
|
+
});
|
|
23
|
+
clearTimeout(timer);
|
|
24
|
+
if (!res.ok)
|
|
25
|
+
return null;
|
|
26
|
+
const json = (await res.json());
|
|
27
|
+
const latest = json?.version;
|
|
28
|
+
if (!latest || !isNewer(latest, currentVersion))
|
|
29
|
+
return null;
|
|
30
|
+
logger.debug?.('CLI update available', { current: currentVersion, latest });
|
|
31
|
+
return { current: currentVersion, latest };
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export async function runCliUpdate(version, onProgress) {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
const child = spawn('npm', ['install', '-g', `orquesta-cli@${version}`], {
|
|
40
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
41
|
+
});
|
|
42
|
+
let err = '';
|
|
43
|
+
child.stdout?.on('data', (d) => onProgress?.(d.toString().trim()));
|
|
44
|
+
child.stderr?.on('data', (d) => {
|
|
45
|
+
err += d.toString();
|
|
46
|
+
onProgress?.(d.toString().trim());
|
|
47
|
+
});
|
|
48
|
+
child.on('close', (code) => {
|
|
49
|
+
if (code === 0) {
|
|
50
|
+
resolve({ success: true });
|
|
51
|
+
}
|
|
52
|
+
else if (/EACCES|permission denied|not permitted|EPERM/i.test(err)) {
|
|
53
|
+
resolve({
|
|
54
|
+
success: false,
|
|
55
|
+
error: `Permission denied. Run manually: sudo npm install -g orquesta-cli@latest`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
resolve({ success: false, error: err.slice(-300).trim() || `npm exited with code ${code}` });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
child.on('error', (e) => resolve({ success: false, error: e.message }));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=update-checker.js.map
|