@topolo/cli 0.8.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +44 -7
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { platform as platform2 } from "os";
9
9
  import { createInterface } from "readline/promises";
10
10
  import { stdin as input } from "process";
11
11
 
12
- // node_modules/@topolo/sdk/dist/index.js
12
+ // ../../node_modules/.pnpm/@topolo+sdk@0.11.7/node_modules/@topolo/sdk/dist/index.js
13
13
  function applyAuthHeaders(headers, credential) {
14
14
  if (credential.kind === "api_key") {
15
15
  headers.set("X-Api-Key", credential.apiKey);
@@ -329,7 +329,7 @@ function originMatchesEnvironment(url, environment) {
329
329
  }
330
330
  if (url.protocol !== "https:") return false;
331
331
  if (environment === "production") {
332
- return hostnameHasSuffix(hostname, "topolo.app") || hostnameHasSuffix(hostname, "topolo.io") || workersDevAccountMatches(hostname, "topolo");
332
+ return hostnameHasSuffix(hostname, "topolo.app") || hostnameHasSuffix(hostname, "topolo.io") || hostname === "api.ol0.me" || workersDevAccountMatches(hostname, "topolo");
333
333
  }
334
334
  if (environment === "staging") {
335
335
  return hostnameHasSuffix(hostname, "stg.topolo.us") || workersDevAccountMatches(hostname, "topolo-staging");
@@ -2371,7 +2371,7 @@ function createTopolo(options) {
2371
2371
  };
2372
2372
  }
2373
2373
 
2374
- // node_modules/@topolo/sdk/dist/node/credential-store.js
2374
+ // ../../node_modules/.pnpm/@topolo+sdk@0.11.7/node_modules/@topolo/sdk/dist/node/credential-store.js
2375
2375
  import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
2376
2376
  import { existsSync } from "fs";
2377
2377
  import { homedir, platform } from "os";
@@ -2687,6 +2687,7 @@ var TopoloOAuth2 = class {
2687
2687
  return parsed;
2688
2688
  }
2689
2689
  };
2690
+ var TOPOLO_RUNTIME_ENVIRONMENTS = ["production", "staging", "development", "local"];
2690
2691
  var TOPOLO_ENVIRONMENT_SERVICE_URLS = {
2691
2692
  production: {
2692
2693
  auth: "https://auth.topolo.app",
@@ -2717,7 +2718,7 @@ function originMatchesEnvironment2(url, environment) {
2717
2718
  }
2718
2719
  if (url.protocol !== "https:") return false;
2719
2720
  if (environment === "production") {
2720
- return hostnameHasSuffix2(hostname, "topolo.app") || hostnameHasSuffix2(hostname, "topolo.io") || workersDevAccountMatches2(hostname, "topolo");
2721
+ return hostnameHasSuffix2(hostname, "topolo.app") || hostnameHasSuffix2(hostname, "topolo.io") || hostname === "api.ol0.me" || workersDevAccountMatches2(hostname, "topolo");
2721
2722
  }
2722
2723
  if (environment === "staging") {
2723
2724
  return hostnameHasSuffix2(hostname, "stg.topolo.us") || workersDevAccountMatches2(hostname, "topolo-staging");
@@ -2747,6 +2748,7 @@ function topoloServiceOrigins2(serviceUrls, environment) {
2747
2748
  ])
2748
2749
  );
2749
2750
  }
2751
+ var TOPOLO_ENVIRONMENTS = TOPOLO_RUNTIME_ENVIRONMENTS;
2750
2752
  function contextKey(contextType, organizationId) {
2751
2753
  return contextType === "organization" && organizationId ? `org:${organizationId}` : "personal";
2752
2754
  }
@@ -3041,6 +3043,19 @@ function resolvedProfileConfig(config, environment = selectedEnvironment()) {
3041
3043
  }
3042
3044
 
3043
3045
  // src/config.ts
3046
+ async function authenticatedEnvironments(configOrPromise = readConfig()) {
3047
+ const config = await configOrPromise;
3048
+ const found = /* @__PURE__ */ new Set();
3049
+ if (config.credential) found.add("production");
3050
+ for (const environment of TOPOLO_ENVIRONMENTS) {
3051
+ const profile = config.profiles?.[environment];
3052
+ if (!profile) continue;
3053
+ if (profile.credential || Object.keys(profile.contexts ?? {}).length > 0) {
3054
+ found.add(environment);
3055
+ }
3056
+ }
3057
+ return TOPOLO_ENVIRONMENTS.filter((environment) => found.has(environment));
3058
+ }
3044
3059
  function environmentLabel(environment = selectedEnvironment()) {
3045
3060
  return environment;
3046
3061
  }
@@ -5261,6 +5276,8 @@ Workspace: ${workspace.name} (${workspace.id})${workspace.isDefault ? "\nDefault
5261
5276
  // src/index.ts
5262
5277
  installOutputErrorHandlers();
5263
5278
  var program = new Command();
5279
+ var environmentArgSeen = false;
5280
+ var inheritedEnvironment = process.env.TOPOLO_ENV?.trim();
5264
5281
  var argv;
5265
5282
  try {
5266
5283
  argv = consumeEnvironmentArg(process.argv);
@@ -5269,13 +5286,31 @@ try {
5269
5286
  `);
5270
5287
  process.exit(1);
5271
5288
  }
5289
+ var environmentWasStated = Boolean(inheritedEnvironment) || environmentArgSeen;
5272
5290
  program.name("topolo").description(
5273
5291
  "Public Topolo CLI for customer identity, organization context, applications, resources, and actions."
5274
5292
  ).version(CLI_VERSION).option("--env <environment>", "Topolo environment: production, staging, development, or local");
5275
- program.hook("preAction", (thisCommand) => {
5293
+ program.hook("preAction", async (thisCommand, actionCommand) => {
5276
5294
  const opts = thisCommand.opts();
5277
- if (!opts.env) return;
5278
- process.env.TOPOLO_ENV = normalizeEnvironment(opts.env);
5295
+ if (opts.env) process.env.TOPOLO_ENV = normalizeEnvironment(opts.env);
5296
+ if (opts.env || environmentWasStated) return;
5297
+ const authenticated = await authenticatedEnvironments();
5298
+ if (authenticated.length < 2) return;
5299
+ const path = [];
5300
+ for (let node = actionCommand; node && node !== program; node = node.parent) {
5301
+ path.unshift(node.name());
5302
+ }
5303
+ process.stderr.write(
5304
+ `This machine is signed in to ${authenticated.length} Topolo environments (${authenticated.join(", ")}), so the environment is no longer safe to assume.
5305
+
5306
+ State it explicitly:
5307
+ topolo --env <${authenticated.join("|")}> ${path.join(" ")} ...
5308
+
5309
+ Or set it once for the whole session:
5310
+ export TOPOLO_ENV=<${authenticated.join("|")}>
5311
+ `
5312
+ );
5313
+ process.exit(2);
5279
5314
  });
5280
5315
  registerAuthCommands(program);
5281
5316
  registerWhoamiCommand(program);
@@ -5307,11 +5342,13 @@ function consumeEnvironmentArg(argv2) {
5307
5342
  throw new Error("--env requires production, staging, development, or local.");
5308
5343
  }
5309
5344
  process.env.TOPOLO_ENV = normalizeEnvironment(value);
5345
+ environmentArgSeen = true;
5310
5346
  i += 1;
5311
5347
  continue;
5312
5348
  }
5313
5349
  if (arg.startsWith("--env=")) {
5314
5350
  process.env.TOPOLO_ENV = normalizeEnvironment(arg.slice("--env=".length));
5351
+ environmentArgSeen = true;
5315
5352
  continue;
5316
5353
  }
5317
5354
  next.push(arg);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@topolo/cli",
3
- "version": "0.8.8",
4
- "topoloPublishedVersion": "0.8.8",
3
+ "version": "0.9.0",
4
+ "topoloPublishedVersion": "0.9.0",
5
5
  "description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
6
6
  "license": "UNLICENSED",
7
7
  "author": "Topolo",
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@modelcontextprotocol/sdk": "^1.0.0",
28
- "@topolo/mcp": "0.11.6",
29
- "@topolo/sdk": "0.11.6",
28
+ "@topolo/mcp": "0.11.7",
29
+ "@topolo/sdk": "0.11.7",
30
30
  "commander": "^12.1.0"
31
31
  },
32
32
  "devDependencies": {