@erdoai/cli 0.55.3 → 0.57.0

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 +72 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -694,8 +694,15 @@ var ErdoClient = class {
694
694
  const { runs } = await this.listAgentRuns({ thread: threadID, limit: 1 });
695
695
  return runs[0]?.id;
696
696
  }
697
- listThreads() {
698
- return this.request("GET", "/v1/threads");
697
+ listThreads(params) {
698
+ const q = new URLSearchParams();
699
+ if (params?.scope) q.set("scope", params.scope);
700
+ if (params?.orderBy) q.set("order_by", params.orderBy);
701
+ if (params?.includeAutomation) q.set("include_automation", "true");
702
+ if (params?.limit !== void 0) q.set("limit", String(params.limit));
703
+ if (params?.offset !== void 0) q.set("offset", String(params.offset));
704
+ const qs = q.toString();
705
+ return this.request("GET", `/v1/threads${qs ? `?${qs}` : ""}`);
699
706
  }
700
707
  getThreadMessages(threadId) {
701
708
  return this.request("GET", `/v1/threads/${encodeURIComponent(threadId)}/messages`);
@@ -880,6 +887,11 @@ var ErdoClient = class {
880
887
  setKnowledgeVisibility(id, visibility) {
881
888
  return this.request("PATCH", `/v1/knowledge/${id}/visibility`, { visibility });
882
889
  }
890
+ // asset_id is what a page's `assetId` field takes — attaching an image here
891
+ // is how it becomes something a published page can render.
892
+ attachKnowledgeAsset(objectID, input) {
893
+ return this.request("POST", `/v1/knowledge/${encodeURIComponent(objectID)}/attachments`, input);
894
+ }
883
895
  // --- automations (heartbeats) ---
884
896
  listHeartbeats() {
885
897
  return this.request("GET", "/v1/heartbeats");
@@ -2583,16 +2595,30 @@ agentCmd.command("thread").description("Create a thread; prints its id").option(
2583
2595
  fail(e);
2584
2596
  }
2585
2597
  });
2586
- agentCmd.command("threads").description("List your threads").action(async () => {
2587
- try {
2588
- const { threads } = await new ErdoClient().listThreads();
2589
- for (const t of threads) {
2590
- console.log(`${t.id} ${t.name} ${t.created_by_user_name || t.created_by_user_id} ${t.source || "unrecorded"}`);
2598
+ agentCmd.command("threads").description("List threads (default: your own; --scope org/shared for organization-wide)").option("-s, --scope <scope>", "own (default) | org | shared \u2014 org/shared require org membership").option(
2599
+ "--order-by <order>",
2600
+ "created_at (default) | activity (last message time) \u2014 scope=org/shared only"
2601
+ ).option(
2602
+ "--include-automation",
2603
+ "include automation/heartbeat-sourced threads, excluded by default \u2014 scope=org/shared only"
2604
+ ).option("-l, --limit <n>", "max threads (default 20, max 100)", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).action(
2605
+ async (opts) => {
2606
+ try {
2607
+ const { threads, total } = await new ErdoClient().listThreads(opts);
2608
+ for (const t of threads) {
2609
+ console.log(`${t.id} ${t.name} ${t.created_by_user_name || t.created_by_user_id} ${t.source || "unrecorded"}`);
2610
+ }
2611
+ const shown = (opts.offset ?? 0) + threads.length;
2612
+ if (total > shown) {
2613
+ console.error(`(showing ${threads.length} of ${total} \u2014 use --limit/--offset for more)`);
2614
+ } else {
2615
+ console.error(`(${total} thread${total === 1 ? "" : "s"})`);
2616
+ }
2617
+ } catch (e) {
2618
+ fail(e);
2591
2619
  }
2592
- } catch (e) {
2593
- fail(e);
2594
2620
  }
2595
- });
2621
+ );
2596
2622
  function contentBlockLabel(c) {
2597
2623
  const type = c.ui_content_type || c.content_type;
2598
2624
  const payload = c.content;
@@ -3338,7 +3364,10 @@ function grantList(v) {
3338
3364
  }
3339
3365
  return slugs;
3340
3366
  }
3341
- pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/--css accept @file").requiredOption("--title <title>", "page title").requiredOption("--html <htmlOr@file>", "HTML (or @path to a file)").option("--js <jsOr@file>", "JS/JSX (or @path)").option("--css <cssOr@file>", "CSS (or @path)").option("--runtime <runtime>", "react-tailwind (default) or none").option("--datasets <csv>", "dataset slugs the page reads").option("--writable-datasets <csv>", "dataset slugs the page may write via erdo.insertRows").option("--kv <csv>", "named KV-store slugs the page reads").option("--writable-kv <csv>", "named KV-store slugs the page may write").option("--public", "make the page publicly viewable").action(
3367
+ pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/--css accept @file").requiredOption("--title <title>", "page title").requiredOption("--html <htmlOr@file>", "HTML (or @path to a file)").option("--js <jsOr@file>", "JS/JSX (or @path)").option("--css <cssOr@file>", "CSS (or @path)").option("--runtime <runtime>", "react-tailwind (default) or none").option(
3368
+ "--meta-title <title>",
3369
+ "public SEO title (browser tab + shared-link headline) \u2014 distinct from --title, the internal name"
3370
+ ).option("--meta-description <description>", "public SEO description (shared-link preview / search result blurb)").option("--datasets <csv>", "dataset slugs the page reads").option("--writable-datasets <csv>", "dataset slugs the page may write via erdo.insertRows").option("--kv <csv>", "named KV-store slugs the page reads").option("--writable-kv <csv>", "named KV-store slugs the page may write").option("--public", "make the page publicly viewable").action(
3342
3371
  async (opts) => {
3343
3372
  try {
3344
3373
  const csv = (v) => v ? v.split(",").map((s) => s.trim()) : void 0;
@@ -3348,6 +3377,8 @@ pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/
3348
3377
  js: readMaybeFile(opts.js),
3349
3378
  css: readMaybeFile(opts.css),
3350
3379
  runtime: opts.runtime,
3380
+ meta_title: opts.metaTitle,
3381
+ meta_description: opts.metaDescription,
3351
3382
  dataset_slugs: csv(opts.datasets),
3352
3383
  writable_dataset_slugs: csv(opts.writableDatasets),
3353
3384
  kv_slugs: csv(opts.kv),
@@ -3363,7 +3394,10 @@ pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/
3363
3394
  );
3364
3395
  pagesCmd.command("update <id>").description(
3365
3396
  "Update an existing page by id; provided fields are merged (update just --js to keep html/css). --html/--js/--css accept @file"
3366
- ).option("--title <title>", "new title").option("--html <htmlOr@file>", "HTML (or @path to a file)").option("--js <jsOr@file>", "JS/JSX (or @path)").option("--css <cssOr@file>", "CSS (or @path)").option("--datasets <csv>", 'replacement read-dataset slugs ("[]" clears)').option("--writable-datasets <csv>", 'replacement writable-dataset slugs ("[]" clears)').option("--kv <csv>", 'replacement read KV-store slugs ("[]" clears)').option("--writable-kv <csv>", 'replacement writable KV-store slugs ("[]" clears)').option("--public", "make the page publicly viewable").option("--private", "make the page private").action(
3397
+ ).option("--title <title>", "new title").option("--html <htmlOr@file>", "HTML (or @path to a file)").option("--js <jsOr@file>", "JS/JSX (or @path)").option("--css <cssOr@file>", "CSS (or @path)").option(
3398
+ "--meta-title <title>",
3399
+ 'new public SEO title (omit to keep current; pass "" to clear back to the default)'
3400
+ ).option("--meta-description <description>", 'new public SEO description (omit to keep current; pass "" to clear)').option("--datasets <csv>", 'replacement read-dataset slugs ("[]" clears)').option("--writable-datasets <csv>", 'replacement writable-dataset slugs ("[]" clears)').option("--kv <csv>", 'replacement read KV-store slugs ("[]" clears)').option("--writable-kv <csv>", 'replacement writable KV-store slugs ("[]" clears)').option("--public", "make the page publicly viewable").option("--private", "make the page private").action(
3367
3401
  async (id, opts) => {
3368
3402
  try {
3369
3403
  const res = await new ErdoClient().updatePage(id, {
@@ -3371,6 +3405,8 @@ pagesCmd.command("update <id>").description(
3371
3405
  html: readMaybeFile(opts.html),
3372
3406
  js: readMaybeFile(opts.js),
3373
3407
  css: readMaybeFile(opts.css),
3408
+ meta_title: opts.metaTitle,
3409
+ meta_description: opts.metaDescription,
3374
3410
  dataset_slugs: grantList(opts.datasets),
3375
3411
  writable_dataset_slugs: grantList(opts.writableDatasets),
3376
3412
  kv_slugs: grantList(opts.kv),
@@ -4031,6 +4067,30 @@ knowledgeCmd.command("visibility <id> <visibility>").description(
4031
4067
  fail(e);
4032
4068
  }
4033
4069
  });
4070
+ knowledgeCmd.command("attach <objectId> <file>").description(
4071
+ "Attach an image or other small binary to a knowledge object as an org-hosted asset, and print its asset id \u2014 the value a page's assetId field takes. Pass a local path, or --url to have the service download it (the only path for video)."
4072
+ ).option("--url <sourceUrl>", "download from this URL instead of reading a local file").option(
4073
+ "-d, --description <text>",
4074
+ "caption for the asset; for an image this is the only text search can match, so describe what is in the picture"
4075
+ ).option("--media-type <mime>", "MIME type hint, e.g. image/jpeg; detected from the filename otherwise").action(
4076
+ async (objectId, file, opts) => {
4077
+ try {
4078
+ const body = opts.url ? { filename: basename(file), source_url: opts.url } : {
4079
+ filename: basename(file),
4080
+ content_base64: readFileSync3(file).toString("base64")
4081
+ };
4082
+ print(
4083
+ await new ErdoClient().attachKnowledgeAsset(objectId, {
4084
+ ...body,
4085
+ description: opts.description,
4086
+ media_type: opts.mediaType
4087
+ })
4088
+ );
4089
+ } catch (e) {
4090
+ fail(e);
4091
+ }
4092
+ }
4093
+ );
4034
4094
  var autoCmd = program.command("automations").description("Scheduled automations (heartbeats)");
4035
4095
  autoCmd.command("list").description("List automations").action(async () => {
4036
4096
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.55.3",
3
+ "version": "0.57.0",
4
4
  "description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {