@perstack/base 0.0.20 → 0.0.22

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/src/index.js CHANGED
@@ -1,114 +1,3 @@
1
- export { appendTextFile, appendTextFileConfig, attemptCompletion, attemptCompletionConfig, clearTodo, clearTodoConfig, createDirectory, createDirectoryConfig, deleteFile, deleteFileConfig, editTextFile, editTextFileConfig, getFileInfo, getFileInfoConfig, listDirectory, listDirectoryConfig, moveFile, moveFileConfig, readImageFile, readImageFileConfig, readPdfFile, readPdfFileConfig, readTextFile, readTextFileConfig, testUrlConfig, testUrls, think, thinkConfig, todo, todoConfig, writeTextFile, writeTextFileConfig } from '../chunk-4N6IWATT.js';
2
- import { execFile } from 'child_process';
3
- import { promisify } from 'util';
4
- import { dedent } from 'ts-dedent';
5
- import { z } from 'zod';
6
-
7
- var execFileAsync = promisify(execFile);
8
- var execInputSchema = z.object({
9
- command: z.string().describe("The command to execute"),
10
- args: z.array(z.string()).describe("The arguments to pass to the command"),
11
- env: z.record(z.string(), z.string()).describe("The environment variables to set"),
12
- cwd: z.string().describe("The working directory to execute the command in"),
13
- stdout: z.boolean().describe("Whether to capture the standard output"),
14
- stderr: z.boolean().describe("Whether to capture the standard error"),
15
- timeout: z.number().optional().describe("Timeout in milliseconds")
16
- });
17
- function execConfig() {
18
- return {
19
- title: "Execute Command",
20
- description: dedent`
21
- A tool for executing a command.
22
- This tool helps execute a command with the given parameters.
23
-
24
- When to use this tool:
25
- - When you need to run system tasks or scripts.
26
- - When automating the use of command-line tools or utilities.
27
-
28
- Key features:
29
- - Flexible Execution Environment: Specify environment variables, working directory, and arguments to tailor the command execution.
30
- - Output Capture: Control whether to capture the standard output and standard error from the executed command.
31
- - Simple Interface: A unified input schema consolidates all parameters needed for command execution.
32
-
33
- Parameters explained:
34
- - command: The command to execute (e.g., \`ls\`, \`python\`).
35
- - args: A list of arguments to pass to the command, functioning similarly to command-line input.
36
- - env: A record of key-value pairs representing environment variables for the command's execution environment.
37
- - cwd: The working directory in which the command will run; both relative and absolute paths are supported.
38
- - stdout: A boolean flag indicating whether to capture the standard output (set to \`true\` to capture).
39
- - stderr: A boolean flag indicating whether to capture the standard error (set to \`true\` to capture).
40
- - timeout: The timeout in milliseconds for the command execution.
41
-
42
- Rules:
43
- - Safety: Only execute commands from trusted sources to avoid executing malicious code.
44
- - Command Termination: Do not execute commands that remain running in the foreground (e.g., \`tail -f\`), as the tool requires commands to complete.
45
- - Resource Management: Be cautious when running commands that may consume significant system resources or produce large amounts of output.
46
- - Error Handling: Implement proper error handling to catch and manage any issues that arise during command execution.
47
- - Parameter Validation: Ensure that all provided parameters adhere to the expected format to prevent unexpected behavior.
48
- `,
49
- inputSchema: execInputSchema.shape
50
- };
51
- }
52
- async function exec(input) {
53
- try {
54
- const { stdout, stderr } = await execFileAsync(input.command, input.args, {
55
- cwd: input.cwd,
56
- env: { ...process.env, ...input.env },
57
- timeout: input.timeout
58
- });
59
- let output = "";
60
- if (input.stdout) {
61
- output += stdout;
62
- }
63
- if (input.stderr) {
64
- output += stderr;
65
- }
66
- if (!output.trim()) {
67
- output = "Command executed successfully, but produced no output.";
68
- }
69
- return {
70
- content: [
71
- {
72
- type: "text",
73
- text: output
74
- }
75
- ]
76
- };
77
- } catch (error) {
78
- let errMsg = "";
79
- const execError = error;
80
- if (execError && (execError.killed || execError.signal === "SIGTERM") && typeof input.timeout === "number") {
81
- errMsg = `Error: Command timed out after ${input.timeout}ms.
82
- `;
83
- } else if (error instanceof Error) {
84
- if (error.message.includes("timeout")) {
85
- errMsg = `Error: Command timed out after ${input.timeout}ms.
86
- `;
87
- } else {
88
- errMsg = `Error: ${error.message}
89
- `;
90
- }
91
- } else {
92
- errMsg = "An unknown error occurred.\n";
93
- }
94
- if (execError.stdout && input.stdout) {
95
- errMsg += `Standard Output: ${execError.stdout}`;
96
- }
97
- if (execError.stderr && input.stderr) {
98
- errMsg += `
99
- Standard Error: ${execError.stderr}`;
100
- }
101
- return {
102
- content: [
103
- {
104
- type: "text",
105
- text: errMsg
106
- }
107
- ]
108
- };
109
- }
110
- }
111
-
112
- export { exec, execConfig };
1
+ export { appendTextFile, attemptCompletion, clearTodo, createDirectory, deleteDirectory, deleteFile, editTextFile, exec, getFileInfo, listDirectory, moveFile, readImageFile, readPdfFile, readTextFile, registerAppendTextFile, registerAttemptCompletion, registerClearTodo, registerCreateDirectory, registerDeleteDirectory, registerDeleteFile, registerEditTextFile, registerExec, registerGetFileInfo, registerListDirectory, registerMoveFile, registerReadImageFile, registerReadPdfFile, registerReadTextFile, registerThink, registerTodo, registerWriteTextFile, think, todo, writeTextFile } from '../chunk-CDWG4Z4N.js';
113
2
  //# sourceMappingURL=index.js.map
114
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tools/exec.ts"],"names":[],"mappings":";;;;;;AAKA,IAAM,aAAA,GAAgB,UAAU,QAAQ,CAAA;AAExC,IAAM,eAAA,GAAkB,EAAE,MAAA,CAAO;AAAA,EAC/B,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,wBAAwB,CAAA;AAAA,EACrD,IAAA,EAAM,EAAE,KAAA,CAAM,CAAA,CAAE,QAAQ,CAAA,CAAE,SAAS,sCAAsC,CAAA;AAAA,EACzE,GAAA,EAAK,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,MAAA,EAAO,EAAG,CAAA,CAAE,MAAA,EAAQ,CAAA,CAAE,QAAA,CAAS,kCAAkC,CAAA;AAAA,EACjF,GAAA,EAAK,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,iDAAiD,CAAA;AAAA,EAC1E,MAAA,EAAQ,CAAA,CAAE,OAAA,EAAQ,CAAE,SAAS,wCAAwC,CAAA;AAAA,EACrE,MAAA,EAAQ,CAAA,CAAE,OAAA,EAAQ,CAAE,SAAS,uCAAuC,CAAA;AAAA,EACpE,SAAS,CAAA,CAAE,MAAA,GAAS,QAAA,EAA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IAAU,SAAA,CAAU,WAAW,SAAA,CAAA,IAC1C,OAAO,KAAA,CAAM,OAAA,KAAY,QAAA,EACzB;AACA,MAAA,MAAA,GAAS,CAAA,+BAAA,EAAkC,MAAM,OAAO,CAAA;AAAA,CAAA;AAAA,IAC1D,CAAA,MAAA,IAAW,iBAAiB,KAAA,EAAO;AACjC,MAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,QAAA,CAAS,SAAS,CAAA,EAAG;AACrC,QAAA,MAAA,GAAS,CAAA,+BAAA,EAAkC,MAAM,OAAO,CAAA;AAAA,CAAA;AAAA,MAC1D,CAAA,MAAO;AACL,QAAA,MAAA,GAAS,CAAA,OAAA,EAAU,MAAM,OAAO;AAAA,CAAA;AAAA,MAClC;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAA,GAAS,8BAAA;AAAA,IACX;AACA,IAAA,IAAI,SAAA,CAAU,MAAA,IAAU,KAAA,CAAM,MAAA,EAAQ;AACpC,MAAA,MAAA,IAAU,CAAA,iBAAA,EAAoB,UAAU,MAAM,CAAA,CAAA;AAAA,IAChD;AACA,IAAA,IAAI,SAAA,CAAU,MAAA,IAAU,KAAA,CAAM,MAAA,EAAQ;AACpC,MAAA,MAAA,IAAU;AAAA,gBAAA,EAAqB,UAAU,MAAM,CAAA,CAAA;AAAA,IACjD;AACA,IAAA,OAAO;AAAA,MACL,OAAA,EAAS;AAAA,QACP;AAAA,UACE,IAAA,EAAM,MAAA;AAAA,UACN,IAAA,EAAM;AAAA;AACR;AACF,KACF;AAAA,EACF;AACF","file":"index.js","sourcesContent":["import { execFile } from \"node:child_process\"\nimport { promisify } from \"node:util\"\nimport { dedent } from \"ts-dedent\"\nimport { z } from \"zod\"\n\nconst execFileAsync = promisify(execFile)\n\nconst execInputSchema = z.object({\n command: z.string().describe(\"The command to execute\"),\n args: z.array(z.string()).describe(\"The arguments to pass to the command\"),\n env: z.record(z.string(), z.string()).describe(\"The environment variables to set\"),\n cwd: z.string().describe(\"The working directory to execute the command in\"),\n stdout: z.boolean().describe(\"Whether to capture the standard output\"),\n stderr: z.boolean().describe(\"Whether to capture the standard error\"),\n timeout: z.number().optional().describe(\"Timeout in milliseconds\"),\n})\ntype ExecInput = z.infer<typeof execInputSchema>\n\nexport function execConfig() {\n return {\n title: \"Execute Command\",\n description: dedent`\n A tool for executing a command.\n This tool helps execute a command with the given parameters.\n\n When to use this tool:\n - When you need to run system tasks or scripts.\n - When automating the use of command-line tools or utilities.\n\n Key features:\n - Flexible Execution Environment: Specify environment variables, working directory, and arguments to tailor the command execution.\n - Output Capture: Control whether to capture the standard output and standard error from the executed command.\n - Simple Interface: A unified input schema consolidates all parameters needed for command execution.\n\n Parameters explained:\n - command: The command to execute (e.g., \\`ls\\`, \\`python\\`).\n - args: A list of arguments to pass to the command, functioning similarly to command-line input.\n - env: A record of key-value pairs representing environment variables for the command's execution environment.\n - cwd: The working directory in which the command will run; both relative and absolute paths are supported.\n - stdout: A boolean flag indicating whether to capture the standard output (set to \\`true\\` to capture).\n - stderr: A boolean flag indicating whether to capture the standard error (set to \\`true\\` to capture).\n - timeout: The timeout in milliseconds for the command execution.\n\n Rules:\n - Safety: Only execute commands from trusted sources to avoid executing malicious code.\n - Command Termination: Do not execute commands that remain running in the foreground (e.g., \\`tail -f\\`), as the tool requires commands to complete.\n - Resource Management: Be cautious when running commands that may consume significant system resources or produce large amounts of output.\n - Error Handling: Implement proper error handling to catch and manage any issues that arise during command execution.\n - Parameter Validation: Ensure that all provided parameters adhere to the expected format to prevent unexpected behavior.\n `,\n inputSchema: execInputSchema.shape,\n }\n}\n\nexport async function exec(input: ExecInput) {\n try {\n const { stdout, stderr } = await execFileAsync(input.command, input.args, {\n cwd: input.cwd,\n env: { ...process.env, ...input.env },\n timeout: input.timeout,\n })\n\n let output = \"\"\n if (input.stdout) {\n output += stdout\n }\n if (input.stderr) {\n output += stderr\n }\n\n if (!output.trim()) {\n output = \"Command executed successfully, but produced no output.\"\n }\n\n return {\n content: [\n {\n type: \"text\",\n text: output,\n },\n ],\n }\n } catch (error: unknown) {\n let errMsg = \"\"\n const execError = error as {\n message?: string\n stdout?: string\n stderr?: string\n killed?: boolean\n signal?: string\n }\n if (\n execError &&\n (execError.killed || execError.signal === \"SIGTERM\") &&\n typeof input.timeout === \"number\"\n ) {\n errMsg = `Error: Command timed out after ${input.timeout}ms.\\n`\n } else if (error instanceof Error) {\n if (error.message.includes(\"timeout\")) {\n errMsg = `Error: Command timed out after ${input.timeout}ms.\\n`\n } else {\n errMsg = `Error: ${error.message}\\n`\n }\n } else {\n errMsg = \"An unknown error occurred.\\n\"\n }\n if (execError.stdout && input.stdout) {\n errMsg += `Standard Output: ${execError.stdout}`\n }\n if (execError.stderr && input.stderr) {\n errMsg += `\\nStandard Error: ${execError.stderr}`\n }\n return {\n content: [\n {\n type: \"text\",\n text: errMsg,\n },\n ],\n }\n }\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perstack/base",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Perstack base skills for agents.",
5
5
  "author": "Wintermute Technologies, Inc.",
6
6
  "license": "Apache-2.0",
@@ -19,7 +19,7 @@
19
19
  "commander": "^14.0.2",
20
20
  "mime-types": "^3.0.2",
21
21
  "ts-dedent": "^2.2.0",
22
- "zod": "^3.25.76"
22
+ "zod": "^4.1.13"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@tsconfig/node22": "^22.0.5",
@@ -27,14 +27,14 @@
27
27
  "@types/node": "^24.10.1",
28
28
  "tsup": "^8.5.1",
29
29
  "typescript": "^5.9.3",
30
- "vitest": "^3.2.4"
30
+ "vitest": "^4.0.14"
31
31
  },
32
32
  "engines": {
33
33
  "node": ">=22.0.0"
34
34
  },
35
35
  "scripts": {
36
36
  "clean": "rm -rf dist",
37
- "build": "pnpm run clean && tsup --config ./tsup.config.ts",
37
+ "build": "pnpm run clean && tsup",
38
38
  "typecheck": "tsc --noEmit"
39
39
  },
40
40
  "bin": {