@openclaw/openshell-sandbox 2026.7.1-beta.6 β†’ 2026.7.2-beta.1

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/dist/index.js CHANGED
@@ -9,12 +9,10 @@ import { MAX_TIMER_TIMEOUT_SECONDS } from "openclaw/plugin-sdk/number-runtime";
9
9
  import { z } from "zod";
10
10
  import { root } from "openclaw/plugin-sdk/file-access-runtime";
11
11
  import { FsSafeError, isPathInside, movePathWithCopyFallback } from "openclaw/plugin-sdk/security-runtime";
12
+ import pLimit from "p-limit";
12
13
  //#region extensions/openshell/src/cli.ts
13
- function resolveOpenShellCommand(command) {
14
- return command;
15
- }
16
14
  function buildOpenShellBaseArgv(config) {
17
- const argv = [resolveOpenShellCommand(config.command)];
15
+ const argv = [config.command];
18
16
  if (config.gateway) argv.push("--gateway", config.gateway);
19
17
  if (config.gatewayEndpoint) argv.push("--gateway-endpoint", config.gatewayEndpoint);
20
18
  return argv;
@@ -514,11 +512,10 @@ async function assertLocalPathSafety(params) {
514
512
  const canonicalRoot = await fsPromises.realpath(params.root).catch(() => path.resolve(params.root));
515
513
  const targetStats = await fsPromises.lstat(params.target.hostPath).catch(() => null);
516
514
  if (!isPathInside(canonicalRoot, params.allowFinalSymlinkForUnlink && targetStats?.isSymbolicLink() ? path.resolve(canonicalRoot, path.relative(params.root, params.target.hostPath)) : await resolveCanonicalCandidate(params.target.hostPath))) throw new Error(`Sandbox path escapes allowed mounts; cannot access: ${params.target.containerPath}`);
517
- const relative = path.relative(params.root, params.target.hostPath);
518
- const segments = relative.split(path.sep).filter(Boolean).slice(0, Math.max(0, relative.split(path.sep).filter(Boolean).length));
515
+ const segments = path.relative(params.root, params.target.hostPath).split(path.sep).filter(Boolean);
519
516
  let cursor = params.root;
520
- for (let index = 0; index < segments.length; index += 1) {
521
- cursor = path.join(cursor, segments[index]);
517
+ for (const [index, segment] of segments.entries()) {
518
+ cursor = path.join(cursor, segment);
522
519
  const stats = await fsPromises.lstat(cursor).catch(() => null);
523
520
  if (!stats) {
524
521
  if (index === segments.length - 1 && params.allowMissingLeaf) return;
@@ -554,26 +551,7 @@ function createExcludeMatcher(excludeDirs) {
554
551
  const excluded = new Set((excludeDirs ?? []).map((d) => normalizeLowercaseStringOrEmpty(d)));
555
552
  return (name) => excluded.has(normalizeLowercaseStringOrEmpty(name));
556
553
  }
557
- function createConcurrencyLimiter(limit) {
558
- let active = 0;
559
- const queue = [];
560
- const release = () => {
561
- active -= 1;
562
- queue.shift()?.();
563
- };
564
- return async (task) => {
565
- if (active >= limit) await new Promise((resolve) => {
566
- queue.push(resolve);
567
- });
568
- active += 1;
569
- try {
570
- return await task();
571
- } finally {
572
- release();
573
- }
574
- };
575
- }
576
- const runLimitedFs = createConcurrencyLimiter(COPY_TREE_FS_CONCURRENCY);
554
+ const runLimitedFs = pLimit(COPY_TREE_FS_CONCURRENCY);
577
555
  async function lstatIfExists(targetPath) {
578
556
  return await runLimitedFs(async () => await fsPromises.lstat(targetPath)).catch(() => null);
579
557
  }
@@ -583,7 +561,7 @@ async function copyTreeWithoutSymlinks(params) {
583
561
  const targetStats = await lstatIfExists(params.targetPath);
584
562
  if (params.preserveTargetSymlinks && targetStats?.isSymbolicLink()) return;
585
563
  if (stats.isDirectory()) {
586
- await runLimitedFs(async () => await fsPromises.mkdir(params.targetPath, { recursive: true }));
564
+ await runLimitedFs(fsPromises.mkdir, params.targetPath, { recursive: true });
587
565
  const entries = await runLimitedFs(async () => await fsPromises.readdir(params.sourcePath));
588
566
  await Promise.all(entries.map(async (entry) => {
589
567
  await copyTreeWithoutSymlinks({
@@ -595,7 +573,7 @@ async function copyTreeWithoutSymlinks(params) {
595
573
  return;
596
574
  }
597
575
  if (stats.isFile()) {
598
- await runLimitedFs(async () => await fsPromises.mkdir(path.dirname(params.targetPath), { recursive: true }));
576
+ await runLimitedFs(fsPromises.mkdir, path.dirname(params.targetPath), { recursive: true });
599
577
  await runLimitedFs(async () => await fsPromises.copyFile(params.sourcePath, params.targetPath));
600
578
  }
601
579
  }
@@ -606,10 +584,10 @@ async function replaceDirectoryContents(params) {
606
584
  await Promise.all(existing.filter((entry) => !isExcluded(entry)).map(async (entry) => {
607
585
  const targetPath = path.join(params.targetDir, entry);
608
586
  if ((await lstatIfExists(targetPath))?.isSymbolicLink()) return;
609
- await runLimitedFs(async () => await fsPromises.rm(targetPath, {
587
+ await runLimitedFs(fsPromises.rm, targetPath, {
610
588
  recursive: true,
611
589
  force: true
612
- }));
590
+ });
613
591
  }));
614
592
  const sourceEntries = await fsPromises.readdir(params.sourceDir);
615
593
  for (const entry of sourceEntries) {
@@ -0,0 +1,136 @@
1
+ export type LimitFunction = {
2
+ /**
3
+ The number of promises that are currently running.
4
+ */
5
+ readonly activeCount: number;
6
+
7
+ /**
8
+ The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
9
+ */
10
+ readonly pendingCount: number;
11
+
12
+ /**
13
+ Get or set the concurrency limit.
14
+ */
15
+ concurrency: number;
16
+
17
+ /**
18
+ Discard pending promises that are waiting to run.
19
+
20
+ This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
21
+
22
+ Note: This does not cancel promises that are already running.
23
+
24
+ When `rejectOnClear` is enabled, pending promises are rejected with an `AbortError`.
25
+ This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
26
+ */
27
+ clearQueue: () => void;
28
+
29
+ /**
30
+ Process an iterable of inputs with limited concurrency.
31
+
32
+ The mapper function receives the item value and its index.
33
+
34
+ This is a convenience function for processing inputs that arrive in batches. For more complex use cases, see [p-map](https://github.com/sindresorhus/p-map).
35
+
36
+ @param iterable - An iterable containing an argument for the given function.
37
+ @param mapperFunction - Promise-returning/async function.
38
+ @returns A promise equivalent to `Promise.all(Array.from(iterable, (item, index) => limit(mapperFunction, item, index)))`.
39
+ */
40
+ map: <Input, ReturnType> (
41
+ iterable: Iterable<Input>,
42
+ mapperFunction: (input: Input, index: number) => PromiseLike<ReturnType> | ReturnType
43
+ ) => Promise<ReturnType[]>;
44
+
45
+ /**
46
+ @param fn - Promise-returning/async function.
47
+ @param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions.
48
+
49
+ Warning: Avoid calling the same `limit` function inside a function that is already limited by it. This can create a deadlock where inner tasks never run. Use a separate limiter for inner tasks.
50
+
51
+ @returns The promise returned by calling `fn(...arguments)`.
52
+ */
53
+ <Arguments extends unknown[], ReturnType>(
54
+ function_: (...arguments_: Arguments) => PromiseLike<ReturnType> | ReturnType,
55
+ ...arguments_: Arguments
56
+ ): Promise<ReturnType>;
57
+ };
58
+
59
+ /**
60
+ Run multiple promise-returning & async functions with limited concurrency.
61
+
62
+ @param concurrency - Concurrency limit. Minimum: `1`. You can pass a number or an options object with a `concurrency` property.
63
+ @returns A `limit` function.
64
+
65
+ @example
66
+ ```
67
+ import pLimit from 'p-limit';
68
+
69
+ const limit = pLimit(1);
70
+
71
+ const input = [
72
+ limit(() => fetchSomething('foo')),
73
+ limit(() => fetchSomething('bar')),
74
+ limit(() => doSomething())
75
+ ];
76
+
77
+ // Only one promise is run at once
78
+ const result = await Promise.all(input);
79
+ console.log(result);
80
+ ```
81
+
82
+ @example
83
+ ```
84
+ import pLimit from 'p-limit';
85
+
86
+ const limit = pLimit({concurrency: 1});
87
+ ```
88
+ */
89
+ export default function pLimit(concurrency: number | Options): LimitFunction;
90
+
91
+ export type Options = {
92
+ /**
93
+ Concurrency limit.
94
+
95
+ Minimum: `1`.
96
+ */
97
+ readonly concurrency: number;
98
+
99
+ /**
100
+ Reject pending promises with an `AbortError` when `clearQueue()` is called.
101
+
102
+ Default: `false`.
103
+
104
+ This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
105
+ */
106
+ readonly rejectOnClear?: boolean;
107
+ };
108
+
109
+ /**
110
+ Returns a function with limited concurrency.
111
+
112
+ The returned function manages its own concurrent executions, allowing you to call it multiple times without exceeding the specified concurrency limit.
113
+
114
+ Ideal for scenarios where you need to control the number of simultaneous executions of a single function, rather than managing concurrency across multiple functions.
115
+
116
+ @param function_ - Promise-returning/async function.
117
+ @return Function with limited concurrency.
118
+
119
+ @example
120
+ ```
121
+ import {limitFunction} from 'p-limit';
122
+
123
+ const limitedFunction = limitFunction(async () => {
124
+ return doSomething();
125
+ }, {concurrency: 1});
126
+
127
+ const input = Array.from({length: 10}, limitedFunction);
128
+
129
+ // Only one promise is run at once.
130
+ await Promise.all(input);
131
+ ```
132
+ */
133
+ export function limitFunction<Arguments extends unknown[], ReturnType>(
134
+ function_: (...arguments_: Arguments) => PromiseLike<ReturnType>,
135
+ options: Options
136
+ ): (...arguments_: Arguments) => Promise<ReturnType>;
@@ -0,0 +1,127 @@
1
+ import Queue from 'yocto-queue';
2
+
3
+ export default function pLimit(concurrency) {
4
+ let rejectOnClear = false;
5
+
6
+ if (typeof concurrency === 'object') {
7
+ ({concurrency, rejectOnClear = false} = concurrency);
8
+ }
9
+
10
+ validateConcurrency(concurrency);
11
+
12
+ if (typeof rejectOnClear !== 'boolean') {
13
+ throw new TypeError('Expected `rejectOnClear` to be a boolean');
14
+ }
15
+
16
+ const queue = new Queue();
17
+ let activeCount = 0;
18
+
19
+ const resumeNext = () => {
20
+ // Process the next queued function if we're under the concurrency limit
21
+ if (activeCount < concurrency && queue.size > 0) {
22
+ activeCount++;
23
+ queue.dequeue().run();
24
+ }
25
+ };
26
+
27
+ const next = () => {
28
+ activeCount--;
29
+ resumeNext();
30
+ };
31
+
32
+ const run = async (function_, resolve, arguments_) => {
33
+ // Execute the function and capture the result promise
34
+ const result = (async () => function_(...arguments_))();
35
+
36
+ // Resolve immediately with the promise (don't wait for completion)
37
+ resolve(result);
38
+
39
+ // Wait for the function to complete (success or failure)
40
+ // We catch errors here to prevent unhandled rejections,
41
+ // but the original promise rejection is preserved for the caller
42
+ try {
43
+ await result;
44
+ } catch {}
45
+
46
+ // Decrement active count and process next queued function
47
+ next();
48
+ };
49
+
50
+ const enqueue = (function_, resolve, reject, arguments_) => {
51
+ const queueItem = {reject};
52
+
53
+ // Queue the internal resolve function instead of the run function
54
+ // to preserve the asynchronous execution context.
55
+ new Promise(internalResolve => { // eslint-disable-line promise/param-names
56
+ queueItem.run = internalResolve;
57
+ queue.enqueue(queueItem);
58
+ }).then(run.bind(undefined, function_, resolve, arguments_)); // eslint-disable-line promise/prefer-await-to-then
59
+
60
+ // Start processing immediately if we haven't reached the concurrency limit
61
+ if (activeCount < concurrency) {
62
+ resumeNext();
63
+ }
64
+ };
65
+
66
+ const generator = (function_, ...arguments_) => new Promise((resolve, reject) => {
67
+ enqueue(function_, resolve, reject, arguments_);
68
+ });
69
+
70
+ Object.defineProperties(generator, {
71
+ activeCount: {
72
+ get: () => activeCount,
73
+ },
74
+ pendingCount: {
75
+ get: () => queue.size,
76
+ },
77
+ clearQueue: {
78
+ value() {
79
+ if (!rejectOnClear) {
80
+ queue.clear();
81
+ return;
82
+ }
83
+
84
+ const abortError = AbortSignal.abort().reason;
85
+
86
+ while (queue.size > 0) {
87
+ queue.dequeue().reject(abortError);
88
+ }
89
+ },
90
+ },
91
+ concurrency: {
92
+ get: () => concurrency,
93
+
94
+ set(newConcurrency) {
95
+ validateConcurrency(newConcurrency);
96
+ concurrency = newConcurrency;
97
+
98
+ queueMicrotask(() => {
99
+ // eslint-disable-next-line no-unmodified-loop-condition
100
+ while (activeCount < concurrency && queue.size > 0) {
101
+ resumeNext();
102
+ }
103
+ });
104
+ },
105
+ },
106
+ map: {
107
+ async value(iterable, function_) {
108
+ const promises = Array.from(iterable, (value, index) => this(function_, value, index));
109
+ return Promise.all(promises);
110
+ },
111
+ },
112
+ });
113
+
114
+ return generator;
115
+ }
116
+
117
+ export function limitFunction(function_, options) {
118
+ const limit = pLimit(options);
119
+
120
+ return (...arguments_) => limit(() => function_(...arguments_));
121
+ }
122
+
123
+ function validateConcurrency(concurrency) {
124
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
125
+ throw new TypeError('Expected `concurrency` to be a number from 1 and up');
126
+ }
127
+ }
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "p-limit",
3
+ "version": "7.3.0",
4
+ "description": "Run multiple promise-returning & async functions with limited concurrency",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/p-limit",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "author": {
9
+ "name": "Sindre Sorhus",
10
+ "email": "sindresorhus@gmail.com",
11
+ "url": "https://sindresorhus.com"
12
+ },
13
+ "type": "module",
14
+ "exports": {
15
+ "types": "./index.d.ts",
16
+ "default": "./index.js"
17
+ },
18
+ "sideEffects": false,
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "scripts": {
23
+ "test": "xo && ava && tsd",
24
+ "benchmark": "node benchmark.js"
25
+ },
26
+ "files": [
27
+ "index.js",
28
+ "index.d.ts"
29
+ ],
30
+ "keywords": [
31
+ "promise",
32
+ "limit",
33
+ "limited",
34
+ "concurrency",
35
+ "throttle",
36
+ "throat",
37
+ "rate",
38
+ "batch",
39
+ "ratelimit",
40
+ "task",
41
+ "queue",
42
+ "async",
43
+ "await",
44
+ "promises",
45
+ "bluebird"
46
+ ],
47
+ "dependencies": {
48
+ "yocto-queue": "^1.2.1"
49
+ },
50
+ "devDependencies": {
51
+ "ava": "^6.4.1",
52
+ "in-range": "^3.0.0",
53
+ "random-int": "^3.0.0",
54
+ "time-span": "^5.1.0",
55
+ "tsd": "^0.33.0",
56
+ "xo": "^1.2.1"
57
+ }
58
+ }
@@ -0,0 +1,173 @@
1
+ # p-limit
2
+
3
+ > Run multiple promise-returning & async functions with limited concurrency
4
+
5
+ *Works in Node.js and browsers.*
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install p-limit
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ import pLimit from 'p-limit';
17
+
18
+ const limit = pLimit(1);
19
+
20
+ const input = [
21
+ limit(() => fetchSomething('foo')),
22
+ limit(() => fetchSomething('bar')),
23
+ limit(() => doSomething())
24
+ ];
25
+
26
+ // Only one promise is run at once
27
+ const result = await Promise.all(input);
28
+ console.log(result);
29
+ ```
30
+
31
+ ## API
32
+
33
+ ### pLimit(concurrency) <sup>default export</sup>
34
+
35
+ Returns a `limit` function.
36
+
37
+ #### concurrency
38
+
39
+ Type: `number | object`\
40
+ Minimum: `1`
41
+
42
+ Concurrency limit.
43
+
44
+ You can pass a number or an options object with a `concurrency` property.
45
+
46
+ #### rejectOnClear
47
+
48
+ Type: `boolean`\
49
+ Default: `false`
50
+
51
+ Reject pending promises with an `AbortError` when `clearQueue()` is called.
52
+ This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
53
+
54
+ ```js
55
+ import pLimit from 'p-limit';
56
+
57
+ const limit = pLimit({concurrency: 1});
58
+ ```
59
+
60
+ ### limit(fn, ...args)
61
+
62
+ Returns the promise returned by calling `fn(...args)`.
63
+
64
+ #### fn
65
+
66
+ Type: `Function`
67
+
68
+ Promise-returning/async function.
69
+
70
+ #### args
71
+
72
+ Any arguments to pass through to `fn`.
73
+
74
+ Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions.
75
+
76
+ Warning: Avoid calling the same `limit` function inside a function that is already limited by it. This can create a deadlock where inner tasks never run. Use a separate limiter for inner tasks.
77
+
78
+ ### limit.map(iterable, mapperFunction)
79
+
80
+ Process an iterable of inputs with limited concurrency.
81
+
82
+ The mapper function receives the item value and its index.
83
+
84
+ Returns a promise equivalent to `Promise.all(Array.from(iterable, (item, index) => limit(mapperFunction, item, index)))`.
85
+
86
+ This is a convenience function for processing inputs that arrive in batches. For more complex use cases, see [p-map](https://github.com/sindresorhus/p-map).
87
+
88
+ ### limit.activeCount
89
+
90
+ The number of promises that are currently running.
91
+
92
+ ### limit.pendingCount
93
+
94
+ The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
95
+
96
+ ### limit.clearQueue()
97
+
98
+ Discard pending promises that are waiting to run.
99
+
100
+ This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
101
+
102
+ Note: This does not cancel promises that are already running.
103
+
104
+ When `rejectOnClear` is enabled, pending promises are rejected with an `AbortError`.
105
+ This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
106
+
107
+ ### limit.concurrency
108
+
109
+ Get or set the concurrency limit.
110
+
111
+ ### limitFunction(fn, options) <sup>named export</sup>
112
+
113
+ Returns a function with limited concurrency.
114
+
115
+ The returned function manages its own concurrent executions, allowing you to call it multiple times without exceeding the specified concurrency limit.
116
+
117
+ Ideal for scenarios where you need to control the number of simultaneous executions of a single function, rather than managing concurrency across multiple functions.
118
+
119
+ ```js
120
+ import {limitFunction} from 'p-limit';
121
+
122
+ const limitedFunction = limitFunction(async () => {
123
+ return doSomething();
124
+ }, {concurrency: 1});
125
+
126
+ const input = Array.from({length: 10}, limitedFunction);
127
+
128
+ // Only one promise is run at once.
129
+ await Promise.all(input);
130
+ ```
131
+
132
+ #### fn
133
+
134
+ Type: `Function`
135
+
136
+ Promise-returning/async function.
137
+
138
+ #### options
139
+
140
+ Type: `object`
141
+
142
+ #### concurrency
143
+
144
+ Type: `number`\
145
+ Minimum: `1`
146
+
147
+ Concurrency limit.
148
+
149
+ #### rejectOnClear
150
+
151
+ Type: `boolean`\
152
+ Default: `false`
153
+
154
+ Reject pending promises with an `AbortError` when `clearQueue()` is called.
155
+ This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
156
+
157
+ ## Recipes
158
+
159
+ See [recipes.md](recipes.md) for common use cases and patterns.
160
+
161
+ ## FAQ
162
+
163
+ ### How is this different from the [`p-queue`](https://github.com/sindresorhus/p-queue) package?
164
+
165
+ This package is only about limiting the number of concurrent executions, while `p-queue` is a fully featured queue implementation with lots of different options, introspection, and ability to pause the queue.
166
+
167
+ ## Related
168
+
169
+ - [p-throttle](https://github.com/sindresorhus/p-throttle) - Throttle promise-returning & async functions
170
+ - [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions
171
+ - [p-map](https://github.com/sindresorhus/p-map) - Run promise-returning & async functions concurrently with different inputs
172
+ - [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
173
+ - [More…](https://github.com/sindresorhus/promise-fun)
@@ -0,0 +1,75 @@
1
+ export default class Queue<ValueType> implements Iterable<ValueType> {
2
+ /**
3
+ The size of the queue.
4
+ */
5
+ readonly size: number;
6
+
7
+ /**
8
+ Tiny queue data structure.
9
+
10
+ The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a β€œfor…of” loop, or use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
11
+
12
+ @example
13
+ ```
14
+ import Queue from 'yocto-queue';
15
+
16
+ const queue = new Queue();
17
+
18
+ queue.enqueue('πŸ¦„');
19
+ queue.enqueue('🌈');
20
+
21
+ console.log(queue.size);
22
+ //=> 2
23
+
24
+ console.log(...queue);
25
+ //=> 'πŸ¦„ 🌈'
26
+
27
+ console.log(queue.dequeue());
28
+ //=> 'πŸ¦„'
29
+
30
+ console.log(queue.dequeue());
31
+ //=> '🌈'
32
+ ```
33
+ */
34
+ constructor();
35
+
36
+ /**
37
+ The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a β€œfor…of” loop. Using the iterator will not remove the items from the queue. If you want that, use `drain()` instead.
38
+
39
+ You can also use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
40
+ */
41
+ [Symbol.iterator](): IterableIterator<ValueType>;
42
+
43
+ /**
44
+ Returns an iterator that dequeues items as you consume it.
45
+
46
+ This allows you to empty the queue while processing its items.
47
+
48
+ If you want to not remove items as you consume it, use the `Queue` object as an iterator.
49
+ */
50
+ drain(): IterableIterator<ValueType>;
51
+
52
+ /**
53
+ Add a value to the queue.
54
+ */
55
+ enqueue(value: ValueType): void;
56
+
57
+ /**
58
+ Remove the next value in the queue.
59
+
60
+ @returns The removed value or `undefined` if the queue is empty.
61
+ */
62
+ dequeue(): ValueType | undefined;
63
+
64
+ /**
65
+ Get the next value in the queue without removing it.
66
+
67
+ @returns The value or `undefined` if the queue is empty.
68
+ */
69
+ peek(): ValueType | undefined;
70
+
71
+ /**
72
+ Clear the queue.
73
+ */
74
+ clear(): void;
75
+ }
@@ -0,0 +1,90 @@
1
+ /*
2
+ How it works:
3
+ `this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
4
+ */
5
+
6
+ class Node {
7
+ value;
8
+ next;
9
+
10
+ constructor(value) {
11
+ this.value = value;
12
+ }
13
+ }
14
+
15
+ export default class Queue {
16
+ #head;
17
+ #tail;
18
+ #size;
19
+
20
+ constructor() {
21
+ this.clear();
22
+ }
23
+
24
+ enqueue(value) {
25
+ const node = new Node(value);
26
+
27
+ if (this.#head) {
28
+ this.#tail.next = node;
29
+ this.#tail = node;
30
+ } else {
31
+ this.#head = node;
32
+ this.#tail = node;
33
+ }
34
+
35
+ this.#size++;
36
+ }
37
+
38
+ dequeue() {
39
+ const current = this.#head;
40
+ if (!current) {
41
+ return;
42
+ }
43
+
44
+ this.#head = this.#head.next;
45
+ this.#size--;
46
+
47
+ // Clean up tail reference when queue becomes empty
48
+ if (!this.#head) {
49
+ this.#tail = undefined;
50
+ }
51
+
52
+ return current.value;
53
+ }
54
+
55
+ peek() {
56
+ if (!this.#head) {
57
+ return;
58
+ }
59
+
60
+ return this.#head.value;
61
+
62
+ // TODO: Node.js 18.
63
+ // return this.#head?.value;
64
+ }
65
+
66
+ clear() {
67
+ this.#head = undefined;
68
+ this.#tail = undefined;
69
+ this.#size = 0;
70
+ }
71
+
72
+ get size() {
73
+ return this.#size;
74
+ }
75
+
76
+ * [Symbol.iterator]() {
77
+ let current = this.#head;
78
+
79
+ while (current) {
80
+ yield current.value;
81
+ current = current.next;
82
+ }
83
+ }
84
+
85
+ * drain() {
86
+ while (this.#head) {
87
+ yield this.dequeue();
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "yocto-queue",
3
+ "version": "1.2.2",
4
+ "description": "Tiny queue data structure",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/yocto-queue",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "author": {
9
+ "name": "Sindre Sorhus",
10
+ "email": "sindresorhus@gmail.com",
11
+ "url": "https://sindresorhus.com"
12
+ },
13
+ "type": "module",
14
+ "exports": "./index.js",
15
+ "types": "./index.d.ts",
16
+ "sideEffects": false,
17
+ "engines": {
18
+ "node": ">=12.20"
19
+ },
20
+ "scripts": {
21
+ "//test": "xo && ava && tsd",
22
+ "test": "ava && tsd"
23
+ },
24
+ "files": [
25
+ "index.js",
26
+ "index.d.ts"
27
+ ],
28
+ "keywords": [
29
+ "queue",
30
+ "data",
31
+ "structure",
32
+ "algorithm",
33
+ "queues",
34
+ "queuing",
35
+ "list",
36
+ "array",
37
+ "linkedlist",
38
+ "fifo",
39
+ "enqueue",
40
+ "dequeue",
41
+ "data-structure"
42
+ ],
43
+ "devDependencies": {
44
+ "ava": "^3.15.0",
45
+ "tsd": "^0.17.0",
46
+ "xo": "^0.44.0"
47
+ }
48
+ }
@@ -0,0 +1,80 @@
1
+ # yocto-queue [![](https://badgen.net/bundlephobia/minzip/yocto-queue)](https://bundlephobia.com/result?p=yocto-queue)
2
+
3
+ > Tiny queue data structure
4
+
5
+ You should use this package instead of an array if you do a lot of `Array#push()` and `Array#shift()` on large arrays, since `Array#shift()` has [linear time complexity](https://medium.com/@ariel.salem1989/an-easy-to-use-guide-to-big-o-time-complexity-5dcf4be8a444#:~:text=O(N)%E2%80%94Linear%20Time) *O(n)* while `Queue#dequeue()` has [constant time complexity](https://medium.com/@ariel.salem1989/an-easy-to-use-guide-to-big-o-time-complexity-5dcf4be8a444#:~:text=O(1)%20%E2%80%94%20Constant%20Time) *O(1)*. That makes a huge difference for large arrays.
6
+
7
+ > A [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) is an ordered list of elements where an element is inserted at the end of the queue and is removed from the front of the queue. A queue works based on the first-in, first-out ([FIFO](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics))) principle.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install yocto-queue
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```js
18
+ import Queue from 'yocto-queue';
19
+
20
+ const queue = new Queue();
21
+
22
+ queue.enqueue('πŸ¦„');
23
+ queue.enqueue('🌈');
24
+
25
+ console.log(queue.size);
26
+ //=> 2
27
+
28
+ console.log(...queue);
29
+ //=> 'πŸ¦„ 🌈'
30
+
31
+ console.log(queue.dequeue());
32
+ //=> 'πŸ¦„'
33
+
34
+ console.log(queue.dequeue());
35
+ //=> '🌈'
36
+ ```
37
+
38
+ ## API
39
+
40
+ ### `queue = new Queue()`
41
+
42
+ The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a β€œfor…of” loop. Using the iterator will not remove the items from the queue. If you want that, use [`drain()`](#drain) instead.
43
+
44
+ You can also use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
45
+
46
+ #### `.enqueue(value)`
47
+
48
+ Add a value to the queue.
49
+
50
+ #### `.dequeue()`
51
+
52
+ Remove the next value in the queue.
53
+
54
+ Returns the removed value or `undefined` if the queue is empty.
55
+
56
+ #### `.peek()`
57
+
58
+ Get the next value in the queue without removing it.
59
+
60
+ Returns the value or `undefined` if the queue is empty.
61
+
62
+ #### `.drain()`
63
+
64
+ Returns an iterator that dequeues items as you consume it.
65
+
66
+ This allows you to empty the queue while processing its items.
67
+
68
+ If you want to not remove items as you consume it, use the `Queue` object as an iterator.
69
+
70
+ #### `.clear()`
71
+
72
+ Clear the queue.
73
+
74
+ #### `.size`
75
+
76
+ The size of the queue.
77
+
78
+ ## Related
79
+
80
+ - [quick-lru](https://github.com/sindresorhus/quick-lru) - Simple β€œLeast Recently Used” (LRU) cache
@@ -1,16 +1,44 @@
1
1
  {
2
2
  "name": "@openclaw/openshell-sandbox",
3
- "version": "2026.7.1-beta.6",
3
+ "version": "2026.7.2-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/openshell-sandbox",
9
- "version": "2026.7.1-beta.6",
9
+ "version": "2026.7.2-beta.1",
10
10
  "dependencies": {
11
+ "p-limit": "7.3.0",
11
12
  "zod": "4.4.3"
12
13
  }
13
14
  },
15
+ "node_modules/p-limit": {
16
+ "version": "7.3.0",
17
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-7.3.0.tgz",
18
+ "integrity": "sha512-7cIXg/Z0M5WZRblrsOla88S4wAK+zOQQWeBYfV3qJuJXMr+LnbYjaadrFaS0JILfEDPVqHyKnZ1Z/1d6J9VVUw==",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "yocto-queue": "^1.2.1"
22
+ },
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "funding": {
27
+ "url": "https://github.com/sponsors/sindresorhus"
28
+ }
29
+ },
30
+ "node_modules/yocto-queue": {
31
+ "version": "1.2.2",
32
+ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.2.tgz",
33
+ "integrity": "sha512-4LCcse/U2MHZ63HAJVE+v71o7yOdIe4cZ70Wpf8D/IyjDKYQLV5GD46B+hSTjJsvV5PztjvHoU580EftxjDZFQ==",
34
+ "license": "MIT",
35
+ "engines": {
36
+ "node": ">=12.20"
37
+ },
38
+ "funding": {
39
+ "url": "https://github.com/sponsors/sindresorhus"
40
+ }
41
+ },
14
42
  "node_modules/zod": {
15
43
  "version": "4.4.3",
16
44
  "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/openshell-sandbox",
3
- "version": "2026.7.1-beta.6",
3
+ "version": "2026.7.2-beta.1",
4
4
  "description": "OpenClaw sandbox backend for the NVIDIA OpenShell CLI with mirrored local workspaces and SSH command execution.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "type": "module",
10
10
  "dependencies": {
11
+ "p-limit": "7.3.0",
11
12
  "zod": "4.4.3"
12
13
  },
13
14
  "openclaw": {
@@ -20,10 +21,10 @@
20
21
  "minHostVersion": ">=2026.5.12-beta.1"
21
22
  },
22
23
  "compat": {
23
- "pluginApi": ">=2026.7.1-beta.6"
24
+ "pluginApi": ">=2026.7.2-beta.1"
24
25
  },
25
26
  "build": {
26
- "openclawVersion": "2026.7.1-beta.6",
27
+ "openclawVersion": "2026.7.2-beta.1",
27
28
  "bundledDist": false
28
29
  },
29
30
  "release": {
@@ -41,7 +42,7 @@
41
42
  "README.md"
42
43
  ],
43
44
  "peerDependencies": {
44
- "openclaw": ">=2026.7.1-beta.6"
45
+ "openclaw": ">=2026.7.2-beta.1"
45
46
  },
46
47
  "peerDependenciesMeta": {
47
48
  "openclaw": {
@@ -49,6 +50,7 @@
49
50
  }
50
51
  },
51
52
  "bundledDependencies": [
53
+ "p-limit",
52
54
  "zod"
53
55
  ]
54
56
  }