crewx-pi-kit 0.1.12 → 0.1.13

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/README.md CHANGED
@@ -10,7 +10,7 @@ work, safety boundaries, and agent handoffs.
10
10
  Install it with Pi:
11
11
 
12
12
  ```sh
13
- pi install npm:crewx-pi-kit@0.1.12
13
+ pi install npm:crewx-pi-kit@0.1.13
14
14
  ```
15
15
 
16
16
  CrewX injects short-lived `CREWX_URL` and `CREWX_TOKEN` capabilities only while
@@ -151,8 +151,7 @@ function wait(milliseconds: number, signal?: AbortSignal): Promise<void> {
151
151
  export default function crewxTools(pi: ExtensionAPI) {
152
152
  const protectedValues = new Set<string>();
153
153
  const deliveredSecretRequests = new Set<string>();
154
- const computerReleases = new Map<string, () => void>();
155
- let computerTail = Promise.resolve();
154
+ const computerCalls = new Set<string>();
156
155
  let computerLease: string | undefined;
157
156
  let computerTimer: ReturnType<typeof setTimeout> | undefined;
158
157
  let computerOperations = Promise.resolve();
@@ -179,8 +178,8 @@ export default function crewxTools(pi: ExtensionAPI) {
179
178
  if (computerTimer) clearTimeout(computerTimer);
180
179
  computerTimer = setTimeout(async () => {
181
180
  if (!computerLease || computerClosed) return;
182
- try { await updateComputer(computerReleases.size > 0); renewComputer(); }
183
- catch { computerLease = undefined; if (computerReleases.size > 0) abortComputerAction?.(); }
181
+ try { await updateComputer(computerCalls.size > 0); renewComputer(); }
182
+ catch { computerLease = undefined; if (computerCalls.size > 0) abortComputerAction?.(); }
184
183
  }, 20_000);
185
184
  computerTimer.unref();
186
185
  };
@@ -188,8 +187,7 @@ export default function crewxTools(pi: ExtensionAPI) {
188
187
  computerClosed = true;
189
188
  if (computerTimer) clearTimeout(computerTimer);
190
189
  if (computerLease) await updateComputer(false, true).catch(() => {});
191
- for (const release of computerReleases.values()) release();
192
- computerReleases.clear();
190
+ computerCalls.clear();
193
191
  };
194
192
  pi.on('agent_start', () => { computerClosed = false; });
195
193
  pi.on('agent_end', closeComputer);
@@ -226,26 +224,30 @@ export default function crewxTools(pi: ExtensionAPI) {
226
224
  }
227
225
 
228
226
  if (!isComputerTool(event.toolName, event.input)) return;
229
- const previous = computerTail;
230
- let release!: () => void;
231
- computerTail = new Promise<void>((resolve) => { release = resolve; });
232
- await previous;
227
+ // Pi prepares every parallel call before executing any of them. Waiting
228
+ // here for an earlier result deadlocks the whole batch. Admit one computer
229
+ // action and return a retryable tool error for the others instead.
230
+ if (computerCalls.size > 0) {
231
+ return { block: true, terminate: false, reason: 'Another computer action is already prepared in this batch. Wait for its result, then retry this action in the next turn. Computer actions must be sequential.' };
232
+ }
233
+ computerCalls.add(event.toolCallId);
233
234
  try { await updateComputer(true); }
234
235
  catch (error) {
235
- computerLease = undefined; release();
236
+ computerLease = undefined; computerCalls.delete(event.toolCallId);
236
237
  return { block: true, terminate: false, reason: error instanceof Error ? error.message : 'Computer ownership is unavailable. No browser action was performed.' };
237
238
  }
238
239
  abortComputerAction = () => ctx.abort();
239
- computerReleases.set(event.toolCallId, release);
240
240
  renewComputer();
241
241
  });
242
- pi.on("tool_result", async (event) => {
243
- const release = computerReleases.get(event.toolCallId);
244
- if (release) {
245
- computerReleases.delete(event.toolCallId);
242
+ const finishComputerCall = async (toolCallId: string) => {
243
+ if (computerCalls.delete(toolCallId)) {
246
244
  if (computerLease) await updateComputer(false).catch(() => { computerLease = undefined; });
247
- release();
248
245
  }
246
+ };
247
+ // Also covers a later extension blocking a call after our preflight passed.
248
+ pi.on('tool_execution_end', async (event) => { await finishComputerCall(event.toolCallId); });
249
+ pi.on("tool_result", async (event) => {
250
+ await finishComputerCall(event.toolCallId);
249
251
  return {
250
252
  content: event.content.map((item) =>
251
253
  item.type === "text" ? { ...item, text: scrub(item.text) } : item,
package/package.json CHANGED
@@ -1,19 +1,16 @@
1
1
  {
2
2
  "name": "crewx-pi-kit",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Typed CrewX tools and operating skills for managed Pi agents.",
5
5
  "type": "module",
6
- "files": [
7
- "extensions",
8
- "skills"
9
- ],
6
+ "files": ["extensions", "skills"],
10
7
  "pi": {
11
- "extensions": [
12
- "extensions"
13
- ],
14
- "skills": [
15
- "skills"
16
- ]
8
+ "extensions": ["extensions"],
9
+ "skills": ["skills"]
10
+ },
11
+ "scripts": {
12
+ "types:check": "tsc --noEmit",
13
+ "test": "tsc --noEmit && node --experimental-strip-types --test test/*.test.mjs"
17
14
  },
18
15
  "peerDependencies": {
19
16
  "@earendil-works/pi-coding-agent": "*",
@@ -25,15 +22,7 @@
25
22
  "typebox": "^1.0.55",
26
23
  "typescript": "^5.9.3"
27
24
  },
28
- "engines": {
29
- "node": ">=22"
30
- },
31
- "publishConfig": {
32
- "access": "public"
33
- },
34
- "license": "MIT",
35
- "scripts": {
36
- "types:check": "tsc --noEmit",
37
- "test": "tsc --noEmit && node --experimental-strip-types --test test/*.test.mjs"
38
- }
39
- }
25
+ "engines": {"node": ">=22"},
26
+ "publishConfig": {"access": "public"},
27
+ "license": "MIT"
28
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 CrewX contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.