@neta-art/cohub-cli 1.0.6 → 1.1.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.
@@ -31,49 +31,6 @@ export function registerCronJobs(program) {
31
31
  handleHttp(e);
32
32
  }
33
33
  });
34
- cmd
35
- .command("create")
36
- .description("Create a cron job")
37
- .requiredOption("-t, --title <title>", "Job title")
38
- .requiredOption("--task-type <type>", "Task type")
39
- .requiredOption("--cron <expression>", "Cron expression")
40
- .option("--payload <json>", "Payload as JSON")
41
- .option("--timezone <tz>", "Timezone", "UTC")
42
- .option("--space <id>", "Space ID")
43
- .option("--session <id>", "Session ID")
44
- .option("--json", "Output as JSON")
45
- .action(async (opts) => {
46
- const token = resolveToken();
47
- if (!token)
48
- return error("Not authenticated");
49
- let payload = {};
50
- if (opts.payload) {
51
- try {
52
- payload = JSON.parse(opts.payload);
53
- }
54
- catch {
55
- return error("Invalid JSON", "--payload must be valid JSON");
56
- }
57
- }
58
- const client = createClient(token);
59
- try {
60
- const result = await client.cronJobs.create({
61
- title: opts.title,
62
- taskType: opts.taskType,
63
- cronExpression: opts.cron,
64
- payload,
65
- timezone: opts.timezone,
66
- spaceId: opts.space,
67
- sessionId: opts.session,
68
- });
69
- if (opts.json)
70
- return outJson(result);
71
- ok(`Cron job created: ${result.id}`);
72
- }
73
- catch (e) {
74
- handleHttp(e);
75
- }
76
- });
77
34
  cmd
78
35
  .command("delete <id>")
79
36
  .description("Delete a cron job")
@@ -103,6 +103,65 @@ export function registerSpaces(program) {
103
103
  handleHttp(e);
104
104
  }
105
105
  });
106
+ // ── spaces prompt ──
107
+ spacesCmd
108
+ .command("prompt [content...]")
109
+ .description("Send or schedule a prompt in the target space")
110
+ .option("--session <id>", "Target session ID")
111
+ .option("--title <title>", "Title for a newly created session or schedule")
112
+ .option("-m, --model <model>", "Model name")
113
+ .option("-p, --provider <provider>", "Provider name")
114
+ .option("--delay-ms <ms>", "Delay sending by milliseconds")
115
+ .option("--at <iso>", "Send once at an ISO 8601 time with timezone")
116
+ .option("--cron <expression>", "Repeat using a 5-field cron expression")
117
+ .option("--timezone <tz>", "IANA timezone for --cron, e.g. Asia/Shanghai")
118
+ .option("--json", "Output as JSON")
119
+ .action(async (words, opts) => {
120
+ const token = resolveToken() ?? missingAuth();
121
+ let content = words.join(" ");
122
+ if (!content && !process.stdin.isTTY) {
123
+ const chunks = [];
124
+ for await (const chunk of process.stdin)
125
+ chunks.push(chunk);
126
+ content = Buffer.concat(chunks).toString().trim();
127
+ }
128
+ if (!content)
129
+ return error("No content", "Pass as argument or pipe via stdin");
130
+ const scheduleFlags = [opts.delayMs, opts.at, opts.cron].filter((value) => value !== undefined);
131
+ if (scheduleFlags.length > 1)
132
+ return error("Conflicting schedule", "Use only one of --delay-ms, --at, or --cron");
133
+ if (opts.cron && !opts.timezone)
134
+ return error("Missing timezone", "--timezone is required with --cron");
135
+ const spaceId = requireSpace(spacesCmd);
136
+ const client = createClient(token);
137
+ try {
138
+ const schedule = opts.delayMs
139
+ ? { mode: "delay", delayMs: Number.parseInt(opts.delayMs, 10) }
140
+ : opts.at
141
+ ? { mode: "at", sendAt: opts.at }
142
+ : opts.cron
143
+ ? { mode: "repeat", cronExpression: opts.cron, timezone: opts.timezone }
144
+ : undefined;
145
+ const result = await client.space(spaceId).prompt({
146
+ sessionId: opts.session,
147
+ title: opts.title,
148
+ content: [{ type: "text", text: content }],
149
+ model: opts.model,
150
+ provider: opts.provider,
151
+ schedule,
152
+ });
153
+ if (opts.json)
154
+ return outJson(result);
155
+ if (result.mode === "immediate")
156
+ return ok(`Prompt sent — sessionId: ${result.sessionId}, turnId: ${result.turnId}`);
157
+ if (result.mode === "repeat")
158
+ return ok(`Prompt scheduled — cronJobId: ${result.cronJobId}, nextRunAt: ${result.nextRunAt}`);
159
+ return ok(`Prompt scheduled — taskRunId: ${result.taskRunId}, scheduledAt: ${result.scheduledAt}`);
160
+ }
161
+ catch (e) {
162
+ handleHttp(e);
163
+ }
164
+ });
106
165
  // ── spaces files ──
107
166
  registerFiles(spacesCmd);
108
167
  // ── spaces sessions ──
@@ -1,6 +1,6 @@
1
1
  import { resolveToken } from "../auth.js";
2
2
  import { createClient } from "../client.js";
3
- import { table, json as outJson, ok, error, handleHttp } from "../output.js";
3
+ import { table, json as outJson, error, handleHttp } from "../output.js";
4
4
  export function registerTasks(program) {
5
5
  const cmd = program.command("tasks").description("Task management");
6
6
  cmd
@@ -62,43 +62,4 @@ export function registerTasks(program) {
62
62
  handleHttp(e);
63
63
  }
64
64
  });
65
- cmd
66
- .command("create")
67
- .description("Create a scheduled task")
68
- .requiredOption("-t, --task-type <type>", "Task type")
69
- .requiredOption("--schedule-at <time>", "ISO timestamp")
70
- .option("--payload <json>", "Task payload as JSON")
71
- .option("--space <id>", "Space ID")
72
- .option("--session <id>", "Session ID")
73
- .option("--json", "Output as JSON")
74
- .action(async (opts) => {
75
- const token = resolveToken();
76
- if (!token)
77
- return error("Not authenticated");
78
- let payload = {};
79
- if (opts.payload) {
80
- try {
81
- payload = JSON.parse(opts.payload);
82
- }
83
- catch {
84
- return error("Invalid JSON", "--payload must be valid JSON");
85
- }
86
- }
87
- const client = createClient(token);
88
- try {
89
- const result = await client.tasks.createScheduled({
90
- taskType: opts.taskType,
91
- payload,
92
- scheduleAt: opts.scheduleAt,
93
- spaceId: opts.space,
94
- sessionId: opts.session,
95
- });
96
- if (opts.json)
97
- return outJson(result);
98
- ok(`Task scheduled — taskRunId: ${result.taskRunId}`);
99
- }
100
- catch (e) {
101
- handleHttp(e);
102
- }
103
- });
104
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "commander": "^13.1.0",
17
- "@neta-art/cohub": "1.4.0"
17
+ "@neta-art/cohub": "1.5.0"
18
18
  },
19
19
  "publishConfig": {
20
20
  "access": "public"