@poe-platform/safe-bash 0.1.781 → 0.1.783
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 +40 -0
- package/dist/office-package/zip-sync.d.ts +2 -0
- package/dist/office-package/zip-sync.js +111 -0
- package/dist/safe-bash/chunks/chunk-4FDQJUFW.js +3464 -0
- package/dist/safe-bash/chunks/csvkit-K55OYAQC.js +1564 -0
- package/dist/safe-bash/chunks/ffmpeg-BEFTQ6DZ.js +60 -0
- package/dist/safe-bash/chunks/gh-HQWOWLWE.js +41 -0
- package/dist/safe-bash/chunks/git-UFNPAOYZ.js +52 -0
- package/dist/safe-bash/chunks/imagemagick-53BMHH6D.js +134 -0
- package/dist/safe-bash/chunks/implementation-QUTAAYMT.js +105 -0
- package/dist/safe-bash/chunks/pdfimages-4OYI6FLG.js +73 -0
- package/dist/safe-bash/chunks/pdfinfo-I7U6TQPP.js +153 -0
- package/dist/safe-bash/chunks/pdftk-SUA6FMHI.js +79 -0
- package/dist/safe-bash/chunks/pdftoppm-4C5DGEWX.js +139 -0
- package/dist/safe-bash/chunks/pdftotext-Y4WI225Y.js +118 -0
- package/dist/safe-bash/chunks/qpdf-IORB4RV5.js +68 -0
- package/dist/safe-bash/chunks/sips-WHAMJFEU.js +77 -0
- package/dist/safe-bash/chunks/soffice-SYEK6WJS.js +89 -0
- package/dist/safe-bash/chunks/wkhtmltopdf-ZIICWJLF.js +85 -0
- package/dist/safe-bash/command-chunks/chunk-2LP3VMPA.js +58 -0
- package/dist/safe-bash/command-chunks/{chunk-CG4JSOK2.js → chunk-3HDIDEUJ.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-4DSJDVBM.js +2897 -0
- package/dist/safe-bash/command-chunks/{chunk-GBHSE6ZO.js → chunk-5GRLAARV.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-7OKDCM5U.js +112 -0
- package/dist/safe-bash/command-chunks/{chunk-FH3D75FC.js → chunk-ADCGH6A7.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-MTKXVRXL.js → chunk-DREUDEQG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ADBFNLLK.js → chunk-FXYWQ6S4.js} +16 -14
- package/dist/safe-bash/command-chunks/{chunk-Y2KHC6TZ.js → chunk-IDKD76KR.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-K6KBYLQC.js → chunk-JUDOV5MJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3ZK5F23O.js → chunk-L3MLMXL4.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-E5TEVROY.js → chunk-PFBJR2PY.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-YGYOVXTO.js → chunk-UUR2S7AD.js} +9 -5
- package/dist/safe-bash/command-chunks/chunk-VIVYKW7Q.js +101 -0
- package/dist/safe-bash/command-chunks/{chunk-I5GLTNVH.js → chunk-X4P42NYK.js} +2 -27
- package/dist/safe-bash/command-chunks/{chunk-XF6TXYLD.js → chunk-Z57TV6TC.js} +4 -54
- package/dist/safe-bash/command-chunks/{chunk-QDPRSPHQ.js → chunk-Z64BW7CG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-X3IVPNC3.js → chunk-Z7TYZG3A.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-GZXLPWT5.js → chunk-ZF3ZVGQC.js} +259 -258
- package/dist/safe-bash/command-chunks/{pptx-ZL6L7KP2-QVZEYFUV.js → pptx-KY2OJWZW-76LBHCHD.js} +4 -3
- package/dist/safe-bash/commands/csvkit/index.d.ts +1 -8
- package/dist/safe-bash/commands/csvkit/index.js +5 -1639
- package/dist/safe-bash/commands/csvkit/sync.d.ts +9 -0
- package/dist/safe-bash/commands/csvkit/sync.js +1639 -0
- package/dist/safe-bash/commands/pandoc/implementation.d.ts +8 -0
- package/dist/safe-bash/commands/pandoc/implementation.js +92 -0
- package/dist/safe-bash/commands/pandoc/index.d.ts +2 -6
- package/dist/safe-bash/commands/pandoc/index.js +2 -90
- package/dist/safe-bash/core.browser.js +808 -6271
- package/dist/safe-bash/core.d.ts +17 -16
- package/dist/safe-bash/core.js +17 -16
- package/dist/safe-bash/lazy-gh.d.ts +10 -0
- package/dist/safe-bash/lazy-gh.js +30 -0
- package/dist/safe-bash/lazy-optional.d.ts +499 -0
- package/dist/safe-bash/lazy-optional.js +609 -0
- package/dist/safe-bash/plugins/composition.d.ts +1 -1
- package/dist/safe-bash/plugins/composition.js +1 -1
- package/dist/safe-bash/plugins/lazy-command.d.ts +9 -0
- package/dist/safe-bash/plugins/lazy-command.js +57 -0
- package/dist/safe-bash/shell/runtime.js +24 -25
- package/dist/safe-bash-command-csvkit/cli/lexical.d.ts +3 -0
- package/dist/safe-bash-command-csvkit/cli/parser.d.ts +1 -2
- package/dist/safe-bash-command-csvkit/codecs/python.js +3 -2
- package/dist/safe-bash-command-csvkit/codecs/utf8.js +2 -1
- package/dist/safe-bash-command-csvkit/index.js +453 -3270
- package/dist/safe-bash-command-csvkit/sync-support.d.ts +7 -0
- package/dist/safe-bash-command-csvkit/sync-support.js +31 -0
- package/dist/safe-bash-command-gh/index.js +25 -17
- package/dist/safe-bash-command-git/index.js +6 -10
- package/dist/safe-bash-command-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-pandoc/citeproc-filters.js +4 -2
- package/dist/safe-bash-command-pandoc/command.js +8 -6
- package/dist/safe-bash-command-pandoc/index.js +8 -6
- package/dist/safe-bash-command-pandoc/lua-filters.js +3 -2
- package/dist/safe-bash-command-pandoc/options.d.ts +5 -0
- package/dist/safe-bash-command-pandoc/options.js +93 -0
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.d.ts +1 -2
- package/dist/safe-bash-command-soffice/index.js +22 -18
- package/dist/safe-bash-command-ssconvert/commands.js +2 -2
- package/dist/safe-bash-command-ssconvert/core.js +2 -2
- package/dist/safe-bash-command-ssconvert/formats/csv.js +2 -2
- package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
- package/dist/safe-bash-command-ssconvert/formats/xlsx.js +3 -3
- package/dist/safe-bash-command-timeout/index.js +3 -3
- package/dist/safe-bash-command-yq/index.js +5 -5
- package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
- package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
- package/dist/safe-bash-compression-engine/files.js +7 -7
- package/dist/safe-bash-compression-engine/index.js +6 -6
- package/dist/safe-bash-compression-engine/operand.js +7 -7
- package/dist/safe-bash-compression-engine/stream.js +6 -6
- package/dist/safe-bash-compression-engine/zstd-decode.js +5 -5
- package/dist/safe-bash-contracts/diagnostics.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +9 -9
- package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
- package/dist/safe-bash-contracts/filesystem-output.js +10 -10
- package/dist/safe-bash-contracts/index.js +40 -40
- package/dist/safe-bash-io-engine/commands/search/requirements.js +4 -4
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +4 -4
- package/dist/safe-bash-io-engine/internal.d.ts +9 -0
- package/dist/safe-bash-io-engine/internal.js +3 -3
- package/dist/safe-bash-query-engine/index.js +6 -6
- package/dist/safe-bash-query-engine/interpreter.js +5 -5
- package/dist/safe-bash-query-engine/query-core.js +6 -6
- package/dist/safe-bash-regex-engine/execution/bounded-provider.js +3 -3
- package/dist/safe-bash-regex-engine/index.js +2 -2
- package/dist/safe-bash-regex-engine/text/regex.js +2 -2
- package/dist/safe-bash-xml-engine/index.js +3 -3
- package/package.json +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DC52GWRK.js → chunk-BUKYQBXO.js} +13 -13
- package/dist/safe-bash/command-chunks/{chunk-QJ3ONEBI.js → chunk-DEH3CMGL.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-Y64PA6IA.js → chunk-KHZZ4V3L.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-I7PKIGII.js → chunk-QIRUOY2W.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-HQG2IBZL.js → chunk-TOSM3T3A.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-F4IQCXZG.js → chunk-VBZMCL23.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-J2NPH7DO.js → chunk-W2T7JWT3.js} +3 -3
package/README.md
CHANGED
|
@@ -51,6 +51,46 @@ an existing host Buffer is preserved. Workers do not need `nodejs_compat` for th
|
|
|
51
51
|
|
|
52
52
|
## Supported features and commands
|
|
53
53
|
|
|
54
|
+
The root and `core` exports register optional spreadsheet, PDF, media, office,
|
|
55
|
+
and Git commands from static metadata and load their implementations on first
|
|
56
|
+
execution. `agentCommands()` keeps its existing default inventory. Select a
|
|
57
|
+
single command or a family explicitly, or retain the full optional inventory:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { optionalCommands } from "@poe-platform/safe-bash";
|
|
61
|
+
|
|
62
|
+
shell.use(optionalCommands({ commands: ["pdftotext", "ffprobe"] }));
|
|
63
|
+
// Alternatively: optionalCommands({ families: ["pdfinfo", "ssconvert"] })
|
|
64
|
+
// Full profile: agentCommands() plus optionalCommands({ profile: "full" })
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The full optional profile fills missing commands and preserves existing dedicated
|
|
68
|
+
registrations, including configured default commands. Pass `replace: true` to
|
|
69
|
+
replace existing registrations explicitly.
|
|
70
|
+
|
|
71
|
+
Existing root factories such as `ffmpegCommands()` and `createPdftotextCommand()`
|
|
72
|
+
also defer loading. The advanced command subpaths retain their eager SDK and
|
|
73
|
+
synchronous APIs. Selected ssconvert format factories remain supported through
|
|
74
|
+
`configuration.ssconvert.formats`; no format adapter is replaced.
|
|
75
|
+
Concurrent first calls share one code-load promise per family. Failed loader
|
|
76
|
+
calls retry on the next invocation. Host module caches can retain evaluation
|
|
77
|
+
errors; correcting a broken bundled module can require restarting the host. Cancellation stops that caller's wait and prevents late
|
|
78
|
+
dispatch; it does not cancel another caller's shared code import. Factories and
|
|
79
|
+
execution contexts are invocation-local, and Git shares compiled Wasm code but
|
|
80
|
+
creates separate mutable instances. Existing filesystem, streams, host bindings,
|
|
81
|
+
limits and cleanup remain with the original command context. Configuration
|
|
82
|
+
validation in deferred factories occurs at first execution.
|
|
83
|
+
|
|
84
|
+
Static dynamic-import chunks and Wasm assets still count toward Cloudflare's
|
|
85
|
+
total uncompressed upload size. Deferring evaluation reduces startup work;
|
|
86
|
+
splitting files alone does not remove deployment bytes. Hosts can parse or
|
|
87
|
+
compile statically declared assets before execution; the loader defers JavaScript
|
|
88
|
+
evaluation and mutable engine initialization. The maintained
|
|
89
|
+
`tests/integration/lazy-loading.test.mjs` qualifies source and installed profiles
|
|
90
|
+
in workerd and reports cold runtime/setup, first use, repeat use and cleanup
|
|
91
|
+
measurements. Python uses an injected asynchronous executor in this loader
|
|
92
|
+
regression; LLM uses a synthetic provider, without external model calls.
|
|
93
|
+
|
|
54
94
|
All private command plugins are available from `@poe-platform/safe-bash/core` in portable browser and workerd environments. Each command exposes its plugin, `create<Name>Commands`, `create<Name>Command`, `<Name>CommandsOptions`, and `<Name>Limits`; factories construct commands without registering them.
|
|
55
95
|
|
|
56
96
|
### Shell syntax
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { inflateRaw } from "pako";
|
|
2
|
+
// Synchronous stored/raw-DEFLATE ZIP access for office document fast paths.
|
|
3
|
+
function crc32Bytes(data) {
|
|
4
|
+
let c = 0xffffffff;
|
|
5
|
+
for (let i = 0; i < data.length; i++) {
|
|
6
|
+
c ^= data[i];
|
|
7
|
+
for (let k = 0; k < 8; k++) {
|
|
8
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return (c ^ 0xffffffff) >>> 0;
|
|
12
|
+
}
|
|
13
|
+
export function createStoredZipArchive(entries) {
|
|
14
|
+
const localParts = [];
|
|
15
|
+
const centralParts = [];
|
|
16
|
+
let offset = 0;
|
|
17
|
+
let count = 0;
|
|
18
|
+
for (const [name, content] of Object.entries(entries)) {
|
|
19
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
20
|
+
const crc = crc32Bytes(content);
|
|
21
|
+
const localHeader = new Uint8Array(30 + nameBytes.length);
|
|
22
|
+
const lv = new DataView(localHeader.buffer);
|
|
23
|
+
lv.setUint32(0, 0x04034b50, true);
|
|
24
|
+
lv.setUint16(4, 20, true);
|
|
25
|
+
lv.setUint16(6, 0, true);
|
|
26
|
+
lv.setUint16(8, 0, true); // stored
|
|
27
|
+
lv.setUint32(14, crc, true);
|
|
28
|
+
lv.setUint32(18, content.length, true);
|
|
29
|
+
lv.setUint32(22, content.length, true);
|
|
30
|
+
lv.setUint16(26, nameBytes.length, true);
|
|
31
|
+
localHeader.set(nameBytes, 30);
|
|
32
|
+
const centralHeader = new Uint8Array(46 + nameBytes.length);
|
|
33
|
+
const cv = new DataView(centralHeader.buffer);
|
|
34
|
+
cv.setUint32(0, 0x02014b50, true);
|
|
35
|
+
cv.setUint16(4, 20, true);
|
|
36
|
+
cv.setUint16(6, 20, true);
|
|
37
|
+
cv.setUint16(10, 0, true);
|
|
38
|
+
cv.setUint32(16, crc, true);
|
|
39
|
+
cv.setUint32(20, content.length, true);
|
|
40
|
+
cv.setUint32(24, content.length, true);
|
|
41
|
+
cv.setUint16(28, nameBytes.length, true);
|
|
42
|
+
cv.setUint32(42, offset, true);
|
|
43
|
+
centralHeader.set(nameBytes, 46);
|
|
44
|
+
localParts.push(localHeader, content);
|
|
45
|
+
centralParts.push(centralHeader);
|
|
46
|
+
offset += localHeader.length + content.length;
|
|
47
|
+
count++;
|
|
48
|
+
}
|
|
49
|
+
const centralSize = centralParts.reduce((s, p) => s + p.length, 0);
|
|
50
|
+
const eocd = new Uint8Array(22);
|
|
51
|
+
const ev = new DataView(eocd.buffer);
|
|
52
|
+
ev.setUint32(0, 0x06054b50, true);
|
|
53
|
+
ev.setUint16(8, count, true);
|
|
54
|
+
ev.setUint16(10, count, true);
|
|
55
|
+
ev.setUint32(12, centralSize, true);
|
|
56
|
+
ev.setUint32(16, offset, true);
|
|
57
|
+
const total = offset + centralSize + 22;
|
|
58
|
+
const out = new Uint8Array(total);
|
|
59
|
+
let pos = 0;
|
|
60
|
+
for (const p of [...localParts, ...centralParts, eocd]) {
|
|
61
|
+
out.set(p, pos);
|
|
62
|
+
pos += p.length;
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
export function readZipArchiveEntries(zipBytes) {
|
|
67
|
+
const map = new Map();
|
|
68
|
+
const view = new DataView(zipBytes.buffer, zipBytes.byteOffset, zipBytes.byteLength);
|
|
69
|
+
let eocdPos = -1;
|
|
70
|
+
for (let i = zipBytes.length - 22; i >= Math.max(0, zipBytes.length - 65557); i--) {
|
|
71
|
+
if (view.getUint32(i, true) === 0x06054b50) {
|
|
72
|
+
eocdPos = i;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (eocdPos < 0)
|
|
77
|
+
throw new Error("Invalid ZIP: missing end of central directory");
|
|
78
|
+
const count = view.getUint16(eocdPos + 10, true);
|
|
79
|
+
let cdPos = view.getUint32(eocdPos + 16, true);
|
|
80
|
+
for (let i = 0; i < count; i++) {
|
|
81
|
+
if (cdPos + 46 > zipBytes.length || view.getUint32(cdPos, true) !== 0x02014b50) {
|
|
82
|
+
throw new Error("Invalid ZIP: truncated central directory");
|
|
83
|
+
}
|
|
84
|
+
const method = view.getUint16(cdPos + 10, true);
|
|
85
|
+
const compSize = view.getUint32(cdPos + 20, true);
|
|
86
|
+
const nameLen = view.getUint16(cdPos + 28, true);
|
|
87
|
+
const extraLen = view.getUint16(cdPos + 30, true);
|
|
88
|
+
const commentLen = view.getUint16(cdPos + 32, true);
|
|
89
|
+
const localOffset = view.getUint32(cdPos + 42, true);
|
|
90
|
+
if (cdPos + 46 + nameLen + extraLen + commentLen > zipBytes.length ||
|
|
91
|
+
localOffset + 30 > zipBytes.length || view.getUint32(localOffset, true) !== 0x04034b50) {
|
|
92
|
+
throw new Error("Invalid ZIP: truncated or invalid entry header");
|
|
93
|
+
}
|
|
94
|
+
const name = new TextDecoder().decode(zipBytes.subarray(cdPos + 46, cdPos + 46 + nameLen));
|
|
95
|
+
const localNameLen = view.getUint16(localOffset + 26, true);
|
|
96
|
+
const localExtraLen = view.getUint16(localOffset + 28, true);
|
|
97
|
+
const dataStart = localOffset + 30 + localNameLen + localExtraLen;
|
|
98
|
+
if (dataStart + compSize > zipBytes.length) {
|
|
99
|
+
throw new Error("Invalid ZIP: truncated entry data");
|
|
100
|
+
}
|
|
101
|
+
const rawData = zipBytes.subarray(dataStart, dataStart + compSize);
|
|
102
|
+
if (method === 0) {
|
|
103
|
+
map.set(name, new Uint8Array(rawData));
|
|
104
|
+
}
|
|
105
|
+
else if (method === 8) {
|
|
106
|
+
map.set(name, inflateRaw(rawData));
|
|
107
|
+
}
|
|
108
|
+
cdPos += 46 + nameLen + extraLen + commentLen;
|
|
109
|
+
}
|
|
110
|
+
return map;
|
|
111
|
+
}
|