@defai.digital/ax-cli 3.4.0 → 3.4.1

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 (53) hide show
  1. package/.ax-cli/checkpoints/2025-11-20/checkpoint-11e9e0ba-c39d-4fd2-aa77-bc818811c921.json +69 -0
  2. package/.ax-cli/checkpoints/2025-11-20/checkpoint-2b260b98-b418-4c7c-9694-e2b94967e662.json +24 -0
  3. package/.ax-cli/checkpoints/2025-11-20/checkpoint-7e03601e-e8ab-4cd7-9841-a74b66adf78f.json +69 -0
  4. package/.ax-cli/checkpoints/2025-11-20/checkpoint-7f9c6562-771f-4fd0-adcf-9e7e9ac34ae8.json +44 -0
  5. package/.ax-cli/checkpoints/2025-11-20/checkpoint-e1ebe666-4c3a-4367-ba5c-27fe512a9c70.json +24 -0
  6. package/.ax-cli/checkpoints/2025-11-21/checkpoint-15743e7d-430c-4d76-b6fc-955d7a5c250c.json +44 -0
  7. package/.ax-cli/checkpoints/2025-11-21/checkpoint-25cf7679-0b3f-4988-83d7-704548fbba91.json +69 -0
  8. package/.ax-cli/checkpoints/2025-11-21/checkpoint-54aedbac-6db0-464e-8ebb-dbb3979e6dca.json +24 -0
  9. package/.ax-cli/checkpoints/2025-11-21/checkpoint-7658aed8-fe5d-4222-903f-1a7c63717ea7.json +24 -0
  10. package/.ax-cli/checkpoints/2025-11-21/checkpoint-c9c13497-40dc-4294-a327-6a5fc854eaa1.json +69 -0
  11. package/automatosx.config.json +333 -0
  12. package/dist/commands/weather.d.ts +8 -0
  13. package/dist/commands/weather.js +160 -0
  14. package/dist/commands/weather.js.map +1 -0
  15. package/dist/grok/client.d.ts +144 -0
  16. package/dist/grok/client.js +237 -0
  17. package/dist/grok/client.js.map +1 -0
  18. package/dist/grok/tools.d.ts +8 -0
  19. package/dist/grok/tools.js +318 -0
  20. package/dist/grok/tools.js.map +1 -0
  21. package/dist/grok/types.d.ts +291 -0
  22. package/dist/grok/types.js +127 -0
  23. package/dist/grok/types.js.map +1 -0
  24. package/dist/index.js +0 -0
  25. package/dist/tools/morph-editor.d.ts +36 -0
  26. package/dist/tools/morph-editor.js +308 -0
  27. package/dist/tools/morph-editor.js.map +1 -0
  28. package/dist/ui/components/session-recovery.d.ts +12 -0
  29. package/dist/ui/components/session-recovery.js +93 -0
  30. package/dist/ui/components/session-recovery.js.map +1 -0
  31. package/dist/utils/model-config.d.ts +28 -0
  32. package/dist/utils/model-config.js +43 -0
  33. package/dist/utils/model-config.js.map +1 -0
  34. package/dist/utils/tool-helpers.d.ts +25 -0
  35. package/dist/utils/tool-helpers.js +79 -0
  36. package/dist/utils/tool-helpers.js.map +1 -0
  37. package/package.json +1 -1
  38. package/packages/schemas/dist/index.d.ts +14 -0
  39. package/packages/schemas/dist/index.d.ts.map +1 -0
  40. package/packages/schemas/dist/index.js +19 -0
  41. package/packages/schemas/dist/index.js.map +1 -0
  42. package/packages/schemas/dist/public/core/brand-types.d.ts +308 -0
  43. package/packages/schemas/dist/public/core/brand-types.d.ts.map +1 -0
  44. package/packages/schemas/dist/public/core/brand-types.js +243 -0
  45. package/packages/schemas/dist/public/core/brand-types.js.map +1 -0
  46. package/packages/schemas/dist/public/core/enums.d.ts +227 -0
  47. package/packages/schemas/dist/public/core/enums.d.ts.map +1 -0
  48. package/packages/schemas/dist/public/core/enums.js +222 -0
  49. package/packages/schemas/dist/public/core/enums.js.map +1 -0
  50. package/packages/schemas/dist/public/core/id-types.d.ts +286 -0
  51. package/packages/schemas/dist/public/core/id-types.d.ts.map +1 -0
  52. package/packages/schemas/dist/public/core/id-types.js +136 -0
  53. package/packages/schemas/dist/public/core/id-types.js.map +1 -0
@@ -0,0 +1,333 @@
1
+ {
2
+ "providers": {
3
+ "claude-code": {
4
+ "enabled": true,
5
+ "priority": 3,
6
+ "timeout": 2700000,
7
+ "command": "claude",
8
+ "healthCheck": {
9
+ "enabled": true,
10
+ "interval": 300000,
11
+ "timeout": 5000
12
+ },
13
+ "circuitBreaker": {
14
+ "enabled": true,
15
+ "failureThreshold": 3,
16
+ "recoveryTimeout": 60000
17
+ },
18
+ "processManagement": {
19
+ "gracefulShutdownTimeout": 5000,
20
+ "forceKillDelay": 1000
21
+ },
22
+ "versionDetection": {
23
+ "timeout": 5000,
24
+ "forceKillDelay": 1000,
25
+ "cacheEnabled": true
26
+ },
27
+ "limitTracking": {
28
+ "enabled": true,
29
+ "window": "weekly",
30
+ "resetHourUtc": 0
31
+ }
32
+ },
33
+ "gemini-cli": {
34
+ "enabled": true,
35
+ "priority": 2,
36
+ "timeout": 2700000,
37
+ "command": "gemini",
38
+ "healthCheck": {
39
+ "enabled": true,
40
+ "interval": 300000,
41
+ "timeout": 5000
42
+ },
43
+ "circuitBreaker": {
44
+ "enabled": true,
45
+ "failureThreshold": 3,
46
+ "recoveryTimeout": 60000
47
+ },
48
+ "processManagement": {
49
+ "gracefulShutdownTimeout": 5000,
50
+ "forceKillDelay": 1000
51
+ },
52
+ "versionDetection": {
53
+ "timeout": 5000,
54
+ "forceKillDelay": 1000,
55
+ "cacheEnabled": true
56
+ },
57
+ "limitTracking": {
58
+ "enabled": true,
59
+ "window": "daily",
60
+ "resetHourUtc": 0
61
+ }
62
+ },
63
+ "openai": {
64
+ "enabled": true,
65
+ "priority": 1,
66
+ "timeout": 2700000,
67
+ "command": "codex",
68
+ "healthCheck": {
69
+ "enabled": true,
70
+ "interval": 300000,
71
+ "timeout": 5000
72
+ },
73
+ "circuitBreaker": {
74
+ "enabled": true,
75
+ "failureThreshold": 3,
76
+ "recoveryTimeout": 60000
77
+ },
78
+ "processManagement": {
79
+ "gracefulShutdownTimeout": 5000,
80
+ "forceKillDelay": 1000
81
+ },
82
+ "versionDetection": {
83
+ "timeout": 5000,
84
+ "forceKillDelay": 1000,
85
+ "cacheEnabled": true
86
+ },
87
+ "limitTracking": {
88
+ "enabled": true,
89
+ "window": "daily",
90
+ "resetHourUtc": 0
91
+ }
92
+ },
93
+ "grok": {
94
+ "enabled": true,
95
+ "priority": 4,
96
+ "timeout": 2700000,
97
+ "command": "grok",
98
+ "healthCheck": {
99
+ "enabled": true,
100
+ "interval": 300000,
101
+ "timeout": 5000
102
+ },
103
+ "circuitBreaker": {
104
+ "enabled": true,
105
+ "failureThreshold": 3,
106
+ "recoveryTimeout": 60000
107
+ },
108
+ "processManagement": {
109
+ "gracefulShutdownTimeout": 5000,
110
+ "forceKillDelay": 1000
111
+ },
112
+ "versionDetection": {
113
+ "timeout": 5000,
114
+ "forceKillDelay": 1000,
115
+ "cacheEnabled": true
116
+ },
117
+ "limitTracking": {
118
+ "enabled": true,
119
+ "window": "daily",
120
+ "resetHourUtc": 0
121
+ }
122
+ }
123
+ },
124
+ "execution": {
125
+ "defaultTimeout": 2700000,
126
+ "concurrency": {
127
+ "maxConcurrentAgents": 4,
128
+ "autoDetect": false,
129
+ "cpuMultiplier": 1,
130
+ "minConcurrency": 2,
131
+ "maxConcurrency": 16
132
+ },
133
+ "retry": {
134
+ "maxAttempts": 3,
135
+ "initialDelay": 1000,
136
+ "maxDelay": 10000,
137
+ "backoffFactor": 2,
138
+ "retryableErrors": [
139
+ "ECONNREFUSED",
140
+ "ETIMEDOUT",
141
+ "ENOTFOUND",
142
+ "rate_limit",
143
+ "overloaded",
144
+ "timeout"
145
+ ]
146
+ },
147
+ "provider": {
148
+ "maxWaitMs": 60000,
149
+ "fallbackDelay": 5000
150
+ },
151
+ "stages": {
152
+ "enabled": true,
153
+ "defaultTimeout": 1800000,
154
+ "checkpointPath": ".automatosx/checkpoints",
155
+ "autoSaveCheckpoint": true,
156
+ "cleanupAfterDays": 7,
157
+ "retry": {
158
+ "defaultMaxRetries": 1,
159
+ "defaultRetryDelay": 2000
160
+ },
161
+ "prompts": {
162
+ "timeout": 600000,
163
+ "autoConfirm": false,
164
+ "locale": "en"
165
+ },
166
+ "progress": {
167
+ "updateInterval": 2000,
168
+ "syntheticProgress": true
169
+ }
170
+ }
171
+ },
172
+ "orchestration": {
173
+ "session": {
174
+ "maxSessions": 100,
175
+ "maxMetadataSize": 10240,
176
+ "saveDebounce": 1000,
177
+ "cleanupAfterDays": 7,
178
+ "maxUuidAttempts": 100,
179
+ "persistPath": ".automatosx/sessions"
180
+ },
181
+ "delegation": {
182
+ "maxDepth": 2,
183
+ "timeout": 2700000,
184
+ "enableCycleDetection": true
185
+ }
186
+ },
187
+ "memory": {
188
+ "maxEntries": 10000,
189
+ "persistPath": ".automatosx/memory",
190
+ "autoCleanup": true,
191
+ "cleanupDays": 30,
192
+ "busyTimeout": 5000,
193
+ "search": {
194
+ "defaultLimit": 10,
195
+ "maxLimit": 100,
196
+ "timeout": 5000
197
+ }
198
+ },
199
+ "abilities": {
200
+ "basePath": ".automatosx/abilities",
201
+ "fallbackPath": "examples/abilities",
202
+ "cache": {
203
+ "enabled": true,
204
+ "maxEntries": 50,
205
+ "ttl": 600000,
206
+ "maxSize": 5242880,
207
+ "cleanupInterval": 120000
208
+ },
209
+ "limits": {
210
+ "maxFileSize": 524288
211
+ }
212
+ },
213
+ "workspace": {
214
+ "prdPath": "automatosx/PRD",
215
+ "tmpPath": "automatosx/tmp",
216
+ "autoCleanupTmp": true,
217
+ "tmpCleanupDays": 7
218
+ },
219
+ "logging": {
220
+ "level": "info",
221
+ "path": ".automatosx/logs",
222
+ "console": true,
223
+ "retention": {
224
+ "maxSizeBytes": 104857600,
225
+ "maxAgeDays": 30,
226
+ "compress": true
227
+ }
228
+ },
229
+ "performance": {
230
+ "profileCache": {
231
+ "enabled": true,
232
+ "maxEntries": 20,
233
+ "ttl": 600000,
234
+ "cleanupInterval": 120000
235
+ },
236
+ "teamCache": {
237
+ "enabled": true,
238
+ "maxEntries": 10,
239
+ "ttl": 600000,
240
+ "cleanupInterval": 120000
241
+ },
242
+ "providerCache": {
243
+ "enabled": true,
244
+ "maxEntries": 100,
245
+ "ttl": 600000,
246
+ "cleanupInterval": 120000
247
+ },
248
+ "adaptiveCache": {
249
+ "maxEntries": 1000,
250
+ "baseTTL": 300000,
251
+ "minTTL": 60000,
252
+ "maxTTL": 3600000,
253
+ "adaptiveMultiplier": 2,
254
+ "lowFreqDivisor": 2,
255
+ "frequencyThreshold": 5,
256
+ "cleanupInterval": 60000
257
+ },
258
+ "responseCache": {
259
+ "enabled": false,
260
+ "ttl": 86400,
261
+ "maxSize": 1000,
262
+ "maxMemorySize": 100,
263
+ "dbPath": ".automatosx/cache/responses.db"
264
+ },
265
+ "rateLimit": {
266
+ "enabled": false,
267
+ "requestsPerMinute": 60,
268
+ "burstSize": 10
269
+ }
270
+ },
271
+ "advanced": {
272
+ "embedding": {
273
+ "timeout": 30000,
274
+ "retryDelay": 1000,
275
+ "dimensions": 1536,
276
+ "maxRetries": 3
277
+ },
278
+ "security": {
279
+ "enablePathValidation": true,
280
+ "allowedExtensions": [
281
+ ".ts",
282
+ ".js",
283
+ ".tsx",
284
+ ".jsx",
285
+ ".py",
286
+ ".go",
287
+ ".rs",
288
+ ".java",
289
+ ".yaml",
290
+ ".yml",
291
+ ".json",
292
+ ".toml",
293
+ ".md",
294
+ ".txt",
295
+ ".csv"
296
+ ]
297
+ },
298
+ "development": {
299
+ "mockProviders": false,
300
+ "profileMode": false
301
+ }
302
+ },
303
+ "integration": {
304
+ "vscode": {
305
+ "enabled": false,
306
+ "apiPort": 3000,
307
+ "autoStart": true,
308
+ "outputPanel": true,
309
+ "notifications": true
310
+ }
311
+ },
312
+ "cli": {
313
+ "run": {
314
+ "defaultMemory": true,
315
+ "defaultSaveMemory": true,
316
+ "defaultFormat": "text",
317
+ "defaultVerbose": false
318
+ },
319
+ "session": {
320
+ "defaultShowAgents": true
321
+ },
322
+ "memory": {
323
+ "defaultLimit": 10
324
+ }
325
+ },
326
+ "router": {
327
+ "healthCheckInterval": 60000,
328
+ "providerCooldownMs": 30000,
329
+ "enableFreeTierPrioritization": true,
330
+ "enableWorkloadAwareRouting": true
331
+ },
332
+ "version": "9.0.0"
333
+ }
@@ -0,0 +1,8 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * Create the weather command
4
+ *
5
+ * Uses curl to fetch weather data from OpenWeatherMap API
6
+ * Requires OPENWEATHER_API_KEY environment variable
7
+ */
8
+ export declare function createWeatherCommand(): Command;
@@ -0,0 +1,160 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { BashTool } from '../tools/bash.js';
4
+ /**
5
+ * Create the weather command
6
+ *
7
+ * Uses curl to fetch weather data from OpenWeatherMap API
8
+ * Requires OPENWEATHER_API_KEY environment variable
9
+ */
10
+ export function createWeatherCommand() {
11
+ const weatherCommand = new Command('weather');
12
+ weatherCommand.description('Get weather information for a location');
13
+ // Get weather command
14
+ weatherCommand
15
+ .command('get')
16
+ .description('Get current weather for a location')
17
+ .argument('<location>', 'Location to get weather for (e.g., "Toronto", "New York, US")')
18
+ .option('-d, --days <number>', 'Number of days to forecast (1-5)', '1')
19
+ .option('-f, --forecast', 'Show forecast instead of current weather', false)
20
+ .option('-k, --api-key <key>', 'OpenWeatherMap API key (overrides environment variable)')
21
+ .action(async (location, options) => {
22
+ try {
23
+ const apiKey = options.apiKey || process.env.OPENWEATHER_API_KEY;
24
+ if (!apiKey) {
25
+ console.error(chalk.red('❌ OpenWeatherMap API key is required'));
26
+ console.log(chalk.yellow('Set OPENWEATHER_API_KEY environment variable or use --api-key option'));
27
+ console.log(chalk.gray('Get a free API key at: https://openweathermap.org/api'));
28
+ process.exit(1);
29
+ }
30
+ const days = Math.min(Math.max(parseInt(options.days) || 1, 1), 5);
31
+ const endpoint = options.forecast ? 'forecast' : 'weather';
32
+ // Build the API URL
33
+ let url = `https://api.openweathermap.org/data/2.5/${endpoint}?q=${encodeURIComponent(location)}&appid=${apiKey}&units=metric`;
34
+ // If forecast and more than 1 day, use the 5 day / 3 hour forecast endpoint
35
+ if (options.forecast && days > 1) {
36
+ url = `https://api.openweathermap.org/data/2.5/forecast?q=${encodeURIComponent(location)}&appid=${apiKey}&units=metric`;
37
+ }
38
+ console.log(chalk.blue(`🌤️ Fetching weather data for ${location}...`));
39
+ const bashTool = new BashTool();
40
+ const result = await bashTool.execute(`curl -s "${url}"`);
41
+ if (result.error) {
42
+ console.error(chalk.red('❌ Error fetching weather data:'), result.error);
43
+ process.exit(1);
44
+ }
45
+ try {
46
+ const weatherData = JSON.parse(result.output || '{}');
47
+ if (weatherData.cod && weatherData.cod !== "200") {
48
+ console.error(chalk.red('❌ Weather API error:'), weatherData.message || 'Unknown error');
49
+ process.exit(1);
50
+ }
51
+ if (options.forecast) {
52
+ displayForecast(weatherData, location, days);
53
+ }
54
+ else {
55
+ displayCurrentWeather(weatherData, location);
56
+ }
57
+ }
58
+ catch (parseError) {
59
+ console.error(chalk.red('❌ Error parsing weather data:'), parseError instanceof Error ? parseError.message : 'Unknown error');
60
+ process.exit(1);
61
+ }
62
+ }
63
+ catch (error) {
64
+ console.error(chalk.red('❌ Error:'), error instanceof Error ? error.message : 'Unknown error');
65
+ process.exit(1);
66
+ }
67
+ });
68
+ return weatherCommand;
69
+ }
70
+ function displayCurrentWeather(data, location) {
71
+ const { main, weather, wind, clouds, name } = data;
72
+ console.log(chalk.bold.blue(`\n🌤️ Current Weather for ${name || location}\n`));
73
+ if (weather && weather.length > 0) {
74
+ const icon = getWeatherIcon(weather[0].main);
75
+ console.log(`${icon} ${weather[0].description.charAt(0).toUpperCase() + weather[0].description.slice(1)}`);
76
+ }
77
+ if (main) {
78
+ console.log(`🌡️ Temperature: ${Math.round(main.temp)}°C (feels like ${Math.round(main.feels_like)}°C)`);
79
+ console.log(`💧 Humidity: ${main.humidity}%`);
80
+ console.log(`📊 Pressure: ${main.pressure} hPa`);
81
+ }
82
+ if (wind) {
83
+ console.log(`💨 Wind: ${wind.speed} m/s${wind.deg ? ` (${getWindDirection(wind.deg)})` : ''}`);
84
+ }
85
+ if (clouds) {
86
+ console.log(`☁️ Cloudiness: ${clouds.all}%`);
87
+ }
88
+ console.log();
89
+ }
90
+ function displayForecast(data, location, days) {
91
+ console.log(chalk.bold.blue(`\n📅 Weather Forecast for ${location} (${days} day${days > 1 ? 's' : ''})\n`));
92
+ if (data.list && Array.isArray(data.list)) {
93
+ // Group forecasts by day
94
+ const dailyForecasts = {};
95
+ data.list.forEach((item) => {
96
+ const date = new Date(item.dt * 1000).toLocaleDateString();
97
+ if (!dailyForecasts[date]) {
98
+ dailyForecasts[date] = [];
99
+ }
100
+ dailyForecasts[date].push(item);
101
+ });
102
+ // Display each day's forecast
103
+ Object.entries(dailyForecasts).slice(0, days).forEach(([date, forecasts]) => {
104
+ console.log(chalk.bold(date));
105
+ // Get midday forecast (or first available)
106
+ const middayForecast = forecasts.find((f) => {
107
+ const hour = new Date(f.dt * 1000).getHours();
108
+ return hour >= 12 && hour <= 15;
109
+ }) || forecasts[0];
110
+ if (middayForecast) {
111
+ const { main, weather, wind } = middayForecast;
112
+ const time = new Date(middayForecast.dt * 1000).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
113
+ if (weather && weather.length > 0) {
114
+ const icon = getWeatherIcon(weather[0].main);
115
+ console.log(` ${icon} ${time} - ${weather[0].description.charAt(0).toUpperCase() + weather[0].description.slice(1)}`);
116
+ }
117
+ if (main) {
118
+ console.log(` 🌡️ ${Math.round(main.temp)}°C (feels like ${Math.round(main.feels_like)}°C)`);
119
+ console.log(` 💧 ${main.humidity}%`);
120
+ }
121
+ if (wind) {
122
+ console.log(` 💨 ${wind.speed} m/s`);
123
+ }
124
+ }
125
+ console.log();
126
+ });
127
+ }
128
+ else if (data.main && data.weather) {
129
+ // Single day forecast (current weather endpoint with forecast data)
130
+ displayCurrentWeather(data, location);
131
+ }
132
+ else {
133
+ console.log(chalk.yellow('⚠️ No forecast data available'));
134
+ }
135
+ }
136
+ function getWeatherIcon(condition) {
137
+ const icons = {
138
+ 'Clear': '☀️',
139
+ 'Clouds': '☁️',
140
+ 'Rain': '🌧️',
141
+ 'Drizzle': '🌦️',
142
+ 'Thunderstorm': '⛈️',
143
+ 'Snow': '❄️',
144
+ 'Mist': '🌫️',
145
+ 'Fog': '🌫️',
146
+ 'Haze': '🌫️',
147
+ 'Dust': '🌫️',
148
+ 'Sand': '🌫️',
149
+ 'Ash': '🌋',
150
+ 'Squall': '💨',
151
+ 'Tornado': '🌪️'
152
+ };
153
+ return icons[condition] || '🌤️';
154
+ }
155
+ function getWindDirection(degrees) {
156
+ const directions = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
157
+ const index = Math.round(degrees / 45) % 8;
158
+ return directions[index];
159
+ }
160
+ //# sourceMappingURL=weather.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weather.js","sourceRoot":"","sources":["../../src/commands/weather.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,cAAc,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9C,cAAc,CAAC,WAAW,CAAC,wCAAwC,CAAC,CAAC;IAErE,sBAAsB;IACtB,cAAc;SACX,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,oCAAoC,CAAC;SACjD,QAAQ,CAAC,YAAY,EAAE,+DAA+D,CAAC;SACvF,MAAM,CAAC,qBAAqB,EAAE,kCAAkC,EAAE,GAAG,CAAC;SACtE,MAAM,CAAC,gBAAgB,EAAE,0CAA0C,EAAE,KAAK,CAAC;SAC3E,MAAM,CAAC,qBAAqB,EAAE,yDAAyD,CAAC;SACxF,MAAM,CAAC,KAAK,EAAE,QAAgB,EAAE,OAA6D,EAAE,EAAE;QAChG,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;YAEjE,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,CAAC,KAAK,CAAC,KAAK,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openai/resources/chat";
2
+ import type { ChatOptions, GLM46StreamChunk } from "./types.js";
3
+ export type GrokMessage = ChatCompletionMessageParam;
4
+ export interface GrokTool {
5
+ type: "function";
6
+ function: {
7
+ name: string;
8
+ description: string;
9
+ parameters: {
10
+ type: "object";
11
+ properties: Record<string, any>;
12
+ required: string[];
13
+ };
14
+ };
15
+ }
16
+ export interface GrokToolCall {
17
+ id: string;
18
+ type: "function";
19
+ function: {
20
+ name: string;
21
+ arguments: string;
22
+ };
23
+ }
24
+ export interface SearchParameters {
25
+ mode?: "auto" | "on" | "off";
26
+ }
27
+ export interface SearchOptions {
28
+ search_parameters?: SearchParameters;
29
+ }
30
+ export interface GrokResponse {
31
+ choices: Array<{
32
+ message: {
33
+ role: string;
34
+ content: string | null;
35
+ reasoning_content?: string;
36
+ tool_calls?: GrokToolCall[];
37
+ };
38
+ finish_reason: string;
39
+ }>;
40
+ usage?: {
41
+ prompt_tokens: number;
42
+ completion_tokens: number;
43
+ total_tokens: number;
44
+ reasoning_tokens?: number;
45
+ };
46
+ }
47
+ /**
48
+ * GrokClient - Enhanced client for GLM-4.6 API
49
+ *
50
+ * Supports advanced features including:
51
+ * - Thinking/reasoning mode
52
+ * - Configurable temperature (0.6-1.0 for GLM-4.6)
53
+ * - Extended context windows (up to 200K tokens)
54
+ * - Multiple model support
55
+ */
56
+ export declare class GrokClient {
57
+ private client;
58
+ private currentModel;
59
+ private defaultMaxTokens;
60
+ private defaultTemperature;
61
+ constructor(apiKey: string, model?: string, baseURL?: string);
62
+ /**
63
+ * Validate and normalize model name
64
+ */
65
+ private validateModel;
66
+ /**
67
+ * Validate temperature for current model
68
+ */
69
+ private validateTemperature;
70
+ /**
71
+ * Validate max tokens for current model
72
+ */
73
+ private validateMaxTokens;
74
+ /**
75
+ * Validate thinking configuration for current model
76
+ */
77
+ private validateThinking;
78
+ setModel(model: string): void;
79
+ getCurrentModel(): string;
80
+ getModelConfig(): {
81
+ name: string;
82
+ contextWindow: number;
83
+ maxOutputTokens: number;
84
+ defaultMaxTokens: number;
85
+ supportsThinking: boolean;
86
+ defaultTemperature: number;
87
+ temperatureRange: {
88
+ min: number;
89
+ max: number;
90
+ };
91
+ tokenEfficiency: number;
92
+ };
93
+ /**
94
+ * Chat completion with GLM-4.6 support
95
+ *
96
+ * @param messages - Conversation messages
97
+ * @param tools - Available tools/functions
98
+ * @param options - Chat options including temperature, thinking mode, etc.
99
+ * @returns Promise<GrokResponse>
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const response = await client.chat(messages, tools, {
104
+ * model: 'glm-4.6',
105
+ * temperature: 0.7,
106
+ * thinking: { type: 'enabled' },
107
+ * maxTokens: 8192
108
+ * });
109
+ * ```
110
+ */
111
+ chat(messages: GrokMessage[], tools?: GrokTool[], options?: ChatOptions): Promise<GrokResponse>;
112
+ /**
113
+ * Streaming chat completion with GLM-4.6 support
114
+ *
115
+ * Yields chunks including reasoning_content when thinking is enabled
116
+ *
117
+ * @param messages - Conversation messages
118
+ * @param tools - Available tools/functions
119
+ * @param options - Chat options including temperature, thinking mode, etc.
120
+ * @returns AsyncGenerator yielding GLM46StreamChunk
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const stream = client.chatStream(messages, tools, {
125
+ * thinking: { type: 'enabled' }
126
+ * });
127
+ *
128
+ * for await (const chunk of stream) {
129
+ * if (chunk.choices[0]?.delta?.reasoning_content) {
130
+ * console.log('Reasoning:', chunk.choices[0].delta.reasoning_content);
131
+ * }
132
+ * if (chunk.choices[0]?.delta?.content) {
133
+ * console.log('Content:', chunk.choices[0].delta.content);
134
+ * }
135
+ * }
136
+ * ```
137
+ */
138
+ chatStream(messages: GrokMessage[], tools?: GrokTool[], options?: ChatOptions): AsyncGenerator<GLM46StreamChunk, void, unknown>;
139
+ /**
140
+ * Search with web context (deprecated - use chat with searchOptions)
141
+ * @deprecated Use chat() with searchOptions parameter instead
142
+ */
143
+ search(query: string, searchParameters?: SearchParameters): Promise<GrokResponse>;
144
+ }