apiblaze 0.21.33 → 0.21.35

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 +20 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__
34
34
  var version;
35
35
  var init_package = __esm({
36
36
  "package.json"() {
37
- version = "0.21.33";
37
+ version = "0.21.35";
38
38
  }
39
39
  });
40
40
 
@@ -159,7 +159,8 @@ async function fetchPolicy() {
159
159
  try {
160
160
  const res = await fetch(`${DASHBOARD_BASE}/api/cli/policy`, { signal: AbortSignal.timeout(1500) });
161
161
  if (!res.ok) return null;
162
- return normalizePolicy(await res.json());
162
+ const raw = await res.json();
163
+ return { policy: normalizePolicy(raw), beta: raw?.beta === true };
163
164
  } catch {
164
165
  return null;
165
166
  }
@@ -168,18 +169,24 @@ function readCache() {
168
169
  try {
169
170
  const raw = JSON.parse(import_fs.default.readFileSync(cacheFile(), "utf8"));
170
171
  if (!raw || typeof raw !== "object" || typeof raw.at !== "number" || !Number.isFinite(raw.at)) return null;
171
- return { at: raw.at, policy: raw.policy === null ? null : normalizePolicy(raw.policy) };
172
+ return { at: raw.at, policy: raw.policy === null ? null : normalizePolicy(raw.policy), beta: raw.beta === true };
172
173
  } catch {
173
174
  return null;
174
175
  }
175
176
  }
176
- function writeCache(policy) {
177
+ function writeCache(policy, beta) {
177
178
  try {
178
179
  import_fs.default.mkdirSync(import_path.default.dirname(cacheFile()), { recursive: true });
179
- import_fs.default.writeFileSync(cacheFile(), JSON.stringify({ at: Date.now(), policy }));
180
+ import_fs.default.writeFileSync(cacheFile(), JSON.stringify({ at: Date.now(), policy, beta }));
180
181
  } catch {
181
182
  }
182
183
  }
184
+ function isBetaCached() {
185
+ return readCache()?.beta === true;
186
+ }
187
+ function betaNotice() {
188
+ return `${import_chalk.default.bgYellow.black.bold(" BETA ")} ${import_chalk.default.yellow("APIblaze is in beta: recharging credits is free, up to a capped balance. Questions? support@apiblaze.com")}`;
189
+ }
183
190
  async function checkCliPolicy(version2, opts = {}) {
184
191
  if (process.env.APIBLAZE_SKIP_VERSION_CHECK === "1") return;
185
192
  const cached = opts.fresh ? null : readCache();
@@ -187,8 +194,9 @@ async function checkCliPolicy(version2, opts = {}) {
187
194
  if (cached && Date.now() - cached.at >= 0 && Date.now() - cached.at < CACHE_MS) {
188
195
  policy = cached.policy;
189
196
  } else {
190
- policy = await fetchPolicy();
191
- writeCache(policy);
197
+ const fetched = await fetchPolicy();
198
+ policy = fetched?.policy ?? null;
199
+ writeCache(policy, fetched?.beta === true);
192
200
  }
193
201
  if (policy && cliRefusal(policy, version2)) throw new CliUpgradeRequired(version2, policy.min_version, policy.message);
194
202
  }
@@ -790,6 +798,7 @@ ${import_chalk4.default.cyan("\u2192")} Team: ${import_chalk4.default.bold(teamN
790
798
  teamName
791
799
  });
792
800
  console.log(import_chalk4.default.green("\n\u2714 Logged in successfully!"));
801
+ if (isBetaCached()) console.log(betaNotice());
793
802
  await offerClaimPendingAnon();
794
803
  }
795
804
  async function offerClaimPendingAnon() {
@@ -837,6 +846,7 @@ var init_login = __esm({
837
846
  init_auth();
838
847
  init_team();
839
848
  init_legal();
849
+ init_version_guard();
840
850
  DASHBOARD_BASE3 = process.env.APIBLAZE_DASHBOARD_BASE || "https://dashboard.apiblaze.com";
841
851
  }
842
852
  });
@@ -18365,7 +18375,7 @@ mcpCommon(mcpOps.command("list").description("Every tool with its effective beha
18365
18375
  mcpCommon(mcpOps.command("set").description("Override one tool").argument("<project>", "Project name or id").argument("<tool>", "Tool name").option("--read-only", "Safe to call, changes nothing (e.g. a POST search)").option("--no-read-only", "Not read-only").option("--destructive", "Changes or deletes data (e.g. a GET with side effects)").option("--no-destructive", "Not destructive").option("--idempotent", "Repeating it has no extra effect").option("--no-idempotent", "Not idempotent").option("--confirm", "Ask the user to confirm before running").option("--no-confirm", "Never ask to confirm").option("--always-async", "Return a task handle immediately (long jobs)").option("--no-always-async", "Wait for the result (default)")).action(action((project, tool, opts) => runMcpOps("set", project, tool, opts)));
18366
18376
  mcpCommon(mcpOps.command("reset").description("Back to the automatic default for one tool").argument("<project>", "Project name or id").argument("<tool>", "Tool name")).action(action((project, tool, opts) => runMcpOps("reset", project, tool, opts)));
18367
18377
  mcpCommon(mcpCmd.command("ui").description("Print a tool's MCP Apps UI resource (ui://{project}/{tool}) \u2014 the automatic viewer").argument("<project>", "Project name or id").argument("<tool>", "Tool name")).action(action((project, tool, opts) => runMcpUi(project, tool, opts)));
18368
- program.command("apichat [project]").description("Turn any API into a chat: point at an OpenAPI spec \u2014 or chat an EXISTING proxy by name (no login needed)").option("--target <url|file>", "What to chat with \u2014 pass ANY of: a target server base URL (spec auto-discovered at /openapi.json etc.), a local OpenAPI file (./openapi.yaml), or a remote OpenAPI URL (https://acme.com/openapi.yaml)").addOption(new import_commander.Option("--openapi <file|url>", "Deprecated alias \u2014 --target now detects spec files/URLs itself").hideHelp()).addOption(new import_commander.Option("--openapispec <file|url>", "Deprecated alias for --openapi").hideHelp()).option("--name <name>", "Proxy name (defaults to the target host)").option("--apiversion <version>", "API version to create (e.g. 1.0.0)").option("--environment <env>", "Environment to chat against (default: prod anonymous / dev logged-in)").option("--access <mode>", 'Who can call this API once connected (e.g. via Claude): "open" = anyone who signs in, "invite" = only you + emails you pre-approve. Default: invite when logged in, open when anonymous.').option("--target-auth-env <ENV_VAR>", "Read the upstream credential from this env var (CI-safe; required when there is no TTY and the API needs auth)").option("--force", "Proceed even if the API uses oauth2/openIdConnect target auth (you configure target auth yourself later)").option("-y, --yes", "Skip confirmation prompts").option("--tenant <slug>", "Tenant (consumer namespace: portal, login, users) for the new proxy; omit to be asked").option("--apikey <key>", "Use this API key for the proxy's door (api_key proxies). Without it, apichat detects the door and asks \u2014 or runs the consumer login for OAuth doors.").option("--xenduserid <id>", "Assert this end-user id (X-End-User-Id) \u2014 required by proxies with identified/pre-approved enforcement; you are asked for one when the proxy demands it.").option("--verbose", "Show the per-turn proxy curl trace (hidden by default)").option("-p, --prompt <question>", "One-shot question: answered through the external agent CLI after an MCP install, or by apichat itself (exits after answering when there is no TTY)").option("--install-mcp <cli>", "Install this proxy's MCP into an external agent CLI without asking: claude | codex. Also re-offers after an earlier decline.").option("--remove-mcp <cli>", "Disconnect this proxy from an external agent CLI (claude | codex): removes the MCP server and the standing instruction").action(action((project, opts) => {
18378
+ program.command("apichat [project]").alias("chat").description("Turn any API into a chat: point at an OpenAPI spec \u2014 or chat an EXISTING proxy by name (no login needed)").option("--target <url|file>", "What to chat with \u2014 pass ANY of: a target server base URL (spec auto-discovered at /openapi.json etc.), a local OpenAPI file (./openapi.yaml), or a remote OpenAPI URL (https://acme.com/openapi.yaml)").addOption(new import_commander.Option("--openapi <file|url>", "Deprecated alias \u2014 --target now detects spec files/URLs itself").hideHelp()).addOption(new import_commander.Option("--openapispec <file|url>", "Deprecated alias for --openapi").hideHelp()).option("--name <name>", "Proxy name (defaults to the target host)").option("--apiversion <version>", "API version to create (e.g. 1.0.0)").option("--environment <env>", "Environment to chat against (default: prod anonymous / dev logged-in)").option("--access <mode>", 'Who can call this API once connected (e.g. via Claude): "open" = anyone who signs in, "invite" = only you + emails you pre-approve. Default: invite when logged in, open when anonymous.').option("--target-auth-env <ENV_VAR>", "Read the upstream credential from this env var (CI-safe; required when there is no TTY and the API needs auth)").option("--force", "Proceed even if the API uses oauth2/openIdConnect target auth (you configure target auth yourself later)").option("-y, --yes", "Skip confirmation prompts").option("--tenant <slug>", "Tenant (consumer namespace: portal, login, users) for the new proxy; omit to be asked").option("--apikey <key>", "Use this API key for the proxy's door (api_key proxies). Without it, apichat detects the door and asks \u2014 or runs the consumer login for OAuth doors.").option("--xenduserid <id>", "Assert this end-user id (X-End-User-Id) \u2014 required by proxies with identified/pre-approved enforcement; you are asked for one when the proxy demands it.").option("--verbose", "Show the per-turn proxy curl trace (hidden by default)").option("-p, --prompt <question>", "One-shot question: answered through the external agent CLI after an MCP install, or by apichat itself (exits after answering when there is no TTY)").option("--install-mcp <cli>", "Install this proxy's MCP into an external agent CLI without asking: claude | codex. Also re-offers after an earlier decline.").option("--remove-mcp <cli>", "Disconnect this proxy from an external agent CLI (claude | codex): removes the MCP server and the standing instruction").action(action((project, opts) => {
18369
18379
  const looksLikeSource = !!project && (/^https?:\/\//i.test(project) || /\.(ya?ml|json)$/i.test(project) || import_fs11.default.existsSync(project));
18370
18380
  const target2 = opts.target ?? (looksLikeSource ? project : void 0);
18371
18381
  return runApichat({ ...opts, target: target2, project: looksLikeSource ? void 0 : project, openapispec: opts.openapispec ?? opts.openapi });
@@ -18566,6 +18576,8 @@ program.configureHelp({
18566
18576
  return cmd === program ? [] : all;
18567
18577
  }
18568
18578
  });
18579
+ program.addHelpText("before", () => isBetaCached() ? `${betaNotice()}
18580
+ ` : "");
18569
18581
  program.addHelpText("after", () => `
18570
18582
  ${import_chalk72.default.bold("Don't like reading docs?")} Run ${import_chalk72.default.bgCyan.black.bold(` npx ${B.cli} docs `)} ${import_chalk72.default.cyan(`\u2014 ask an AI chatbot about ${B.product}, and let it act on your account.`)}
18571
18583
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.21.33",
3
+ "version": "0.21.35",
4
4
  "description": "APIblaze CLI — Chat with your APIs, Manage your API keys, users and groups with the APIblaze serverless proxy",
5
5
  "keywords": [
6
6
  "apiblaze",