@av-pi-studio/server 0.0.107 → 0.0.108

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.
@@ -218,13 +218,13 @@ class PiAgentSession {
218
218
  });
219
219
  }
220
220
  /**
221
- * Send a `/command` prompt *correlated* (`request`, not `notify`) so Pi's own ack is observable:
222
- * Pi acks on preflight (dist/modes/rpc/rpc-mode.js `case "prompt"`), then `get_state.isStreaming`
223
- * — set synchronously as `_runAgentPrompt`'s first statement, hence already `true` for a real
224
- * turn by the time the ack reaches us — says whether a turn is actually running. Not streaming ⇒
225
- * the command was handled inline (extension command) and this turn is already over. A rejected
226
- * ack (no model, no auth, "Agent is already processing") now surfaces as a failed turn instead of
227
- * being silently dropped the way an unmatched `notify` response is (rpc-transport.ts `handleLine`).
221
+ * Send a `/command` prompt *correlated* (`request`, not `notify`) so Pi's own ack is observable.
222
+ * Pi acks on preflight with `data.disposition` (dist/modes/rpc/rpc-mode.js `case "prompt"`,
223
+ * Pi ≥ 0.99.0): `"handled"` ⇒ an extension command ran inline, no run started and no
224
+ * `agent_settled` will follow, so this turn is already over; `"started"`/`"queued"` ⇒ a run is
225
+ * (or will be) in flight, so await its terminal event. A rejected ack (no model, no auth, "Agent
226
+ * is already processing") surfaces as a failed turn instead of being silently dropped the way an
227
+ * unmatched `notify` response is (rpc-transport.ts `handleLine`).
228
228
  */
229
229
  async runSlashPrompt(prompt, opts) {
230
230
  let terminated = false;
@@ -242,14 +242,11 @@ class PiAgentSession {
242
242
  });
243
243
  try {
244
244
  const images = this.toPiImages(opts?.images);
245
- await this.transport.request("prompt", {
245
+ const ack = (await this.transport.request("prompt", {
246
246
  message: prompt,
247
247
  ...(images ? { images } : {}),
248
- });
249
- if (terminated)
250
- return;
251
- const state = (await this.transport.request("get_state"));
252
- if (state.isStreaming === false)
248
+ }));
249
+ if (terminated || ack?.disposition === "handled")
253
250
  return;
254
251
  await terminal;
255
252
  }
@@ -135,12 +135,15 @@ export function createPiEventMapper() {
135
135
  return null;
136
136
  }
137
137
  case "agent_settled": {
138
- // The true terminal (docs/rpc.md § agent_settled: Pi will not continue automatically
139
- // through retry, compaction retry, or queued follow-up messages past this point).
140
- const result = disposition === "failed"
141
- ? { kind: "turn_failed", error: error ?? "error" }
142
- : disposition === "canceled"
143
- ? { kind: "turn_canceled" }
138
+ // The true terminal (docs/json.md § Agent and turn events: Pi will not continue
139
+ // automatically through retry, compaction retry, or queued follow-up messages past this).
140
+ // `aborted` (Pi ≥ 1.1.0) is authoritative for a user abort and wins over the latch: an
141
+ // abort landing between runs — during an auto-retry backoff or a compaction — produces
142
+ // no `stopReason: "aborted"` message to latch, so the latch alone would misreport it.
143
+ const result = event.aborted === true || disposition === "canceled"
144
+ ? { kind: "turn_canceled" }
145
+ : disposition === "failed"
146
+ ? { kind: "turn_failed", error: error ?? "error" }
144
147
  : { kind: "turn_completed" };
145
148
  latch("completed");
146
149
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@av-pi-studio/server",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "bin": {
5
5
  "pi-studio-daemon": "dist/daemon/main.js"
6
6
  },
@@ -24,9 +24,9 @@
24
24
  "clean": "rm -rf dist *.tsbuildinfo"
25
25
  },
26
26
  "dependencies": {
27
- "@av-pi-studio/protocol": "^0.0.107",
28
- "@av-pi-studio/relay": "^0.0.107",
29
- "@earendil-works/pi-coding-agent": ">=0.85.1 <1.0.0",
27
+ "@av-pi-studio/protocol": "^0.0.108",
28
+ "@av-pi-studio/relay": "^0.0.108",
29
+ "@earendil-works/pi-coding-agent": "^1.1.0",
30
30
  "@xterm/addon-serialize": "^0.14.0",
31
31
  "@xterm/headless": "^6.0.0",
32
32
  "bcryptjs": "^3.0.3",