@asteroidai/cli 1.9.436 → 1.9.438

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/asteroid.js CHANGED
@@ -7373,6 +7373,12 @@ var BUILTINS = [
7373
7373
  description: "Show who you act as, in which organization, and how long the token lasts.",
7374
7374
  args: 0
7375
7375
  },
7376
+ {
7377
+ command: "auth token",
7378
+ usage: "asteroid auth token",
7379
+ description: 'Print the access token the CLI sends for the active organization, refreshed from your sign-in when needed. Like `gh auth token`, it lets a script call the API as you: `curl -H "Authorization: Bearer $(asteroid auth token)" ...`. The token lasts a few minutes, so fetch it right before each call. With `--json`, also prints when it expires and which organization it acts in.',
7380
+ args: 0
7381
+ },
7376
7382
  {
7377
7383
  command: "skill sync",
7378
7384
  usage: "asteroid skill sync",
@@ -8113,7 +8119,7 @@ var ApiError = class extends Error {
8113
8119
  status;
8114
8120
  body;
8115
8121
  };
8116
- var VERSION = "1.9.436";
8122
+ var VERSION = "1.9.438";
8117
8123
  function problem(status, body, fallback) {
8118
8124
  if (body && typeof body === "object") {
8119
8125
  const record2 = body;
@@ -9064,6 +9070,41 @@ async function whoami(deps, flagOrg, json) {
9064
9070
  );
9065
9071
  return 0;
9066
9072
  }
9073
+ async function authToken(deps, flagOrg, json) {
9074
+ if (deps.env.apiKey) {
9075
+ throw new UsageError(
9076
+ `${API_KEY_OVERRIDES} An API key has no access token to print. ${UNSET_API_KEY}`
9077
+ );
9078
+ }
9079
+ const config = loadConfig(deps.env);
9080
+ const auth = await resolveAuth(
9081
+ deps.env,
9082
+ config,
9083
+ requestedOrg(flagOrg, deps.env, deps.cwd, config),
9084
+ deps.fetch
9085
+ );
9086
+ const token = auth.headers.Authorization.replace(/^Bearer /, "");
9087
+ if (!json) {
9088
+ deps.stdout(`${token}
9089
+ `);
9090
+ return 0;
9091
+ }
9092
+ deps.stdout(
9093
+ `${JSON.stringify(
9094
+ {
9095
+ token,
9096
+ expiresAt: auth.expiresAt === void 0 ? null : new Date(auth.expiresAt).toISOString(),
9097
+ organizationId: auth.org?.id ?? null,
9098
+ organizationName: auth.org?.name ?? null,
9099
+ staffAccess: auth.staff !== void 0
9100
+ },
9101
+ null,
9102
+ 2
9103
+ )}
9104
+ `
9105
+ );
9106
+ return 0;
9107
+ }
9067
9108
 
9068
9109
  // src/request.ts
9069
9110
  import { readFileSync as readFileSync3 } from "node:fs";
@@ -10295,6 +10336,8 @@ async function runBuiltin(name, parsed, deps) {
10295
10336
  reason: parsed.flags.get("reason")?.[0],
10296
10337
  exit: parsed.flags.has("exit")
10297
10338
  });
10339
+ case "auth token":
10340
+ return authToken(deps, parsed.org, parsed.json);
10298
10341
  case "skill sync":
10299
10342
  if (parsed.body) throw new UsageError("skill sync takes no --body");
10300
10343
  return syncSkills(deps, parsed.org, {
@@ -10393,7 +10436,13 @@ function nodeRemote(apiUrl, auth, fetchImpl) {
10393
10436
  };
10394
10437
  }
10395
10438
  var DESCRIPTION = "The Asteroid CLI. Sign in with `asteroid login`, or set ASTEROID_API_KEY.\nAt a terminal, tables show up to 6 columns and cut long cells to fit; when output is piped, they show every column in full. Use `--json` for every field.";
10396
- var NO_NOTICE = /* @__PURE__ */ new Set(["login", "logout", "complete", "skill sync"]);
10439
+ var NO_NOTICE = /* @__PURE__ */ new Set([
10440
+ "login",
10441
+ "logout",
10442
+ "complete",
10443
+ "skill sync",
10444
+ "auth token"
10445
+ ]);
10397
10446
  function noticeApplies(invocation, deps) {
10398
10447
  if (!deps.ui || deps.env.apiKey || invocation.parsed.json) return false;
10399
10448
  return invocation.kind === "command" || !NO_NOTICE.has(invocation.name);
package/dist/core.js CHANGED
@@ -7134,6 +7134,12 @@ var BUILTINS = [
7134
7134
  description: "Show who you act as, in which organization, and how long the token lasts.",
7135
7135
  args: 0
7136
7136
  },
7137
+ {
7138
+ command: "auth token",
7139
+ usage: "asteroid auth token",
7140
+ description: 'Print the access token the CLI sends for the active organization, refreshed from your sign-in when needed. Like `gh auth token`, it lets a script call the API as you: `curl -H "Authorization: Bearer $(asteroid auth token)" ...`. The token lasts a few minutes, so fetch it right before each call. With `--json`, also prints when it expires and which organization it acts in.',
7141
+ args: 0
7142
+ },
7137
7143
  {
7138
7144
  command: "skill sync",
7139
7145
  usage: "asteroid skill sync",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteroidai/cli",
3
- "version": "1.9.436",
3
+ "version": "1.9.438",
4
4
  "description": "The asteroid command-line interface for the Asteroid platform.",
5
5
  "type": "module",
6
6
  "license": "MIT",