@dexto/tools-process 1.5.0

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 (42) hide show
  1. package/LICENSE +44 -0
  2. package/dist/bash-exec-tool.cjs +130 -0
  3. package/dist/bash-exec-tool.d.cts +17 -0
  4. package/dist/bash-exec-tool.d.ts +17 -0
  5. package/dist/bash-exec-tool.js +96 -0
  6. package/dist/bash-output-tool.cjs +49 -0
  7. package/dist/bash-output-tool.d.cts +16 -0
  8. package/dist/bash-output-tool.d.ts +16 -0
  9. package/dist/bash-output-tool.js +25 -0
  10. package/dist/command-validator.cjs +554 -0
  11. package/dist/command-validator.d.cts +52 -0
  12. package/dist/command-validator.d.ts +52 -0
  13. package/dist/command-validator.js +530 -0
  14. package/dist/error-codes.cjs +47 -0
  15. package/dist/error-codes.d.cts +26 -0
  16. package/dist/error-codes.d.ts +26 -0
  17. package/dist/error-codes.js +23 -0
  18. package/dist/errors.cjs +243 -0
  19. package/dist/errors.d.cts +90 -0
  20. package/dist/errors.d.ts +90 -0
  21. package/dist/errors.js +219 -0
  22. package/dist/index.cjs +49 -0
  23. package/dist/index.d.cts +11 -0
  24. package/dist/index.d.ts +11 -0
  25. package/dist/index.js +18 -0
  26. package/dist/kill-process-tool.cjs +47 -0
  27. package/dist/kill-process-tool.d.cts +16 -0
  28. package/dist/kill-process-tool.d.ts +16 -0
  29. package/dist/kill-process-tool.js +23 -0
  30. package/dist/process-service.cjs +544 -0
  31. package/dist/process-service.d.cts +96 -0
  32. package/dist/process-service.d.ts +96 -0
  33. package/dist/process-service.js +510 -0
  34. package/dist/tool-provider.cjs +96 -0
  35. package/dist/tool-provider.d.cts +72 -0
  36. package/dist/tool-provider.d.ts +72 -0
  37. package/dist/tool-provider.js +72 -0
  38. package/dist/types.cjs +16 -0
  39. package/dist/types.d.cts +108 -0
  40. package/dist/types.d.ts +108 -0
  41. package/dist/types.js +0 -0
  42. package/package.json +38 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var tool_provider_exports = {};
20
+ __export(tool_provider_exports, {
21
+ processToolsProvider: () => processToolsProvider
22
+ });
23
+ module.exports = __toCommonJS(tool_provider_exports);
24
+ var import_zod = require("zod");
25
+ var import_process_service = require("./process-service.js");
26
+ var import_bash_exec_tool = require("./bash-exec-tool.js");
27
+ var import_bash_output_tool = require("./bash-output-tool.js");
28
+ var import_kill_process_tool = require("./kill-process-tool.js");
29
+ const DEFAULT_SECURITY_LEVEL = "moderate";
30
+ const DEFAULT_MAX_TIMEOUT = 6e5;
31
+ const DEFAULT_MAX_CONCURRENT_PROCESSES = 5;
32
+ const DEFAULT_MAX_OUTPUT_BUFFER = 1 * 1024 * 1024;
33
+ const DEFAULT_ALLOWED_COMMANDS = [];
34
+ const DEFAULT_BLOCKED_COMMANDS = [];
35
+ const DEFAULT_ENVIRONMENT = {};
36
+ const ProcessToolsConfigSchema = import_zod.z.object({
37
+ type: import_zod.z.literal("process-tools"),
38
+ securityLevel: import_zod.z.enum(["strict", "moderate", "permissive"]).default(DEFAULT_SECURITY_LEVEL).describe("Security level for command execution validation"),
39
+ maxTimeout: import_zod.z.number().int().positive().max(DEFAULT_MAX_TIMEOUT).default(DEFAULT_MAX_TIMEOUT).describe(
40
+ `Maximum timeout for commands in milliseconds (max: ${DEFAULT_MAX_TIMEOUT / 1e3 / 60} minutes)`
41
+ ),
42
+ maxConcurrentProcesses: import_zod.z.number().int().positive().default(DEFAULT_MAX_CONCURRENT_PROCESSES).describe(
43
+ `Maximum number of concurrent background processes (default: ${DEFAULT_MAX_CONCURRENT_PROCESSES})`
44
+ ),
45
+ maxOutputBuffer: import_zod.z.number().int().positive().default(DEFAULT_MAX_OUTPUT_BUFFER).describe(
46
+ `Maximum output buffer size in bytes (default: ${DEFAULT_MAX_OUTPUT_BUFFER / 1024 / 1024}MB)`
47
+ ),
48
+ workingDirectory: import_zod.z.string().optional().describe("Working directory for process execution (defaults to process.cwd())"),
49
+ allowedCommands: import_zod.z.array(import_zod.z.string()).default(DEFAULT_ALLOWED_COMMANDS).describe(
50
+ "Explicitly allowed commands (empty = all allowed with approval, strict mode only)"
51
+ ),
52
+ blockedCommands: import_zod.z.array(import_zod.z.string()).default(DEFAULT_BLOCKED_COMMANDS).describe("Blocked command patterns (applies to all security levels)"),
53
+ environment: import_zod.z.record(import_zod.z.string()).default(DEFAULT_ENVIRONMENT).describe("Custom environment variables to set for command execution"),
54
+ timeout: import_zod.z.number().int().positive().max(DEFAULT_MAX_TIMEOUT).optional().describe(
55
+ `Default timeout in milliseconds (max: ${DEFAULT_MAX_TIMEOUT / 1e3 / 60} minutes)`
56
+ )
57
+ }).strict();
58
+ const processToolsProvider = {
59
+ type: "process-tools",
60
+ configSchema: ProcessToolsConfigSchema,
61
+ create: (config, context) => {
62
+ const { logger } = context;
63
+ logger.debug("Creating ProcessService for process tools");
64
+ const processService = new import_process_service.ProcessService(
65
+ {
66
+ securityLevel: config.securityLevel,
67
+ maxTimeout: config.maxTimeout,
68
+ maxConcurrentProcesses: config.maxConcurrentProcesses,
69
+ maxOutputBuffer: config.maxOutputBuffer,
70
+ workingDirectory: config.workingDirectory || process.cwd(),
71
+ allowedCommands: config.allowedCommands,
72
+ blockedCommands: config.blockedCommands,
73
+ environment: config.environment
74
+ },
75
+ logger
76
+ );
77
+ processService.initialize().catch((error) => {
78
+ logger.error(`Failed to initialize ProcessService: ${error.message}`);
79
+ });
80
+ logger.debug("ProcessService created - initialization will complete on first tool use");
81
+ return [
82
+ (0, import_bash_exec_tool.createBashExecTool)(processService),
83
+ (0, import_bash_output_tool.createBashOutputTool)(processService),
84
+ (0, import_kill_process_tool.createKillProcessTool)(processService)
85
+ ];
86
+ },
87
+ metadata: {
88
+ displayName: "Process Tools",
89
+ description: "Process execution and management (bash, output, kill)",
90
+ category: "process"
91
+ }
92
+ };
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ processToolsProvider
96
+ });
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ import { CustomToolProvider } from '@dexto/core';
3
+
4
+ /**
5
+ * Process Tools Provider
6
+ *
7
+ * Provides process execution and management tools by wrapping ProcessService.
8
+ * When registered, the provider initializes ProcessService and creates tools
9
+ * for command execution and process management.
10
+ */
11
+
12
+ /**
13
+ * Configuration schema for Process tools provider.
14
+ *
15
+ * This is the SINGLE SOURCE OF TRUTH for all configuration:
16
+ * - Validation rules
17
+ * - Default values (using constants above)
18
+ * - Documentation
19
+ * - Type definitions
20
+ *
21
+ * Services receive fully-validated config from this schema and use it as-is,
22
+ * with no additional defaults or fallbacks needed.
23
+ */
24
+ declare const ProcessToolsConfigSchema: z.ZodObject<{
25
+ type: z.ZodLiteral<"process-tools">;
26
+ securityLevel: z.ZodDefault<z.ZodEnum<["strict", "moderate", "permissive"]>>;
27
+ maxTimeout: z.ZodDefault<z.ZodNumber>;
28
+ maxConcurrentProcesses: z.ZodDefault<z.ZodNumber>;
29
+ maxOutputBuffer: z.ZodDefault<z.ZodNumber>;
30
+ workingDirectory: z.ZodOptional<z.ZodString>;
31
+ allowedCommands: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
32
+ blockedCommands: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
33
+ environment: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
34
+ timeout: z.ZodOptional<z.ZodNumber>;
35
+ }, "strict", z.ZodTypeAny, {
36
+ type: "process-tools";
37
+ securityLevel: "strict" | "moderate" | "permissive";
38
+ maxTimeout: number;
39
+ maxConcurrentProcesses: number;
40
+ maxOutputBuffer: number;
41
+ allowedCommands: string[];
42
+ blockedCommands: string[];
43
+ environment: Record<string, string>;
44
+ timeout?: number | undefined;
45
+ workingDirectory?: string | undefined;
46
+ }, {
47
+ type: "process-tools";
48
+ timeout?: number | undefined;
49
+ securityLevel?: "strict" | "moderate" | "permissive" | undefined;
50
+ maxTimeout?: number | undefined;
51
+ maxConcurrentProcesses?: number | undefined;
52
+ maxOutputBuffer?: number | undefined;
53
+ allowedCommands?: string[] | undefined;
54
+ blockedCommands?: string[] | undefined;
55
+ environment?: Record<string, string> | undefined;
56
+ workingDirectory?: string | undefined;
57
+ }>;
58
+ type ProcessToolsConfig = z.output<typeof ProcessToolsConfigSchema>;
59
+ /**
60
+ * Process tools provider.
61
+ *
62
+ * Wraps ProcessService and provides process operation tools:
63
+ * - bash_exec: Execute bash commands (foreground or background)
64
+ * - bash_output: Retrieve output from background processes
65
+ * - kill_process: Terminate background processes
66
+ *
67
+ * When registered via customToolRegistry, ProcessService is automatically
68
+ * initialized and process operation tools become available to the agent.
69
+ */
70
+ declare const processToolsProvider: CustomToolProvider<'process-tools', ProcessToolsConfig>;
71
+
72
+ export { processToolsProvider };
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ import { CustomToolProvider } from '@dexto/core';
3
+
4
+ /**
5
+ * Process Tools Provider
6
+ *
7
+ * Provides process execution and management tools by wrapping ProcessService.
8
+ * When registered, the provider initializes ProcessService and creates tools
9
+ * for command execution and process management.
10
+ */
11
+
12
+ /**
13
+ * Configuration schema for Process tools provider.
14
+ *
15
+ * This is the SINGLE SOURCE OF TRUTH for all configuration:
16
+ * - Validation rules
17
+ * - Default values (using constants above)
18
+ * - Documentation
19
+ * - Type definitions
20
+ *
21
+ * Services receive fully-validated config from this schema and use it as-is,
22
+ * with no additional defaults or fallbacks needed.
23
+ */
24
+ declare const ProcessToolsConfigSchema: z.ZodObject<{
25
+ type: z.ZodLiteral<"process-tools">;
26
+ securityLevel: z.ZodDefault<z.ZodEnum<["strict", "moderate", "permissive"]>>;
27
+ maxTimeout: z.ZodDefault<z.ZodNumber>;
28
+ maxConcurrentProcesses: z.ZodDefault<z.ZodNumber>;
29
+ maxOutputBuffer: z.ZodDefault<z.ZodNumber>;
30
+ workingDirectory: z.ZodOptional<z.ZodString>;
31
+ allowedCommands: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
32
+ blockedCommands: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
33
+ environment: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
34
+ timeout: z.ZodOptional<z.ZodNumber>;
35
+ }, "strict", z.ZodTypeAny, {
36
+ type: "process-tools";
37
+ securityLevel: "strict" | "moderate" | "permissive";
38
+ maxTimeout: number;
39
+ maxConcurrentProcesses: number;
40
+ maxOutputBuffer: number;
41
+ allowedCommands: string[];
42
+ blockedCommands: string[];
43
+ environment: Record<string, string>;
44
+ timeout?: number | undefined;
45
+ workingDirectory?: string | undefined;
46
+ }, {
47
+ type: "process-tools";
48
+ timeout?: number | undefined;
49
+ securityLevel?: "strict" | "moderate" | "permissive" | undefined;
50
+ maxTimeout?: number | undefined;
51
+ maxConcurrentProcesses?: number | undefined;
52
+ maxOutputBuffer?: number | undefined;
53
+ allowedCommands?: string[] | undefined;
54
+ blockedCommands?: string[] | undefined;
55
+ environment?: Record<string, string> | undefined;
56
+ workingDirectory?: string | undefined;
57
+ }>;
58
+ type ProcessToolsConfig = z.output<typeof ProcessToolsConfigSchema>;
59
+ /**
60
+ * Process tools provider.
61
+ *
62
+ * Wraps ProcessService and provides process operation tools:
63
+ * - bash_exec: Execute bash commands (foreground or background)
64
+ * - bash_output: Retrieve output from background processes
65
+ * - kill_process: Terminate background processes
66
+ *
67
+ * When registered via customToolRegistry, ProcessService is automatically
68
+ * initialized and process operation tools become available to the agent.
69
+ */
70
+ declare const processToolsProvider: CustomToolProvider<'process-tools', ProcessToolsConfig>;
71
+
72
+ export { processToolsProvider };
@@ -0,0 +1,72 @@
1
+ import { z } from "zod";
2
+ import { ProcessService } from "./process-service.js";
3
+ import { createBashExecTool } from "./bash-exec-tool.js";
4
+ import { createBashOutputTool } from "./bash-output-tool.js";
5
+ import { createKillProcessTool } from "./kill-process-tool.js";
6
+ const DEFAULT_SECURITY_LEVEL = "moderate";
7
+ const DEFAULT_MAX_TIMEOUT = 6e5;
8
+ const DEFAULT_MAX_CONCURRENT_PROCESSES = 5;
9
+ const DEFAULT_MAX_OUTPUT_BUFFER = 1 * 1024 * 1024;
10
+ const DEFAULT_ALLOWED_COMMANDS = [];
11
+ const DEFAULT_BLOCKED_COMMANDS = [];
12
+ const DEFAULT_ENVIRONMENT = {};
13
+ const ProcessToolsConfigSchema = z.object({
14
+ type: z.literal("process-tools"),
15
+ securityLevel: z.enum(["strict", "moderate", "permissive"]).default(DEFAULT_SECURITY_LEVEL).describe("Security level for command execution validation"),
16
+ maxTimeout: z.number().int().positive().max(DEFAULT_MAX_TIMEOUT).default(DEFAULT_MAX_TIMEOUT).describe(
17
+ `Maximum timeout for commands in milliseconds (max: ${DEFAULT_MAX_TIMEOUT / 1e3 / 60} minutes)`
18
+ ),
19
+ maxConcurrentProcesses: z.number().int().positive().default(DEFAULT_MAX_CONCURRENT_PROCESSES).describe(
20
+ `Maximum number of concurrent background processes (default: ${DEFAULT_MAX_CONCURRENT_PROCESSES})`
21
+ ),
22
+ maxOutputBuffer: z.number().int().positive().default(DEFAULT_MAX_OUTPUT_BUFFER).describe(
23
+ `Maximum output buffer size in bytes (default: ${DEFAULT_MAX_OUTPUT_BUFFER / 1024 / 1024}MB)`
24
+ ),
25
+ workingDirectory: z.string().optional().describe("Working directory for process execution (defaults to process.cwd())"),
26
+ allowedCommands: z.array(z.string()).default(DEFAULT_ALLOWED_COMMANDS).describe(
27
+ "Explicitly allowed commands (empty = all allowed with approval, strict mode only)"
28
+ ),
29
+ blockedCommands: z.array(z.string()).default(DEFAULT_BLOCKED_COMMANDS).describe("Blocked command patterns (applies to all security levels)"),
30
+ environment: z.record(z.string()).default(DEFAULT_ENVIRONMENT).describe("Custom environment variables to set for command execution"),
31
+ timeout: z.number().int().positive().max(DEFAULT_MAX_TIMEOUT).optional().describe(
32
+ `Default timeout in milliseconds (max: ${DEFAULT_MAX_TIMEOUT / 1e3 / 60} minutes)`
33
+ )
34
+ }).strict();
35
+ const processToolsProvider = {
36
+ type: "process-tools",
37
+ configSchema: ProcessToolsConfigSchema,
38
+ create: (config, context) => {
39
+ const { logger } = context;
40
+ logger.debug("Creating ProcessService for process tools");
41
+ const processService = new ProcessService(
42
+ {
43
+ securityLevel: config.securityLevel,
44
+ maxTimeout: config.maxTimeout,
45
+ maxConcurrentProcesses: config.maxConcurrentProcesses,
46
+ maxOutputBuffer: config.maxOutputBuffer,
47
+ workingDirectory: config.workingDirectory || process.cwd(),
48
+ allowedCommands: config.allowedCommands,
49
+ blockedCommands: config.blockedCommands,
50
+ environment: config.environment
51
+ },
52
+ logger
53
+ );
54
+ processService.initialize().catch((error) => {
55
+ logger.error(`Failed to initialize ProcessService: ${error.message}`);
56
+ });
57
+ logger.debug("ProcessService created - initialization will complete on first tool use");
58
+ return [
59
+ createBashExecTool(processService),
60
+ createBashOutputTool(processService),
61
+ createKillProcessTool(processService)
62
+ ];
63
+ },
64
+ metadata: {
65
+ displayName: "Process Tools",
66
+ description: "Process execution and management (bash, output, kill)",
67
+ category: "process"
68
+ }
69
+ };
70
+ export {
71
+ processToolsProvider
72
+ };
package/dist/types.cjs ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Process Service Types
3
+ *
4
+ * Types and interfaces for command execution and process management
5
+ */
6
+ /**
7
+ * Process execution options
8
+ */
9
+ interface ExecuteOptions {
10
+ /** Working directory */
11
+ cwd?: string | undefined;
12
+ /** Timeout in milliseconds (max: 600000) */
13
+ timeout?: number | undefined;
14
+ /** Run command in background */
15
+ runInBackground?: boolean | undefined;
16
+ /** Environment variables */
17
+ env?: Record<string, string> | undefined;
18
+ /** Description of what the command does (5-10 words) */
19
+ description?: string | undefined;
20
+ /** Abort signal for cancellation support */
21
+ abortSignal?: AbortSignal | undefined;
22
+ }
23
+ /**
24
+ * Process execution result (foreground execution only)
25
+ * For background execution, see ProcessHandle
26
+ */
27
+ interface ProcessResult {
28
+ stdout: string;
29
+ stderr: string;
30
+ exitCode: number;
31
+ duration: number;
32
+ }
33
+ /**
34
+ * Background process handle
35
+ */
36
+ interface ProcessHandle {
37
+ processId: string;
38
+ command: string;
39
+ pid?: number | undefined;
40
+ startedAt: Date;
41
+ description?: string | undefined;
42
+ }
43
+ /**
44
+ * Process output (for retrieving from background processes)
45
+ */
46
+ interface ProcessOutput {
47
+ stdout: string;
48
+ stderr: string;
49
+ status: 'running' | 'completed' | 'failed';
50
+ exitCode?: number | undefined;
51
+ duration?: number | undefined;
52
+ }
53
+ /**
54
+ * Process information
55
+ */
56
+ interface ProcessInfo {
57
+ processId: string;
58
+ command: string;
59
+ pid?: number | undefined;
60
+ status: 'running' | 'completed' | 'failed';
61
+ startedAt: Date;
62
+ completedAt?: Date | undefined;
63
+ exitCode?: number | undefined;
64
+ description?: string | undefined;
65
+ }
66
+ /**
67
+ * Command validation result
68
+ */
69
+ interface CommandValidation {
70
+ isValid: boolean;
71
+ error?: string;
72
+ normalizedCommand?: string;
73
+ requiresApproval?: boolean;
74
+ }
75
+ /**
76
+ * Process service configuration
77
+ */
78
+ interface ProcessConfig {
79
+ /** Security level for command execution */
80
+ securityLevel: 'strict' | 'moderate' | 'permissive';
81
+ /** Maximum timeout for commands in milliseconds */
82
+ maxTimeout: number;
83
+ /** Maximum concurrent background processes */
84
+ maxConcurrentProcesses: number;
85
+ /** Maximum output buffer size in bytes */
86
+ maxOutputBuffer: number;
87
+ /** Explicitly allowed commands (empty = all allowed with approval) */
88
+ allowedCommands: string[];
89
+ /** Blocked command patterns */
90
+ blockedCommands: string[];
91
+ /** Custom environment variables */
92
+ environment: Record<string, string>;
93
+ /** Working directory (defaults to process.cwd()) */
94
+ workingDirectory?: string | undefined;
95
+ }
96
+ /**
97
+ * Output buffer management
98
+ */
99
+ interface OutputBuffer {
100
+ stdout: string[];
101
+ stderr: string[];
102
+ complete: boolean;
103
+ lastRead: number;
104
+ bytesUsed: number;
105
+ truncated?: boolean;
106
+ }
107
+
108
+ export type { CommandValidation, ExecuteOptions, OutputBuffer, ProcessConfig, ProcessHandle, ProcessInfo, ProcessOutput, ProcessResult };
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Process Service Types
3
+ *
4
+ * Types and interfaces for command execution and process management
5
+ */
6
+ /**
7
+ * Process execution options
8
+ */
9
+ interface ExecuteOptions {
10
+ /** Working directory */
11
+ cwd?: string | undefined;
12
+ /** Timeout in milliseconds (max: 600000) */
13
+ timeout?: number | undefined;
14
+ /** Run command in background */
15
+ runInBackground?: boolean | undefined;
16
+ /** Environment variables */
17
+ env?: Record<string, string> | undefined;
18
+ /** Description of what the command does (5-10 words) */
19
+ description?: string | undefined;
20
+ /** Abort signal for cancellation support */
21
+ abortSignal?: AbortSignal | undefined;
22
+ }
23
+ /**
24
+ * Process execution result (foreground execution only)
25
+ * For background execution, see ProcessHandle
26
+ */
27
+ interface ProcessResult {
28
+ stdout: string;
29
+ stderr: string;
30
+ exitCode: number;
31
+ duration: number;
32
+ }
33
+ /**
34
+ * Background process handle
35
+ */
36
+ interface ProcessHandle {
37
+ processId: string;
38
+ command: string;
39
+ pid?: number | undefined;
40
+ startedAt: Date;
41
+ description?: string | undefined;
42
+ }
43
+ /**
44
+ * Process output (for retrieving from background processes)
45
+ */
46
+ interface ProcessOutput {
47
+ stdout: string;
48
+ stderr: string;
49
+ status: 'running' | 'completed' | 'failed';
50
+ exitCode?: number | undefined;
51
+ duration?: number | undefined;
52
+ }
53
+ /**
54
+ * Process information
55
+ */
56
+ interface ProcessInfo {
57
+ processId: string;
58
+ command: string;
59
+ pid?: number | undefined;
60
+ status: 'running' | 'completed' | 'failed';
61
+ startedAt: Date;
62
+ completedAt?: Date | undefined;
63
+ exitCode?: number | undefined;
64
+ description?: string | undefined;
65
+ }
66
+ /**
67
+ * Command validation result
68
+ */
69
+ interface CommandValidation {
70
+ isValid: boolean;
71
+ error?: string;
72
+ normalizedCommand?: string;
73
+ requiresApproval?: boolean;
74
+ }
75
+ /**
76
+ * Process service configuration
77
+ */
78
+ interface ProcessConfig {
79
+ /** Security level for command execution */
80
+ securityLevel: 'strict' | 'moderate' | 'permissive';
81
+ /** Maximum timeout for commands in milliseconds */
82
+ maxTimeout: number;
83
+ /** Maximum concurrent background processes */
84
+ maxConcurrentProcesses: number;
85
+ /** Maximum output buffer size in bytes */
86
+ maxOutputBuffer: number;
87
+ /** Explicitly allowed commands (empty = all allowed with approval) */
88
+ allowedCommands: string[];
89
+ /** Blocked command patterns */
90
+ blockedCommands: string[];
91
+ /** Custom environment variables */
92
+ environment: Record<string, string>;
93
+ /** Working directory (defaults to process.cwd()) */
94
+ workingDirectory?: string | undefined;
95
+ }
96
+ /**
97
+ * Output buffer management
98
+ */
99
+ interface OutputBuffer {
100
+ stdout: string[];
101
+ stderr: string[];
102
+ complete: boolean;
103
+ lastRead: number;
104
+ bytesUsed: number;
105
+ truncated?: boolean;
106
+ }
107
+
108
+ export type { CommandValidation, ExecuteOptions, OutputBuffer, ProcessConfig, ProcessHandle, ProcessInfo, ProcessOutput, ProcessResult };
package/dist/types.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@dexto/tools-process",
3
+ "version": "1.5.0",
4
+ "description": "Process tools provider for Dexto agents",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "keywords": [
15
+ "dexto",
16
+ "tools",
17
+ "process",
18
+ "bash",
19
+ "shell"
20
+ ],
21
+ "dependencies": {
22
+ "zod": "^3.25.0",
23
+ "@dexto/core": "1.5.0"
24
+ },
25
+ "devDependencies": {
26
+ "tsup": "^8.0.0",
27
+ "typescript": "^5.3.3"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsup",
35
+ "typecheck": "tsc --noEmit",
36
+ "clean": "rm -rf dist"
37
+ }
38
+ }