@mutagent/cli 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,4 @@
1
- #!/usr/bin/env bun
2
- // @bun
1
+ #!/usr/bin/env node
3
2
  import { createRequire } from "node:module";
4
3
  var __create = Object.create;
5
4
  var __getProtoOf = Object.getPrototypeOf;
@@ -17,667 +16,14 @@ var __toESM = (mod, isNodeMode, target) => {
17
16
  });
18
17
  return to;
19
18
  };
20
- var __export = (target, all) => {
21
- for (var name in all)
22
- __defProp(target, name, {
23
- get: all[name],
24
- enumerable: true,
25
- configurable: true,
26
- set: (newValue) => all[name] = () => newValue
27
- });
28
- };
29
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
19
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
20
 
32
- // ../node_modules/is-inside-container/node_modules/is-docker/index.js
33
- import fs from "node:fs";
34
- function hasDockerEnv() {
35
- try {
36
- fs.statSync("/.dockerenv");
37
- return true;
38
- } catch {
39
- return false;
40
- }
41
- }
42
- function hasDockerCGroup() {
43
- try {
44
- return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
45
- } catch {
46
- return false;
47
- }
48
- }
49
- function isDocker() {
50
- if (isDockerCached === undefined) {
51
- isDockerCached = hasDockerEnv() || hasDockerCGroup();
52
- }
53
- return isDockerCached;
54
- }
55
- var isDockerCached;
56
- var init_is_docker = () => {};
57
-
58
- // ../node_modules/is-inside-container/index.js
59
- import fs2 from "node:fs";
60
- function isInsideContainer() {
61
- if (cachedResult === undefined) {
62
- cachedResult = hasContainerEnv() || isDocker();
63
- }
64
- return cachedResult;
65
- }
66
- var cachedResult, hasContainerEnv = () => {
67
- try {
68
- fs2.statSync("/run/.containerenv");
69
- return true;
70
- } catch {
71
- return false;
72
- }
73
- };
74
- var init_is_inside_container = __esm(() => {
75
- init_is_docker();
76
- });
77
-
78
- // ../node_modules/is-wsl/index.js
79
- import process2 from "node:process";
80
- import os from "node:os";
81
- import fs3 from "node:fs";
82
- var isWsl = () => {
83
- if (process2.platform !== "linux") {
84
- return false;
85
- }
86
- if (os.release().toLowerCase().includes("microsoft")) {
87
- if (isInsideContainer()) {
88
- return false;
89
- }
90
- return true;
91
- }
92
- try {
93
- return fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
94
- } catch {
95
- return false;
96
- }
97
- }, is_wsl_default;
98
- var init_is_wsl = __esm(() => {
99
- init_is_inside_container();
100
- is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
101
- });
102
-
103
- // ../node_modules/powershell-utils/index.js
104
- import process3 from "node:process";
105
- import { Buffer } from "node:buffer";
106
- import { promisify } from "node:util";
107
- import childProcess from "node:child_process";
108
- var execFile, powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {}) => {
109
- const {
110
- powerShellPath: psPath,
111
- ...execFileOptions
112
- } = options;
113
- const encodedCommand = executePowerShell.encodeCommand(command);
114
- return execFile(psPath ?? powerShellPath(), [
115
- ...executePowerShell.argumentsPrefix,
116
- encodedCommand
117
- ], {
118
- encoding: "utf8",
119
- ...execFileOptions
120
- });
121
- };
122
- var init_powershell_utils = __esm(() => {
123
- execFile = promisify(childProcess.execFile);
124
- executePowerShell.argumentsPrefix = [
125
- "-NoProfile",
126
- "-NonInteractive",
127
- "-ExecutionPolicy",
128
- "Bypass",
129
- "-EncodedCommand"
130
- ];
131
- executePowerShell.encodeCommand = (command) => Buffer.from(command, "utf16le").toString("base64");
132
- executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
133
- });
134
-
135
- // ../node_modules/wsl-utils/utilities.js
136
- function parseMountPointFromConfig(content) {
137
- for (const line of content.split(`
138
- `)) {
139
- if (/^\s*#/.test(line)) {
140
- continue;
141
- }
142
- const match2 = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
143
- if (!match2) {
144
- continue;
145
- }
146
- return match2.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
147
- }
148
- }
149
-
150
- // ../node_modules/wsl-utils/index.js
151
- import { promisify as promisify2 } from "node:util";
152
- import childProcess2 from "node:child_process";
153
- import fs4, { constants as fsConstants } from "node:fs/promises";
154
- var execFile2, wslDrivesMountPoint, powerShellPathFromWsl = async () => {
155
- const mountPoint = await wslDrivesMountPoint();
156
- return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
157
- }, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell = async () => {
158
- canAccessPowerShellPromise ??= (async () => {
159
- try {
160
- const psPath = await powerShellPath2();
161
- await fs4.access(psPath, fsConstants.X_OK);
162
- return true;
163
- } catch {
164
- return false;
165
- }
166
- })();
167
- return canAccessPowerShellPromise;
168
- }, wslDefaultBrowser = async () => {
169
- const psPath = await powerShellPath2();
170
- const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
171
- const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
172
- return stdout.trim();
173
- }, convertWslPathToWindows = async (path) => {
174
- if (/^[a-z]+:\/\//i.test(path)) {
175
- return path;
176
- }
177
- try {
178
- const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
179
- return stdout.trim();
180
- } catch {
181
- return path;
182
- }
183
- };
184
- var init_wsl_utils = __esm(() => {
185
- init_is_wsl();
186
- init_powershell_utils();
187
- init_is_wsl();
188
- execFile2 = promisify2(childProcess2.execFile);
189
- wslDrivesMountPoint = (() => {
190
- const defaultMountPoint = "/mnt/";
191
- let mountPoint;
192
- return async function() {
193
- if (mountPoint) {
194
- return mountPoint;
195
- }
196
- const configFilePath = "/etc/wsl.conf";
197
- let isConfigFileExists = false;
198
- try {
199
- await fs4.access(configFilePath, fsConstants.F_OK);
200
- isConfigFileExists = true;
201
- } catch {}
202
- if (!isConfigFileExists) {
203
- return defaultMountPoint;
204
- }
205
- const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
206
- const parsedMountPoint = parseMountPointFromConfig(configContent);
207
- if (parsedMountPoint === undefined) {
208
- return defaultMountPoint;
209
- }
210
- mountPoint = parsedMountPoint;
211
- mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
212
- return mountPoint;
213
- };
214
- })();
215
- powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
216
- });
217
-
218
- // ../node_modules/define-lazy-prop/index.js
219
- function defineLazyProperty(object197, propertyName, valueGetter) {
220
- const define = (value) => Object.defineProperty(object197, propertyName, { value, enumerable: true, writable: true });
221
- Object.defineProperty(object197, propertyName, {
222
- configurable: true,
223
- enumerable: true,
224
- get() {
225
- const result = valueGetter();
226
- define(result);
227
- return result;
228
- },
229
- set(value) {
230
- define(value);
231
- }
232
- });
233
- return object197;
234
- }
235
-
236
- // ../node_modules/default-browser-id/index.js
237
- import { promisify as promisify3 } from "node:util";
238
- import process4 from "node:process";
239
- import { execFile as execFile3 } from "node:child_process";
240
- async function defaultBrowserId() {
241
- if (process4.platform !== "darwin") {
242
- throw new Error("macOS only");
243
- }
244
- const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
245
- const match2 = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
246
- return match2?.groups.id ?? "com.apple.Safari";
247
- }
248
- var execFileAsync;
249
- var init_default_browser_id = __esm(() => {
250
- execFileAsync = promisify3(execFile3);
251
- });
252
-
253
- // ../node_modules/run-applescript/index.js
254
- import process5 from "node:process";
255
- import { promisify as promisify4 } from "node:util";
256
- import { execFile as execFile4, execFileSync } from "node:child_process";
257
- async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
258
- if (process5.platform !== "darwin") {
259
- throw new Error("macOS only");
260
- }
261
- const outputArguments = humanReadableOutput ? [] : ["-ss"];
262
- const execOptions = {};
263
- if (signal) {
264
- execOptions.signal = signal;
265
- }
266
- const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
267
- return stdout.trim();
268
- }
269
- var execFileAsync2;
270
- var init_run_applescript = __esm(() => {
271
- execFileAsync2 = promisify4(execFile4);
272
- });
273
-
274
- // ../node_modules/bundle-name/index.js
275
- async function bundleName(bundleId) {
276
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
277
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
278
- }
279
- var init_bundle_name = __esm(() => {
280
- init_run_applescript();
281
- });
282
-
283
- // ../node_modules/default-browser/windows.js
284
- import { promisify as promisify5 } from "node:util";
285
- import { execFile as execFile5 } from "node:child_process";
286
- async function defaultBrowser(_execFileAsync = execFileAsync3) {
287
- const { stdout } = await _execFileAsync("reg", [
288
- "QUERY",
289
- " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
290
- "/v",
291
- "ProgId"
292
- ]);
293
- const match2 = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
294
- if (!match2) {
295
- throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
296
- }
297
- const { id } = match2.groups;
298
- const dotIndex = id.lastIndexOf(".");
299
- const hyphenIndex = id.lastIndexOf("-");
300
- const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
301
- const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
302
- return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
303
- }
304
- var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
305
- var init_windows = __esm(() => {
306
- execFileAsync3 = promisify5(execFile5);
307
- windowsBrowserProgIds = {
308
- MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
309
- MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
310
- MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
311
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
312
- ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
313
- ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
314
- ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
315
- ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
316
- BraveHTML: { name: "Brave", id: "com.brave.Browser" },
317
- BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
318
- BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
319
- BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
320
- FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
321
- OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
322
- VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
323
- "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
324
- };
325
- _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
326
- UnknownBrowserError = class UnknownBrowserError extends Error {
327
- };
328
- });
329
-
330
- // ../node_modules/default-browser/index.js
331
- import { promisify as promisify6 } from "node:util";
332
- import process6 from "node:process";
333
- import { execFile as execFile6 } from "node:child_process";
334
- async function defaultBrowser2() {
335
- if (process6.platform === "darwin") {
336
- const id = await defaultBrowserId();
337
- const name = await bundleName(id);
338
- return { name, id };
339
- }
340
- if (process6.platform === "linux") {
341
- const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
342
- const id = stdout.trim();
343
- const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
344
- return { name, id };
345
- }
346
- if (process6.platform === "win32") {
347
- return defaultBrowser();
348
- }
349
- throw new Error("Only macOS, Linux, and Windows are supported");
350
- }
351
- var execFileAsync4, titleize = (string99) => string99.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
352
- var init_default_browser = __esm(() => {
353
- init_default_browser_id();
354
- init_bundle_name();
355
- init_windows();
356
- init_windows();
357
- execFileAsync4 = promisify6(execFile6);
358
- });
359
-
360
- // ../node_modules/is-in-ssh/index.js
361
- import process7 from "node:process";
362
- var isInSsh, is_in_ssh_default;
363
- var init_is_in_ssh = __esm(() => {
364
- isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY);
365
- is_in_ssh_default = isInSsh;
366
- });
367
-
368
- // ../node_modules/open/index.js
369
- var exports_open = {};
370
- __export(exports_open, {
371
- openApp: () => openApp,
372
- default: () => open_default,
373
- apps: () => apps
374
- });
375
- import process8 from "node:process";
376
- import path from "node:path";
377
- import { fileURLToPath } from "node:url";
378
- import childProcess3 from "node:child_process";
379
- import fs5, { constants as fsConstants2 } from "node:fs/promises";
380
- function detectArchBinary(binary) {
381
- if (typeof binary === "string" || Array.isArray(binary)) {
382
- return binary;
383
- }
384
- const { [arch]: archBinary } = binary;
385
- if (!archBinary) {
386
- throw new Error(`${arch} is not supported`);
387
- }
388
- return archBinary;
389
- }
390
- function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
391
- if (wsl && is_wsl_default) {
392
- return detectArchBinary(wsl);
393
- }
394
- if (!platformBinary) {
395
- throw new Error(`${platform} is not supported`);
396
- }
397
- return detectArchBinary(platformBinary);
398
- }
399
- var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEachApp = async (apps, opener) => {
400
- if (apps.length === 0) {
401
- return;
402
- }
403
- const errors = [];
404
- for (const app of apps) {
405
- try {
406
- return await opener(app);
407
- } catch (error) {
408
- errors.push(error);
409
- }
410
- }
411
- throw new AggregateError(errors, "Failed to open in all supported apps");
412
- }, baseOpen = async (options) => {
413
- options = {
414
- wait: false,
415
- background: false,
416
- newInstance: false,
417
- allowNonzeroExitCode: false,
418
- ...options
419
- };
420
- const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
421
- delete options[fallbackAttemptSymbol];
422
- if (Array.isArray(options.app)) {
423
- return tryEachApp(options.app, (singleApp) => baseOpen({
424
- ...options,
425
- app: singleApp,
426
- [fallbackAttemptSymbol]: true
427
- }));
428
- }
429
- let { name: app, arguments: appArguments = [] } = options.app ?? {};
430
- appArguments = [...appArguments];
431
- if (Array.isArray(app)) {
432
- return tryEachApp(app, (appName) => baseOpen({
433
- ...options,
434
- app: {
435
- name: appName,
436
- arguments: appArguments
437
- },
438
- [fallbackAttemptSymbol]: true
439
- }));
440
- }
441
- if (app === "browser" || app === "browserPrivate") {
442
- const ids = {
443
- "com.google.chrome": "chrome",
444
- "google-chrome.desktop": "chrome",
445
- "com.brave.browser": "brave",
446
- "org.mozilla.firefox": "firefox",
447
- "firefox.desktop": "firefox",
448
- "com.microsoft.msedge": "edge",
449
- "com.microsoft.edge": "edge",
450
- "com.microsoft.edgemac": "edge",
451
- "microsoft-edge.desktop": "edge",
452
- "com.apple.safari": "safari"
453
- };
454
- const flags = {
455
- chrome: "--incognito",
456
- brave: "--incognito",
457
- firefox: "--private-window",
458
- edge: "--inPrivate"
459
- };
460
- let browser;
461
- if (is_wsl_default) {
462
- const progId = await wslDefaultBrowser();
463
- const browserInfo = _windowsBrowserProgIdMap.get(progId);
464
- browser = browserInfo ?? {};
465
- } else {
466
- browser = await defaultBrowser2();
467
- }
468
- if (browser.id in ids) {
469
- const browserName = ids[browser.id.toLowerCase()];
470
- if (app === "browserPrivate") {
471
- if (browserName === "safari") {
472
- throw new Error("Safari doesn't support opening in private mode via command line");
473
- }
474
- appArguments.push(flags[browserName]);
475
- }
476
- return baseOpen({
477
- ...options,
478
- app: {
479
- name: apps[browserName],
480
- arguments: appArguments
481
- }
482
- });
483
- }
484
- throw new Error(`${browser.name} is not supported as a default browser`);
485
- }
486
- let command;
487
- const cliArguments = [];
488
- const childProcessOptions = {};
489
- let shouldUseWindowsInWsl = false;
490
- if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
491
- shouldUseWindowsInWsl = await canAccessPowerShell();
492
- }
493
- if (platform === "darwin") {
494
- command = "open";
495
- if (options.wait) {
496
- cliArguments.push("--wait-apps");
497
- }
498
- if (options.background) {
499
- cliArguments.push("--background");
500
- }
501
- if (options.newInstance) {
502
- cliArguments.push("--new");
503
- }
504
- if (app) {
505
- cliArguments.push("-a", app);
506
- }
507
- } else if (platform === "win32" || shouldUseWindowsInWsl) {
508
- command = await powerShellPath2();
509
- cliArguments.push(...executePowerShell.argumentsPrefix);
510
- if (!is_wsl_default) {
511
- childProcessOptions.windowsVerbatimArguments = true;
512
- }
513
- if (is_wsl_default && options.target) {
514
- options.target = await convertWslPathToWindows(options.target);
515
- }
516
- const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
517
- if (options.wait) {
518
- encodedArguments.push("-Wait");
519
- }
520
- if (app) {
521
- encodedArguments.push(executePowerShell.escapeArgument(app));
522
- if (options.target) {
523
- appArguments.push(options.target);
524
- }
525
- } else if (options.target) {
526
- encodedArguments.push(executePowerShell.escapeArgument(options.target));
527
- }
528
- if (appArguments.length > 0) {
529
- appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
530
- encodedArguments.push("-ArgumentList", appArguments.join(","));
531
- }
532
- options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
533
- if (!options.wait) {
534
- childProcessOptions.stdio = "ignore";
535
- }
536
- } else {
537
- if (app) {
538
- command = app;
539
- } else {
540
- const isBundled = !__dirname2 || __dirname2 === "/";
541
- let exeLocalXdgOpen = false;
542
- try {
543
- await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
544
- exeLocalXdgOpen = true;
545
- } catch {}
546
- const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
547
- command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
548
- }
549
- if (appArguments.length > 0) {
550
- cliArguments.push(...appArguments);
551
- }
552
- if (!options.wait) {
553
- childProcessOptions.stdio = "ignore";
554
- childProcessOptions.detached = true;
555
- }
556
- }
557
- if (platform === "darwin" && appArguments.length > 0) {
558
- cliArguments.push("--args", ...appArguments);
559
- }
560
- if (options.target) {
561
- cliArguments.push(options.target);
562
- }
563
- const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
564
- if (options.wait) {
565
- return new Promise((resolve, reject) => {
566
- subprocess.once("error", reject);
567
- subprocess.once("close", (exitCode) => {
568
- if (!options.allowNonzeroExitCode && exitCode !== 0) {
569
- reject(new Error(`Exited with code ${exitCode}`));
570
- return;
571
- }
572
- resolve(subprocess);
573
- });
574
- });
575
- }
576
- if (isFallbackAttempt) {
577
- return new Promise((resolve, reject) => {
578
- subprocess.once("error", reject);
579
- subprocess.once("spawn", () => {
580
- subprocess.once("close", (exitCode) => {
581
- subprocess.off("error", reject);
582
- if (exitCode !== 0) {
583
- reject(new Error(`Exited with code ${exitCode}`));
584
- return;
585
- }
586
- subprocess.unref();
587
- resolve(subprocess);
588
- });
589
- });
590
- });
591
- }
592
- subprocess.unref();
593
- return new Promise((resolve, reject) => {
594
- subprocess.once("error", reject);
595
- subprocess.once("spawn", () => {
596
- subprocess.off("error", reject);
597
- resolve(subprocess);
598
- });
599
- });
600
- }, open = (target, options) => {
601
- if (typeof target !== "string") {
602
- throw new TypeError("Expected a `target`");
603
- }
604
- return baseOpen({
605
- ...options,
606
- target
607
- });
608
- }, openApp = (name, options) => {
609
- if (typeof name !== "string" && !Array.isArray(name)) {
610
- throw new TypeError("Expected a valid `name`");
611
- }
612
- const { arguments: appArguments = [] } = options ?? {};
613
- if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {
614
- throw new TypeError("Expected `appArguments` as Array type");
615
- }
616
- return baseOpen({
617
- ...options,
618
- app: {
619
- name,
620
- arguments: appArguments
621
- }
622
- });
623
- }, apps, open_default;
624
- var init_open = __esm(() => {
625
- init_wsl_utils();
626
- init_powershell_utils();
627
- init_default_browser();
628
- init_is_inside_container();
629
- init_is_in_ssh();
630
- fallbackAttemptSymbol = Symbol("fallbackAttempt");
631
- __dirname2 = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
632
- localXdgOpenPath = path.join(__dirname2, "xdg-open");
633
- ({ platform, arch } = process8);
634
- apps = {
635
- browser: "browser",
636
- browserPrivate: "browserPrivate"
637
- };
638
- defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
639
- darwin: "google chrome",
640
- win32: "chrome",
641
- linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
642
- }, {
643
- wsl: {
644
- ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
645
- x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
646
- }
647
- }));
648
- defineLazyProperty(apps, "brave", () => detectPlatformBinary({
649
- darwin: "brave browser",
650
- win32: "brave",
651
- linux: ["brave-browser", "brave"]
652
- }, {
653
- wsl: {
654
- ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
655
- x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
656
- }
657
- }));
658
- defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
659
- darwin: "firefox",
660
- win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
661
- linux: "firefox"
662
- }, {
663
- wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
664
- }));
665
- defineLazyProperty(apps, "edge", () => detectPlatformBinary({
666
- darwin: "microsoft edge",
667
- win32: "msedge",
668
- linux: ["microsoft-edge", "microsoft-edge-dev"]
669
- }, {
670
- wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
671
- }));
672
- defineLazyProperty(apps, "safari", () => detectPlatformBinary({
673
- darwin: "Safari"
674
- }));
675
- open_default = open;
676
- });
677
-
678
21
  // src/bin/cli.ts
679
22
  import { Command as Command11 } from "commander";
680
23
  import chalk12 from "chalk";
24
+ import { readFileSync as readFileSync11 } from "fs";
25
+ import { join as join2, dirname } from "path";
26
+ import { fileURLToPath } from "url";
681
27
 
682
28
  // src/commands/auth.ts
683
29
  import { Command } from "commander";
@@ -693,7 +39,7 @@ import { join } from "path";
693
39
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
694
40
  var configSchema = z.object({
695
41
  apiKey: z.string().optional(),
696
- endpoint: z.string().default("https://api.mutagent.io/v1"),
42
+ endpoint: z.string().default("https://api.mutagent.io"),
697
43
  format: z.enum(["table", "json"]).default("table"),
698
44
  timeout: z.number().default(30000),
699
45
  defaultWorkspace: z.string().optional(),
@@ -760,7 +106,7 @@ function saveFullCredentials(creds) {
760
106
  const credentials = {
761
107
  ...existingCredentials,
762
108
  apiKey: creds.apiKey,
763
- endpoint: creds.endpoint ?? existingCredentials.endpoint ?? "https://api.mutagent.io/v1",
109
+ endpoint: creds.endpoint ?? existingCredentials.endpoint ?? "https://api.mutagent.io",
764
110
  defaultWorkspace: creds.workspaceId ?? existingCredentials.defaultWorkspace,
765
111
  defaultOrganization: creds.organizationId ?? existingCredentials.defaultOrganization,
766
112
  expiresAt: creds.expiresAt
@@ -854,11 +200,10 @@ function serverURLFromOptions(options) {
854
200
  var SDK_METADATA = {
855
201
  language: "typescript",
856
202
  openapiDocVersion: "2.0.0",
857
- sdkVersion: "0.2.13",
858
- genVersion: "2.811.4",
859
- userAgent: "speakeasy-sdk/typescript 0.2.13 2.811.4 2.0.0 @mutagent/sdk"
203
+ sdkVersion: "0.2.21",
204
+ genVersion: "2.812.2",
205
+ userAgent: "speakeasy-sdk/typescript 0.2.21 2.812.2 2.0.0 @mutagent/sdk"
860
206
  };
861
-
862
207
  // ../mutagent-sdk/dist/esm/lib/http.js
863
208
  var DEFAULT_FETCHER = (input, init) => {
864
209
  if (init == null) {
@@ -1023,7 +368,6 @@ function isAbortError(err) {
1023
368
  const isGenericErr = "code" in err && typeof err.code === "string" && err.code.toLowerCase() === "econnaborted";
1024
369
  return isNative || isLegacyNative || isGenericErr;
1025
370
  }
1026
-
1027
371
  // ../mutagent-sdk/dist/esm/hooks/registration.js
1028
372
  function initHooks(hooks) {}
1029
373
 
@@ -13931,7 +13275,6 @@ class Mutagent extends ClientSDK {
13931
13275
  return this._traces ?? (this._traces = new Traces(this._options));
13932
13276
  }
13933
13277
  }
13934
-
13935
13278
  // src/lib/errors.ts
13936
13279
  class MutagentError2 extends Error {
13937
13280
  code;
@@ -13997,14 +13340,27 @@ class SDKClientWrapper {
13997
13340
  sdk;
13998
13341
  apiKey;
13999
13342
  endpoint;
13343
+ workspaceId;
13344
+ organizationId;
14000
13345
  constructor(opts) {
14001
13346
  this.apiKey = opts.bearerAuth;
14002
13347
  this.endpoint = opts.serverURL ?? "http://localhost:3003";
13348
+ this.workspaceId = opts.workspaceId;
13349
+ this.organizationId = opts.organizationId;
13350
+ const httpClient = new HTTPClient;
13351
+ httpClient.addHook("beforeRequest", (req) => {
13352
+ if (this.workspaceId)
13353
+ req.headers.set("x-workspace-id", this.workspaceId);
13354
+ if (this.organizationId)
13355
+ req.headers.set("x-organization-id", this.organizationId);
13356
+ return req;
13357
+ });
14003
13358
  this.sdk = new Mutagent({
14004
13359
  security: {
14005
13360
  apiKey: this.apiKey
14006
13361
  },
14007
- serverURL: this.endpoint
13362
+ serverURL: this.endpoint,
13363
+ httpClient
14008
13364
  });
14009
13365
  }
14010
13366
  handleError(error) {
@@ -14029,11 +13385,17 @@ class SDKClientWrapper {
14029
13385
  } else if (optHeaders) {
14030
13386
  extraHeaders = optHeaders;
14031
13387
  }
13388
+ const tenancyHeaders = {};
13389
+ if (this.workspaceId)
13390
+ tenancyHeaders["x-workspace-id"] = this.workspaceId;
13391
+ if (this.organizationId)
13392
+ tenancyHeaders["x-organization-id"] = this.organizationId;
14032
13393
  const response = await fetch(`${this.endpoint}${path}`, {
14033
13394
  ...options,
14034
13395
  headers: {
14035
- Authorization: `Bearer ${this.apiKey}`,
13396
+ "x-api-key": this.apiKey,
14036
13397
  "Content-Type": "application/json",
13398
+ ...tenancyHeaders,
14037
13399
  ...extraHeaders
14038
13400
  }
14039
13401
  });
@@ -14112,7 +13474,7 @@ class SDKClientWrapper {
14112
13474
  async listDatasets(promptId) {
14113
13475
  try {
14114
13476
  const response = await this.request(`/api/prompt/${promptId}/datasets`);
14115
- return response.data;
13477
+ return Array.isArray(response) ? response : response.data;
14116
13478
  } catch (error) {
14117
13479
  this.handleError(error);
14118
13480
  }
@@ -14197,7 +13559,8 @@ class SDKClientWrapper {
14197
13559
  }
14198
13560
  async listTraces(filters) {
14199
13561
  const params = filters ? new URLSearchParams(filters).toString() : "";
14200
- return this.request(`/api/traces${params ? `?${params}` : ""}`);
13562
+ const response = await this.request(`/api/traces${params ? `?${params}` : ""}`);
13563
+ return response.data ?? [];
14201
13564
  }
14202
13565
  async getTrace(id) {
14203
13566
  return this.request(`/api/traces/${id}`);
@@ -14379,7 +13742,7 @@ class SDKClientWrapper {
14379
13742
  const response = await fetch(`${this.endpoint}/api/prompt/${promptId}/execute/stream`, {
14380
13743
  method: "POST",
14381
13744
  headers: {
14382
- Authorization: `Bearer ${this.apiKey}`,
13745
+ "x-api-key": this.apiKey,
14383
13746
  "Content-Type": "application/json",
14384
13747
  Accept: "text/event-stream"
14385
13748
  },
@@ -14439,20 +13802,25 @@ function getSDKClient() {
14439
13802
  if (!apiKey) {
14440
13803
  throw new AuthenticationError;
14441
13804
  }
14442
- const config = loadConfig();
13805
+ const config2 = loadConfig();
14443
13806
  sdkClient = new SDKClientWrapper({
14444
13807
  bearerAuth: apiKey,
14445
- serverURL: config.endpoint
13808
+ serverURL: config2.endpoint,
13809
+ workspaceId: config2.defaultWorkspace,
13810
+ organizationId: config2.defaultOrganization
14446
13811
  });
14447
13812
  }
14448
13813
  return sdkClient;
14449
13814
  }
14450
- function validateApiKey(apiKey, endpoint) {
14451
- const client = new SDKClientWrapper({
14452
- bearerAuth: apiKey,
14453
- serverURL: endpoint
14454
- });
14455
- return client.listPrompts().then(() => true).catch(() => false);
13815
+ async function validateApiKey(apiKey, endpoint) {
13816
+ try {
13817
+ const response = await fetch(`${endpoint}/api/organizations`, {
13818
+ headers: { "x-api-key": apiKey }
13819
+ });
13820
+ return response.ok;
13821
+ } catch {
13822
+ return false;
13823
+ }
14456
13824
  }
14457
13825
 
14458
13826
  // src/lib/output.ts
@@ -14577,7 +13945,7 @@ ${String(data.length)} result(s)`));
14577
13945
  }
14578
13946
 
14579
13947
  // src/lib/browser-auth.ts
14580
- import { hostname, platform as platform2 } from "os";
13948
+ import { hostname, platform } from "os";
14581
13949
  function generateCliToken() {
14582
13950
  return crypto.randomUUID();
14583
13951
  }
@@ -14588,7 +13956,7 @@ async function initBrowserAuth(endpoint, cliToken) {
14588
13956
  body: JSON.stringify({
14589
13957
  cliToken,
14590
13958
  hostname: hostname(),
14591
- platform: platform2()
13959
+ platform: platform()
14592
13960
  })
14593
13961
  });
14594
13962
  if (!response.ok) {
@@ -14613,8 +13981,8 @@ async function openBrowser(url) {
14613
13981
  return;
14614
13982
  }
14615
13983
  try {
14616
- const { default: open2 } = await Promise.resolve().then(() => (init_open(), exports_open));
14617
- await open2(url);
13984
+ const { default: open } = await import("open");
13985
+ await open(url);
14618
13986
  } catch {
14619
13987
  throw new BrowserAuthError("BROWSER_OPEN_FAILED", `Could not open browser automatically. Please visit: ${url}`);
14620
13988
  }
@@ -14719,12 +14087,22 @@ Examples:
14719
14087
  ${chalk2.dim("$")} mutagent auth status
14720
14088
  ${chalk2.dim("$")} mutagent auth logout
14721
14089
  `);
14722
- auth.command("login").description("Authenticate and store API key").option("--api-key <key>", "API key (non-interactive)").option("--browser", "Force browser-based authentication").option("--endpoint <url>", "API endpoint", "https://api.mutagent.io/v1").action(async (options) => {
14090
+ auth.command("login").description("Authenticate and store API key").option("--api-key <key>", "API key (non-interactive)").option("--browser", "Force browser-based authentication").option("--endpoint <url>", "API endpoint", "https://api.mutagent.io").addHelpText("after", `
14091
+ Examples:
14092
+ ${chalk2.dim("$")} mutagent auth login ${chalk2.dim("# Interactive (choose method)")}
14093
+ ${chalk2.dim("$")} mutagent auth login --browser ${chalk2.dim("# Browser OAuth flow")}
14094
+ ${chalk2.dim("$")} mutagent auth login --api-key mg_live_xxx ${chalk2.dim("# Direct API key (CI/CD)")}
14095
+
14096
+ Environment Variables:
14097
+ MUTAGENT_API_KEY API key (skips login entirely)
14098
+ MUTAGENT_ENDPOINT Custom API endpoint
14099
+ CI=true Enables non-interactive mode
14100
+ `).action(async (options) => {
14723
14101
  const isJson = getJsonFlag(auth);
14724
14102
  const output = new OutputFormatter(isJson ? "json" : "table");
14725
14103
  try {
14726
- let apiKey = options.apiKey;
14727
- let endpoint = options.endpoint;
14104
+ let apiKey = options.apiKey ?? process.env.MUTAGENT_API_KEY;
14105
+ let endpoint = process.env.MUTAGENT_ENDPOINT ?? options.endpoint;
14728
14106
  let workspaceName;
14729
14107
  let organizationName;
14730
14108
  if (apiKey) {
@@ -14740,8 +14118,8 @@ Examples:
14740
14118
  }
14741
14119
  return;
14742
14120
  }
14743
- if (isJson) {
14744
- throw new MutagentError2("INTERACTIVE_REQUIRED", "Interactive login required. Use --api-key flag for non-interactive mode.", "Run without --json or provide --api-key");
14121
+ if (isJson || process.env.MUTAGENT_NON_INTERACTIVE === "true") {
14122
+ throw new MutagentError2("INTERACTIVE_REQUIRED", "Interactive login required. Use --api-key flag or set MUTAGENT_API_KEY env var.", "Run: mutagent auth login --api-key <key> or export MUTAGENT_API_KEY=<key>");
14745
14123
  }
14746
14124
  if (!hasCredentials()) {
14747
14125
  console.log(`
@@ -14842,12 +14220,16 @@ Examples:
14842
14220
  throw error;
14843
14221
  }
14844
14222
  });
14845
- auth.command("status").description("Check authentication status").action(async () => {
14223
+ auth.command("status").description("Check authentication status").addHelpText("after", `
14224
+ Examples:
14225
+ ${chalk2.dim("$")} mutagent auth status
14226
+ ${chalk2.dim("$")} mutagent auth status --json
14227
+ `).action(async () => {
14846
14228
  const isJson = getJsonFlag(auth);
14847
14229
  const output = new OutputFormatter(isJson ? "json" : "table");
14848
14230
  const apiKey = getApiKey();
14849
- const config = loadConfig();
14850
- const endpoint = config.endpoint ?? "https://api.mutagent.io/v1";
14231
+ const config2 = loadConfig();
14232
+ const endpoint = config2.endpoint ?? "https://api.mutagent.io";
14851
14233
  if (!apiKey) {
14852
14234
  if (isJson) {
14853
14235
  output.output({ authenticated: false, message: "Not authenticated" });
@@ -14863,19 +14245,19 @@ Examples:
14863
14245
  authenticated: isValid,
14864
14246
  endpoint,
14865
14247
  keyPrefix: `${apiKey.slice(0, 8)}...`,
14866
- defaultWorkspace: config.defaultWorkspace,
14867
- defaultOrganization: config.defaultOrganization
14248
+ defaultWorkspace: config2.defaultWorkspace,
14249
+ defaultOrganization: config2.defaultOrganization
14868
14250
  });
14869
14251
  } else {
14870
14252
  if (isValid) {
14871
14253
  output.success("Authenticated");
14872
14254
  output.info(`Endpoint: ${endpoint}`);
14873
14255
  output.info(`Key: ${apiKey.slice(0, 8)}...`);
14874
- if (config.defaultWorkspace) {
14875
- output.info(`Workspace: ${config.defaultWorkspace}`);
14256
+ if (config2.defaultWorkspace) {
14257
+ output.info(`Workspace: ${config2.defaultWorkspace}`);
14876
14258
  }
14877
- if (config.defaultOrganization) {
14878
- output.info(`Organization: ${config.defaultOrganization}`);
14259
+ if (config2.defaultOrganization) {
14260
+ output.info(`Organization: ${config2.defaultOrganization}`);
14879
14261
  }
14880
14262
  } else {
14881
14263
  output.warn("API key invalid or expired");
@@ -14883,7 +14265,10 @@ Examples:
14883
14265
  }
14884
14266
  }
14885
14267
  });
14886
- auth.command("logout").description("Clear stored credentials").action(() => {
14268
+ auth.command("logout").description("Clear stored credentials").addHelpText("after", `
14269
+ Examples:
14270
+ ${chalk2.dim("$")} mutagent auth logout
14271
+ `).action(() => {
14887
14272
  const isJson = getJsonFlag(auth);
14888
14273
  const output = new OutputFormatter(isJson ? "json" : "table");
14889
14274
  clearCredentials();
@@ -14898,7 +14283,7 @@ import inquirer2 from "inquirer";
14898
14283
  import chalk3 from "chalk";
14899
14284
  import ora2 from "ora";
14900
14285
  function createLoginCommand() {
14901
- const login = new Command2("login").description("Login to MutagenT platform").option("--api-key <key>", "API key (non-interactive)").option("--browser", "Force browser-based authentication").option("--endpoint <url>", "API endpoint", "https://api.mutagent.io/v1").addHelpText("after", `
14286
+ const login = new Command2("login").description("Login to MutagenT platform").option("--api-key <key>", "API key (non-interactive)").option("--browser", "Force browser-based authentication").option("--endpoint <url>", "API endpoint", "https://api.mutagent.io").addHelpText("after", `
14902
14287
  Examples:
14903
14288
  ${chalk3.dim("$")} mutagent login
14904
14289
  ${chalk3.dim("$")} mutagent login --browser
@@ -14907,8 +14292,8 @@ Examples:
14907
14292
  const isJson = getJsonFlag(login);
14908
14293
  const output = new OutputFormatter(isJson ? "json" : "table");
14909
14294
  try {
14910
- const apiKey = options.apiKey;
14911
- const endpoint = options.endpoint;
14295
+ const apiKey = options.apiKey ?? process.env.MUTAGENT_API_KEY;
14296
+ const endpoint = process.env.MUTAGENT_ENDPOINT ?? options.endpoint;
14912
14297
  if (apiKey) {
14913
14298
  output.info("Validating API key...");
14914
14299
  const isValid = await validateApiKey(apiKey, endpoint);
@@ -14922,8 +14307,8 @@ Examples:
14922
14307
  }
14923
14308
  return;
14924
14309
  }
14925
- if (isJson) {
14926
- throw new MutagentError2("INTERACTIVE_REQUIRED", "Interactive login required. Use --api-key flag for non-interactive mode.", "Run without --json or provide --api-key");
14310
+ if (isJson || process.env.MUTAGENT_NON_INTERACTIVE === "true") {
14311
+ throw new MutagentError2("INTERACTIVE_REQUIRED", "Interactive login required. Use --api-key flag or set MUTAGENT_API_KEY env var.", "Run: mutagent login --api-key <key> or export MUTAGENT_API_KEY=<key>");
14927
14312
  }
14928
14313
  if (!hasCredentials()) {
14929
14314
  console.log(`
@@ -15033,6 +14418,15 @@ Examples:
15033
14418
  import { Command as Command3 } from "commander";
15034
14419
  import chalk4 from "chalk";
15035
14420
  import { readFileSync as readFileSync2 } from "fs";
14421
+ var APP_URL = "https://app.mutagent.io";
14422
+ function promptLinks(promptId) {
14423
+ const id = String(promptId);
14424
+ return {
14425
+ view: `${APP_URL}/prompts/${id}`,
14426
+ datasets: `${APP_URL}/prompts/${id}/datasets`,
14427
+ evaluations: `${APP_URL}/prompts/${id}/evaluations`
14428
+ };
14429
+ }
15036
14430
  function createPromptsCommand() {
15037
14431
  const prompts = new Command3("prompts").description("Manage prompts, datasets, evaluations, and optimizations").addHelpText("after", `
15038
14432
  Examples:
@@ -15049,7 +14443,14 @@ Subcommands:
15049
14443
  evaluation list|run|results
15050
14444
  optimize start|status|results
15051
14445
  `);
15052
- prompts.command("list").description("List all prompts").option("-l, --limit <n>", "Limit results", "50").action(async (options) => {
14446
+ prompts.command("list").description("List all prompts").option("-l, --limit <n>", "Limit results", "50").addHelpText("after", `
14447
+ Examples:
14448
+ ${chalk4.dim("$")} mutagent prompts list
14449
+ ${chalk4.dim("$")} mutagent prompts list --limit 10
14450
+ ${chalk4.dim("$")} mutagent prompts list --json
14451
+
14452
+ ${chalk4.dim("Tip: Use --json for machine-readable output (AI agents, CI pipelines).")}
14453
+ `).action(async (options) => {
15053
14454
  const isJson = getJsonFlag(prompts);
15054
14455
  const output = new OutputFormatter(isJson ? "json" : "table");
15055
14456
  try {
@@ -15058,7 +14459,11 @@ Subcommands:
15058
14459
  const limit = parseInt(options.limit, 10) || 50;
15059
14460
  const limited = promptsList.slice(0, limit);
15060
14461
  if (isJson) {
15061
- output.output(limited);
14462
+ const withLinks = limited.map((p) => ({
14463
+ ...p,
14464
+ _links: promptLinks(p.id)
14465
+ }));
14466
+ output.output(withLinks);
15062
14467
  } else {
15063
14468
  const formatted = limited.map((p) => ({
15064
14469
  id: p.id,
@@ -15072,7 +14477,14 @@ Subcommands:
15072
14477
  handleError(error, isJson);
15073
14478
  }
15074
14479
  });
15075
- prompts.command("get").description("Get prompt details with nested data").argument("<id>", "Prompt ID").option("--with-datasets", "Include datasets").option("--with-evals", "Include evaluations").action(async (id, options) => {
14480
+ prompts.command("get").description("Get prompt details with nested data").argument("<id>", "Prompt ID").option("--with-datasets", "Include datasets").option("--with-evals", "Include evaluations").addHelpText("after", `
14481
+ Examples:
14482
+ ${chalk4.dim("$")} mutagent prompts get <id>
14483
+ ${chalk4.dim("$")} mutagent prompts get <id> --with-datasets --with-evals
14484
+ ${chalk4.dim("$")} mutagent prompts get <id> --json
14485
+
14486
+ ${chalk4.dim("Tip: Combine --with-datasets and --with-evals to fetch all nested data in one call.")}
14487
+ `).action(async (id, options) => {
15076
14488
  const isJson = getJsonFlag(prompts);
15077
14489
  const output = new OutputFormatter(isJson ? "json" : "table");
15078
14490
  try {
@@ -15087,12 +14499,27 @@ Subcommands:
15087
14499
  const evals = await client.listEvaluations(id);
15088
14500
  result.evaluations = evals;
15089
14501
  }
14502
+ if (isJson) {
14503
+ result._links = promptLinks(id);
14504
+ }
15090
14505
  output.output(result);
15091
14506
  } catch (error) {
15092
14507
  handleError(error, isJson);
15093
14508
  }
15094
14509
  });
15095
- prompts.command("create").description("Create a new prompt").option("-f, --file <path>", "Create from JSON file").option("-n, --name <name>", "Prompt name").option("-c, --content <content>", "Prompt content (rawPrompt) [DEPRECATED: use --raw]").option("-r, --raw <text>", "Raw prompt text (single prompt)").option("--system <text>", "System prompt (use with --human)").option("--human <text>", "Human prompt (use with --system)").option("--messages <json>", `Messages array as JSON (e.g., '[{"role":"system","content":"..."}]')`).action(async (options) => {
14510
+ prompts.command("create").description("Create a new prompt").option("-f, --file <path>", "Create from JSON file").option("-n, --name <name>", "Prompt name").option("-c, --content <content>", "Prompt content (rawPrompt) [DEPRECATED: use --raw]").option("-r, --raw <text>", "Raw prompt text (single prompt)").option("--system <text>", "System prompt (use with --human)").option("--human <text>", "Human prompt (use with --system)").option("--messages <json>", `Messages array as JSON (e.g., '[{"role":"system","content":"..."}]')`).addHelpText("after", `
14511
+ Examples:
14512
+ ${chalk4.dim("$")} mutagent prompts create --name "my-prompt" --system "You are helpful" --human "Hello"
14513
+ ${chalk4.dim("$")} mutagent prompts create --name "raw-prompt" --raw "Summarize: {{text}}"
14514
+ ${chalk4.dim("$")} mutagent prompts create --file prompt.json
14515
+ ${chalk4.dim("$")} mutagent prompts create --name "chat" --messages '[{"role":"system","content":"..."}]'
14516
+
14517
+ Prompt Input Methods (pick one):
14518
+ --system/--human Structured system + user message pair
14519
+ --raw Single raw prompt text with {{variables}}
14520
+ --messages Full messages array as JSON
14521
+ --file Load from JSON file
14522
+ `).action(async (options) => {
15096
14523
  const isJson = getJsonFlag(prompts);
15097
14524
  const output = new OutputFormatter(isJson ? "json" : "table");
15098
14525
  try {
@@ -15132,12 +14559,23 @@ Subcommands:
15132
14559
  const client = getSDKClient();
15133
14560
  const prompt = await client.createPrompt(data);
15134
14561
  output.success(`Created prompt: ${prompt.name}`);
15135
- output.output(prompt);
14562
+ if (isJson) {
14563
+ output.output({ ...prompt, _links: promptLinks(prompt.id) });
14564
+ } else {
14565
+ output.output(prompt);
14566
+ output.info(`View: ${APP_URL}/prompts/${String(prompt.id)}`);
14567
+ }
15136
14568
  } catch (error) {
15137
14569
  handleError(error, isJson);
15138
14570
  }
15139
14571
  });
15140
- prompts.command("update").description("Update a prompt").argument("<id>", "Prompt ID").option("-f, --file <path>", "Update from JSON file").option("-n, --name <name>", "New name").option("-c, --content <content>", "New content (rawPrompt) [DEPRECATED: use --raw]").option("-r, --raw <text>", "Raw prompt text (single prompt)").option("--system <text>", "System prompt (use with --human)").option("--human <text>", "Human prompt (use with --system)").option("--messages <json>", `Messages array as JSON (e.g., '[{"role":"system","content":"..."}]')`).action(async (id, options) => {
14572
+ prompts.command("update").description("Update a prompt").argument("<id>", "Prompt ID").option("-f, --file <path>", "Update from JSON file").option("-n, --name <name>", "New name").option("-c, --content <content>", "New content (rawPrompt) [DEPRECATED: use --raw]").option("-r, --raw <text>", "Raw prompt text (single prompt)").option("--system <text>", "System prompt (use with --human)").option("--human <text>", "Human prompt (use with --system)").option("--messages <json>", `Messages array as JSON (e.g., '[{"role":"system","content":"..."}]')`).addHelpText("after", `
14573
+ Examples:
14574
+ ${chalk4.dim("$")} mutagent prompts update <id> --name "new-name"
14575
+ ${chalk4.dim("$")} mutagent prompts update <id> --system "Updated system prompt"
14576
+ ${chalk4.dim("$")} mutagent prompts update <id> --file updated-prompt.json
14577
+ ${chalk4.dim("$")} mutagent prompts update <id> --json
14578
+ `).action(async (id, options) => {
15141
14579
  const isJson = getJsonFlag(prompts);
15142
14580
  const output = new OutputFormatter(isJson ? "json" : "table");
15143
14581
  try {
@@ -15182,7 +14620,14 @@ Subcommands:
15182
14620
  handleError(error, isJson);
15183
14621
  }
15184
14622
  });
15185
- prompts.command("delete").description("Delete a prompt").argument("<id>", "Prompt ID").option("--force", "Skip confirmation").action(async (id, options) => {
14623
+ prompts.command("delete").description("Delete a prompt").argument("<id>", "Prompt ID").option("--force", "Skip confirmation").addHelpText("after", `
14624
+ Examples:
14625
+ ${chalk4.dim("$")} mutagent prompts delete <id>
14626
+ ${chalk4.dim("$")} mutagent prompts delete <id> --force
14627
+ ${chalk4.dim("$")} mutagent prompts delete <id> --force --json
14628
+
14629
+ ${chalk4.dim("Tip: Use --force to skip confirmation (required for non-interactive/CI usage).")}
14630
+ `).action(async (id, options) => {
15186
14631
  const isJson = getJsonFlag(prompts);
15187
14632
  const output = new OutputFormatter(isJson ? "json" : "table");
15188
14633
  try {
@@ -15206,8 +14651,17 @@ Subcommands:
15206
14651
  handleError(error, isJson);
15207
14652
  }
15208
14653
  });
15209
- const dataset = prompts.command("dataset").description("Manage datasets for prompts");
15210
- dataset.command("list").description("List datasets for a prompt").argument("<prompt-id>", "Prompt ID").action(async (promptId) => {
14654
+ const dataset = prompts.command("dataset").description("Manage datasets for prompts").addHelpText("after", `
14655
+ Examples:
14656
+ ${chalk4.dim("$")} mutagent prompts dataset list <prompt-id>
14657
+ ${chalk4.dim("$")} mutagent prompts dataset add <prompt-id> --file dataset.jsonl
14658
+ ${chalk4.dim("$")} mutagent prompts dataset remove <prompt-id> <dataset-id>
14659
+ `);
14660
+ dataset.command("list").description("List datasets for a prompt").argument("<prompt-id>", "Prompt ID").addHelpText("after", `
14661
+ Examples:
14662
+ ${chalk4.dim("$")} mutagent prompts dataset list <prompt-id>
14663
+ ${chalk4.dim("$")} mutagent prompts dataset list <prompt-id> --json
14664
+ `).action(async (promptId) => {
15211
14665
  const isJson = getJsonFlag(prompts);
15212
14666
  const output = new OutputFormatter(isJson ? "json" : "table");
15213
14667
  try {
@@ -15218,7 +14672,13 @@ Subcommands:
15218
14672
  handleError(error, isJson);
15219
14673
  }
15220
14674
  });
15221
- dataset.command("add").description("Add dataset to a prompt").argument("<prompt-id>", "Prompt ID").requiredOption("-f, --file <path>", "Dataset file (JSONL or CSV)").action(async (promptId, options) => {
14675
+ dataset.command("add").description("Add dataset to a prompt").argument("<prompt-id>", "Prompt ID").requiredOption("-f, --file <path>", "Dataset file (JSONL or CSV)").addHelpText("after", `
14676
+ Examples:
14677
+ ${chalk4.dim("$")} mutagent prompts dataset add <prompt-id> --file dataset.jsonl
14678
+ ${chalk4.dim("$")} mutagent prompts dataset add <prompt-id> --file dataset.csv --json
14679
+
14680
+ ${chalk4.dim("Supported formats: JSONL, CSV")}
14681
+ `).action(async (promptId, options) => {
15222
14682
  const isJson = getJsonFlag(prompts);
15223
14683
  const output = new OutputFormatter(isJson ? "json" : "table");
15224
14684
  try {
@@ -15231,7 +14691,11 @@ Subcommands:
15231
14691
  handleError(error, isJson);
15232
14692
  }
15233
14693
  });
15234
- dataset.command("remove").description("Remove dataset from a prompt").argument("<prompt-id>", "Prompt ID").argument("<dataset-id>", "Dataset ID").action(async (promptId, datasetId) => {
14694
+ dataset.command("remove").description("Remove dataset from a prompt").argument("<prompt-id>", "Prompt ID").argument("<dataset-id>", "Dataset ID").addHelpText("after", `
14695
+ Examples:
14696
+ ${chalk4.dim("$")} mutagent prompts dataset remove <prompt-id> <dataset-id>
14697
+ ${chalk4.dim("$")} mutagent prompts dataset remove <prompt-id> <dataset-id> --json
14698
+ `).action(async (promptId, datasetId) => {
15235
14699
  const isJson = getJsonFlag(prompts);
15236
14700
  const output = new OutputFormatter(isJson ? "json" : "table");
15237
14701
  try {
@@ -15242,8 +14706,17 @@ Subcommands:
15242
14706
  handleError(error, isJson);
15243
14707
  }
15244
14708
  });
15245
- const evaluation = prompts.command("evaluation").description("Manage evaluations for prompts");
15246
- evaluation.command("list").description("List evaluations for a prompt").argument("<prompt-id>", "Prompt ID").action(async (promptId) => {
14709
+ const evaluation = prompts.command("evaluation").description("Manage evaluations for prompts").addHelpText("after", `
14710
+ Examples:
14711
+ ${chalk4.dim("$")} mutagent prompts evaluation list <prompt-id>
14712
+ ${chalk4.dim("$")} mutagent prompts evaluation run <prompt-id> --dataset <dataset-id>
14713
+ ${chalk4.dim("$")} mutagent prompts evaluation results <run-id>
14714
+ `);
14715
+ evaluation.command("list").description("List evaluations for a prompt").argument("<prompt-id>", "Prompt ID").addHelpText("after", `
14716
+ Examples:
14717
+ ${chalk4.dim("$")} mutagent prompts evaluation list <prompt-id>
14718
+ ${chalk4.dim("$")} mutagent prompts evaluation list <prompt-id> --json
14719
+ `).action(async (promptId) => {
15247
14720
  const isJson = getJsonFlag(prompts);
15248
14721
  const output = new OutputFormatter(isJson ? "json" : "table");
15249
14722
  try {
@@ -15254,7 +14727,13 @@ Subcommands:
15254
14727
  handleError(error, isJson);
15255
14728
  }
15256
14729
  });
15257
- evaluation.command("run").description("Run evaluation for a prompt").argument("<prompt-id>", "Prompt ID").requiredOption("-d, --dataset <id>", "Dataset ID").action(async (promptId, options) => {
14730
+ evaluation.command("run").description("Run evaluation for a prompt").argument("<prompt-id>", "Prompt ID").requiredOption("-d, --dataset <id>", "Dataset ID").addHelpText("after", `
14731
+ Examples:
14732
+ ${chalk4.dim("$")} mutagent prompts evaluation run <prompt-id> --dataset <dataset-id>
14733
+ ${chalk4.dim("$")} mutagent prompts evaluation run <prompt-id> --dataset <dataset-id> --json
14734
+
14735
+ ${chalk4.dim("Tip: Get the dataset ID from: mutagent prompts dataset list <prompt-id>")}
14736
+ `).action(async (promptId, options) => {
15258
14737
  const isJson = getJsonFlag(prompts);
15259
14738
  const output = new OutputFormatter(isJson ? "json" : "table");
15260
14739
  try {
@@ -15266,7 +14745,11 @@ Subcommands:
15266
14745
  handleError(error, isJson);
15267
14746
  }
15268
14747
  });
15269
- evaluation.command("results").description("Get evaluation results").argument("<run-id>", "Evaluation run ID").action(async (runId) => {
14748
+ evaluation.command("results").description("Get evaluation results").argument("<run-id>", "Evaluation run ID").addHelpText("after", `
14749
+ Examples:
14750
+ ${chalk4.dim("$")} mutagent prompts evaluation results <run-id>
14751
+ ${chalk4.dim("$")} mutagent prompts evaluation results <run-id> --json
14752
+ `).action(async (runId) => {
15270
14753
  const isJson = getJsonFlag(prompts);
15271
14754
  const output = new OutputFormatter(isJson ? "json" : "table");
15272
14755
  try {
@@ -15277,8 +14760,21 @@ Subcommands:
15277
14760
  handleError(error, isJson);
15278
14761
  }
15279
14762
  });
15280
- const optimize = prompts.command("optimize").description("Manage prompt optimization jobs");
15281
- optimize.command("start").description("Start prompt optimization").argument("<prompt-id>", "Prompt ID").requiredOption("-d, --dataset <id>", "Dataset ID for optimization").action(async (promptId, options) => {
14763
+ const optimize = prompts.command("optimize").description("Manage prompt optimization jobs").addHelpText("after", `
14764
+ Examples:
14765
+ ${chalk4.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id>
14766
+ ${chalk4.dim("$")} mutagent prompts optimize status <job-id>
14767
+ ${chalk4.dim("$")} mutagent prompts optimize results <job-id>
14768
+
14769
+ Workflow: start -> status (poll) -> results
14770
+ `);
14771
+ optimize.command("start").description("Start prompt optimization").argument("<prompt-id>", "Prompt ID").requiredOption("-d, --dataset <id>", "Dataset ID for optimization").addHelpText("after", `
14772
+ Examples:
14773
+ ${chalk4.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id>
14774
+ ${chalk4.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --json
14775
+
14776
+ ${chalk4.dim("Tip: Monitor progress with: mutagent prompts optimize status <job-id>")}
14777
+ `).action(async (promptId, options) => {
15282
14778
  const isJson = getJsonFlag(prompts);
15283
14779
  const output = new OutputFormatter(isJson ? "json" : "table");
15284
14780
  try {
@@ -15290,7 +14786,11 @@ Subcommands:
15290
14786
  handleError(error, isJson);
15291
14787
  }
15292
14788
  });
15293
- optimize.command("status").description("Check optimization status").argument("<job-id>", "Optimization job ID").action(async (jobId) => {
14789
+ optimize.command("status").description("Check optimization status").argument("<job-id>", "Optimization job ID").addHelpText("after", `
14790
+ Examples:
14791
+ ${chalk4.dim("$")} mutagent prompts optimize status <job-id>
14792
+ ${chalk4.dim("$")} mutagent prompts optimize status <job-id> --json
14793
+ `).action(async (jobId) => {
15294
14794
  const isJson = getJsonFlag(prompts);
15295
14795
  const output = new OutputFormatter(isJson ? "json" : "table");
15296
14796
  try {
@@ -15307,7 +14807,11 @@ Subcommands:
15307
14807
  handleError(error, isJson);
15308
14808
  }
15309
14809
  });
15310
- optimize.command("results").description("Get optimization results").argument("<job-id>", "Optimization job ID").action(async (jobId) => {
14810
+ optimize.command("results").description("Get optimization results").argument("<job-id>", "Optimization job ID").addHelpText("after", `
14811
+ Examples:
14812
+ ${chalk4.dim("$")} mutagent prompts optimize results <job-id>
14813
+ ${chalk4.dim("$")} mutagent prompts optimize results <job-id> --json
14814
+ `).action(async (jobId) => {
15311
14815
  const isJson = getJsonFlag(prompts);
15312
14816
  const output = new OutputFormatter(isJson ? "json" : "table");
15313
14817
  try {
@@ -15324,6 +14828,7 @@ Subcommands:
15324
14828
  // src/commands/traces.ts
15325
14829
  import { Command as Command4 } from "commander";
15326
14830
  import chalk5 from "chalk";
14831
+ var APP_URL2 = "https://app.mutagent.io";
15327
14832
  function createTracesCommand() {
15328
14833
  const traces = new Command4("traces").description("View and analyze traces (replaces Langfuse)").addHelpText("after", `
15329
14834
  Examples:
@@ -15335,7 +14840,14 @@ Examples:
15335
14840
 
15336
14841
  Note: MutagenT traces replace Langfuse for observability.
15337
14842
  `);
15338
- traces.command("list").description("List traces").option("-p, --prompt <id>", "Filter by prompt ID").option("-l, --limit <n>", "Limit results", "50").action(async (options) => {
14843
+ traces.command("list").description("List traces").option("-p, --prompt <id>", "Filter by prompt ID").option("-l, --limit <n>", "Limit results", "50").addHelpText("after", `
14844
+ Examples:
14845
+ ${chalk5.dim("$")} mutagent traces list
14846
+ ${chalk5.dim("$")} mutagent traces list --prompt <prompt-id>
14847
+ ${chalk5.dim("$")} mutagent traces list --limit 10 --json
14848
+
14849
+ ${chalk5.dim("Tip: Filter by prompt to see traces for a specific prompt version.")}
14850
+ `).action(async (options) => {
15339
14851
  const isJson = getJsonFlag(traces);
15340
14852
  const output = new OutputFormatter(isJson ? "json" : "table");
15341
14853
  try {
@@ -15361,18 +14873,35 @@ Note: MutagenT traces replace Langfuse for observability.
15361
14873
  handleError(error, isJson);
15362
14874
  }
15363
14875
  });
15364
- traces.command("get").description("Get trace details").argument("<id>", "Trace ID").action(async (id) => {
14876
+ traces.command("get").description("Get trace details").argument("<id>", "Trace ID").addHelpText("after", `
14877
+ Examples:
14878
+ ${chalk5.dim("$")} mutagent traces get <trace-id>
14879
+ ${chalk5.dim("$")} mutagent traces get <trace-id> --json
14880
+
14881
+ ${chalk5.dim("Returns full trace details including spans, tokens, and latency.")}
14882
+ `).action(async (id) => {
15365
14883
  const isJson = getJsonFlag(traces);
15366
14884
  const output = new OutputFormatter(isJson ? "json" : "table");
15367
14885
  try {
15368
14886
  const client = getSDKClient();
15369
14887
  const trace = await client.getTrace(id);
15370
- output.output(trace);
14888
+ if (isJson) {
14889
+ output.output({ ...trace, _links: { view: `${APP_URL2}/traces/${id}` } });
14890
+ } else {
14891
+ output.output(trace);
14892
+ output.info(`View: ${APP_URL2}/traces/${id}`);
14893
+ }
15371
14894
  } catch (error) {
15372
14895
  handleError(error, isJson);
15373
14896
  }
15374
14897
  });
15375
- traces.command("analyze").description("Analyze traces for a prompt").argument("<prompt-id>", "Prompt ID").action(async (promptId) => {
14898
+ traces.command("analyze").description("Analyze traces for a prompt").argument("<prompt-id>", "Prompt ID").addHelpText("after", `
14899
+ Examples:
14900
+ ${chalk5.dim("$")} mutagent traces analyze <prompt-id>
14901
+ ${chalk5.dim("$")} mutagent traces analyze <prompt-id> --json
14902
+
14903
+ ${chalk5.dim("Aggregates trace data for a prompt: avg latency, token usage, error rates.")}
14904
+ `).action(async (promptId) => {
15376
14905
  const isJson = getJsonFlag(traces);
15377
14906
  const output = new OutputFormatter(isJson ? "json" : "table");
15378
14907
  try {
@@ -15383,7 +14912,15 @@ Note: MutagenT traces replace Langfuse for observability.
15383
14912
  handleError(error, isJson);
15384
14913
  }
15385
14914
  });
15386
- traces.command("export").description("Export traces").option("-p, --prompt <id>", "Filter by prompt ID").option("-f, --format <format>", "Export format (json, csv)", "json").option("-o, --output <path>", "Output file path").action(async (options) => {
14915
+ traces.command("export").description("Export traces").option("-p, --prompt <id>", "Filter by prompt ID").option("-f, --format <format>", "Export format (json, csv)", "json").option("-o, --output <path>", "Output file path").addHelpText("after", `
14916
+ Examples:
14917
+ ${chalk5.dim("$")} mutagent traces export
14918
+ ${chalk5.dim("$")} mutagent traces export --format json --output traces.json
14919
+ ${chalk5.dim("$")} mutagent traces export --format csv --output traces.csv
14920
+ ${chalk5.dim("$")} mutagent traces export --prompt <prompt-id> --format json
14921
+
14922
+ ${chalk5.dim("Exports to stdout by default. Use --output to save to a file.")}
14923
+ `).action(async (options) => {
15387
14924
  const isJson = getJsonFlag(traces);
15388
14925
  const output = new OutputFormatter(isJson ? "json" : "table");
15389
14926
  try {
@@ -15431,10 +14968,10 @@ import { execSync } from "child_process";
15431
14968
 
15432
14969
  // src/lib/integrations/mastra.ts
15433
14970
  import { readFileSync as readFileSync3, existsSync as existsSync2 } from "fs";
15434
- function renderPrerequisites(config) {
15435
- const keyPreview = config.apiKey.slice(0, 8) + "..." + config.apiKey.slice(-4);
14971
+ function renderPrerequisites(config2) {
14972
+ const keyPreview = config2.apiKey.slice(0, 8) + "..." + config2.apiKey.slice(-4);
15436
14973
  return `✓ MUTAGENT_API_KEY: ${keyPreview}
15437
- ✓ MUTAGENT_ENDPOINT: ${config.endpoint}
14974
+ ✓ MUTAGENT_ENDPOINT: ${config2.endpoint}
15438
14975
  ✓ API Connection: Verified`;
15439
14976
  }
15440
14977
  var mastraIntegration = {
@@ -15462,7 +14999,7 @@ var mastraIntegration = {
15462
14999
  files: found
15463
15000
  };
15464
15001
  },
15465
- async generate(config) {
15002
+ async generate(config2) {
15466
15003
  return `---
15467
15004
  name: mutagent-mastra-integration
15468
15005
  description: Integrate MutagenT with Mastra framework for prompt optimization and trace observability
@@ -15474,7 +15011,7 @@ version: 1.0.0
15474
15011
 
15475
15012
  ## Prerequisites Verification
15476
15013
 
15477
- ${renderPrerequisites(config)}
15014
+ ${renderPrerequisites(config2)}
15478
15015
 
15479
15016
  ## Installation
15480
15017
 
@@ -15491,8 +15028,8 @@ npm install @mutagent/sdk
15491
15028
  Add to your \`.env\` file:
15492
15029
 
15493
15030
  \`\`\`env
15494
- MUTAGENT_API_KEY=${config.apiKey}
15495
- MUTAGENT_ENDPOINT=${config.endpoint}
15031
+ MUTAGENT_API_KEY=${config2.apiKey}
15032
+ MUTAGENT_ENDPOINT=${config2.endpoint}
15496
15033
  \`\`\`
15497
15034
 
15498
15035
  ### 2. Mastra Config Integration
@@ -15645,7 +15182,7 @@ var langchainIntegration = {
15645
15182
  files: hasLangchain ? ["package.json"] : []
15646
15183
  };
15647
15184
  },
15648
- async generate(config) {
15185
+ async generate(config2) {
15649
15186
  return `---
15650
15187
  name: mutagent-langchain-integration
15651
15188
  description: Integrate MutagenT with LangChain for prompt optimization and trace observability
@@ -15657,8 +15194,8 @@ version: 1.0.0
15657
15194
 
15658
15195
  ## Prerequisites Verification
15659
15196
 
15660
- - MUTAGENT_API_KEY: ${config.apiKey.slice(0, 8)}...${config.apiKey.slice(-4)}
15661
- - MUTAGENT_ENDPOINT: ${config.endpoint}
15197
+ - MUTAGENT_API_KEY: ${config2.apiKey.slice(0, 8)}...${config2.apiKey.slice(-4)}
15198
+ - MUTAGENT_ENDPOINT: ${config2.endpoint}
15662
15199
  - API Connection: Verified
15663
15200
 
15664
15201
  ## Installation
@@ -15676,8 +15213,8 @@ npm install @mutagent/langchain
15676
15213
  ### 1. Environment Variables
15677
15214
 
15678
15215
  \`\`\`env
15679
- MUTAGENT_API_KEY=${config.apiKey}
15680
- MUTAGENT_ENDPOINT=${config.endpoint}
15216
+ MUTAGENT_API_KEY=${config2.apiKey}
15217
+ MUTAGENT_ENDPOINT=${config2.endpoint}
15681
15218
  \`\`\`
15682
15219
 
15683
15220
  ### 2. LangChain Callback Handler
@@ -15685,54 +15222,45 @@ MUTAGENT_ENDPOINT=${config.endpoint}
15685
15222
  \`\`\`typescript
15686
15223
  import { ChatOpenAI } from '@langchain/openai';
15687
15224
  import { MutagentCallbackHandler } from '@mutagent/langchain';
15225
+ import { initTracing } from '@mutagent/sdk/tracing';
15688
15226
 
15689
- const handler = new MutagentCallbackHandler({
15227
+ // Initialize tracing (or set MUTAGENT_API_KEY env var for auto-init)
15228
+ initTracing({
15690
15229
  apiKey: process.env.MUTAGENT_API_KEY!,
15691
15230
  endpoint: process.env.MUTAGENT_ENDPOINT,
15692
- promptId: 'my-prompt',
15693
15231
  });
15694
15232
 
15233
+ // Create callback handler (no args needed — uses SDK tracing)
15234
+ const handler = new MutagentCallbackHandler();
15235
+
15695
15236
  const llm = new ChatOpenAI({
15696
15237
  callbacks: [handler],
15697
15238
  });
15698
15239
 
15699
15240
  const result = await llm.invoke('Hello world');
15700
- // Traces automatically captured
15241
+ // Traces automatically captured via LangChain callbacks
15701
15242
  \`\`\`
15702
15243
 
15703
15244
  ### 3. Chain Integration
15704
15245
 
15705
15246
  \`\`\`typescript
15706
- import { LLMChain } from 'langchain/chains';
15247
+ import { ChatOpenAI } from '@langchain/openai';
15707
15248
  import { PromptTemplate } from '@langchain/core/prompts';
15708
- import { getOptimizedPrompt } from '@mutagent/langchain';
15249
+ import { MutagentCallbackHandler } from '@mutagent/langchain';
15709
15250
 
15710
- const template = new PromptTemplate({
15711
- template: await getOptimizedPrompt('template-id'), // From MutagenT
15712
- inputVariables: ['question'],
15713
- });
15251
+ const handler = new MutagentCallbackHandler();
15714
15252
 
15715
- const chain = new LLMChain({
15716
- llm,
15717
- prompt: template,
15253
+ const llm = new ChatOpenAI({
15718
15254
  callbacks: [handler],
15719
15255
  });
15720
- \`\`\`
15721
-
15722
- ## Usage
15723
-
15724
- ### Get Optimized Prompt
15725
15256
 
15726
- \`\`\`typescript
15727
- import { getOptimizedPrompt } from '@mutagent/langchain';
15257
+ const template = PromptTemplate.fromTemplate('Answer the question: {question}');
15258
+ const chain = template.pipe(llm);
15728
15259
 
15729
- const optimized = await getOptimizedPrompt('template-id');
15730
- \`\`\`
15731
-
15732
- ### Run Evaluation
15733
-
15734
- \`\`\`bash
15735
- mutagent prompts evals:run <prompt-id> --dataset <dataset-id>
15260
+ const result = await chain.invoke(
15261
+ { question: 'What is TypeScript?' },
15262
+ { callbacks: [handler] },
15263
+ );
15736
15264
  \`\`\`
15737
15265
 
15738
15266
  ## Migration from Langfuse
@@ -15746,7 +15274,7 @@ const callbacks = [new CallbackHandler()];
15746
15274
 
15747
15275
  // After
15748
15276
  import { MutagentCallbackHandler } from '@mutagent/langchain';
15749
- const callbacks = [new MutagentCallbackHandler({ promptId: '...' })];
15277
+ const callbacks = [new MutagentCallbackHandler()];
15750
15278
  \`\`\`
15751
15279
 
15752
15280
  ## Verification
@@ -15755,6 +15283,12 @@ const callbacks = [new MutagentCallbackHandler({ promptId: '...' })];
15755
15283
  mutagent integrate langchain --verify
15756
15284
  \`\`\`
15757
15285
 
15286
+ ## Documentation
15287
+
15288
+ - Full guide: https://docs.mutagent.io/integrations/langchain
15289
+ - API Reference: https://docs.mutagent.io/sdk/tracing
15290
+ - Dashboard: https://app.mutagent.io
15291
+
15758
15292
  ## CLI Reference
15759
15293
 
15760
15294
  \`\`\`bash
@@ -15788,7 +15322,7 @@ var langgraphIntegration = {
15788
15322
  files: hasLanggraph ? ["package.json"] : []
15789
15323
  };
15790
15324
  },
15791
- async generate(config) {
15325
+ async generate(config2) {
15792
15326
  return `---
15793
15327
  name: mutagent-langgraph-integration
15794
15328
  description: Integrate MutagenT with LangGraph for agent workflow observability
@@ -15800,8 +15334,8 @@ version: 1.0.0
15800
15334
 
15801
15335
  ## Prerequisites Verification
15802
15336
 
15803
- - MUTAGENT_API_KEY: ${config.apiKey.slice(0, 8)}...${config.apiKey.slice(-4)}
15804
- - MUTAGENT_ENDPOINT: ${config.endpoint}
15337
+ - MUTAGENT_API_KEY: ${config2.apiKey.slice(0, 8)}...${config2.apiKey.slice(-4)}
15338
+ - MUTAGENT_ENDPOINT: ${config2.endpoint}
15805
15339
  - API Connection: Verified
15806
15340
 
15807
15341
  ## Installation
@@ -15816,58 +15350,57 @@ npm install @mutagent/langgraph
15816
15350
 
15817
15351
  ## Configuration
15818
15352
 
15819
- ### Graph with MutagenT Observer
15353
+ ### Graph with MutagenT Tracer
15820
15354
 
15821
15355
  \`\`\`typescript
15822
- import { StateGraph } from '@langchain/langgraph';
15356
+ import { StateGraph, Annotation } from '@langchain/langgraph';
15823
15357
  import { MutagentGraphTracer } from '@mutagent/langgraph';
15358
+ import { initTracing } from '@mutagent/sdk/tracing';
15824
15359
 
15825
- const tracer = new MutagentGraphTracer({
15360
+ // Initialize tracing (or set MUTAGENT_API_KEY env var for auto-init)
15361
+ initTracing({
15826
15362
  apiKey: process.env.MUTAGENT_API_KEY!,
15827
15363
  endpoint: process.env.MUTAGENT_ENDPOINT,
15828
- graphId: 'agent-workflow',
15829
15364
  });
15830
15365
 
15831
- const graph = new StateGraph({...})
15366
+ // Create tracer (no args needed — uses SDK tracing)
15367
+ const tracer = new MutagentGraphTracer();
15368
+
15369
+ // Define your graph as usual
15370
+ const StateAnnotation = Annotation.Root({
15371
+ input: Annotation<string>,
15372
+ output: Annotation<string>,
15373
+ });
15374
+
15375
+ const graph = new StateGraph(StateAnnotation)
15832
15376
  .addNode('agent', agentNode)
15833
15377
  .addNode('tools', toolNode)
15834
15378
  .addEdge('__start__', 'agent')
15835
15379
  .compile();
15836
15380
 
15837
- // Wrap execution with tracing
15838
- const tracedGraph = tracer.wrap(graph);
15839
-
15840
- const result = await tracedGraph.invoke({ input: 'Hello' });
15841
- \`\`\`
15842
-
15843
- ### Per-Node Tracing
15844
-
15845
- \`\`\`typescript
15846
- import { traceNode } from '@mutagent/langgraph';
15847
-
15848
- const agentNode = traceNode(
15849
- async (state) => {
15850
- // Agent logic
15851
- return { ... };
15852
- },
15853
- { nodeId: 'agent', promptId: 'agent-prompt' }
15854
- );
15381
+ // Use lifecycle methods for tracing
15382
+ tracer.handleGraphStart('agent-workflow', { input: 'Hello' });
15383
+ const result = await graph.invoke({ input: 'Hello' });
15384
+ tracer.handleGraphEnd({ output: result.output });
15855
15385
  \`\`\`
15856
15386
 
15857
- ## State Management with MutagenT
15387
+ ### Per-Node and Edge Tracing
15858
15388
 
15859
15389
  \`\`\`typescript
15860
- import { getOptimizedPrompt } from '@mutagent/langgraph';
15390
+ // Track individual nodes
15391
+ tracer.handleNodeStart('agent', { query: 'Hello' });
15392
+ // ... node logic ...
15393
+ tracer.handleNodeEnd('agent', { result: 'response' });
15861
15394
 
15862
- // Use optimized prompts in graph nodes
15863
- const optimizedPrompt = await getOptimizedPrompt('agent-template');
15395
+ // Track edge transitions
15396
+ tracer.handleEdgeTransition('agent', 'tools', {
15397
+ isConditional: true,
15398
+ condition: 'needsTools',
15399
+ conditionResult: true,
15400
+ });
15864
15401
 
15865
- const agentNode = async (state: AgentState) => {
15866
- const model = new ChatOpenAI().bind({
15867
- prompt: optimizedPrompt,
15868
- });
15869
- // ...
15870
- };
15402
+ tracer.handleNodeStart('tools', { toolName: 'search' });
15403
+ tracer.handleNodeEnd('tools', { result: 'found' });
15871
15404
  \`\`\`
15872
15405
 
15873
15406
  ## Verification
@@ -15876,6 +15409,12 @@ const agentNode = async (state: AgentState) => {
15876
15409
  mutagent integrate langgraph --verify
15877
15410
  \`\`\`
15878
15411
 
15412
+ ## Documentation
15413
+
15414
+ - Full guide: https://docs.mutagent.io/integrations/langgraph
15415
+ - API Reference: https://docs.mutagent.io/sdk/tracing
15416
+ - Dashboard: https://app.mutagent.io
15417
+
15879
15418
  ## CLI Commands
15880
15419
 
15881
15420
  \`\`\`bash
@@ -15909,7 +15448,7 @@ var vercelAiIntegration = {
15909
15448
  files: hasAiSdk ? ["package.json"] : []
15910
15449
  };
15911
15450
  },
15912
- async generate(config) {
15451
+ async generate(config2) {
15913
15452
  return `---
15914
15453
  name: mutagent-vercel-ai-integration
15915
15454
  description: Integrate MutagenT with Vercel AI SDK for streaming and edge functions
@@ -15921,8 +15460,8 @@ version: 1.0.0
15921
15460
 
15922
15461
  ## Prerequisites Verification
15923
15462
 
15924
- - MUTAGENT_API_KEY: ${config.apiKey.slice(0, 8)}...${config.apiKey.slice(-4)}
15925
- - MUTAGENT_ENDPOINT: ${config.endpoint}
15463
+ - MUTAGENT_API_KEY: ${config2.apiKey.slice(0, 8)}...${config2.apiKey.slice(-4)}
15464
+ - MUTAGENT_ENDPOINT: ${config2.endpoint}
15926
15465
  - API Connection: Verified
15927
15466
 
15928
15467
  ## Installation
@@ -15935,67 +15474,53 @@ bun add @mutagent/vercel-ai
15935
15474
  npm install @mutagent/vercel-ai
15936
15475
  \`\`\`
15937
15476
 
15938
- ## Edge Function Integration
15477
+ ## Integration
15939
15478
 
15940
15479
  \`\`\`typescript
15941
15480
  // app/api/chat/route.ts
15942
- import { streamText } from 'ai';
15481
+ import { streamText, wrapLanguageModel } from 'ai';
15943
15482
  import { openai } from '@ai-sdk/openai';
15944
15483
  import { createMutagentMiddleware } from '@mutagent/vercel-ai';
15484
+ import { initTracing } from '@mutagent/sdk/tracing';
15945
15485
 
15946
- // Create middleware for tracing
15947
- const mutagent = createMutagentMiddleware({
15486
+ // Initialize tracing (or set MUTAGENT_API_KEY env var for auto-init)
15487
+ initTracing({
15948
15488
  apiKey: process.env.MUTAGENT_API_KEY!,
15949
15489
  endpoint: process.env.MUTAGENT_ENDPOINT,
15950
15490
  });
15951
15491
 
15952
- export async function POST(req: Request) {
15953
- const { messages } = await req.json();
15954
-
15955
- const result = streamText({
15956
- model: openai('gpt-4o'),
15957
- messages,
15958
- experimental_telemetry: {
15959
- isEnabled: true,
15960
- metadata: {
15961
- mutagentPromptId: 'chat-template',
15962
- },
15963
- },
15964
- });
15965
-
15966
- return mutagent.wrapResponse(result, {
15967
- promptId: 'chat-template',
15968
- });
15969
- }
15970
- \`\`\`
15971
-
15972
- ## Client-Side Streaming
15492
+ // Create middleware (no args needed — uses SDK tracing)
15493
+ const middleware = createMutagentMiddleware();
15973
15494
 
15974
- \`\`\`typescript
15975
- 'use client';
15495
+ // Wrap your model with MutagenT middleware
15496
+ const model = wrapLanguageModel({
15497
+ model: openai('gpt-4o'),
15498
+ middleware,
15499
+ });
15976
15500
 
15977
- import { useChat } from 'ai/react';
15501
+ export async function POST(req: Request) {
15502
+ const { messages } = await req.json();
15978
15503
 
15979
- export default function Chat() {
15980
- const { messages, input, handleInputChange, handleSubmit } = useChat({
15981
- api: '/api/chat',
15982
- });
15504
+ // All calls are automatically traced
15505
+ const result = streamText({ model, messages });
15983
15506
 
15984
- return (...);
15507
+ return result.toDataStreamResponse();
15985
15508
  }
15986
15509
  \`\`\`
15987
15510
 
15988
- ## Optimized Prompts
15511
+ ## Non-Streaming Usage
15989
15512
 
15990
15513
  \`\`\`typescript
15991
- import { getOptimizedPrompt } from '@mutagent/vercel-ai';
15514
+ import { generateText, wrapLanguageModel } from 'ai';
15515
+ import { openai } from '@ai-sdk/openai';
15516
+ import { createMutagentMiddleware } from '@mutagent/vercel-ai';
15992
15517
 
15993
- const systemPrompt = await getOptimizedPrompt('system-template');
15518
+ const middleware = createMutagentMiddleware();
15519
+ const model = wrapLanguageModel({ model: openai('gpt-4o'), middleware });
15994
15520
 
15995
- const result = streamText({
15996
- model: openai('gpt-4o'),
15997
- system: systemPrompt,
15998
- messages,
15521
+ const { text } = await generateText({
15522
+ model,
15523
+ prompt: 'What is TypeScript?',
15999
15524
  });
16000
15525
  \`\`\`
16001
15526
 
@@ -16005,6 +15530,12 @@ const result = streamText({
16005
15530
  mutagent integrate vercel-ai --verify
16006
15531
  \`\`\`
16007
15532
 
15533
+ ## Documentation
15534
+
15535
+ - Full guide: https://docs.mutagent.io/integrations/vercel-ai
15536
+ - API Reference: https://docs.mutagent.io/sdk/tracing
15537
+ - Dashboard: https://app.mutagent.io
15538
+
16008
15539
  ## CLI Commands
16009
15540
 
16010
15541
  \`\`\`bash
@@ -16038,7 +15569,7 @@ var openaiIntegration = {
16038
15569
  files: hasOpenAI ? ["package.json"] : []
16039
15570
  };
16040
15571
  },
16041
- async generate(config) {
15572
+ async generate(config2) {
16042
15573
  return `---
16043
15574
  name: mutagent-openai-integration
16044
15575
  description: Integrate MutagenT with OpenAI SDK for automatic tracing
@@ -16050,8 +15581,8 @@ version: 1.0.0
16050
15581
 
16051
15582
  ## Prerequisites Verification
16052
15583
 
16053
- - MUTAGENT_API_KEY: ${config.apiKey.slice(0, 8)}...${config.apiKey.slice(-4)}
16054
- - MUTAGENT_ENDPOINT: ${config.endpoint}
15584
+ - MUTAGENT_API_KEY: ${config2.apiKey.slice(0, 8)}...${config2.apiKey.slice(-4)}
15585
+ - MUTAGENT_ENDPOINT: ${config2.endpoint}
16055
15586
  - API Connection: Verified
16056
15587
 
16057
15588
  ## Installation
@@ -16069,26 +15600,28 @@ npm install @mutagent/openai
16069
15600
  ### 1. Environment Variables
16070
15601
 
16071
15602
  \`\`\`env
16072
- MUTAGENT_API_KEY=${config.apiKey}
16073
- MUTAGENT_ENDPOINT=${config.endpoint}
15603
+ MUTAGENT_API_KEY=${config2.apiKey}
15604
+ MUTAGENT_ENDPOINT=${config2.endpoint}
16074
15605
  OPENAI_API_KEY=your-openai-api-key
16075
15606
  \`\`\`
16076
15607
 
16077
- ### 2. Wrapped OpenAI Client
15608
+ ### 2. Traced OpenAI Client
16078
15609
 
16079
15610
  \`\`\`typescript
16080
- import { createTracedOpenAI } from '@mutagent/openai';
15611
+ import { MutagentOpenAI } from '@mutagent/openai';
15612
+ import { initTracing } from '@mutagent/sdk/tracing';
16081
15613
 
16082
- // Create a traced OpenAI client
16083
- const openai = createTracedOpenAI({
16084
- // OpenAI options
16085
- apiKey: process.env.OPENAI_API_KEY,
16086
- }, {
16087
- // MutagenT options
15614
+ // Initialize tracing (or set MUTAGENT_API_KEY env var for auto-init)
15615
+ initTracing({
16088
15616
  apiKey: process.env.MUTAGENT_API_KEY!,
16089
15617
  endpoint: process.env.MUTAGENT_ENDPOINT,
16090
15618
  });
16091
15619
 
15620
+ // Create a traced OpenAI client (drop-in replacement for OpenAI)
15621
+ const openai = new MutagentOpenAI({
15622
+ apiKey: process.env.OPENAI_API_KEY,
15623
+ });
15624
+
16092
15625
  // All calls are automatically traced
16093
15626
  const completion = await openai.chat.completions.create({
16094
15627
  model: 'gpt-4o',
@@ -16098,32 +15631,6 @@ const completion = await openai.chat.completions.create({
16098
15631
  console.log(completion.choices[0].message.content);
16099
15632
  \`\`\`
16100
15633
 
16101
- ### 3. With Trace Metadata
16102
-
16103
- \`\`\`typescript
16104
- import { createTracedOpenAI, withTrace } from '@mutagent/openai';
16105
-
16106
- const openai = createTracedOpenAI({
16107
- apiKey: process.env.OPENAI_API_KEY,
16108
- }, {
16109
- apiKey: process.env.MUTAGENT_API_KEY!,
16110
- });
16111
-
16112
- // Add custom metadata to traces
16113
- const completion = await withTrace(
16114
- openai.chat.completions.create({
16115
- model: 'gpt-4o',
16116
- messages: [{ role: 'user', content: 'Hello!' }],
16117
- }),
16118
- {
16119
- promptId: 'my-prompt',
16120
- userId: 'user-123',
16121
- sessionId: 'session-456',
16122
- tags: ['production', 'chat'],
16123
- }
16124
- );
16125
- \`\`\`
16126
-
16127
15634
  ## Usage Examples
16128
15635
 
16129
15636
  ### Chat Completion
@@ -16158,6 +15665,12 @@ for await (const chunk of stream) {
16158
15665
  mutagent integrate openai --verify
16159
15666
  \`\`\`
16160
15667
 
15668
+ ## Documentation
15669
+
15670
+ - Full guide: https://docs.mutagent.io/integrations/openai
15671
+ - API Reference: https://docs.mutagent.io/sdk/tracing
15672
+ - Dashboard: https://app.mutagent.io
15673
+
16161
15674
  ## CLI Reference
16162
15675
 
16163
15676
  \`\`\`bash
@@ -16194,7 +15707,7 @@ var claudeCodeIntegration = {
16194
15707
  files: hasClaudeCode ? ["package.json"] : []
16195
15708
  };
16196
15709
  },
16197
- async generate(config) {
15710
+ async generate(config2) {
16198
15711
  return `---
16199
15712
  name: mutagent-claude-code-integration
16200
15713
  description: Integrate MutagenT with Claude Code SDK
@@ -16206,8 +15719,8 @@ version: 1.0.0
16206
15719
 
16207
15720
  ## Prerequisites Verification
16208
15721
 
16209
- ✓ MUTAGENT_API_KEY: ${config.apiKey.slice(0, 8)}...${config.apiKey.slice(-4)}
16210
- ✓ MUTAGENT_ENDPOINT: ${config.endpoint}
15722
+ ✓ MUTAGENT_API_KEY: ${config2.apiKey.slice(0, 8)}...${config2.apiKey.slice(-4)}
15723
+ ✓ MUTAGENT_ENDPOINT: ${config2.endpoint}
16211
15724
  ✓ API Connection: Verified
16212
15725
 
16213
15726
  ## Installation
@@ -16269,7 +15782,7 @@ For Claude Desktop / MCP:
16269
15782
  "command": "npx",
16270
15783
  "args": ["-y", "@mutagent/mcp-server"],
16271
15784
  "env": {
16272
- "MUTAGENT_API_KEY": "${config.apiKey}"
15785
+ "MUTAGENT_API_KEY": "${config2.apiKey}"
16273
15786
  }
16274
15787
  }
16275
15788
  }
@@ -16306,7 +15819,7 @@ var genericIntegration = {
16306
15819
  files: []
16307
15820
  };
16308
15821
  },
16309
- async generate(config) {
15822
+ async generate(config2) {
16310
15823
  return `---
16311
15824
  name: mutagent-generic-integration
16312
15825
  description: Generic OpenAI-compatible API integration
@@ -16318,8 +15831,8 @@ version: 1.0.0
16318
15831
 
16319
15832
  ## Prerequisites Verification
16320
15833
 
16321
- ✓ MUTAGENT_API_KEY: ${config.apiKey.slice(0, 8)}...${config.apiKey.slice(-4)}
16322
- ✓ MUTAGENT_ENDPOINT: ${config.endpoint}
15834
+ ✓ MUTAGENT_API_KEY: ${config2.apiKey.slice(0, 8)}...${config2.apiKey.slice(-4)}
15835
+ ✓ MUTAGENT_ENDPOINT: ${config2.endpoint}
16323
15836
  ✓ API Connection: Verified
16324
15837
 
16325
15838
  ## Installation
@@ -16574,7 +16087,7 @@ It returns INSTRUCTIONS that AI agents execute - it does NOT auto-install packag
16574
16087
  if (!apiKey) {
16575
16088
  throw new MutagentError2("AUTH_REQUIRED", "API key required for integration", "Run: mutagent auth login");
16576
16089
  }
16577
- const config = loadConfig();
16090
+ const config2 = loadConfig();
16578
16091
  if (!frameworkArg) {
16579
16092
  const explorationInstructions = generateExplorationInstructions();
16580
16093
  if (options.output) {
@@ -16596,7 +16109,7 @@ It returns INSTRUCTIONS that AI agents execute - it does NOT auto-install packag
16596
16109
  const meta = getFrameworkMetadata(frameworkArg);
16597
16110
  const mutagentPackage = meta?.mutagentPackage;
16598
16111
  const pm = detectPackageManager();
16599
- const endpoint = config.endpoint ?? "https://api.mutagent.io/v1";
16112
+ const endpoint = config2.endpoint ?? "https://api.mutagent.io";
16600
16113
  const frameworkMarkdown = await framework.generate({
16601
16114
  apiKey,
16602
16115
  endpoint,
@@ -16683,7 +16196,12 @@ Subcommands:
16683
16196
  list, get, create, update, delete
16684
16197
  conversations list|get|create|delete|messages
16685
16198
  `);
16686
- agents.command("list").description("List all agents").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").option("-n, --name <name>", "Filter by name").option("-s, --status <status>", "Filter by status (active, paused, archived)").action(async (options) => {
16199
+ agents.command("list").description("List all agents").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").option("-n, --name <name>", "Filter by name").option("-s, --status <status>", "Filter by status (active, paused, archived)").addHelpText("after", `
16200
+ Examples:
16201
+ ${chalk7.dim("$")} mutagent agents list
16202
+ ${chalk7.dim("$")} mutagent agents list --status active
16203
+ ${chalk7.dim("$")} mutagent agents list --name "reviewer" --json
16204
+ `).action(async (options) => {
16687
16205
  const isJson = getJsonFlag(agents);
16688
16206
  const output = new OutputFormatter(isJson ? "json" : "table");
16689
16207
  try {
@@ -16719,7 +16237,11 @@ Subcommands:
16719
16237
  handleError(error, isJson);
16720
16238
  }
16721
16239
  });
16722
- agents.command("get").description("Get agent details").argument("<id>", "Agent ID").action(async (id) => {
16240
+ agents.command("get").description("Get agent details").argument("<id>", "Agent ID").addHelpText("after", `
16241
+ Examples:
16242
+ ${chalk7.dim("$")} mutagent agents get <agent-id>
16243
+ ${chalk7.dim("$")} mutagent agents get <agent-id> --json
16244
+ `).action(async (id) => {
16723
16245
  const isJson = getJsonFlag(agents);
16724
16246
  const output = new OutputFormatter(isJson ? "json" : "table");
16725
16247
  try {
@@ -16758,7 +16280,14 @@ System Prompt:`));
16758
16280
  handleError(error, isJson);
16759
16281
  }
16760
16282
  });
16761
- agents.command("create").description("Create a new agent").option("-f, --file <path>", "Create from JSON file").option("-n, --name <name>", "Agent name").option("-s, --slug <slug>", "Agent slug (URL-friendly identifier)").option("-p, --system-prompt <prompt>", "System prompt").option("-m, --model <model>", "Model (claude-sonnet-4-5, claude-opus-4-5, claude-haiku-4-5)").option("-d, --description <description>", "Agent description").action(async (options) => {
16283
+ agents.command("create").description("Create a new agent").option("-f, --file <path>", "Create from JSON file").option("-n, --name <name>", "Agent name").option("-s, --slug <slug>", "Agent slug (URL-friendly identifier)").option("-p, --system-prompt <prompt>", "System prompt").option("-m, --model <model>", "Model (claude-sonnet-4-5, claude-opus-4-5, claude-haiku-4-5)").option("-d, --description <description>", "Agent description").addHelpText("after", `
16284
+ Examples:
16285
+ ${chalk7.dim("$")} mutagent agents create --name "Code Reviewer" --slug code-reviewer --system-prompt "Review code for bugs"
16286
+ ${chalk7.dim("$")} mutagent agents create --file agent.json
16287
+ ${chalk7.dim("$")} mutagent agents create --name "Helper" --slug helper --system-prompt "..." --model claude-sonnet-4-5 --json
16288
+
16289
+ ${chalk7.dim("Required: --name, --slug, and --system-prompt (or --file).")}
16290
+ `).action(async (options) => {
16762
16291
  const isJson = getJsonFlag(agents);
16763
16292
  const output = new OutputFormatter(isJson ? "json" : "table");
16764
16293
  try {
@@ -16787,7 +16316,12 @@ System Prompt:`));
16787
16316
  handleError(error, isJson);
16788
16317
  }
16789
16318
  });
16790
- agents.command("update").description("Update an agent").argument("<id>", "Agent ID").option("-f, --file <path>", "Update from JSON file").option("-n, --name <name>", "New name").option("-p, --system-prompt <prompt>", "New system prompt").option("-m, --model <model>", "New model").option("-d, --description <description>", "New description").option("-s, --status <status>", "New status (active, paused, archived)").action(async (id, options) => {
16319
+ agents.command("update").description("Update an agent").argument("<id>", "Agent ID").option("-f, --file <path>", "Update from JSON file").option("-n, --name <name>", "New name").option("-p, --system-prompt <prompt>", "New system prompt").option("-m, --model <model>", "New model").option("-d, --description <description>", "New description").option("-s, --status <status>", "New status (active, paused, archived)").addHelpText("after", `
16320
+ Examples:
16321
+ ${chalk7.dim("$")} mutagent agents update <id> --name "New Name"
16322
+ ${chalk7.dim("$")} mutagent agents update <id> --status paused
16323
+ ${chalk7.dim("$")} mutagent agents update <id> --file updated-agent.json --json
16324
+ `).action(async (id, options) => {
16791
16325
  const isJson = getJsonFlag(agents);
16792
16326
  const output = new OutputFormatter(isJson ? "json" : "table");
16793
16327
  try {
@@ -16818,7 +16352,14 @@ System Prompt:`));
16818
16352
  handleError(error, isJson);
16819
16353
  }
16820
16354
  });
16821
- agents.command("delete").description("Delete an agent").argument("<id>", "Agent ID").option("--force", "Skip confirmation").action(async (id, options) => {
16355
+ agents.command("delete").description("Delete an agent").argument("<id>", "Agent ID").option("--force", "Skip confirmation").addHelpText("after", `
16356
+ Examples:
16357
+ ${chalk7.dim("$")} mutagent agents delete <id>
16358
+ ${chalk7.dim("$")} mutagent agents delete <id> --force
16359
+ ${chalk7.dim("$")} mutagent agents delete <id> --force --json
16360
+
16361
+ ${chalk7.dim("Tip: Use --force to skip confirmation (required for non-interactive/CI usage).")}
16362
+ `).action(async (id, options) => {
16822
16363
  const isJson = getJsonFlag(agents);
16823
16364
  const output = new OutputFormatter(isJson ? "json" : "table");
16824
16365
  try {
@@ -16842,8 +16383,17 @@ System Prompt:`));
16842
16383
  handleError(error, isJson);
16843
16384
  }
16844
16385
  });
16845
- const conversations = agents.command("conversations").description("Manage conversations for agents");
16846
- conversations.command("list").description("List conversations for an agent").argument("<agent-id>", "Agent ID").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").action(async (agentId, options) => {
16386
+ const conversations = agents.command("conversations").description("Manage conversations for agents").addHelpText("after", `
16387
+ Examples:
16388
+ ${chalk7.dim("$")} mutagent agents conversations list <agent-id>
16389
+ ${chalk7.dim("$")} mutagent agents conversations create <agent-id>
16390
+ ${chalk7.dim("$")} mutagent agents conversations messages <agent-id> <conversation-id>
16391
+ `);
16392
+ conversations.command("list").description("List conversations for an agent").argument("<agent-id>", "Agent ID").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").addHelpText("after", `
16393
+ Examples:
16394
+ ${chalk7.dim("$")} mutagent agents conversations list <agent-id>
16395
+ ${chalk7.dim("$")} mutagent agents conversations list <agent-id> --limit 10 --json
16396
+ `).action(async (agentId, options) => {
16847
16397
  const isJson = getJsonFlag(agents);
16848
16398
  const output = new OutputFormatter(isJson ? "json" : "table");
16849
16399
  try {
@@ -16872,7 +16422,11 @@ System Prompt:`));
16872
16422
  handleError(error, isJson);
16873
16423
  }
16874
16424
  });
16875
- conversations.command("get").description("Get conversation details").argument("<agent-id>", "Agent ID").argument("<conversation-id>", "Conversation ID").action(async (agentId, conversationId) => {
16425
+ conversations.command("get").description("Get conversation details").argument("<agent-id>", "Agent ID").argument("<conversation-id>", "Conversation ID").addHelpText("after", `
16426
+ Examples:
16427
+ ${chalk7.dim("$")} mutagent agents conversations get <agent-id> <conversation-id>
16428
+ ${chalk7.dim("$")} mutagent agents conversations get <agent-id> <conversation-id> --json
16429
+ `).action(async (agentId, conversationId) => {
16876
16430
  const isJson = getJsonFlag(agents);
16877
16431
  const output = new OutputFormatter(isJson ? "json" : "table");
16878
16432
  try {
@@ -16896,7 +16450,11 @@ System Prompt:`));
16896
16450
  handleError(error, isJson);
16897
16451
  }
16898
16452
  });
16899
- conversations.command("create").description("Start a new conversation with an agent").argument("<agent-id>", "Agent ID").option("-t, --title <title>", "Conversation title").action(async (agentId, options) => {
16453
+ conversations.command("create").description("Start a new conversation with an agent").argument("<agent-id>", "Agent ID").option("-t, --title <title>", "Conversation title").addHelpText("after", `
16454
+ Examples:
16455
+ ${chalk7.dim("$")} mutagent agents conversations create <agent-id>
16456
+ ${chalk7.dim("$")} mutagent agents conversations create <agent-id> --title "Debug session" --json
16457
+ `).action(async (agentId, options) => {
16900
16458
  const isJson = getJsonFlag(agents);
16901
16459
  const output = new OutputFormatter(isJson ? "json" : "table");
16902
16460
  try {
@@ -16912,7 +16470,11 @@ System Prompt:`));
16912
16470
  handleError(error, isJson);
16913
16471
  }
16914
16472
  });
16915
- conversations.command("delete").description("Delete a conversation").argument("<agent-id>", "Agent ID").argument("<conversation-id>", "Conversation ID").option("--force", "Skip confirmation").action(async (agentId, conversationId, options) => {
16473
+ conversations.command("delete").description("Delete a conversation").argument("<agent-id>", "Agent ID").argument("<conversation-id>", "Conversation ID").option("--force", "Skip confirmation").addHelpText("after", `
16474
+ Examples:
16475
+ ${chalk7.dim("$")} mutagent agents conversations delete <agent-id> <conversation-id>
16476
+ ${chalk7.dim("$")} mutagent agents conversations delete <agent-id> <conversation-id> --force --json
16477
+ `).action(async (agentId, conversationId, options) => {
16916
16478
  const isJson = getJsonFlag(agents);
16917
16479
  const output = new OutputFormatter(isJson ? "json" : "table");
16918
16480
  try {
@@ -16936,7 +16498,11 @@ System Prompt:`));
16936
16498
  handleError(error, isJson);
16937
16499
  }
16938
16500
  });
16939
- conversations.command("messages").description("List messages in a conversation").argument("<agent-id>", "Agent ID").argument("<conversation-id>", "Conversation ID").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").action(async (agentId, conversationId, options) => {
16501
+ conversations.command("messages").description("List messages in a conversation").argument("<agent-id>", "Agent ID").argument("<conversation-id>", "Conversation ID").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").addHelpText("after", `
16502
+ Examples:
16503
+ ${chalk7.dim("$")} mutagent agents conversations messages <agent-id> <conversation-id>
16504
+ ${chalk7.dim("$")} mutagent agents conversations messages <agent-id> <conversation-id> --limit 20 --json
16505
+ `).action(async (agentId, conversationId, options) => {
16940
16506
  const isJson = getJsonFlag(agents);
16941
16507
  const output = new OutputFormatter(isJson ? "json" : "table");
16942
16508
  try {
@@ -16971,15 +16537,19 @@ System Prompt:`));
16971
16537
  import { Command as Command7 } from "commander";
16972
16538
  import chalk8 from "chalk";
16973
16539
  function createConfigCommand() {
16974
- const config = new Command7("config").description("Manage CLI configuration").addHelpText("after", `
16540
+ const config2 = new Command7("config").description("Manage CLI configuration").addHelpText("after", `
16975
16541
  Examples:
16976
16542
  ${chalk8.dim("$")} mutagent config list
16977
16543
  ${chalk8.dim("$")} mutagent config get endpoint
16978
16544
  ${chalk8.dim("$")} mutagent config set workspace <workspace-id>
16979
16545
  ${chalk8.dim("$")} mutagent config set org <org-id>
16980
16546
  `);
16981
- config.command("list").description("List all configuration").action(() => {
16982
- const isJson = getJsonFlag(config);
16547
+ config2.command("list").description("List all configuration").addHelpText("after", `
16548
+ Examples:
16549
+ ${chalk8.dim("$")} mutagent config list
16550
+ ${chalk8.dim("$")} mutagent config list --json
16551
+ `).action(() => {
16552
+ const isJson = getJsonFlag(config2);
16983
16553
  const output = new OutputFormatter(isJson ? "json" : "table");
16984
16554
  const cfg = loadConfig();
16985
16555
  const display = {
@@ -16988,8 +16558,15 @@ Examples:
16988
16558
  };
16989
16559
  output.output(display);
16990
16560
  });
16991
- config.command("get").description("Get configuration value").argument("<key>", "Configuration key (apiKey, endpoint, format, timeout, defaultWorkspace, defaultOrganization)").action((key) => {
16992
- const isJson = getJsonFlag(config);
16561
+ config2.command("get").description("Get configuration value").argument("<key>", "Configuration key (apiKey, endpoint, format, timeout, defaultWorkspace, defaultOrganization)").addHelpText("after", `
16562
+ Examples:
16563
+ ${chalk8.dim("$")} mutagent config get endpoint
16564
+ ${chalk8.dim("$")} mutagent config get defaultWorkspace
16565
+ ${chalk8.dim("$")} mutagent config get apiKey --json
16566
+
16567
+ ${chalk8.dim("Keys: apiKey, endpoint, format, timeout, defaultWorkspace, defaultOrganization")}
16568
+ `).action((key) => {
16569
+ const isJson = getJsonFlag(config2);
16993
16570
  const output = new OutputFormatter(isJson ? "json" : "table");
16994
16571
  const cfg = loadConfig();
16995
16572
  if (!(key in cfg)) {
@@ -17006,8 +16583,13 @@ Examples:
17006
16583
  }
17007
16584
  });
17008
16585
  const set = new Command7("set").description("Set configuration value");
17009
- set.command("workspace").description("Set default workspace ID").argument("<id>", "Workspace ID to set as default").action((id) => {
17010
- const isJson = getJsonFlag(config);
16586
+ set.command("workspace").description("Set default workspace ID").argument("<id>", "Workspace ID to set as default").addHelpText("after", `
16587
+ Examples:
16588
+ ${chalk8.dim("$")} mutagent config set workspace <workspace-id>
16589
+
16590
+ ${chalk8.dim("Persists workspace ID so you don't need to pass headers on every request.")}
16591
+ `).action((id) => {
16592
+ const isJson = getJsonFlag(config2);
17011
16593
  const output = new OutputFormatter(isJson ? "json" : "table");
17012
16594
  setDefaultWorkspace(id);
17013
16595
  if (isJson) {
@@ -17016,8 +16598,13 @@ Examples:
17016
16598
  output.success(`Default workspace set to ${id}`);
17017
16599
  }
17018
16600
  });
17019
- set.command("org").description("Set default organization ID").argument("<id>", "Organization ID to set as default").action((id) => {
17020
- const isJson = getJsonFlag(config);
16601
+ set.command("org").description("Set default organization ID").argument("<id>", "Organization ID to set as default").addHelpText("after", `
16602
+ Examples:
16603
+ ${chalk8.dim("$")} mutagent config set org <org-id>
16604
+
16605
+ ${chalk8.dim("Persists organization ID for org-scoped API keys.")}
16606
+ `).action((id) => {
16607
+ const isJson = getJsonFlag(config2);
17021
16608
  const output = new OutputFormatter(isJson ? "json" : "table");
17022
16609
  setDefaultOrganization(id);
17023
16610
  if (isJson) {
@@ -17026,8 +16613,8 @@ Examples:
17026
16613
  output.success(`Default organization set to ${id}`);
17027
16614
  }
17028
16615
  });
17029
- config.addCommand(set);
17030
- return config;
16616
+ config2.addCommand(set);
16617
+ return config2;
17031
16618
  }
17032
16619
 
17033
16620
  // src/commands/playground.ts
@@ -17078,7 +16665,19 @@ Streaming:
17078
16665
  Use --stream to receive tokens as they are generated.
17079
16666
  In JSON mode (--json), each token is output as a separate JSON object.
17080
16667
  `);
17081
- playground.command("run").description("Execute a prompt with input variables").argument("<prompt-id>", "Prompt ID to execute").option("-i, --input <json>", "Input variables as JSON").option("-f, --file <path>", "Input from JSON file").option("-s, --stream", "Stream the response").option("-m, --model <model>", "Override model").option("--system <text>", "Set system prompt text").option("--human <text>", "Set human/user message text").option("--messages <json>", "Pass full messages array as JSON string").action(async (promptId, options) => {
16668
+ playground.command("run").description("Execute a prompt with input variables").argument("<prompt-id>", "Prompt ID to execute").option("-i, --input <json>", "Input variables as JSON").option("-f, --file <path>", "Input from JSON file").option("-s, --stream", "Stream the response").option("-m, --model <model>", "Override model").option("--system <text>", "Set system prompt text").option("--human <text>", "Set human/user message text").option("--messages <json>", "Pass full messages array as JSON string").addHelpText("after", `
16669
+ Examples:
16670
+ ${chalk9.dim("$")} mutagent playground run <prompt-id> --input '{"name": "John"}'
16671
+ ${chalk9.dim("$")} mutagent playground run <prompt-id> --file input.json --stream
16672
+ ${chalk9.dim("$")} mutagent playground run <prompt-id> --system "You are helpful" --human "Hello"
16673
+ ${chalk9.dim("$")} mutagent playground run <prompt-id> --input '{}' --model gpt-4-turbo --json
16674
+
16675
+ Input Methods (pick one):
16676
+ --input '{"key":"value"}' Inline JSON variables
16677
+ --file input.json Load from JSON file
16678
+ --system/--human Quick system + user message
16679
+ --messages '[...]' Full messages array
16680
+ `).action(async (promptId, options) => {
17082
16681
  const isJson = getJsonFlag(playground);
17083
16682
  const output = new OutputFormatter(isJson ? "json" : "table");
17084
16683
  try {
@@ -17291,7 +16890,11 @@ Subcommands:
17291
16890
 
17292
16891
  Note: Workspace management (create, update, delete) is available in the Admin Panel only.
17293
16892
  `);
17294
- workspaces.command("list").description("List all workspaces").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").action(async (options) => {
16893
+ workspaces.command("list").description("List all workspaces").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").addHelpText("after", `
16894
+ Examples:
16895
+ ${chalk10.dim("$")} mutagent workspaces list
16896
+ ${chalk10.dim("$")} mutagent workspaces list --limit 10 --json
16897
+ `).action(async (options) => {
17295
16898
  const isJson = getJsonFlag(workspaces);
17296
16899
  const output = new OutputFormatter(isJson ? "json" : "table");
17297
16900
  try {
@@ -17319,7 +16922,11 @@ Note: Workspace management (create, update, delete) is available in the Admin Pa
17319
16922
  handleError(error, isJson);
17320
16923
  }
17321
16924
  });
17322
- workspaces.command("get").description("Get workspace details").argument("<id>", "Workspace ID").action(async (id) => {
16925
+ workspaces.command("get").description("Get workspace details").argument("<id>", "Workspace ID").addHelpText("after", `
16926
+ Examples:
16927
+ ${chalk10.dim("$")} mutagent workspaces get <workspace-id>
16928
+ ${chalk10.dim("$")} mutagent workspaces get <workspace-id> --json
16929
+ `).action(async (id) => {
17323
16930
  const isJson = getJsonFlag(workspaces);
17324
16931
  const output = new OutputFormatter(isJson ? "json" : "table");
17325
16932
  try {
@@ -17384,7 +16991,12 @@ Subcommands:
17384
16991
 
17385
16992
  Note: Provider management (create, update, delete) is available in the Admin Panel only.
17386
16993
  `);
17387
- providers.command("list").description("List all providers").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").option("-t, --type <type>", "Filter by provider type").action(async (options) => {
16994
+ providers.command("list").description("List all providers").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").option("-t, --type <type>", "Filter by provider type").addHelpText("after", `
16995
+ Examples:
16996
+ ${chalk11.dim("$")} mutagent providers list
16997
+ ${chalk11.dim("$")} mutagent providers list --type openai
16998
+ ${chalk11.dim("$")} mutagent providers list --json
16999
+ `).action(async (options) => {
17388
17000
  const isJson = getJsonFlag(providers);
17389
17001
  const output = new OutputFormatter(isJson ? "json" : "table");
17390
17002
  try {
@@ -17416,7 +17028,11 @@ Note: Provider management (create, update, delete) is available in the Admin Pan
17416
17028
  handleError(error, isJson);
17417
17029
  }
17418
17030
  });
17419
- providers.command("get").description("Get provider details").argument("<id>", "Provider ID").action(async (id) => {
17031
+ providers.command("get").description("Get provider details").argument("<id>", "Provider ID").addHelpText("after", `
17032
+ Examples:
17033
+ ${chalk11.dim("$")} mutagent providers get <provider-id>
17034
+ ${chalk11.dim("$")} mutagent providers get <provider-id> --json
17035
+ `).action(async (id) => {
17420
17036
  const isJson = getJsonFlag(providers);
17421
17037
  const output = new OutputFormatter(isJson ? "json" : "table");
17422
17038
  try {
@@ -17441,7 +17057,13 @@ Note: Provider management (create, update, delete) is available in the Admin Pan
17441
17057
  handleError(error, isJson);
17442
17058
  }
17443
17059
  });
17444
- providers.command("test").description("Test provider connectivity").argument("<id>", "Provider ID").action(async (id) => {
17060
+ providers.command("test").description("Test provider connectivity").argument("<id>", "Provider ID").addHelpText("after", `
17061
+ Examples:
17062
+ ${chalk11.dim("$")} mutagent providers test <provider-id>
17063
+ ${chalk11.dim("$")} mutagent providers test <provider-id> --json
17064
+
17065
+ ${chalk11.dim("Tests connectivity and lists available models for the provider.")}
17066
+ `).action(async (id) => {
17445
17067
  const isJson = getJsonFlag(providers);
17446
17068
  const output = new OutputFormatter(isJson ? "json" : "table");
17447
17069
  try {
@@ -17478,22 +17100,44 @@ Available Models:`));
17478
17100
  }
17479
17101
 
17480
17102
  // src/bin/cli.ts
17103
+ var cliVersion = "0.1.1";
17104
+ try {
17105
+ const __dirname2 = dirname(fileURLToPath(import.meta.url));
17106
+ const pkgPath = join2(__dirname2, "..", "..", "package.json");
17107
+ const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
17108
+ cliVersion = pkg.version ?? cliVersion;
17109
+ } catch {}
17481
17110
  var program = new Command11;
17482
- program.name("mutagent").description("MutagenT CLI - AI-native prompt optimization platform").version("0.1.0").option("--json", "Output results as JSON (for AI agents)").option("--api-key <key>", "MutagenT API key").option("--endpoint <url>", "MutagenT server endpoint").configureHelp({
17111
+ program.name("mutagent").description(`MutagenT CLI - AI-native prompt optimization platform
17112
+
17113
+ Documentation: https://docs.mutagent.io/cli
17114
+ Dashboard: https://app.mutagent.io`).version(cliVersion).option("--json", "Output results as JSON (for AI agents)").option("--api-key <key>", "MutagenT API key").option("--endpoint <url>", "MutagenT server endpoint").option("--non-interactive", "Disable interactive prompts (for CI/AI agents)").configureHelp({
17483
17115
  sortSubcommands: true,
17484
17116
  showGlobalOptions: true
17485
17117
  });
17486
17118
  program.addHelpText("afterAll", `
17487
- ${chalk12.cyan("\u250C\u2500 \uD83E\uDD16 AI AGENT INTEGRATION HINT \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510")}
17488
- ${chalk12.cyan("\u2502")} ${chalk12.cyan("\u2502")}
17489
- ${chalk12.cyan("\u2502")} Frameworks: mastra, langchain, langgraph, vercel-ai, claude-code, generic ${chalk12.cyan("\u2502")}
17490
- ${chalk12.cyan("\u2502")} ${chalk12.cyan("\u2502")}
17491
- ${chalk12.cyan("\u2502")} Get integration guide: mutagent integrate <framework> ${chalk12.cyan("\u2502")}
17492
- ${chalk12.cyan("\u2502")} Verify setup: mutagent integrate <framework> --verify ${chalk12.cyan("\u2502")}
17493
- ${chalk12.cyan("\u2502")} Use --json for AI parsing: mutagent <command> --json ${chalk12.cyan("\u2502")}
17494
- ${chalk12.cyan("\u2502")} ${chalk12.cyan("\u2502")}
17495
- ${chalk12.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}
17119
+ ${chalk12.cyan("┌─ \uD83E\uDD16 AI AGENT INTEGRATION HINT ────────────────────────────────────────────┐")}
17120
+ ${chalk12.cyan("")} ${chalk12.cyan("")}
17121
+ ${chalk12.cyan("")} Frameworks: mastra, langchain, langgraph, vercel-ai, claude-code, generic ${chalk12.cyan("")}
17122
+ ${chalk12.cyan("")} ${chalk12.cyan("")}
17123
+ ${chalk12.cyan("")} Get integration guide: mutagent integrate <framework> ${chalk12.cyan("")}
17124
+ ${chalk12.cyan("")} Verify setup: mutagent integrate <framework> --verify ${chalk12.cyan("")}
17125
+ ${chalk12.cyan("")} Use --json for AI parsing: mutagent <command> --json ${chalk12.cyan("")}
17126
+ ${chalk12.cyan("")} ${chalk12.cyan("")}
17127
+ ${chalk12.cyan("└───────────────────────────────────────────────────────────────────────────┘")}
17496
17128
  `);
17129
+ program.hook("preAction", (thisCommand) => {
17130
+ const globalOpts = thisCommand.optsWithGlobals();
17131
+ if (globalOpts.apiKey && !process.env.MUTAGENT_API_KEY) {
17132
+ process.env.MUTAGENT_API_KEY = globalOpts.apiKey;
17133
+ }
17134
+ if (globalOpts.endpoint && !process.env.MUTAGENT_ENDPOINT) {
17135
+ process.env.MUTAGENT_ENDPOINT = globalOpts.endpoint;
17136
+ }
17137
+ if (globalOpts.nonInteractive || process.env.CI === "true") {
17138
+ process.env.MUTAGENT_NON_INTERACTIVE = "true";
17139
+ }
17140
+ });
17497
17141
  program.addCommand(createLoginCommand());
17498
17142
  program.addCommand(createAuthCommand());
17499
17143
  program.addCommand(createConfigCommand());
@@ -17506,5 +17150,5 @@ program.addCommand(createWorkspacesCommand());
17506
17150
  program.addCommand(createProvidersCommand());
17507
17151
  program.parse();
17508
17152
 
17509
- //# debugId=88C0764D59EF3CC264756E2164756E21
17153
+ //# debugId=478A37FBB111956764756E2164756E21
17510
17154
  //# sourceMappingURL=cli.js.map