pirc-extension 0.3.9 → 0.3.10

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pirc-extension",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "description": "PiRC: puts every interactive pi session on a PiRC relay",
5
5
  "license": "MIT",
6
6
  "homepage": "https://pirc.dev",
@@ -1,4 +1,4 @@
1
- // PiRC extension 0.3.9. Third-party code in this file: @bufbuild/protobuf@2.16.0, ws@8.22.0; see NOTICE.
1
+ // PiRC extension 0.3.10. Third-party code in this file: @bufbuild/protobuf@2.16.0, ws@8.22.0; see NOTICE.
2
2
  import { createRequire as __pircCreateRequire } from "node:module";
3
3
  const require = __pircCreateRequire(import.meta.url);
4
4
  var __create = Object.create;
@@ -8388,6 +8388,7 @@ var DELTA_MS = 50;
8388
8388
  var PROGRESS_MS = 250;
8389
8389
  var PROMPT_ECHO_MS = 10 * 6e4;
8390
8390
  var CONFIRM_MS = 3e4;
8391
+ var STOP_COMING_MS = 5e3;
8391
8392
  var STOP_DELAY_MS = 300;
8392
8393
  var PERSIST_MS = 2e3;
8393
8394
  var SHOWN = /* @__PURE__ */ new Set(["user", "assistant", "toolResult"]);
@@ -8594,6 +8595,12 @@ var Live = class {
8594
8595
  // Sent the first to an idle pi: the rest wait for its run to start, or
8595
8596
  // for as long as a prompt may take to, not counting a compaction first.
8596
8597
  starting = false;
8598
+ // A prompt has come in (pi's input) and its run has not started: a
8599
+ // question asked now (in before_agent_start) holds that run up.
8600
+ runComing = false;
8601
+ // Until when the run coming is to be stopped as it starts: a dismissed
8602
+ // question held it up (the answer case below).
8603
+ stopComing = 0;
8597
8604
  startTimer;
8598
8605
  // A Compact being run, answered when pi finishes it.
8599
8606
  compaction;
@@ -8892,8 +8899,15 @@ var Live = class {
8892
8899
  if (p) clearTimeout(p.timer);
8893
8900
  this.progress.delete(toolCallId);
8894
8901
  }
8902
+ // pi has taken a prompt in; its run starts after before_agent_start.
8903
+ onInput() {
8904
+ if (!this.working) this.runComing = true;
8905
+ }
8895
8906
  onWorking(working) {
8896
8907
  this.catchUp();
8908
+ this.runComing = false;
8909
+ if (working && Date.now() < this.stopComing) this.ctx.abort();
8910
+ this.stopComing = 0;
8897
8911
  if (working && !this.working) this.reply = void 0;
8898
8912
  if (!working && this.working) this.raise(turnNotice(this.reply, this.nextNumber()));
8899
8913
  if (working) {
@@ -9233,7 +9247,10 @@ var Live = class {
9233
9247
  if (note && turn) this.pi.sendUserMessage(note, { deliverAs: "steer" });
9234
9248
  });
9235
9249
  if (why) return respond(errorReply(requestId, 4 /* INVALID */, why));
9236
- if (value.case === "dismissed" && (turn || !this.ctx.isIdle())) this.ctx.abort();
9250
+ if (value.case === "dismissed") {
9251
+ if (turn || !this.ctx.isIdle()) this.ctx.abort();
9252
+ if (!turn && this.runComing) this.stopComing = Date.now() + STOP_COMING_MS;
9253
+ }
9237
9254
  if (note && !turn) setImmediate(this.guard("note", () => this.pi.sendUserMessage(note, { deliverAs: "followUp" })));
9238
9255
  return respond(accepted(requestId));
9239
9256
  }
@@ -9835,8 +9852,8 @@ var Host = class _Host {
9835
9852
  };
9836
9853
 
9837
9854
  // extension/src/index.ts
9838
- var EXTENSION_VERSION = true ? "0.3.9" : "dev";
9839
- var LOAD = true ? "0.3.9" : `dev ${randomBytes4(4).toString("hex")}`;
9855
+ var EXTENSION_VERSION = true ? "0.3.10" : "dev";
9856
+ var LOAD = true ? "0.3.10" : `dev ${randomBytes4(4).toString("hex")}`;
9840
9857
  var KEY = /* @__PURE__ */ Symbol.for("pirc.extension");
9841
9858
  var proc = globalThis[KEY] ??= {};
9842
9859
  var USAGE = "usage: /pirc [status | enrol <relay-url> [token] | reconnect]";
@@ -9905,6 +9922,10 @@ async function index_default(pi) {
9905
9922
  pi.on("tool_execution_start", on("tool_execution_start", (live, e) => live.onToolStart(e.toolCallId)));
9906
9923
  pi.on("tool_execution_update", on("tool_execution_update", (live, e) => live.onToolUpdate(e)));
9907
9924
  pi.on("tool_execution_end", on("tool_execution_end", (live, e) => live.onToolEnd(e.toolCallId)));
9925
+ pi.on("input", (e) => {
9926
+ on("input", (live) => live.onInput())(e);
9927
+ return { action: "continue" };
9928
+ });
9908
9929
  pi.on("agent_start", on("agent_start", (live) => {
9909
9930
  proc.host.dialogs.install(live.ctx.ui, () => proc.host.dialogs);
9910
9931
  live.onWorking(true);
File without changes
File without changes