@genspark/cli 1.0.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.
package/dist/index.js ADDED
@@ -0,0 +1,613 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Genspark Tool CLI
4
+ *
5
+ * A command-line interface for Genspark Tool API.
6
+ * Designed for integration with AI agents (e.g., Claude Code).
7
+ *
8
+ * Output conventions:
9
+ * - stderr: Debug info, progress, errors (for human reading)
10
+ * - stdout: API response JSON (for AI agent context)
11
+ *
12
+ * Command Naming Convention:
13
+ * - CLI commands are dynamically generated from server tool schemas
14
+ * - Tool name is always the canonical command name
15
+ * - Aliases provide human-friendly shortcuts (e.g., `search` for `web_search`)
16
+ *
17
+ * Example:
18
+ * Tool name: "web_search" -> Command: `gsk web_search`, Alias: `gsk search`
19
+ * Tool name: "crawler" -> Command: `gsk crawler`, Alias: `gsk crawl`
20
+ */
21
+ import { Command } from "commander";
22
+ import * as fs from "fs";
23
+ import * as pathModule from "path";
24
+ import { spawn } from "child_process";
25
+ import { ApiClient, unauthenticatedRequest } from "./client.js";
26
+ import { setDebugEnabled, setOutputFormat, debug, info, error as logError, output, } from "./logger.js";
27
+ import { loadConfigFile, saveConfigFile, getConfigPath, loadToolsCache, saveToolsCache, } from "./config.js";
28
+ import { checkForUpdates } from "./updater.js";
29
+ const VERSION = "1.1.0";
30
+ const DEFAULT_BASE_URL = "http://localhost:8582";
31
+ const DEFAULT_TIMEOUT = 300000; // 5 minutes (video generation can be slow)
32
+ // Load config file (lowest priority)
33
+ const fileConfig = loadConfigFile();
34
+ // Create main program
35
+ const program = new Command();
36
+ program
37
+ .name("gsk")
38
+ .description("Genspark Tool CLI - Search, crawl, analyze, and generate media")
39
+ .version(VERSION)
40
+ .option("--api-key <key>", "API key (or set GSK_API_KEY env var)")
41
+ .option("--base-url <url>", `Base URL for API (default: ${DEFAULT_BASE_URL})`, DEFAULT_BASE_URL)
42
+ .option("--project-id <id>", "Project ID for access control (or set GSK_PROJECT_ID env var)")
43
+ .option("--debug", "Enable debug output and request more details from server", false)
44
+ .option("--timeout <ms>", "Request timeout in milliseconds", String(DEFAULT_TIMEOUT))
45
+ .option("--output <format>", "Output format: json or text", "json")
46
+ .option("--refresh", "Force refresh of cached tool schemas from server");
47
+ /**
48
+ * Get global options with priority:
49
+ * 1. Command-line options (highest)
50
+ * 2. Environment variables
51
+ * 3. Config file (~/.genspark-tool-cli/config.json) (lowest)
52
+ */
53
+ function getGlobalOptions() {
54
+ const opts = program.opts();
55
+ // API key priority: CLI > env > config file
56
+ const apiKey = opts.apiKey || process.env.GSK_API_KEY || fileConfig.api_key;
57
+ // Base URL priority: CLI > env > config file > default
58
+ const baseUrl = opts.baseUrl !== DEFAULT_BASE_URL
59
+ ? opts.baseUrl
60
+ : process.env.GSK_BASE_URL || fileConfig.base_url || DEFAULT_BASE_URL;
61
+ // Timeout priority: CLI > config file > default
62
+ const timeout = opts.timeout !== String(DEFAULT_TIMEOUT)
63
+ ? parseInt(opts.timeout, 10)
64
+ : fileConfig.timeout || DEFAULT_TIMEOUT;
65
+ // Debug priority: CLI > config file > default
66
+ const debugMode = opts.debug || fileConfig.debug || false;
67
+ // Project ID priority: CLI > env > config file
68
+ const projectId = opts.projectId || process.env.GSK_PROJECT_ID || fileConfig.project_id;
69
+ return {
70
+ apiKey,
71
+ baseUrl,
72
+ debug: debugMode,
73
+ timeout,
74
+ output: opts.output,
75
+ projectId,
76
+ refresh: opts.refresh || false,
77
+ };
78
+ }
79
+ function createClient() {
80
+ const options = getGlobalOptions();
81
+ setDebugEnabled(options.debug);
82
+ setOutputFormat(options.output);
83
+ if (!options.apiKey) {
84
+ logError("API key is required. Provide it via:");
85
+ logError(" 1. --api-key option");
86
+ logError(" 2. GSK_API_KEY environment variable");
87
+ logError(` 3. Config file: ${getConfigPath()}`);
88
+ process.exit(1);
89
+ }
90
+ debug(`Base URL: ${options.baseUrl}`);
91
+ debug(`Timeout: ${options.timeout}ms`);
92
+ debug(`Debug mode: ${options.debug}`);
93
+ debug(`Project ID: ${options.projectId || "(not set)"}`);
94
+ return new ApiClient(options);
95
+ }
96
+ // ============================================
97
+ // Shared helpers for local file handling
98
+ // ============================================
99
+ const CONTENT_TYPE_MAP = {
100
+ ".jpg": "image/jpeg",
101
+ ".jpeg": "image/jpeg",
102
+ ".png": "image/png",
103
+ ".gif": "image/gif",
104
+ ".webp": "image/webp",
105
+ ".pdf": "application/pdf",
106
+ ".txt": "text/plain",
107
+ ".json": "application/json",
108
+ ".html": "text/html",
109
+ ".css": "text/css",
110
+ ".js": "application/javascript",
111
+ ".ts": "application/typescript",
112
+ ".md": "text/markdown",
113
+ ".xml": "application/xml",
114
+ ".csv": "text/csv",
115
+ ".zip": "application/zip",
116
+ ".mp3": "audio/mpeg",
117
+ ".mp4": "video/mp4",
118
+ ".wav": "audio/wav",
119
+ ".webm": "video/webm",
120
+ };
121
+ async function uploadLocalFile(filePath, client) {
122
+ const fileName = pathModule.basename(filePath);
123
+ const ext = pathModule.extname(filePath).toLowerCase();
124
+ const contentType = CONTENT_TYPE_MAP[ext] || "application/octet-stream";
125
+ const stats = fs.statSync(filePath);
126
+ info(`Uploading ${fileName} (${(stats.size / 1024).toFixed(1)} KB, ${contentType})...`);
127
+ const globalOpts = getGlobalOptions();
128
+ const uploadUrlResult = await client.getUploadUrl({
129
+ content_type: contentType,
130
+ name: fileName,
131
+ project_id: globalOpts.projectId,
132
+ });
133
+ if (uploadUrlResult.status !== "ok" || !uploadUrlResult.data) {
134
+ throw new Error(`Failed to get upload URL: ${uploadUrlResult.message}`);
135
+ }
136
+ const { upload_url, file_wrapper_url } = uploadUrlResult.data;
137
+ debug(`Upload URL: ${upload_url.substring(0, 80)}...`);
138
+ const fileBuffer = fs.readFileSync(filePath);
139
+ const uploadResponse = await fetch(upload_url, {
140
+ method: "PUT",
141
+ headers: { "Content-Type": contentType, "x-ms-blob-type": "BlockBlob" },
142
+ body: fileBuffer,
143
+ });
144
+ if (!uploadResponse.ok)
145
+ throw new Error(`Upload failed: HTTP ${uploadResponse.status}`);
146
+ info(`Uploaded → ${file_wrapper_url}`);
147
+ return file_wrapper_url;
148
+ }
149
+ async function downloadToFile(wrapperUrl, savePath, client) {
150
+ info(`Downloading to ${savePath}...`);
151
+ const result = await client.getDownloadUrl({ file_wrapper_url: wrapperUrl });
152
+ if (result.status !== "ok" || !result.data)
153
+ throw new Error(`Failed to get download URL: ${result.message}`);
154
+ const resp = await fetch(result.data.download_url);
155
+ if (!resp.ok)
156
+ throw new Error(`Download failed: HTTP ${resp.status}`);
157
+ const buffer = Buffer.from(await resp.arrayBuffer());
158
+ fs.writeFileSync(savePath, buffer);
159
+ info(`Downloaded ${(buffer.length / 1024).toFixed(1)} KB → ${savePath}`);
160
+ return pathModule.resolve(savePath);
161
+ }
162
+ function isLocalFilePath(value) {
163
+ return (!value.startsWith("http://") &&
164
+ !value.startsWith("https://") &&
165
+ !value.startsWith("/api/") &&
166
+ fs.existsSync(value));
167
+ }
168
+ async function resolveFileArg(value, client) {
169
+ if (!isLocalFilePath(value))
170
+ return value;
171
+ return await uploadLocalFile(value, client);
172
+ }
173
+ /**
174
+ * Resolve local file paths to uploaded URLs in tool arguments.
175
+ * Convention: parameter names ending with '_urls' (arrays) or '_url'/'url' (strings)
176
+ * are checked for local file paths and auto-uploaded.
177
+ */
178
+ async function resolveLocalFiles(args, client) {
179
+ const resolved = { ...args };
180
+ for (const [key, value] of Object.entries(resolved)) {
181
+ // Handle array of URLs (e.g., image_urls)
182
+ if (key.endsWith("_urls") && Array.isArray(value)) {
183
+ const resolvedUrls = [];
184
+ for (const item of value) {
185
+ if (typeof item === "string") {
186
+ resolvedUrls.push(await resolveFileArg(item, client));
187
+ }
188
+ else {
189
+ resolvedUrls.push(item);
190
+ }
191
+ }
192
+ resolved[key] = resolvedUrls;
193
+ }
194
+ // Handle single URL (e.g., url, audio_url)
195
+ else if ((key === "url" || key.endsWith("_url")) &&
196
+ typeof value === "string") {
197
+ resolved[key] = await resolveFileArg(value, client);
198
+ }
199
+ }
200
+ return resolved;
201
+ }
202
+ // ============================================
203
+ // Dynamic tool command registration
204
+ // ============================================
205
+ /**
206
+ * Extract a file URL from nested result data using dot-separated path keys.
207
+ * Tries each key in order, returns the first non-empty string found.
208
+ */
209
+ function extractFileUrl(data, keys) {
210
+ for (const key of keys) {
211
+ let current = data;
212
+ for (const part of key.split(".")) {
213
+ if (current == null || typeof current !== "object") {
214
+ current = undefined;
215
+ break;
216
+ }
217
+ current = current[part];
218
+ }
219
+ if (typeof current === "string" && current.length > 0)
220
+ return current;
221
+ }
222
+ return null;
223
+ }
224
+ /**
225
+ * Register a dynamic tool command from a server-provided schema
226
+ */
227
+ function registerToolCommand(parentProgram, tool, clientFactory) {
228
+ const cmd = parentProgram.command(tool.name).description(tool.description);
229
+ // Register aliases
230
+ for (const alias of tool.cli.aliases) {
231
+ cmd.alias(alias);
232
+ }
233
+ const props = tool.parameters?.properties || {};
234
+ const required = tool.parameters?.required || [];
235
+ // If primary_arg is set, make it a positional argument
236
+ if (tool.cli.primary_arg && props[tool.cli.primary_arg]) {
237
+ const param = props[tool.cli.primary_arg];
238
+ const isRequired = required.includes(tool.cli.primary_arg);
239
+ const bracket = isRequired ? "<value>" : "[value]";
240
+ cmd.argument(bracket, param.description || tool.cli.primary_arg);
241
+ }
242
+ // Add remaining params as --options
243
+ const aliases = tool.cli.parameter_aliases || {};
244
+ for (const [name, param] of Object.entries(props)) {
245
+ if (name === tool.cli.primary_arg)
246
+ continue;
247
+ const isRequired = required.includes(name);
248
+ const paramType = Array.isArray(param.type) ? param.type[0] : param.type;
249
+ const shortAlias = aliases[name];
250
+ const shortPrefix = shortAlias ? `-${shortAlias}, ` : "";
251
+ if (paramType === "array") {
252
+ const flag = `${shortPrefix}--${name} <values...>`;
253
+ if (isRequired) {
254
+ cmd.requiredOption(flag, param.description || name);
255
+ }
256
+ else {
257
+ cmd.option(flag, param.description || name);
258
+ }
259
+ }
260
+ else if (paramType === "boolean") {
261
+ cmd.option(`${shortPrefix}--${name}`, param.description || name);
262
+ }
263
+ else {
264
+ const flag = `${shortPrefix}--${name} <value>`;
265
+ if (isRequired) {
266
+ cmd.requiredOption(flag, param.description || name);
267
+ }
268
+ else {
269
+ cmd.option(flag, param.description || name);
270
+ }
271
+ }
272
+ }
273
+ // Add -o/--output-file option for tools that produce downloadable files
274
+ const outputFileKeys = tool.cli.output_file_keys || [];
275
+ if (outputFileKeys.length > 0) {
276
+ cmd.option("-o, --output-file <path>", "Download the generated file to a local path");
277
+ }
278
+ // Generic action handler
279
+ cmd.action(async (primaryArgValue, opts) => {
280
+ // Commander passes opts as second arg when there's an argument,
281
+ // or as first arg when there's no argument
282
+ if (typeof primaryArgValue === "object" && primaryArgValue !== null) {
283
+ opts = primaryArgValue;
284
+ primaryArgValue = undefined;
285
+ }
286
+ try {
287
+ const client = clientFactory();
288
+ // Extract and remove client-side-only options before sending to API
289
+ const outputFilePath = opts.outputFile;
290
+ delete opts.outputFile;
291
+ const args = { ...opts };
292
+ // Set primary arg
293
+ if (tool.cli.primary_arg && primaryArgValue !== undefined) {
294
+ args[tool.cli.primary_arg] = primaryArgValue;
295
+ }
296
+ // Coerce numeric strings to numbers based on schema
297
+ for (const [name, param] of Object.entries(props)) {
298
+ if (args[name] !== undefined) {
299
+ const paramType = Array.isArray(param.type)
300
+ ? param.type[0]
301
+ : param.type;
302
+ if (paramType === "integer" || paramType === "number") {
303
+ const num = Number(args[name]);
304
+ if (!isNaN(num)) {
305
+ args[name] = paramType === "integer" ? Math.floor(num) : num;
306
+ }
307
+ }
308
+ }
309
+ }
310
+ // Resolve local file paths to uploaded URLs
311
+ const resolvedArgs = await resolveLocalFiles(args, client);
312
+ const result = await client.executeTool(tool.name, resolvedArgs);
313
+ // If -o was specified and tool succeeded, download the output file
314
+ if (outputFilePath &&
315
+ outputFileKeys.length > 0 &&
316
+ result.status === "ok" &&
317
+ result.data &&
318
+ typeof result.data === "object") {
319
+ const fileUrl = extractFileUrl(result.data, outputFileKeys);
320
+ if (fileUrl) {
321
+ const localPath = await downloadToFile(fileUrl, outputFilePath, client);
322
+ result.data.local_path = localPath;
323
+ }
324
+ else {
325
+ info("Warning: Could not find a file URL in the result to download");
326
+ }
327
+ }
328
+ output(result);
329
+ }
330
+ catch (err) {
331
+ logError(err.message);
332
+ process.exit(1);
333
+ }
334
+ });
335
+ }
336
+ // ============================================
337
+ // Built-in Commands
338
+ // ============================================
339
+ // List tools
340
+ program
341
+ .command("list-tools")
342
+ .alias("ls")
343
+ .description("List all available tools")
344
+ .action(async () => {
345
+ try {
346
+ const client = createClient();
347
+ const result = await client.listTools();
348
+ output(result);
349
+ }
350
+ catch (err) {
351
+ logError(err.message);
352
+ process.exit(1);
353
+ }
354
+ });
355
+ // Upload file - get upload URL, upload file, return file wrapper URL
356
+ program
357
+ .command("upload")
358
+ .description("Upload a local file and get a file wrapper URL")
359
+ .argument("<file>", "Local file path to upload")
360
+ .action(async (filePath) => {
361
+ try {
362
+ if (!fs.existsSync(filePath)) {
363
+ logError(`File not found: ${filePath}`);
364
+ process.exit(1);
365
+ }
366
+ const client = createClient();
367
+ const file_wrapper_url = await uploadLocalFile(filePath, client);
368
+ const fileName = pathModule.basename(filePath);
369
+ const ext = pathModule.extname(filePath).toLowerCase();
370
+ const contentType = CONTENT_TYPE_MAP[ext] || "application/octet-stream";
371
+ const stats = fs.statSync(filePath);
372
+ output({
373
+ status: "ok",
374
+ message: "File uploaded successfully",
375
+ data: {
376
+ file_wrapper_url,
377
+ file_name: fileName,
378
+ content_type: contentType,
379
+ size_bytes: stats.size,
380
+ },
381
+ });
382
+ }
383
+ catch (err) {
384
+ logError(err.message);
385
+ process.exit(1);
386
+ }
387
+ });
388
+ // Download file - get download URL from file wrapper URL
389
+ program
390
+ .command("download")
391
+ .description("Get a download URL for a file wrapper URL")
392
+ .argument("<file_wrapper_url>", "File wrapper URL (e.g., /api/files/s/xxxxx)")
393
+ .option("-s, --save <path>", "Download and save to local file path")
394
+ .action(async (fileWrapperUrl, opts) => {
395
+ try {
396
+ const client = createClient();
397
+ const result = await client.getDownloadUrl({
398
+ file_wrapper_url: fileWrapperUrl,
399
+ });
400
+ if (result.status !== "ok" || !result.data) {
401
+ logError(`Failed to get download URL: ${result.message}`);
402
+ process.exit(1);
403
+ }
404
+ // If save path specified, download using the already-fetched URL
405
+ if (opts.save) {
406
+ info(`Downloading to ${opts.save}...`);
407
+ const resp = await fetch(result.data.download_url);
408
+ if (!resp.ok)
409
+ throw new Error(`Download failed: HTTP ${resp.status}`);
410
+ const buffer = Buffer.from(await resp.arrayBuffer());
411
+ fs.writeFileSync(opts.save, buffer);
412
+ const localPath = pathModule.resolve(opts.save);
413
+ info(`Downloaded ${(buffer.length / 1024).toFixed(1)} KB → ${localPath}`);
414
+ output({
415
+ status: "ok",
416
+ message: "File downloaded successfully",
417
+ data: {
418
+ ...result.data,
419
+ local_path: localPath,
420
+ size_bytes: buffer.length,
421
+ },
422
+ });
423
+ }
424
+ else {
425
+ // Just output the download URL
426
+ output(result);
427
+ }
428
+ }
429
+ catch (err) {
430
+ logError(err.message);
431
+ process.exit(1);
432
+ }
433
+ });
434
+ // Login - browser-based device flow authentication
435
+ program
436
+ .command("login")
437
+ .description("Log in to Genspark via browser to obtain an API key")
438
+ .action(async () => {
439
+ const globalOpts = getGlobalOptions();
440
+ setDebugEnabled(globalOpts.debug);
441
+ setOutputFormat(globalOpts.output);
442
+ const baseUrl = globalOpts.baseUrl;
443
+ try {
444
+ // Step 1: Request device code
445
+ info("Requesting device code...");
446
+ const deviceResp = await unauthenticatedRequest(baseUrl, "/api/cli_auth/device_code", "POST");
447
+ const { device_code, auth_url, poll_interval, expires_in } = deviceResp;
448
+ // Step 2: Open browser (use spawn to avoid shell command injection)
449
+ info("Opening browser for login...");
450
+ info(`Login URL: ${auth_url}`);
451
+ // Validate auth_url is a same-origin HTTP(S) URL before passing to spawn
452
+ try {
453
+ const parsed = new URL(auth_url);
454
+ const base = new URL(baseUrl);
455
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
456
+ throw new Error("auth_url is not http(s)");
457
+ }
458
+ if (parsed.host !== base.host) {
459
+ throw new Error("auth_url host does not match baseUrl host");
460
+ }
461
+ let cmd;
462
+ let args;
463
+ if (process.platform === "win32") {
464
+ // Avoid cmd.exe which interprets & in URLs as command separators
465
+ cmd = "rundll32";
466
+ args = ["url.dll,FileProtocolHandler", auth_url];
467
+ }
468
+ else if (process.platform === "darwin") {
469
+ cmd = "open";
470
+ args = [auth_url];
471
+ }
472
+ else {
473
+ cmd = "xdg-open";
474
+ args = [auth_url];
475
+ }
476
+ const child = spawn(cmd, args, { stdio: "ignore", detached: true });
477
+ child.on("error", () => {
478
+ info("Could not open browser automatically.");
479
+ info("Please open the URL above manually.");
480
+ });
481
+ child.unref();
482
+ }
483
+ catch {
484
+ info("Could not open browser automatically.");
485
+ info("Please open the URL above manually.");
486
+ }
487
+ info(`Waiting for authorization (expires in ${expires_in}s, press Ctrl+C to cancel)...`);
488
+ // Step 3: Poll for token
489
+ const startTime = Date.now();
490
+ const timeoutMs = expires_in * 1000;
491
+ while (Date.now() - startTime < timeoutMs) {
492
+ await new Promise((resolve) => setTimeout(resolve, poll_interval * 1000));
493
+ const elapsedSec = Math.round((Date.now() - startTime) / 1000);
494
+ const remainingSec = expires_in - elapsedSec;
495
+ const tokenResp = await unauthenticatedRequest(baseUrl, `/api/cli_auth/token?code=${encodeURIComponent(device_code)}`, "GET");
496
+ if (tokenResp.status === "approved" && tokenResp.api_key) {
497
+ // Save to config
498
+ const config = loadConfigFile();
499
+ config.api_key = tokenResp.api_key;
500
+ saveConfigFile(config);
501
+ info("Login successful! API key saved.");
502
+ output({
503
+ status: "ok",
504
+ message: "Login successful",
505
+ data: { config_path: getConfigPath() },
506
+ });
507
+ return;
508
+ }
509
+ if (tokenResp.status === "expired") {
510
+ logError("Authorization expired. Please try again.");
511
+ process.exit(1);
512
+ }
513
+ // status === "pending" — keep polling with countdown
514
+ info(`Still waiting for authorization... (${remainingSec}s remaining)`);
515
+ }
516
+ logError("Authorization timed out. Please try again.");
517
+ process.exit(1);
518
+ }
519
+ catch (err) {
520
+ logError(err.message);
521
+ process.exit(1);
522
+ }
523
+ });
524
+ // Logout - remove API key from config
525
+ program
526
+ .command("logout")
527
+ .description("Log out by removing the saved API key")
528
+ .action(() => {
529
+ const globalOpts = getGlobalOptions();
530
+ setDebugEnabled(globalOpts.debug);
531
+ setOutputFormat(globalOpts.output);
532
+ try {
533
+ const config = loadConfigFile();
534
+ if (!config.api_key) {
535
+ info("Already logged out (no API key in config).");
536
+ return;
537
+ }
538
+ delete config.api_key;
539
+ saveConfigFile(config);
540
+ info("Logged out. API key removed.");
541
+ output({
542
+ status: "ok",
543
+ message: "Logged out",
544
+ data: { config_path: getConfigPath() },
545
+ });
546
+ }
547
+ catch (err) {
548
+ logError(err.message);
549
+ process.exit(1);
550
+ }
551
+ });
552
+ // ============================================
553
+ // Dynamic Tool Registration & Startup
554
+ // ============================================
555
+ async function main() {
556
+ // Check for updates (non-blocking — failures are silently ignored)
557
+ try {
558
+ await checkForUpdates(VERSION);
559
+ }
560
+ catch {
561
+ // Never block CLI execution due to update check failures
562
+ }
563
+ // Pre-parse global options before program.parse() so --refresh, --debug etc. work
564
+ program.parseOptions(process.argv);
565
+ const globalOpts = getGlobalOptions();
566
+ setDebugEnabled(globalOpts.debug);
567
+ setOutputFormat(globalOpts.output);
568
+ const baseUrl = globalOpts.baseUrl;
569
+ const forceRefresh = globalOpts.refresh || false;
570
+ // Try to load tools from cache
571
+ let tools = forceRefresh
572
+ ? null
573
+ : loadToolsCache(baseUrl);
574
+ if (tools) {
575
+ debug(`Loaded ${tools.length} tools from cache`);
576
+ }
577
+ else {
578
+ // Need to fetch from server
579
+ debug(forceRefresh
580
+ ? "Force refreshing tools from server..."
581
+ : "No cached tools found, fetching from server...");
582
+ // Only fetch if we have an API key
583
+ if (globalOpts.apiKey) {
584
+ try {
585
+ const client = new ApiClient(globalOpts);
586
+ const result = await client.listTools();
587
+ tools = result.tools;
588
+ saveToolsCache(baseUrl, tools);
589
+ debug(`Fetched and cached ${tools.length} tools from server`);
590
+ }
591
+ catch (err) {
592
+ debug(`Failed to fetch tools: ${err.message}`);
593
+ // Continue without dynamic commands - built-in commands still work
594
+ }
595
+ }
596
+ else {
597
+ debug("No API key available, skipping tool fetch");
598
+ }
599
+ }
600
+ // Register dynamic tool commands
601
+ if (tools) {
602
+ for (const tool of tools) {
603
+ registerToolCommand(program, tool, createClient);
604
+ }
605
+ }
606
+ // Parse and run
607
+ program.parse();
608
+ }
609
+ main().catch((err) => {
610
+ logError(err.message);
611
+ process.exit(1);
612
+ });
613
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,UAAU,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EACL,eAAe,EACf,eAAe,EACf,KAAK,EACL,IAAI,EACJ,KAAK,IAAI,QAAQ,EACjB,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,MAAM,OAAO,GAAG,OAAO,CAAC;AACxB,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,2CAA2C;AAE3E,qCAAqC;AACrC,MAAM,UAAU,GAAG,cAAc,EAA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AAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Logger utility - outputs debug/info to stderr, results to stdout
3
+ */
4
+ export declare function setDebugEnabled(enabled: boolean): void;
5
+ export declare function isDebugEnabled(): boolean;
6
+ export declare function setOutputFormat(format: "json" | "text"): void;
7
+ /**
8
+ * Log debug message to stderr (only when debug is enabled)
9
+ */
10
+ export declare function debug(message: string, ...args: unknown[]): void;
11
+ /**
12
+ * Log info message to stderr
13
+ */
14
+ export declare function info(message: string, ...args: unknown[]): void;
15
+ /**
16
+ * Log warning message to stderr
17
+ */
18
+ export declare function warn(message: string, ...args: unknown[]): void;
19
+ /**
20
+ * Log error message to stderr
21
+ */
22
+ export declare function error(message: string, ...args: unknown[]): void;
23
+ /**
24
+ * Output final result to stdout (this goes to AI agent context)
25
+ */
26
+ export declare function output(data: unknown): void;
27
+ /**
28
+ * Output raw JSON to stdout (compact, for machine consumption)
29
+ */
30
+ export declare function outputJson(data: unknown): void;
31
+ //# sourceMappingURL=logger.d.ts.map