@poe-platform/safe-bash 0.1.771 → 0.1.772

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.
@@ -1431,7 +1431,6 @@ function createPythonHostBridge(capabilities, options) {
1431
1431
  const pull = async (handle) => {
1432
1432
  const stream = streams.get(handle);
1433
1433
  if (!stream) throw new Error("Unknown Python host stream");
1434
- stream.busy = true;
1435
1434
  try {
1436
1435
  const result = await stream.iterator.next();
1437
1436
  assertLive();
@@ -1451,8 +1450,6 @@ function createPythonHostBridge(capabilities, options) {
1451
1450
  } catch (error) {
1452
1451
  if (streams.has(handle)) await release(handle);
1453
1452
  throw error;
1454
- } finally {
1455
- stream.busy = false;
1456
1453
  }
1457
1454
  };
1458
1455
  const request = async (incoming) => {
@@ -1480,9 +1477,12 @@ function createPythonHostBridge(capabilities, options) {
1480
1477
  if (payload.operation === "begin" || payload.operation === "begin-next") {
1481
1478
  let work;
1482
1479
  let child;
1480
+ let reservedStream;
1483
1481
  if (payload.operation === "begin-next") {
1484
1482
  const stream = typeof payload.handle === "number" ? streams.get(payload.handle) : void 0;
1485
1483
  if (!stream || stream.busy) throw new Error("Unknown or busy Python host stream");
1484
+ reservedStream = stream;
1485
+ stream.busy = true;
1486
1486
  child = stream.controller;
1487
1487
  work = () => pull(payload.handle);
1488
1488
  } else {
@@ -1505,6 +1505,7 @@ function createPythonHostBridge(capabilities, options) {
1505
1505
  }).catch((error) => {
1506
1506
  job.failed = pythonHostFailureCode(error);
1507
1507
  }).finally(() => {
1508
+ if (reservedStream) reservedStream.busy = false;
1508
1509
  jobWork.delete(task);
1509
1510
  });
1510
1511
  jobWork.add(task);
@@ -1520,7 +1521,12 @@ function createPythonHostBridge(capabilities, options) {
1520
1521
  await release(handle);
1521
1522
  return null;
1522
1523
  }
1523
- return pull(handle);
1524
+ stream.busy = true;
1525
+ try {
1526
+ return await pull(handle);
1527
+ } finally {
1528
+ stream.busy = false;
1529
+ }
1524
1530
  }
1525
1531
  if (typeof payload.capability !== "string") throw new TypeError("Invalid Python host capability");
1526
1532
  const capability = registry.get(payload.capability);
@@ -108,7 +108,6 @@ export function createPythonHostBridge(capabilities, options) {
108
108
  const stream = streams.get(handle);
109
109
  if (!stream)
110
110
  throw new Error('Unknown Python host stream');
111
- stream.busy = true;
112
111
  try {
113
112
  const result = await stream.iterator.next();
114
113
  assertLive();
@@ -133,9 +132,6 @@ export function createPythonHostBridge(capabilities, options) {
133
132
  await release(handle);
134
133
  throw error;
135
134
  }
136
- finally {
137
- stream.busy = false;
138
- }
139
135
  };
140
136
  const request = async (incoming) => {
141
137
  assertLive();
@@ -168,10 +164,13 @@ export function createPythonHostBridge(capabilities, options) {
168
164
  if (payload.operation === 'begin' || payload.operation === 'begin-next') {
169
165
  let work;
170
166
  let child;
167
+ let reservedStream;
171
168
  if (payload.operation === 'begin-next') {
172
169
  const stream = typeof payload.handle === 'number' ? streams.get(payload.handle) : undefined;
173
170
  if (!stream || stream.busy)
174
171
  throw new Error('Unknown or busy Python host stream');
172
+ reservedStream = stream;
173
+ stream.busy = true;
175
174
  child = stream.controller;
176
175
  work = () => pull(payload.handle);
177
176
  }
@@ -193,7 +192,11 @@ export function createPythonHostBridge(capabilities, options) {
193
192
  assertLive();
194
193
  child.signal.throwIfAborted();
195
194
  job.result = data(value);
196
- }).catch(error => { job.failed = pythonHostFailureCode(error); }).finally(() => { jobWork.delete(task); });
195
+ }).catch(error => { job.failed = pythonHostFailureCode(error); }).finally(() => {
196
+ if (reservedStream)
197
+ reservedStream.busy = false;
198
+ jobWork.delete(task);
199
+ });
197
200
  jobWork.add(task);
198
201
  return handle;
199
202
  }
@@ -210,7 +213,13 @@ export function createPythonHostBridge(capabilities, options) {
210
213
  await release(handle);
211
214
  return null;
212
215
  }
213
- return pull(handle);
216
+ stream.busy = true;
217
+ try {
218
+ return await pull(handle);
219
+ }
220
+ finally {
221
+ stream.busy = false;
222
+ }
214
223
  }
215
224
  if (typeof payload.capability !== 'string')
216
225
  throw new TypeError('Invalid Python host capability');
@@ -16,7 +16,7 @@ import {
16
16
  pythonCommands,
17
17
  pythonDocumentPackages,
18
18
  pythonHostFailureCode
19
- } from "../../chunks/chunk-FSH7QRIC.js";
19
+ } from "../../chunks/chunk-Z3HX3ZBA.js";
20
20
  import {
21
21
  PythonFailure,
22
22
  inspectPythonCapabilities
@@ -158,7 +158,7 @@ import {
158
158
  sha256,
159
159
  sha384,
160
160
  sha512
161
- } from "./chunks/chunk-FSH7QRIC.js";
161
+ } from "./chunks/chunk-Z3HX3ZBA.js";
162
162
  import {
163
163
  PythonFailure,
164
164
  inspectPythonCapabilities
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.771",
3
+ "version": "0.1.772",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -841,7 +841,7 @@
841
841
  "access": "public"
842
842
  },
843
843
  "dependencies": {
844
- "@poe-platform/safe-fs": "0.1.771",
844
+ "@poe-platform/safe-fs": "0.1.772",
845
845
  "pdf-lib": "1.17.1",
846
846
  "@noble/hashes": "2.4.0",
847
847
  "pako": "3.0.1",