@saadnvd1/agent-os 0.3.625 → 0.3.627
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/lib/chat/worker/host.ts +22 -0
- package/package.json +1 -1
package/lib/chat/worker/host.ts
CHANGED
|
@@ -533,6 +533,26 @@ export class ChatHost {
|
|
|
533
533
|
return true;
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
+
// A blocking step moved to the background frees the agent: the turn goes
|
|
537
|
+
// on, and what's queued goes in now, in order, as a message sent mid-turn
|
|
538
|
+
// does, rather than wait for the turn to end. Only the turn it was asked
|
|
539
|
+
// in: one that ended meanwhile has sent its queue by the usual rules.
|
|
540
|
+
private sendQueuedMidTurn(turn: number): void {
|
|
541
|
+
if (
|
|
542
|
+
!this.busy() ||
|
|
543
|
+
this.turnsStarted !== turn ||
|
|
544
|
+
this.closed ||
|
|
545
|
+
this.handingOver() ||
|
|
546
|
+
this.compacting ||
|
|
547
|
+
this.compactingNow
|
|
548
|
+
)
|
|
549
|
+
return;
|
|
550
|
+
for (let next; (next = claimNext(this.session.id)); ) {
|
|
551
|
+
this.emit({ type: "queue" });
|
|
552
|
+
this.sendUser(next);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
536
556
|
private sendUser(
|
|
537
557
|
m: {
|
|
538
558
|
id: string;
|
|
@@ -769,7 +789,9 @@ export class ChatHost {
|
|
|
769
789
|
case "background_task":
|
|
770
790
|
try {
|
|
771
791
|
if (!this.conversation.backgroundTask) throw new Error("unsupported");
|
|
792
|
+
const turn = this.turnsStarted;
|
|
772
793
|
const ok = await this.conversation.backgroundTask(cmd.toolUseId);
|
|
794
|
+
if (ok) this.sendQueuedMidTurn(turn);
|
|
773
795
|
this.emit({ type: "background_result", reqId: cmd.reqId, ok });
|
|
774
796
|
} catch (error) {
|
|
775
797
|
this.emit({
|