@anaella/cli 0.2.1 → 0.3.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 +33 -3
  2. package/package.json +5 -3
package/dist/index.js CHANGED
@@ -112,7 +112,12 @@ function cmdPost(client, o) {
112
112
  when: o.when,
113
113
  media: (o.media ?? []).map((url) => ({ url })),
114
114
  type: o.type,
115
- firstComment: o.firstComment
115
+ firstComment: o.firstComment,
116
+ title: o.title,
117
+ markdown: o.markdown,
118
+ excerpt: o.excerpt,
119
+ tags: o.tag?.length ? o.tag : void 0,
120
+ canonicalUrl: o.canonicalUrl
116
121
  });
117
122
  }
118
123
  var cmdPosts = (client, o) => client.listPosts({
@@ -138,6 +143,22 @@ function cmdUpload(client, o) {
138
143
  }))
139
144
  );
140
145
  }
146
+ var cmdFind = (client, q, o) => client.find(q.join(" "), { category: o.category });
147
+ var cmdExplain = (client, id) => client.explain(id);
148
+ var cmdJob = (client, id) => client.job(id);
149
+ var cmdBalance = (client) => client.balance();
150
+ async function cmdDo(client, id, o) {
151
+ let input = {};
152
+ if (o.input) {
153
+ try {
154
+ input = JSON.parse(o.input);
155
+ } catch {
156
+ throw new Error(`--input must be JSON, e.g. --input '{"prompt":"a red fox"}'`);
157
+ }
158
+ }
159
+ const job = await client.do(id, input);
160
+ return o.wait && (job.status === "queued" || job.status === "running") ? client.waitForJob(job.id) : job;
161
+ }
141
162
 
142
163
  // src/config.ts
143
164
  import { chmodSync, existsSync, mkdirSync, readFileSync as readFileSync2, rmSync, writeFileSync } from "fs";
@@ -235,7 +256,9 @@ var collect = (val, acc) => {
235
256
  return acc;
236
257
  };
237
258
  var program = new Command();
238
- program.name("anaella").description("CLI for anaella.com \u2014 schedule and publish social posts via the /v1 API.").version("0.1.1").option("--api-key <key>", "ana_ API key (overrides env + config)").option("--api-url <url>", "API base URL").option("--json", "output raw JSON");
259
+ program.name("anaella").description(
260
+ "CLI for anaella.com \u2014 find and run tools, schedule and publish posts via the /v1 API."
261
+ ).version("0.1.1").option("--api-key <key>", "ana_ API key (overrides env + config)").option("--api-url <url>", "API base URL").option("--json", "output raw JSON");
239
262
  async function withClient(command, fn, columns) {
240
263
  const opts = command.optsWithGlobals();
241
264
  const cfg = resolveConfig({ apiKey: opts.apiKey, apiUrl: opts.apiUrl }, process.env);
@@ -297,7 +320,7 @@ program.command("logout").description("Remove the saved API key").action(() => {
297
320
  program.command("channels").description("List connected channels").action(
298
321
  (_opts, command) => withClient(command, (c) => cmdChannels(c), ["id", "platform", "name", "active"])
299
322
  );
300
- program.command("post").description("Create/schedule/publish a post").requiredOption("-c, --channel <id>", "channel id (repeatable)", collect, []).option("-t, --text <text>", "post text").option("-w, --when <when>", '"now" | "draft" | ISO-8601', "draft").option("-m, --media <url>", "public media URL (repeatable)", collect, []).option("--type <type>", "post | reel | thread | story").option("--first-comment <text>", "first comment").action((opts, command) => withClient(command, (c) => cmdPost(c, opts)));
323
+ program.command("post").description("Create/schedule/publish a post").requiredOption("-c, --channel <id>", "channel id (repeatable)", collect, []).option("-t, --text <text>", "post text").option("-w, --when <when>", '"now" | "draft" | ISO-8601', "draft").option("-m, --media <url>", "public media URL (repeatable)", collect, []).option("--type <type>", "post | reel | thread | story | article").option("--first-comment <text>", "first comment").option("--title <title>", "article title (--type article)").option("--markdown <md>", 'article body in Markdown, e.g. "$(cat post.md)" (--type article)').option("--excerpt <text>", "article excerpt (--type article)").option("--tag <tag>", "article tag (repeatable, --type article)", collect, []).option("--canonical-url <url>", "article canonical URL (--type article)").action((opts, command) => withClient(command, (c) => cmdPost(c, opts)));
301
324
  program.command("posts").description("List recent posts").option("--limit <n>", "max results (1-100)").option("--cursor <n>", "offset").action(
302
325
  (opts, command) => withClient(command, (c) => cmdPosts(c, opts), ["id", "type", "status", "scheduledAt"])
303
326
  );
@@ -307,4 +330,11 @@ program.command("analytics").description("Organization analytics, or one post wi
307
330
  program.command("upload [files...]").description("Upload local media files, or register public URLs with --url").option("--url <url>", "public media URL to register (repeatable)", collect, []).action(
308
331
  (files, opts, command) => withClient(command, (c) => cmdUpload(c, { files, url: opts.url }), ["id", "url", "type"])
309
332
  );
333
+ program.command("find [query...]").description("Find capabilities by what you want to do").option("--category <c>", "filter by category").action(
334
+ (query, opts, command) => withClient(command, (c) => cmdFind(c, query, opts), ["id", "summary", "priceUsd", "mode"])
335
+ );
336
+ program.command("explain <id>").description("Show a capability's input/output schema and price").action((id, _opts, command) => withClient(command, (c) => cmdExplain(c, id)));
337
+ program.command("do <id>").description("Run a capability").option("-i, --input <json>", "input object as JSON (see explain)").option("--wait", "wait for async jobs to finish").action((id, opts, command) => withClient(command, (c) => cmdDo(c, id, opts)));
338
+ program.command("job <id>").description("Status, output and cost of a job").action((id, _opts, command) => withClient(command, (c) => cmdJob(c, id)));
339
+ program.command("balance").description("Wallet balance in dollars").action((_opts, command) => withClient(command, (c) => cmdBalance(c)));
310
340
  program.parseAsync(process.argv);
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@anaella/cli",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Command-line tool for anaella.com — schedule and publish social posts.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "anaella": "dist/index.js"
8
8
  },
9
- "files": ["dist"],
9
+ "files": [
10
+ "dist"
11
+ ],
10
12
  "publishConfig": {
11
13
  "access": "public"
12
14
  },
@@ -16,7 +18,7 @@
16
18
  "test": "bun test"
17
19
  },
18
20
  "dependencies": {
19
- "@anaella/client": "^0.1.7",
21
+ "@anaella/client": "^0.2.0",
20
22
  "commander": "^12.0.0"
21
23
  },
22
24
  "devDependencies": {