@pstdio/pocketcoder-remote 0.3.1 → 0.3.2

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.
Files changed (2) hide show
  1. package/dist/extension.js +17 -0
  2. package/package.json +2 -2
package/dist/extension.js CHANGED
@@ -784,6 +784,7 @@ var RemoteAgentClient = class {
784
784
  key;
785
785
  pollIntervalMs;
786
786
  timeoutMs;
787
+ readyTimeoutMs;
787
788
  fetchImpl;
788
789
  changesUrl;
789
790
  constructor(config, fetchImpl = fetch) {
@@ -791,6 +792,7 @@ var RemoteAgentClient = class {
791
792
  this.key = config.key;
792
793
  this.pollIntervalMs = config.pollIntervalMs ?? 250;
793
794
  this.timeoutMs = config.timeoutMs ?? 6e5;
795
+ this.readyTimeoutMs = Math.min(config.readyTimeoutMs ?? 12e4, this.timeoutMs);
794
796
  this.fetchImpl = fetchImpl;
795
797
  this.changesUrl = changesUrlFor(this.serviceUrl);
796
798
  }
@@ -851,7 +853,22 @@ var RemoteAgentClient = class {
851
853
  agentState: body.workspace.agent_state
852
854
  };
853
855
  }
856
+ async waitForInput(signal) {
857
+ const deadline = Date.now() + this.readyTimeoutMs;
858
+ let cursor = 0;
859
+ for (;;) {
860
+ const remainingMs = deadline - Date.now();
861
+ const change = await this.workspaceChange(cursor, Math.max(1, Math.min(30, Math.ceil(remainingMs / 1e3))), "submit_readiness", false, signal);
862
+ const state = change ? change.agentState : await this.status("submit_readiness", false, signal);
863
+ if (state === "stable") return;
864
+ const advanced = change !== void 0 && change.cursor !== cursor;
865
+ if (change) cursor = change.cursor;
866
+ if (Date.now() >= deadline) throw new Error(`remote agent was still ${state} after ${this.readyTimeoutMs}ms and cannot accept a message`);
867
+ if (!advanced) await delay(this.pollIntervalMs, signal);
868
+ }
869
+ }
854
870
  async submit(prompt, attachmentIds, signal) {
871
+ await this.waitForInput(signal);
855
872
  const response = await this.request("/message", {
856
873
  method: "POST",
857
874
  body: JSON.stringify({
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "type:app"
7
7
  ]
8
8
  },
9
- "version": "0.3.1",
9
+ "version": "0.3.2",
10
10
  "private": false,
11
11
  "description": "Pi-based terminal UI for PocketCoder workspaces.",
12
12
  "type": "module",
@@ -46,7 +46,7 @@
46
46
  "@earendil-works/pi-ai": "0.83.0",
47
47
  "@earendil-works/pi-coding-agent": "0.83.0",
48
48
  "@earendil-works/pi-tui": "0.83.0",
49
- "@pstdio/pocketcoder-sdk": "^0.4.0"
49
+ "@pstdio/pocketcoder-sdk": "^0.5.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/bun": "1.3.14",