Updates
Rolling release / release (push) Successful in 8m31s

This commit is contained in:
2026-09-13 15:08:05 -04:00
parent b56171da9b
commit c5ccaa490b
29 changed files with 933 additions and 146 deletions
+45 -26
View File
@@ -396,6 +396,7 @@ async function complete(opts, onEvent) {
let text = '';
let thinking = '';
let thinkState = { inThink: false, carry: '' };
const toolCalls = [];
const abortRun = () => {
try {
@@ -420,39 +421,57 @@ async function complete(opts, onEvent) {
const n = events.normalizeCompletionEvent(ev);
if (!n) continue;
watch.bump();
if (n.type === 'contentDelta') {
text += n.delta;
if (onEvent) onEvent(n);
if (repeatLoop.isRepeating(text)) {
abortRun();
settleTimeout();
return;
const split = events.expandThinkEvents(n, thinkState);
thinkState = split.state;
for (const p of split.events) {
if (p.type === 'contentDelta') {
text += p.delta;
if (onEvent) onEvent(p);
if (repeatLoop.isRepeating(text)) {
abortRun();
settleTimeout();
return;
}
} else if (p.type === 'thinkingDelta') {
thinking += p.delta;
if (onEvent) onEvent(p);
if (repeatLoop.isRepeating(thinking)) {
abortRun();
settleTimeout();
return;
}
} else if (p.type === 'toolCall') {
toolCalls.push(p.call);
if (onEvent) onEvent(p);
} else if (onEvent) {
onEvent(p);
}
} else if (n.type === 'thinkingDelta') {
thinking += n.delta;
if (onEvent) onEvent(n);
if (repeatLoop.isRepeating(thinking)) {
abortRun();
settleTimeout();
return;
}
} else if (n.type === 'toolCall') {
toolCalls.push(n.call);
if (onEvent) onEvent(n);
} else if (onEvent) {
onEvent(n);
}
}
} else if (run.tokenStream) {
for await (const token of run.tokenStream) {
if (watch.timedOut()) return;
watch.bump();
text += token;
if (onEvent) onEvent({ type: 'contentDelta', delta: token });
if (repeatLoop.isRepeating(text)) {
abortRun();
settleTimeout();
return;
const split = events.expandThinkEvents({ type: 'contentDelta', delta: token }, thinkState);
thinkState = split.state;
for (const p of split.events) {
if (p.type === 'thinkingDelta') {
thinking += p.delta;
if (onEvent) onEvent(p);
if (repeatLoop.isRepeating(thinking)) {
abortRun();
settleTimeout();
return;
}
} else {
text += p.delta;
if (onEvent) onEvent({ type: 'contentDelta', delta: p.delta });
if (repeatLoop.isRepeating(text)) {
abortRun();
settleTimeout();
return;
}
}
}
}
if (run.toolCallStream) {