@evalops/maestro 0.10.16 → 0.10.17

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/cli.js CHANGED
@@ -37563,16 +37563,16 @@ import { WebSocketServer } from "ws";
37563
37563
  import { realpath as realpath3, stat as stat8 } from "node:fs/promises";
37564
37564
  import { resolve as resolve58 } from "node:path";
37565
37565
  import chalk60 from "chalk";
37566
+ import chalk61 from "chalk";
37567
+ import chalk62 from "chalk";
37566
37568
  import { existsSync as existsSync103, mkdirSync as mkdirSync40, readFileSync as readFileSync75, writeFileSync as writeFileSync41 } from "node:fs";
37567
37569
  import { join as join82 } from "node:path";
37568
- import chalk61 from "chalk";
37570
+ import chalk63 from "chalk";
37569
37571
  import { timingSafeEqual as timingSafeEqual7 } from "node:crypto";
37570
37572
  import {
37571
37573
  createServer as createServer7
37572
37574
  } from "node:http";
37573
37575
  import { URL as URL2 } from "node:url";
37574
- import chalk62 from "chalk";
37575
- import chalk63 from "chalk";
37576
37576
  import chalk64 from "chalk";
37577
37577
  import chalk65 from "chalk";
37578
37578
  import { createInterface as createInterface2 } from "node:readline/promises";
@@ -38029,11 +38029,9 @@ var Logger = class {
38029
38029
  }
38030
38030
  }
38031
38031
  outputJson(entry2) {
38032
- const output = entry2.level === "error" ? console.error : console.log;
38033
- output(JSON.stringify(entry2));
38032
+ console.error(JSON.stringify(entry2));
38034
38033
  }
38035
38034
  outputPretty(entry2) {
38036
- const output = entry2.level === "error" ? console.error : console.log;
38037
38035
  const parts = [];
38038
38036
  if (this.config.timestamps) {
38039
38037
  parts.push(`[${entry2.timestamp}]`);
@@ -38043,9 +38041,9 @@ var Logger = class {
38043
38041
  if (entry2.context && Object.keys(entry2.context).length > 0) {
38044
38042
  parts.push(JSON.stringify(entry2.context));
38045
38043
  }
38046
- output(parts.join(" "));
38044
+ console.error(parts.join(" "));
38047
38045
  if (entry2.error?.stack) {
38048
- output(entry2.error.stack);
38046
+ console.error(entry2.error.stack);
38049
38047
  }
38050
38048
  }
38051
38049
  debug(message, context2) {
@@ -170440,6 +170438,223 @@ Environment:
170440
170438
  MAESTRO_ATTACH_AUDIENCE`;
170441
170439
  var init_hosted_runner = () => {
170442
170440
  };
170441
+ var exports_init = {};
170442
+ __export2(exports_init, {
170443
+ parseInitArgs: () => parseInitArgs,
170444
+ handleInitCommand: () => handleInitCommand2,
170445
+ formatInitSuccess: () => formatInitSuccess,
170446
+ formatInitHelp: () => formatInitHelp
170447
+ });
170448
+ function formatInitHelp() {
170449
+ return `${sectionHeading("maestro init")}${muted(` maestro init Login, create or reuse an API key, and register this agent
170450
+ maestro init --rotate-key Replace the stored agent MCP API key
170451
+ maestro init --mcp-url <url> Override the EvalOps agent MCP endpoint
170452
+ maestro init --json Emit machine-readable bootstrap output
170453
+
170454
+ Options
170455
+ --agent-type <type> Agent type to register, defaults to maestro
170456
+ --surface <surface> Surface to register, defaults to cli
170457
+ --integration-profile <profile> mcp_only, mcp_otlp, managed_runtime, sdk_integrated, or provider_proxy
170458
+ --shim-type <type> native_mcp, command_wrapper, hook, provider_proxy, sdk, or mcp_firewall_proxy
170459
+ --trace-mode <mode> none, mcp_events, or otlp
170460
+ --memory-mode <mode> none, read_only, durable, or cerebro
170461
+ --runtime-owner <owner> external or evalops
170462
+ --workspace, --workspace-id <id> Workspace to associate with the registration
170463
+ --scope <scope[,scope...]> Registration scopes to request
170464
+ --key-scope <scope[,scope...]> API key scopes to request
170465
+ --expires-in-days <days> API key TTL in days
170466
+ --force-login Re-run EvalOps OAuth before bootstrapping
170467
+ --manifest-url <url> Override the agent MCP manifest URL
170468
+ --ttl-seconds <seconds> Registration TTL in seconds`)}`;
170469
+ }
170470
+ function readValue(args, index2, flag) {
170471
+ const value = args[index2 + 1];
170472
+ if (!value || value.startsWith("-")) {
170473
+ throw new Error(`${flag} requires a value`);
170474
+ }
170475
+ return value;
170476
+ }
170477
+ function parsePositiveInteger(value, flag) {
170478
+ const parsed = Number.parseInt(value, 10);
170479
+ if (!Number.isInteger(parsed) || parsed <= 0) {
170480
+ throw new Error(`${flag} must be a positive integer`);
170481
+ }
170482
+ return parsed;
170483
+ }
170484
+ function appendScopes(existing, value) {
170485
+ return [
170486
+ ...existing ?? [],
170487
+ ...value.split(",").map((entry2) => entry2.trim()).filter((entry2) => entry2.length > 0)
170488
+ ];
170489
+ }
170490
+ function parseInitArgs(args) {
170491
+ const options = {};
170492
+ for (let i2 = 0; i2 < args.length; i2++) {
170493
+ const arg = args[i2];
170494
+ switch (arg) {
170495
+ case "--agent-mcp-url":
170496
+ case "--mcp-url":
170497
+ options.mcpUrl = readValue(args, i2, arg);
170498
+ i2++;
170499
+ break;
170500
+ case "--agent-type":
170501
+ options.agentType = readValue(args, i2, arg);
170502
+ i2++;
170503
+ break;
170504
+ case "--api-key-scope":
170505
+ case "--key-scope":
170506
+ options.apiKeyScopes = appendScopes(options.apiKeyScopes, readValue(args, i2, arg));
170507
+ i2++;
170508
+ break;
170509
+ case "--expires-in-days":
170510
+ options.expiresInDays = parsePositiveInteger(readValue(args, i2, arg), arg);
170511
+ i2++;
170512
+ break;
170513
+ case "--force-login":
170514
+ options.forceLogin = true;
170515
+ break;
170516
+ case "--integration-profile":
170517
+ options.integrationProfile = readValue(args, i2, arg);
170518
+ i2++;
170519
+ break;
170520
+ case "--json":
170521
+ options.json = true;
170522
+ break;
170523
+ case "--key-name":
170524
+ options.keyName = readValue(args, i2, arg);
170525
+ i2++;
170526
+ break;
170527
+ case "--manifest-url":
170528
+ options.manifestUrl = readValue(args, i2, arg);
170529
+ i2++;
170530
+ break;
170531
+ case "--memory-mode":
170532
+ options.memoryMode = readValue(args, i2, arg);
170533
+ i2++;
170534
+ break;
170535
+ case "--register-scope":
170536
+ case "--scope":
170537
+ options.registerScopes = appendScopes(options.registerScopes, readValue(args, i2, arg));
170538
+ i2++;
170539
+ break;
170540
+ case "--rotate-key":
170541
+ options.rotateKey = true;
170542
+ break;
170543
+ case "--runtime-owner":
170544
+ options.runtimeOwner = readValue(args, i2, arg);
170545
+ i2++;
170546
+ break;
170547
+ case "--shim-type":
170548
+ options.shimType = readValue(args, i2, arg);
170549
+ i2++;
170550
+ break;
170551
+ case "--surface":
170552
+ options.surface = readValue(args, i2, arg);
170553
+ i2++;
170554
+ break;
170555
+ case "--trace-mode":
170556
+ options.traceMode = readValue(args, i2, arg);
170557
+ i2++;
170558
+ break;
170559
+ case "--ttl-seconds":
170560
+ options.ttlSeconds = parsePositiveInteger(readValue(args, i2, arg), arg);
170561
+ i2++;
170562
+ break;
170563
+ case "--workspace":
170564
+ case "--workspace-id":
170565
+ options.workspaceId = readValue(args, i2, arg);
170566
+ i2++;
170567
+ break;
170568
+ default:
170569
+ if (arg?.startsWith("-")) {
170570
+ throw new Error(`Unknown maestro init option: ${arg}`);
170571
+ }
170572
+ throw new Error(`Unexpected maestro init argument: ${arg}`);
170573
+ }
170574
+ }
170575
+ return options;
170576
+ }
170577
+ function checkLine(text2) {
170578
+ return `${chalk61.green("\u2713")} ${text2}`;
170579
+ }
170580
+ function formatInitSuccess(result) {
170581
+ const keyMode = result.apiKeyCreated ? "Created" : "Reused";
170582
+ const authenticatedAs = result.authenticatedAs ?? "EvalOps";
170583
+ const governedActions = result.governedActionsLoaded ?? 0;
170584
+ const lines = [
170585
+ chalk61.bold("EvalOps Maestro bootstrap"),
170586
+ "",
170587
+ checkLine(`Authenticated as ${authenticatedAs}`),
170588
+ checkLine(`${keyMode} managed inference key`),
170589
+ checkLine("Registered local agent runtime"),
170590
+ checkLine(`Integration profile ${result.integrationProfile ?? "managed_runtime"} via ${result.shimType ?? "sdk"}`),
170591
+ checkLine(`Loaded ${governedActions} governed actions`),
170592
+ checkLine(result.approvalPolicyAttached ? "Attached default approval policy" : "Queued approval policy review"),
170593
+ checkLine(result.traceIngestionStarted ? "Started trace ingestion" : "Requested trace ingestion"),
170594
+ checkLine(result.governedInferenceCheckRan ? "Ran first governed inference check" : "Queued first governed inference check"),
170595
+ checkLine(result.evidenceEventPublished ? "Published evidence event" : "Queued evidence event"),
170596
+ "",
170597
+ "Open console:",
170598
+ result.consoleUrl ?? "https://app.evalops.dev/overview?env=production"
170599
+ ];
170600
+ return lines.join(`
170601
+ `);
170602
+ }
170603
+ async function handleInitCommand2(args = []) {
170604
+ if (args.includes("--help") || args.includes("-h")) {
170605
+ console.log(formatInitHelp());
170606
+ return;
170607
+ }
170608
+ let options;
170609
+ try {
170610
+ options = parseInitArgs(args);
170611
+ } catch (error) {
170612
+ console.error(chalk61.red(error instanceof Error ? error.message : String(error)));
170613
+ process.exit(1);
170614
+ }
170615
+ const result = await bootstrapEvalOpsAgent(options, {
170616
+ onAuthUrl: (url) => {
170617
+ if (options.json) {
170618
+ console.error("Open this URL in your browser to authenticate with EvalOps:");
170619
+ console.error(url);
170620
+ return;
170621
+ }
170622
+ console.log(chalk61.yellow("Open this URL in your browser to authenticate with EvalOps:"));
170623
+ console.log(chalk61.underline(url));
170624
+ },
170625
+ onStatus: (status) => {
170626
+ if (options.json) {
170627
+ console.error(status.message);
170628
+ return;
170629
+ }
170630
+ console.log(chalk61.dim(status.message));
170631
+ }
170632
+ });
170633
+ if (options.json) {
170634
+ console.log(JSON.stringify(result, null, 2));
170635
+ return;
170636
+ }
170637
+ console.log(formatInitSuccess(result));
170638
+ }
170639
+ var init_init = __esm2(() => {
170640
+ init_agent_bootstrap();
170641
+ init_theme2();
170642
+ });
170643
+ var exports_status = {};
170644
+ __export2(exports_status, {
170645
+ handleStatusCommand: () => handleStatusCommand
170646
+ });
170647
+ async function handleStatusCommand() {
170648
+ const context2 = resolveManagedEvalOpsContext();
170649
+ console.log(chalk62.bold("Maestro status"));
170650
+ console.log(formatManagedEvalOpsStatus(context2));
170651
+ if (!context2.authenticated) {
170652
+ console.log(chalk62.dim('Run "maestro init" to bring EvalOps managed mode online.'));
170653
+ }
170654
+ }
170655
+ var init_status4 = __esm2(() => {
170656
+ init_managed_context();
170657
+ });
170443
170658
  var exports_config = {};
170444
170659
  __export2(exports_config, {
170445
170660
  handleConfigValidate: () => handleConfigValidate,
@@ -170609,7 +170824,7 @@ function buildConfigShowSections(inspection, options) {
170609
170824
  output.push(badge(`Providers (${inspection.providers.length})`, void 0, "info"));
170610
170825
  for (const provider of inspection.providers) {
170611
170826
  const isOverrideOnly = provider.modelCount === 0;
170612
- const heading2 = `${chalk61.cyan(provider.id)} ${muted(`(${provider.modelCount} models)`)}`;
170827
+ const heading2 = `${chalk63.cyan(provider.id)} ${muted(`(${provider.modelCount} models)`)}`;
170613
170828
  const enabledBadge = provider.enabled ? badge("enabled", void 0, "success") : badge("disabled", void 0, "warn");
170614
170829
  const metaBadges = [];
170615
170830
  if (isOverrideOnly) {
@@ -170664,7 +170879,7 @@ function buildConfigShowSections(inspection, options) {
170664
170879
  for (const envVar of inspection.envVars) {
170665
170880
  const status = envVar.set ? badge("set", void 0, "success") : badge("missing", void 0, "warn");
170666
170881
  const value = envVar.maskedValue ? envVar.maskedValue : "(not set)";
170667
- output.push(` ${status} ${chalk61.cyan(envVar.name)}: ${muted(value)}`);
170882
+ output.push(` ${status} ${chalk63.cyan(envVar.name)}: ${muted(value)}`);
170668
170883
  }
170669
170884
  output.push("");
170670
170885
  }
@@ -170688,14 +170903,14 @@ async function handleConfigValidate() {
170688
170903
  if (result.errors.length > 0) {
170689
170904
  console.log(badge("[ERROR] Errors", void 0, "danger"));
170690
170905
  for (const error of result.errors) {
170691
- console.log(chalk61.red(` \u2022 ${error}`));
170906
+ console.log(chalk63.red(` \u2022 ${error}`));
170692
170907
  }
170693
170908
  console.log();
170694
170909
  }
170695
170910
  if (result.warnings.length > 0) {
170696
170911
  console.log(badge("[WARN] Warnings", void 0, "warn"));
170697
170912
  for (const warning of result.warnings) {
170698
- console.log(chalk61.yellow(` \u2022 ${warning}`));
170913
+ console.log(chalk63.yellow(` \u2022 ${warning}`));
170699
170914
  }
170700
170915
  console.log();
170701
170916
  }
@@ -170729,7 +170944,7 @@ function renderConfigShowLegacy(inspection, hierarchy, homeDir) {
170729
170944
  console.log(badge(`Providers (${inspection.providers.length})`, void 0, "info"));
170730
170945
  for (const provider of inspection.providers) {
170731
170946
  const isOverrideOnly = provider.modelCount === 0;
170732
- const heading2 = `${chalk61.cyan(provider.id)} ${muted(`(${provider.modelCount} models)`)}`;
170947
+ const heading2 = `${chalk63.cyan(provider.id)} ${muted(`(${provider.modelCount} models)`)}`;
170733
170948
  const enabledBadge = provider.enabled ? badge("enabled", void 0, "success") : badge("disabled", void 0, "warn");
170734
170949
  const metaBadges = [];
170735
170950
  if (isOverrideOnly) {
@@ -170785,7 +171000,7 @@ function renderConfigShowLegacy(inspection, hierarchy, homeDir) {
170785
171000
  for (const envVar of inspection.envVars) {
170786
171001
  const status = envVar.set ? badge("set", void 0, "success") : badge("missing", void 0, "warn");
170787
171002
  const value = envVar.maskedValue ? envVar.maskedValue : "(not set)";
170788
- console.log(` ${status} ${chalk61.cyan(envVar.name)}: ${muted(value)}`);
171003
+ console.log(` ${status} ${chalk63.cyan(envVar.name)}: ${muted(value)}`);
170789
171004
  }
170790
171005
  console.log();
170791
171006
  }
@@ -170822,7 +171037,7 @@ async function handleConfigInit() {
170822
171037
  const configPath2 = join82(configDir, "config.json");
170823
171038
  const promptsDir = join82(configDir, "prompts");
170824
171039
  if (existsSync103(configPath2)) {
170825
- const overwrite = await rl.question(chalk61.yellow(`Config already exists at ${configPath2}. Overwrite? (y/N): `));
171040
+ const overwrite = await rl.question(chalk63.yellow(`Config already exists at ${configPath2}. Overwrite? (y/N): `));
170826
171041
  if (overwrite.toLowerCase() !== "y") {
170827
171042
  console.log(muted(`
170828
171043
  Cancelled.`));
@@ -170836,23 +171051,23 @@ Cancelled.`));
170836
171051
  console.log(`
170837
171052
  ${badge("1. Choose your provider", void 0, "info")}`);
170838
171053
  providerPresets.forEach((preset2, idx) => {
170839
- const note = preset2.note ? chalk61.dim(` \u2014 ${preset2.note}`) : "";
171054
+ const note = preset2.note ? chalk63.dim(` \u2014 ${preset2.note}`) : "";
170840
171055
  console.log(` ${idx + 1}) ${preset2.name}${note}`);
170841
171056
  });
170842
171057
  let preset;
170843
171058
  if (presetId) {
170844
171059
  const found = providerPresets.find((p) => p.id.toLowerCase() === presetId.toLowerCase());
170845
171060
  if (!found) {
170846
- console.log(chalk61.yellow(`
171061
+ console.log(chalk63.yellow(`
170847
171062
  Unknown preset "${presetId}", falling back to menu selection.`));
170848
171063
  } else {
170849
171064
  preset = found;
170850
- console.log(chalk61.green(`
171065
+ console.log(chalk63.green(`
170851
171066
  Using preset: ${preset.name}`));
170852
171067
  }
170853
171068
  }
170854
171069
  if (!preset) {
170855
- const providerChoice = await rl.question(chalk61.cyan(`
171070
+ const providerChoice = await rl.question(chalk63.cyan(`
170856
171071
  Provider (1-${providerPresets.length}): `));
170857
171072
  const presetIndex = Number.parseInt(providerChoice.trim(), 10) - 1 >= 0 && Number.parseInt(providerChoice.trim(), 10) - 1 < providerPresets.length ? Number.parseInt(providerChoice.trim(), 10) - 1 : 0;
170858
171073
  preset = providerPresets[presetIndex] ?? providerPresets[0];
@@ -170875,17 +171090,17 @@ Provider (1-${providerPresets.length}): `));
170875
171090
  ${badge("2. How would you like to provide your API key?", void 0, "info")}`);
170876
171091
  console.log(" 1) Environment variable (recommended)");
170877
171092
  console.log(" 2) Direct in config (not recommended)");
170878
- const keyChoice = await rl.question(chalk61.cyan(`
171093
+ const keyChoice = await rl.question(chalk63.cyan(`
170879
171094
  Choice (1-2): `));
170880
171095
  useEnv = keyChoice.trim() !== "2";
170881
171096
  if (useEnv) {
170882
171097
  const fallbackEnv = getEnvVarsForProvider(providerId)[0] ?? `${providerId.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_API_KEY`;
170883
171098
  const envVarName = preset.apiKeyEnv ?? fallbackEnv;
170884
171099
  apiKeyField = { apiKeyEnv: envVarName };
170885
- console.log(chalk61.dim(`
171100
+ console.log(chalk63.dim(`
170886
171101
  Using environment variable: ${envVarName}`));
170887
171102
  } else {
170888
- const apiKey = await rl.question(chalk61.cyan(`
171103
+ const apiKey = await rl.question(chalk63.cyan(`
170889
171104
  Enter API key: `));
170890
171105
  apiKeyField = { apiKey: apiKey.trim() };
170891
171106
  }
@@ -170894,12 +171109,12 @@ Enter API key: `));
170894
171109
  const noKeyMessage = isEvalOpsManagedProvider(providerId) ? `
170895
171110
  Managed gateway preset does not use a local API key. Run maestro evalops login after setup.` : `
170896
171111
  Local providers do not require API keys. Skipping step.`;
170897
- console.log(chalk61.dim(noKeyMessage));
171112
+ console.log(chalk63.dim(noKeyMessage));
170898
171113
  }
170899
171114
  console.log(`
170900
171115
  ${badge("3. Would you like to use file references for prompts?", void 0, "info")}`);
170901
171116
  console.log(" This creates a prompts/ folder for better organization.");
170902
- const useFiles = await rl.question(chalk61.cyan(`
171117
+ const useFiles = await rl.question(chalk63.cyan(`
170903
171118
  Use file references? (Y/n): `));
170904
171119
  const createPrompts = useFiles.toLowerCase() !== "n";
170905
171120
  mkdirSync40(configDir, { recursive: true });
@@ -171042,11 +171257,11 @@ async function checkLocalEndpoint(name, baseUrl) {
171042
171257
  url.pathname = "/models";
171043
171258
  const response = await fetch(url.toString(), { method: "GET" });
171044
171259
  if (response.ok) {
171045
- return `${badge(name, void 0, "success")} ${chalk61.dim(`responded with ${response.status}`)}`;
171260
+ return `${badge(name, void 0, "success")} ${chalk63.dim(`responded with ${response.status}`)}`;
171046
171261
  }
171047
- return `${badge(name, void 0, "warn")} ${chalk61.dim(`HTTP ${response.status}`)}`;
171262
+ return `${badge(name, void 0, "warn")} ${chalk63.dim(`HTTP ${response.status}`)}`;
171048
171263
  } catch (error) {
171049
- return `${badge(name, void 0, "danger")} ${chalk61.dim(error instanceof Error ? error.message : String(error))}`;
171264
+ return `${badge(name, void 0, "danger")} ${chalk63.dim(error instanceof Error ? error.message : String(error))}`;
171050
171265
  }
171051
171266
  }
171052
171267
  async function handleConfigLocal() {
@@ -171061,7 +171276,7 @@ async function handleConfigLocal() {
171061
171276
  console.log(" 2) Add Ollama provider");
171062
171277
  console.log(" 3) Check local endpoints");
171063
171278
  console.log(" 4) Cancel");
171064
- const choice = (await rl.question(chalk61.cyan(`
171279
+ const choice = (await rl.question(chalk63.cyan(`
171065
171280
  Choice (1-4): `))).trim();
171066
171281
  if (choice === "4") {
171067
171282
  console.log(muted(`
@@ -171085,12 +171300,12 @@ Cancelled.`));
171085
171300
  const templateKey = choice === "2" ? "ollama" : "lmstudio";
171086
171301
  const template = LOCAL_PROVIDER_TEMPLATES[templateKey];
171087
171302
  if (!template) {
171088
- console.log(chalk61.red(`
171303
+ console.log(chalk63.red(`
171089
171304
  Unknown template: ${templateKey}`));
171090
171305
  rl.close();
171091
171306
  return;
171092
171307
  }
171093
- const scope = (await rl.question(chalk61.cyan(`
171308
+ const scope = (await rl.question(chalk63.cyan(`
171094
171309
  Save provider to:
171095
171310
  1) Project (.maestro/local.json)
171096
171311
  2) Home (~/.maestro/local.json)
@@ -171100,14 +171315,14 @@ Choice (1-2): `))).trim();
171100
171315
  mkdirSync40(targetDir, { recursive: true });
171101
171316
  const localPath = join82(targetDir, "local.json");
171102
171317
  const config2 = loadLocalConfig(localPath);
171103
- const providerId = (await rl.question(chalk61.cyan(`
171318
+ const providerId = (await rl.question(chalk63.cyan(`
171104
171319
  Provider id (${template.id}): `))).trim() || template.id;
171105
- const providerName = (await rl.question(chalk61.cyan(`Provider name (${template.name}): `))).trim() || template.name;
171106
- const baseUrl = (await rl.question(chalk61.cyan(`Base URL (${template.baseUrl}): `))).trim() || template.baseUrl;
171107
- const modelId = (await rl.question(chalk61.cyan(`Model id (${template.model.id}): `))).trim() || template.model.id;
171108
- const modelName = (await rl.question(chalk61.cyan(`Model name (${template.model.name}): `))).trim() || template.model.name;
171109
- const contextWindowAnswer = (await rl.question(chalk61.cyan(`Context window (${template.model.contextWindow}): `))).trim();
171110
- const maxTokensAnswer = (await rl.question(chalk61.cyan(`Max output tokens (${template.model.maxTokens}): `))).trim();
171320
+ const providerName = (await rl.question(chalk63.cyan(`Provider name (${template.name}): `))).trim() || template.name;
171321
+ const baseUrl = (await rl.question(chalk63.cyan(`Base URL (${template.baseUrl}): `))).trim() || template.baseUrl;
171322
+ const modelId = (await rl.question(chalk63.cyan(`Model id (${template.model.id}): `))).trim() || template.model.id;
171323
+ const modelName = (await rl.question(chalk63.cyan(`Model name (${template.model.name}): `))).trim() || template.model.name;
171324
+ const contextWindowAnswer = (await rl.question(chalk63.cyan(`Context window (${template.model.contextWindow}): `))).trim();
171325
+ const maxTokensAnswer = (await rl.question(chalk63.cyan(`Max output tokens (${template.model.maxTokens}): `))).trim();
171111
171326
  const contextWindow = Number.parseInt(contextWindowAnswer, 10) || template.model.contextWindow;
171112
171327
  const maxTokens = Number.parseInt(maxTokensAnswer, 10) || template.model.maxTokens;
171113
171328
  upsertLocalProvider(config2, template, {
@@ -171151,7 +171366,7 @@ function formatModelLabel2(model) {
171151
171366
  if (model.input?.includes("image")) {
171152
171367
  caps.push("vision");
171153
171368
  }
171154
- const suffix = caps.length ? ` ${chalk61.dim(`[${caps.join(", ")}]`)}` : "";
171369
+ const suffix = caps.length ? ` ${chalk63.dim(`[${caps.join(", ")}]`)}` : "";
171155
171370
  return `${model.id}${suffix}`;
171156
171371
  }
171157
171372
  var ANSI_STRING_TERMINATORS3 = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
@@ -171213,15 +171428,15 @@ async function handleOpenAICommand(subcommand, _params = []) {
171213
171428
  await handleStatus2();
171214
171429
  return;
171215
171430
  default:
171216
- console.error(chalk62.red('Unknown openai subcommand. Try "maestro openai login", "logout", or "status".'));
171431
+ console.error(chalk64.red('Unknown openai subcommand. Try "maestro openai login", "logout", or "status".'));
171217
171432
  process.exit(1);
171218
171433
  }
171219
171434
  }
171220
171435
  async function handleLogin2() {
171221
- console.log(chalk62.bold("Maestro OpenAI Login"));
171436
+ console.log(chalk64.bold("Maestro OpenAI Login"));
171222
171437
  const { url, verifier, state: state2 } = await generateOpenAILoginUrl();
171223
- console.log(chalk62.yellow("Please open the following URL in your browser to authenticate:"));
171224
- console.log(chalk62.underline(url));
171438
+ console.log(chalk64.yellow("Please open the following URL in your browser to authenticate:"));
171439
+ console.log(chalk64.underline(url));
171225
171440
  const server = createServer7(async (req, res) => {
171226
171441
  const reqUrl = new URL2(req.url ?? "", CALLBACK_ORIGIN4);
171227
171442
  if (reqUrl.pathname === "/auth/callback") {
@@ -171258,12 +171473,12 @@ async function handleLogin2() {
171258
171473
  });
171259
171474
  res.writeHead(200, { "Content-Type": "text/html" });
171260
171475
  res.end("<html><body><h1>Login Successful</h1><p>You can close this tab and return to the terminal.</p></body></html>");
171261
- console.log(chalk62.green(`
171476
+ console.log(chalk64.green(`
171262
171477
  OpenAI credentials saved successfully.`));
171263
- console.log(chalk62.dim("Future runs can use --auth auto (default) or provide an OpenAI API key."));
171478
+ console.log(chalk64.dim("Future runs can use --auth auto (default) or provide an OpenAI API key."));
171264
171479
  } catch (error) {
171265
171480
  const errorMsg = error instanceof Error ? error.message : "Unknown error";
171266
- console.error(chalk62.red(`
171481
+ console.error(chalk64.red(`
171267
171482
  Login failed: ${errorMsg}`));
171268
171483
  res.writeHead(500, { "Content-Type": "text/plain" });
171269
171484
  res.end("Login failed. Check terminal for details.");
@@ -171277,32 +171492,32 @@ Login failed: ${errorMsg}`));
171277
171492
  });
171278
171493
  server.on("error", (e2) => {
171279
171494
  if (e2.code === "EADDRINUSE") {
171280
- console.error(chalk62.red(`Port ${DEFAULT_PORT} is already in use. Please close the other process and try again.`));
171495
+ console.error(chalk64.red(`Port ${DEFAULT_PORT} is already in use. Please close the other process and try again.`));
171281
171496
  process.exit(1);
171282
171497
  }
171283
- console.error(chalk62.red(`Server error: ${e2.message}`));
171498
+ console.error(chalk64.red(`Server error: ${e2.message}`));
171284
171499
  process.exit(1);
171285
171500
  });
171286
171501
  server.listen(DEFAULT_PORT, "127.0.0.1");
171287
171502
  }
171288
171503
  async function handleLogout() {
171289
171504
  await deleteOpenAIOAuthCredential();
171290
- console.log(chalk62.green("Removed stored OpenAI credentials."));
171505
+ console.log(chalk64.green("Removed stored OpenAI credentials."));
171291
171506
  }
171292
171507
  async function handleStatus2() {
171293
171508
  const stored = await getStoredOpenAIOAuthCredential();
171294
171509
  if (!stored) {
171295
- console.log(chalk62.yellow("No stored OpenAI credentials."));
171296
- console.log(chalk62.dim('Run "maestro openai login" to authenticate with OpenAI.'));
171510
+ console.log(chalk64.yellow("No stored OpenAI credentials."));
171511
+ console.log(chalk64.dim('Run "maestro openai login" to authenticate with OpenAI.'));
171297
171512
  return;
171298
171513
  }
171299
171514
  const remainingMs = Math.max(0, stored.expiresAt - Date.now());
171300
171515
  const minutes = Math.round(remainingMs / 6e4);
171301
- console.log(chalk62.green("Stored OpenAI credentials detected."));
171302
- console.log(chalk62.dim(`Access token expires in ~${minutes} minute${minutes === 1 ? "" : "s"} (auto-refresh enabled).`));
171516
+ console.log(chalk64.green("Stored OpenAI credentials detected."));
171517
+ console.log(chalk64.dim(`Access token expires in ~${minutes} minute${minutes === 1 ? "" : "s"} (auto-refresh enabled).`));
171303
171518
  const fresh = await getFreshOpenAIOAuthCredential();
171304
171519
  if (fresh) {
171305
- console.log(chalk62.dim("Credentials refreshed."));
171520
+ console.log(chalk64.dim("Credentials refreshed."));
171306
171521
  }
171307
171522
  }
171308
171523
  var CALLBACK_ORIGIN4;
@@ -171310,208 +171525,6 @@ var init_openai3 = __esm2(() => {
171310
171525
  init_openai_auth();
171311
171526
  CALLBACK_ORIGIN4 = `http://127.0.0.1:${DEFAULT_PORT}`;
171312
171527
  });
171313
- var exports_init = {};
171314
- __export2(exports_init, {
171315
- parseInitArgs: () => parseInitArgs,
171316
- handleInitCommand: () => handleInitCommand2,
171317
- formatInitSuccess: () => formatInitSuccess,
171318
- formatInitHelp: () => formatInitHelp
171319
- });
171320
- function formatInitHelp() {
171321
- return `${sectionHeading("maestro init")}${muted(` maestro init Login, create or reuse an API key, and register this agent
171322
- maestro init --rotate-key Replace the stored agent MCP API key
171323
- maestro init --mcp-url <url> Override the EvalOps agent MCP endpoint
171324
- maestro init --json Emit machine-readable bootstrap output
171325
-
171326
- Options
171327
- --agent-type <type> Agent type to register, defaults to maestro
171328
- --surface <surface> Surface to register, defaults to cli
171329
- --integration-profile <profile> mcp_only, mcp_otlp, managed_runtime, sdk_integrated, or provider_proxy
171330
- --shim-type <type> native_mcp, command_wrapper, hook, provider_proxy, sdk, or mcp_firewall_proxy
171331
- --trace-mode <mode> none, mcp_events, or otlp
171332
- --memory-mode <mode> none, read_only, durable, or cerebro
171333
- --runtime-owner <owner> external or evalops
171334
- --workspace, --workspace-id <id> Workspace to associate with the registration
171335
- --scope <scope[,scope...]> Registration scopes to request
171336
- --key-scope <scope[,scope...]> API key scopes to request
171337
- --expires-in-days <days> API key TTL in days
171338
- --force-login Re-run EvalOps OAuth before bootstrapping
171339
- --manifest-url <url> Override the agent MCP manifest URL
171340
- --ttl-seconds <seconds> Registration TTL in seconds`)}`;
171341
- }
171342
- function readValue(args, index2, flag) {
171343
- const value = args[index2 + 1];
171344
- if (!value || value.startsWith("-")) {
171345
- throw new Error(`${flag} requires a value`);
171346
- }
171347
- return value;
171348
- }
171349
- function parsePositiveInteger(value, flag) {
171350
- const parsed = Number.parseInt(value, 10);
171351
- if (!Number.isInteger(parsed) || parsed <= 0) {
171352
- throw new Error(`${flag} must be a positive integer`);
171353
- }
171354
- return parsed;
171355
- }
171356
- function appendScopes(existing, value) {
171357
- return [
171358
- ...existing ?? [],
171359
- ...value.split(",").map((entry2) => entry2.trim()).filter((entry2) => entry2.length > 0)
171360
- ];
171361
- }
171362
- function parseInitArgs(args) {
171363
- const options = {};
171364
- for (let i2 = 0; i2 < args.length; i2++) {
171365
- const arg = args[i2];
171366
- switch (arg) {
171367
- case "--agent-mcp-url":
171368
- case "--mcp-url":
171369
- options.mcpUrl = readValue(args, i2, arg);
171370
- i2++;
171371
- break;
171372
- case "--agent-type":
171373
- options.agentType = readValue(args, i2, arg);
171374
- i2++;
171375
- break;
171376
- case "--api-key-scope":
171377
- case "--key-scope":
171378
- options.apiKeyScopes = appendScopes(options.apiKeyScopes, readValue(args, i2, arg));
171379
- i2++;
171380
- break;
171381
- case "--expires-in-days":
171382
- options.expiresInDays = parsePositiveInteger(readValue(args, i2, arg), arg);
171383
- i2++;
171384
- break;
171385
- case "--force-login":
171386
- options.forceLogin = true;
171387
- break;
171388
- case "--integration-profile":
171389
- options.integrationProfile = readValue(args, i2, arg);
171390
- i2++;
171391
- break;
171392
- case "--json":
171393
- options.json = true;
171394
- break;
171395
- case "--key-name":
171396
- options.keyName = readValue(args, i2, arg);
171397
- i2++;
171398
- break;
171399
- case "--manifest-url":
171400
- options.manifestUrl = readValue(args, i2, arg);
171401
- i2++;
171402
- break;
171403
- case "--memory-mode":
171404
- options.memoryMode = readValue(args, i2, arg);
171405
- i2++;
171406
- break;
171407
- case "--register-scope":
171408
- case "--scope":
171409
- options.registerScopes = appendScopes(options.registerScopes, readValue(args, i2, arg));
171410
- i2++;
171411
- break;
171412
- case "--rotate-key":
171413
- options.rotateKey = true;
171414
- break;
171415
- case "--runtime-owner":
171416
- options.runtimeOwner = readValue(args, i2, arg);
171417
- i2++;
171418
- break;
171419
- case "--shim-type":
171420
- options.shimType = readValue(args, i2, arg);
171421
- i2++;
171422
- break;
171423
- case "--surface":
171424
- options.surface = readValue(args, i2, arg);
171425
- i2++;
171426
- break;
171427
- case "--trace-mode":
171428
- options.traceMode = readValue(args, i2, arg);
171429
- i2++;
171430
- break;
171431
- case "--ttl-seconds":
171432
- options.ttlSeconds = parsePositiveInteger(readValue(args, i2, arg), arg);
171433
- i2++;
171434
- break;
171435
- case "--workspace":
171436
- case "--workspace-id":
171437
- options.workspaceId = readValue(args, i2, arg);
171438
- i2++;
171439
- break;
171440
- default:
171441
- if (arg?.startsWith("-")) {
171442
- throw new Error(`Unknown maestro init option: ${arg}`);
171443
- }
171444
- throw new Error(`Unexpected maestro init argument: ${arg}`);
171445
- }
171446
- }
171447
- return options;
171448
- }
171449
- function checkLine(text2) {
171450
- return `${chalk63.green("\u2713")} ${text2}`;
171451
- }
171452
- function formatInitSuccess(result) {
171453
- const keyMode = result.apiKeyCreated ? "Created" : "Reused";
171454
- const authenticatedAs = result.authenticatedAs ?? "EvalOps";
171455
- const governedActions = result.governedActionsLoaded ?? 0;
171456
- const lines = [
171457
- chalk63.bold("EvalOps Maestro bootstrap"),
171458
- "",
171459
- checkLine(`Authenticated as ${authenticatedAs}`),
171460
- checkLine(`${keyMode} managed inference key`),
171461
- checkLine("Registered local agent runtime"),
171462
- checkLine(`Integration profile ${result.integrationProfile ?? "managed_runtime"} via ${result.shimType ?? "sdk"}`),
171463
- checkLine(`Loaded ${governedActions} governed actions`),
171464
- checkLine(result.approvalPolicyAttached ? "Attached default approval policy" : "Queued approval policy review"),
171465
- checkLine(result.traceIngestionStarted ? "Started trace ingestion" : "Requested trace ingestion"),
171466
- checkLine(result.governedInferenceCheckRan ? "Ran first governed inference check" : "Queued first governed inference check"),
171467
- checkLine(result.evidenceEventPublished ? "Published evidence event" : "Queued evidence event"),
171468
- "",
171469
- "Open console:",
171470
- result.consoleUrl ?? "https://app.evalops.dev/overview?env=production"
171471
- ];
171472
- return lines.join(`
171473
- `);
171474
- }
171475
- async function handleInitCommand2(args = []) {
171476
- if (args.includes("--help") || args.includes("-h")) {
171477
- console.log(formatInitHelp());
171478
- return;
171479
- }
171480
- let options;
171481
- try {
171482
- options = parseInitArgs(args);
171483
- } catch (error) {
171484
- console.error(chalk63.red(error instanceof Error ? error.message : String(error)));
171485
- process.exit(1);
171486
- }
171487
- const result = await bootstrapEvalOpsAgent(options, {
171488
- onAuthUrl: (url) => {
171489
- if (options.json) {
171490
- console.error("Open this URL in your browser to authenticate with EvalOps:");
171491
- console.error(url);
171492
- return;
171493
- }
171494
- console.log(chalk63.yellow("Open this URL in your browser to authenticate with EvalOps:"));
171495
- console.log(chalk63.underline(url));
171496
- },
171497
- onStatus: (status) => {
171498
- if (options.json) {
171499
- console.error(status.message);
171500
- return;
171501
- }
171502
- console.log(chalk63.dim(status.message));
171503
- }
171504
- });
171505
- if (options.json) {
171506
- console.log(JSON.stringify(result, null, 2));
171507
- return;
171508
- }
171509
- console.log(formatInitSuccess(result));
171510
- }
171511
- var init_init = __esm2(() => {
171512
- init_agent_bootstrap();
171513
- init_theme2();
171514
- });
171515
171528
  var exports_evalops = {};
171516
171529
  __export2(exports_evalops, {
171517
171530
  handleEvalOpsStatus: () => handleEvalOpsStatus,
@@ -171534,58 +171547,43 @@ async function handleEvalOpsCommand(subcommand, args = []) {
171534
171547
  await handleEvalOpsStatus();
171535
171548
  return;
171536
171549
  default:
171537
- console.error(chalk64.red('Unknown evalops subcommand. Try "maestro init" for setup, or "maestro evalops login", "logout", or "status".'));
171550
+ console.error(chalk65.red('Unknown evalops subcommand. Try "maestro init" for setup, or "maestro evalops login", "logout", or "status".'));
171538
171551
  process.exit(1);
171539
171552
  }
171540
171553
  }
171541
171554
  async function handleLogin3() {
171542
- console.log(chalk64.bold("Maestro EvalOps Login"));
171555
+ console.log(chalk65.bold("Maestro EvalOps Login"));
171543
171556
  await login("evalops", {
171544
171557
  onAuthUrl: (url) => {
171545
- console.log(chalk64.yellow("Open this URL in your browser to authenticate with EvalOps:"));
171546
- console.log(chalk64.underline(url));
171558
+ console.log(chalk65.yellow("Open this URL in your browser to authenticate with EvalOps:"));
171559
+ console.log(chalk65.underline(url));
171547
171560
  },
171548
- onStatus: (status) => console.log(chalk64.dim(status))
171561
+ onStatus: (status) => console.log(chalk65.dim(status))
171549
171562
  });
171550
- console.log(chalk64.green("EvalOps credentials saved successfully."));
171551
- console.log(chalk64.dim('Try "maestro --provider evalops --model gpt-4o-mini".'));
171563
+ console.log(chalk65.green("EvalOps credentials saved successfully."));
171564
+ console.log(chalk65.dim('Try "maestro --provider evalops --model gpt-4o-mini".'));
171552
171565
  }
171553
171566
  async function handleLogout2() {
171554
171567
  await logout("evalops");
171555
- console.log(chalk64.green("Removed stored EvalOps credentials."));
171568
+ console.log(chalk65.green("Removed stored EvalOps credentials."));
171556
171569
  }
171557
171570
  async function handleEvalOpsStatus() {
171558
171571
  if (!hasOAuthCredentials("evalops")) {
171559
- console.log(chalk64.yellow("No stored EvalOps credentials."));
171560
- console.log(chalk64.dim('Run "maestro evalops login" to authenticate with EvalOps.'));
171572
+ console.log(chalk65.yellow("No stored EvalOps credentials."));
171573
+ console.log(chalk65.dim('Run "maestro evalops login" to authenticate with EvalOps.'));
171561
171574
  return;
171562
171575
  }
171563
- console.log(chalk64.green("Stored EvalOps credentials detected."));
171576
+ console.log(chalk65.green("Stored EvalOps credentials detected."));
171564
171577
  const context2 = resolveManagedEvalOpsContext();
171565
171578
  console.log(formatManagedEvalOpsStatus(context2));
171566
171579
  if (!context2.managed) {
171567
- console.log(chalk64.yellow('No EvalOps agent session yet. Run "maestro init".'));
171580
+ console.log(chalk65.yellow('No EvalOps agent session yet. Run "maestro init".'));
171568
171581
  }
171569
171582
  }
171570
171583
  var init_evalops2 = __esm2(() => {
171571
171584
  init_managed_context();
171572
171585
  init_oauth();
171573
171586
  });
171574
- var exports_status = {};
171575
- __export2(exports_status, {
171576
- handleStatusCommand: () => handleStatusCommand
171577
- });
171578
- async function handleStatusCommand() {
171579
- const context2 = resolveManagedEvalOpsContext();
171580
- console.log(chalk65.bold("Maestro status"));
171581
- console.log(formatManagedEvalOpsStatus(context2));
171582
- if (!context2.authenticated) {
171583
- console.log(chalk65.dim('Run "maestro init" to bring EvalOps managed mode online.'));
171584
- }
171585
- }
171586
- var init_status4 = __esm2(() => {
171587
- init_managed_context();
171588
- });
171589
171587
  var exports_codex = {};
171590
171588
  __export2(exports_codex, {
171591
171589
  handleCodexCommand: () => handleCodexCommand
@@ -176424,6 +176422,11 @@ async function main(args) {
176424
176422
  console.error(chalk81.red(parsed.error));
176425
176423
  process.exit(1);
176426
176424
  }
176425
+ const exitWithEarlyStartupError = (error) => {
176426
+ const message = error instanceof Error ? error.message : String(error);
176427
+ console.error(chalk81.red(message));
176428
+ process.exit(1);
176429
+ };
176427
176430
  if (parsed.command === "hosted-runner") {
176428
176431
  const { handleHostedRunnerCommand: handleHostedRunnerCommand2 } = await Promise.resolve().then(() => (init_hosted_runner(), exports_hosted_runner));
176429
176432
  await handleHostedRunnerCommand2(parsed.commandArgs ?? [], {
@@ -176443,6 +176446,26 @@ async function main(args) {
176443
176446
  await startWebServer2(port, { skipStartupMigration: true });
176444
176447
  return;
176445
176448
  }
176449
+ if (parsed.command === "init") {
176450
+ try {
176451
+ validateCodexFlags(args, parsed.command);
176452
+ } catch (error) {
176453
+ exitWithEarlyStartupError(error);
176454
+ }
176455
+ const { handleInitCommand: handleInitCommand3 } = await Promise.resolve().then(() => (init_init(), exports_init));
176456
+ await handleInitCommand3(parsed.commandArgs ?? []);
176457
+ return;
176458
+ }
176459
+ if (parsed.command === "status") {
176460
+ try {
176461
+ validateCodexFlags(args, parsed.command);
176462
+ } catch (error) {
176463
+ exitWithEarlyStartupError(error);
176464
+ }
176465
+ const { handleStatusCommand: handleStatusCommand2 } = await Promise.resolve().then(() => (init_status4(), exports_status));
176466
+ await handleStatusCommand2();
176467
+ return;
176468
+ }
176446
176469
  const isLikelyInteractiveTui = !parsed.messages.length && (parsed.mode === "text" || parsed.mode === void 0) && parsed.command === void 0;
176447
176470
  const isHeadlessMode = parsed.headless || parsed.mode === "headless";
176448
176471
  if (isLikelyInteractiveTui || isHeadlessMode) {
@@ -176602,16 +176625,6 @@ Available commands:`));
176602
176625
  await handleEvalOpsCommand2(parsed.subcommand, parsed.commandArgs ?? []);
176603
176626
  return;
176604
176627
  }
176605
- if (parsed.command === "status") {
176606
- const { handleStatusCommand: handleStatusCommand2 } = await Promise.resolve().then(() => (init_status4(), exports_status));
176607
- await handleStatusCommand2();
176608
- return;
176609
- }
176610
- if (parsed.command === "init") {
176611
- const { handleInitCommand: handleInitCommand3 } = await Promise.resolve().then(() => (init_init(), exports_init));
176612
- await handleInitCommand3(parsed.commandArgs ?? []);
176613
- return;
176614
- }
176615
176628
  if (parsed.command === "codex") {
176616
176629
  const { handleCodexCommand: handleCodexCommand2 } = await Promise.resolve().then(() => (init_codex(), exports_codex));
176617
176630
  await handleCodexCommand2(parsed.subcommand, parsed.messages);