@erdoai/cli 0.64.0 → 0.64.1

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 +21 -17
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { readFileSync as readFileSync3 } from "fs";
4
+ import { readFileSync as readFileSync4 } from "fs";
5
5
  import { basename } from "path";
6
6
  import { select } from "@inquirer/prompts";
7
7
  import { Command } from "commander";
@@ -1333,9 +1333,17 @@ async function browserLogin() {
1333
1333
  return { token: data.access_token, me };
1334
1334
  }
1335
1335
 
1336
+ // src/input.ts
1337
+ import { readFileSync as readFileSync2 } from "fs";
1338
+ function readMaybeFile(value) {
1339
+ if (!value) return void 0;
1340
+ if (value.startsWith("@@")) return value.slice(1);
1341
+ return value.startsWith("@") ? readFileSync2(value.slice(1), "utf8") : value;
1342
+ }
1343
+
1336
1344
  // src/update.ts
1337
1345
  import { spawn as spawn2, spawnSync } from "child_process";
1338
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
1346
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
1339
1347
  import { dirname as dirname2 } from "path";
1340
1348
  var PKG = "@erdoai/cli";
1341
1349
  var MANUAL_HINT = `npm install -g ${PKG}@latest`;
@@ -1373,7 +1381,7 @@ async function fetchLatestVersion(timeoutMs) {
1373
1381
  function readVersionCache() {
1374
1382
  try {
1375
1383
  if (!existsSync2(CACHE_PATH)) return {};
1376
- const raw = JSON.parse(readFileSync2(CACHE_PATH, "utf8"));
1384
+ const raw = JSON.parse(readFileSync3(CACHE_PATH, "utf8"));
1377
1385
  return raw && typeof raw === "object" ? raw : {};
1378
1386
  } catch {
1379
1387
  return {};
@@ -1441,7 +1449,7 @@ async function update(current) {
1441
1449
  }
1442
1450
 
1443
1451
  // src/index.ts
1444
- var pkg = JSON.parse(readFileSync3(new URL("../package.json", import.meta.url), "utf8"));
1452
+ var pkg = JSON.parse(readFileSync4(new URL("../package.json", import.meta.url), "utf8"));
1445
1453
  function fail(err) {
1446
1454
  if (err instanceof ErdoApiError) {
1447
1455
  console.error(`Error ${err.status}: ${err.message}`);
@@ -2643,14 +2651,14 @@ caseCmd.command("rm <slug> <caseName>").description("Archive a case from a suite
2643
2651
  }
2644
2652
  });
2645
2653
  var agentCmd = program.command("agent").description("Run agents");
2646
- agentCmd.command("ask <question>").description("Ask the data-question agent (one-shot); prints the answer").option("-d, --datasets <csv>", "dataset slugs to scope to").option(
2654
+ agentCmd.command("ask <question>").description("Ask the data-question agent (one-shot); question accepts @path to a UTF-8 file").option("-d, --datasets <csv>", "dataset slugs to scope to").option(
2647
2655
  "--sync",
2648
2656
  "hold one long HTTP request open until the run finishes, instead of polling. Faster for quick questions; a proxy will time it out on any run over ~100s, losing the thread id while the run continues server-side"
2649
2657
  ).action(async (question, opts) => {
2650
2658
  try {
2651
2659
  const client = new ErdoClient();
2652
2660
  const res = await client.ask({
2653
- question,
2661
+ question: readMaybeFile(question) ?? "",
2654
2662
  dataset_slugs: opts.datasets ? opts.datasets.split(",").map((s) => s.trim()) : void 0,
2655
2663
  async: !opts.sync
2656
2664
  });
@@ -2676,9 +2684,9 @@ thread: ${res.thread_id}`);
2676
2684
  fail(e);
2677
2685
  }
2678
2686
  });
2679
- agentCmd.command("send <threadId> <message>").description("Send a message to a thread and print the agent's reply").option("-a, --agent <key>", "agent to invoke (e.g. erdo.artifact-builder)").option(
2687
+ agentCmd.command("send <threadId> <message>").description("Send a message to a thread and print the agent's reply; message accepts @path to a UTF-8 file").option("-a, --agent <key>", "agent to invoke (e.g. erdo.artifact-builder)").option(
2680
2688
  "--context <text>",
2681
- "application context for this turn; available to the agent but omitted from the visible user message"
2689
+ "application context for this turn, or @path to a UTF-8 file; omitted from the visible user message"
2682
2690
  ).option(
2683
2691
  "--sync",
2684
2692
  "hold one long HTTP request open until the run finishes, instead of polling. Faster for quick questions; a proxy will time it out on any run over ~100s while the run continues server-side"
@@ -2687,8 +2695,8 @@ agentCmd.command("send <threadId> <message>").description("Send a message to a t
2687
2695
  const client = new ErdoClient();
2688
2696
  const baselineRunID = opts.sync ? void 0 : await client.latestRunID(threadId);
2689
2697
  const res = await client.sendMessage(threadId, {
2690
- message,
2691
- context: opts.context,
2698
+ message: readMaybeFile(message) ?? "",
2699
+ context: readMaybeFile(opts.context),
2692
2700
  agent_key: opts.agent,
2693
2701
  async: !opts.sync
2694
2702
  });
@@ -3596,10 +3604,6 @@ reviewsCmd.command("decide <id>").description(
3596
3604
  }
3597
3605
  );
3598
3606
  var pagesCmd = program.command("pages").description("Create and manage pages/artifacts");
3599
- function readMaybeFile(v) {
3600
- if (!v) return void 0;
3601
- return v.startsWith("@") ? readFileSync3(v.slice(1), "utf8") : v;
3602
- }
3603
3607
  function grantList(v) {
3604
3608
  if (v === void 0) return void 0;
3605
3609
  if (v.trim() === "[]") return [];
@@ -4139,7 +4143,7 @@ datasetsCmd.command("schema <slug>").alias("describe").description(
4139
4143
  var MAX_UPLOAD_BYTES = 20 * 1024 * 1024;
4140
4144
  datasetsCmd.command("upload <file>").description("Upload a file (CSV, Excel, JSON, ...) and create a dataset from it").option("-n, --name <name>", "display name for the dataset (defaults to the filename)").option("-d, --description <text>", "description shown to agents analyzing the dataset").action(async (file, opts) => {
4141
4145
  try {
4142
- const content = readFileSync3(file);
4146
+ const content = readFileSync4(file);
4143
4147
  if (content.byteLength > MAX_UPLOAD_BYTES) {
4144
4148
  fail(
4145
4149
  new Error(
@@ -4568,7 +4572,7 @@ knowledgeCmd.command("attach <objectId> <file>").description(
4568
4572
  try {
4569
4573
  const body = opts.url ? { filename: basename(file), source_url: opts.url } : {
4570
4574
  filename: basename(file),
4571
- content_base64: readFileSync3(file).toString("base64")
4575
+ content_base64: readFileSync4(file).toString("base64")
4572
4576
  };
4573
4577
  print(
4574
4578
  await new ErdoClient().attachKnowledgeAsset(objectId, {
@@ -4608,7 +4612,7 @@ autoCmd.command("update <id>").description("Edit an automation \u2014 rename, re
4608
4612
  fail(new Error("pass either --script-js or --script-file, not both"));
4609
4613
  return;
4610
4614
  }
4611
- const scriptJs = opts.scriptFile ? readFileSync3(opts.scriptFile, "utf8") : opts.scriptJs;
4615
+ const scriptJs = opts.scriptFile ? readFileSync4(opts.scriptFile, "utf8") : opts.scriptJs;
4612
4616
  const body = {
4613
4617
  name: opts.name,
4614
4618
  description: opts.description,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.64.0",
3
+ "version": "0.64.1",
4
4
  "description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,6 +35,7 @@
35
35
  "scripts": {
36
36
  "build": "tsup src/index.ts --format esm --clean",
37
37
  "build:check": "tsc --noEmit",
38
+ "test": "node --import tsx --test src/input.test.ts",
38
39
  "dev": "tsx src/index.ts",
39
40
  "postinstall": "node scripts/postinstall.mjs",
40
41
  "prepublishOnly": "npm run build"