jazz-ai 0.2.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +8 -6
  2. package/dist/cli/commands/chat-agent.d.ts +3 -1
  3. package/dist/cli/commands/chat-agent.d.ts.map +1 -1
  4. package/dist/cli/commands/chat-agent.js +180 -102
  5. package/dist/cli/commands/chat-agent.js.map +1 -1
  6. package/dist/cli/commands/edit-agent.d.ts +2 -2
  7. package/dist/cli/commands/edit-agent.d.ts.map +1 -1
  8. package/dist/cli/commands/edit-agent.js +20 -10
  9. package/dist/cli/commands/edit-agent.js.map +1 -1
  10. package/dist/cli/commands/task-agent.d.ts +1 -1
  11. package/dist/cli/commands/task-agent.d.ts.map +1 -1
  12. package/dist/cli/commands/task-agent.js +6 -6
  13. package/dist/cli/commands/task-agent.js.map +1 -1
  14. package/dist/constants/agent.d.ts +2 -0
  15. package/dist/constants/agent.d.ts.map +1 -0
  16. package/dist/constants/agent.js +5 -0
  17. package/dist/constants/agent.js.map +1 -0
  18. package/dist/core/agent/agent-prompt.d.ts +0 -1
  19. package/dist/core/agent/agent-prompt.d.ts.map +1 -1
  20. package/dist/core/agent/agent-prompt.js +7 -15
  21. package/dist/core/agent/agent-prompt.js.map +1 -1
  22. package/dist/core/agent/agent-runner.d.ts +15 -0
  23. package/dist/core/agent/agent-runner.d.ts.map +1 -1
  24. package/dist/core/agent/agent-runner.js +570 -270
  25. package/dist/core/agent/agent-runner.js.map +1 -1
  26. package/dist/core/agent/agent-service.d.ts +20 -5
  27. package/dist/core/agent/agent-service.d.ts.map +1 -1
  28. package/dist/core/agent/agent-service.js +54 -6
  29. package/dist/core/agent/agent-service.js.map +1 -1
  30. package/dist/core/agent/gmail-agent.js +7 -7
  31. package/dist/core/agent/gmail-agent.js.map +1 -1
  32. package/dist/core/agent/prompts/coder/v1.d.ts +2 -0
  33. package/dist/core/agent/prompts/coder/v1.d.ts.map +1 -0
  34. package/dist/core/agent/prompts/coder/v1.js +370 -0
  35. package/dist/core/agent/prompts/coder/v1.js.map +1 -0
  36. package/dist/core/agent/prompts/default/v2.d.ts +1 -1
  37. package/dist/core/agent/prompts/default/v2.d.ts.map +1 -1
  38. package/dist/core/agent/prompts/default/v2.js +1 -2
  39. package/dist/core/agent/prompts/default/v2.js.map +1 -1
  40. package/dist/core/agent/prompts/gmail/v1.d.ts +1 -1
  41. package/dist/core/agent/prompts/gmail/v1.d.ts.map +1 -1
  42. package/dist/core/agent/prompts/gmail/v1.js +5 -5
  43. package/dist/core/agent/prompts/gmail/v2.d.ts +1 -1
  44. package/dist/core/agent/prompts/gmail/v2.d.ts.map +1 -1
  45. package/dist/core/agent/prompts/gmail/v2.js +7 -7
  46. package/dist/core/agent/tools/base-tool.d.ts +3 -4
  47. package/dist/core/agent/tools/base-tool.d.ts.map +1 -1
  48. package/dist/core/agent/tools/base-tool.js +11 -51
  49. package/dist/core/agent/tools/base-tool.js.map +1 -1
  50. package/dist/core/agent/tools/context-utils.d.ts +6 -0
  51. package/dist/core/agent/tools/context-utils.d.ts.map +1 -0
  52. package/dist/core/agent/tools/context-utils.js +9 -0
  53. package/dist/core/agent/tools/context-utils.js.map +1 -0
  54. package/dist/core/agent/tools/env-utils.d.ts +7 -0
  55. package/dist/core/agent/tools/env-utils.d.ts.map +1 -0
  56. package/dist/core/agent/tools/env-utils.js +39 -0
  57. package/dist/core/agent/tools/env-utils.js.map +1 -0
  58. package/dist/core/agent/tools/fs-tools.d.ts.map +1 -1
  59. package/dist/core/agent/tools/fs-tools.js +48 -53
  60. package/dist/core/agent/tools/fs-tools.js.map +1 -1
  61. package/dist/core/agent/tools/git-tools.d.ts +5 -0
  62. package/dist/core/agent/tools/git-tools.d.ts.map +1 -1
  63. package/dist/core/agent/tools/git-tools.js +716 -154
  64. package/dist/core/agent/tools/git-tools.js.map +1 -1
  65. package/dist/core/agent/tools/gmail-tools.js +35 -35
  66. package/dist/core/agent/tools/gmail-tools.js.map +1 -1
  67. package/dist/core/agent/tools/http-tools.js +2 -2
  68. package/dist/core/agent/tools/http-tools.js.map +1 -1
  69. package/dist/core/agent/tools/register-tools.d.ts +18 -1
  70. package/dist/core/agent/tools/register-tools.d.ts.map +1 -1
  71. package/dist/core/agent/tools/register-tools.js +52 -6
  72. package/dist/core/agent/tools/register-tools.js.map +1 -1
  73. package/dist/core/agent/tools/shell-tools.d.ts.map +1 -1
  74. package/dist/core/agent/tools/shell-tools.js +10 -20
  75. package/dist/core/agent/tools/shell-tools.js.map +1 -1
  76. package/dist/core/agent/tools/tool-registry.d.ts +11 -7
  77. package/dist/core/agent/tools/tool-registry.d.ts.map +1 -1
  78. package/dist/core/agent/tools/tool-registry.js +45 -19
  79. package/dist/core/agent/tools/tool-registry.js.map +1 -1
  80. package/dist/core/agent/tools/web-search-tools.js +1 -1
  81. package/dist/core/agent/tools/web-search-tools.js.map +1 -1
  82. package/dist/core/agent/tracking/agent-run-tracker.d.ts +2 -0
  83. package/dist/core/agent/tracking/agent-run-tracker.d.ts.map +1 -1
  84. package/dist/core/agent/tracking/agent-run-tracker.js +40 -2
  85. package/dist/core/agent/tracking/agent-run-tracker.js.map +1 -1
  86. package/dist/core/types/index.d.ts +82 -15
  87. package/dist/core/types/index.d.ts.map +1 -1
  88. package/dist/core/types/index.js.map +1 -1
  89. package/dist/core/utils/markdown-renderer.d.ts +25 -0
  90. package/dist/core/utils/markdown-renderer.d.ts.map +1 -1
  91. package/dist/core/utils/markdown-renderer.js +100 -1
  92. package/dist/core/utils/markdown-renderer.js.map +1 -1
  93. package/dist/core/utils/output-renderer.d.ts +81 -0
  94. package/dist/core/utils/output-renderer.d.ts.map +1 -0
  95. package/dist/core/utils/output-renderer.js +291 -0
  96. package/dist/core/utils/output-renderer.js.map +1 -0
  97. package/dist/core/utils/output-theme.d.ts +64 -0
  98. package/dist/core/utils/output-theme.d.ts.map +1 -0
  99. package/dist/core/utils/output-theme.js +154 -0
  100. package/dist/core/utils/output-theme.js.map +1 -0
  101. package/dist/core/utils/output-writer.d.ts +79 -0
  102. package/dist/core/utils/output-writer.d.ts.map +1 -0
  103. package/dist/core/utils/output-writer.js +133 -0
  104. package/dist/core/utils/output-writer.js.map +1 -0
  105. package/dist/core/utils/runtime-detection.d.ts +28 -0
  106. package/dist/core/utils/runtime-detection.d.ts.map +1 -0
  107. package/dist/core/utils/runtime-detection.js +62 -0
  108. package/dist/core/utils/runtime-detection.js.map +1 -0
  109. package/dist/core/utils/string.d.ts +8 -0
  110. package/dist/core/utils/string.d.ts.map +1 -0
  111. package/dist/core/utils/string.js +19 -0
  112. package/dist/core/utils/string.js.map +1 -0
  113. package/dist/core/utils/thinking-renderer.d.ts +56 -0
  114. package/dist/core/utils/thinking-renderer.d.ts.map +1 -0
  115. package/dist/core/utils/thinking-renderer.js +174 -0
  116. package/dist/core/utils/thinking-renderer.js.map +1 -0
  117. package/dist/core/utils/tool-formatter.d.ts +21 -0
  118. package/dist/core/utils/tool-formatter.d.ts.map +1 -0
  119. package/dist/core/utils/tool-formatter.js +343 -0
  120. package/dist/core/utils/tool-formatter.js.map +1 -0
  121. package/dist/main.js +11 -4
  122. package/dist/main.js.map +1 -1
  123. package/dist/services/config.d.ts.map +1 -1
  124. package/dist/services/config.js +20 -20
  125. package/dist/services/config.js.map +1 -1
  126. package/dist/services/llm/ai-sdk-service.d.ts.map +1 -1
  127. package/dist/services/llm/ai-sdk-service.js +128 -37
  128. package/dist/services/llm/ai-sdk-service.js.map +1 -1
  129. package/dist/services/llm/stream-detector.d.ts +44 -0
  130. package/dist/services/llm/stream-detector.d.ts.map +1 -0
  131. package/dist/services/llm/stream-detector.js +81 -0
  132. package/dist/services/llm/stream-detector.js.map +1 -0
  133. package/dist/services/llm/stream-processor.d.ts +93 -0
  134. package/dist/services/llm/stream-processor.d.ts.map +1 -0
  135. package/dist/services/llm/stream-processor.js +330 -0
  136. package/dist/services/llm/stream-processor.js.map +1 -0
  137. package/dist/services/llm/streaming-types.d.ts +131 -0
  138. package/dist/services/llm/streaming-types.d.ts.map +1 -0
  139. package/dist/services/llm/streaming-types.js +12 -0
  140. package/dist/services/llm/streaming-types.js.map +1 -0
  141. package/dist/services/llm/types.d.ts +8 -0
  142. package/dist/services/llm/types.d.ts.map +1 -1
  143. package/dist/services/llm/types.js.map +1 -1
  144. package/dist/services/logger.d.ts +4 -4
  145. package/dist/services/logger.d.ts.map +1 -1
  146. package/dist/services/logger.js +23 -45
  147. package/dist/services/logger.js.map +1 -1
  148. package/dist/services/shell.d.ts.map +1 -1
  149. package/dist/services/shell.js +52 -18
  150. package/dist/services/shell.js.map +1 -1
  151. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defineTool = defineTool;
4
- exports.makeJsonSchemaValidator = makeJsonSchemaValidator;
4
+ exports.makeZodValidator = makeZodValidator;
5
5
  exports.withApprovalBoolean = withApprovalBoolean;
6
6
  const effect_1 = require("effect");
7
7
  const zod_1 = require("zod");
@@ -63,7 +63,7 @@ function defineTool(config) {
63
63
  message: approvalMessage,
64
64
  ...(execute
65
65
  ? {
66
- instruction: `Please ask the user for confirmation. If they confirm, call this tool again with { "confirm": true } or call: ${execute.toolName} with these exact arguments: ${JSON.stringify(execute.buildArgs(validated))}`,
66
+ instruction: `Please ask the user for confirmation. If they confirm, ${execute.toolName} with these exact arguments: ${JSON.stringify(execute.buildArgs(validated))}`,
67
67
  executeToolName: execute.toolName,
68
68
  executeArgs: execute.buildArgs(validated),
69
69
  }
@@ -82,59 +82,19 @@ function defineTool(config) {
82
82
  };
83
83
  }
84
84
  /**
85
- * Build a minimal runtime validator from a JSON Schema subset.
86
- * Supports: type = string|number|boolean|array(object: items.type), required[], additionalProperties.
85
+ * Build a runtime validator from a Zod schema. Keeps validation logic and typing in sync.
87
86
  */
88
- function makeJsonSchemaValidator(schema) {
87
+ function makeZodValidator(schema) {
89
88
  return (args) => {
90
- const errors = [];
91
- const s = schema;
92
- if (s.type !== undefined && s.type !== "object") {
93
- errors.push("Root schema.type must be 'object'");
94
- }
95
- const properties = (s.properties || {});
96
- const required = new Set((s.required || []));
97
- for (const key of required) {
98
- if (!(key in args)) {
99
- errors.push(`Missing required property: ${key}`);
100
- }
101
- }
102
- for (const [key, value] of Object.entries(args)) {
103
- const prop = properties[key];
104
- if (!prop) {
105
- if (s.additionalProperties === false) {
106
- errors.push(`Unknown property: ${key}`);
107
- }
108
- continue;
109
- }
110
- const expected = prop.type;
111
- if (!expected)
112
- continue;
113
- const actual = typeof value;
114
- if (expected === "array") {
115
- if (!Array.isArray(value)) {
116
- errors.push(`Property '${key}' expected array, got ${actual}`);
117
- }
118
- else {
119
- const itemType = prop.items?.type;
120
- if (itemType) {
121
- for (let i = 0; i < value.length; i++) {
122
- const t = typeof value[i];
123
- if (t !== itemType) {
124
- errors.push(`Property '${key}[${i}]' expected ${itemType}, got ${t}`);
125
- }
126
- }
127
- }
128
- }
129
- }
130
- else if (actual !== expected) {
131
- errors.push(`Property '${key}' expected ${expected}, got ${actual}`);
132
- }
133
- }
134
- if (errors.length > 0) {
89
+ const result = schema.safeParse(args);
90
+ if (!result.success) {
91
+ const errors = result.error.issues.map((issue) => {
92
+ const path = issue.path.join(".");
93
+ return path.length > 0 ? `${path}: ${issue.message}` : issue.message;
94
+ });
135
95
  return { valid: false, errors };
136
96
  }
137
- return { valid: true, value: args };
97
+ return { valid: true, value: result.data };
138
98
  };
139
99
  }
140
100
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"base-tool.js","sourceRoot":"","sources":["../../../../src/core/agent/tools/base-tool.ts"],"names":[],"mappings":";;AAgKA,gCAyDC;AAMD,0DAiEC;AAMD,kDAeC;AArTD,mCAAgC;AAChC,6BAAwB;AAqIxB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,UAAU,CACxB,MAA+B;IAE/B,MAAM,uBAAuB,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,Q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AG,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;YACvE,CAAC,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAW,CAAC;QAC3C,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAW,CAAC;IACtD,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,MAAoB,EACpB,OAAsD;IAEtD,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,SAAS,CAAC;IAClD,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,qCAAqC,CAAC;IAElF,4EAA4E;IAC5E,IAAI,MAAM,YAAY,OAAC,CAAC,SAAS,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,CAAC,SAAS,CAAC,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;SAC/C,CAAC,CAAC;IACL,CAAC;IACD,yEAAyE;IACzE,OAAO,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAClF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type ToolExecutionContext } from "./tool-registry";
2
+ export declare function buildKeyFromContext(context: ToolExecutionContext): {
3
+ readonly agentId: string;
4
+ readonly conversationId?: string;
5
+ };
6
+ //# sourceMappingURL=context-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-utils.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/tools/context-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAIA"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildKeyFromContext = buildKeyFromContext;
4
+ function buildKeyFromContext(context) {
5
+ return context.conversationId
6
+ ? { agentId: context.agentId, conversationId: context.conversationId }
7
+ : { agentId: context.agentId };
8
+ }
9
+ //# sourceMappingURL=context-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-utils.js","sourceRoot":"","sources":["../../../../src/core/agent/tools/context-utils.ts"],"names":[],"mappings":";;AAEA,kDAOC;AAPD,SAAgB,mBAAmB,CAAC,OAA6B;IAI/D,OAAO,OAAO,CAAC,cAAc;QAC3B,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE;QACtE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type ProcessEnvRecord = Record<string, string | undefined>;
2
+ /**
3
+ * Build a sanitized environment for child process execution.
4
+ * Strips sensitive vars while preserving essentials like PATH.
5
+ */
6
+ export declare function createSanitizedEnv(overrides?: ProcessEnvRecord): ProcessEnvRecord;
7
+ //# sourceMappingURL=env-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-utils.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/tools/env-utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAElE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,GAAE,gBAAqB,GAAG,gBAAgB,CAoCrF"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSanitizedEnv = createSanitizedEnv;
4
+ /**
5
+ * Build a sanitized environment for child process execution.
6
+ * Strips sensitive vars while preserving essentials like PATH.
7
+ */
8
+ function createSanitizedEnv(overrides = {}) {
9
+ const baseEnv = {
10
+ PATH: process.env["PATH"] ?? "/usr/local/bin:/usr/bin:/bin",
11
+ HOME: process.env["HOME"],
12
+ USER: process.env["USER"],
13
+ LOGNAME: process.env["LOGNAME"] ?? process.env["USER"] ?? "jazz",
14
+ SHELL: process.env["SHELL"] ?? "/bin/sh",
15
+ LANG: process.env["LANG"] ?? "en_US.UTF-8",
16
+ LC_ALL: process.env["LC_ALL"] ?? "C",
17
+ LC_CTYPE: process.env["LC_CTYPE"] ?? "UTF-8",
18
+ TERM: process.env["TERM"] ?? "xterm-256color",
19
+ PWD: process.cwd(),
20
+ TMPDIR: process.env["TMPDIR"] ?? "/tmp",
21
+ XDG_RUNTIME_DIR: process.env["XDG_RUNTIME_DIR"],
22
+ GIT_PAGER: process.env["GIT_PAGER"] ?? "cat",
23
+ GIT_TERMINAL_PROMPT: "0",
24
+ ...overrides,
25
+ };
26
+ for (const [key, value] of Object.entries(process.env ?? {})) {
27
+ if (value === undefined) {
28
+ continue;
29
+ }
30
+ if (/API|KEY|SECRET|TOKEN|PASSWORD|CREDENTIAL|AUTH/i.test(key) ||
31
+ key in baseEnv ||
32
+ key.startsWith("SSH_")) {
33
+ continue;
34
+ }
35
+ baseEnv[key] = value;
36
+ }
37
+ return baseEnv;
38
+ }
39
+ //# sourceMappingURL=env-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-utils.js","sourceRoot":"","sources":["../../../../src/core/agent/tools/env-utils.ts"],"names":[],"mappings":";;AAMA,gDAoCC;AAxCD;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,YAA8B,EAAE;IACjE,MAAM,OAAO,GAAqB;QAChC,IAAI,EAAE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,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CAoI3F;AAKD,wBAAgB,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CAkD5F;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAChD,UAAU,CAAC,UAAU,GAAG,wBAAwB,CACjD,CAsDA;AAGD,wBAAgB,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CAsMvF;AAGD,wBAAgB,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CAmOvF;AAGD,wBAAgB,eAAe,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CA2DxF;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CA0D/F;AAGD,wBAAgB,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CAqEvF;AAGD,wBAAgB,YAAY,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CA+CrF;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CA2E5F;AAGD,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,wBAAwB,CAAC,CA0D1F;AAGD,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,CAGrF"}
@@ -22,16 +22,11 @@ const effect_1 = require("effect");
22
22
  const zod_1 = require("zod");
23
23
  const shell_1 = require("../../../services/shell");
24
24
  const base_tool_1 = require("./base-tool");
25
+ const context_utils_1 = require("./context-utils");
25
26
  /**
26
27
  * Filesystem and shell tools: pwd, ls, cd, grep, find, mkdir, rm
27
28
  * mkdir and rm require explicit approval and are executed via hidden execute* tools.
28
29
  */
29
- // Utility helpers
30
- function buildKeyFromContext(context) {
31
- return context.conversationId
32
- ? { agentId: context.agentId, conversationId: context.conversationId }
33
- : { agentId: context.agentId };
34
- }
35
30
  function normalizeFilterPattern(pattern) {
36
31
  if (!pattern || pattern.trim() === "")
37
32
  return { type: "substring" };
@@ -63,7 +58,7 @@ function normalizeStatSize(size) {
63
58
  }
64
59
  return null;
65
60
  }
66
- // findPath - helps agent discover paths when unsure
61
+ // find_path - helps agent discover paths when unsure
67
62
  function createFindPathTool() {
68
63
  const parameters = zod_1.z
69
64
  .object({
@@ -82,8 +77,8 @@ function createFindPathTool() {
82
77
  })
83
78
  .strict();
84
79
  return (0, base_tool_1.defineTool)({
85
- name: "findPath",
86
- description: "Find directories or files by name using the system find command",
80
+ name: "find_path",
81
+ description: "Quick search for files or directories by name with shallow depth (default 3 levels). Use when you need to quickly locate a specific file or directory by name without deep traversal.",
87
82
  tags: ["filesystem", "search"],
88
83
  parameters,
89
84
  validate: (args) => {
@@ -97,9 +92,9 @@ function createFindPathTool() {
97
92
  },
98
93
  handler: (args, context) => effect_1.Effect.gen(function* () {
99
94
  const shell = yield* shell_1.FileSystemContextServiceTag;
100
- const currentDir = yield* shell.getCwd(buildKeyFromContext(context));
95
+ const currentDir = yield* shell.getCwd((0, context_utils_1.buildKeyFromContext)(context));
101
96
  const searchDir = args.searchPath
102
- ? yield* shell.resolvePath(buildKeyFromContext(context), args.searchPath)
97
+ ? yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.searchPath)
103
98
  : currentDir;
104
99
  const maxDepth = args.maxDepth ?? 3;
105
100
  const searchType = args.type ?? "both";
@@ -206,7 +201,7 @@ function createPwdTool() {
206
201
  },
207
202
  handler: (_args, context) => effect_1.Effect.gen(function* () {
208
203
  const shell = yield* shell_1.FileSystemContextServiceTag;
209
- const cwd = yield* shell.getCwd(buildKeyFromContext(context));
204
+ const cwd = yield* shell.getCwd((0, context_utils_1.buildKeyFromContext)(context));
210
205
  return { success: true, result: cwd };
211
206
  }),
212
207
  });
@@ -232,7 +227,7 @@ function createLsTool() {
232
227
  .strict();
233
228
  return (0, base_tool_1.defineTool)({
234
229
  name: "ls",
235
- description: "List directory contents with optional filtering and recursion",
230
+ description: "List files and directories within a specified path. Supports recursive traversal, filtering by name patterns (substring or regex), showing hidden files, and limiting results. Returns file/directory names, paths, and types.",
236
231
  tags: ["filesystem", "listing"],
237
232
  parameters,
238
233
  validate: (args) => {
@@ -248,12 +243,12 @@ function createLsTool() {
248
243
  const fs = yield* platform_1.FileSystem.FileSystem;
249
244
  const shell = yield* shell_1.FileSystemContextServiceTag;
250
245
  const basePath = args.path
251
- ? yield* shell.resolvePath(buildKeyFromContext(context), args.path).pipe(effect_1.Effect.catchAll((error) => effect_1.Effect.succeed({
246
+ ? yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path).pipe(effect_1.Effect.catchAll((error) => effect_1.Effect.succeed({
252
247
  success: false,
253
248
  result: null,
254
249
  error: error instanceof Error ? error.message : String(error),
255
250
  })))
256
- : yield* shell.getCwd(buildKeyFromContext(context));
251
+ : yield* shell.getCwd((0, context_utils_1.buildKeyFromContext)(context));
257
252
  // If path resolution failed, return the error with suggestions
258
253
  if (typeof basePath === "object" && "success" in basePath && !basePath.success) {
259
254
  return basePath;
@@ -341,7 +336,7 @@ function createCdTool() {
341
336
  const fs = yield* platform_1.FileSystem.FileSystem;
342
337
  const shell = yield* shell_1.FileSystemContextServiceTag;
343
338
  // Try to resolve the path - this will provide helpful suggestions if the path doesn't exist
344
- const targetResult = yield* shell.resolvePath(buildKeyFromContext(context), args.path).pipe(effect_1.Effect.catchAll((error) => effect_1.Effect.succeed({
339
+ const targetResult = yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path).pipe(effect_1.Effect.catchAll((error) => effect_1.Effect.succeed({
345
340
  success: false,
346
341
  result: null,
347
342
  error: error instanceof Error ? error.message : String(error),
@@ -358,7 +353,7 @@ function createCdTool() {
358
353
  if (stat.type !== "Directory") {
359
354
  return { success: false, result: null, error: `Not a directory: ${target}` };
360
355
  }
361
- yield* shell.setCwd(buildKeyFromContext(context), target);
356
+ yield* shell.setCwd((0, context_utils_1.buildKeyFromContext)(context), target);
362
357
  return { success: true, result: target };
363
358
  }
364
359
  catch (error) {
@@ -388,8 +383,8 @@ function createReadFileTool() {
388
383
  })
389
384
  .strict();
390
385
  return (0, base_tool_1.defineTool)({
391
- name: "readFile",
392
- description: "Read a text file with optional line range and size limit",
386
+ name: "read_file",
387
+ description: "Read the contents of a text file with optional line range selection (startLine/endLine). Automatically handles UTF-8 BOM, enforces size limits to prevent memory issues (default 128KB), and reports truncation. Returns file content, encoding, line counts, and range information.",
393
388
  tags: ["filesystem", "read"],
394
389
  parameters,
395
390
  validate: (args) => {
@@ -405,7 +400,7 @@ function createReadFileTool() {
405
400
  const fs = yield* platform_1.FileSystem.FileSystem;
406
401
  const shell = yield* shell_1.FileSystemContextServiceTag;
407
402
  const filePathResult = yield* shell
408
- .resolvePath(buildKeyFromContext(context), args.path)
403
+ .resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path)
409
404
  .pipe(effect_1.Effect.catchAll((error) => effect_1.Effect.succeed({
410
405
  success: false,
411
406
  result: null,
@@ -492,7 +487,7 @@ function createWriteFileTool() {
492
487
  })
493
488
  .strict();
494
489
  return (0, base_tool_1.defineTool)({
495
- name: "writeFile",
490
+ name: "write_file",
496
491
  description: "Write content to a file, creating it if it doesn't exist (requires user approval)",
497
492
  tags: ["filesystem", "write"],
498
493
  parameters,
@@ -505,14 +500,14 @@ function createWriteFileTool() {
505
500
  approval: {
506
501
  message: (args, context) => effect_1.Effect.gen(function* () {
507
502
  const shell = yield* shell_1.FileSystemContextServiceTag;
508
- const target = yield* shell.resolvePath(buildKeyFromContext(context), args.path, {
503
+ const target = yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path, {
509
504
  skipExistenceCheck: true,
510
505
  });
511
- return `About to write to file: ${target}${args.createDirs === true ? " (will create parent directories)" : ""}.\n\nIMPORTANT: After getting user confirmation, you MUST call the executeWriteFile tool with these exact arguments: {"path": "${args.path}", "content": ${JSON.stringify(args.content)}, "encoding": "${args.encoding ?? "utf-8"}", "createDirs": ${args.createDirs === true}}`;
506
+ return `About to write to file: ${target}${args.createDirs === true ? " (will create parent directories)" : ""}.\n\nIMPORTANT: After getting user confirmation, you MUST call the execute_write_file tool with these exact arguments: {"path": "${args.path}", "content": ${JSON.stringify(args.content)}, "encoding": "${args.encoding ?? "utf-8"}", "createDirs": ${args.createDirs === true}}`;
512
507
  }),
513
508
  errorMessage: "Approval required: File writing requires user confirmation.",
514
509
  execute: {
515
- toolName: "executeWriteFile",
510
+ toolName: "execute_write_file",
516
511
  buildArgs: (args) => ({
517
512
  path: args.path,
518
513
  content: args.content,
@@ -537,8 +532,8 @@ function createExecuteWriteFileTool() {
537
532
  })
538
533
  .strict();
539
534
  return (0, base_tool_1.defineTool)({
540
- name: "executeWriteFile",
541
- description: "Execute writeFile after user approval",
535
+ name: "execute_write_file",
536
+ description: "Internal tool that performs the actual file write operation after user has approved the write_file request. Creates or overwrites the file at the specified path with the provided content.",
542
537
  hidden: true,
543
538
  parameters,
544
539
  validate: (args) => {
@@ -550,7 +545,7 @@ function createExecuteWriteFileTool() {
550
545
  handler: (args, context) => effect_1.Effect.gen(function* () {
551
546
  const fs = yield* platform_1.FileSystem.FileSystem;
552
547
  const shell = yield* shell_1.FileSystemContextServiceTag;
553
- const target = yield* shell.resolvePath(buildKeyFromContext(context), args.path, {
548
+ const target = yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path, {
554
549
  skipExistenceCheck: true,
555
550
  });
556
551
  try {
@@ -593,7 +588,7 @@ function createGrepTool() {
593
588
  .strict();
594
589
  return (0, base_tool_1.defineTool)({
595
590
  name: "grep",
596
- description: "Search for a pattern in files using the system grep command",
591
+ description: "Search for text patterns within file contents using grep. Supports literal strings and regex patterns. Use to find specific code, text, or patterns across files. Returns matching lines with file paths and line numbers.",
597
592
  tags: ["search", "text"],
598
593
  parameters,
599
594
  validate: (args) => {
@@ -608,8 +603,8 @@ function createGrepTool() {
608
603
  handler: (args, context) => effect_1.Effect.gen(function* () {
609
604
  const shell = yield* shell_1.FileSystemContextServiceTag;
610
605
  const start = args.path
611
- ? yield* shell.resolvePath(buildKeyFromContext(context), args.path)
612
- : yield* shell.getCwd(buildKeyFromContext(context));
606
+ ? yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path)
607
+ : yield* shell.getCwd((0, context_utils_1.buildKeyFromContext)(context));
613
608
  const recursive = args.recursive !== false;
614
609
  const maxResults = typeof args.maxResults === "number" && args.maxResults > 0 ? args.maxResults : 5000;
615
610
  // Build grep command arguments
@@ -747,7 +742,7 @@ function createFindTool() {
747
742
  .strict();
748
743
  return (0, base_tool_1.defineTool)({
749
744
  name: "find",
750
- description: "Find files and directories using the system find command with smart hierarchical search",
745
+ description: "Advanced file and directory search with smart hierarchical search strategy (searches cwd, home, and parent directories in order). Supports deep traversal (default 25 levels), regex patterns, type filters, and hidden files. Use for comprehensive searches when find_path doesn't locate what you need.",
751
746
  tags: ["filesystem", "search"],
752
747
  parameters,
753
748
  validate: (args) => {
@@ -770,13 +765,13 @@ function createFindTool() {
770
765
  const searchPaths = [];
771
766
  if (args.path) {
772
767
  // If path is specified, use it directly
773
- const start = yield* shell.resolvePath(buildKeyFromContext(context), args.path);
768
+ const start = yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path);
774
769
  searchPaths.push(start);
775
770
  }
776
771
  else if (useSmart) {
777
772
  // Smart search: start with most likely locations
778
773
  const home = process.env["HOME"] || "";
779
- const cwd = yield* shell.getCwd(buildKeyFromContext(context));
774
+ const cwd = yield* shell.getCwd((0, context_utils_1.buildKeyFromContext)(context));
780
775
  // 1. Current working directory (most likely)
781
776
  if (cwd && cwd !== home) {
782
777
  searchPaths.push(cwd);
@@ -800,7 +795,7 @@ function createFindTool() {
800
795
  }
801
796
  else {
802
797
  // Traditional search: start from current directory
803
- const start = yield* shell.getCwd(buildKeyFromContext(context));
798
+ const start = yield* shell.getCwd((0, context_utils_1.buildKeyFromContext)(context));
804
799
  searchPaths.push(start);
805
800
  }
806
801
  const allResults = [];
@@ -926,7 +921,7 @@ function createMkdirTool() {
926
921
  message: (args, context) => effect_1.Effect.gen(function* () {
927
922
  const shell = yield* shell_1.FileSystemContextServiceTag;
928
923
  const fs = yield* platform_1.FileSystem.FileSystem;
929
- const target = yield* shell.resolvePathForMkdir(buildKeyFromContext(context), args.path);
924
+ const target = yield* shell.resolvePathForMkdir((0, context_utils_1.buildKeyFromContext)(context), args.path);
930
925
  // Check if directory already exists
931
926
  const statResult = yield* fs
932
927
  .stat(target)
@@ -939,11 +934,11 @@ function createMkdirTool() {
939
934
  return `Path exists but is not a directory: ${target}\n\nCannot create directory at this location because a file already exists.`;
940
935
  }
941
936
  }
942
- return `About to create directory: ${target}${args.recursive === false ? "" : " (with parents)"}.\n\nIMPORTANT: After getting user confirmation, you MUST call the executeMkdir tool with these exact arguments: {"path": "${args.path}", "recursive": ${args.recursive !== false}}`;
937
+ return `About to create directory: ${target}${args.recursive === false ? "" : " (with parents)"}.\n\nIMPORTANT: After getting user confirmation, you MUST call the execute_mkdir tool with these exact arguments: {"path": "${args.path}", "recursive": ${args.recursive !== false}}`;
943
938
  }),
944
939
  errorMessage: "Approval required: Directory creation requires user confirmation.",
945
940
  execute: {
946
- toolName: "executeMkdir",
941
+ toolName: "execute_mkdir",
947
942
  buildArgs: (args) => ({
948
943
  path: args.path,
949
944
  recursive: args.recursive,
@@ -961,8 +956,8 @@ function createExecuteMkdirTool() {
961
956
  })
962
957
  .strict();
963
958
  return (0, base_tool_1.defineTool)({
964
- name: "executeMkdir",
965
- description: "Execute mkdir after user approval",
959
+ name: "execute_mkdir",
960
+ description: "Internal tool that performs the actual directory creation after user has approved the mkdir request. Creates the directory at the specified path, optionally creating parent directories.",
966
961
  hidden: true,
967
962
  parameters,
968
963
  validate: (args) => {
@@ -977,7 +972,7 @@ function createExecuteMkdirTool() {
977
972
  handler: (args, context) => effect_1.Effect.gen(function* () {
978
973
  const fs = yield* platform_1.FileSystem.FileSystem;
979
974
  const shell = yield* shell_1.FileSystemContextServiceTag;
980
- const target = yield* shell.resolvePathForMkdir(buildKeyFromContext(context), args.path);
975
+ const target = yield* shell.resolvePathForMkdir((0, context_utils_1.buildKeyFromContext)(context), args.path);
981
976
  // Check if directory already exists
982
977
  const statResult = yield* fs.stat(target).pipe(effect_1.Effect.catchAll(() => effect_1.Effect.succeed(null)));
983
978
  if (statResult) {
@@ -1015,7 +1010,7 @@ function createStatTool() {
1015
1010
  .strict();
1016
1011
  return (0, base_tool_1.defineTool)({
1017
1012
  name: "stat",
1018
- description: "Check if a file or directory exists and get its information",
1013
+ description: "Check if a file or directory exists and retrieve its metadata (type, size, modification time, access time). Use this to verify existence before operations or to get file information without reading contents.",
1019
1014
  tags: ["filesystem", "info"],
1020
1015
  parameters,
1021
1016
  validate: (args) => {
@@ -1030,7 +1025,7 @@ function createStatTool() {
1030
1025
  handler: (args, context) => effect_1.Effect.gen(function* () {
1031
1026
  const fs = yield* platform_1.FileSystem.FileSystem;
1032
1027
  const shell = yield* shell_1.FileSystemContextServiceTag;
1033
- const target = yield* shell.resolvePathForMkdir(buildKeyFromContext(context), args.path);
1028
+ const target = yield* shell.resolvePathForMkdir((0, context_utils_1.buildKeyFromContext)(context), args.path);
1034
1029
  try {
1035
1030
  const stat = yield* fs.stat(target);
1036
1031
  const normalizedSize = normalizeStatSize(stat.size);
@@ -1100,13 +1095,13 @@ function createRmTool() {
1100
1095
  approval: {
1101
1096
  message: (args, context) => effect_1.Effect.gen(function* () {
1102
1097
  const shell = yield* shell_1.FileSystemContextServiceTag;
1103
- const target = yield* shell.resolvePath(buildKeyFromContext(context), args.path);
1098
+ const target = yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path);
1104
1099
  const recurse = args.recursive === true ? " recursively" : "";
1105
- return `About to delete${recurse}: ${target}. This action may be irreversible.\nIf the user confirms, call executeRm with the same arguments.`;
1100
+ return `About to delete${recurse}: ${target}. This action may be irreversible.\n\nIMPORTANT: After getting user confirmation, you MUST call the execute_rm tool with the same arguments: {"path": "${args.path}", "recursive": ${args.recursive === true}, "force": ${args.force === true}}`;
1106
1101
  }),
1107
1102
  errorMessage: "Approval required: File/directory deletion requires user confirmation.",
1108
1103
  execute: {
1109
- toolName: "executeRm",
1104
+ toolName: "execute_rm",
1110
1105
  buildArgs: (args) => ({
1111
1106
  path: args.path,
1112
1107
  recursive: args.recursive,
@@ -1126,8 +1121,8 @@ function createExecuteRmTool() {
1126
1121
  })
1127
1122
  .strict();
1128
1123
  return (0, base_tool_1.defineTool)({
1129
- name: "executeRm",
1130
- description: "Execute rm after user approval",
1124
+ name: "execute_rm",
1125
+ description: "Internal tool that performs the actual file/directory removal after user has approved the rm request. Deletes the specified path, optionally recursively for directories.",
1131
1126
  hidden: true,
1132
1127
  parameters,
1133
1128
  validate: (args) => {
@@ -1142,7 +1137,7 @@ function createExecuteRmTool() {
1142
1137
  handler: (args, context) => effect_1.Effect.gen(function* () {
1143
1138
  const fs = yield* platform_1.FileSystem.FileSystem;
1144
1139
  const shell = yield* shell_1.FileSystemContextServiceTag;
1145
- const target = yield* shell.resolvePath(buildKeyFromContext(context), args.path);
1140
+ const target = yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path);
1146
1141
  try {
1147
1142
  // Basic safeguards: do not allow deleting root or home dir directly
1148
1143
  if (target === "/" || target === process.env["HOME"]) {
@@ -1203,8 +1198,8 @@ function createFindDirTool() {
1203
1198
  })
1204
1199
  .strict();
1205
1200
  return (0, base_tool_1.defineTool)({
1206
- name: "finddir",
1207
- description: "Search for directories by name with partial matching",
1201
+ name: "find_dir",
1202
+ description: "Search specifically for directories by name with partial matching support. Specialized version of find_path that only returns directories. Use when you need to locate a directory and want to filter out files from results.",
1208
1203
  tags: ["filesystem", "search"],
1209
1204
  parameters,
1210
1205
  validate: (args) => {
@@ -1219,9 +1214,9 @@ function createFindDirTool() {
1219
1214
  handler: (args, context) => effect_1.Effect.gen(function* () {
1220
1215
  const shell = yield* shell_1.FileSystemContextServiceTag;
1221
1216
  const startPath = args.path
1222
- ? yield* shell.resolvePath(buildKeyFromContext(context), args.path)
1223
- : yield* shell.getCwd(buildKeyFromContext(context));
1224
- const found = yield* shell.findDirectory(buildKeyFromContext(context), args.name, args.maxDepth || 3);
1217
+ ? yield* shell.resolvePath((0, context_utils_1.buildKeyFromContext)(context), args.path)
1218
+ : yield* shell.getCwd((0, context_utils_1.buildKeyFromContext)(context));
1219
+ const found = yield* shell.findDirectory((0, context_utils_1.buildKeyFromContext)(context), args.name, args.maxDepth || 3);
1225
1220
  return {
1226
1221
  success: true,
1227
1222
  result: {