@defai.digital/ax-cli 3.4.6 → 3.5.2

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 (211) hide show
  1. package/LICENSE +2 -6
  2. package/README.md +90 -2
  3. package/dist/analyzers/ast/parser.d.ts +59 -0
  4. package/dist/analyzers/ast/parser.js +293 -0
  5. package/dist/analyzers/ast/parser.js.map +1 -0
  6. package/dist/analyzers/ast/types.d.ts +107 -0
  7. package/dist/analyzers/ast/types.js +7 -0
  8. package/dist/analyzers/ast/types.js.map +1 -0
  9. package/dist/analyzers/code-smells/base-smell-detector.d.ts +30 -0
  10. package/dist/analyzers/code-smells/base-smell-detector.js +44 -0
  11. package/dist/analyzers/code-smells/base-smell-detector.js.map +1 -0
  12. package/dist/analyzers/code-smells/code-smell-analyzer.d.ts +30 -0
  13. package/dist/analyzers/code-smells/code-smell-analyzer.js +167 -0
  14. package/dist/analyzers/code-smells/code-smell-analyzer.js.map +1 -0
  15. package/dist/analyzers/code-smells/detectors/data-clumps-detector.d.ts +11 -0
  16. package/dist/analyzers/code-smells/detectors/data-clumps-detector.js +66 -0
  17. package/dist/analyzers/code-smells/detectors/data-clumps-detector.js.map +1 -0
  18. package/dist/analyzers/code-smells/detectors/dead-code-detector.d.ts +11 -0
  19. package/dist/analyzers/code-smells/detectors/dead-code-detector.js +53 -0
  20. package/dist/analyzers/code-smells/detectors/dead-code-detector.js.map +1 -0
  21. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.d.ts +11 -0
  22. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js +51 -0
  23. package/dist/analyzers/code-smells/detectors/duplicate-code-detector.js.map +1 -0
  24. package/dist/analyzers/code-smells/detectors/feature-envy-detector.d.ts +11 -0
  25. package/dist/analyzers/code-smells/detectors/feature-envy-detector.js +64 -0
  26. package/dist/analyzers/code-smells/detectors/feature-envy-detector.js.map +1 -0
  27. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.d.ts +11 -0
  28. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js +56 -0
  29. package/dist/analyzers/code-smells/detectors/inappropriate-intimacy-detector.js.map +1 -0
  30. package/dist/analyzers/code-smells/detectors/large-class-detector.d.ts +13 -0
  31. package/dist/analyzers/code-smells/detectors/large-class-detector.js +58 -0
  32. package/dist/analyzers/code-smells/detectors/large-class-detector.js.map +1 -0
  33. package/dist/analyzers/code-smells/detectors/long-method-detector.d.ts +12 -0
  34. package/dist/analyzers/code-smells/detectors/long-method-detector.js +52 -0
  35. package/dist/analyzers/code-smells/detectors/long-method-detector.js.map +1 -0
  36. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.d.ts +12 -0
  37. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js +50 -0
  38. package/dist/analyzers/code-smells/detectors/long-parameter-list-detector.js.map +1 -0
  39. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.d.ts +12 -0
  40. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js +54 -0
  41. package/dist/analyzers/code-smells/detectors/magic-numbers-detector.js.map +1 -0
  42. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.d.ts +13 -0
  43. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js +71 -0
  44. package/dist/analyzers/code-smells/detectors/nested-conditionals-detector.js.map +1 -0
  45. package/dist/analyzers/code-smells/index.d.ts +16 -0
  46. package/dist/analyzers/code-smells/index.js +19 -0
  47. package/dist/analyzers/code-smells/index.js.map +1 -0
  48. package/dist/analyzers/code-smells/types.d.ts +82 -0
  49. package/dist/analyzers/code-smells/types.js +30 -0
  50. package/dist/analyzers/code-smells/types.js.map +1 -0
  51. package/dist/analyzers/dependency/circular-detector.d.ts +17 -0
  52. package/dist/analyzers/dependency/circular-detector.js +71 -0
  53. package/dist/analyzers/dependency/circular-detector.js.map +1 -0
  54. package/dist/analyzers/dependency/coupling-calculator.d.ts +24 -0
  55. package/dist/analyzers/dependency/coupling-calculator.js +86 -0
  56. package/dist/analyzers/dependency/coupling-calculator.js.map +1 -0
  57. package/dist/analyzers/dependency/dependency-analyzer.d.ts +40 -0
  58. package/dist/analyzers/dependency/dependency-analyzer.js +214 -0
  59. package/dist/analyzers/dependency/dependency-analyzer.js.map +1 -0
  60. package/dist/analyzers/dependency/dependency-graph.d.ts +57 -0
  61. package/dist/analyzers/dependency/dependency-graph.js +186 -0
  62. package/dist/analyzers/dependency/dependency-graph.js.map +1 -0
  63. package/dist/analyzers/dependency/index.d.ts +8 -0
  64. package/dist/analyzers/dependency/index.js +8 -0
  65. package/dist/analyzers/dependency/index.js.map +1 -0
  66. package/dist/analyzers/dependency/types.d.ts +105 -0
  67. package/dist/analyzers/dependency/types.js +5 -0
  68. package/dist/analyzers/dependency/types.js.map +1 -0
  69. package/dist/analyzers/git/churn-calculator.d.ts +34 -0
  70. package/dist/analyzers/git/churn-calculator.js +214 -0
  71. package/dist/analyzers/git/churn-calculator.js.map +1 -0
  72. package/dist/analyzers/git/git-analyzer.d.ts +19 -0
  73. package/dist/analyzers/git/git-analyzer.js +71 -0
  74. package/dist/analyzers/git/git-analyzer.js.map +1 -0
  75. package/dist/analyzers/git/hotspot-detector.d.ts +34 -0
  76. package/dist/analyzers/git/hotspot-detector.js +170 -0
  77. package/dist/analyzers/git/hotspot-detector.js.map +1 -0
  78. package/dist/analyzers/git/index.d.ts +7 -0
  79. package/dist/analyzers/git/index.js +7 -0
  80. package/dist/analyzers/git/index.js.map +1 -0
  81. package/dist/analyzers/git/types.d.ts +88 -0
  82. package/dist/analyzers/git/types.js +5 -0
  83. package/dist/analyzers/git/types.js.map +1 -0
  84. package/dist/analyzers/metrics/halstead-calculator.d.ts +30 -0
  85. package/dist/analyzers/metrics/halstead-calculator.js +150 -0
  86. package/dist/analyzers/metrics/halstead-calculator.js.map +1 -0
  87. package/dist/analyzers/metrics/index.d.ts +9 -0
  88. package/dist/analyzers/metrics/index.js +9 -0
  89. package/dist/analyzers/metrics/index.js.map +1 -0
  90. package/dist/analyzers/metrics/maintainability-calculator.d.ts +17 -0
  91. package/dist/analyzers/metrics/maintainability-calculator.js +46 -0
  92. package/dist/analyzers/metrics/maintainability-calculator.js.map +1 -0
  93. package/dist/analyzers/metrics/metrics-analyzer.d.ts +32 -0
  94. package/dist/analyzers/metrics/metrics-analyzer.js +140 -0
  95. package/dist/analyzers/metrics/metrics-analyzer.js.map +1 -0
  96. package/dist/analyzers/metrics/types.d.ts +67 -0
  97. package/dist/analyzers/metrics/types.js +5 -0
  98. package/dist/analyzers/metrics/types.js.map +1 -0
  99. package/dist/analyzers/security/base-detector.d.ts +58 -0
  100. package/dist/analyzers/security/base-detector.js +104 -0
  101. package/dist/analyzers/security/base-detector.js.map +1 -0
  102. package/dist/analyzers/security/detectors/command-injection-detector.d.ts +12 -0
  103. package/dist/analyzers/security/detectors/command-injection-detector.js +84 -0
  104. package/dist/analyzers/security/detectors/command-injection-detector.js.map +1 -0
  105. package/dist/analyzers/security/detectors/hardcoded-secrets-detector.d.ts +16 -0
  106. package/dist/analyzers/security/detectors/hardcoded-secrets-detector.js +140 -0
  107. package/dist/analyzers/security/detectors/hardcoded-secrets-detector.js.map +1 -0
  108. package/dist/analyzers/security/detectors/insecure-deserialization-detector.d.ts +12 -0
  109. package/dist/analyzers/security/detectors/insecure-deserialization-detector.js +109 -0
  110. package/dist/analyzers/security/detectors/insecure-deserialization-detector.js.map +1 -0
  111. package/dist/analyzers/security/detectors/insecure-random-detector.d.ts +12 -0
  112. package/dist/analyzers/security/detectors/insecure-random-detector.js +61 -0
  113. package/dist/analyzers/security/detectors/insecure-random-detector.js.map +1 -0
  114. package/dist/analyzers/security/detectors/path-traversal-detector.d.ts +12 -0
  115. package/dist/analyzers/security/detectors/path-traversal-detector.js +82 -0
  116. package/dist/analyzers/security/detectors/path-traversal-detector.js.map +1 -0
  117. package/dist/analyzers/security/detectors/sql-injection-detector.d.ts +12 -0
  118. package/dist/analyzers/security/detectors/sql-injection-detector.js +88 -0
  119. package/dist/analyzers/security/detectors/sql-injection-detector.js.map +1 -0
  120. package/dist/analyzers/security/detectors/weak-crypto-detector.d.ts +12 -0
  121. package/dist/analyzers/security/detectors/weak-crypto-detector.js +104 -0
  122. package/dist/analyzers/security/detectors/weak-crypto-detector.js.map +1 -0
  123. package/dist/analyzers/security/detectors/xss-detector.d.ts +12 -0
  124. package/dist/analyzers/security/detectors/xss-detector.js +90 -0
  125. package/dist/analyzers/security/detectors/xss-detector.js.map +1 -0
  126. package/dist/analyzers/security/index.d.ts +16 -0
  127. package/dist/analyzers/security/index.js +18 -0
  128. package/dist/analyzers/security/index.js.map +1 -0
  129. package/dist/analyzers/security/security-analyzer.d.ts +38 -0
  130. package/dist/analyzers/security/security-analyzer.js +215 -0
  131. package/dist/analyzers/security/security-analyzer.js.map +1 -0
  132. package/dist/analyzers/security/types.d.ts +95 -0
  133. package/dist/analyzers/security/types.js +7 -0
  134. package/dist/analyzers/security/types.js.map +1 -0
  135. package/dist/commands/memory.js +1 -1
  136. package/dist/commands/memory.js.map +1 -1
  137. package/dist/commands/setup.js +6 -1
  138. package/dist/commands/setup.js.map +1 -1
  139. package/dist/hooks/use-enhanced-input.d.ts +0 -1
  140. package/dist/hooks/use-enhanced-input.js.map +1 -1
  141. package/dist/mcp/health.js +4 -2
  142. package/dist/mcp/health.js.map +1 -1
  143. package/dist/mcp/validation.js +12 -6
  144. package/dist/mcp/validation.js.map +1 -1
  145. package/dist/tools/analysis-tools.d.ts +73 -0
  146. package/dist/tools/analysis-tools.js +422 -0
  147. package/dist/tools/analysis-tools.js.map +1 -0
  148. package/dist/tools/bash.js +2 -1
  149. package/dist/tools/bash.js.map +1 -1
  150. package/dist/ui/components/chat-history.js +1 -1
  151. package/dist/ui/components/chat-history.js.map +1 -1
  152. package/dist/ui/components/chat-interface.js +3 -2
  153. package/dist/ui/components/chat-interface.js.map +1 -1
  154. package/dist/ui/components/confirmation-dialog.js +1 -1
  155. package/dist/ui/components/confirmation-dialog.js.map +1 -1
  156. package/dist/ui/components/welcome-panel.js +1 -1
  157. package/dist/ui/components/welcome-panel.js.map +1 -1
  158. package/dist/ui/hooks/use-chat-reducer.d.ts +61 -0
  159. package/dist/ui/hooks/use-chat-reducer.js +118 -0
  160. package/dist/ui/hooks/use-chat-reducer.js.map +1 -0
  161. package/dist/ui/hooks/use-enhanced-input.d.ts +40 -0
  162. package/dist/ui/hooks/use-enhanced-input.js +254 -0
  163. package/dist/ui/hooks/use-enhanced-input.js.map +1 -0
  164. package/dist/ui/hooks/use-input-handler.d.ts +46 -0
  165. package/dist/ui/hooks/use-input-handler.js +1434 -0
  166. package/dist/ui/hooks/use-input-handler.js.map +1 -0
  167. package/dist/ui/hooks/use-input-history.d.ts +9 -0
  168. package/dist/ui/hooks/use-input-history.js +117 -0
  169. package/dist/ui/hooks/use-input-history.js.map +1 -0
  170. package/dist/utils/config-loader.js +3 -3
  171. package/dist/utils/config-loader.js.map +1 -1
  172. package/dist/utils/parallel-analyzer.js +7 -11
  173. package/dist/utils/parallel-analyzer.js.map +1 -1
  174. package/dist/utils/paste-collapse.d.ts +46 -0
  175. package/dist/utils/paste-collapse.js +77 -0
  176. package/dist/utils/paste-collapse.js.map +1 -0
  177. package/dist/utils/settings-manager.js +16 -2
  178. package/dist/utils/settings-manager.js.map +1 -1
  179. package/dist/utils/streaming-analyzer.js +9 -21
  180. package/dist/utils/streaming-analyzer.js.map +1 -1
  181. package/package.json +5 -5
  182. package/vitest.config.ts +1 -0
  183. package/dist/commands/weather.d.ts +0 -8
  184. package/dist/commands/weather.js +0 -160
  185. package/dist/commands/weather.js.map +0 -1
  186. package/dist/grok/client.d.ts +0 -144
  187. package/dist/grok/client.js +0 -237
  188. package/dist/grok/client.js.map +0 -1
  189. package/dist/grok/tools.d.ts +0 -8
  190. package/dist/grok/tools.js +0 -318
  191. package/dist/grok/tools.js.map +0 -1
  192. package/dist/grok/types.d.ts +0 -291
  193. package/dist/grok/types.js +0 -127
  194. package/dist/grok/types.js.map +0 -1
  195. package/dist/tools/morph-editor.d.ts +0 -36
  196. package/dist/tools/morph-editor.js +0 -308
  197. package/dist/tools/morph-editor.js.map +0 -1
  198. package/dist/ui/components/session-recovery.d.ts +0 -12
  199. package/dist/ui/components/session-recovery.js +0 -93
  200. package/dist/ui/components/session-recovery.js.map +0 -1
  201. package/dist/utils/model-config.d.ts +0 -28
  202. package/dist/utils/model-config.js +0 -43
  203. package/dist/utils/model-config.js.map +0 -1
  204. package/dist/utils/tool-helpers.d.ts +0 -25
  205. package/dist/utils/tool-helpers.js +0 -79
  206. package/dist/utils/tool-helpers.js.map +0 -1
  207. /package/{automatosx.config.json → ax.config.json} +0 -0
  208. /package/{config → config-defaults}/messages.yaml +0 -0
  209. /package/{config → config-defaults}/models.yaml +0 -0
  210. /package/{config → config-defaults}/prompts.yaml +0 -0
  211. /package/{config → config-defaults}/settings.yaml +0 -0
@@ -1,318 +0,0 @@
1
- import { MCPManager } from "../mcp/client.js";
2
- import { loadMCPConfig } from "../mcp/config.js";
3
- const BASE_GROK_TOOLS = [
4
- {
5
- type: "function",
6
- function: {
7
- name: "view_file",
8
- description: "View contents of a file or list directory contents",
9
- parameters: {
10
- type: "object",
11
- properties: {
12
- path: {
13
- type: "string",
14
- description: "Path to file or directory to view",
15
- },
16
- start_line: {
17
- type: "number",
18
- description: "Starting line number for partial file view (optional)",
19
- },
20
- end_line: {
21
- type: "number",
22
- description: "Ending line number for partial file view (optional)",
23
- },
24
- },
25
- required: ["path"],
26
- },
27
- },
28
- },
29
- {
30
- type: "function",
31
- function: {
32
- name: "create_file",
33
- description: "Create a new file with specified content",
34
- parameters: {
35
- type: "object",
36
- properties: {
37
- path: {
38
- type: "string",
39
- description: "Path where the file should be created",
40
- },
41
- content: {
42
- type: "string",
43
- description: "Content to write to the file",
44
- },
45
- },
46
- required: ["path", "content"],
47
- },
48
- },
49
- },
50
- {
51
- type: "function",
52
- function: {
53
- name: "str_replace_editor",
54
- description: "Replace specific text in a file. Use this for single line edits only",
55
- parameters: {
56
- type: "object",
57
- properties: {
58
- path: {
59
- type: "string",
60
- description: "Path to the file to edit",
61
- },
62
- old_str: {
63
- type: "string",
64
- description: "Text to replace (must match exactly, or will use fuzzy matching for multi-line strings)",
65
- },
66
- new_str: {
67
- type: "string",
68
- description: "Text to replace with",
69
- },
70
- replace_all: {
71
- type: "boolean",
72
- description: "Replace all occurrences (default: false, only replaces first occurrence)",
73
- },
74
- },
75
- required: ["path", "old_str", "new_str"],
76
- },
77
- },
78
- },
79
- {
80
- type: "function",
81
- function: {
82
- name: "bash",
83
- description: "Execute a bash command",
84
- parameters: {
85
- type: "object",
86
- properties: {
87
- command: {
88
- type: "string",
89
- description: "The bash command to execute",
90
- },
91
- },
92
- required: ["command"],
93
- },
94
- },
95
- },
96
- {
97
- type: "function",
98
- function: {
99
- name: "search",
100
- description: "Unified search tool for finding text content or files (similar to Cursor's search)",
101
- parameters: {
102
- type: "object",
103
- properties: {
104
- query: {
105
- type: "string",
106
- description: "Text to search for or file name/path pattern",
107
- },
108
- search_type: {
109
- type: "string",
110
- enum: ["text", "files", "both"],
111
- description: "Type of search: 'text' for content search, 'files' for file names, 'both' for both (default: 'both')",
112
- },
113
- include_pattern: {
114
- type: "string",
115
- description: "Glob pattern for files to include (e.g. '*.ts', '*.js')",
116
- },
117
- exclude_pattern: {
118
- type: "string",
119
- description: "Glob pattern for files to exclude (e.g. '*.log', 'node_modules')",
120
- },
121
- case_sensitive: {
122
- type: "boolean",
123
- description: "Whether search should be case sensitive (default: false)",
124
- },
125
- whole_word: {
126
- type: "boolean",
127
- description: "Whether to match whole words only (default: false)",
128
- },
129
- regex: {
130
- type: "boolean",
131
- description: "Whether query is a regex pattern (default: false)",
132
- },
133
- max_results: {
134
- type: "number",
135
- description: "Maximum number of results to return (default: 50)",
136
- },
137
- file_types: {
138
- type: "array",
139
- items: { type: "string" },
140
- description: "File types to search (e.g. ['js', 'ts', 'py'])",
141
- },
142
- include_hidden: {
143
- type: "boolean",
144
- description: "Whether to include hidden files (default: false)",
145
- },
146
- },
147
- required: ["query"],
148
- },
149
- },
150
- },
151
- {
152
- type: "function",
153
- function: {
154
- name: "create_todo_list",
155
- description: "Create a new todo list for planning and tracking tasks",
156
- parameters: {
157
- type: "object",
158
- properties: {
159
- todos: {
160
- type: "array",
161
- description: "Array of todo items",
162
- items: {
163
- type: "object",
164
- properties: {
165
- id: {
166
- type: "string",
167
- description: "Unique identifier for the todo item",
168
- },
169
- content: {
170
- type: "string",
171
- description: "Description of the todo item",
172
- },
173
- status: {
174
- type: "string",
175
- enum: ["pending", "in_progress", "completed"],
176
- description: "Current status of the todo item",
177
- },
178
- priority: {
179
- type: "string",
180
- enum: ["high", "medium", "low"],
181
- description: "Priority level of the todo item",
182
- },
183
- },
184
- required: ["id", "content", "status", "priority"],
185
- },
186
- },
187
- },
188
- required: ["todos"],
189
- },
190
- },
191
- },
192
- {
193
- type: "function",
194
- function: {
195
- name: "update_todo_list",
196
- description: "Update existing todos in the todo list",
197
- parameters: {
198
- type: "object",
199
- properties: {
200
- updates: {
201
- type: "array",
202
- description: "Array of todo updates",
203
- items: {
204
- type: "object",
205
- properties: {
206
- id: {
207
- type: "string",
208
- description: "ID of the todo item to update",
209
- },
210
- status: {
211
- type: "string",
212
- enum: ["pending", "in_progress", "completed"],
213
- description: "New status for the todo item",
214
- },
215
- content: {
216
- type: "string",
217
- description: "New content for the todo item",
218
- },
219
- priority: {
220
- type: "string",
221
- enum: ["high", "medium", "low"],
222
- description: "New priority for the todo item",
223
- },
224
- },
225
- required: ["id"],
226
- },
227
- },
228
- },
229
- required: ["updates"],
230
- },
231
- },
232
- },
233
- ];
234
- // Function to build tools array
235
- function buildGrokTools() {
236
- return [...BASE_GROK_TOOLS];
237
- }
238
- // Export dynamic tools array
239
- export const GROK_TOOLS = buildGrokTools();
240
- // Global MCP manager instance
241
- let mcpManager = null;
242
- export function getMCPManager() {
243
- if (!mcpManager) {
244
- mcpManager = new MCPManager();
245
- }
246
- return mcpManager;
247
- }
248
- export async function initializeMCPServers() {
249
- const manager = getMCPManager();
250
- const config = loadMCPConfig();
251
- // Store original stderr.write
252
- const originalStderrWrite = process.stderr.write;
253
- // Temporarily suppress stderr to hide verbose MCP connection logs
254
- process.stderr.write = function (chunk, encoding, callback) {
255
- // Filter out mcp-remote verbose logs
256
- const chunkStr = chunk.toString();
257
- if (chunkStr.includes('[') && (chunkStr.includes('Using existing client port') ||
258
- chunkStr.includes('Connecting to remote server') ||
259
- chunkStr.includes('Using transport strategy') ||
260
- chunkStr.includes('Connected to remote server') ||
261
- chunkStr.includes('Local STDIO server running') ||
262
- chunkStr.includes('Proxy established successfully') ||
263
- chunkStr.includes('Local→Remote') ||
264
- chunkStr.includes('Remote→Local'))) {
265
- // Suppress these verbose logs
266
- if (callback)
267
- callback();
268
- return true;
269
- }
270
- // Allow other stderr output
271
- return originalStderrWrite.call(this, chunk, encoding, callback);
272
- };
273
- try {
274
- for (const serverConfig of config.servers) {
275
- try {
276
- await manager.addServer(serverConfig);
277
- }
278
- catch (error) {
279
- console.warn(`Failed to initialize MCP server ${serverConfig.name}:`, error);
280
- }
281
- }
282
- }
283
- finally {
284
- // Restore original stderr.write
285
- process.stderr.write = originalStderrWrite;
286
- }
287
- }
288
- export function convertMCPToolToGrokTool(mcpTool) {
289
- return {
290
- type: "function",
291
- function: {
292
- name: mcpTool.name,
293
- description: mcpTool.description,
294
- parameters: mcpTool.inputSchema || {
295
- type: "object",
296
- properties: {},
297
- required: []
298
- }
299
- }
300
- };
301
- }
302
- export function addMCPToolsToGrokTools(baseTools) {
303
- if (!mcpManager) {
304
- return baseTools;
305
- }
306
- const mcpTools = mcpManager.getTools();
307
- const grokMCPTools = mcpTools.map(convertMCPToolToGrokTool);
308
- return [...baseTools, ...grokMCPTools];
309
- }
310
- export async function getAllGrokTools() {
311
- const manager = getMCPManager();
312
- // Try to initialize servers if not already done, but don't block
313
- manager.ensureServersInitialized().catch(() => {
314
- // Ignore initialization errors to avoid blocking
315
- });
316
- return addMCPToolsToGrokTools(GROK_TOOLS);
317
- }
318
- //# sourceMappingURL=tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/grok/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAW,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,eAAe,GAAe;IAClC;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE,oDAAoD;YACjE,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,mCAAmC;qBACjD;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,QAAQ;wBACd,WAAW,EACT,uDAAuD;qBAC1D;oBACD,QAAQ,EAAE;wBACR,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,qDAAqD;qBACnE;iBACF;gBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;aACnB;SACF;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,0CAA0C;YACvD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,uCAAuC;qBACrD;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,8BAA8B;qBAC5C;iBACF;gBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;aAC9B;SACF;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,oBAAoB;YAC1B,WAAW,EAAE,sEAAsE;YACnF,UAAU,EAAE;gBACV,IAAI,EA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AiD;IACnD,CAAC,CAAC,CAAC;IACH,OAAO,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,291 +0,0 @@
1
- /**
2
- * GLM-4.6 API Type Definitions
3
- *
4
- * This file contains comprehensive type definitions for GLM-4.6 API features,
5
- * including advanced reasoning mode, configurable parameters, and enhanced
6
- * response structures.
7
- *
8
- * @see https://docs.z.ai/guides/llm/glm-4.6
9
- */
10
- import type { GrokTool, GrokToolCall, SearchOptions } from "./client.js";
11
- /**
12
- * Thinking/Reasoning configuration for GLM-4.6
13
- *
14
- * When enabled, the model will include reasoning_content in responses,
15
- * showing the step-by-step thought process before generating the final answer.
16
- *
17
- * @example
18
- * ```typescript
19
- * const thinking: ThinkingConfig = { type: "enabled" };
20
- * const response = await client.chat(messages, [], { thinking });
21
- * ```
22
- */
23
- export interface ThinkingConfig {
24
- /**
25
- * Enable or disable thinking mode
26
- * - "enabled": Include reasoning process in responses
27
- * - "disabled": Standard response without reasoning
28
- */
29
- type: "enabled" | "disabled";
30
- }
31
- /**
32
- * Comprehensive options for GLM-4.6 chat requests
33
- *
34
- * Consolidates all available parameters for chat completions,
35
- * providing type-safe configuration for GLM-4.6 features.
36
- */
37
- export interface ChatOptions {
38
- /**
39
- * Model identifier
40
- * @default "glm-4.6"
41
- * @example "glm-4.6", "grok-code-fast-1"
42
- */
43
- model?: string;
44
- /**
45
- * Temperature controls randomness in responses
46
- *
47
- * - Lower values (0.6): More focused and deterministic
48
- * - Higher values (1.0): More creative and diverse
49
- *
50
- * @default 0.7
51
- * @minimum 0.6
52
- * @maximum 1.0
53
- */
54
- temperature?: number;
55
- /**
56
- * Maximum number of tokens to generate
57
- *
58
- * GLM-4.6 supports up to 128,000 output tokens
59
- *
60
- * @default 8192
61
- * @maximum 128000
62
- */
63
- maxTokens?: number;
64
- /**
65
- * Enable/disable advanced reasoning mode
66
- *
67
- * When enabled, responses include reasoning_content showing
68
- * the model's step-by-step thought process.
69
- */
70
- thinking?: ThinkingConfig;
71
- /**
72
- * Search parameters for web-enabled queries
73
- */
74
- searchOptions?: SearchOptions;
75
- /**
76
- * Tools/functions available for the model to call
77
- */
78
- tools?: GrokTool[];
79
- /**
80
- * Enable streaming responses
81
- * @default false
82
- */
83
- stream?: boolean;
84
- }
85
- /**
86
- * GLM-4.6 enhanced response structure
87
- *
88
- * Extends the standard response with reasoning content and
89
- * enhanced usage metrics.
90
- */
91
- export interface GLM46Response {
92
- id: string;
93
- object: string;
94
- created: number;
95
- model: string;
96
- choices: Array<{
97
- index: number;
98
- message: {
99
- role: string;
100
- content: string | null;
101
- /**
102
- * Reasoning process (only present when thinking is enabled)
103
- * Contains the step-by-step thought process before the final answer
104
- */
105
- reasoning_content?: string;
106
- tool_calls?: GrokToolCall[];
107
- };
108
- finish_reason: string;
109
- }>;
110
- /**
111
- * Token usage statistics
112
- */
113
- usage?: {
114
- prompt_tokens: number;
115
- completion_tokens: number;
116
- total_tokens: number;
117
- /**
118
- * Tokens used for reasoning (only when thinking is enabled)
119
- */
120
- reasoning_tokens?: number;
121
- };
122
- }
123
- /**
124
- * GLM-4.6 streaming response chunk
125
- *
126
- * Individual chunks received during streaming responses,
127
- * including support for reasoning content.
128
- */
129
- export interface GLM46StreamChunk {
130
- id: string;
131
- object: string;
132
- created: number;
133
- model: string;
134
- choices: Array<{
135
- index: number;
136
- delta: {
137
- role?: string;
138
- /**
139
- * Incremental content from the final response
140
- */
141
- content?: string;
142
- /**
143
- * Incremental reasoning content (when thinking is enabled)
144
- * Shows the model's thought process as it develops
145
- */
146
- reasoning_content?: string;
147
- tool_calls?: Array<{
148
- index: number;
149
- id?: string;
150
- type?: "function";
151
- function?: {
152
- name?: string;
153
- arguments?: string;
154
- };
155
- }>;
156
- };
157
- finish_reason?: string | null;
158
- }>;
159
- }
160
- /**
161
- * Type guard to check if a response is a GLM-4.6 response
162
- */
163
- export declare function isGLM46Response(response: unknown): response is GLM46Response;
164
- /**
165
- * Type guard to check if a chunk has reasoning content
166
- */
167
- export declare function hasReasoningContent(chunk: GLM46StreamChunk): chunk is GLM46StreamChunk & {
168
- choices: Array<{
169
- delta: {
170
- reasoning_content: string;
171
- };
172
- }>;
173
- };
174
- /**
175
- * GLM-4.6 model configurations
176
- *
177
- * Defines capabilities and limits for supported models
178
- */
179
- export declare const GLM_MODELS: {
180
- readonly "glm-4.6": {
181
- readonly contextWindow: 200000;
182
- readonly maxOutputTokens: 128000;
183
- readonly supportsThinking: true;
184
- readonly defaultTemperature: 0.7;
185
- readonly temperatureRange: {
186
- readonly min: 0.6;
187
- readonly max: 1;
188
- };
189
- readonly tokenEfficiency: 1.3;
190
- };
191
- readonly "grok-code-fast-1": {
192
- readonly contextWindow: 128000;
193
- readonly maxOutputTokens: 4096;
194
- readonly supportsThinking: false;
195
- readonly defaultTemperature: 0.7;
196
- readonly temperatureRange: {
197
- readonly min: 0;
198
- readonly max: 2;
199
- };
200
- readonly tokenEfficiency: 1;
201
- };
202
- readonly "glm-4-air": {
203
- readonly contextWindow: 128000;
204
- readonly maxOutputTokens: 8192;
205
- readonly supportsThinking: false;
206
- readonly defaultTemperature: 0.7;
207
- readonly temperatureRange: {
208
- readonly min: 0.6;
209
- readonly max: 1;
210
- };
211
- readonly tokenEfficiency: 1.15;
212
- };
213
- readonly "glm-4-airx": {
214
- readonly contextWindow: 8192;
215
- readonly maxOutputTokens: 8192;
216
- readonly supportsThinking: false;
217
- readonly defaultTemperature: 0.7;
218
- readonly temperatureRange: {
219
- readonly min: 0.6;
220
- readonly max: 1;
221
- };
222
- readonly tokenEfficiency: 1.1;
223
- };
224
- };
225
- export type SupportedModel = keyof typeof GLM_MODELS;
226
- /**
227
- * Get model configuration by name
228
- */
229
- export declare function getModelConfig(model: string): {
230
- readonly contextWindow: 200000;
231
- readonly maxOutputTokens: 128000;
232
- readonly supportsThinking: true;
233
- readonly defaultTemperature: 0.7;
234
- readonly temperatureRange: {
235
- readonly min: 0.6;
236
- readonly max: 1;
237
- };
238
- readonly tokenEfficiency: 1.3;
239
- } | {
240
- readonly contextWindow: 128000;
241
- readonly maxOutputTokens: 4096;
242
- readonly supportsThinking: false;
243
- readonly defaultTemperature: 0.7;
244
- readonly temperatureRange: {
245
- readonly min: 0;
246
- readonly max: 2;
247
- };
248
- readonly tokenEfficiency: 1;
249
- } | {
250
- readonly contextWindow: 128000;
251
- readonly maxOutputTokens: 8192;
252
- readonly supportsThinking: false;
253
- readonly defaultTemperature: 0.7;
254
- readonly temperatureRange: {
255
- readonly min: 0.6;
256
- readonly max: 1;
257
- };
258
- readonly tokenEfficiency: 1.15;
259
- } | {
260
- readonly contextWindow: 8192;
261
- readonly maxOutputTokens: 8192;
262
- readonly supportsThinking: false;
263
- readonly defaultTemperature: 0.7;
264
- readonly temperatureRange: {
265
- readonly min: 0.6;
266
- readonly max: 1;
267
- };
268
- readonly tokenEfficiency: 1.1;
269
- };
270
- /**
271
- * Validate temperature for a given model
272
- *
273
- * @throws Error if temperature is out of valid range
274
- */
275
- export declare function validateTemperature(temperature: number, model: string): void;
276
- /**
277
- * Validate max tokens for a given model
278
- *
279
- * @throws Error if maxTokens exceeds model limit
280
- */
281
- export declare function validateMaxTokens(maxTokens: number, model: string): void;
282
- /**
283
- * Validate thinking configuration for a given model
284
- *
285
- * @throws Error if thinking is not supported by the model
286
- */
287
- export declare function validateThinking(thinking: ThinkingConfig | undefined, model: string): void;
288
- /**
289
- * Create default chat options with sensible defaults
290
- */
291
- export declare function createDefaultChatOptions(model?: string): Required<Omit<ChatOptions, 'thinking' | 'searchOptions' | 'tools'>>;