@anaella/cli 0.2.2 → 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.
- package/dist/index.js +26 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -143,6 +143,22 @@ function cmdUpload(client, o) {
|
|
|
143
143
|
}))
|
|
144
144
|
);
|
|
145
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
|
+
}
|
|
146
162
|
|
|
147
163
|
// src/config.ts
|
|
148
164
|
import { chmodSync, existsSync, mkdirSync, readFileSync as readFileSync2, rmSync, writeFileSync } from "fs";
|
|
@@ -240,7 +256,9 @@ var collect = (val, acc) => {
|
|
|
240
256
|
return acc;
|
|
241
257
|
};
|
|
242
258
|
var program = new Command();
|
|
243
|
-
program.name("anaella").description(
|
|
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");
|
|
244
262
|
async function withClient(command, fn, columns) {
|
|
245
263
|
const opts = command.optsWithGlobals();
|
|
246
264
|
const cfg = resolveConfig({ apiKey: opts.apiKey, apiUrl: opts.apiUrl }, process.env);
|
|
@@ -312,4 +330,11 @@ program.command("analytics").description("Organization analytics, or one post wi
|
|
|
312
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(
|
|
313
331
|
(files, opts, command) => withClient(command, (c) => cmdUpload(c, { files, url: opts.url }), ["id", "url", "type"])
|
|
314
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)));
|
|
315
340
|
program.parseAsync(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anaella/cli",
|
|
3
|
-
"version": "0.
|
|
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": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test": "bun test"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@anaella/client": "^0.
|
|
21
|
+
"@anaella/client": "^0.2.0",
|
|
22
22
|
"commander": "^12.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|