@asteroidai/cli 1.9.434 → 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
@@ -6922,11 +6922,19 @@ var COMMANDS = [
6922
6922
  }
6923
6923
  ];
6924
6924
 
6925
+ // src/args.ts
6926
+ var UsageError = class extends Error {
6927
+ };
6928
+
6925
6929
  // src/sync/types.ts
6926
6930
  var MANIFEST = ".asteroid.json";
6927
6931
  function get(path, query = {}) {
6928
6932
  return { method: "GET", path, query: new URLSearchParams(query) };
6929
6933
  }
6934
+ function pathId(id) {
6935
+ if (id === "." || id === "..") throw new UsageError(`invalid id: ${id}`);
6936
+ return encodeURIComponent(id);
6937
+ }
6930
6938
  function statusOf(error) {
6931
6939
  const status = error?.status;
6932
6940
  return typeof status === "number" ? status : void 0;
@@ -6942,7 +6950,7 @@ async function syncExecution(sync, executionId2, timeoutMs) {
6942
6950
  Math.max(1, Math.ceil(timeoutMs / 1e3))
6943
6951
  );
6944
6952
  return await sync.remote.json(
6945
- get(`/agents/v2/executions/${executionId2}/sync`, {
6953
+ get(`/agents/v2/executions/${pathId(executionId2)}/sync`, {
6946
6954
  timeoutSeconds: String(timeoutSeconds)
6947
6955
  })
6948
6956
  );
@@ -7314,10 +7322,6 @@ function orgLabel(org) {
7314
7322
  // src/program.ts
7315
7323
  import { Command, CommanderError, Option as Flag } from "commander";
7316
7324
 
7317
- // src/args.ts
7318
- var UsageError = class extends Error {
7319
- };
7320
-
7321
7325
  // src/reference.ts
7322
7326
  var BUILTINS = [
7323
7327
  {
@@ -7369,6 +7373,12 @@ var BUILTINS = [
7369
7373
  description: "Show who you act as, in which organization, and how long the token lasts.",
7370
7374
  args: 0
7371
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
+ },
7372
7382
  {
7373
7383
  command: "skill sync",
7374
7384
  usage: "asteroid skill sync",
@@ -8109,7 +8119,7 @@ var ApiError = class extends Error {
8109
8119
  status;
8110
8120
  body;
8111
8121
  };
8112
- var VERSION = "1.9.434";
8122
+ var VERSION = "1.9.438";
8113
8123
  function problem(status, body, fallback) {
8114
8124
  if (body && typeof body === "object") {
8115
8125
  const record2 = body;
@@ -9060,6 +9070,41 @@ async function whoami(deps, flagOrg, json) {
9060
9070
  );
9061
9071
  return 0;
9062
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
+ }
9063
9108
 
9064
9109
  // src/request.ts
9065
9110
  import { readFileSync as readFileSync3 } from "node:fs";
@@ -9410,7 +9455,9 @@ async function writeText(sync, path, text3) {
9410
9455
  async function writeActivities(sync, dir, execution) {
9411
9456
  try {
9412
9457
  const activities = await sync.remote.json(
9413
- get(`/agents/v2/executions/${execution.id}/activities`, { order: "asc" })
9458
+ get(`/agents/v2/executions/${pathId(execution.id)}/activities`, {
9459
+ order: "asc"
9460
+ })
9414
9461
  );
9415
9462
  if (activities.length === 0) return false;
9416
9463
  const markdown = formatActivitiesMarkdown(
@@ -9426,12 +9473,12 @@ async function writeActivities(sync, dir, execution) {
9426
9473
  }
9427
9474
  async function listFiles(sync, executionId2) {
9428
9475
  const listing = await sync.remote.json(
9429
- get(`/agents/v2/executions/${executionId2}/files`)
9476
+ get(`/agents/v2/executions/${pathId(executionId2)}/files`)
9430
9477
  );
9431
9478
  return DIRECTORIES.flatMap((name) => listing.directories[name] ?? []);
9432
9479
  }
9433
9480
  async function download(sync, executionId2, file) {
9434
- const path = `/agents/v2/executions/${executionId2}/files/${file.id}/signed-url`;
9481
+ const path = `/agents/v2/executions/${pathId(executionId2)}/files/${pathId(file.id)}/signed-url`;
9435
9482
  const { url } = await sync.remote.json(get(path));
9436
9483
  return sync.remote.download(url);
9437
9484
  }
@@ -9480,7 +9527,7 @@ async function pullFiles(sync, dir, options) {
9480
9527
  }
9481
9528
  async function pullExecution(sync, options) {
9482
9529
  const execution = await sync.remote.json(
9483
- get(`/agents/v2/executions/${options.executionId}`)
9530
+ get(`/agents/v2/executions/${pathId(options.executionId)}`)
9484
9531
  );
9485
9532
  const dir = executionDir(options, execution);
9486
9533
  await writeText(
@@ -9632,7 +9679,7 @@ async function pullInsights(sync, options = {}) {
9632
9679
  const dir = options.dir ?? INSIGHTS_DIR;
9633
9680
  const insights = options.insightId ? [
9634
9681
  await sync.remote.json(
9635
- get(`/astro/v2/insights/${options.insightId}`)
9682
+ get(`/astro/v2/insights/${pathId(options.insightId)}`)
9636
9683
  )
9637
9684
  ] : await listInsights(sync, options.workflowId);
9638
9685
  const pulled = [];
@@ -9731,10 +9778,10 @@ function pullDir(root, tree, head) {
9731
9778
  return join3(base, ".versions", workflowDirName(tree.versionId, tree.version));
9732
9779
  }
9733
9780
  function headFilesRequest(workflowId) {
9734
- return get(`/agents/v2/workflows/${workflowId}/head/files`);
9781
+ return get(`/agents/v2/workflows/${pathId(workflowId)}/head/files`);
9735
9782
  }
9736
- async function agentFileBytes(sync, workflowId, tree, entry) {
9737
- const path = `/agents/v2/workflows/${workflowId}/versions/${tree.versionId}/files/${entry.fileId}/signed-url`;
9783
+ async function agentFileBytes(sync, workflowId, tree, fileId) {
9784
+ const path = `/agents/v2/workflows/${pathId(workflowId)}/versions/${pathId(tree.versionId)}/files/${pathId(fileId)}/signed-url`;
9738
9785
  const { url } = await sync.remote.json(get(path));
9739
9786
  return sync.remote.download(url);
9740
9787
  }
@@ -9745,7 +9792,7 @@ async function entryBytes(sync, workflowId, tree, entry) {
9745
9792
  if (entry.storageObjectKey && sync.remote.object)
9746
9793
  return sync.remote.object(entry.storageObjectKey);
9747
9794
  if (!entry.fileId) return void 0;
9748
- return agentFileBytes(sync, workflowId, tree, entry);
9795
+ return agentFileBytes(sync, workflowId, tree, entry.fileId);
9749
9796
  }
9750
9797
  function inlineBytes(entry) {
9751
9798
  if (entry.contentBase64 !== void 0)
@@ -9960,7 +10007,7 @@ async function patch(sync, manifest, writes, deletes) {
9960
10007
  try {
9961
10008
  const snapshot = await sync.remote.json({
9962
10009
  method: "PATCH",
9963
- path: `/agents/v2/workflows/${manifest.workflowId}/head/files`,
10010
+ path: `/agents/v2/workflows/${pathId(manifest.workflowId)}/head/files`,
9964
10011
  query: new URLSearchParams(),
9965
10012
  json: {
9966
10013
  baseRev: manifest.rev,
@@ -10289,6 +10336,8 @@ async function runBuiltin(name, parsed, deps) {
10289
10336
  reason: parsed.flags.get("reason")?.[0],
10290
10337
  exit: parsed.flags.has("exit")
10291
10338
  });
10339
+ case "auth token":
10340
+ return authToken(deps, parsed.org, parsed.json);
10292
10341
  case "skill sync":
10293
10342
  if (parsed.body) throw new UsageError("skill sync takes no --body");
10294
10343
  return syncSkills(deps, parsed.org, {
@@ -10387,7 +10436,13 @@ function nodeRemote(apiUrl, auth, fetchImpl) {
10387
10436
  };
10388
10437
  }
10389
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.";
10390
- 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
+ ]);
10391
10446
  function noticeApplies(invocation, deps) {
10392
10447
  if (!deps.ui || deps.env.apiKey || invocation.parsed.json) return false;
10393
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",
@@ -7655,6 +7661,10 @@ var MANIFEST = ".asteroid.json";
7655
7661
  function get(path, query = {}) {
7656
7662
  return { method: "GET", path, query: new URLSearchParams(query) };
7657
7663
  }
7664
+ function pathId(id) {
7665
+ if (id === "." || id === "..") throw new UsageError(`invalid id: ${id}`);
7666
+ return encodeURIComponent(id);
7667
+ }
7658
7668
  function statusOf(error) {
7659
7669
  const status = error?.status;
7660
7670
  return typeof status === "number" ? status : void 0;
@@ -7670,7 +7680,7 @@ async function syncExecution(sync, executionId2, timeoutMs) {
7670
7680
  Math.max(1, Math.ceil(timeoutMs / 1e3))
7671
7681
  );
7672
7682
  return await sync.remote.json(
7673
- get(`/agents/v2/executions/${executionId2}/sync`, {
7683
+ get(`/agents/v2/executions/${pathId(executionId2)}/sync`, {
7674
7684
  timeoutSeconds: String(timeoutSeconds)
7675
7685
  })
7676
7686
  );
@@ -8030,7 +8040,9 @@ async function writeText(sync, path, text2) {
8030
8040
  async function writeActivities(sync, dir, execution) {
8031
8041
  try {
8032
8042
  const activities = await sync.remote.json(
8033
- get(`/agents/v2/executions/${execution.id}/activities`, { order: "asc" })
8043
+ get(`/agents/v2/executions/${pathId(execution.id)}/activities`, {
8044
+ order: "asc"
8045
+ })
8034
8046
  );
8035
8047
  if (activities.length === 0) return false;
8036
8048
  const markdown = formatActivitiesMarkdown(
@@ -8046,12 +8058,12 @@ async function writeActivities(sync, dir, execution) {
8046
8058
  }
8047
8059
  async function listFiles(sync, executionId2) {
8048
8060
  const listing = await sync.remote.json(
8049
- get(`/agents/v2/executions/${executionId2}/files`)
8061
+ get(`/agents/v2/executions/${pathId(executionId2)}/files`)
8050
8062
  );
8051
8063
  return DIRECTORIES.flatMap((name) => listing.directories[name] ?? []);
8052
8064
  }
8053
8065
  async function download(sync, executionId2, file) {
8054
- const path = `/agents/v2/executions/${executionId2}/files/${file.id}/signed-url`;
8066
+ const path = `/agents/v2/executions/${pathId(executionId2)}/files/${pathId(file.id)}/signed-url`;
8055
8067
  const { url } = await sync.remote.json(get(path));
8056
8068
  return sync.remote.download(url);
8057
8069
  }
@@ -8100,7 +8112,7 @@ async function pullFiles(sync, dir, options) {
8100
8112
  }
8101
8113
  async function pullExecution(sync, options) {
8102
8114
  const execution = await sync.remote.json(
8103
- get(`/agents/v2/executions/${options.executionId}`)
8115
+ get(`/agents/v2/executions/${pathId(options.executionId)}`)
8104
8116
  );
8105
8117
  const dir = executionDir(options, execution);
8106
8118
  await writeText(
@@ -8252,7 +8264,7 @@ async function pullInsights(sync, options = {}) {
8252
8264
  const dir = options.dir ?? INSIGHTS_DIR;
8253
8265
  const insights = options.insightId ? [
8254
8266
  await sync.remote.json(
8255
- get(`/astro/v2/insights/${options.insightId}`)
8267
+ get(`/astro/v2/insights/${pathId(options.insightId)}`)
8256
8268
  )
8257
8269
  ] : await listInsights(sync, options.workflowId);
8258
8270
  const pulled = [];
@@ -8351,10 +8363,10 @@ function pullDir(root, tree, head) {
8351
8363
  return join(base, ".versions", workflowDirName(tree.versionId, tree.version));
8352
8364
  }
8353
8365
  function headFilesRequest(workflowId) {
8354
- return get(`/agents/v2/workflows/${workflowId}/head/files`);
8366
+ return get(`/agents/v2/workflows/${pathId(workflowId)}/head/files`);
8355
8367
  }
8356
- async function agentFileBytes(sync, workflowId, tree, entry) {
8357
- const path = `/agents/v2/workflows/${workflowId}/versions/${tree.versionId}/files/${entry.fileId}/signed-url`;
8368
+ async function agentFileBytes(sync, workflowId, tree, fileId) {
8369
+ const path = `/agents/v2/workflows/${pathId(workflowId)}/versions/${pathId(tree.versionId)}/files/${pathId(fileId)}/signed-url`;
8358
8370
  const { url } = await sync.remote.json(get(path));
8359
8371
  return sync.remote.download(url);
8360
8372
  }
@@ -8365,7 +8377,7 @@ async function entryBytes(sync, workflowId, tree, entry) {
8365
8377
  if (entry.storageObjectKey && sync.remote.object)
8366
8378
  return sync.remote.object(entry.storageObjectKey);
8367
8379
  if (!entry.fileId) return void 0;
8368
- return agentFileBytes(sync, workflowId, tree, entry);
8380
+ return agentFileBytes(sync, workflowId, tree, entry.fileId);
8369
8381
  }
8370
8382
  function inlineBytes(entry) {
8371
8383
  if (entry.contentBase64 !== void 0)
@@ -8580,7 +8592,7 @@ async function patch(sync, manifest, writes, deletes) {
8580
8592
  try {
8581
8593
  const snapshot = await sync.remote.json({
8582
8594
  method: "PATCH",
8583
- path: `/agents/v2/workflows/${manifest.workflowId}/head/files`,
8595
+ path: `/agents/v2/workflows/${pathId(manifest.workflowId)}/head/files`,
8584
8596
  query: new URLSearchParams(),
8585
8597
  json: {
8586
8598
  baseRev: manifest.rev,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteroidai/cli",
3
- "version": "1.9.434",
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",