@neta-art/cohub-cli 1.15.2 → 1.17.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.
@@ -1,11 +1,19 @@
1
+ import { readFileSync } from "node:fs";
1
2
  import { createClient } from "../client.js";
2
3
  import { table, json as outJson, jsonRequested, ok, error, handleHttp } from "../output.js";
4
+ function readJsonObject(pathOrJson) {
5
+ const raw = pathOrJson.trim().startsWith("{") ? pathOrJson : readFileSync(pathOrJson, "utf8");
6
+ const parsed = JSON.parse(raw);
7
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
8
+ error("Invalid payload", "Expected a JSON object");
9
+ return parsed;
10
+ }
3
11
  export function registerCronJobs(program) {
4
- const cmd = program.command("cron-jobs", { hidden: true }).description("Scheduled prompt jobs");
12
+ const cmd = program.command("cron-jobs", { hidden: true }).description("Scheduled jobs");
5
13
  cmd
6
14
  .command("ls [spaceId]")
7
15
  .alias("list")
8
- .description("List cron jobs")
16
+ .description("List scheduled jobs")
9
17
  .option("--json", "Output as JSON")
10
18
  .action(async (spaceId, opts) => {
11
19
  const client = createClient();
@@ -18,6 +26,7 @@ export function registerCronJobs(program) {
18
26
  table(result.jobs, [
19
27
  { key: "id", label: "ID" },
20
28
  { key: "title", label: "Title" },
29
+ { key: "taskType", label: "Type" },
21
30
  { key: "cronExpression", label: "Schedule" },
22
31
  { key: "enabled", label: "Enabled" },
23
32
  { key: "spaceId", label: "Space" },
@@ -27,9 +36,67 @@ export function registerCronJobs(program) {
27
36
  handleHttp(e);
28
37
  }
29
38
  });
39
+ cmd
40
+ .command("get <id>")
41
+ .description("Show scheduled job")
42
+ .option("--json", "Output as JSON")
43
+ .action(async (id, opts) => {
44
+ const client = createClient();
45
+ try {
46
+ const result = await client.cronJobs.get(id);
47
+ if (jsonRequested(opts))
48
+ return outJson(result);
49
+ table([result.job], [
50
+ { key: "id", label: "ID" },
51
+ { key: "title", label: "Title" },
52
+ { key: "taskType", label: "Type" },
53
+ { key: "cronExpression", label: "Schedule" },
54
+ { key: "timezone", label: "Timezone" },
55
+ { key: "enabled", label: "Enabled" },
56
+ { key: "spaceId", label: "Space" },
57
+ ]);
58
+ }
59
+ catch (e) {
60
+ handleHttp(e);
61
+ }
62
+ });
63
+ cmd
64
+ .command("update <id>")
65
+ .description("Update scheduled job")
66
+ .option("--title <title>", "Update title")
67
+ .option("--cron <expression>", "Update cron expression")
68
+ .option("--timezone <timezone>", "Update timezone")
69
+ .option("--payload <jsonOrPath>", "Update payload from JSON string or file")
70
+ .option("--json", "Output as JSON")
71
+ .action(async (id, opts) => {
72
+ const client = createClient();
73
+ try {
74
+ const patch = {};
75
+ if (opts.title !== undefined)
76
+ patch.title = opts.title;
77
+ if (opts.cron !== undefined)
78
+ patch.cronExpression = opts.cron;
79
+ if (opts.timezone !== undefined)
80
+ patch.timezone = opts.timezone;
81
+ if (opts.payload !== undefined)
82
+ patch.payload = readJsonObject(opts.payload);
83
+ if (Object.keys(patch).length === 0)
84
+ error("No changes provided", "Use --title, --cron, --timezone, or --payload");
85
+ const result = await client.cronJobs.update(id, patch);
86
+ if (jsonRequested(opts))
87
+ return outJson(result);
88
+ ok(`Cron job updated: ${result.job.id}`);
89
+ }
90
+ catch (e) {
91
+ if (e instanceof Error && /ENOENT|Unexpected token|JSON/.test(e.message)) {
92
+ error("Invalid payload", e.message);
93
+ }
94
+ handleHttp(e);
95
+ }
96
+ });
30
97
  cmd
31
98
  .command("delete <id>")
32
- .description("Delete a cron job")
99
+ .description("Delete scheduled job")
33
100
  .action(async (id) => {
34
101
  const client = createClient();
35
102
  try {
@@ -42,7 +109,7 @@ export function registerCronJobs(program) {
42
109
  });
43
110
  cmd
44
111
  .command("toggle <id> <on|off>")
45
- .description("Enable or disable a cron job")
112
+ .description("Enable or pause scheduled job")
46
113
  .action(async (id, state) => {
47
114
  if (state !== "on" && state !== "off")
48
115
  return error("Invalid state", "Use on or off");
@@ -58,12 +125,15 @@ export function registerCronJobs(program) {
58
125
  });
59
126
  cmd
60
127
  .command("runs <id>")
61
- .description("List cron job runs")
128
+ .description("List scheduled job runs")
129
+ .option("--limit <limit>", "Page size", "20")
130
+ .option("--cursor <cursor>", "Pagination cursor")
62
131
  .option("--json", "Output as JSON")
63
132
  .action(async (id, opts) => {
64
133
  const client = createClient();
134
+ const limit = Number(opts.limit ?? 20);
65
135
  try {
66
- const result = await client.cronJobs.runs(id);
136
+ const result = await client.cronJobs.runs(id, { limit: Number.isFinite(limit) ? limit : 20, cursor: opts.cursor });
67
137
  if (jsonRequested(opts))
68
138
  return outJson(result);
69
139
  if (result.runs.length === 0)
@@ -71,9 +141,12 @@ export function registerCronJobs(program) {
71
141
  table(result.runs, [
72
142
  { key: "id", label: "ID" },
73
143
  { key: "status", label: "Status" },
144
+ { key: "scheduledAt", label: "Scheduled" },
74
145
  { key: "startedAt", label: "Started" },
75
146
  { key: "finishedAt", label: "Finished" },
76
147
  ]);
148
+ if (result.pageInfo.hasMore && result.pageInfo.nextCursor)
149
+ console.log(`\nNext cursor: ${result.pageInfo.nextCursor}`);
77
150
  }
78
151
  catch (e) {
79
152
  handleHttp(e);
@@ -188,6 +188,7 @@ async function sendPrompt(command, words, opts) {
188
188
  const result = await client.space(spaceId).prompt({
189
189
  sessionId: opts.session,
190
190
  title: opts.title,
191
+ source: opts.source?.trim() || "cli",
191
192
  content: [{ type: "text", text: content }],
192
193
  model: opts.model,
193
194
  provider: opts.provider,
@@ -214,6 +215,7 @@ export function registerPrompt(program) {
214
215
  .description("Send or schedule a prompt in a space")
215
216
  .option("--session <id>", "Target session ID")
216
217
  .option("--title <title>", "Title for a newly created session or schedule")
218
+ .option("--source <source>", "Prompt source for newly created sessions", "cli")
217
219
  .option("-m, --model <model>", "Model name")
218
220
  .option("-p, --provider <provider>", "Provider name")
219
221
  .option("--read-only", "Use read-only tools")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "1.15.2",
3
+ "version": "1.17.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -13,10 +13,10 @@
13
13
  "README.md"
14
14
  ],
15
15
  "dependencies": {
16
- "@neta-art/generation": "^0.1.3",
16
+ "@neta-art/generation": "^0.1.4",
17
17
  "commander": "^14.0.3",
18
18
  "sharp": "^0.34.5",
19
- "@neta-art/cohub": "1.25.2"
19
+ "@neta-art/cohub": "1.27.0"
20
20
  },
21
21
  "publishConfig": {
22
22
  "access": "public"