@poe-platform/safe-bash 0.1.41 → 0.1.42

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 (134) hide show
  1. package/README.md +11 -2
  2. package/dist/safe-bash/browser.d.ts +5 -0
  3. package/dist/safe-bash/browser.d.ts.map +1 -1
  4. package/dist/safe-bash/browser.js +878 -122
  5. package/dist/safe-bash/browser.js.map +4 -4
  6. package/dist/safe-bash/commands/apply-patch/shared.js +2 -2
  7. package/dist/safe-bash/commands/apply-patch/shared.js.map +1 -1
  8. package/dist/safe-bash/commands/archive/internal.d.ts.map +1 -1
  9. package/dist/safe-bash/commands/archive/internal.js +3 -2
  10. package/dist/safe-bash/commands/archive/internal.js.map +1 -1
  11. package/dist/safe-bash/commands/bytes/checksums/index.d.ts.map +1 -1
  12. package/dist/safe-bash/commands/bytes/checksums/index.js +3 -2
  13. package/dist/safe-bash/commands/bytes/checksums/index.js.map +1 -1
  14. package/dist/safe-bash/commands/bytes/compression/gunzip.js +2 -2
  15. package/dist/safe-bash/commands/bytes/compression/gunzip.js.map +1 -1
  16. package/dist/safe-bash/commands/bytes/compression/stream.js +2 -2
  17. package/dist/safe-bash/commands/bytes/compression/stream.js.map +1 -1
  18. package/dist/safe-bash/commands/bytes/encoding/shared.js +3 -3
  19. package/dist/safe-bash/commands/bytes/encoding/shared.js.map +1 -1
  20. package/dist/safe-bash/commands/column/internal.d.ts.map +1 -1
  21. package/dist/safe-bash/commands/column/internal.js +2 -1
  22. package/dist/safe-bash/commands/column/internal.js.map +1 -1
  23. package/dist/safe-bash/commands/diff-patch/shared.js +2 -2
  24. package/dist/safe-bash/commands/diff-patch/shared.js.map +1 -1
  25. package/dist/safe-bash/commands/du/budget.d.ts.map +1 -1
  26. package/dist/safe-bash/commands/du/budget.js +3 -2
  27. package/dist/safe-bash/commands/du/budget.js.map +1 -1
  28. package/dist/safe-bash/commands/env-split.d.ts.map +1 -1
  29. package/dist/safe-bash/commands/env-split.js +2 -1
  30. package/dist/safe-bash/commands/env-split.js.map +1 -1
  31. package/dist/safe-bash/commands/expr/internal.d.ts.map +1 -1
  32. package/dist/safe-bash/commands/expr/internal.js +2 -1
  33. package/dist/safe-bash/commands/expr/internal.js.map +1 -1
  34. package/dist/safe-bash/commands/file/shared.d.ts.map +1 -1
  35. package/dist/safe-bash/commands/file/shared.js +3 -2
  36. package/dist/safe-bash/commands/file/shared.js.map +1 -1
  37. package/dist/safe-bash/commands/find.d.ts.map +1 -1
  38. package/dist/safe-bash/commands/find.js +12 -31
  39. package/dist/safe-bash/commands/find.js.map +1 -1
  40. package/dist/safe-bash/commands/html-to-markdown/budget.js +2 -2
  41. package/dist/safe-bash/commands/html-to-markdown/budget.js.map +1 -1
  42. package/dist/safe-bash/commands/metadata/internal.d.ts.map +1 -1
  43. package/dist/safe-bash/commands/metadata/internal.js +2 -1
  44. package/dist/safe-bash/commands/metadata/internal.js.map +1 -1
  45. package/dist/safe-bash/commands/move.d.ts.map +1 -1
  46. package/dist/safe-bash/commands/move.js +2 -1
  47. package/dist/safe-bash/commands/move.js.map +1 -1
  48. package/dist/safe-bash/commands/network/authorizer.d.ts +7 -0
  49. package/dist/safe-bash/commands/network/authorizer.d.ts.map +1 -0
  50. package/dist/safe-bash/commands/network/authorizer.js +48 -0
  51. package/dist/safe-bash/commands/network/authorizer.js.map +1 -0
  52. package/dist/safe-bash/commands/network/body.js +2 -2
  53. package/dist/safe-bash/commands/network/body.js.map +1 -1
  54. package/dist/safe-bash/commands/network/curl.js +2 -2
  55. package/dist/safe-bash/commands/network/curl.js.map +1 -1
  56. package/dist/safe-bash/commands/network/fetch-transport.d.ts +6 -0
  57. package/dist/safe-bash/commands/network/fetch-transport.d.ts.map +1 -0
  58. package/dist/safe-bash/commands/network/fetch-transport.js +80 -0
  59. package/dist/safe-bash/commands/network/fetch-transport.js.map +1 -0
  60. package/dist/safe-bash/commands/network/index.d.ts +2 -0
  61. package/dist/safe-bash/commands/network/index.d.ts.map +1 -1
  62. package/dist/safe-bash/commands/network/index.js +2 -0
  63. package/dist/safe-bash/commands/network/index.js.map +1 -1
  64. package/dist/safe-bash/commands/network/types.d.ts +1 -0
  65. package/dist/safe-bash/commands/network/types.d.ts.map +1 -1
  66. package/dist/safe-bash/commands/network/types.js +10 -0
  67. package/dist/safe-bash/commands/network/types.js.map +1 -1
  68. package/dist/safe-bash/commands/regex-execution/ere/limits.js +2 -2
  69. package/dist/safe-bash/commands/regex-execution/ere/limits.js.map +1 -1
  70. package/dist/safe-bash/commands/safejs/io.js +2 -2
  71. package/dist/safe-bash/commands/safejs/io.js.map +1 -1
  72. package/dist/safe-bash/commands/search/shared.js +2 -2
  73. package/dist/safe-bash/commands/search/shared.js.map +1 -1
  74. package/dist/safe-bash/commands/split/io.js +2 -2
  75. package/dist/safe-bash/commands/split/io.js.map +1 -1
  76. package/dist/safe-bash/commands/stream-format/shared.d.ts.map +1 -1
  77. package/dist/safe-bash/commands/stream-format/shared.js +2 -1
  78. package/dist/safe-bash/commands/stream-format/shared.js.map +1 -1
  79. package/dist/safe-bash/commands/stream-inspection/shared.d.ts.map +1 -1
  80. package/dist/safe-bash/commands/stream-inspection/shared.js +2 -1
  81. package/dist/safe-bash/commands/stream-inspection/shared.js.map +1 -1
  82. package/dist/safe-bash/commands/structured/limits.js +2 -2
  83. package/dist/safe-bash/commands/structured/limits.js.map +1 -1
  84. package/dist/safe-bash/commands/table-text/internal.d.ts.map +1 -1
  85. package/dist/safe-bash/commands/table-text/internal.js +2 -1
  86. package/dist/safe-bash/commands/table-text/internal.js.map +1 -1
  87. package/dist/safe-bash/commands/text-programs/shared.js +2 -2
  88. package/dist/safe-bash/commands/text-programs/shared.js.map +1 -1
  89. package/dist/safe-bash/commands/tree/io.js +2 -2
  90. package/dist/safe-bash/commands/tree/io.js.map +1 -1
  91. package/dist/safe-bash/contracts/yield.d.ts +13 -0
  92. package/dist/safe-bash/contracts/yield.d.ts.map +1 -0
  93. package/dist/safe-bash/contracts/yield.js +41 -0
  94. package/dist/safe-bash/contracts/yield.js.map +1 -0
  95. package/dist/safe-bash/shell/arithmetic.js +1 -1
  96. package/dist/safe-bash/shell/arithmetic.js.map +1 -1
  97. package/dist/safe-bash/shell/arrays/ledger.d.ts.map +1 -1
  98. package/dist/safe-bash/shell/arrays/ledger.js +2 -9
  99. package/dist/safe-bash/shell/arrays/ledger.js.map +1 -1
  100. package/dist/safe-bash/shell/conditional.d.ts.map +1 -1
  101. package/dist/safe-bash/shell/conditional.js +2 -1
  102. package/dist/safe-bash/shell/conditional.js.map +1 -1
  103. package/dist/safe-bash/shell/env-warning.d.ts +2 -0
  104. package/dist/safe-bash/shell/env-warning.d.ts.map +1 -0
  105. package/dist/safe-bash/shell/env-warning.js +18 -0
  106. package/dist/safe-bash/shell/env-warning.js.map +1 -0
  107. package/dist/safe-bash/shell/index.d.ts +1 -0
  108. package/dist/safe-bash/shell/index.d.ts.map +1 -1
  109. package/dist/safe-bash/shell/index.js +1 -0
  110. package/dist/safe-bash/shell/index.js.map +1 -1
  111. package/dist/safe-bash/shell/input.d.ts.map +1 -1
  112. package/dist/safe-bash/shell/input.js +4 -3
  113. package/dist/safe-bash/shell/input.js.map +1 -1
  114. package/dist/safe-bash/shell/parser.d.ts.map +1 -1
  115. package/dist/safe-bash/shell/parser.js +15 -1
  116. package/dist/safe-bash/shell/parser.js.map +1 -1
  117. package/dist/safe-bash/shell/pattern.d.ts.map +1 -1
  118. package/dist/safe-bash/shell/pattern.js +3 -2
  119. package/dist/safe-bash/shell/pattern.js.map +1 -1
  120. package/dist/safe-bash/shell/runtime.d.ts +3 -2
  121. package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
  122. package/dist/safe-bash/shell/runtime.js +57 -55
  123. package/dist/safe-bash/shell/runtime.js.map +1 -1
  124. package/dist/safe-bash/shell/shell.d.ts.map +1 -1
  125. package/dist/safe-bash/shell/shell.js +4 -1
  126. package/dist/safe-bash/shell/shell.js.map +1 -1
  127. package/dist/safe-bash/shell/types.d.ts +2 -0
  128. package/dist/safe-bash/shell/types.d.ts.map +1 -1
  129. package/dist/safe-bash/shell/types.js.map +1 -1
  130. package/dist/safe-bash/shell/worker-limits.d.ts +3 -0
  131. package/dist/safe-bash/shell/worker-limits.d.ts.map +1 -0
  132. package/dist/safe-bash/shell/worker-limits.js +14 -0
  133. package/dist/safe-bash/shell/worker-limits.js.map +1 -0
  134. package/package.json +2 -2
package/README.md CHANGED
@@ -121,7 +121,7 @@ These plugins are separate from `agentCommands()`; pass them to `shell.use(...)`
121
121
 
122
122
  | Command | Plugin and configuration |
123
123
  | --- | --- |
124
- | `curl` | `networkCommands({ authorize, transport?, limits?, replace? })`: required authorization on every request, redirect, and retry. The default transport makes real HTTP(S) requests; inject `transport` for mocks. [Options and limits](src/commands/network/types.ts). |
124
+ | `curl` | `networkCommands({ authorize, transport?, limits?, replace? })`: required authorization on every request, redirect, and retry. Node uses the native HTTP transport; Workers can inject `createFetchTransport()`. `createOriginAuthorizer([...])` provides exact origin/hostname policy; its omitted allowlist is deliberately `*` (allow all). [Options and limits](src/commands/network/types.ts). |
125
125
  | `node` | `nodeCommands({ runtime, limits?, replace? })`: runs JavaScript with an injected SafeJS runtime, virtual files, and shell streams. [Usage and supported subset](src/commands/node/README.md). |
126
126
  | `safejs` | `safeJsCommands({ runtime, limits?, replace? })`: inject `run`, `createBudget`, `makeFsModule`, and `declareHostOperation` to execute programs. [Runtime contract](src/commands/safejs/types.ts). |
127
127
 
@@ -271,7 +271,7 @@ For SafeJS host integration, `makeSafeJsShellModule` exposes shell execution and
271
271
  | --- | --- |
272
272
  | `fs` | Required filesystem; no implicit host access. |
273
273
  | `cwd` | Initial virtual directory; defaults to `/`. |
274
- | `env` | Initial exported variables; defaults to an empty map, with `PWD` set from `cwd`. No host environment inheritance. |
274
+ | `env` | Initial exported variables; defaults to an empty map, with `PWD` set from `cwd`. No host environment inheritance. Never pass host `process.env` or any secret-bearing object: everything in `env` is readable by executed scripts (`env`, `printenv`, `$VAR`), and on Cloudflare Workers with `nodejs_compat` `process.env` contains the Worker's secret bindings. The shell logs a warning when it detects this. |
275
275
  | `commands` | Existing `CommandRegistry`; defaults to an empty registry. |
276
276
  | `limits` | Resource limits listed below. |
277
277
 
@@ -289,10 +289,19 @@ provided. Pass an `AbortSignal` as `signal` to cancel. [Option types](src/shell/
289
289
  | `maxSourceBytes` | 1 MiB |
290
290
  | `maxExpansionFields` | 10,000 |
291
291
  | `maxExpansionBytes` | 16 MiB |
292
+ | `maxWallClockMs` | 30 seconds |
293
+ | `maxCpuMs` | 30 seconds, checked at command and cooperative-yield checkpoints |
292
294
  | `pipeHighWaterMark` | 64 KiB |
293
295
 
294
296
  Always call `dispose()` when finished. Shell failures normally produce an exit
295
297
  code and stderr; limit violations, cancellation, and host failures can reject `exec()`.
298
+ For Cloudflare Workers, start with the exported `cloudflareWorkerLimits` profile
299
+ and configure command-family buffers at no more than 8 MiB. Create a separate
300
+ `Shell`, environment object, and quota-wrapped filesystem view for each tenant or
301
+ request. Never reuse tenant state across requests; import `withFileSystemQuota`
302
+ from `poe-code/safe-fs` to bound cumulative writes, including command-initiated
303
+ copies and streaming output. Admission control and rate limiting remain host
304
+ responsibilities.
296
305
 
297
306
  ### Command configuration
298
307
 
@@ -5,6 +5,11 @@ export * from "./fs/memory/index.js";
5
5
  export * from "./fs/readonly/index.js";
6
6
  export * from "./fs/mount/index.js";
7
7
  export * from "./fs/overlay/index.js";
8
+ export { createFetchTransport } from "./commands/network/fetch-transport.js";
9
+ export type { FetchTransportOptions } from "./commands/network/fetch-transport.js";
10
+ export { createOriginAuthorizer } from "./commands/network/authorizer.js";
11
+ export type { OriginAllowlist, OriginAuthorizerOptions } from "./commands/network/authorizer.js";
12
+ export { cloudflareWorkerNetworkLimits } from "./commands/network/types.js";
8
13
  export interface BrowserCommandsOptions {
9
14
  readonly replace?: boolean;
10
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":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