@useorgx/wizard 0.1.58 → 0.1.60

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/cli.ts
4
4
 
5
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="66b240e6-4f09-5817-86f1-bac0012af8cb")}catch(e){}}();
5
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7bd631ed-f07c-5a2e-95a9-249e72dc087a")}catch(e){}}();
6
6
  import * as clack from "@clack/prompts";
7
7
  import { spawnSync as spawnSync5 } from "child_process";
8
8
  import { readFileSync as readFileSync10 } from "fs";
@@ -32,7 +32,9 @@ import { join } from "path";
32
32
  var ORGX_HOSTED_MCP_KEY = "orgx";
33
33
  var ORGX_LOCAL_MCP_KEY = "orgx-openclaw";
34
34
  var ORGX_HOSTED_MCP_URL = "https://mcp.useorgx.com/mcp";
35
- var ORGX_CODEX_MCP_URL = `${ORGX_HOSTED_MCP_URL}?profile=commander`;
35
+ var ORGX_CODEX_MCP_URL = ORGX_HOSTED_MCP_URL;
36
+ var ORGX_CODEX_TOOL_PROFILE_HEADER = "x-orgx-tool-profile";
37
+ var ORGX_CODEX_TOOL_PROFILE = "commander";
36
38
  var ORGX_HOSTED_MCP_HEALTH_URL = "https://mcp.useorgx.com/health";
37
39
  var ORGX_HOSTED_OAUTH_BASE_URL = "https://mcp.useorgx.com";
38
40
  var ORGX_HOSTED_OAUTH_AUTHORIZE_URL = `${ORGX_HOSTED_OAUTH_BASE_URL}/authorize`;
@@ -2179,6 +2181,7 @@ import { dirname as dirname4, join as join4 } from "path";
2179
2181
 
2180
2182
  // src/surfaces/mcp-config.ts
2181
2183
  import * as TOML from "@iarna/toml";
2184
+ var ORGX_LEGACY_CODEX_MCP_URL = `${ORGX_HOSTED_MCP_URL}?profile=commander`;
2182
2185
  function cloneConfigCollection(config, key) {
2183
2186
  return { ...readObject(config[key]) };
2184
2187
  }
@@ -2441,12 +2444,20 @@ function stringifyTomlDocument(document) {
2441
2444
  return rendered.endsWith("\n") ? rendered : `${rendered}
2442
2445
  `;
2443
2446
  }
2444
- function upsertCodexEntry(servers, key, url) {
2447
+ function upsertCodexEntry(servers, key, url, oauthResource, toolProfile) {
2445
2448
  const current = readObject(servers[key]);
2446
2449
  const next = {
2447
2450
  ...current,
2448
2451
  url
2449
2452
  };
2453
+ if (oauthResource) {
2454
+ next.oauth_resource = oauthResource;
2455
+ }
2456
+ if (toolProfile) {
2457
+ const httpHeaders = readObject(next.http_headers);
2458
+ httpHeaders[ORGX_CODEX_TOOL_PROFILE_HEADER] = toolProfile;
2459
+ next.http_headers = httpHeaders;
2460
+ }
2450
2461
  delete next.command;
2451
2462
  delete next.args;
2452
2463
  delete next.startup_timeout_sec;
@@ -2466,7 +2477,13 @@ function removeLegacyCodexEntries(servers) {
2466
2477
  function patchCodexConfigToml(input, localMcpUrl) {
2467
2478
  const current = parseTomlDocument(input);
2468
2479
  const servers = readObject(current.mcp_servers);
2469
- upsertCodexEntry(servers, ORGX_HOSTED_MCP_KEY, ORGX_CODEX_MCP_URL);
2480
+ upsertCodexEntry(
2481
+ servers,
2482
+ ORGX_HOSTED_MCP_KEY,
2483
+ ORGX_CODEX_MCP_URL,
2484
+ ORGX_HOSTED_MCP_URL,
2485
+ ORGX_CODEX_TOOL_PROFILE
2486
+ );
2470
2487
  if (localMcpUrl) {
2471
2488
  upsertCodexEntry(servers, ORGX_LOCAL_MCP_KEY, localMcpUrl);
2472
2489
  }
@@ -2474,27 +2491,115 @@ function patchCodexConfigToml(input, localMcpUrl) {
2474
2491
  current.mcp_servers = servers;
2475
2492
  return stringifyTomlDocument(current);
2476
2493
  }
2477
- function migrateCodexHostedMcpProfile(input) {
2494
+ function migrateCodexHostedMcpConnection(input) {
2478
2495
  if (!input) return input;
2479
2496
  const current = parseTomlDocument(input);
2480
2497
  const servers = readObject(current.mcp_servers);
2481
2498
  const hosted = readObject(servers[ORGX_HOSTED_MCP_KEY]);
2482
- if (hosted.url !== ORGX_HOSTED_MCP_URL) return input;
2499
+ if (hosted.url !== ORGX_HOSTED_MCP_URL && hosted.url !== ORGX_LEGACY_CODEX_MCP_URL) {
2500
+ return input;
2501
+ }
2483
2502
  const lines = input.match(/.*(?:\r\n|\n|$)/g)?.filter((line) => line.length > 0) ?? [];
2484
- let inOrgxSection = false;
2485
- let changed = false;
2486
- const nextLines = lines.map((line) => {
2503
+ let activeSection = "other";
2504
+ let orgxSectionEnd = lines.length;
2505
+ let headersSectionStart = -1;
2506
+ let headersSectionEnd = lines.length;
2507
+ let urlIndex = -1;
2508
+ let oauthResourceIndex = -1;
2509
+ let inlineHeadersIndex = -1;
2510
+ let profileHeaderIndex = -1;
2511
+ for (const [index, line] of lines.entries()) {
2487
2512
  if (/^\s*\[/.test(line)) {
2488
- inOrgxSection = /^\s*\[mcp_servers\.(?:orgx|"orgx")\]\s*(?:#.*)?(?:\r?\n)?$/.test(line);
2489
- return line;
2513
+ if (activeSection === "orgx" && orgxSectionEnd === lines.length) {
2514
+ orgxSectionEnd = index;
2515
+ }
2516
+ if (activeSection === "headers" && headersSectionEnd === lines.length) {
2517
+ headersSectionEnd = index;
2518
+ }
2519
+ if (/^\s*\[mcp_servers\.(?:orgx|"orgx")\]\s*(?:#.*)?(?:\r?\n)?$/.test(line)) {
2520
+ activeSection = "orgx";
2521
+ } else if (/^\s*\[mcp_servers\.(?:orgx|"orgx")\.http_headers\]\s*(?:#.*)?(?:\r?\n)?$/.test(line)) {
2522
+ activeSection = "headers";
2523
+ headersSectionStart = index;
2524
+ } else {
2525
+ activeSection = "other";
2526
+ }
2527
+ continue;
2528
+ }
2529
+ if (activeSection === "orgx") {
2530
+ if (/^\s*url\s*=/.test(line)) urlIndex = index;
2531
+ if (/^\s*oauth_resource\s*=/.test(line)) oauthResourceIndex = index;
2532
+ if (/^\s*http_headers\s*=/.test(line)) inlineHeadersIndex = index;
2533
+ } else if (activeSection === "headers" && /^\s*(?:"x-orgx-tool-profile"|x-orgx-tool-profile)\s*=/.test(line)) {
2534
+ profileHeaderIndex = index;
2490
2535
  }
2491
- if (!inOrgxSection || changed) return line;
2492
- const match = line.match(/^(\s*url\s*=\s*)(["'])(https:\/\/mcp\.useorgx\.com\/mcp)\2([ \t]*(?:#.*)?)(\r?\n)?$/);
2493
- if (!match) return line;
2536
+ }
2537
+ if (urlIndex < 0) return input;
2538
+ const urlMatch = lines[urlIndex]?.match(
2539
+ /^(\s*url\s*=\s*)(["'])(https:\/\/mcp\.useorgx\.com\/mcp(?:\?profile=commander)?)\2([ \t]*(?:#.*)?)(\r?\n)?$/
2540
+ );
2541
+ if (!urlMatch) return input;
2542
+ let changed = false;
2543
+ if (urlMatch[3] !== ORGX_CODEX_MCP_URL) {
2544
+ lines[urlIndex] = `${urlMatch[1]}${urlMatch[2]}${ORGX_CODEX_MCP_URL}${urlMatch[2]}${urlMatch[4]}${urlMatch[5] ?? ""}`;
2494
2545
  changed = true;
2495
- return `${match[1]}${match[2]}${ORGX_CODEX_MCP_URL}${match[2]}${match[4]}${match[5] ?? ""}`;
2496
- });
2497
- return changed ? nextLines.join("") : input;
2546
+ }
2547
+ const httpHeaders = readObject(hosted.http_headers);
2548
+ const configuredProfile = httpHeaders[ORGX_CODEX_TOOL_PROFILE_HEADER];
2549
+ if (inlineHeadersIndex >= 0 && configuredProfile !== ORGX_CODEX_TOOL_PROFILE) {
2550
+ return input;
2551
+ }
2552
+ if (oauthResourceIndex >= 0) {
2553
+ const oauthResourceMatch = lines[oauthResourceIndex]?.match(
2554
+ /^(\s*oauth_resource\s*=\s*)(["'])([^"']*)\2([ \t]*(?:#.*)?)(\r?\n)?$/
2555
+ );
2556
+ if (!oauthResourceMatch) return input;
2557
+ if (oauthResourceMatch[3] !== ORGX_HOSTED_MCP_URL) {
2558
+ lines[oauthResourceIndex] = `${oauthResourceMatch[1]}${oauthResourceMatch[2]}${ORGX_HOSTED_MCP_URL}${oauthResourceMatch[2]}${oauthResourceMatch[4]}${oauthResourceMatch[5] ?? ""}`;
2559
+ changed = true;
2560
+ }
2561
+ } else {
2562
+ const lineEnding = urlMatch[5] ?? (input.includes("\r\n") ? "\r\n" : "\n");
2563
+ if (!urlMatch[5]) {
2564
+ lines[urlIndex] = `${lines[urlIndex]}${lineEnding}`;
2565
+ }
2566
+ const indent = urlMatch[1]?.match(/^\s*/)?.[0] ?? "";
2567
+ lines.splice(
2568
+ urlIndex + 1,
2569
+ 0,
2570
+ `${indent}oauth_resource = "${ORGX_HOSTED_MCP_URL}"${lineEnding}`
2571
+ );
2572
+ changed = true;
2573
+ }
2574
+ const oauthInsertionShift = oauthResourceIndex < 0 ? 1 : 0;
2575
+ if (configuredProfile !== ORGX_CODEX_TOOL_PROFILE) {
2576
+ if (profileHeaderIndex >= 0) {
2577
+ const currentIndex = profileHeaderIndex + oauthInsertionShift;
2578
+ const profileHeaderMatch = lines[currentIndex]?.match(
2579
+ /^(\s*(?:"x-orgx-tool-profile"|x-orgx-tool-profile)\s*=\s*)(["'])([^"']*)\2([ \t]*(?:#.*)?)(\r?\n)?$/
2580
+ );
2581
+ if (!profileHeaderMatch) return input;
2582
+ lines[currentIndex] = `${profileHeaderMatch[1]}${profileHeaderMatch[2]}${ORGX_CODEX_TOOL_PROFILE}${profileHeaderMatch[2]}${profileHeaderMatch[4]}${profileHeaderMatch[5] ?? ""}`;
2583
+ } else if (headersSectionStart >= 0) {
2584
+ lines.splice(
2585
+ headersSectionEnd + oauthInsertionShift,
2586
+ 0,
2587
+ `${ORGX_CODEX_TOOL_PROFILE_HEADER} = "${ORGX_CODEX_TOOL_PROFILE}"${urlMatch[5] ?? "\n"}`
2588
+ );
2589
+ } else if (readObject(hosted.http_headers)[ORGX_CODEX_TOOL_PROFILE_HEADER] === void 0) {
2590
+ const lineEnding = urlMatch[5] ?? (input.includes("\r\n") ? "\r\n" : "\n");
2591
+ const insertionIndex = orgxSectionEnd + oauthInsertionShift;
2592
+ lines.splice(
2593
+ insertionIndex,
2594
+ 0,
2595
+ `[mcp_servers.orgx.http_headers]${lineEnding}`,
2596
+ `${ORGX_CODEX_TOOL_PROFILE_HEADER} = "${ORGX_CODEX_TOOL_PROFILE}"${lineEnding}`,
2597
+ lineEnding
2598
+ );
2599
+ }
2600
+ changed = true;
2601
+ }
2602
+ return changed ? lines.join("") : input;
2498
2603
  }
2499
2604
  function removeCodexConfigToml(input) {
2500
2605
  const current = parseTomlDocument(input);
@@ -2503,7 +2608,7 @@ function removeCodexConfigToml(input) {
2503
2608
  if (isRecord(servers[ORGX_LOCAL_MCP_KEY])) {
2504
2609
  delete servers[ORGX_LOCAL_MCP_KEY];
2505
2610
  }
2506
- if (hosted.url === ORGX_HOSTED_MCP_URL || hosted.url === ORGX_CODEX_MCP_URL) {
2611
+ if (hosted.url === ORGX_HOSTED_MCP_URL || hosted.url === ORGX_LEGACY_CODEX_MCP_URL) {
2507
2612
  delete servers[ORGX_HOSTED_MCP_KEY];
2508
2613
  }
2509
2614
  removeLegacyCodexEntries(servers);
@@ -2515,7 +2620,7 @@ function inspectCodexConfigToml(input) {
2515
2620
  const servers = readObject(current.mcp_servers);
2516
2621
  const hosted = readObject(servers[ORGX_HOSTED_MCP_KEY]);
2517
2622
  const local = readObject(servers[ORGX_LOCAL_MCP_KEY]);
2518
- const hostedConfigured = hosted.url === ORGX_CODEX_MCP_URL;
2623
+ const hostedConfigured = hosted.url === ORGX_CODEX_MCP_URL && hosted.oauth_resource === ORGX_HOSTED_MCP_URL && readObject(hosted.http_headers)[ORGX_CODEX_TOOL_PROFILE_HEADER] === ORGX_CODEX_TOOL_PROFILE;
2519
2624
  const localConfigured = typeof local.url === "string";
2520
2625
  return {
2521
2626
  configured: hostedConfigured && localConfigured,
@@ -4252,7 +4357,7 @@ async function installCodexPlugin(paths, fetchImpl, runner) {
4252
4357
  const syncResult = await syncManagedRepoTree(CODEX_PLUGIN_SYNC_SPEC, paths.codexPluginDir, fetchImpl);
4253
4358
  const marketplaceChanged = upsertCodexMarketplaceEntry(paths.codexMarketplacePath);
4254
4359
  const previousConfig = readTextIfExists(paths.codexConfigPath);
4255
- const nextConfig = migrateCodexHostedMcpProfile(previousConfig);
4360
+ const nextConfig = migrateCodexHostedMcpConnection(previousConfig);
4256
4361
  const configChanged = nextConfig !== previousConfig;
4257
4362
  if (configChanged && nextConfig !== null) {
4258
4363
  writeTextFile(paths.codexConfigPath, nextConfig);
@@ -4261,7 +4366,7 @@ async function installCodexPlugin(paths, fetchImpl, runner) {
4261
4366
  const changes = [
4262
4367
  ...syncResult.changed ? [`Synced ${syncResult.fileCount} Codex plugin files.`] : [],
4263
4368
  ...marketplaceChanged ? ["Updated the Codex marketplace entry."] : [],
4264
- ...configChanged ? ["Updated the existing OrgX MCP connection to the commander profile."] : []
4369
+ ...configChanged ? ["Updated the existing OrgX MCP connection to the canonical OAuth resource and commander profile."] : []
4265
4370
  ];
4266
4371
  return {
4267
4372
  target: "codex",
@@ -6249,7 +6354,7 @@ function initializeWizardSentry() {
6249
6354
  Sentry.init({
6250
6355
  dsn,
6251
6356
  environment: process.env.ORGX_SENTRY_ENVIRONMENT || "production",
6252
- release: "useorgx-wizard@0.1.58",
6357
+ release: "useorgx-wizard@0.1.60",
6253
6358
  tracesSampleRate: sampleRate(process.env.ORGX_SENTRY_TRACES_SAMPLE_RATE),
6254
6359
  enableLogs: true,
6255
6360
  sendDefaultPii: false,
@@ -18280,7 +18385,7 @@ async function main() {
18280
18385
  initializeWizardSentry();
18281
18386
  const program = new Command();
18282
18387
  program.name("orgx-wizard").description("Add OrgX MCP configs, skills/rules, and companion plugins to your local AI tools.").showHelpAfterError();
18283
- const pkgVersion = true ? "0.1.58" : void 0;
18388
+ const pkgVersion = true ? "0.1.60" : void 0;
18284
18389
  program.version(pkgVersion ?? "unknown", "-V, --version");
18285
18390
  program.hook("preAction", (_thisCommand, actionCommand) => {
18286
18391
  if (Boolean(actionCommand.optsWithGlobals().json)) return;
@@ -19324,4 +19429,4 @@ main().catch(async (error) => {
19324
19429
  process.exitCode = 1;
19325
19430
  });
19326
19431
  //# sourceMappingURL=cli.js.map
19327
- //# debugId=66b240e6-4f09-5817-86f1-bac0012af8cb
19432
+ //# debugId=7bd631ed-f07c-5a2e-95a9-249e72dc087a