@hunterzhu/pulse-adapters 0.4.1 → 0.4.3
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.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/providers/canonical/capabilities.d.ts +19 -0
- package/dist/providers/canonical/capabilities.js +164 -0
- package/dist/providers/canonical/index.d.ts +6 -0
- package/dist/providers/canonical/index.js +6 -0
- package/dist/providers/canonical/lowering.d.ts +17 -0
- package/dist/providers/canonical/lowering.js +122 -0
- package/dist/providers/canonical/mappers/anthropic.d.ts +6 -0
- package/dist/providers/canonical/mappers/anthropic.js +153 -0
- package/dist/providers/canonical/mappers/openai.d.ts +3 -0
- package/dist/providers/canonical/mappers/openai.js +140 -0
- package/dist/providers/canonical/polyfill.d.ts +10 -0
- package/dist/providers/canonical/polyfill.js +98 -0
- package/dist/providers/canonical/types.d.ts +109 -0
- package/dist/providers/canonical/types.js +1 -0
- package/dist/providers/normalize.js +220 -3
- package/dist/providers/openai-compat.d.ts +1 -1
- package/dist/providers/openai-compat.js +27 -88
- package/dist/tools/filesystem.js +13 -4
- package/dist/tools/shell.js +8 -0
- package/package.json +3 -3
package/dist/tools/shell.js
CHANGED
|
@@ -161,6 +161,12 @@ function shellEnvironment(env) {
|
|
|
161
161
|
const source = env ?? process.env;
|
|
162
162
|
return Object.fromEntries(Object.entries(source).filter(([key]) => !/(API_KEY|TOKEN|SECRET|PASSWORD|PRIVATE_KEY|AUTHORIZATION|BEARER|CREDENTIAL|COOKIE)/i.test(key) && key !== 'NODE_OPTIONS'));
|
|
163
163
|
}
|
|
164
|
+
function shellLaunchesCommand(command, args) {
|
|
165
|
+
const base = basename(command).toLowerCase();
|
|
166
|
+
if (!['sh', 'bash', 'zsh', 'dash', 'fish', 'ksh', 'cmd', 'cmd.exe', 'powershell', 'powershell.exe', 'pwsh', 'pwsh.exe'].includes(base))
|
|
167
|
+
return false;
|
|
168
|
+
return args.some((arg) => /^(?:-lc|-c|-command|\/c)$/i.test(arg));
|
|
169
|
+
}
|
|
164
170
|
export function runShell(command, args = [], options = {}) {
|
|
165
171
|
const max = options.maxOutputBytes ?? 256 * 1024;
|
|
166
172
|
if (!Number.isFinite(max) || max < 0)
|
|
@@ -169,6 +175,8 @@ export function runShell(command, args = [], options = {}) {
|
|
|
169
175
|
return Promise.reject(shellError('INVALID_SHELL_TIMEOUT'));
|
|
170
176
|
if (!command || typeof command !== 'string' || !Array.isArray(args) || args.some((arg) => typeof arg !== 'string'))
|
|
171
177
|
return Promise.reject(shellError('INVALID_SHELL_ARGUMENT'));
|
|
178
|
+
if (/&&|\|\||[|&;<>\n`]|\$\(/.test(command) || shellLaunchesCommand(command, args))
|
|
179
|
+
return Promise.reject(Object.assign(shellError('SHELL_SYNTAX_UNSUPPORTED'), { message: 'shell.exec does not start a shell. Pass the executable in command and each argument in args. Do not put &&, pipes, redirects, command substitution, or sh -c in command.' }));
|
|
172
180
|
try {
|
|
173
181
|
encodeSandboxCommand(command, args);
|
|
174
182
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hunterzhu/pulse-adapters",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@anthropic-ai/sandbox-runtime": "0.0.77",
|
|
21
|
-
"@hunterzhu/pulse-runtime": "0.4.
|
|
22
|
-
"@hunterzhu/pulse-tool-sdk": "0.4.
|
|
21
|
+
"@hunterzhu/pulse-runtime": "0.4.3",
|
|
22
|
+
"@hunterzhu/pulse-tool-sdk": "0.4.3",
|
|
23
23
|
"exceljs": "4.4.0",
|
|
24
24
|
"pdfjs-dist": "4.10.38"
|
|
25
25
|
}
|