orquesta-cli 0.2.13 → 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.
- package/dist/orchestration/plan-executor.js +15 -1
- package/dist/tools/llm/simple/final-response-tool.d.ts +2 -0
- package/dist/tools/llm/simple/final-response-tool.js +18 -15
- package/dist/ui/TodoPanel.d.ts +1 -0
- package/dist/ui/TodoPanel.js +5 -5
- package/dist/ui/components/PlanExecuteApp.js +51 -1
- package/dist/ui/hooks/slashCommandProcessor.js +4 -0
- package/dist/utils/update-checker.d.ts +9 -0
- package/dist/utils/update-checker.js +65 -0
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { sessionManager } from '../core/session/session-manager.js';
|
|
|
3
3
|
import { CompactManager, contextTracker, buildCompactedMessages, } from '../core/compact/index.js';
|
|
4
4
|
import { configManager } from '../core/config/config-manager.js';
|
|
5
5
|
import { setTodoWriteCallback, clearTodoCallbacks, } from '../tools/llm/simple/todo-tools.js';
|
|
6
|
-
import { setGetTodosCallback, setFinalResponseCallback, clearFinalResponseCallbacks, } from '../tools/llm/simple/final-response-tool.js';
|
|
6
|
+
import { setGetTodosCallback, setFinalResponseCallback, setMarkTodosCompletedCallback, clearFinalResponseCallbacks, } from '../tools/llm/simple/final-response-tool.js';
|
|
7
7
|
import { setDocsSearchLLMClientGetter, clearDocsSearchLLMClientGetter, } from '../tools/llm/simple/docs-search-agent-tool.js';
|
|
8
8
|
import { emitPlanCreated, emitTodoStart, emitTodoComplete, emitTodoFail, emitCompact, emitAssistantResponse, } from '../tools/llm/simple/file-tools.js';
|
|
9
9
|
import { toolRegistry } from '../tools/registry.js';
|
|
@@ -419,6 +419,20 @@ export class PlanExecutor {
|
|
|
419
419
|
setFinalResponseCallback((message) => {
|
|
420
420
|
emitAssistantResponse(message);
|
|
421
421
|
});
|
|
422
|
+
setMarkTodosCompletedCallback(() => {
|
|
423
|
+
const completed = todosRef.map(t => t.status === 'completed' || t.status === 'failed'
|
|
424
|
+
? t
|
|
425
|
+
: { ...t, status: 'completed' });
|
|
426
|
+
for (const t of completed) {
|
|
427
|
+
const old = todosRef.find(o => o.id === t.id);
|
|
428
|
+
if (old && old.status !== 'completed' && old.status !== 'failed') {
|
|
429
|
+
emitTodoComplete(t.title);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
todosRef = completed;
|
|
433
|
+
updateLocalTodos(completed);
|
|
434
|
+
callbacks.setTodos([...completed]);
|
|
435
|
+
});
|
|
422
436
|
}
|
|
423
437
|
async maybeRunRefiner(llmClient, currentMessages, currentTodos, callbacks) {
|
|
424
438
|
if (!configManager.isRefinerEnabled())
|
|
@@ -3,6 +3,8 @@ import { ToolDefinition } from '../../../types/index.js';
|
|
|
3
3
|
import { TodoItem } from '../../../types/index.js';
|
|
4
4
|
export type GetTodosCallback = () => TodoItem[];
|
|
5
5
|
export type FinalResponseCallback = (message: string) => void;
|
|
6
|
+
export type MarkTodosCompletedCallback = () => void;
|
|
7
|
+
export declare function setMarkTodosCompletedCallback(callback: MarkTodosCompletedCallback): void;
|
|
6
8
|
export declare function setGetTodosCallback(callback: GetTodosCallback): void;
|
|
7
9
|
export declare function setFinalResponseCallback(callback: FinalResponseCallback): void;
|
|
8
10
|
export declare function clearFinalResponseCallbacks(): void;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { logger } from '../../../utils/logger.js';
|
|
2
2
|
let getTodosCallback = null;
|
|
3
3
|
let finalResponseCallback = null;
|
|
4
|
+
let markTodosCompletedCallback = null;
|
|
5
|
+
export function setMarkTodosCompletedCallback(callback) {
|
|
6
|
+
markTodosCompletedCallback = callback;
|
|
7
|
+
}
|
|
4
8
|
export function setGetTodosCallback(callback) {
|
|
5
9
|
logger.flow('Setting getTodos callback for final_response');
|
|
6
10
|
getTodosCallback = callback;
|
|
@@ -13,19 +17,13 @@ export function clearFinalResponseCallbacks() {
|
|
|
13
17
|
logger.flow('Clearing final response callbacks');
|
|
14
18
|
getTodosCallback = null;
|
|
15
19
|
finalResponseCallback = null;
|
|
20
|
+
markTodosCompletedCallback = null;
|
|
16
21
|
}
|
|
17
22
|
function areAllTodosCompleted(todos) {
|
|
18
23
|
if (todos.length === 0)
|
|
19
24
|
return true;
|
|
20
25
|
return todos.every(t => t.status === 'completed' || t.status === 'failed');
|
|
21
26
|
}
|
|
22
|
-
function getIncompleteTodosSummary(todos) {
|
|
23
|
-
const incomplete = todos.filter(t => t.status !== 'completed' && t.status !== 'failed');
|
|
24
|
-
if (incomplete.length === 0)
|
|
25
|
-
return '';
|
|
26
|
-
const list = incomplete.map(t => `- [${t.status}] ${t.title}`).join('\n');
|
|
27
|
-
return `Incomplete TODOs:\n${list}`;
|
|
28
|
-
}
|
|
29
27
|
const FINAL_RESPONSE_DEFINITION = {
|
|
30
28
|
type: 'function',
|
|
31
29
|
function: {
|
|
@@ -76,15 +74,20 @@ async function executeFinalResponse(args) {
|
|
|
76
74
|
}
|
|
77
75
|
const todos = getTodosCallback();
|
|
78
76
|
if (!areAllTodosCompleted(todos)) {
|
|
79
|
-
|
|
80
|
-
logger.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
logger.flow('final_response with incomplete TODOs — auto-completing remaining and delivering');
|
|
78
|
+
logger.debug('Auto-completed TODOs', { count: todos.filter(t => t.status !== 'completed' && t.status !== 'failed').length });
|
|
79
|
+
if (markTodosCompletedCallback) {
|
|
80
|
+
try {
|
|
81
|
+
markTodosCompletedCallback();
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
logger.warn(`markTodosCompleted failed: ${e}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
logger.flow('All TODOs completed - delivering final response');
|
|
86
90
|
}
|
|
87
|
-
logger.flow('All TODOs completed - delivering final response');
|
|
88
91
|
if (finalResponseCallback) {
|
|
89
92
|
finalResponseCallback(message);
|
|
90
93
|
}
|
package/dist/ui/TodoPanel.d.ts
CHANGED
package/dist/ui/TodoPanel.js
CHANGED
|
@@ -70,10 +70,10 @@ export const TodoPanel = React.memo(({ todos, currentTodoId, isProcessing = fals
|
|
|
70
70
|
const isCompleted = todo.status === 'completed';
|
|
71
71
|
return (React.createElement(Box, { key: todo.id, flexDirection: "column" },
|
|
72
72
|
React.createElement(Box, null,
|
|
73
|
-
React.createElement(Box, { width: 2 }, isInProgress ? (React.createElement(Text, { color: "blueBright" },
|
|
73
|
+
React.createElement(Box, { width: 2 }, isInProgress && isProcessing ? (React.createElement(Text, { color: "blueBright" },
|
|
74
74
|
React.createElement(Spinner, { type: "dots2" }))) : (React.createElement(Text, { color: config.color }, config.icon))),
|
|
75
75
|
React.createElement(Text, { color: isCompleted ? 'gray' : isInProgress ? 'white' : 'gray', bold: isInProgress, dimColor: isCompleted, strikethrough: isCompleted }, todo.title),
|
|
76
|
-
isInProgress && (React.createElement(Text, { color: "blueBright" }, " \u2190"))),
|
|
76
|
+
isInProgress && isProcessing && (React.createElement(Text, { color: "blueBright" }, " \u2190"))),
|
|
77
77
|
todo.error && (React.createElement(Box, { marginLeft: 2 },
|
|
78
78
|
React.createElement(Text, { color: "red", dimColor: true },
|
|
79
79
|
"\u26A0 ",
|
|
@@ -100,7 +100,7 @@ export const TodoPanel = React.memo(({ todos, currentTodoId, isProcessing = fals
|
|
|
100
100
|
}
|
|
101
101
|
return true;
|
|
102
102
|
});
|
|
103
|
-
export const TodoStatusBar = React.memo(({ todos, projectName, batutaUsage }) => {
|
|
103
|
+
export const TodoStatusBar = React.memo(({ todos, projectName, batutaUsage, isProcessing = false }) => {
|
|
104
104
|
useEffect(() => {
|
|
105
105
|
logger.debug('TodoStatusBar rendered', { todoCount: todos.length });
|
|
106
106
|
}, [todos.length]);
|
|
@@ -145,8 +145,8 @@ export const TodoStatusBar = React.memo(({ todos, projectName, batutaUsage }) =>
|
|
|
145
145
|
todos.length),
|
|
146
146
|
currentTodo && (React.createElement(React.Fragment, null,
|
|
147
147
|
React.createElement(Text, { color: "white" }, " \u2502 "),
|
|
148
|
-
React.createElement(Text, { color: "blueBright" },
|
|
149
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
148
|
+
isProcessing ? (React.createElement(Text, { color: "blueBright" },
|
|
149
|
+
React.createElement(Spinner, { type: "dots" }))) : (React.createElement(Text, { color: "gray" }, "\u2610")),
|
|
150
150
|
React.createElement(Text, { color: "white" },
|
|
151
151
|
" ",
|
|
152
152
|
currentTodo.title.slice(0, 30),
|
|
@@ -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 }, "> "),
|
|
@@ -1358,7 +1408,7 @@ export const PlanExecuteApp = ({ llmClient: initialLlmClient, modelInfo }) => {
|
|
|
1358
1408
|
React.createElement(Text, { color: "gray" }, shortenPath(process.cwd())),
|
|
1359
1409
|
(planExecutionState.todos.length > 0 || batutaUsage) && (React.createElement(React.Fragment, null,
|
|
1360
1410
|
React.createElement(Text, { color: "gray" }, " \u2502 "),
|
|
1361
|
-
React.createElement(TodoStatusBar, { todos: planExecutionState.todos, projectName: configManager.getOrquestaConfig()?.projectName, batutaUsage: batutaUsage })))),
|
|
1411
|
+
React.createElement(TodoStatusBar, { todos: planExecutionState.todos, projectName: configManager.getOrquestaConfig()?.projectName, batutaUsage: batutaUsage, isProcessing: isProcessing })))),
|
|
1362
1412
|
React.createElement(Text, { color: "gray", dimColor: true }, "Tab: mode \u2502 /help")))),
|
|
1363
1413
|
showLogFiles && (React.createElement(Box, { marginTop: 0 },
|
|
1364
1414
|
React.createElement(LogBrowser, { onClose: () => setShowLogFiles(false) })))));
|
|
@@ -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
|