@evandu/super-pi 0.1.94 → 0.1.95

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.
@@ -1556,18 +1556,18 @@ export class Store {
1556
1556
  const waiting = this.waitingMessages(conversation);
1557
1557
  const from = waiting.indexOf(message);
1558
1558
  const target = Math.max(0, Math.min(Math.trunc(toIndex), waiting.length - 1));
1559
- if (target === from)
1560
- return structuredClone(message);
1561
1559
  // NOTHING MAY OCCUPY THE `sending` MESSAGE'S SLOT, in either direction. It is already in Pi's stdin and
1562
1560
  // Pi's steering queue is FIFO, so it is delivered next whatever this method does - meaning a different
1563
1561
  // message landing in front of it would be a move the UI performed and the transport then ignored, and
1564
1562
  // moving the `sending` message itself off that spot would be a lie of the same kind.
1565
- const sendingIndex = waiting.findIndex((item) => item.delivery === "sending");
1566
- if (sendingIndex >= 0 && (from === sendingIndex || target <= sendingIndex)) {
1563
+ const lastSendingIndex = waiting.reduce((last, item, index) => item.delivery === "sending" ? index : last, -1);
1564
+ if (lastSendingIndex >= 0 && (message.delivery === "sending" || target <= lastSendingIndex)) {
1567
1565
  throw new Error(message.delivery === "sending"
1568
1566
  ? "这条消息已经交给 Agent 了,挪不动(Pi 会先回答已经收到的那条)"
1569
1567
  : "前面那条消息已经交给 Agent 了,插不过去(Pi 按收到的顺序送达)");
1570
1568
  }
1569
+ if (target === from)
1570
+ return structuredClone(message);
1571
1571
  // Permute THE WAITING SLOTS rather than splicing a message to an index. The waiting messages are
1572
1572
  // usually a suffix of the array, but they are not guaranteed to be one - an assistant message sits
1573
1573
  // between two of them once a steer has been delivered mid-turn - and an offset derived from "where in
@@ -222,10 +222,11 @@ export class WsServer {
222
222
  this.broadcaster.configureStreaming(socket, parsed.coalesce);
223
223
  return;
224
224
  }
225
- // A send represents a streaming operation. It must be admitted immediately so a second send
226
- // can observe the active run and enter the durable follow-up queue; waiting for the first model
227
- // turn here makes every follow-up test time out and defeats the queue semantics.
228
- const runIndependently = parsed.type === "message.send" || parsed.type === "run.stop";
225
+ // A send or selected queued turn is a streaming operation. It must leave the socket's command
226
+ // chain immediately: waiting for the model turn would block later priority/cancel commands and
227
+ // make a second send miss the durable queue. The service owns per-conversation run claims.
228
+ const runIndependently = parsed.type === "message.send" || parsed.type === "message.sendQueued"
229
+ || parsed.type === "message.interrupt" || parsed.type === "run.stop";
229
230
  // ...WHICH MEANS A SEND CAN OVERTAKE A REVERT SENT JUST BEFORE IT, because the revert below is
230
231
  // queued behind whatever this socket was already doing. The service only learns it is cutting
231
232
  // when the command EXECUTES, so a send handled in between would find the conversation open and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.94",
3
+ "version": "0.1.95",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,6 +40,7 @@
40
40
  "check:logic": [
41
41
  "scripts/stream-checkpoint.test.mjs",
42
42
  "scripts/stream-transport.test.mjs",
43
+ "scripts/pi-session.test.mjs",
43
44
  "scripts/lan-access.test.mjs",
44
45
  "scripts/terminal-pty.test.mjs",
45
46
  "scripts/persistence-repository.test.mjs",
@@ -141,6 +142,7 @@
141
142
  "scripts/knowledge-base-browser.test.mjs"
142
143
  ],
143
144
  "dependencies": {
145
+ "@earendil-works/pi-coding-agent": "^0.86.1",
144
146
  "@xterm/addon-fit": "^0.11.0",
145
147
  "@xterm/xterm": "^6.0.0",
146
148
  "node-pty": "^1.2.0-beta.15",