@wingman-ai/gateway 0.2.2 → 0.2.4

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 (160) hide show
  1. package/.wingman/agents/README.md +7 -1
  2. package/.wingman/agents/coding/agent.md +299 -201
  3. package/.wingman/agents/coding-v2/agent.md +127 -0
  4. package/.wingman/agents/coding-v2/implementor.md +89 -0
  5. package/.wingman/agents/main/agent.md +4 -0
  6. package/README.md +1 -0
  7. package/dist/agent/config/agentConfig.cjs +31 -17
  8. package/dist/agent/config/agentConfig.d.ts +23 -1
  9. package/dist/agent/config/agentConfig.js +30 -19
  10. package/dist/agent/config/agentLoader.cjs +26 -8
  11. package/dist/agent/config/agentLoader.d.ts +4 -2
  12. package/dist/agent/config/agentLoader.js +26 -8
  13. package/dist/agent/config/modelFactory.cjs +95 -25
  14. package/dist/agent/config/modelFactory.d.ts +13 -1
  15. package/dist/agent/config/modelFactory.js +95 -25
  16. package/dist/agent/config/toolRegistry.cjs +19 -6
  17. package/dist/agent/config/toolRegistry.d.ts +5 -2
  18. package/dist/agent/config/toolRegistry.js +19 -6
  19. package/dist/agent/middleware/hooks/types.cjs +13 -13
  20. package/dist/agent/middleware/hooks/types.d.ts +1 -1
  21. package/dist/agent/middleware/hooks/types.js +14 -14
  22. package/dist/agent/tests/agentConfig.test.cjs +22 -2
  23. package/dist/agent/tests/agentConfig.test.js +22 -2
  24. package/dist/agent/tests/agentLoader.test.cjs +38 -1
  25. package/dist/agent/tests/agentLoader.test.js +38 -1
  26. package/dist/agent/tests/backgroundTerminal.test.cjs +70 -0
  27. package/dist/agent/tests/backgroundTerminal.test.d.ts +1 -0
  28. package/dist/agent/tests/backgroundTerminal.test.js +64 -0
  29. package/dist/agent/tests/commandExecuteTool.test.cjs +29 -0
  30. package/dist/agent/tests/commandExecuteTool.test.d.ts +1 -0
  31. package/dist/agent/tests/commandExecuteTool.test.js +23 -0
  32. package/dist/agent/tests/modelFactory.test.cjs +47 -5
  33. package/dist/agent/tests/modelFactory.test.js +47 -5
  34. package/dist/agent/tests/terminalSessionManager.test.cjs +121 -0
  35. package/dist/agent/tests/terminalSessionManager.test.d.ts +1 -0
  36. package/dist/agent/tests/terminalSessionManager.test.js +115 -0
  37. package/dist/agent/tests/toolRegistry.test.cjs +14 -2
  38. package/dist/agent/tests/toolRegistry.test.js +14 -2
  39. package/dist/agent/tools/background_terminal.cjs +128 -0
  40. package/dist/agent/tools/background_terminal.d.ts +41 -0
  41. package/dist/agent/tools/background_terminal.js +94 -0
  42. package/dist/agent/tools/code_search.cjs +6 -6
  43. package/dist/agent/tools/code_search.d.ts +1 -1
  44. package/dist/agent/tools/code_search.js +7 -7
  45. package/dist/agent/tools/command_execute.cjs +22 -7
  46. package/dist/agent/tools/command_execute.d.ts +3 -2
  47. package/dist/agent/tools/command_execute.js +23 -8
  48. package/dist/agent/tools/git_status.cjs +3 -3
  49. package/dist/agent/tools/git_status.d.ts +1 -1
  50. package/dist/agent/tools/git_status.js +4 -4
  51. package/dist/agent/tools/internet_search.cjs +6 -6
  52. package/dist/agent/tools/internet_search.d.ts +1 -1
  53. package/dist/agent/tools/internet_search.js +7 -7
  54. package/dist/agent/tools/terminal_session_manager.cjs +321 -0
  55. package/dist/agent/tools/terminal_session_manager.d.ts +77 -0
  56. package/dist/agent/tools/terminal_session_manager.js +284 -0
  57. package/dist/agent/tools/think.cjs +4 -4
  58. package/dist/agent/tools/think.d.ts +1 -1
  59. package/dist/agent/tools/think.js +5 -5
  60. package/dist/agent/tools/ui_registry.cjs +13 -13
  61. package/dist/agent/tools/ui_registry.d.ts +4 -4
  62. package/dist/agent/tools/ui_registry.js +14 -14
  63. package/dist/agent/tools/web_crawler.cjs +4 -4
  64. package/dist/agent/tools/web_crawler.d.ts +1 -1
  65. package/dist/agent/tools/web_crawler.js +5 -5
  66. package/dist/agent/utils.cjs +2 -1
  67. package/dist/agent/utils.js +2 -1
  68. package/dist/cli/commands/init.cjs +7 -6
  69. package/dist/cli/commands/init.js +7 -6
  70. package/dist/cli/commands/provider.cjs +17 -3
  71. package/dist/cli/commands/provider.js +17 -3
  72. package/dist/cli/config/loader.cjs +27 -0
  73. package/dist/cli/config/loader.js +27 -0
  74. package/dist/cli/config/schema.cjs +146 -68
  75. package/dist/cli/config/schema.d.ts +89 -1
  76. package/dist/cli/config/schema.js +134 -68
  77. package/dist/cli/core/agentInvoker.cjs +344 -17
  78. package/dist/cli/core/agentInvoker.d.ts +63 -3
  79. package/dist/cli/core/agentInvoker.js +303 -12
  80. package/dist/cli/core/sessionManager.cjs +32 -5
  81. package/dist/cli/core/sessionManager.js +32 -5
  82. package/dist/cli/core/streamParser.cjs +15 -0
  83. package/dist/cli/core/streamParser.js +15 -0
  84. package/dist/cli/index.cjs +6 -5
  85. package/dist/cli/index.js +6 -5
  86. package/dist/cli/types.d.ts +32 -0
  87. package/dist/cli/ui/toolDisplayHelpers.cjs +2 -0
  88. package/dist/cli/ui/toolDisplayHelpers.js +2 -0
  89. package/dist/gateway/hooks/registry.cjs +2 -1
  90. package/dist/gateway/hooks/registry.d.ts +1 -1
  91. package/dist/gateway/hooks/registry.js +2 -1
  92. package/dist/gateway/hooks/types.cjs +11 -11
  93. package/dist/gateway/hooks/types.d.ts +1 -1
  94. package/dist/gateway/hooks/types.js +12 -12
  95. package/dist/gateway/http/agents.cjs +67 -4
  96. package/dist/gateway/http/agents.js +67 -4
  97. package/dist/gateway/http/sessions.cjs +7 -7
  98. package/dist/gateway/http/sessions.js +7 -7
  99. package/dist/gateway/http/types.d.ts +5 -3
  100. package/dist/gateway/http/webhooks.cjs +6 -5
  101. package/dist/gateway/http/webhooks.js +6 -5
  102. package/dist/gateway/server.cjs +198 -41
  103. package/dist/gateway/server.d.ts +9 -1
  104. package/dist/gateway/server.js +198 -41
  105. package/dist/gateway/types.d.ts +1 -0
  106. package/dist/gateway/validation.cjs +39 -39
  107. package/dist/gateway/validation.d.ts +1 -1
  108. package/dist/gateway/validation.js +40 -40
  109. package/dist/providers/codex.cjs +167 -0
  110. package/dist/providers/codex.d.ts +15 -0
  111. package/dist/providers/codex.js +127 -0
  112. package/dist/providers/credentials.cjs +8 -0
  113. package/dist/providers/credentials.js +8 -0
  114. package/dist/providers/registry.cjs +11 -0
  115. package/dist/providers/registry.d.ts +1 -1
  116. package/dist/providers/registry.js +11 -0
  117. package/dist/tests/additionalMessageMiddleware.test.cjs +3 -0
  118. package/dist/tests/additionalMessageMiddleware.test.js +3 -0
  119. package/dist/tests/agentInvokerSummarization.test.cjs +455 -0
  120. package/dist/tests/agentInvokerSummarization.test.d.ts +1 -0
  121. package/dist/tests/agentInvokerSummarization.test.js +449 -0
  122. package/dist/tests/agents-api.test.cjs +45 -5
  123. package/dist/tests/agents-api.test.js +45 -5
  124. package/dist/tests/cli-config-loader.test.cjs +88 -0
  125. package/dist/tests/cli-config-loader.test.js +88 -0
  126. package/dist/tests/cli-init.test.cjs +27 -3
  127. package/dist/tests/cli-init.test.js +27 -3
  128. package/dist/tests/codex-credentials-precedence.test.cjs +94 -0
  129. package/dist/tests/codex-credentials-precedence.test.d.ts +1 -0
  130. package/dist/tests/codex-credentials-precedence.test.js +88 -0
  131. package/dist/tests/codex-provider.test.cjs +210 -0
  132. package/dist/tests/codex-provider.test.d.ts +1 -0
  133. package/dist/tests/codex-provider.test.js +204 -0
  134. package/dist/tests/gateway.test.cjs +115 -8
  135. package/dist/tests/gateway.test.js +115 -8
  136. package/dist/tests/provider-command-codex.test.cjs +57 -0
  137. package/dist/tests/provider-command-codex.test.d.ts +1 -0
  138. package/dist/tests/provider-command-codex.test.js +51 -0
  139. package/dist/tests/sessionStateMessages.test.cjs +38 -0
  140. package/dist/tests/sessionStateMessages.test.js +38 -0
  141. package/dist/tests/toolDisplayHelpers.test.cjs +3 -0
  142. package/dist/tests/toolDisplayHelpers.test.js +3 -0
  143. package/dist/tools/mcp-finance.cjs +48 -48
  144. package/dist/tools/mcp-finance.js +48 -48
  145. package/dist/types/mcp.cjs +15 -15
  146. package/dist/types/mcp.d.ts +1 -1
  147. package/dist/types/mcp.js +16 -16
  148. package/dist/types/voice.cjs +21 -21
  149. package/dist/types/voice.d.ts +1 -1
  150. package/dist/types/voice.js +22 -22
  151. package/dist/webui/assets/index-DVWQluit.css +11 -0
  152. package/dist/webui/assets/index-Dlyzwalc.js +270 -0
  153. package/dist/webui/favicon-32x32.png +0 -0
  154. package/dist/webui/favicon-64x64.png +0 -0
  155. package/dist/webui/favicon.webp +0 -0
  156. package/dist/webui/index.html +4 -2
  157. package/package.json +13 -12
  158. package/.wingman/agents/coding/implementor.md +0 -79
  159. package/dist/webui/assets/index-CPhfGPHc.js +0 -182
  160. package/dist/webui/assets/index-DDsMIOTX.css +0 -11
@@ -0,0 +1,41 @@
1
+ import * as z from "zod";
2
+ import type { TerminalSessionManager, TerminalSessionStatus } from "./terminal_session_manager.js";
3
+ export interface BackgroundTerminalToolOptions {
4
+ workspace: string;
5
+ ownerId: string;
6
+ sessionManager: TerminalSessionManager;
7
+ envVariables?: Record<string, string>;
8
+ blockedCommands?: string[];
9
+ allowScriptExecution?: boolean;
10
+ commandTimeout?: number;
11
+ }
12
+ export declare const createBackgroundTerminalTool: (options: BackgroundTerminalToolOptions) => import("langchain").DynamicStructuredTool<z.ZodObject<{
13
+ command: z.ZodOptional<z.ZodString>;
14
+ session_id: z.ZodOptional<z.ZodString>;
15
+ chars: z.ZodDefault<z.ZodOptional<z.ZodString>>;
16
+ wait_ms: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
17
+ max_output_chars: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
18
+ }, z.core.$strip>, {
19
+ command?: string;
20
+ session_id?: string;
21
+ chars?: string;
22
+ wait_ms?: number;
23
+ max_output_chars?: number;
24
+ }, {
25
+ command?: string | undefined;
26
+ session_id?: string | undefined;
27
+ chars?: string | undefined;
28
+ wait_ms?: number | undefined;
29
+ max_output_chars?: number | undefined;
30
+ }, {
31
+ session_id?: string;
32
+ status?: TerminalSessionStatus;
33
+ output?: string;
34
+ has_more?: boolean;
35
+ exit_code?: number | null;
36
+ signal?: NodeJS.Signals | null;
37
+ command?: string;
38
+ cwd?: string;
39
+ dropped_chars?: number;
40
+ error?: string;
41
+ }, "background_terminal">;
@@ -0,0 +1,94 @@
1
+ import { tool } from "langchain";
2
+ import { number, object, string } from "zod";
3
+ import { DEFAULT_BLOCKED_COMMANDS } from "./command_execute.js";
4
+ const normalizeCommandParts = (command)=>{
5
+ const commandParts = command.trim().split(/\s+/);
6
+ const commandName = (commandParts[0] || "").toLowerCase();
7
+ return commandName.split(/[\\/]/).pop() || "";
8
+ };
9
+ const isScriptCommand = (command)=>{
10
+ const normalized = command.trim().toLowerCase();
11
+ return normalized.endsWith(".sh") || normalized.endsWith(".bash") || normalized.endsWith(".zsh") || normalized.endsWith(".ps1") || normalized.endsWith(".cmd") || normalized.endsWith(".bat");
12
+ };
13
+ const createSafeEnv = (envVariables)=>{
14
+ const { NODE_OPTIONS, NODE_DEBUG, VSCODE_INSPECTOR_OPTIONS, ...cleanEnv } = process.env;
15
+ return {
16
+ ...cleanEnv,
17
+ FORCE_COLOR: "0",
18
+ NO_COLOR: "1",
19
+ GIT_PAGER: "cat",
20
+ ...envVariables ?? {}
21
+ };
22
+ };
23
+ const buildTerminalResponse = (payload)=>payload;
24
+ const createBackgroundTerminalTool = (options)=>{
25
+ const { workspace, ownerId, sessionManager, envVariables, blockedCommands = DEFAULT_BLOCKED_COMMANDS, allowScriptExecution = true, commandTimeout = 300000 } = options;
26
+ return tool(async ({ command, session_id, chars, wait_ms, max_output_chars })=>{
27
+ try {
28
+ if (command && session_id) return buildTerminalResponse({
29
+ error: "Provide either command or session_id, not both"
30
+ });
31
+ if (!command && !session_id) return buildTerminalResponse({
32
+ error: "Provide command to start a session or session_id to poll/write"
33
+ });
34
+ let resolvedSessionId = session_id;
35
+ if (command) {
36
+ const baseCommand = normalizeCommandParts(command);
37
+ if (blockedCommands.includes(baseCommand)) return buildTerminalResponse({
38
+ error: `Command "${command}" rejected by blockedCommands policy`
39
+ });
40
+ if (!allowScriptExecution && isScriptCommand(command)) return buildTerminalResponse({
41
+ error: `Command "${command}" rejected because script execution is disabled`
42
+ });
43
+ const session = sessionManager.startSession({
44
+ ownerId,
45
+ command,
46
+ cwd: workspace,
47
+ env: createSafeEnv(envVariables),
48
+ runtimeLimitMs: commandTimeout
49
+ });
50
+ resolvedSessionId = session.sessionId;
51
+ }
52
+ if (!resolvedSessionId) return buildTerminalResponse({
53
+ error: "session_id is required"
54
+ });
55
+ if (chars && chars.length > 0) sessionManager.writeSession({
56
+ ownerId,
57
+ sessionId: resolvedSessionId,
58
+ chars
59
+ });
60
+ const pollResult = await sessionManager.pollSession({
61
+ ownerId,
62
+ sessionId: resolvedSessionId,
63
+ waitMs: wait_ms,
64
+ maxOutputChars: max_output_chars
65
+ });
66
+ return buildTerminalResponse({
67
+ session_id: pollResult.sessionId,
68
+ status: pollResult.status,
69
+ output: pollResult.output,
70
+ has_more: pollResult.hasMore,
71
+ exit_code: pollResult.exitCode,
72
+ signal: pollResult.signal,
73
+ command: pollResult.command,
74
+ cwd: pollResult.cwd,
75
+ dropped_chars: pollResult.droppedChars
76
+ });
77
+ } catch (error) {
78
+ return buildTerminalResponse({
79
+ error: error instanceof Error ? error.message : String(error)
80
+ });
81
+ }
82
+ }, {
83
+ name: "background_terminal",
84
+ description: "Single background terminal interface for long-running sessions. Use this for commands that may not exit on their own (for example web servers, test watchers, or log tailing). Start a session with command, then poll or write using session_id. Use normal shell commands in-session (for example ps/jobs/kill) and control chars like \\u0003 to interrupt running programs.",
85
+ schema: object({
86
+ command: string().optional().describe("Command to start a new terminal session"),
87
+ session_id: string().optional().describe("Existing terminal session id for poll/write"),
88
+ chars: string().optional().default("").describe("Optional stdin text to write before polling"),
89
+ wait_ms: number().min(0).max(30000).optional().default(1000).describe("How long to wait for output before returning"),
90
+ max_output_chars: number().min(1).max(200000).optional().default(8000).describe("Maximum output characters to return")
91
+ })
92
+ });
93
+ };
94
+ export { createBackgroundTerminalTool };
@@ -90,12 +90,12 @@ const createCodeSearchTool = (workspace)=>{
90
90
  }), {
91
91
  name: "code_search",
92
92
  description: "Search code patterns across the codebase using ripgrep (or grep as fallback). Fast and efficient for finding function definitions, variables, imports, or any text pattern. Returns file paths with line numbers and context.",
93
- schema: external_zod_namespaceObject.z.object({
94
- pattern: external_zod_namespaceObject.z.string().describe("The pattern to search for (regex or literal string). Examples: 'function.*processData', 'import.*React', 'TODO'"),
95
- path: external_zod_namespaceObject.z.string().optional().describe("Optional: Directory or file to search in (e.g., 'src/', 'src/utils.ts'). Defaults to the active execution workspace."),
96
- type: external_zod_namespaceObject.z.string().optional().describe("Optional: File type filter (e.g., 'ts', 'js', 'py', 'go'). Searches only files of this type."),
97
- context: external_zod_namespaceObject.z.number().optional().default(2).describe("Optional: Number of context lines to show around matches. Default is 2."),
98
- caseSensitive: external_zod_namespaceObject.z.boolean().optional().default(false).describe("Optional: Whether search should be case-sensitive.")
93
+ schema: external_zod_namespaceObject.object({
94
+ pattern: external_zod_namespaceObject.string().describe("The pattern to search for (regex or literal string). Examples: 'function.*processData', 'import.*React', 'TODO'"),
95
+ path: external_zod_namespaceObject.string().optional().describe("Optional: Directory or file to search in (e.g., 'src/', 'src/utils.ts'). Defaults to the active execution workspace."),
96
+ type: external_zod_namespaceObject.string().optional().describe("Optional: File type filter (e.g., 'ts', 'js', 'py', 'go'). Searches only files of this type."),
97
+ context: external_zod_namespaceObject.number().optional().default(2).describe("Optional: Number of context lines to show around matches. Default is 2."),
98
+ caseSensitive: external_zod_namespaceObject.boolean().optional().default(false).describe("Optional: Whether search should be case-sensitive.")
99
99
  })
100
100
  });
101
101
  };
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  /**
3
3
  * Creates a tool that searches code using ripgrep (or grep as fallback)
4
4
  * This provides fast, structured code search across the codebase
@@ -1,5 +1,5 @@
1
1
  import { tool } from "langchain";
2
- import { z } from "zod";
2
+ import { boolean as external_zod_boolean, number, object, string } from "zod";
3
3
  import { execSync, spawn } from "node:child_process";
4
4
  function isRipgrepAvailable() {
5
5
  try {
@@ -62,12 +62,12 @@ const createCodeSearchTool = (workspace)=>{
62
62
  }), {
63
63
  name: "code_search",
64
64
  description: "Search code patterns across the codebase using ripgrep (or grep as fallback). Fast and efficient for finding function definitions, variables, imports, or any text pattern. Returns file paths with line numbers and context.",
65
- schema: z.object({
66
- pattern: z.string().describe("The pattern to search for (regex or literal string). Examples: 'function.*processData', 'import.*React', 'TODO'"),
67
- path: z.string().optional().describe("Optional: Directory or file to search in (e.g., 'src/', 'src/utils.ts'). Defaults to the active execution workspace."),
68
- type: z.string().optional().describe("Optional: File type filter (e.g., 'ts', 'js', 'py', 'go'). Searches only files of this type."),
69
- context: z.number().optional().default(2).describe("Optional: Number of context lines to show around matches. Default is 2."),
70
- caseSensitive: z.boolean().optional().default(false).describe("Optional: Whether search should be case-sensitive.")
65
+ schema: object({
66
+ pattern: string().describe("The pattern to search for (regex or literal string). Examples: 'function.*processData', 'import.*React', 'TODO'"),
67
+ path: string().optional().describe("Optional: Directory or file to search in (e.g., 'src/', 'src/utils.ts'). Defaults to the active execution workspace."),
68
+ type: string().optional().describe("Optional: File type filter (e.g., 'ts', 'js', 'py', 'go'). Searches only files of this type."),
69
+ context: number().optional().default(2).describe("Optional: Number of context lines to show around matches. Default is 2."),
70
+ caseSensitive: external_zod_boolean().optional().default(false).describe("Optional: Whether search should be case-sensitive.")
71
71
  })
72
72
  });
73
73
  };
@@ -27,9 +27,9 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  createCommandExecuteTool: ()=>createCommandExecuteTool,
28
28
  DEFAULT_BLOCKED_COMMANDS: ()=>DEFAULT_BLOCKED_COMMANDS
29
29
  });
30
+ const external_node_child_process_namespaceObject = require("node:child_process");
30
31
  const external_langchain_namespaceObject = require("langchain");
31
32
  const external_zod_namespaceObject = require("zod");
32
- const external_node_child_process_namespaceObject = require("node:child_process");
33
33
  const DEFAULT_BLOCKED_COMMANDS = [
34
34
  "rm",
35
35
  "remove",
@@ -48,7 +48,22 @@ const DEFAULT_BLOCKED_COMMANDS = [
48
48
  "sudo",
49
49
  "su"
50
50
  ];
51
- const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEFAULT_BLOCKED_COMMANDS, allowScriptExecution = true, timeoutInMilliseconds = 300000)=>(0, external_langchain_namespaceObject.tool)(async ({ command })=>new Promise((resolve)=>{
51
+ const DEFAULT_MAX_OUTPUT_CHARS = 200000;
52
+ const TRUNCATION_HEAD_CHARS = 120000;
53
+ const TRUNCATION_TAIL_CHARS = 80000;
54
+ function appendCommandOutput(existing, incoming, maxChars) {
55
+ if (!incoming) return existing;
56
+ if (maxChars <= 0) return "";
57
+ const combined = existing + incoming;
58
+ if (combined.length <= maxChars) return combined;
59
+ const headBudget = Math.min(TRUNCATION_HEAD_CHARS, Math.floor(0.6 * maxChars));
60
+ const tailBudget = Math.min(TRUNCATION_TAIL_CHARS, Math.max(0, maxChars - headBudget));
61
+ const head = combined.slice(0, headBudget);
62
+ const tail = tailBudget > 0 ? combined.slice(-tailBudget) : "";
63
+ const omitted = Math.max(0, combined.length - head.length - tail.length);
64
+ return `${head}\n\n[output truncated: omitted ${omitted} chars]\n\n${tail}`;
65
+ }
66
+ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEFAULT_BLOCKED_COMMANDS, allowScriptExecution = true, timeoutInMilliseconds = 300000, maxOutputChars = DEFAULT_MAX_OUTPUT_CHARS)=>(0, external_langchain_namespaceObject.tool)(async ({ command })=>new Promise((resolve)=>{
52
67
  try {
53
68
  const commandParts = command.trim().split(/\s+/);
54
69
  const commandName = (commandParts[0] || "").toLowerCase();
@@ -89,7 +104,7 @@ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEF
89
104
  hasExited = true;
90
105
  try {
91
106
  terminalProcess.kill();
92
- } catch (e) {}
107
+ } catch {}
93
108
  const result = `Command: "${command}" timed out after ${timeoutInMilliseconds / 1000} seconds`;
94
109
  resolve(result);
95
110
  }
@@ -103,10 +118,10 @@ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEF
103
118
  }
104
119
  };
105
120
  terminalProcess.stdout?.on("data", (data)=>{
106
- output += data.toString();
121
+ output = appendCommandOutput(output, data.toString(), maxOutputChars);
107
122
  });
108
123
  terminalProcess.stderr?.on("data", (data)=>{
109
- output += data.toString();
124
+ output = appendCommandOutput(output, data.toString(), maxOutputChars);
110
125
  });
111
126
  terminalProcess.on("error", (err)=>{
112
127
  resolveResponse(err.message, true);
@@ -121,8 +136,8 @@ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEF
121
136
  }), {
122
137
  name: "command_execute",
123
138
  description: "Executes a command in a terminal and reports the output. Cannot execute potentially destructive commands like rm, mv, chmod, sudo, etc. Use for safe operations like running tests, builds, or other validation commands. Do not run long-running commands like dev servers. Commands run with a timeout in the active execution workspace context.",
124
- schema: external_zod_namespaceObject.z.object({
125
- command: external_zod_namespaceObject.z.string().describe("The command to execute in the terminal")
139
+ schema: external_zod_namespaceObject.object({
140
+ command: external_zod_namespaceObject.string().describe("The command to execute in the terminal")
126
141
  })
127
142
  });
128
143
  exports.DEFAULT_BLOCKED_COMMANDS = __webpack_exports__.DEFAULT_BLOCKED_COMMANDS;
@@ -1,9 +1,10 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  export declare const DEFAULT_BLOCKED_COMMANDS: string[];
3
3
  /**
4
4
  * Creates a tool that executes terminal commands safely
5
5
  */
6
- export declare const createCommandExecuteTool: (workspace: string, envVariables?: Record<string, string>, blockedCommands?: string[], allowScriptExecution?: boolean, timeoutInMilliseconds?: number) => import("langchain").DynamicStructuredTool<z.ZodObject<{
6
+ export declare const createCommandExecuteTool: (workspace: string, envVariables?: Record<string, string>, blockedCommands?: string[], allowScriptExecution?: boolean, timeoutInMilliseconds?: number, // Default timeout of 5 minutes
7
+ maxOutputChars?: number) => import("langchain").DynamicStructuredTool<z.ZodObject<{
7
8
  command: z.ZodString;
8
9
  }, z.core.$strip>, {
9
10
  command: string;
@@ -1,6 +1,6 @@
1
- import { tool } from "langchain";
2
- import { z } from "zod";
3
1
  import { spawn } from "node:child_process";
2
+ import { tool } from "langchain";
3
+ import { object, string } from "zod";
4
4
  const DEFAULT_BLOCKED_COMMANDS = [
5
5
  "rm",
6
6
  "remove",
@@ -19,7 +19,22 @@ const DEFAULT_BLOCKED_COMMANDS = [
19
19
  "sudo",
20
20
  "su"
21
21
  ];
22
- const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEFAULT_BLOCKED_COMMANDS, allowScriptExecution = true, timeoutInMilliseconds = 300000)=>tool(async ({ command })=>new Promise((resolve)=>{
22
+ const DEFAULT_MAX_OUTPUT_CHARS = 200000;
23
+ const TRUNCATION_HEAD_CHARS = 120000;
24
+ const TRUNCATION_TAIL_CHARS = 80000;
25
+ function appendCommandOutput(existing, incoming, maxChars) {
26
+ if (!incoming) return existing;
27
+ if (maxChars <= 0) return "";
28
+ const combined = existing + incoming;
29
+ if (combined.length <= maxChars) return combined;
30
+ const headBudget = Math.min(TRUNCATION_HEAD_CHARS, Math.floor(0.6 * maxChars));
31
+ const tailBudget = Math.min(TRUNCATION_TAIL_CHARS, Math.max(0, maxChars - headBudget));
32
+ const head = combined.slice(0, headBudget);
33
+ const tail = tailBudget > 0 ? combined.slice(-tailBudget) : "";
34
+ const omitted = Math.max(0, combined.length - head.length - tail.length);
35
+ return `${head}\n\n[output truncated: omitted ${omitted} chars]\n\n${tail}`;
36
+ }
37
+ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEFAULT_BLOCKED_COMMANDS, allowScriptExecution = true, timeoutInMilliseconds = 300000, maxOutputChars = DEFAULT_MAX_OUTPUT_CHARS)=>tool(async ({ command })=>new Promise((resolve)=>{
23
38
  try {
24
39
  const commandParts = command.trim().split(/\s+/);
25
40
  const commandName = (commandParts[0] || "").toLowerCase();
@@ -60,7 +75,7 @@ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEF
60
75
  hasExited = true;
61
76
  try {
62
77
  terminalProcess.kill();
63
- } catch (e) {}
78
+ } catch {}
64
79
  const result = `Command: "${command}" timed out after ${timeoutInMilliseconds / 1000} seconds`;
65
80
  resolve(result);
66
81
  }
@@ -74,10 +89,10 @@ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEF
74
89
  }
75
90
  };
76
91
  terminalProcess.stdout?.on("data", (data)=>{
77
- output += data.toString();
92
+ output = appendCommandOutput(output, data.toString(), maxOutputChars);
78
93
  });
79
94
  terminalProcess.stderr?.on("data", (data)=>{
80
- output += data.toString();
95
+ output = appendCommandOutput(output, data.toString(), maxOutputChars);
81
96
  });
82
97
  terminalProcess.on("error", (err)=>{
83
98
  resolveResponse(err.message, true);
@@ -92,8 +107,8 @@ const createCommandExecuteTool = (workspace, envVariables, blockedCommands = DEF
92
107
  }), {
93
108
  name: "command_execute",
94
109
  description: "Executes a command in a terminal and reports the output. Cannot execute potentially destructive commands like rm, mv, chmod, sudo, etc. Use for safe operations like running tests, builds, or other validation commands. Do not run long-running commands like dev servers. Commands run with a timeout in the active execution workspace context.",
95
- schema: z.object({
96
- command: z.string().describe("The command to execute in the terminal")
110
+ schema: object({
111
+ command: string().describe("The command to execute in the terminal")
97
112
  })
98
113
  });
99
114
  export { DEFAULT_BLOCKED_COMMANDS, createCommandExecuteTool };
@@ -112,9 +112,9 @@ const createGitStatusTool = (workspace)=>(0, external_langchain_namespaceObject.
112
112
  }), {
113
113
  name: "git_status",
114
114
  description: "Get current git repository status including uncommitted changes, current branch, and optionally diff statistics. Read-only operation that helps understand the state before making changes.",
115
- schema: external_zod_namespaceObject.z.object({
116
- includeDiff: external_zod_namespaceObject.z.boolean().optional().default(false).describe("Optional: Include summary of unstaged changes (diff --stat). Useful for understanding what has changed."),
117
- includeStaged: external_zod_namespaceObject.z.boolean().optional().default(false).describe("Optional: Include summary of staged changes (diff --cached --stat). Shows what will be committed.")
115
+ schema: external_zod_namespaceObject.object({
116
+ includeDiff: external_zod_namespaceObject.boolean().optional().default(false).describe("Optional: Include summary of unstaged changes (diff --stat). Useful for understanding what has changed."),
117
+ includeStaged: external_zod_namespaceObject.boolean().optional().default(false).describe("Optional: Include summary of staged changes (diff --cached --stat). Shows what will be committed.")
118
118
  })
119
119
  });
120
120
  exports.createGitStatusTool = __webpack_exports__.createGitStatusTool;
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  /**
3
3
  * Creates a tool that gets git repository status (read-only)
4
4
  * Helps agents understand the current state without making modifications
@@ -1,5 +1,5 @@
1
1
  import { tool } from "langchain";
2
- import { z } from "zod";
2
+ import { boolean as external_zod_boolean, object } from "zod";
3
3
  import { spawn } from "node:child_process";
4
4
  const createGitStatusTool = (workspace)=>tool(async ({ includeDiff = false, includeStaged = false })=>new Promise((resolve)=>{
5
5
  try {
@@ -84,9 +84,9 @@ const createGitStatusTool = (workspace)=>tool(async ({ includeDiff = false, incl
84
84
  }), {
85
85
  name: "git_status",
86
86
  description: "Get current git repository status including uncommitted changes, current branch, and optionally diff statistics. Read-only operation that helps understand the state before making changes.",
87
- schema: z.object({
88
- includeDiff: z.boolean().optional().default(false).describe("Optional: Include summary of unstaged changes (diff --stat). Useful for understanding what has changed."),
89
- includeStaged: z.boolean().optional().default(false).describe("Optional: Include summary of staged changes (diff --cached --stat). Shows what will be committed.")
87
+ schema: object({
88
+ includeDiff: external_zod_boolean().optional().default(false).describe("Optional: Include summary of unstaged changes (diff --stat). Useful for understanding what has changed."),
89
+ includeStaged: external_zod_boolean().optional().default(false).describe("Optional: Include summary of staged changes (diff --cached --stat). Shows what will be committed.")
90
90
  })
91
91
  });
92
92
  export { createGitStatusTool };
@@ -130,9 +130,9 @@ function createDuckDuckGoTool(maxResults) {
130
130
  }, {
131
131
  name: "internet_search",
132
132
  description: "Run a web search using DuckDuckGo",
133
- schema: external_zod_namespaceObject.z.object({
134
- query: external_zod_namespaceObject.z.string().describe("The search query"),
135
- maxResults: external_zod_namespaceObject.z.number().optional().default(maxResults).describe("Maximum number of results to return")
133
+ schema: external_zod_namespaceObject.object({
134
+ query: external_zod_namespaceObject.string().describe("The search query"),
135
+ maxResults: external_zod_namespaceObject.number().optional().default(maxResults).describe("Maximum number of results to return")
136
136
  })
137
137
  });
138
138
  }
@@ -154,9 +154,9 @@ function createPerplexityTool(maxResults) {
154
154
  }, {
155
155
  name: "internet_search",
156
156
  description: "Run a web search using Perplexity Sonar with built-in citations",
157
- schema: external_zod_namespaceObject.z.object({
158
- query: external_zod_namespaceObject.z.string().describe("The search query"),
159
- maxResults: external_zod_namespaceObject.z.number().optional().default(maxResults).describe("Maximum number of results to return")
157
+ schema: external_zod_namespaceObject.object({
158
+ query: external_zod_namespaceObject.string().describe("The search query"),
159
+ maxResults: external_zod_namespaceObject.number().optional().default(maxResults).describe("Maximum number of results to return")
160
160
  })
161
161
  });
162
162
  }
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import type { SearchConfig } from "../../cli/config/schema.js";
3
3
  /**
4
4
  * Create an internet search tool based on configuration
@@ -1,7 +1,7 @@
1
1
  import { tool } from "langchain";
2
2
  import { DuckDuckGoSearch } from "@langchain/community/tools/duckduckgo_search";
3
3
  import { ChatOpenAI } from "@langchain/openai";
4
- import { z } from "zod";
4
+ import { number, object, string } from "zod";
5
5
  function _define_property(obj, key, value) {
6
6
  if (key in obj) Object.defineProperty(obj, key, {
7
7
  value: value,
@@ -101,9 +101,9 @@ function createDuckDuckGoTool(maxResults) {
101
101
  }, {
102
102
  name: "internet_search",
103
103
  description: "Run a web search using DuckDuckGo",
104
- schema: z.object({
105
- query: z.string().describe("The search query"),
106
- maxResults: z.number().optional().default(maxResults).describe("Maximum number of results to return")
104
+ schema: object({
105
+ query: string().describe("The search query"),
106
+ maxResults: number().optional().default(maxResults).describe("Maximum number of results to return")
107
107
  })
108
108
  });
109
109
  }
@@ -125,9 +125,9 @@ function createPerplexityTool(maxResults) {
125
125
  }, {
126
126
  name: "internet_search",
127
127
  description: "Run a web search using Perplexity Sonar with built-in citations",
128
- schema: z.object({
129
- query: z.string().describe("The search query"),
130
- maxResults: z.number().optional().default(maxResults).describe("Maximum number of results to return")
128
+ schema: object({
129
+ query: string().describe("The search query"),
130
+ maxResults: number().optional().default(maxResults).describe("Maximum number of results to return")
131
131
  })
132
132
  });
133
133
  }