@ghostystudio/cli 0.4.0 → 0.6.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 +35 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -275,7 +275,7 @@ async function request(path, opts = {}, retried = false) {
|
|
|
275
275
|
method: opts.method ?? (opts.body !== void 0 || opts.raw !== void 0 ? "POST" : "GET"),
|
|
276
276
|
headers: {
|
|
277
277
|
authorization: `Bearer ${token}`,
|
|
278
|
-
"user-agent": `ghosty-cli/${"0.
|
|
278
|
+
"user-agent": `ghosty-cli/${"0.6.0"}`,
|
|
279
279
|
...opts.body !== void 0 ? { "content-type": "application/json" } : {},
|
|
280
280
|
...opts.headers
|
|
281
281
|
},
|
|
@@ -364,10 +364,18 @@ async function agentsSet(id, v) {
|
|
|
364
364
|
if (v["prompt-file"]) body.prompt = await readFile2(v["prompt-file"], "utf8");
|
|
365
365
|
const env = parseEnv(v.env);
|
|
366
366
|
if (env) body.env = env;
|
|
367
|
-
|
|
367
|
+
const connectors = {};
|
|
368
|
+
for (const c of (v.connect ?? "").split(",").map((s) => s.trim()).filter(Boolean)) connectors[c] = {};
|
|
369
|
+
for (const c of (v.disconnect ?? "").split(",").map((s) => s.trim()).filter(Boolean)) connectors[c] = null;
|
|
370
|
+
if (Object.keys(connectors).length) body.connectors = connectors;
|
|
371
|
+
if (!Object.keys(body).length) throw usage("Nothing to change.", "Use --name, --engine, --model, --prompt, --prompt-file, --env, --connect or --disconnect.");
|
|
368
372
|
const r = await api(agentPath(id), { method: "PATCH", body });
|
|
369
373
|
out(r, () => `${lavender("\u2713")} Updated ${Object.keys(body).join(", ")}.`);
|
|
370
374
|
}
|
|
375
|
+
async function agentsRm(id) {
|
|
376
|
+
id = need(id, "agent id", "ghosty agents rm <agent-id>");
|
|
377
|
+
out(await api(agentPath(id), { method: "DELETE" }), () => `${lavender("\u2713")} Deleted ${id}.`);
|
|
378
|
+
}
|
|
371
379
|
async function agentsRestart(id) {
|
|
372
380
|
id = need(id, "agent id", "ghosty agents restart <agent-id>");
|
|
373
381
|
out(await api(agentPath(id, "/restart"), { method: "POST", body: {} }), () => `${lavender("\u2713")} Restarting \u2014 the next turn uses the new config.`);
|
|
@@ -631,6 +639,20 @@ ${dim(`${(r.storage.usedBytes / 1e9).toFixed(2)} GB of ${r.storage.limitGb} GB u
|
|
|
631
639
|
throw usage(`Unknown files subcommand: ${sub ?? "(none)"}.`, ex);
|
|
632
640
|
}
|
|
633
641
|
}
|
|
642
|
+
async function meUsage() {
|
|
643
|
+
const r = await api("/api/v2/me/usage");
|
|
644
|
+
const pct = (p) => `${Math.round(p * 100)}%`;
|
|
645
|
+
out(
|
|
646
|
+
r,
|
|
647
|
+
() => [
|
|
648
|
+
`Plan ${r.plan.name}${r.exhausted ? " \u2014 out of usage for now" : ""}`,
|
|
649
|
+
` This week ${pct(r.week.pct).padStart(4)} used ${dim(`resets ${r.week.resetsAt.slice(0, 10)}`)}`,
|
|
650
|
+
...r.month.pct !== null ? [` This month ${pct(r.month.pct).padStart(4)} used ${dim(`resets ${r.month.resetsAt.slice(0, 10)}`)}`] : [],
|
|
651
|
+
` Top-ups ${r.creditMxn > 0 ? "available" : "none"}`,
|
|
652
|
+
dim("Change plan or top up: https://www.ghosty.studio/c/uso")
|
|
653
|
+
].join("\n")
|
|
654
|
+
);
|
|
655
|
+
}
|
|
634
656
|
|
|
635
657
|
// src/commands/schedule.ts
|
|
636
658
|
var enc3 = encodeURIComponent;
|
|
@@ -724,12 +746,15 @@ ${bold("Session")}
|
|
|
724
746
|
--device Sign in from another device with a link + code (auto over SSH/CI)
|
|
725
747
|
logout Sign out and revoke this device's session
|
|
726
748
|
whoami Show who you are signed in as
|
|
749
|
+
usage Your plan and how much you've used this week and month
|
|
727
750
|
|
|
728
751
|
${bold("Agents")}
|
|
729
752
|
agents ls List your agents
|
|
730
753
|
agents create Create an agent --name [--engine] [--model] [--prompt | --prompt-file FILE] [--env K=V,\u2026]
|
|
731
754
|
agents get <id> Show an agent's config [--fields name,model,prompt]
|
|
732
755
|
agents set <id> Change identity or engine [--name] [--engine] [--model] [--prompt | --prompt-file FILE] [--env K=V,\u2026]
|
|
756
|
+
[--connect google-drive,\u2026] [--disconnect \u2026] give/remove access to your connectors
|
|
757
|
+
agents rm <id> Delete an agent (owner only)
|
|
733
758
|
agents restart <id> Restart an ACP agent (needsRestart) so it loads new skills
|
|
734
759
|
|
|
735
760
|
${bold("Configure an agent")}
|
|
@@ -777,6 +802,8 @@ async function main() {
|
|
|
777
802
|
name: { type: "string" },
|
|
778
803
|
model: { type: "string" },
|
|
779
804
|
engine: { type: "string" },
|
|
805
|
+
connect: { type: "string" },
|
|
806
|
+
disconnect: { type: "string" },
|
|
780
807
|
env: { type: "string" },
|
|
781
808
|
prompt: { type: "string" },
|
|
782
809
|
"prompt-file": { type: "string" },
|
|
@@ -796,7 +823,7 @@ async function main() {
|
|
|
796
823
|
});
|
|
797
824
|
globals.json = Boolean(v.json);
|
|
798
825
|
globals.token = v.token;
|
|
799
|
-
if (v.version) return out({ version: "0.
|
|
826
|
+
if (v.version) return out({ version: "0.6.0" }, () => "0.6.0");
|
|
800
827
|
const [cmd, sub, a1, a2] = pos;
|
|
801
828
|
if (!cmd || v.help || cmd === "help") return showHelp();
|
|
802
829
|
switch (cmd) {
|
|
@@ -823,8 +850,9 @@ async function main() {
|
|
|
823
850
|
if (sub === "create" || sub === "new") return agentsCreate(v);
|
|
824
851
|
if (sub === "get") return agentsGet(a1, v.fields);
|
|
825
852
|
if (sub === "set") return agentsSet(a1, v);
|
|
853
|
+
if (sub === "rm" || sub === "delete") return agentsRm(a1);
|
|
826
854
|
if (sub === "restart") return agentsRestart(a1);
|
|
827
|
-
throw usage(`Unknown agents subcommand: ${sub}.`, "Try: ghosty agents ls | create | get | set | restart");
|
|
855
|
+
throw usage(`Unknown agents subcommand: ${sub}.`, "Try: ghosty agents ls | create | get | set | rm | restart");
|
|
828
856
|
case "files":
|
|
829
857
|
return filesCmd(sub, a1, a2, v);
|
|
830
858
|
case "skills":
|
|
@@ -840,8 +868,11 @@ async function main() {
|
|
|
840
868
|
throw usage(`Unknown conversations subcommand: ${sub ?? "(none)"}.`, "Try: ghosty conversations ls <agent-id>");
|
|
841
869
|
case "schedule":
|
|
842
870
|
return scheduleCmd(sub, a1, a2, v);
|
|
871
|
+
case "usage":
|
|
872
|
+
return meUsage();
|
|
843
873
|
case "me":
|
|
844
874
|
if (sub === "files") return meFiles(a1, a2, v);
|
|
875
|
+
if (sub === "usage") return meUsage();
|
|
845
876
|
throw usage(`Unknown me subcommand: ${sub ?? "(none)"}.`, "Try: ghosty me files ls");
|
|
846
877
|
case "docs": {
|
|
847
878
|
const url = `${await baseUrl()}/docs${sub ? `/${encodeURIComponent(sub)}` : "/cli"}`;
|
package/package.json
CHANGED