@dexto/tools-process 1.5.8 → 1.6.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 (55) hide show
  1. package/dist/bash-exec-tool.cjs +23 -10
  2. package/dist/bash-exec-tool.d.cts +25 -4
  3. package/dist/bash-exec-tool.d.ts +27 -9
  4. package/dist/bash-exec-tool.d.ts.map +1 -0
  5. package/dist/bash-exec-tool.js +26 -10
  6. package/dist/bash-output-tool.cjs +8 -5
  7. package/dist/bash-output-tool.d.cts +12 -3
  8. package/dist/bash-output-tool.d.ts +13 -8
  9. package/dist/bash-output-tool.d.ts.map +1 -0
  10. package/dist/bash-output-tool.js +8 -5
  11. package/dist/command-pattern-utils.cjs +83 -0
  12. package/dist/command-pattern-utils.d.cts +30 -0
  13. package/dist/command-pattern-utils.d.ts +29 -0
  14. package/dist/command-pattern-utils.d.ts.map +1 -0
  15. package/dist/command-pattern-utils.js +56 -0
  16. package/dist/command-pattern-utils.test.cjs +80 -0
  17. package/dist/command-pattern-utils.test.d.cts +2 -0
  18. package/dist/command-pattern-utils.test.d.ts +2 -0
  19. package/dist/command-pattern-utils.test.d.ts.map +1 -0
  20. package/dist/command-pattern-utils.test.js +83 -0
  21. package/dist/command-validator.d.cts +2 -2
  22. package/dist/command-validator.d.ts +5 -8
  23. package/dist/command-validator.d.ts.map +1 -0
  24. package/dist/error-codes.d.ts +2 -3
  25. package/dist/error-codes.d.ts.map +1 -0
  26. package/dist/errors.d.ts +4 -7
  27. package/dist/errors.d.ts.map +1 -0
  28. package/dist/index.cjs +3 -3
  29. package/dist/index.d.cts +3 -1
  30. package/dist/index.d.ts +9 -4
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +2 -2
  33. package/dist/kill-process-tool.cjs +8 -5
  34. package/dist/kill-process-tool.d.cts +12 -3
  35. package/dist/kill-process-tool.d.ts +13 -8
  36. package/dist/kill-process-tool.d.ts.map +1 -0
  37. package/dist/kill-process-tool.js +8 -5
  38. package/dist/process-service.cjs +11 -1
  39. package/dist/process-service.d.cts +9 -5
  40. package/dist/process-service.d.ts +12 -11
  41. package/dist/process-service.d.ts.map +1 -0
  42. package/dist/process-service.js +11 -1
  43. package/dist/{tool-provider.cjs → tool-factory-config.cjs} +6 -48
  44. package/dist/{tool-provider.d.cts → tool-factory-config.d.cts} +4 -20
  45. package/dist/{tool-provider.d.ts → tool-factory-config.d.ts} +8 -27
  46. package/dist/tool-factory-config.d.ts.map +1 -0
  47. package/dist/{tool-provider.js → tool-factory-config.js} +2 -44
  48. package/dist/tool-factory.cjs +77 -0
  49. package/dist/tool-factory.d.cts +7 -0
  50. package/dist/tool-factory.d.ts +4 -0
  51. package/dist/tool-factory.d.ts.map +1 -0
  52. package/dist/tool-factory.js +53 -0
  53. package/dist/types.d.ts +9 -10
  54. package/dist/types.d.ts.map +1 -0
  55. package/package.json +4 -3
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var import_command_pattern_utils = require("./command-pattern-utils.js");
3
+ var import_vitest = require("vitest");
4
+ (0, import_vitest.describe)("command-pattern-utils", () => {
5
+ (0, import_vitest.describe)("isDangerousCommand", () => {
6
+ (0, import_vitest.it)("should detect dangerous commands", () => {
7
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("rm -rf /")).toBe(true);
8
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("sudo apt install")).toBe(true);
9
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("chmod 777 file")).toBe(true);
10
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("kill -9 1234")).toBe(true);
11
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("dd if=/dev/zero of=/dev/sda")).toBe(true);
12
+ });
13
+ (0, import_vitest.it)("should not flag safe commands", () => {
14
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("ls -la")).toBe(false);
15
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("git status")).toBe(false);
16
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("npm install")).toBe(false);
17
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("cat file.txt")).toBe(false);
18
+ });
19
+ (0, import_vitest.it)("should be case-insensitive", () => {
20
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("RM -rf /")).toBe(true);
21
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("SUDO apt install")).toBe(true);
22
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("Chmod 777 file")).toBe(true);
23
+ });
24
+ (0, import_vitest.it)("should handle empty input", () => {
25
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)("")).toBe(false);
26
+ (0, import_vitest.expect)((0, import_command_pattern_utils.isDangerousCommand)(" ")).toBe(false);
27
+ });
28
+ });
29
+ (0, import_vitest.describe)("generateCommandPatternKey", () => {
30
+ (0, import_vitest.it)("should generate patterns for simple commands", () => {
31
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("ls")).toBe("ls *");
32
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("pwd")).toBe("pwd *");
33
+ });
34
+ (0, import_vitest.it)("should ignore flags when choosing subcommand", () => {
35
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("ls -la")).toBe("ls *");
36
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("git -v status")).toBe("git status *");
37
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("npm --verbose install")).toBe("npm install *");
38
+ });
39
+ (0, import_vitest.it)("should generate subcommand patterns", () => {
40
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("git status")).toBe("git status *");
41
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("git push origin main")).toBe("git push *");
42
+ });
43
+ (0, import_vitest.it)("should return null for dangerous commands", () => {
44
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("rm -rf /")).toBeNull();
45
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("sudo apt install")).toBeNull();
46
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("shutdown -h now")).toBeNull();
47
+ });
48
+ (0, import_vitest.it)("should handle empty input", () => {
49
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)("")).toBeNull();
50
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)(" ")).toBeNull();
51
+ });
52
+ (0, import_vitest.it)("should trim and normalize whitespace", () => {
53
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)(" ls -la ")).toBe("ls *");
54
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternKey)(" git push origin ")).toBe("git push *");
55
+ });
56
+ });
57
+ (0, import_vitest.describe)("generateCommandPatternSuggestions", () => {
58
+ (0, import_vitest.it)("should generate broad-to-narrow suggestions", () => {
59
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternSuggestions)("ls")).toEqual(["ls *"]);
60
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternSuggestions)("git push origin main")).toEqual([
61
+ "git push *",
62
+ "git *"
63
+ ]);
64
+ });
65
+ (0, import_vitest.it)("should return empty for dangerous commands", () => {
66
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternSuggestions)("rm -rf /")).toEqual([]);
67
+ });
68
+ (0, import_vitest.it)("should handle empty input", () => {
69
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternSuggestions)("")).toEqual([]);
70
+ (0, import_vitest.expect)((0, import_command_pattern_utils.generateCommandPatternSuggestions)(" ")).toEqual([]);
71
+ });
72
+ (0, import_vitest.it)("should keep suggestions consistent with pattern key", () => {
73
+ const command = "git push origin main";
74
+ const patternKey = (0, import_command_pattern_utils.generateCommandPatternKey)(command);
75
+ const suggestions = (0, import_command_pattern_utils.generateCommandPatternSuggestions)(command);
76
+ (0, import_vitest.expect)(patternKey).toBe("git push *");
77
+ (0, import_vitest.expect)(suggestions[0]).toBe(patternKey);
78
+ });
79
+ });
80
+ });
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=command-pattern-utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-pattern-utils.test.d.ts","sourceRoot":"","sources":["../src/command-pattern-utils.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ import {
2
+ generateCommandPatternKey,
3
+ generateCommandPatternSuggestions,
4
+ isDangerousCommand
5
+ } from "./command-pattern-utils.js";
6
+ import { describe, it, expect } from "vitest";
7
+ describe("command-pattern-utils", () => {
8
+ describe("isDangerousCommand", () => {
9
+ it("should detect dangerous commands", () => {
10
+ expect(isDangerousCommand("rm -rf /")).toBe(true);
11
+ expect(isDangerousCommand("sudo apt install")).toBe(true);
12
+ expect(isDangerousCommand("chmod 777 file")).toBe(true);
13
+ expect(isDangerousCommand("kill -9 1234")).toBe(true);
14
+ expect(isDangerousCommand("dd if=/dev/zero of=/dev/sda")).toBe(true);
15
+ });
16
+ it("should not flag safe commands", () => {
17
+ expect(isDangerousCommand("ls -la")).toBe(false);
18
+ expect(isDangerousCommand("git status")).toBe(false);
19
+ expect(isDangerousCommand("npm install")).toBe(false);
20
+ expect(isDangerousCommand("cat file.txt")).toBe(false);
21
+ });
22
+ it("should be case-insensitive", () => {
23
+ expect(isDangerousCommand("RM -rf /")).toBe(true);
24
+ expect(isDangerousCommand("SUDO apt install")).toBe(true);
25
+ expect(isDangerousCommand("Chmod 777 file")).toBe(true);
26
+ });
27
+ it("should handle empty input", () => {
28
+ expect(isDangerousCommand("")).toBe(false);
29
+ expect(isDangerousCommand(" ")).toBe(false);
30
+ });
31
+ });
32
+ describe("generateCommandPatternKey", () => {
33
+ it("should generate patterns for simple commands", () => {
34
+ expect(generateCommandPatternKey("ls")).toBe("ls *");
35
+ expect(generateCommandPatternKey("pwd")).toBe("pwd *");
36
+ });
37
+ it("should ignore flags when choosing subcommand", () => {
38
+ expect(generateCommandPatternKey("ls -la")).toBe("ls *");
39
+ expect(generateCommandPatternKey("git -v status")).toBe("git status *");
40
+ expect(generateCommandPatternKey("npm --verbose install")).toBe("npm install *");
41
+ });
42
+ it("should generate subcommand patterns", () => {
43
+ expect(generateCommandPatternKey("git status")).toBe("git status *");
44
+ expect(generateCommandPatternKey("git push origin main")).toBe("git push *");
45
+ });
46
+ it("should return null for dangerous commands", () => {
47
+ expect(generateCommandPatternKey("rm -rf /")).toBeNull();
48
+ expect(generateCommandPatternKey("sudo apt install")).toBeNull();
49
+ expect(generateCommandPatternKey("shutdown -h now")).toBeNull();
50
+ });
51
+ it("should handle empty input", () => {
52
+ expect(generateCommandPatternKey("")).toBeNull();
53
+ expect(generateCommandPatternKey(" ")).toBeNull();
54
+ });
55
+ it("should trim and normalize whitespace", () => {
56
+ expect(generateCommandPatternKey(" ls -la ")).toBe("ls *");
57
+ expect(generateCommandPatternKey(" git push origin ")).toBe("git push *");
58
+ });
59
+ });
60
+ describe("generateCommandPatternSuggestions", () => {
61
+ it("should generate broad-to-narrow suggestions", () => {
62
+ expect(generateCommandPatternSuggestions("ls")).toEqual(["ls *"]);
63
+ expect(generateCommandPatternSuggestions("git push origin main")).toEqual([
64
+ "git push *",
65
+ "git *"
66
+ ]);
67
+ });
68
+ it("should return empty for dangerous commands", () => {
69
+ expect(generateCommandPatternSuggestions("rm -rf /")).toEqual([]);
70
+ });
71
+ it("should handle empty input", () => {
72
+ expect(generateCommandPatternSuggestions("")).toEqual([]);
73
+ expect(generateCommandPatternSuggestions(" ")).toEqual([]);
74
+ });
75
+ it("should keep suggestions consistent with pattern key", () => {
76
+ const command = "git push origin main";
77
+ const patternKey = generateCommandPatternKey(command);
78
+ const suggestions = generateCommandPatternSuggestions(command);
79
+ expect(patternKey).toBe("git push *");
80
+ expect(suggestions[0]).toBe(patternKey);
81
+ });
82
+ });
83
+ });
@@ -1,5 +1,5 @@
1
1
  import { ProcessConfig, CommandValidation } from './types.cjs';
2
- import { IDextoLogger } from '@dexto/core';
2
+ import { Logger } from '@dexto/core';
3
3
 
4
4
  /**
5
5
  * Command Validator
@@ -21,7 +21,7 @@ import { IDextoLogger } from '@dexto/core';
21
21
  declare class CommandValidator {
22
22
  private config;
23
23
  private logger;
24
- constructor(config: ProcessConfig, logger: IDextoLogger);
24
+ constructor(config: ProcessConfig, logger: Logger);
25
25
  /**
26
26
  * Validate a command for security and policy compliance
27
27
  */
@@ -1,12 +1,10 @@
1
- import { ProcessConfig, CommandValidation } from './types.js';
2
- import { IDextoLogger } from '@dexto/core';
3
-
4
1
  /**
5
2
  * Command Validator
6
3
  *
7
4
  * Security-focused command validation for process execution
8
5
  */
9
-
6
+ import { ProcessConfig, CommandValidation } from './types.js';
7
+ import type { Logger } from '@dexto/core';
10
8
  /**
11
9
  * CommandValidator - Validates commands for security and policy compliance
12
10
  *
@@ -18,10 +16,10 @@ import { IDextoLogger } from '@dexto/core';
18
16
  * 5. Shell metacharacter analysis
19
17
  * TODO: Add tests for this class
20
18
  */
21
- declare class CommandValidator {
19
+ export declare class CommandValidator {
22
20
  private config;
23
21
  private logger;
24
- constructor(config: ProcessConfig, logger: IDextoLogger);
22
+ constructor(config: ProcessConfig, logger: Logger);
25
23
  /**
26
24
  * Validate a command for security and policy compliance
27
25
  */
@@ -48,5 +46,4 @@ declare class CommandValidator {
48
46
  */
49
47
  getSecurityLevel(): string;
50
48
  }
51
-
52
- export { CommandValidator };
49
+ //# sourceMappingURL=command-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-validator.d.ts","sourceRoot":"","sources":["../src/command-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAkQ1C;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM;IAQjD;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAgFnD;;OAEG;IACH,OAAO,CAAC,eAAe;IAgCvB;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAyCpC;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,gBAAgB,IAAI,MAAM;CAG7B"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Standardized error codes for process execution and management
5
5
  */
6
- declare enum ProcessErrorCode {
6
+ export declare enum ProcessErrorCode {
7
7
  INVALID_COMMAND = "PROCESS_INVALID_COMMAND",
8
8
  COMMAND_BLOCKED = "PROCESS_COMMAND_BLOCKED",
9
9
  COMMAND_TOO_LONG = "PROCESS_COMMAND_TOO_LONG",
@@ -22,5 +22,4 @@ declare enum ProcessErrorCode {
22
22
  INVALID_CONFIG = "PROCESS_INVALID_CONFIG",
23
23
  SERVICE_NOT_INITIALIZED = "PROCESS_SERVICE_NOT_INITIALIZED"
24
24
  }
25
-
26
- export { ProcessErrorCode };
25
+ //# sourceMappingURL=error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oBAAY,gBAAgB;IAExB,eAAe,4BAA4B;IAC3C,eAAe,4BAA4B;IAC3C,gBAAgB,6BAA6B;IAC7C,kBAAkB,+BAA+B;IACjD,iBAAiB,8BAA8B;IAC/C,eAAe,4BAA4B;IAG3C,gBAAgB,6BAA6B;IAC7C,OAAO,oBAAoB;IAC3B,iBAAiB,8BAA8B;IAC/C,iBAAiB,8BAA8B;IAC/C,yBAAyB,sCAAsC;IAG/D,iBAAiB,sBAAsB;IACvC,kBAAkB,+BAA+B;IACjD,WAAW,wBAAwB;IACnC,kBAAkB,+BAA+B;IAGjD,cAAc,2BAA2B;IACzC,uBAAuB,oCAAoC;CAC9D"}
package/dist/errors.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { DextoRuntimeError } from '@dexto/core';
2
-
3
1
  /**
4
2
  * Process Service Errors
5
3
  *
6
4
  * Error classes for process execution and management
7
5
  */
8
-
9
- interface ProcessErrorContext {
6
+ import { DextoRuntimeError } from '@dexto/core';
7
+ export interface ProcessErrorContext {
10
8
  command?: string;
11
9
  processId?: string;
12
10
  timeout?: number;
@@ -15,7 +13,7 @@ interface ProcessErrorContext {
15
13
  /**
16
14
  * Factory class for creating Process-related errors
17
15
  */
18
- declare class ProcessError {
16
+ export declare class ProcessError {
19
17
  private constructor();
20
18
  /**
21
19
  * Invalid command error
@@ -86,5 +84,4 @@ declare class ProcessError {
86
84
  */
87
85
  static notInitialized(): DextoRuntimeError;
88
86
  }
89
-
90
- export { ProcessError, type ProcessErrorContext };
87
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAa,MAAM,aAAa,CAAC;AAM3D,MAAM,WAAW,mBAAmB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,qBAAa,YAAY;IACrB,OAAO;IAIP;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB;IAUzE;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB;IAUzE;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB;IAU3E;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAU5E;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB;IAW5E;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAUzD;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB;IAUzE;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAWnE;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAU3D;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAW1D;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB;IAU/E;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB;IAU5D;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB;IAWxE;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB;IAUtE;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAW5F;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB;IAUvD;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,iBAAiB;CAU7C"}
package/dist/index.cjs CHANGED
@@ -25,10 +25,10 @@ __export(index_exports, {
25
25
  createBashExecTool: () => import_bash_exec_tool.createBashExecTool,
26
26
  createBashOutputTool: () => import_bash_output_tool.createBashOutputTool,
27
27
  createKillProcessTool: () => import_kill_process_tool.createKillProcessTool,
28
- processToolsProvider: () => import_tool_provider.processToolsProvider
28
+ processToolsFactory: () => import_tool_factory.processToolsFactory
29
29
  });
30
30
  module.exports = __toCommonJS(index_exports);
31
- var import_tool_provider = require("./tool-provider.js");
31
+ var import_tool_factory = require("./tool-factory.js");
32
32
  var import_process_service = require("./process-service.js");
33
33
  var import_command_validator = require("./command-validator.js");
34
34
  var import_errors = require("./errors.js");
@@ -45,5 +45,5 @@ var import_kill_process_tool = require("./kill-process-tool.js");
45
45
  createBashExecTool,
46
46
  createBashOutputTool,
47
47
  createKillProcessTool,
48
- processToolsProvider
48
+ processToolsFactory
49
49
  });
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { processToolsProvider } from './tool-provider.cjs';
1
+ export { processToolsFactory } from './tool-factory.cjs';
2
2
  export { ProcessService } from './process-service.cjs';
3
3
  export { CommandValidator } from './command-validator.cjs';
4
4
  export { ProcessError } from './errors.cjs';
@@ -7,5 +7,7 @@ export { CommandValidation, ExecuteOptions, OutputBuffer, ProcessConfig, Process
7
7
  export { createBashExecTool } from './bash-exec-tool.cjs';
8
8
  export { createBashOutputTool } from './bash-output-tool.cjs';
9
9
  export { createKillProcessTool } from './kill-process-tool.cjs';
10
+ import '@dexto/agent-config';
11
+ import './tool-factory-config.cjs';
10
12
  import 'zod';
11
13
  import '@dexto/core';
package/dist/index.d.ts CHANGED
@@ -1,11 +1,16 @@
1
- export { processToolsProvider } from './tool-provider.js';
1
+ /**
2
+ * @dexto/tools-process
3
+ *
4
+ * Process tools factory for Dexto agents.
5
+ * Provides process operation tools: bash exec, output, kill.
6
+ */
7
+ export { processToolsFactory } from './tool-factory.js';
2
8
  export { ProcessService } from './process-service.js';
3
9
  export { CommandValidator } from './command-validator.js';
4
10
  export { ProcessError } from './errors.js';
5
11
  export { ProcessErrorCode } from './error-codes.js';
6
- export { CommandValidation, ExecuteOptions, OutputBuffer, ProcessConfig, ProcessHandle, ProcessInfo, ProcessOutput, ProcessResult } from './types.js';
12
+ export type { ProcessConfig, ExecuteOptions, ProcessResult, ProcessHandle, ProcessOutput, ProcessInfo, CommandValidation, OutputBuffer, } from './types.js';
7
13
  export { createBashExecTool } from './bash-exec-tool.js';
8
14
  export { createBashOutputTool } from './bash-output-tool.js';
9
15
  export { createKillProcessTool } from './kill-process-tool.js';
10
- import 'zod';
11
- import '@dexto/core';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,YAAY,EACR,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,YAAY,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { processToolsProvider } from "./tool-provider.js";
1
+ import { processToolsFactory } from "./tool-factory.js";
2
2
  import { ProcessService } from "./process-service.js";
3
3
  import { CommandValidator } from "./command-validator.js";
4
4
  import { ProcessError } from "./errors.js";
@@ -14,5 +14,5 @@ export {
14
14
  createBashExecTool,
15
15
  createBashOutputTool,
16
16
  createKillProcessTool,
17
- processToolsProvider
17
+ processToolsFactory
18
18
  };
@@ -22,24 +22,27 @@ __export(kill_process_tool_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(kill_process_tool_exports);
24
24
  var import_zod = require("zod");
25
+ var import_core = require("@dexto/core");
25
26
  const KillProcessInputSchema = import_zod.z.object({
26
27
  process_id: import_zod.z.string().describe("Process ID of the background process to terminate")
27
28
  }).strict();
28
- function createKillProcessTool(processService) {
29
- return {
29
+ function createKillProcessTool(getProcessService) {
30
+ return (0, import_core.defineTool)({
30
31
  id: "kill_process",
32
+ displayName: "Kill",
31
33
  description: "Terminate a background process started with bash_exec. Sends SIGTERM signal first, then SIGKILL if process doesn't terminate within 5 seconds. Only works on processes started by this agent. Returns success status and whether the process was running. Does not require additional approval (process was already approved when started).",
32
34
  inputSchema: KillProcessInputSchema,
33
- execute: async (input, _context) => {
35
+ async execute(input, context) {
36
+ const resolvedProcessService = await getProcessService(context);
34
37
  const { process_id } = input;
35
- await processService.killProcess(process_id);
38
+ await resolvedProcessService.killProcess(process_id);
36
39
  return {
37
40
  success: true,
38
41
  process_id,
39
42
  message: `Termination signal sent to process ${process_id}`
40
43
  };
41
44
  }
42
- };
45
+ });
43
46
  }
44
47
  // Annotate the CommonJS export names for ESM import in node:
45
48
  0 && (module.exports = {
@@ -1,5 +1,7 @@
1
- import { InternalTool } from '@dexto/core';
2
- import { ProcessService } from './process-service.cjs';
1
+ import { z } from 'zod';
2
+ import { Tool } from '@dexto/core';
3
+ import { ProcessServiceGetter } from './bash-exec-tool.cjs';
4
+ import './process-service.cjs';
3
5
  import './types.cjs';
4
6
 
5
7
  /**
@@ -8,9 +10,16 @@ import './types.cjs';
8
10
  * Internal tool for terminating background processes
9
11
  */
10
12
 
13
+ declare const KillProcessInputSchema: z.ZodObject<{
14
+ process_id: z.ZodString;
15
+ }, "strict", z.ZodTypeAny, {
16
+ process_id: string;
17
+ }, {
18
+ process_id: string;
19
+ }>;
11
20
  /**
12
21
  * Create the kill_process internal tool
13
22
  */
14
- declare function createKillProcessTool(processService: ProcessService): InternalTool;
23
+ declare function createKillProcessTool(getProcessService: ProcessServiceGetter): Tool<typeof KillProcessInputSchema>;
15
24
 
16
25
  export { createKillProcessTool };
@@ -1,16 +1,21 @@
1
- import { InternalTool } from '@dexto/core';
2
- import { ProcessService } from './process-service.js';
3
- import './types.js';
4
-
5
1
  /**
6
2
  * Kill Process Tool
7
3
  *
8
4
  * Internal tool for terminating background processes
9
5
  */
10
-
6
+ import { z } from 'zod';
7
+ import type { Tool } from '@dexto/core';
8
+ import type { ProcessServiceGetter } from './bash-exec-tool.js';
9
+ declare const KillProcessInputSchema: z.ZodObject<{
10
+ process_id: z.ZodString;
11
+ }, "strict", z.ZodTypeAny, {
12
+ process_id: string;
13
+ }, {
14
+ process_id: string;
15
+ }>;
11
16
  /**
12
17
  * Create the kill_process internal tool
13
18
  */
14
- declare function createKillProcessTool(processService: ProcessService): InternalTool;
15
-
16
- export { createKillProcessTool };
19
+ export declare function createKillProcessTool(getProcessService: ProcessServiceGetter): Tool<typeof KillProcessInputSchema>;
20
+ export {};
21
+ //# sourceMappingURL=kill-process-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill-process-tool.d.ts","sourceRoot":"","sources":["../src/kill-process-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,QAAA,MAAM,sBAAsB;;;;;;EAIf,CAAC;AAEd;;GAEG;AACH,wBAAgB,qBAAqB,CACjC,iBAAiB,EAAE,oBAAoB,GACxC,IAAI,CAAC,OAAO,sBAAsB,CAAC,CAwBrC"}
@@ -1,22 +1,25 @@
1
1
  import { z } from "zod";
2
+ import { defineTool } from "@dexto/core";
2
3
  const KillProcessInputSchema = z.object({
3
4
  process_id: z.string().describe("Process ID of the background process to terminate")
4
5
  }).strict();
5
- function createKillProcessTool(processService) {
6
- return {
6
+ function createKillProcessTool(getProcessService) {
7
+ return defineTool({
7
8
  id: "kill_process",
9
+ displayName: "Kill",
8
10
  description: "Terminate a background process started with bash_exec. Sends SIGTERM signal first, then SIGKILL if process doesn't terminate within 5 seconds. Only works on processes started by this agent. Returns success status and whether the process was running. Does not require additional approval (process was already approved when started).",
9
11
  inputSchema: KillProcessInputSchema,
10
- execute: async (input, _context) => {
12
+ async execute(input, context) {
13
+ const resolvedProcessService = await getProcessService(context);
11
14
  const { process_id } = input;
12
- await processService.killProcess(process_id);
15
+ await resolvedProcessService.killProcess(process_id);
13
16
  return {
14
17
  success: true,
15
18
  process_id,
16
19
  message: `Termination signal sent to process ${process_id}`
17
20
  };
18
21
  }
19
- };
22
+ });
20
23
  }
21
24
  export {
22
25
  createKillProcessTool
@@ -48,7 +48,7 @@ class ProcessService {
48
48
  /**
49
49
  * Create a new ProcessService with validated configuration.
50
50
  *
51
- * @param config - Fully-validated configuration from provider schema.
51
+ * @param config - Fully-validated configuration from the factory schema.
52
52
  * All required fields have values, defaults already applied.
53
53
  * @param logger - Logger instance for this service
54
54
  */
@@ -504,6 +504,16 @@ Process terminated by signal ${signal ?? "UNKNOWN"}`;
504
504
  getConfig() {
505
505
  return { ...this.config };
506
506
  }
507
+ /**
508
+ * Update the working directory at runtime (e.g., when workspace changes).
509
+ */
510
+ setWorkingDirectory(workingDirectory) {
511
+ const normalized = workingDirectory?.trim();
512
+ if (!normalized) return;
513
+ if (this.config.workingDirectory === normalized) return;
514
+ this.config = { ...this.config, workingDirectory: normalized };
515
+ this.logger.info(`ProcessService working directory set to ${normalized}`);
516
+ }
507
517
  /**
508
518
  * Resolve and confine cwd to the configured working directory
509
519
  */
@@ -1,5 +1,5 @@
1
1
  import { ProcessConfig, ExecuteOptions, ProcessResult, ProcessHandle, ProcessOutput, ProcessInfo } from './types.cjs';
2
- import { IDextoLogger } from '@dexto/core';
2
+ import { Logger } from '@dexto/core';
3
3
 
4
4
  /**
5
5
  * Process Service
@@ -10,8 +10,8 @@ import { IDextoLogger } from '@dexto/core';
10
10
  /**
11
11
  * ProcessService - Handles command execution and process management
12
12
  *
13
- * This service receives fully-validated configuration from the Process Tools Provider.
14
- * All defaults have been applied by the provider's schema, so the service trusts the config
13
+ * This service receives fully-validated configuration from the Process Tools Factory.
14
+ * All defaults have been applied by the factory's schema, so the service trusts the config
15
15
  * and uses it as-is without any fallback logic.
16
16
  *
17
17
  * TODO: Add tests for this class
@@ -26,11 +26,11 @@ declare class ProcessService {
26
26
  /**
27
27
  * Create a new ProcessService with validated configuration.
28
28
  *
29
- * @param config - Fully-validated configuration from provider schema.
29
+ * @param config - Fully-validated configuration from the factory schema.
30
30
  * All required fields have values, defaults already applied.
31
31
  * @param logger - Logger instance for this service
32
32
  */
33
- constructor(config: ProcessConfig, logger: IDextoLogger);
33
+ constructor(config: ProcessConfig, logger: Logger);
34
34
  /**
35
35
  * Initialize the service.
36
36
  * Safe to call multiple times - subsequent calls return the same promise.
@@ -83,6 +83,10 @@ declare class ProcessService {
83
83
  * Get service configuration
84
84
  */
85
85
  getConfig(): Readonly<ProcessConfig>;
86
+ /**
87
+ * Update the working directory at runtime (e.g., when workspace changes).
88
+ */
89
+ setWorkingDirectory(workingDirectory: string): void;
86
90
  /**
87
91
  * Resolve and confine cwd to the configured working directory
88
92
  */
@@ -1,22 +1,20 @@
1
- import { ProcessConfig, ExecuteOptions, ProcessResult, ProcessHandle, ProcessOutput, ProcessInfo } from './types.js';
2
- import { IDextoLogger } from '@dexto/core';
3
-
4
1
  /**
5
2
  * Process Service
6
3
  *
7
4
  * Secure command execution and process management for Dexto internal tools
8
5
  */
9
-
6
+ import { ProcessConfig, ExecuteOptions, ProcessResult, ProcessHandle, ProcessOutput, ProcessInfo } from './types.js';
7
+ import type { Logger } from '@dexto/core';
10
8
  /**
11
9
  * ProcessService - Handles command execution and process management
12
10
  *
13
- * This service receives fully-validated configuration from the Process Tools Provider.
14
- * All defaults have been applied by the provider's schema, so the service trusts the config
11
+ * This service receives fully-validated configuration from the Process Tools Factory.
12
+ * All defaults have been applied by the factory's schema, so the service trusts the config
15
13
  * and uses it as-is without any fallback logic.
16
14
  *
17
15
  * TODO: Add tests for this class
18
16
  */
19
- declare class ProcessService {
17
+ export declare class ProcessService {
20
18
  private config;
21
19
  private commandValidator;
22
20
  private initialized;
@@ -26,11 +24,11 @@ declare class ProcessService {
26
24
  /**
27
25
  * Create a new ProcessService with validated configuration.
28
26
  *
29
- * @param config - Fully-validated configuration from provider schema.
27
+ * @param config - Fully-validated configuration from the factory schema.
30
28
  * All required fields have values, defaults already applied.
31
29
  * @param logger - Logger instance for this service
32
30
  */
33
- constructor(config: ProcessConfig, logger: IDextoLogger);
31
+ constructor(config: ProcessConfig, logger: Logger);
34
32
  /**
35
33
  * Initialize the service.
36
34
  * Safe to call multiple times - subsequent calls return the same promise.
@@ -83,6 +81,10 @@ declare class ProcessService {
83
81
  * Get service configuration
84
82
  */
85
83
  getConfig(): Readonly<ProcessConfig>;
84
+ /**
85
+ * Update the working directory at runtime (e.g., when workspace changes).
86
+ */
87
+ setWorkingDirectory(workingDirectory: string): void;
86
88
  /**
87
89
  * Resolve and confine cwd to the configured working directory
88
90
  */
@@ -92,5 +94,4 @@ declare class ProcessService {
92
94
  */
93
95
  cleanup(): Promise<void>;
94
96
  }
95
-
96
- export { ProcessService };
97
+ //# sourceMappingURL=process-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-service.d.ts","sourceRoot":"","sources":["../src/process-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EACH,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EAEd,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAoB1C;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,mBAAmB,CAA6C;IACxE,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;;;OAMG;gBACS,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM;IAQjD;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B;;OAEG;YACW,YAAY;IAa1B;;;;OAIG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOxC;;OAEG;IACG,cAAc,CAChB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,cAAmB,GAC7B,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;IAqDzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAO;IAEjD;;OAEG;YACW,eAAe;IA6B7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA8KzB;;OAEG;YACW,mBAAmB;IAoKjC;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA6BjE;;OAEG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCnD;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAe7C;;OAEG;IACH,OAAO,CAAC,aAAa;IAMrB;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,aAAa,CAAC;IAIpC;;OAEG;IACH,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI;IAQnD;;OAEG;IACH,OAAO,CAAC,cAAc;IAetB;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAcjC"}