@halfagiraf/clawx 0.1.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 (69) hide show
  1. package/.env.example +44 -0
  2. package/LICENSE +21 -0
  3. package/README.md +489 -0
  4. package/clawx.json.example +23 -0
  5. package/dist/cli/main.d.ts +21 -0
  6. package/dist/cli/main.d.ts.map +1 -0
  7. package/dist/cli/main.js +176 -0
  8. package/dist/cli/main.js.map +1 -0
  9. package/dist/cli/repl.d.ts +11 -0
  10. package/dist/cli/repl.d.ts.map +1 -0
  11. package/dist/cli/repl.js +119 -0
  12. package/dist/cli/repl.js.map +1 -0
  13. package/dist/cli/tui.d.ts +35 -0
  14. package/dist/cli/tui.d.ts.map +1 -0
  15. package/dist/cli/tui.js +92 -0
  16. package/dist/cli/tui.js.map +1 -0
  17. package/dist/config/index.d.ts +9 -0
  18. package/dist/config/index.d.ts.map +1 -0
  19. package/dist/config/index.js +106 -0
  20. package/dist/config/index.js.map +1 -0
  21. package/dist/core/agent.d.ts +53 -0
  22. package/dist/core/agent.d.ts.map +1 -0
  23. package/dist/core/agent.js +152 -0
  24. package/dist/core/agent.js.map +1 -0
  25. package/dist/core/provider.d.ts +30 -0
  26. package/dist/core/provider.d.ts.map +1 -0
  27. package/dist/core/provider.js +76 -0
  28. package/dist/core/provider.js.map +1 -0
  29. package/dist/core/session.d.ts +37 -0
  30. package/dist/core/session.d.ts.map +1 -0
  31. package/dist/core/session.js +87 -0
  32. package/dist/core/session.js.map +1 -0
  33. package/dist/core/streaming.d.ts +27 -0
  34. package/dist/core/streaming.d.ts.map +1 -0
  35. package/dist/core/streaming.js +137 -0
  36. package/dist/core/streaming.js.map +1 -0
  37. package/dist/index.d.ts +18 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +18 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/tools/gitDiff.d.ts +13 -0
  42. package/dist/tools/gitDiff.d.ts.map +1 -0
  43. package/dist/tools/gitDiff.js +50 -0
  44. package/dist/tools/gitDiff.js.map +1 -0
  45. package/dist/tools/gitStatus.d.ts +13 -0
  46. package/dist/tools/gitStatus.d.ts.map +1 -0
  47. package/dist/tools/gitStatus.js +43 -0
  48. package/dist/tools/gitStatus.js.map +1 -0
  49. package/dist/tools/searchFiles.d.ts +19 -0
  50. package/dist/tools/searchFiles.d.ts.map +1 -0
  51. package/dist/tools/searchFiles.js +101 -0
  52. package/dist/tools/searchFiles.js.map +1 -0
  53. package/dist/tools/sshRun.d.ts +26 -0
  54. package/dist/tools/sshRun.d.ts.map +1 -0
  55. package/dist/tools/sshRun.js +170 -0
  56. package/dist/tools/sshRun.js.map +1 -0
  57. package/dist/types/index.d.ts +35 -0
  58. package/dist/types/index.d.ts.map +1 -0
  59. package/dist/types/index.js +8 -0
  60. package/dist/types/index.js.map +1 -0
  61. package/dist/utils/logger.d.ts +19 -0
  62. package/dist/utils/logger.d.ts.map +1 -0
  63. package/dist/utils/logger.js +43 -0
  64. package/dist/utils/logger.js.map +1 -0
  65. package/dist/utils/system-prompt.d.ts +9 -0
  66. package/dist/utils/system-prompt.d.ts.map +1 -0
  67. package/dist/utils/system-prompt.js +49 -0
  68. package/dist/utils/system-prompt.js.map +1 -0
  69. package/package.json +71 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Git diff tool for Clawx.
3
+ * Written fresh — not present in OpenClaw as a model tool.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { execFile } from "node:child_process";
7
+ import { promisify } from "node:util";
8
+ const execFileAsync = promisify(execFile);
9
+ const GitDiffSchema = Type.Object({
10
+ path: Type.Optional(Type.String({ description: "Directory to diff in (default: working directory)" })),
11
+ staged: Type.Optional(Type.Boolean({ description: "Show staged changes only (default: false)" })),
12
+ file: Type.Optional(Type.String({ description: "Specific file to diff" })),
13
+ });
14
+ export function createGitDiffTool(defaultCwd) {
15
+ return {
16
+ name: "git_diff",
17
+ label: "Git Diff",
18
+ description: "Show file differences in a git repository",
19
+ parameters: GitDiffSchema,
20
+ async execute(_toolCallId, params) {
21
+ const cwd = params.path || defaultCwd;
22
+ const args = ["diff"];
23
+ if (params.staged)
24
+ args.push("--cached");
25
+ args.push("--stat", "--patch");
26
+ if (params.file)
27
+ args.push("--", params.file);
28
+ try {
29
+ const { stdout } = await execFileAsync("git", args, {
30
+ cwd,
31
+ timeout: 10_000,
32
+ maxBuffer: 1024 * 1024,
33
+ encoding: "utf-8",
34
+ });
35
+ return {
36
+ content: [{ type: "text", text: stdout.trim() || "(no differences)" }],
37
+ details: {},
38
+ };
39
+ }
40
+ catch (e) {
41
+ const msg = e instanceof Error ? e.message : String(e);
42
+ return {
43
+ content: [{ type: "text", text: `git diff error: ${msg}` }],
44
+ details: {},
45
+ };
46
+ }
47
+ },
48
+ };
49
+ }
50
+ //# sourceMappingURL=gitDiff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitDiff.js","sourceRoot":"","sources":["../../src/tools/gitDiff.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC,QAAQ,CACjB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC,CAClF;IACD,MAAM,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC,CAC3E;IACD,IAAI,EAAE,IAAI,CAAC,QAAQ,CACjB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC,C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E,CAAC;oBAC3D,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Git status tool for Clawx.
3
+ *
4
+ * EXTRACTION NOTE: OpenClaw does not expose git tools to the model.
5
+ * Written fresh as simple wrappers around `git` CLI.
6
+ */
7
+ import type { AgentTool } from "@mariozechner/pi-agent-core";
8
+ declare const GitStatusSchema: import("@sinclair/typebox").TObject<{
9
+ path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
10
+ }>;
11
+ export declare function createGitStatusTool(defaultCwd: string): AgentTool<typeof GitStatusSchema>;
12
+ export {};
13
+ //# sourceMappingURL=gitStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitStatus.d.ts","sourceRoot":"","sources":["../../src/tools/gitStatus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,6BAA6B,CAAC;AAM9E,QAAA,MAAM,eAAe;;EAInB,CAAC;AAIH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,GACjB,SAAS,CAAC,OAAO,eAAe,CAAC,CA8BnC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Git status tool for Clawx.
3
+ *
4
+ * EXTRACTION NOTE: OpenClaw does not expose git tools to the model.
5
+ * Written fresh as simple wrappers around `git` CLI.
6
+ */
7
+ import { Type } from "@sinclair/typebox";
8
+ import { execFile } from "node:child_process";
9
+ import { promisify } from "node:util";
10
+ const execFileAsync = promisify(execFile);
11
+ const GitStatusSchema = Type.Object({
12
+ path: Type.Optional(Type.String({ description: "Directory to check status in (default: working directory)" })),
13
+ });
14
+ export function createGitStatusTool(defaultCwd) {
15
+ return {
16
+ name: "git_status",
17
+ label: "Git Status",
18
+ description: "Show the working tree status of a git repository",
19
+ parameters: GitStatusSchema,
20
+ async execute(_toolCallId, params) {
21
+ const cwd = params.path || defaultCwd;
22
+ try {
23
+ const { stdout } = await execFileAsync("git", ["status", "--porcelain=v2", "--branch"], {
24
+ cwd,
25
+ timeout: 10_000,
26
+ encoding: "utf-8",
27
+ });
28
+ return {
29
+ content: [{ type: "text", text: stdout.trim() || "(clean working tree)" }],
30
+ details: {},
31
+ };
32
+ }
33
+ catch (e) {
34
+ const msg = e instanceof Error ? e.message : String(e);
35
+ return {
36
+ content: [{ type: "text", text: `git status error: ${msg}` }],
37
+ details: {},
38
+ };
39
+ }
40
+ },
41
+ };
42
+ }
43
+ //# sourceMappingURL=gitStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitStatus.js","sourceRoot":"","sources":["../../src/tools/gitStatus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC,QAAQ,CACjB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,2DAA2D,EAAE,CAAC,CAC1F;CACF,CAAC,CAAC;AAIH,MAAM,UAAU,mBAAmB,CACjC,UAAkB;IAElB,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,kDAAkD;QAC/D,UAAU,EAAE,eAAe;QAC3B,KAAK,CAAC,OAAO,CACX,WAAmB,EACnB,MAAsB;YAEtB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,IAAI,UAAU,CAAC;YACtC,IAAI,CAAC;gBACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,gBAAgB,EAAE,UAAU,CAAC,EAAE;oBACtF,GAAG;oBACH,OAAO,EAAE,MAAM;oBACf,QAAQ,EAAE,OAAO;iBAClB,CAAC,CAAC;gBACH,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,sBAAsB,EAAE,CAAC;oBAC1E,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACvD,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,GAAG,EAAE,EAAE,CAAC;oBAC7D,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * File content search tool for Clawx.
3
+ *
4
+ * EXTRACTION NOTE:
5
+ * pi-coding-agent provides `grepTool` and `findTool` as separate tools.
6
+ * This is a unified search tool that combines both patterns for the model.
7
+ * We expose the pi-coding-agent grep/find as the primary implementation.
8
+ * This is a convenience wrapper that the model can use for broader searches.
9
+ */
10
+ import type { AgentTool } from "@mariozechner/pi-agent-core";
11
+ declare const SearchFilesSchema: import("@sinclair/typebox").TObject<{
12
+ pattern: import("@sinclair/typebox").TString;
13
+ path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
14
+ glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
15
+ maxResults: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
16
+ }>;
17
+ export declare function createSearchFilesTool(defaultCwd: string): AgentTool<typeof SearchFilesSchema>;
18
+ export {};
19
+ //# sourceMappingURL=searchFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchFiles.d.ts","sourceRoot":"","sources":["../../src/tools/searchFiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,6BAA6B,CAAC;AAM9E,QAAA,MAAM,iBAAiB;;;;;EAWrB,CAAC;AAIH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,GACjB,SAAS,CAAC,OAAO,iBAAiB,CAAC,CAoFrC"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * File content search tool for Clawx.
3
+ *
4
+ * EXTRACTION NOTE:
5
+ * pi-coding-agent provides `grepTool` and `findTool` as separate tools.
6
+ * This is a unified search tool that combines both patterns for the model.
7
+ * We expose the pi-coding-agent grep/find as the primary implementation.
8
+ * This is a convenience wrapper that the model can use for broader searches.
9
+ */
10
+ import { Type } from "@sinclair/typebox";
11
+ import { execFile } from "node:child_process";
12
+ import { promisify } from "node:util";
13
+ const execFileAsync = promisify(execFile);
14
+ const SearchFilesSchema = Type.Object({
15
+ pattern: Type.String({ description: "Search pattern (regex supported)" }),
16
+ path: Type.Optional(Type.String({ description: "Directory to search in (default: working directory)" })),
17
+ glob: Type.Optional(Type.String({ description: "File glob pattern to filter (e.g. '*.ts', '*.py')" })),
18
+ maxResults: Type.Optional(Type.Number({ description: "Maximum number of matches to return (default: 50)" })),
19
+ });
20
+ export function createSearchFilesTool(defaultCwd) {
21
+ return {
22
+ name: "search_files",
23
+ label: "Search Files",
24
+ description: "Search file contents for a pattern. Uses grep/ripgrep for fast regex search across files.",
25
+ parameters: SearchFilesSchema,
26
+ async execute(_toolCallId, params) {
27
+ const cwd = params.path || defaultCwd;
28
+ const maxResults = params.maxResults || 50;
29
+ // Try ripgrep first, fall back to grep
30
+ const rgArgs = [
31
+ "--no-heading",
32
+ "--line-number",
33
+ "--color=never",
34
+ `--max-count=${maxResults}`,
35
+ ];
36
+ if (params.glob) {
37
+ rgArgs.push("--glob", params.glob);
38
+ }
39
+ rgArgs.push(params.pattern);
40
+ try {
41
+ const { stdout } = await execFileAsync("rg", rgArgs, {
42
+ cwd,
43
+ timeout: 15_000,
44
+ maxBuffer: 512 * 1024,
45
+ encoding: "utf-8",
46
+ });
47
+ const lines = stdout.trim().split("\n").slice(0, maxResults);
48
+ return {
49
+ content: [
50
+ {
51
+ type: "text",
52
+ text: lines.length > 0 ? lines.join("\n") : "(no matches)",
53
+ },
54
+ ],
55
+ details: {},
56
+ };
57
+ }
58
+ catch {
59
+ // rg not found or failed, try grep
60
+ try {
61
+ const grepArgs = ["-rn", "--color=never"];
62
+ if (params.glob) {
63
+ grepArgs.push(`--include=${params.glob}`);
64
+ }
65
+ grepArgs.push(params.pattern, ".");
66
+ const { stdout } = await execFileAsync("grep", grepArgs, {
67
+ cwd,
68
+ timeout: 15_000,
69
+ maxBuffer: 512 * 1024,
70
+ encoding: "utf-8",
71
+ });
72
+ const lines = stdout.trim().split("\n").slice(0, maxResults);
73
+ return {
74
+ content: [
75
+ {
76
+ type: "text",
77
+ text: lines.length > 0 ? lines.join("\n") : "(no matches)",
78
+ },
79
+ ],
80
+ details: {},
81
+ };
82
+ }
83
+ catch (e) {
84
+ const msg = e instanceof Error ? e.message : String(e);
85
+ // grep returns exit 1 for no matches — that's not an error
86
+ if (msg.includes("exit code 1")) {
87
+ return {
88
+ content: [{ type: "text", text: "(no matches)" }],
89
+ details: {},
90
+ };
91
+ }
92
+ return {
93
+ content: [{ type: "text", text: `search error: ${msg}` }],
94
+ details: {},
95
+ };
96
+ }
97
+ }
98
+ },
99
+ };
100
+ }
101
+ //# sourceMappingURL=searchFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchFiles.js","sourceRoot":"","sources":["../../src/tools/searchFiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE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AAC,CAAC;oBAC7D,OAAO;wBACL,OAAO,EAAE;4BACP;gCACE,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc;6BAC3D;yBACF;wBACD,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;oBACvD,2DAA2D;oBAC3D,IAAI,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;wBAChC,OAAO;4BACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;4BACjD,OAAO,EAAE,EAAE;yBACZ,CAAC;oBACJ,CAAC;oBACD,OAAO;wBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,EAAE,EAAE,CAAC;wBACzD,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * SSH execution tool for Clawx.
3
+ *
4
+ * EXTRACTION NOTE:
5
+ * OpenClaw has NO SSH implementation — remote execution goes through a "gateway"
6
+ * and "node-host" abstraction that requires the full platform. This is written fresh.
7
+ *
8
+ * Uses ssh2 to connect to named SSH targets defined in config.
9
+ * The model can run commands on remote machines, create files, and iterate.
10
+ */
11
+ import type { AgentTool } from "@mariozechner/pi-agent-core";
12
+ import type { SshTarget } from "../types/index.js";
13
+ declare const SshRunSchema: import("@sinclair/typebox").TObject<{
14
+ target: import("@sinclair/typebox").TString;
15
+ command: import("@sinclair/typebox").TString;
16
+ timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
17
+ }>;
18
+ export interface SshRunDetails {
19
+ target: string;
20
+ host: string;
21
+ exitCode: number | null;
22
+ durationMs: number;
23
+ }
24
+ export declare function createSshRunTool(targets: Record<string, SshTarget>): AgentTool<typeof SshRunSchema, SshRunDetails>;
25
+ export {};
26
+ //# sourceMappingURL=sshRun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sshRun.d.ts","sourceRoot":"","sources":["../../src/tools/sshRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,6BAA6B,CAAC;AAK9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,QAAA,MAAM,YAAY;;;;EAIhB,CAAC;AAIH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAuFD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACjC,SAAS,CAAC,OAAO,YAAY,EAAE,aAAa,CAAC,CA4E/C"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * SSH execution tool for Clawx.
3
+ *
4
+ * EXTRACTION NOTE:
5
+ * OpenClaw has NO SSH implementation — remote execution goes through a "gateway"
6
+ * and "node-host" abstraction that requires the full platform. This is written fresh.
7
+ *
8
+ * Uses ssh2 to connect to named SSH targets defined in config.
9
+ * The model can run commands on remote machines, create files, and iterate.
10
+ */
11
+ import { Type } from "@sinclair/typebox";
12
+ import { Client } from "ssh2";
13
+ import fs from "node:fs";
14
+ import path from "node:path";
15
+ import os from "node:os";
16
+ import { log } from "../utils/logger.js";
17
+ const SshRunSchema = Type.Object({
18
+ target: Type.String({ description: "Named SSH target from config (e.g. 'pi', 'server')" }),
19
+ command: Type.String({ description: "Shell command to execute on the remote host" }),
20
+ timeout: Type.Optional(Type.Number({ description: "Timeout in ms (default: 30000)" })),
21
+ });
22
+ function resolvePrivateKey(keyPath) {
23
+ const resolved = keyPath.startsWith("~")
24
+ ? path.join(os.homedir(), keyPath.slice(1))
25
+ : keyPath;
26
+ return fs.readFileSync(resolved, "utf-8");
27
+ }
28
+ async function executeSSH(target, command, timeoutMs) {
29
+ return new Promise((resolve, reject) => {
30
+ const conn = new Client();
31
+ let stdout = "";
32
+ let stderr = "";
33
+ let exitCode = null;
34
+ let settled = false;
35
+ const timer = setTimeout(() => {
36
+ if (!settled) {
37
+ settled = true;
38
+ conn.end();
39
+ reject(new Error(`SSH command timed out after ${timeoutMs}ms`));
40
+ }
41
+ }, timeoutMs);
42
+ conn.on("ready", () => {
43
+ conn.exec(command, (err, stream) => {
44
+ if (err) {
45
+ settled = true;
46
+ clearTimeout(timer);
47
+ conn.end();
48
+ reject(err);
49
+ return;
50
+ }
51
+ stream.on("close", (code) => {
52
+ exitCode = code;
53
+ if (!settled) {
54
+ settled = true;
55
+ clearTimeout(timer);
56
+ conn.end();
57
+ resolve({ stdout, stderr, exitCode });
58
+ }
59
+ });
60
+ stream.on("data", (data) => {
61
+ stdout += data.toString();
62
+ });
63
+ stream.stderr.on("data", (data) => {
64
+ stderr += data.toString();
65
+ });
66
+ });
67
+ });
68
+ conn.on("error", (err) => {
69
+ if (!settled) {
70
+ settled = true;
71
+ clearTimeout(timer);
72
+ reject(err);
73
+ }
74
+ });
75
+ const connectConfig = {
76
+ host: target.host,
77
+ port: target.port || 22,
78
+ username: target.username,
79
+ };
80
+ if (target.privateKeyPath) {
81
+ try {
82
+ connectConfig.privateKey = resolvePrivateKey(target.privateKeyPath);
83
+ }
84
+ catch (e) {
85
+ settled = true;
86
+ clearTimeout(timer);
87
+ reject(new Error(`Failed to read SSH key: ${target.privateKeyPath}: ${e}`));
88
+ return;
89
+ }
90
+ }
91
+ else if (target.password) {
92
+ connectConfig.password = target.password;
93
+ }
94
+ conn.connect(connectConfig);
95
+ });
96
+ }
97
+ export function createSshRunTool(targets) {
98
+ return {
99
+ name: "ssh_run",
100
+ label: "SSH Run",
101
+ description: "Execute a shell command on a remote host via SSH. " +
102
+ `Available targets: ${Object.keys(targets).join(", ") || "(none configured)"}`,
103
+ parameters: SshRunSchema,
104
+ async execute(_toolCallId, params) {
105
+ const target = targets[params.target];
106
+ if (!target) {
107
+ const available = Object.keys(targets).join(", ") || "none";
108
+ return {
109
+ content: [
110
+ {
111
+ type: "text",
112
+ text: `SSH target "${params.target}" not found. Available: ${available}`,
113
+ },
114
+ ],
115
+ details: {
116
+ target: params.target,
117
+ host: "",
118
+ exitCode: null,
119
+ durationMs: 0,
120
+ },
121
+ };
122
+ }
123
+ const timeoutMs = params.timeout || 30_000;
124
+ const start = Date.now();
125
+ log.info(`SSH [${params.target}] ${target.username}@${target.host}: ${params.command}`);
126
+ try {
127
+ const result = await executeSSH(target, params.command, timeoutMs);
128
+ const durationMs = Date.now() - start;
129
+ let output = "";
130
+ if (result.stdout.trim())
131
+ output += result.stdout.trim();
132
+ if (result.stderr.trim()) {
133
+ if (output)
134
+ output += "\n--- stderr ---\n";
135
+ output += result.stderr.trim();
136
+ }
137
+ if (!output)
138
+ output = "(no output)";
139
+ return {
140
+ content: [
141
+ {
142
+ type: "text",
143
+ text: `[${params.target}] exit=${result.exitCode} (${durationMs}ms)\n${output}`,
144
+ },
145
+ ],
146
+ details: {
147
+ target: params.target,
148
+ host: target.host,
149
+ exitCode: result.exitCode,
150
+ durationMs,
151
+ },
152
+ };
153
+ }
154
+ catch (e) {
155
+ const durationMs = Date.now() - start;
156
+ const msg = e instanceof Error ? e.message : String(e);
157
+ return {
158
+ content: [{ type: "text", text: `SSH error on ${params.target}: ${msg}` }],
159
+ details: {
160
+ target: params.target,
161
+ host: target.host,
162
+ exitCode: null,
163
+ durationMs,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BACjB,QAAQ,EAAE,IAAI;wBACd,UAAU;qBACX;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Clawx type definitions.
3
+ *
4
+ * Core message/tool/model types come from @mariozechner/pi-ai and pi-agent-core.
5
+ * This file defines Clawx-specific configuration and runtime types.
6
+ */
7
+ export interface ClawxConfig {
8
+ provider: string;
9
+ baseUrl: string;
10
+ model: string;
11
+ apiKey: string;
12
+ workDir: string;
13
+ shell: string;
14
+ execTimeout: number;
15
+ thinkingLevel: "off" | "minimal" | "low" | "medium" | "high";
16
+ maxTokens: number;
17
+ sessionDir: string;
18
+ sshTargets: Record<string, SshTarget>;
19
+ systemPrompt?: string;
20
+ }
21
+ export interface SshTarget {
22
+ host: string;
23
+ port?: number;
24
+ username: string;
25
+ privateKeyPath?: string;
26
+ password?: string;
27
+ }
28
+ export interface ClawxSession {
29
+ id: string;
30
+ startedAt: number;
31
+ workDir: string;
32
+ model: string;
33
+ provider: string;
34
+ }
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Clawx type definitions.
3
+ *
4
+ * Core message/tool/model types come from @mariozechner/pi-ai and pi-agent-core.
5
+ * This file defines Clawx-specific configuration and runtime types.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Structured logger for Clawx.
3
+ * Simple, no dependencies beyond chalk.
4
+ */
5
+ type LogLevel = "debug" | "info" | "warn" | "error";
6
+ export declare function setLogLevel(level: LogLevel): void;
7
+ export declare function debug(msg: string, ...args: unknown[]): void;
8
+ export declare function info(msg: string, ...args: unknown[]): void;
9
+ export declare function warn(msg: string, ...args: unknown[]): void;
10
+ export declare function error(msg: string, ...args: unknown[]): void;
11
+ export declare const log: {
12
+ debug: typeof debug;
13
+ info: typeof info;
14
+ warn: typeof warn;
15
+ error: typeof error;
16
+ setLogLevel: typeof setLogLevel;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAWpD,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,QAE1C;AAUD,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,QAGpD;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,QAGnD;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,QAGnD;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,QAGpD;AAED,eAAO,MAAM,GAAG;;;;;;CAA4C,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Structured logger for Clawx.
3
+ * Simple, no dependencies beyond chalk.
4
+ */
5
+ import chalk from "chalk";
6
+ let currentLevel = "info";
7
+ const LEVEL_PRIORITY = {
8
+ debug: 0,
9
+ info: 1,
10
+ warn: 2,
11
+ error: 3,
12
+ };
13
+ export function setLogLevel(level) {
14
+ currentLevel = level;
15
+ }
16
+ function shouldLog(level) {
17
+ return LEVEL_PRIORITY[level] >= LEVEL_PRIORITY[currentLevel];
18
+ }
19
+ function timestamp() {
20
+ return new Date().toISOString().slice(11, 23);
21
+ }
22
+ export function debug(msg, ...args) {
23
+ if (!shouldLog("debug"))
24
+ return;
25
+ console.error(chalk.gray(`[${timestamp()}] DBG ${msg}`), ...args);
26
+ }
27
+ export function info(msg, ...args) {
28
+ if (!shouldLog("info"))
29
+ return;
30
+ console.error(chalk.blue(`[${timestamp()}] INF ${msg}`), ...args);
31
+ }
32
+ export function warn(msg, ...args) {
33
+ if (!shouldLog("warn"))
34
+ return;
35
+ console.error(chalk.yellow(`[${timestamp()}] WRN ${msg}`), ...args);
36
+ }
37
+ export function error(msg, ...args) {
38
+ if (!shouldLog("error"))
39
+ return;
40
+ console.error(chalk.red(`[${timestamp()}] ERR ${msg}`), ...args);
41
+ }
42
+ export const log = { debug, info, warn, error, setLogLevel };
43
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,IAAI,YAAY,GAAa,MAAM,CAAC;AAEpC,MAAM,cAAc,GAA6B;IAC/C,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,YAAY,GAAG,KAAK,CAAC;AACvB,CAAC;AAED,SAAS,SAAS,CAAC,KAAe;IAChC,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,YAAY,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAW,EAAE,GAAG,IAAe;IACnD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAAE,OAAO;IAChC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,EAAE,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAW,EAAE,GAAG,IAAe;IAClD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAAE,OAAO;IAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,EAAE,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAW,EAAE,GAAG,IAAe;IAClD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAAE,OAAO;IAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,SAAS,EAAE,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAW,EAAE,GAAG,IAAe;IACnD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAAE,OAAO;IAChC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * System prompt builder for Clawx.
3
+ *
4
+ * Builds a focused system prompt for coding/execution tasks.
5
+ * No personality systems, no lore, no bootstrap documents.
6
+ */
7
+ import type { ClawxConfig } from "../types/index.js";
8
+ export declare function buildSystemPrompt(config: ClawxConfig): string;
9
+ //# sourceMappingURL=system-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/utils/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAEhE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CA0C7D"}