@overaihq/cli 0.14.1 → 0.14.2

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 +105 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35354,6 +35354,7 @@ var generateRandomVariableName = customAlphabet(
35354
35354
 
35355
35355
  // ../common/src/ids.ts
35356
35356
  var ID_PREFIXES = {
35357
+ action: { prefix: "act", body: 20 },
35357
35358
  action_runner: { prefix: "ar", body: 10 },
35358
35359
  action_runner_email_alert: { prefix: "area", body: 10 },
35359
35360
  action_runner_email_subscription: { prefix: "ares", body: 10 },
@@ -37353,6 +37354,102 @@ var runSql = async (args) => {
37353
37354
  }
37354
37355
  };
37355
37356
 
37357
+ // src/commands/storage.ts
37358
+ import { openAsBlob, writeFileSync as writeFileSync6 } from "fs";
37359
+ var USAGE3 = "Usage: overai storage upload <path> [--no-random-prefix] | storage download <key> [path|-] | storage exists <key> | storage head <key> [--lines N] | storage presign <key> [--expires-in <seconds>]";
37360
+ var runStorage = async (args) => {
37361
+ const [operation, first2, second] = args;
37362
+ if (operation == null) throw new Error(USAGE3);
37363
+ const { organizationId } = await getAccessToken();
37364
+ const segment = (key) => encodeURIComponent(key);
37365
+ if (operation === "upload") {
37366
+ if (first2 == null || first2 === "-") {
37367
+ throw new Error("Upload requires a file path (stdin uploads need a filename to build the key).");
37368
+ }
37369
+ const randomPrefix = !args.includes("--no-random-prefix");
37370
+ const query = randomPrefix ? "" : "?disableRandomPrefix=true";
37371
+ const response = await v2Fetch(
37372
+ `/v2/storage/${organizationId}/stream${query}`,
37373
+ {
37374
+ method: "POST",
37375
+ headers: {
37376
+ "Content-Type": "application/octet-stream",
37377
+ "x-file-name": first2.split("/").pop() ?? first2
37378
+ },
37379
+ body: await openAsBlob(first2)
37380
+ }
37381
+ );
37382
+ if (!response.ok) {
37383
+ throw v2Error("storage upload", response, await response.text());
37384
+ }
37385
+ const { path } = await response.json();
37386
+ const key = path.startsWith(`${organizationId}/`) ? path.slice(organizationId.length + 1) : path;
37387
+ const format2 = resolveFormat(flagValue(args, "-o", "--output"));
37388
+ if (format2 === "json") printResult({ key, path }, format2);
37389
+ else process.stdout.write(`${key}
37390
+ `);
37391
+ return;
37392
+ }
37393
+ if (first2 == null) throw new Error(USAGE3);
37394
+ if (operation === "download") {
37395
+ const response = await v2Fetch(
37396
+ `/v2/storage/${organizationId}/${segment(first2)}`,
37397
+ { redirect: "follow" }
37398
+ );
37399
+ if (!response.ok) {
37400
+ throw v2Error("storage download", response, await response.text());
37401
+ }
37402
+ const bytes = Buffer.from(await response.arrayBuffer());
37403
+ if (second != null && second !== "-") writeFileSync6(second, bytes);
37404
+ else process.stdout.write(bytes);
37405
+ return;
37406
+ }
37407
+ if (operation === "exists") {
37408
+ const response = await v2Fetch(
37409
+ `/v2/storage/${organizationId}/${segment(first2)}/exists`
37410
+ );
37411
+ if (response.status === 404) {
37412
+ if (resolveFormat(flagValue(args, "-o", "--output")) === "json") {
37413
+ printResult({ exists: false }, "json");
37414
+ }
37415
+ process.exitCode = 1;
37416
+ return;
37417
+ }
37418
+ if (!response.ok) {
37419
+ throw v2Error("storage exists", response, await response.text());
37420
+ }
37421
+ printResult(
37422
+ { exists: true, ...await response.json() },
37423
+ resolveFormat(flagValue(args, "-o", "--output"))
37424
+ );
37425
+ return;
37426
+ }
37427
+ if (operation === "head") {
37428
+ const lines = flagValue(args, "--lines") ?? "50";
37429
+ const response = await v2Fetch(
37430
+ `/v2/storage/${organizationId}/${segment(first2)}/head?numLines=${encodeURIComponent(lines)}`
37431
+ );
37432
+ if (!response.ok) {
37433
+ throw v2Error("storage head", response, await response.text());
37434
+ }
37435
+ process.stdout.write(await response.text());
37436
+ return;
37437
+ }
37438
+ if (operation === "presign") {
37439
+ const expiresIn2 = flagValue(args, "--expires-in") ?? String(60 * 60 * 24 * 7);
37440
+ const response = await v2Fetch(
37441
+ `/v2/storage/${organizationId}/${segment(first2)}/presign?expiresIn=${encodeURIComponent(expiresIn2)}`
37442
+ );
37443
+ if (!response.ok) {
37444
+ throw v2Error("storage presign", response, await response.text());
37445
+ }
37446
+ process.stdout.write(`${(await response.text()).trim()}
37447
+ `);
37448
+ return;
37449
+ }
37450
+ throw new Error(USAGE3);
37451
+ };
37452
+
37356
37453
  // src/commands/workspace.ts
37357
37454
  var workspaceIdFrom = (args) => args.find(
37358
37455
  (arg, index) => !arg.startsWith("-") && args[index - 1] !== "-o" && args[index - 1] !== "--output"
@@ -37436,7 +37533,7 @@ var listWorkspaceUsers = async (args) => {
37436
37533
  resolveFormat(flagValue(args, "-o", "--output"))
37437
37534
  );
37438
37535
  };
37439
- var USAGE3 = `Usage:
37536
+ var USAGE4 = `Usage:
37440
37537
  overai workspace list [--archived] [--limit <n>]
37441
37538
  overai workspace show [workspaceId]
37442
37539
  overai workspace users [workspaceId]
@@ -37454,7 +37551,7 @@ var runWorkspace = async (args) => {
37454
37551
  await listWorkspaceUsers(args.slice(1));
37455
37552
  return;
37456
37553
  }
37457
- process.stderr.write(USAGE3);
37554
+ process.stderr.write(USAGE4);
37458
37555
  process.exitCode = 1;
37459
37556
  };
37460
37557
 
@@ -37616,6 +37713,9 @@ Other resources:
37616
37713
  overai data-stream query <id> --start <date> --end <date> [--query <filter>]
37617
37714
  overai data-file upload <id> <path> [-m <message>]
37618
37715
  overai data-file download <id> [path|-] | data-file head <id>
37716
+ overai storage upload <path> [--no-random-prefix]
37717
+ overai storage download <key> [path|-] | storage exists <key>
37718
+ overai storage head <key> [--lines N] | storage presign <key> [--expires-in <seconds>]
37619
37719
  overai knowledge-base upload <id> <file...>
37620
37720
  overai knowledge-base search <id> <query> [--limit N]
37621
37721
  overai integration configure <id> --config <json|@file|@->
@@ -37861,6 +37961,9 @@ var run = async () => {
37861
37961
  case "data-file":
37862
37962
  await runDataFile(rest);
37863
37963
  return;
37964
+ case "storage":
37965
+ await runStorage(rest);
37966
+ return;
37864
37967
  case "integration":
37865
37968
  await runIntegration(rest);
37866
37969
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overaihq/cli",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "Create, edit, deploy, and run OverAI workspace resources from the command line",
5
5
  "type": "module",
6
6
  "homepage": "https://overai.com",