@causyne/agent 1.20.107 → 1.20.111
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/package.json +2 -2
- package/src/agentLoop.js +5 -0
- package/src/agentLoop.ts +5 -0
- package/src/tui/chatRenderer.js +15 -1
- package/src/tui/prompt.js +92 -22
- package/src/tui/stage.js +15 -0
- package/src/tui/stage.ts +15 -0
- package/src/tui/stageSurface.js +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@causyne/agent",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.111",
|
|
4
4
|
"description": "Agentic AI for software, tools, and computer workflows",
|
|
5
5
|
"main": "bin/causyne.js",
|
|
6
6
|
"type": "module",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"zod": "4.6.7"
|
|
69
69
|
},
|
|
70
70
|
"overrides": {
|
|
71
|
-
"@hono/node-server": "^2.1.
|
|
71
|
+
"@hono/node-server": "^2.1.8"
|
|
72
72
|
},
|
|
73
73
|
"private": false
|
|
74
74
|
}
|
package/src/agentLoop.js
CHANGED
|
@@ -3052,6 +3052,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3052
3052
|
// some providers, so a terminal turn always carries something.
|
|
3053
3053
|
content: hasToolCalls ? '' : (response.content || 'No final response was provided.')
|
|
3054
3054
|
};
|
|
3055
|
+
if (!hasToolCalls && !String(response.content || '').trim()) {
|
|
3056
|
+
// Protocol-only placeholder: never present as a real assistant answer.
|
|
3057
|
+
// Some peers reject empty assistant turns during history continuation.
|
|
3058
|
+
assistantMsg.causyne_synthetic_no_final = true;
|
|
3059
|
+
}
|
|
3055
3060
|
if (hasToolCalls) {
|
|
3056
3061
|
assistantMsg.tool_calls = response.toolCalls;
|
|
3057
3062
|
}
|
package/src/agentLoop.ts
CHANGED
|
@@ -3166,6 +3166,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3166
3166
|
// some providers, so a terminal turn always carries something.
|
|
3167
3167
|
content: hasToolCalls ? '' : (response.content || 'No final response was provided.')
|
|
3168
3168
|
};
|
|
3169
|
+
if (!hasToolCalls && !String(response.content || '').trim()) {
|
|
3170
|
+
// Protocol-only placeholder: never present as a real assistant answer.
|
|
3171
|
+
// Some peers reject empty assistant turns during history continuation.
|
|
3172
|
+
assistantMsg.causyne_synthetic_no_final = true;
|
|
3173
|
+
}
|
|
3169
3174
|
if (hasToolCalls) {
|
|
3170
3175
|
assistantMsg.tool_calls = response.toolCalls;
|
|
3171
3176
|
}
|
package/src/tui/chatRenderer.js
CHANGED
|
@@ -744,7 +744,21 @@ export class ChatRenderer {
|
|
|
744
744
|
: (Array.isArray(msg.content)
|
|
745
745
|
? msg.content.map(p => (typeof p === 'string' ? p : (p && p.text) || '')).filter(Boolean).join('\n')
|
|
746
746
|
: String(msg.content || ''));
|
|
747
|
-
|
|
747
|
+
// The agent loop stores a protocol placeholder when a peer emits no
|
|
748
|
+
// final reply. Restoring it as a Causyne message falsely implies an
|
|
749
|
+
// answer was given. Older histories have the literal but no marker.
|
|
750
|
+
const syntheticNoFinal = msg.causyne_synthetic_no_final === true
|
|
751
|
+
|| (text.trim() === 'No final response was provided.'
|
|
752
|
+
&& (!Array.isArray(msg.tool_calls) || msg.tool_calls.length === 0));
|
|
753
|
+
if (syntheticNoFinal) {
|
|
754
|
+
const isLatestTurn = !messages.slice(i + 1).some(next =>
|
|
755
|
+
next && (next.role === 'assistant' || next.role === 'user'));
|
|
756
|
+
if (isLatestTurn) {
|
|
757
|
+
this.frame('notice', () => {
|
|
758
|
+
this.write(`${paint('warn', GLYPHS.warnMark)} ${dim('Provider returned no final answer; task completion is unverified.')}`);
|
|
759
|
+
}, { syntheticNoFinal: true });
|
|
760
|
+
}
|
|
761
|
+
} else if (text.trim()) {
|
|
748
762
|
this.renderAssistantMessage(text);
|
|
749
763
|
}
|
|
750
764
|
} else if (role === 'tool') {
|
package/src/tui/prompt.js
CHANGED
|
@@ -172,6 +172,9 @@ export class ChatPrompt {
|
|
|
172
172
|
this.layer = null;
|
|
173
173
|
this.queue = [];
|
|
174
174
|
this.waiter = null;
|
|
175
|
+
// Each submission owns its attachments; later pasted images must not leak
|
|
176
|
+
// into a turn which was already sent.
|
|
177
|
+
this.currentSubmissionAttachments = null;
|
|
175
178
|
this.completion = null;
|
|
176
179
|
this.selected = 0;
|
|
177
180
|
this.lastCtrlC = 0;
|
|
@@ -401,7 +404,7 @@ export class ChatPrompt {
|
|
|
401
404
|
renderer.onPlanChange = (plan) => {
|
|
402
405
|
if (this.surface) this.surface.sidebarPlan = plan;
|
|
403
406
|
this.scheduleDraw();
|
|
404
|
-
return this.surface && sidebarVisible(this.surface.width) ? 'sidebar' : undefined;
|
|
407
|
+
return this.surface && sidebarVisible(this.surface.width, false, this.surface.env) ? 'sidebar' : undefined;
|
|
405
408
|
};
|
|
406
409
|
}
|
|
407
410
|
|
|
@@ -470,7 +473,7 @@ export class ChatPrompt {
|
|
|
470
473
|
|
|
471
474
|
/** Persistent checklist shown outside the chat transcript. */
|
|
472
475
|
planRows(width) {
|
|
473
|
-
if (this.surface && sidebarVisible(this.surface.width)) return [];
|
|
476
|
+
if (this.surface && sidebarVisible(this.surface.width, false, this.surface.env)) return [];
|
|
474
477
|
const plan = this.renderer && Array.isArray(this.renderer.latestPlan) ? this.renderer.latestPlan : [];
|
|
475
478
|
if (plan.length === 0) return [];
|
|
476
479
|
const completed = plan.filter(item => item.status === 'completed').length;
|
|
@@ -482,8 +485,15 @@ export class ChatPrompt {
|
|
|
482
485
|
return [summary, ''];
|
|
483
486
|
}
|
|
484
487
|
const rows = [`${bold(paint('accent', 'implementation plan'))} ${dim(`${completed}/${plan.length}`)}`];
|
|
488
|
+
// When the sidebar is absent, keep the active task visible instead of
|
|
489
|
+
// permanently showing the first five (often already completed) steps.
|
|
485
490
|
const limit = Math.min(plan.length, 5);
|
|
486
|
-
|
|
491
|
+
const active = plan.findIndex(item => item.status === 'in_progress');
|
|
492
|
+
const pending = plan.findIndex(item => item.status !== 'completed');
|
|
493
|
+
const focus = active >= 0 ? active : pending >= 0 ? pending : plan.length - 1;
|
|
494
|
+
const start = Math.max(0, Math.min(focus - 1, plan.length - limit));
|
|
495
|
+
if (start > 0) rows.push(` ${dim(`${GLYPHS.ellipsis} ${start} earlier`)}`);
|
|
496
|
+
for (const item of plan.slice(start, start + limit)) {
|
|
487
497
|
const mark = item.status === 'completed'
|
|
488
498
|
? paint('success', GLYPHS.check)
|
|
489
499
|
: item.status === 'in_progress'
|
|
@@ -491,7 +501,8 @@ export class ChatPrompt {
|
|
|
491
501
|
: paint('muted', GLYPHS.dot);
|
|
492
502
|
rows.push(` ${mark} ${truncate(safeDisplay(item.text || item.step || ''), Math.max(8, width - 5), GLYPHS.ellipsis)}`);
|
|
493
503
|
}
|
|
494
|
-
|
|
504
|
+
const remaining = plan.length - start - limit;
|
|
505
|
+
if (remaining > 0) rows.push(` ${dim(`${GLYPHS.ellipsis} ${remaining} later`)}`);
|
|
495
506
|
rows.push('');
|
|
496
507
|
return rows;
|
|
497
508
|
}
|
|
@@ -749,13 +760,42 @@ export class ChatPrompt {
|
|
|
749
760
|
});
|
|
750
761
|
}
|
|
751
762
|
|
|
752
|
-
/**
|
|
763
|
+
/** Restore attachments if an earlier submission was handled as a local command. */
|
|
764
|
+
restoreUnconsumedAttachments() {
|
|
765
|
+
if (Array.isArray(this.currentSubmissionAttachments) && this.currentSubmissionAttachments.length) {
|
|
766
|
+
this.pendingAttachments = this.currentSubmissionAttachments.concat(this.pendingAttachments);
|
|
767
|
+
}
|
|
768
|
+
this.currentSubmissionAttachments = null;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
takeSubmissionAttachments() {
|
|
772
|
+
const attachments = Array.isArray(this.pendingAttachments) ? this.pendingAttachments : [];
|
|
773
|
+
this.pendingAttachments = [];
|
|
774
|
+
return attachments;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/** Queue text with its attachments. Local command values retain their existing type. */
|
|
778
|
+
enqueueSubmission(text, { rendered = false } = {}) {
|
|
779
|
+
if (!Array.isArray(this.queue)) this.queue = [];
|
|
780
|
+
if (this.isCommand(text)) {
|
|
781
|
+
this.queue.push(text);
|
|
782
|
+
} else {
|
|
783
|
+
this.queue.push({ kind: 'chat-submission', text, attachments: this.takeSubmissionAttachments(), rendered });
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/** Read in FIFO order and display a submitted message only once dispatched. */
|
|
753
788
|
read() {
|
|
789
|
+
this.restoreUnconsumedAttachments();
|
|
754
790
|
if (this.queue.length > 0) {
|
|
755
|
-
const
|
|
756
|
-
|
|
791
|
+
const entry = this.queue.shift();
|
|
792
|
+
const submission = entry && typeof entry === 'object' && entry.kind === 'chat-submission';
|
|
793
|
+
const text = submission ? entry.text : entry;
|
|
794
|
+
if (submission) this.currentSubmissionAttachments = entry.attachments;
|
|
795
|
+
if (typeof text === 'string' && !this.isCommand(text) && !(submission && entry.rendered)) {
|
|
757
796
|
this.renderSubmittedUserMessage(text);
|
|
758
797
|
}
|
|
798
|
+
this.scheduleDraw();
|
|
759
799
|
return Promise.resolve(text);
|
|
760
800
|
}
|
|
761
801
|
return new Promise((resolve) => { this.waiter = resolve; });
|
|
@@ -787,9 +827,13 @@ export class ChatPrompt {
|
|
|
787
827
|
* Consume and return any pending multimodal attachments (e.g. pasted screenshots).
|
|
788
828
|
*/
|
|
789
829
|
consumeAttachments() {
|
|
790
|
-
|
|
791
|
-
this.
|
|
792
|
-
|
|
830
|
+
// An empty submission snapshot still takes precedence over a future draft.
|
|
831
|
+
if (this.currentSubmissionAttachments !== null) {
|
|
832
|
+
const attachments = this.currentSubmissionAttachments;
|
|
833
|
+
this.currentSubmissionAttachments = null;
|
|
834
|
+
return Array.isArray(attachments) ? attachments : [];
|
|
835
|
+
}
|
|
836
|
+
return this.takeSubmissionAttachments();
|
|
793
837
|
}
|
|
794
838
|
|
|
795
839
|
/**
|
|
@@ -810,8 +854,10 @@ export class ChatPrompt {
|
|
|
810
854
|
submit() {
|
|
811
855
|
const text = this.editor.getText();
|
|
812
856
|
if (!text.trim()) return;
|
|
813
|
-
if (this.
|
|
814
|
-
|
|
857
|
+
if (!Array.isArray(this.queue)) this.queue = [];
|
|
858
|
+
// busy=false does not imply read() is awaiting: command dispatch has gaps.
|
|
859
|
+
if ((this.busy || !this.waiter) && this.queue.length >= 32
|
|
860
|
+
&& !/^\/(?:stop|interrupt)$/i.test(text.trim())) {
|
|
815
861
|
this.notice = '32 queued messages: wait for a turn to complete before adding another';
|
|
816
862
|
this.scheduleDraw();
|
|
817
863
|
return;
|
|
@@ -826,7 +872,7 @@ export class ChatPrompt {
|
|
|
826
872
|
}
|
|
827
873
|
|
|
828
874
|
// Instant slash command shortcuts that operate directly on the prompt surface
|
|
829
|
-
if (text === '/usage') {
|
|
875
|
+
if (text === '/usage' && typeof this.toggleUsageCard === 'function') {
|
|
830
876
|
void this.toggleUsageCard();
|
|
831
877
|
return;
|
|
832
878
|
}
|
|
@@ -872,7 +918,7 @@ export class ChatPrompt {
|
|
|
872
918
|
} else {
|
|
873
919
|
this.notice = `queued (${this.queue.length + 1}) — sends when this turn ends`;
|
|
874
920
|
}
|
|
875
|
-
this.
|
|
921
|
+
this.enqueueSubmission(text);
|
|
876
922
|
this.scheduleDraw();
|
|
877
923
|
return;
|
|
878
924
|
}
|
|
@@ -886,19 +932,29 @@ export class ChatPrompt {
|
|
|
886
932
|
this.waiter = null;
|
|
887
933
|
if (settle) settle(text);
|
|
888
934
|
else {
|
|
889
|
-
|
|
890
|
-
this.queue.
|
|
935
|
+
this.enqueueSubmission(text); // no waiter yet: retain the command
|
|
936
|
+
this.notice = `queued (${this.queue.length}) — sends when ready`;
|
|
937
|
+
this.scheduleDraw?.();
|
|
891
938
|
}
|
|
892
939
|
return;
|
|
893
940
|
}
|
|
894
941
|
|
|
895
|
-
// Render live submissions through the same path used when history reflows.
|
|
896
|
-
if (!this.isCommand(text)) {
|
|
897
|
-
this.renderSubmittedUserMessage(text);
|
|
898
|
-
}
|
|
899
942
|
const resolve = this.waiter;
|
|
900
943
|
this.waiter = null;
|
|
901
|
-
if (resolve)
|
|
944
|
+
if (resolve) {
|
|
945
|
+
this.restoreUnconsumedAttachments();
|
|
946
|
+
this.currentSubmissionAttachments = this.takeSubmissionAttachments();
|
|
947
|
+
this.renderSubmittedUserMessage(text);
|
|
948
|
+
resolve(text);
|
|
949
|
+
} else {
|
|
950
|
+
// Display the user's submitted message immediately, as before, but
|
|
951
|
+
// retain it until the CLI registers its next read() waiter.
|
|
952
|
+
// The rendered marker prevents a duplicate transcript entry at dequeue.
|
|
953
|
+
this.renderSubmittedUserMessage(text);
|
|
954
|
+
this.enqueueSubmission(text, { rendered: true });
|
|
955
|
+
this.notice = `queued (${this.queue.length}) — sends when ready`;
|
|
956
|
+
this.scheduleDraw?.();
|
|
957
|
+
}
|
|
902
958
|
}
|
|
903
959
|
|
|
904
960
|
// -------------------------------------------------------------------------
|
|
@@ -1649,6 +1705,19 @@ export class ChatPrompt {
|
|
|
1649
1705
|
// Drawing
|
|
1650
1706
|
// -------------------------------------------------------------------------
|
|
1651
1707
|
|
|
1708
|
+
/** Preview pending input without falsely adding unsent text to the transcript. */
|
|
1709
|
+
queuedPreviewRows(width) {
|
|
1710
|
+
if (this.queue.length === 0) return [];
|
|
1711
|
+
const last = this.queue[this.queue.length - 1];
|
|
1712
|
+
const text = typeof last === 'string' ? last
|
|
1713
|
+
: last && typeof last.text === 'string' ? last.text : 'pending action';
|
|
1714
|
+
const prefix = ` Queued (${this.queue.length}): `;
|
|
1715
|
+
const available = Math.max(0, width - visibleWidth(prefix) - 2);
|
|
1716
|
+
// Do not reformat megabyte-sized pastes on every running-turn redraw.
|
|
1717
|
+
const preview = safeDisplay(text.slice(0, 160).replace(/\s+/g, ' ').trim());
|
|
1718
|
+
return [dim(prefix + truncate(preview, available, GLYPHS.ellipsis))];
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1652
1721
|
/**
|
|
1653
1722
|
* Clamp every row so the terminal can never wrap one of them.
|
|
1654
1723
|
*
|
|
@@ -1783,6 +1852,7 @@ export class ChatPrompt {
|
|
|
1783
1852
|
pickerCount: pickerRows.length,
|
|
1784
1853
|
totalPromptRows: 0
|
|
1785
1854
|
} : null;
|
|
1855
|
+
const queuedRows = this.queuedPreviewRows(width);
|
|
1786
1856
|
const noticeRows = this.notice ? [dim(` ${this.notice}`)] : [];
|
|
1787
1857
|
|
|
1788
1858
|
// And a row of air between the box and the footer. The picker and a notice
|
|
@@ -1793,7 +1863,7 @@ export class ChatPrompt {
|
|
|
1793
1863
|
const gap = status.length > 0 ? new Array(FOOTER_GAP).fill('') : [];
|
|
1794
1864
|
|
|
1795
1865
|
const all = this.clampRows(
|
|
1796
|
-
usageCardRows.concat(planRows, boxRows, pickerRows, noticeRows, gap, status), width
|
|
1866
|
+
usageCardRows.concat(planRows, boxRows, pickerRows, queuedRows, noticeRows, gap, status), width
|
|
1797
1867
|
);
|
|
1798
1868
|
if (this.pickerLayout) this.pickerLayout.totalPromptRows = all.length;
|
|
1799
1869
|
|
package/src/tui/stage.js
CHANGED
|
@@ -225,6 +225,21 @@ export class Stage {
|
|
|
225
225
|
this.write(`\x1b[${delta}B`);
|
|
226
226
|
this.cursor = target;
|
|
227
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Recover the reserved band's physical anchor after a terminal reflow.
|
|
230
|
+
* A width change can soft-wrap old screen rows before the next repaint.
|
|
231
|
+
* Cursor-down clamps at the screen bottom without emitting a newline or
|
|
232
|
+
* addressing an absolute row, preserving native terminal scrollback.
|
|
233
|
+
*/
|
|
234
|
+
reanchor() {
|
|
235
|
+
if (!this.reserved)
|
|
236
|
+
return false;
|
|
237
|
+
this.write('\x1b[999B\r');
|
|
238
|
+
this.cursor = this.height - 1;
|
|
239
|
+
this.caret = { row: this.cursor, col: 0, hideCursor: Boolean(this.caret.hideCursor) };
|
|
240
|
+
this.invalidate();
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
228
243
|
/**
|
|
229
244
|
* Repaint the band. Rows that did not change cost nothing.
|
|
230
245
|
*
|
package/src/tui/stage.ts
CHANGED
|
@@ -244,6 +244,21 @@ export class Stage {
|
|
|
244
244
|
this.cursor = target;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Recover the reserved band's physical anchor after a terminal reflow.
|
|
249
|
+
* A width change can soft-wrap old screen rows before the next repaint.
|
|
250
|
+
* Cursor-down clamps at the screen bottom without emitting a newline or
|
|
251
|
+
* addressing an absolute row, preserving native terminal scrollback.
|
|
252
|
+
*/
|
|
253
|
+
reanchor(): boolean {
|
|
254
|
+
if (!this.reserved) return false;
|
|
255
|
+
this.write('\x1b[999B\r');
|
|
256
|
+
this.cursor = this.height - 1;
|
|
257
|
+
this.caret = { row: this.cursor, col: 0, hideCursor: Boolean(this.caret.hideCursor) };
|
|
258
|
+
this.invalidate();
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
|
|
247
262
|
/**
|
|
248
263
|
* Repaint the band. Rows that did not change cost nothing.
|
|
249
264
|
*
|
package/src/tui/stageSurface.js
CHANGED
|
@@ -186,6 +186,7 @@ export class StageSurface {
|
|
|
186
186
|
this.env = env;
|
|
187
187
|
|
|
188
188
|
this.stage = new Stage({ out, env });
|
|
189
|
+
this.lastColumns = this.stage.width();
|
|
189
190
|
this.transcript = new Transcript({
|
|
190
191
|
onEvict: (rows) => this.absorbEvicted(rows),
|
|
191
192
|
onChange: () => this.handleChange()
|
|
@@ -680,9 +681,15 @@ export class StageSurface {
|
|
|
680
681
|
// obsolete sidebar columns behind during the 160-column breakpoint.
|
|
681
682
|
// The existing rows are already reserved: repaint them in place with
|
|
682
683
|
// their new width, clearing trailing cells through Stage.paint().
|
|
684
|
+
const columns = this.stage.width();
|
|
683
685
|
if (!this.stage.reserved || next !== this.stage.maxHeight) {
|
|
684
686
|
this.stage.resize(next, 1);
|
|
687
|
+
} else if (columns !== this.lastColumns && !this.detached) {
|
|
688
|
+
// macOS Terminal may physically reflow rows when the sidebar appears
|
|
689
|
+
// or disappears. The old caret row is then no longer a reliable anchor.
|
|
690
|
+
this.stage.reanchor();
|
|
685
691
|
}
|
|
692
|
+
this.lastColumns = columns;
|
|
686
693
|
this.stage.invalidate();
|
|
687
694
|
// Re-derive from the new geometry: growing the viewport lowers maxScrollTop,
|
|
688
695
|
// and leaving scrollTop above it would read as "the user scrolled away".
|
|
@@ -827,9 +834,9 @@ export class StageSurface {
|
|
|
827
834
|
this.out.write(mouseHoverTracking(true, this.env));
|
|
828
835
|
this.mouseCaptured = true;
|
|
829
836
|
this.detached = false;
|
|
830
|
-
//
|
|
831
|
-
//
|
|
832
|
-
this.stage.
|
|
837
|
+
// After native scrollback, the former physical cursor location is unknown.
|
|
838
|
+
// Return to the screen bottom before repainting any transcript rows.
|
|
839
|
+
this.stage.reanchor();
|
|
833
840
|
return true;
|
|
834
841
|
}
|
|
835
842
|
}
|