@causyne/agent 1.20.108 → 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 +80 -18
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;
|
|
@@ -757,13 +760,42 @@ export class ChatPrompt {
|
|
|
757
760
|
});
|
|
758
761
|
}
|
|
759
762
|
|
|
760
|
-
/**
|
|
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. */
|
|
761
788
|
read() {
|
|
789
|
+
this.restoreUnconsumedAttachments();
|
|
762
790
|
if (this.queue.length > 0) {
|
|
763
|
-
const
|
|
764
|
-
|
|
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)) {
|
|
765
796
|
this.renderSubmittedUserMessage(text);
|
|
766
797
|
}
|
|
798
|
+
this.scheduleDraw();
|
|
767
799
|
return Promise.resolve(text);
|
|
768
800
|
}
|
|
769
801
|
return new Promise((resolve) => { this.waiter = resolve; });
|
|
@@ -795,9 +827,13 @@ export class ChatPrompt {
|
|
|
795
827
|
* Consume and return any pending multimodal attachments (e.g. pasted screenshots).
|
|
796
828
|
*/
|
|
797
829
|
consumeAttachments() {
|
|
798
|
-
|
|
799
|
-
this.
|
|
800
|
-
|
|
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();
|
|
801
837
|
}
|
|
802
838
|
|
|
803
839
|
/**
|
|
@@ -818,8 +854,10 @@ export class ChatPrompt {
|
|
|
818
854
|
submit() {
|
|
819
855
|
const text = this.editor.getText();
|
|
820
856
|
if (!text.trim()) return;
|
|
821
|
-
if (this.
|
|
822
|
-
|
|
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())) {
|
|
823
861
|
this.notice = '32 queued messages: wait for a turn to complete before adding another';
|
|
824
862
|
this.scheduleDraw();
|
|
825
863
|
return;
|
|
@@ -834,7 +872,7 @@ export class ChatPrompt {
|
|
|
834
872
|
}
|
|
835
873
|
|
|
836
874
|
// Instant slash command shortcuts that operate directly on the prompt surface
|
|
837
|
-
if (text === '/usage') {
|
|
875
|
+
if (text === '/usage' && typeof this.toggleUsageCard === 'function') {
|
|
838
876
|
void this.toggleUsageCard();
|
|
839
877
|
return;
|
|
840
878
|
}
|
|
@@ -880,7 +918,7 @@ export class ChatPrompt {
|
|
|
880
918
|
} else {
|
|
881
919
|
this.notice = `queued (${this.queue.length + 1}) — sends when this turn ends`;
|
|
882
920
|
}
|
|
883
|
-
this.
|
|
921
|
+
this.enqueueSubmission(text);
|
|
884
922
|
this.scheduleDraw();
|
|
885
923
|
return;
|
|
886
924
|
}
|
|
@@ -894,19 +932,29 @@ export class ChatPrompt {
|
|
|
894
932
|
this.waiter = null;
|
|
895
933
|
if (settle) settle(text);
|
|
896
934
|
else {
|
|
897
|
-
|
|
898
|
-
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?.();
|
|
899
938
|
}
|
|
900
939
|
return;
|
|
901
940
|
}
|
|
902
941
|
|
|
903
|
-
// Render live submissions through the same path used when history reflows.
|
|
904
|
-
if (!this.isCommand(text)) {
|
|
905
|
-
this.renderSubmittedUserMessage(text);
|
|
906
|
-
}
|
|
907
942
|
const resolve = this.waiter;
|
|
908
943
|
this.waiter = null;
|
|
909
|
-
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
|
+
}
|
|
910
958
|
}
|
|
911
959
|
|
|
912
960
|
// -------------------------------------------------------------------------
|
|
@@ -1657,6 +1705,19 @@ export class ChatPrompt {
|
|
|
1657
1705
|
// Drawing
|
|
1658
1706
|
// -------------------------------------------------------------------------
|
|
1659
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
|
+
|
|
1660
1721
|
/**
|
|
1661
1722
|
* Clamp every row so the terminal can never wrap one of them.
|
|
1662
1723
|
*
|
|
@@ -1791,6 +1852,7 @@ export class ChatPrompt {
|
|
|
1791
1852
|
pickerCount: pickerRows.length,
|
|
1792
1853
|
totalPromptRows: 0
|
|
1793
1854
|
} : null;
|
|
1855
|
+
const queuedRows = this.queuedPreviewRows(width);
|
|
1794
1856
|
const noticeRows = this.notice ? [dim(` ${this.notice}`)] : [];
|
|
1795
1857
|
|
|
1796
1858
|
// And a row of air between the box and the footer. The picker and a notice
|
|
@@ -1801,7 +1863,7 @@ export class ChatPrompt {
|
|
|
1801
1863
|
const gap = status.length > 0 ? new Array(FOOTER_GAP).fill('') : [];
|
|
1802
1864
|
|
|
1803
1865
|
const all = this.clampRows(
|
|
1804
|
-
usageCardRows.concat(planRows, boxRows, pickerRows, noticeRows, gap, status), width
|
|
1866
|
+
usageCardRows.concat(planRows, boxRows, pickerRows, queuedRows, noticeRows, gap, status), width
|
|
1805
1867
|
);
|
|
1806
1868
|
if (this.pickerLayout) this.pickerLayout.totalPromptRows = all.length;
|
|
1807
1869
|
|