edge-pi-cli 0.1.2 → 0.1.3
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/main.d.ts.map +1 -1
- package/dist/main.js +4 -15
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +11 -42
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/print-mode.d.ts +2 -2
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +2 -8
- package/dist/modes/print-mode.js.map +1 -1
- package/package.json +6 -2
|
@@ -139,7 +139,7 @@ class InteractiveMode {
|
|
|
139
139
|
// UI Setup
|
|
140
140
|
// ========================================================================
|
|
141
141
|
initUI() {
|
|
142
|
-
const { provider, modelId, skills = [], contextFiles = [], prompts = [], verbose
|
|
142
|
+
const { provider, modelId, skills = [], contextFiles = [], prompts = [], verbose } = this.options;
|
|
143
143
|
this.ui = new TUI(new ProcessTerminal());
|
|
144
144
|
// Header
|
|
145
145
|
this.headerContainer = new Container();
|
|
@@ -159,8 +159,8 @@ class InteractiveMode {
|
|
|
159
159
|
this.headerContainer.addChild(new Spacer(1));
|
|
160
160
|
this.headerContainer.addChild(new Text(`${logo}\n${hints}`, 1, 0));
|
|
161
161
|
this.headerContainer.addChild(new Spacer(1));
|
|
162
|
-
if (verbose && sessionManager?.getSessionFile()) {
|
|
163
|
-
this.headerContainer.addChild(new Text(chalk.dim(`Session: ${sessionManager.getSessionFile()}`), 1, 0));
|
|
162
|
+
if (verbose && this.agent.sessionManager?.getSessionFile()) {
|
|
163
|
+
this.headerContainer.addChild(new Text(chalk.dim(`Session: ${this.agent.sessionManager.getSessionFile()}`), 1, 0));
|
|
164
164
|
}
|
|
165
165
|
// Show loaded context, skills, and prompts at startup
|
|
166
166
|
this.showLoadedResources(contextFiles, skills, prompts);
|
|
@@ -372,7 +372,6 @@ class InteractiveMode {
|
|
|
372
372
|
await this.streamPrompt(expanded, images);
|
|
373
373
|
}
|
|
374
374
|
async handleBashCommand(command, excludeFromContext) {
|
|
375
|
-
const { sessionManager } = this.options;
|
|
376
375
|
this.bashAbortController = new AbortController();
|
|
377
376
|
this.isBashRunning = true;
|
|
378
377
|
this.bashComponent = new BashExecutionComponent(command, this.ui, excludeFromContext);
|
|
@@ -395,7 +394,7 @@ class InteractiveMode {
|
|
|
395
394
|
const msgText = `Ran \`${command}\`\n\n\`\`\`\n${result.output.trimEnd()}\n\`\`\``;
|
|
396
395
|
const userMsg = { role: "user", content: [{ type: "text", text: msgText }] };
|
|
397
396
|
this.agent.setMessages([...this.agent.messages, userMsg]);
|
|
398
|
-
sessionManager?.appendMessage(userMsg);
|
|
397
|
+
this.agent.sessionManager?.appendMessage(userMsg);
|
|
399
398
|
}
|
|
400
399
|
}
|
|
401
400
|
finally {
|
|
@@ -490,8 +489,6 @@ class InteractiveMode {
|
|
|
490
489
|
async streamPrompt(prompt, images) {
|
|
491
490
|
this.isStreaming = true;
|
|
492
491
|
this.updatePendingMessagesDisplay();
|
|
493
|
-
const { sessionManager } = this.options;
|
|
494
|
-
const messagesBefore = this.agent.messages.length;
|
|
495
492
|
// Build image parts from clipboard images
|
|
496
493
|
const imageParts = (images ?? []).map((img) => ({
|
|
497
494
|
type: "image",
|
|
@@ -573,25 +570,8 @@ class InteractiveMode {
|
|
|
573
570
|
}
|
|
574
571
|
if (errorDisplayed)
|
|
575
572
|
return;
|
|
576
|
-
//
|
|
577
|
-
|
|
578
|
-
const responseMessages = response.messages;
|
|
579
|
-
this.agent.setMessages([
|
|
580
|
-
...this.agent.messages.slice(0, messagesBefore),
|
|
581
|
-
...buildUserMessage(prompt, imageParts),
|
|
582
|
-
...responseMessages,
|
|
583
|
-
]);
|
|
584
|
-
// Save to session
|
|
585
|
-
if (sessionManager) {
|
|
586
|
-
const userMsg = {
|
|
587
|
-
role: "user",
|
|
588
|
-
content: [{ type: "text", text: prompt }, ...imageParts],
|
|
589
|
-
};
|
|
590
|
-
sessionManager.appendMessage(userMsg);
|
|
591
|
-
for (const msg of responseMessages) {
|
|
592
|
-
sessionManager.appendMessage(msg);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
573
|
+
// Wait for stream to complete — the agent auto-updates messages and persists to session
|
|
574
|
+
await result.response;
|
|
595
575
|
// Update footer token stats
|
|
596
576
|
this.updateFooterTokens();
|
|
597
577
|
// Check for auto-compaction after successful response
|
|
@@ -771,7 +751,7 @@ class InteractiveMode {
|
|
|
771
751
|
async executeCompaction(isAuto) {
|
|
772
752
|
if (this.isCompacting)
|
|
773
753
|
return undefined;
|
|
774
|
-
const
|
|
754
|
+
const sessionManager = this.agent.sessionManager;
|
|
775
755
|
// Build path entries from session if available, otherwise from agent messages
|
|
776
756
|
const pathEntries = sessionManager ? sessionManager.getBranch() : this.buildSessionEntriesFromMessages();
|
|
777
757
|
if (pathEntries.length < 2) {
|
|
@@ -1196,7 +1176,7 @@ class InteractiveMode {
|
|
|
1196
1176
|
const sessions = [];
|
|
1197
1177
|
for (const file of files) {
|
|
1198
1178
|
// Skip the current session file
|
|
1199
|
-
if (this.
|
|
1179
|
+
if (this.agent.sessionManager?.getSessionFile() === file.path)
|
|
1200
1180
|
continue;
|
|
1201
1181
|
const preview = this.getSessionPreview(file.path);
|
|
1202
1182
|
const timestamp = new Date(file.mtime).toLocaleString();
|
|
@@ -1292,20 +1272,16 @@ class InteractiveMode {
|
|
|
1292
1272
|
if (!session)
|
|
1293
1273
|
return;
|
|
1294
1274
|
try {
|
|
1295
|
-
// Open the selected session
|
|
1275
|
+
// Open the selected session and set on agent (auto-restores messages)
|
|
1296
1276
|
const sessionDir = this.options.sessionDir;
|
|
1297
1277
|
const newSessionManager = SessionManagerClass.open(selected, sessionDir);
|
|
1298
|
-
|
|
1299
|
-
const context = newSessionManager.buildSessionContext();
|
|
1300
|
-
this.agent.setMessages(context.messages);
|
|
1301
|
-
// Update session manager reference
|
|
1302
|
-
this.options.sessionManager = newSessionManager;
|
|
1278
|
+
this.agent.sessionManager = newSessionManager;
|
|
1303
1279
|
// Rebuild the chat UI
|
|
1304
1280
|
this.chatContainer.clear();
|
|
1305
1281
|
this.rebuildChatFromSession();
|
|
1306
1282
|
// Update footer tokens
|
|
1307
1283
|
this.updateFooterTokens();
|
|
1308
|
-
const msgCount =
|
|
1284
|
+
const msgCount = this.agent.messages.length;
|
|
1309
1285
|
this.showStatus(chalk.green(`Resumed session (${msgCount} messages)`));
|
|
1310
1286
|
}
|
|
1311
1287
|
catch (error) {
|
|
@@ -1369,13 +1345,6 @@ class InteractiveMode {
|
|
|
1369
1345
|
// ============================================================================
|
|
1370
1346
|
// Helpers
|
|
1371
1347
|
// ============================================================================
|
|
1372
|
-
function buildUserMessage(text, imageParts) {
|
|
1373
|
-
const content = [{ type: "text", text }];
|
|
1374
|
-
if (imageParts && imageParts.length > 0) {
|
|
1375
|
-
content.push(...imageParts);
|
|
1376
|
-
}
|
|
1377
|
-
return [{ role: "user", content }];
|
|
1378
|
-
}
|
|
1379
1348
|
function extractTextFromMessage(msg) {
|
|
1380
1349
|
if (msg.role === "user") {
|
|
1381
1350
|
const content = msg.content;
|