feat: send agent prompt -> prompt agent

This commit is contained in:
Shivering Ocelot committed 2026-10-10 12:38:01 -05:00
1 parent 161dfd507f
commit 0dee6a392f
7 files changed
+199 -105

No files matched your search

+27 -6
View File
@@ -157,14 +157,35 @@
}
promptHistory.value.push(historyEntry);
let res = await backend.sendAction("send-agent-prompt", payload);
if (res.error) {
historyEntry.error = res.error;
} else {
historyEntry.output = res.response;
// prompt-agent is a multiple-result action (like read-stream): one packet
// per generated inference.Message, followed by a terminal eof packet. The
// callback runs once per packet. Assistant/reasoning content is an open
// stream ({streamId}); we read it live via read-stream.
historyEntry.output = "";
try {
await backend.sendAction("prompt-agent", payload, (packet, deferred) => {
if (packet.eof) {
deferred.resolve(packet);
} else {
const msg = packet.data;
if (msg.role !== 'assistant') return;
const content = msg.content;
if (content && content.streamId != null) {
const stream = backend.readStream(content.streamId);
stream.on('data', () => {
historyEntry.output = stream.partialContent;
});
} else if (typeof content === 'string') {
historyEntry.output += content;
}
}
});
} catch (e) {
historyEntry.error = e.message || String(e);
} finally {
historyEntry.loading = false;
}
historyEntry.loading = false;
}
function promptKeyDown (event, stage) {