soltask 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +398 -2
- package/dist/cli.d.ts +15 -0
- package/dist/cli.js +344 -0
- package/dist/client.d.ts +131 -0
- package/dist/client.js +879 -0
- package/dist/commands/actions.d.ts +26 -0
- package/dist/commands/actions.js +1181 -0
- package/dist/commands/auth.d.ts +10 -0
- package/dist/commands/auth.js +489 -0
- package/dist/commands/drafts.d.ts +22 -0
- package/dist/commands/drafts.js +736 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +10 -0
- package/dist/commands/meta.d.ts +4 -0
- package/dist/commands/meta.js +195 -0
- package/dist/commands/read.d.ts +24 -0
- package/dist/commands/read.js +1106 -0
- package/dist/commands/watch.d.ts +2 -0
- package/dist/commands/watch.js +397 -0
- package/dist/config.d.ts +86 -0
- package/dist/config.js +365 -0
- package/dist/context.d.ts +70 -0
- package/dist/context.js +1 -0
- package/dist/domain.d.ts +311 -0
- package/dist/domain.js +747 -0
- package/dist/errors.d.ts +28 -0
- package/dist/errors.js +40 -0
- package/dist/fsutil.d.ts +35 -0
- package/dist/fsutil.js +243 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/output.d.ts +27 -0
- package/dist/output.js +74 -0
- package/dist/types.d.ts +254 -0
- package/dist/types.js +1 -0
- package/dist/util.d.ts +32 -0
- package/dist/util.js +116 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +13 -0
- package/package.json +63 -4
|
@@ -0,0 +1,1181 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { HACKATHON_DRAFTER_HINT, PRIORITIES, TEMPLATES, composeActionPost, createNameResolver, hackathonDrafters, preflightNewTask, resolveAgent, resolveTaskRef, splitDraftBody, } from "../domain.js";
|
|
3
|
+
import { CliError, EXIT_CONFLICT, EXIT_OK, EXIT_RUNTIME, EXIT_VALIDATION } from "../errors.js";
|
|
4
|
+
import { readUtf8File } from "../fsutil.js";
|
|
5
|
+
import { displayText, emitJson, errOut, out } from "../output.js";
|
|
6
|
+
import { splitCsvList } from "../util.js";
|
|
7
|
+
const MAX_TITLE_CHARS = 200;
|
|
8
|
+
const MAX_BODY_CHARS = 60_000;
|
|
9
|
+
const MAX_MESSAGE_CHARS = 65_536;
|
|
10
|
+
const MAX_DECIDE_REASON_CHARS = 65_000;
|
|
11
|
+
const MAX_SHORT_REASON_CHARS = 2_000;
|
|
12
|
+
const MAX_LABELS = 10;
|
|
13
|
+
const MAX_LABEL_CHARS = 40;
|
|
14
|
+
const MAX_MENTIONS = 50;
|
|
15
|
+
const HEX64 = /^[0-9a-f]{64}$/i;
|
|
16
|
+
const DRAFT_ID_RE = /^[\w-]{16}$/;
|
|
17
|
+
const TASK_KIND_CHOICES = ["brainstorm", "canon", "hackathons", "implementation", "bug", "ask"];
|
|
18
|
+
const DECISION_CHOICES = ["accepted", "rejected", "done"];
|
|
19
|
+
function validateHex64(flagName, raw) {
|
|
20
|
+
const trimmed = raw.trim();
|
|
21
|
+
if (!HEX64.test(trimmed)) {
|
|
22
|
+
throw new CliError(`--${flagName} must be a 64-character hex ID.`, { exitCode: EXIT_VALIDATION });
|
|
23
|
+
}
|
|
24
|
+
return trimmed.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
function requireTaskRef(ctx) {
|
|
27
|
+
const ref = (ctx.positionals[0] ?? "").trim();
|
|
28
|
+
if (ref === "") {
|
|
29
|
+
throw new CliError("Task reference cannot be empty.", { exitCode: EXIT_VALIDATION });
|
|
30
|
+
}
|
|
31
|
+
return ref;
|
|
32
|
+
}
|
|
33
|
+
function formatUtcTime(epochSeconds) {
|
|
34
|
+
return `${new Date(epochSeconds * 1000).toUTCString().slice(5, 22)} UTC`;
|
|
35
|
+
}
|
|
36
|
+
function syntheticReason(type, by) {
|
|
37
|
+
return {
|
|
38
|
+
type,
|
|
39
|
+
label: type,
|
|
40
|
+
at: Math.floor(Date.now() / 1000),
|
|
41
|
+
by,
|
|
42
|
+
forWho: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function readStdinText(stream, maxBytes, label) {
|
|
46
|
+
const chunks = [];
|
|
47
|
+
let total = 0;
|
|
48
|
+
for await (const chunk of stream) {
|
|
49
|
+
const buf = typeof chunk === "string" ? Buffer.from(chunk, "utf8") : Buffer.from(chunk);
|
|
50
|
+
total += buf.byteLength;
|
|
51
|
+
if (total > maxBytes) {
|
|
52
|
+
throw new CliError(`Stdin ${label} exceeds the ${maxBytes}-byte limit.`, { exitCode: EXIT_VALIDATION });
|
|
53
|
+
}
|
|
54
|
+
chunks.push(buf);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks)).replace(/\r\n?/g, "\n");
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw new CliError(`Stdin ${label} is not valid UTF-8.`, { exitCode: EXIT_VALIDATION });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function readRawTextSource(ctx, base, maxBytes) {
|
|
64
|
+
const inline = ctx.opt(base);
|
|
65
|
+
const filePath = ctx.opt(`${base}-file`);
|
|
66
|
+
const fromStdin = ctx.flag(`${base}-stdin`);
|
|
67
|
+
const count = (inline !== undefined ? 1 : 0) + (filePath !== undefined ? 1 : 0) + (fromStdin ? 1 : 0);
|
|
68
|
+
if (count > 1) {
|
|
69
|
+
throw new CliError(`Pass only one of --${base}, --${base}-file, or --${base}-stdin.`, { exitCode: EXIT_VALIDATION });
|
|
70
|
+
}
|
|
71
|
+
if (inline !== undefined) {
|
|
72
|
+
return { source: "flag", raw: inline.replace(/\r\n?/g, "\n") };
|
|
73
|
+
}
|
|
74
|
+
if (filePath !== undefined) {
|
|
75
|
+
if (filePath.trim() === "") {
|
|
76
|
+
throw new CliError(`--${base}-file requires a file path.`, { exitCode: EXIT_VALIDATION });
|
|
77
|
+
}
|
|
78
|
+
return { source: "file", raw: readUtf8File(resolve(ctx.io.cwd, filePath), maxBytes) };
|
|
79
|
+
}
|
|
80
|
+
if (fromStdin) {
|
|
81
|
+
return { source: "stdin", raw: await readStdinText(ctx.io.stdin, maxBytes, base) };
|
|
82
|
+
}
|
|
83
|
+
return { source: null, raw: undefined };
|
|
84
|
+
}
|
|
85
|
+
async function readRequiredText(ctx, base, maxChars) {
|
|
86
|
+
const { raw } = await readRawTextSource(ctx, base, maxChars * 4);
|
|
87
|
+
if (raw === undefined) {
|
|
88
|
+
throw new CliError(`Provide text via --${base}, --${base}-file PATH, or --${base}-stdin.`, { exitCode: EXIT_VALIDATION });
|
|
89
|
+
}
|
|
90
|
+
const trimmed = raw.trim();
|
|
91
|
+
if (trimmed === "") {
|
|
92
|
+
throw new CliError(`--${base} cannot be empty.`, { exitCode: EXIT_VALIDATION });
|
|
93
|
+
}
|
|
94
|
+
if (trimmed.length > maxChars) {
|
|
95
|
+
throw new CliError(`--${base} must be at most ${maxChars.toLocaleString("en-US")} characters.`, { exitCode: EXIT_VALIDATION });
|
|
96
|
+
}
|
|
97
|
+
return trimmed;
|
|
98
|
+
}
|
|
99
|
+
async function readOptionalText(ctx, base, maxChars) {
|
|
100
|
+
const { raw } = await readRawTextSource(ctx, base, maxChars * 4);
|
|
101
|
+
if (raw === undefined) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const trimmed = raw.trim();
|
|
105
|
+
if (trimmed === "") {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
if (trimmed.length > maxChars) {
|
|
109
|
+
throw new CliError(`--${base} must be at most ${maxChars.toLocaleString("en-US")} characters.`, { exitCode: EXIT_VALIDATION });
|
|
110
|
+
}
|
|
111
|
+
return trimmed;
|
|
112
|
+
}
|
|
113
|
+
async function resolveCreateCommunity(ctx, client) {
|
|
114
|
+
const requested = ctx.community();
|
|
115
|
+
const communities = ctx.global.waitLive
|
|
116
|
+
? (await client.waitUntilLive(requested === undefined ? undefined : [requested])).communities
|
|
117
|
+
: await client.communities();
|
|
118
|
+
if (requested !== undefined) {
|
|
119
|
+
const match = communities.find((c) => c.id === requested);
|
|
120
|
+
if (match === undefined) {
|
|
121
|
+
throw new CliError(`Community not found: ${requested}`, {
|
|
122
|
+
exitCode: EXIT_RUNTIME,
|
|
123
|
+
payload: { ok: false, error: "not_found", status: 404, message: `Community not found: ${requested}` },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return match;
|
|
127
|
+
}
|
|
128
|
+
if (communities.length === 1) {
|
|
129
|
+
const only = communities[0];
|
|
130
|
+
if (only !== undefined) {
|
|
131
|
+
return only;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (communities.length === 0) {
|
|
135
|
+
throw new CliError("No communities are configured on this server.", { exitCode: EXIT_VALIDATION });
|
|
136
|
+
}
|
|
137
|
+
const ids = communities.map((c) => c.id).join(", ");
|
|
138
|
+
throw new CliError(`Multiple communities available (${ids}); specify --community.`, { exitCode: EXIT_VALIDATION });
|
|
139
|
+
}
|
|
140
|
+
async function loadTaskDetail(ctx, ref) {
|
|
141
|
+
const client = ctx.client();
|
|
142
|
+
const explicitCommunity = ctx.community();
|
|
143
|
+
let communityIds;
|
|
144
|
+
if (ctx.global.waitLive) {
|
|
145
|
+
const waited = await client.waitUntilLive(explicitCommunity === undefined ? undefined : [explicitCommunity]);
|
|
146
|
+
communityIds = explicitCommunity === undefined ? waited.communities.map((c) => c.id) : [explicitCommunity];
|
|
147
|
+
}
|
|
148
|
+
else if (explicitCommunity !== undefined) {
|
|
149
|
+
communityIds = [explicitCommunity];
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const communities = await client.communities();
|
|
153
|
+
communityIds = communities.map((c) => c.id);
|
|
154
|
+
}
|
|
155
|
+
const lists = await Promise.all(communityIds.map(async (community) => {
|
|
156
|
+
const res = await client.request("GET", "/api/tasks", { query: { community } });
|
|
157
|
+
return res.body.tasks;
|
|
158
|
+
}));
|
|
159
|
+
const summary = resolveTaskRef(ref, lists.flat());
|
|
160
|
+
const detailRes = await client.request("GET", `/api/tasks/${encodeURIComponent(summary.community)}/${encodeURIComponent(summary.root)}`);
|
|
161
|
+
return { client, detail: detailRes.body };
|
|
162
|
+
}
|
|
163
|
+
async function loadAgents(client, community) {
|
|
164
|
+
const res = await client.request("GET", "/api/agents", { query: { community } });
|
|
165
|
+
return res.body.agents;
|
|
166
|
+
}
|
|
167
|
+
async function loadDirectory(client, community) {
|
|
168
|
+
const [agentsRes, peopleRes] = await Promise.all([
|
|
169
|
+
client.request("GET", "/api/agents", { query: { community } }),
|
|
170
|
+
client.request("GET", "/api/people", { query: { community } }),
|
|
171
|
+
]);
|
|
172
|
+
const agents = agentsRes.body.agents;
|
|
173
|
+
const people = peopleRes.body.people;
|
|
174
|
+
return {
|
|
175
|
+
agents,
|
|
176
|
+
people,
|
|
177
|
+
names: createNameResolver(agents, people, community),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function taskEndpoint(community, root, action) {
|
|
181
|
+
return `/api/tasks/${encodeURIComponent(community)}/${encodeURIComponent(root)}/${action}`;
|
|
182
|
+
}
|
|
183
|
+
function checkComposedMessage(text, unavailable) {
|
|
184
|
+
if (unavailable !== undefined) {
|
|
185
|
+
throw new CliError(unavailable, { exitCode: EXIT_CONFLICT });
|
|
186
|
+
}
|
|
187
|
+
if (text.length > MAX_MESSAGE_CHARS) {
|
|
188
|
+
throw new CliError(`Message must be at most ${MAX_MESSAGE_CHARS.toLocaleString("en-US")} characters.`, {
|
|
189
|
+
exitCode: EXIT_VALIDATION,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function resolveMentions(selectors, agents) {
|
|
194
|
+
const result = [];
|
|
195
|
+
const seen = new Set();
|
|
196
|
+
for (const selector of selectors) {
|
|
197
|
+
let pubkey;
|
|
198
|
+
if (HEX64.test(selector)) {
|
|
199
|
+
pubkey = selector.toLowerCase();
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
const agent = resolveAgent(selector, agents);
|
|
203
|
+
if (agent.pubkey === null) {
|
|
204
|
+
throw new CliError(`${agent.name} has no profile on the relay yet.`, { exitCode: EXIT_VALIDATION });
|
|
205
|
+
}
|
|
206
|
+
pubkey = agent.pubkey.toLowerCase();
|
|
207
|
+
}
|
|
208
|
+
if (!seen.has(pubkey)) {
|
|
209
|
+
seen.add(pubkey);
|
|
210
|
+
result.push(pubkey);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (result.length > MAX_MENTIONS) {
|
|
214
|
+
throw new CliError(`At most ${MAX_MENTIONS} mentions are allowed (got ${result.length}).`, { exitCode: EXIT_VALIDATION });
|
|
215
|
+
}
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
function mergeMentions(base, extra) {
|
|
219
|
+
const result = [];
|
|
220
|
+
const seen = new Set();
|
|
221
|
+
for (const raw of [...base, ...extra]) {
|
|
222
|
+
const normalized = raw.toLowerCase();
|
|
223
|
+
if (!seen.has(normalized)) {
|
|
224
|
+
seen.add(normalized);
|
|
225
|
+
result.push(normalized);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (result.length > MAX_MENTIONS) {
|
|
229
|
+
throw new CliError(`At most ${MAX_MENTIONS} mentions are allowed (got ${result.length}).`, { exitCode: EXIT_VALIDATION });
|
|
230
|
+
}
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
function resolveTargetReason(task, expected, toOpt, agents, missingMessage) {
|
|
234
|
+
if (task.state.reason?.type === expected) {
|
|
235
|
+
return task.state.reason;
|
|
236
|
+
}
|
|
237
|
+
if (toOpt !== undefined) {
|
|
238
|
+
const agent = resolveAgent(toOpt, agents);
|
|
239
|
+
return syntheticReason(expected, agent.id);
|
|
240
|
+
}
|
|
241
|
+
throw new CliError(missingMessage, { exitCode: EXIT_CONFLICT });
|
|
242
|
+
}
|
|
243
|
+
function resolveCardId(ctx, task) {
|
|
244
|
+
const cardOpt = ctx.opt("card");
|
|
245
|
+
if (cardOpt !== undefined) {
|
|
246
|
+
return validateHex64("card", cardOpt);
|
|
247
|
+
}
|
|
248
|
+
const reasonCard = task.state.reason?.type === "approve" ? task.state.reason.cardId : undefined;
|
|
249
|
+
if (reasonCard !== undefined && reasonCard !== "") {
|
|
250
|
+
return reasonCard;
|
|
251
|
+
}
|
|
252
|
+
throw new CliError(`Task ${task.key} has no open approval card.`, { exitCode: EXIT_CONFLICT });
|
|
253
|
+
}
|
|
254
|
+
/** `create`: preflights and creates a task, optionally applying priority/labels metadata and deleting a promoted draft. */
|
|
255
|
+
export async function cmdCreate(ctx) {
|
|
256
|
+
const { global: g } = ctx;
|
|
257
|
+
const titleOpt = ctx.opt("title");
|
|
258
|
+
const maxReadBytes = (titleOpt === undefined ? MAX_MESSAGE_CHARS : MAX_BODY_CHARS) * 4;
|
|
259
|
+
const bodySource = await readRawTextSource(ctx, "body", maxReadBytes);
|
|
260
|
+
let title;
|
|
261
|
+
let body;
|
|
262
|
+
if (titleOpt === undefined && (bodySource.source === "file" || bodySource.source === "stdin") && bodySource.raw !== undefined) {
|
|
263
|
+
const split = splitDraftBody(bodySource.raw);
|
|
264
|
+
title = split.title.trim();
|
|
265
|
+
body = split.body;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
title = (titleOpt ?? "").trim();
|
|
269
|
+
body = (bodySource.raw ?? "").trim();
|
|
270
|
+
}
|
|
271
|
+
if (title.length > MAX_TITLE_CHARS) {
|
|
272
|
+
throw new CliError(`Task title must be at most ${MAX_TITLE_CHARS} characters.`, { exitCode: EXIT_VALIDATION });
|
|
273
|
+
}
|
|
274
|
+
if (body.length > MAX_BODY_CHARS) {
|
|
275
|
+
throw new CliError(`Task body must be at most ${MAX_BODY_CHARS.toLocaleString("en-US")} characters.`, {
|
|
276
|
+
exitCode: EXIT_VALIDATION,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
const draftId = ctx.opt("draft-id");
|
|
280
|
+
if (draftId !== undefined && !DRAFT_ID_RE.test(draftId)) {
|
|
281
|
+
throw new CliError("--draft-id must be a 16-character draft ID.", { exitCode: EXIT_VALIDATION });
|
|
282
|
+
}
|
|
283
|
+
const labels = splitCsvList([...ctx.optList("labels"), ...ctx.optList("label")]);
|
|
284
|
+
if (labels.length > MAX_LABELS) {
|
|
285
|
+
throw new CliError(`At most ${MAX_LABELS} labels are allowed (got ${labels.length}).`, { exitCode: EXIT_VALIDATION });
|
|
286
|
+
}
|
|
287
|
+
const tooLongLabel = labels.find((label) => label.length > MAX_LABEL_CHARS);
|
|
288
|
+
if (tooLongLabel !== undefined) {
|
|
289
|
+
throw new CliError(`Each label must be at most ${MAX_LABEL_CHARS} characters ('${tooLongLabel}').`, {
|
|
290
|
+
exitCode: EXIT_VALIDATION,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
const kind = ctx.opt("kind");
|
|
294
|
+
const channelOpt = ctx.opt("channel");
|
|
295
|
+
const entryOpt = ctx.opt("entry");
|
|
296
|
+
const priorityOpt = ctx.opt("priority");
|
|
297
|
+
const effectivePriority = priorityOpt ?? "normal";
|
|
298
|
+
const needsMeta = (priorityOpt !== undefined && priorityOpt !== "normal") || labels.length > 0;
|
|
299
|
+
const force = ctx.flag("force");
|
|
300
|
+
const client = ctx.client();
|
|
301
|
+
const communityView = await resolveCreateCommunity(ctx, client);
|
|
302
|
+
const [agents, tasksRes] = await Promise.all([
|
|
303
|
+
loadAgents(client, communityView.id),
|
|
304
|
+
client.request("GET", "/api/tasks", { query: { community: communityView.id } }),
|
|
305
|
+
]);
|
|
306
|
+
const preflight = preflightNewTask({
|
|
307
|
+
community: communityView.id,
|
|
308
|
+
title,
|
|
309
|
+
body,
|
|
310
|
+
...(kind === undefined ? {} : { kind }),
|
|
311
|
+
...(channelOpt === undefined ? {} : { channel: channelOpt }),
|
|
312
|
+
...(entryOpt === undefined ? {} : { entry: entryOpt }),
|
|
313
|
+
channels: communityView.channels,
|
|
314
|
+
agents,
|
|
315
|
+
tasks: tasksRes.body.tasks,
|
|
316
|
+
});
|
|
317
|
+
const blockers = [...preflight.blockers];
|
|
318
|
+
const warnings = [...preflight.warnings];
|
|
319
|
+
if (force && preflight.channel !== null && preflight.entry !== null) {
|
|
320
|
+
const entryAgent = agents.find((a) => a.id === preflight.entry?.id);
|
|
321
|
+
if (entryAgent?.presence === "offline") {
|
|
322
|
+
const offlineBlocker = `${entryAgent.name} is down. Send it once the agent is back.`;
|
|
323
|
+
const index = blockers.indexOf(offlineBlocker);
|
|
324
|
+
if (index !== -1) {
|
|
325
|
+
blockers.splice(index, 1);
|
|
326
|
+
warnings.push(`${offlineBlocker} (bypassed with --force)`);
|
|
327
|
+
if (preflight.template?.id === "hackathons" && kind !== "implementation") {
|
|
328
|
+
const message = body !== "" ? `${title}\n\n${body}` : title;
|
|
329
|
+
const [drafter, second] = hackathonDrafters(message);
|
|
330
|
+
if (drafter === undefined || second !== undefined) {
|
|
331
|
+
blockers.push(HACKATHON_DRAFTER_HINT);
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
const drafterAgent = agents.find((a) => a.id === drafter && a.pubkey !== null);
|
|
335
|
+
if (!Object.hasOwn(preflight.channel.people, drafter) || drafterAgent === undefined) {
|
|
336
|
+
blockers.push("The named drafter is unavailable in #hackathons.");
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const ready = blockers.length === 0 && preflight.channel !== null && preflight.entry !== null;
|
|
344
|
+
const payload = preflight.channel !== null && preflight.entry !== null
|
|
345
|
+
? {
|
|
346
|
+
community: communityView.id,
|
|
347
|
+
channel: preflight.channel.id,
|
|
348
|
+
entry: preflight.entry.id,
|
|
349
|
+
title,
|
|
350
|
+
body,
|
|
351
|
+
...(kind === undefined ? {} : { kind }),
|
|
352
|
+
...(draftId === undefined ? {} : { draftId }),
|
|
353
|
+
}
|
|
354
|
+
: null;
|
|
355
|
+
const meta = needsMeta ? { priority: effectivePriority, labels } : null;
|
|
356
|
+
if (!g.json) {
|
|
357
|
+
for (const warning of warnings) {
|
|
358
|
+
errOut(`Warning: ${displayText(warning)}`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (g.dryRun) {
|
|
362
|
+
const dryDoc = {
|
|
363
|
+
ok: ready,
|
|
364
|
+
dry_run: true,
|
|
365
|
+
action: "create",
|
|
366
|
+
community: communityView.id,
|
|
367
|
+
channel: preflight.channel?.slug ?? null,
|
|
368
|
+
entry: preflight.entry?.id ?? null,
|
|
369
|
+
template: preflight.template?.id ?? null,
|
|
370
|
+
preview_text: preflight.previewText,
|
|
371
|
+
blockers,
|
|
372
|
+
warnings,
|
|
373
|
+
payload,
|
|
374
|
+
meta,
|
|
375
|
+
};
|
|
376
|
+
if (g.json) {
|
|
377
|
+
emitJson(dryDoc);
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
const targetChannel = preflight.channel === null ? "" : ` #${displayText(preflight.channel.slug)}`;
|
|
381
|
+
const targetEntry = preflight.entry === null ? "" : ` -> @${displayText(preflight.entry.name)}`;
|
|
382
|
+
out(`Dry run: create task in ${displayText(communityView.id)}${targetChannel}${targetEntry}`);
|
|
383
|
+
out(`Preview: ${displayText(preflight.previewText)}`);
|
|
384
|
+
if (meta !== null) {
|
|
385
|
+
out(`Meta: priority=${effectivePriority}, labels=${labels.length > 0 ? labels.join(", ") : "(none)"}`);
|
|
386
|
+
}
|
|
387
|
+
for (const blocker of blockers) {
|
|
388
|
+
errOut(`Blocker: ${displayText(blocker)}`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return ready ? EXIT_OK : EXIT_VALIDATION;
|
|
392
|
+
}
|
|
393
|
+
if (!ready || preflight.channel === null || preflight.entry === null || payload === null) {
|
|
394
|
+
const message = blockers.length > 0 ? blockers.join(" ") : "Task preflight failed.";
|
|
395
|
+
throw new CliError(message, {
|
|
396
|
+
exitCode: EXIT_VALIDATION,
|
|
397
|
+
payload: { ok: false, error: "preflight_failed", message, blockers, warnings },
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
const createdRes = await client.request("POST", "/api/tasks", { jsonBody: payload });
|
|
401
|
+
const created = createdRes.body;
|
|
402
|
+
if (needsMeta && meta !== null) {
|
|
403
|
+
await client.request("PUT", taskEndpoint(communityView.id, created.root, "meta"), { jsonBody: meta });
|
|
404
|
+
}
|
|
405
|
+
if (g.json) {
|
|
406
|
+
emitJson({
|
|
407
|
+
ok: true,
|
|
408
|
+
key: created.key,
|
|
409
|
+
root: created.root,
|
|
410
|
+
community: communityView.id,
|
|
411
|
+
channel: preflight.channel.slug,
|
|
412
|
+
entry: preflight.entry.id,
|
|
413
|
+
template: preflight.template?.id ?? null,
|
|
414
|
+
priority: effectivePriority,
|
|
415
|
+
labels,
|
|
416
|
+
warnings,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
out(`Created ${displayText(created.key)} (${displayText(created.root)}) in ${displayText(communityView.id)} ` +
|
|
421
|
+
`#${displayText(preflight.channel.slug)} -> @${displayText(preflight.entry.name)}`);
|
|
422
|
+
}
|
|
423
|
+
return EXIT_OK;
|
|
424
|
+
}
|
|
425
|
+
/** `reply`: posts a message to a task thread with optional mentions, parent event, or `--answer` formatting. */
|
|
426
|
+
export async function cmdReply(ctx) {
|
|
427
|
+
const { global: g } = ctx;
|
|
428
|
+
const ref = requireTaskRef(ctx);
|
|
429
|
+
const text = await readRequiredText(ctx, "text", MAX_MESSAGE_CHARS);
|
|
430
|
+
const parentOpt = ctx.opt("parent");
|
|
431
|
+
const parent = parentOpt === undefined ? undefined : validateHex64("parent", parentOpt);
|
|
432
|
+
const mentionSelectors = splitCsvList(ctx.optList("mention"));
|
|
433
|
+
const asAnswer = ctx.flag("answer");
|
|
434
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
435
|
+
const task = detail.task;
|
|
436
|
+
let finalText = text;
|
|
437
|
+
let mentions = [];
|
|
438
|
+
if (asAnswer) {
|
|
439
|
+
const reason = task.state.reason;
|
|
440
|
+
if (reason === null) {
|
|
441
|
+
throw new CliError(`Task ${task.key} has no open reason to answer.`, { exitCode: EXIT_CONFLICT });
|
|
442
|
+
}
|
|
443
|
+
const { agents, names } = await loadDirectory(client, task.community);
|
|
444
|
+
const composed = composeActionPost("reply", task, reason, names, text);
|
|
445
|
+
checkComposedMessage(composed.text, composed.unavailable);
|
|
446
|
+
finalText = composed.text;
|
|
447
|
+
const explicitMentions = mentionSelectors.length > 0 ? resolveMentions(mentionSelectors, agents) : [];
|
|
448
|
+
mentions = mergeMentions(composed.mentions, explicitMentions);
|
|
449
|
+
}
|
|
450
|
+
else if (mentionSelectors.length > 0) {
|
|
451
|
+
const needsAgents = mentionSelectors.some((item) => !HEX64.test(item));
|
|
452
|
+
const agents = needsAgents ? await loadAgents(client, task.community) : [];
|
|
453
|
+
mentions = resolveMentions(mentionSelectors, agents);
|
|
454
|
+
}
|
|
455
|
+
const payload = {
|
|
456
|
+
text: finalText,
|
|
457
|
+
...(mentions.length > 0 ? { mentions } : {}),
|
|
458
|
+
...(parent === undefined ? {} : { parent }),
|
|
459
|
+
};
|
|
460
|
+
if (g.dryRun) {
|
|
461
|
+
if (g.json) {
|
|
462
|
+
emitJson({ ok: true, dry_run: true, action: "reply", key: task.key, root: task.root, community: task.community, payload });
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
out(`Dry run: would post reply to ${displayText(task.key)} (${displayText(task.community)}).`);
|
|
466
|
+
}
|
|
467
|
+
return EXIT_OK;
|
|
468
|
+
}
|
|
469
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "messages"), {
|
|
470
|
+
jsonBody: payload,
|
|
471
|
+
});
|
|
472
|
+
if (g.json) {
|
|
473
|
+
emitJson({
|
|
474
|
+
ok: true,
|
|
475
|
+
id: res.body.id,
|
|
476
|
+
key: task.key,
|
|
477
|
+
root: task.root,
|
|
478
|
+
community: task.community,
|
|
479
|
+
text: finalText,
|
|
480
|
+
mentions,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
out(`Posted reply to ${displayText(task.key)} (event ${displayText(res.body.id)})`);
|
|
485
|
+
}
|
|
486
|
+
return EXIT_OK;
|
|
487
|
+
}
|
|
488
|
+
/** `answer`: answers a task waiting on a person's answer (or an explicit `--to` agent). */
|
|
489
|
+
export async function cmdAnswer(ctx) {
|
|
490
|
+
const { global: g } = ctx;
|
|
491
|
+
const ref = requireTaskRef(ctx);
|
|
492
|
+
const text = await readRequiredText(ctx, "text", MAX_MESSAGE_CHARS);
|
|
493
|
+
const toOpt = ctx.opt("to");
|
|
494
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
495
|
+
const task = detail.task;
|
|
496
|
+
const { agents, names } = await loadDirectory(client, task.community);
|
|
497
|
+
const targetReason = resolveTargetReason(task, "answer", toOpt, agents, `Task ${task.key} is not waiting for an answer; pass --to <AGENT> to override.`);
|
|
498
|
+
const composed = composeActionPost("reply", task, targetReason, names, text);
|
|
499
|
+
checkComposedMessage(composed.text, composed.unavailable);
|
|
500
|
+
const agentName = names.name(targetReason.by);
|
|
501
|
+
const payload = { text: composed.text, mentions: composed.mentions };
|
|
502
|
+
if (g.dryRun) {
|
|
503
|
+
if (g.json) {
|
|
504
|
+
emitJson({ ok: true, dry_run: true, action: "answer", key: task.key, root: task.root, community: task.community, payload });
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
out(`Dry run: would answer ${displayText(task.key)} -> @${displayText(agentName)}.`);
|
|
508
|
+
}
|
|
509
|
+
return EXIT_OK;
|
|
510
|
+
}
|
|
511
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "messages"), {
|
|
512
|
+
jsonBody: payload,
|
|
513
|
+
});
|
|
514
|
+
if (g.json) {
|
|
515
|
+
emitJson({
|
|
516
|
+
ok: true,
|
|
517
|
+
id: res.body.id,
|
|
518
|
+
key: task.key,
|
|
519
|
+
root: task.root,
|
|
520
|
+
community: task.community,
|
|
521
|
+
text: composed.text,
|
|
522
|
+
mentions: composed.mentions,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
out(`Answered ${displayText(task.key)} -> @${displayText(agentName)} (event ${displayText(res.body.id)})`);
|
|
527
|
+
}
|
|
528
|
+
return EXIT_OK;
|
|
529
|
+
}
|
|
530
|
+
/** `approve`: approves an open approval card immediately without interactive confirmation. */
|
|
531
|
+
export async function cmdApprove(ctx) {
|
|
532
|
+
const { global: g } = ctx;
|
|
533
|
+
const ref = requireTaskRef(ctx);
|
|
534
|
+
const cardOpt = ctx.opt("card");
|
|
535
|
+
if (cardOpt !== undefined) {
|
|
536
|
+
validateHex64("card", cardOpt);
|
|
537
|
+
}
|
|
538
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
539
|
+
const task = detail.task;
|
|
540
|
+
const cardId = resolveCardId(ctx, task);
|
|
541
|
+
const approveReason = task.state.reason?.type === "approve" ? task.state.reason : undefined;
|
|
542
|
+
const payload = { card: cardId };
|
|
543
|
+
if (g.dryRun) {
|
|
544
|
+
if (g.json) {
|
|
545
|
+
emitJson({
|
|
546
|
+
ok: true,
|
|
547
|
+
dry_run: true,
|
|
548
|
+
action: "approve",
|
|
549
|
+
key: task.key,
|
|
550
|
+
root: task.root,
|
|
551
|
+
community: task.community,
|
|
552
|
+
card: cardId,
|
|
553
|
+
...(approveReason?.level === undefined ? {} : { level: approveReason.level }),
|
|
554
|
+
...(approveReason?.need === undefined ? {} : { need: approveReason.need }),
|
|
555
|
+
payload,
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
const details = [
|
|
560
|
+
`card ${displayText(cardId)}`,
|
|
561
|
+
...(approveReason?.level === undefined ? [] : [`risk=${approveReason.level}`]),
|
|
562
|
+
...(approveReason?.need === undefined ? [] : [`need=${approveReason.need}`]),
|
|
563
|
+
];
|
|
564
|
+
out(`Dry run: would approve ${displayText(task.key)} (${details.join(", ")}).`);
|
|
565
|
+
}
|
|
566
|
+
return EXIT_OK;
|
|
567
|
+
}
|
|
568
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "approve"), {
|
|
569
|
+
jsonBody: payload,
|
|
570
|
+
});
|
|
571
|
+
if (g.json) {
|
|
572
|
+
emitJson({ ok: true, id: res.body.id, key: task.key, root: task.root, community: task.community, card: cardId });
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
out(`Approved ${displayText(task.key)} (card ${displayText(cardId)}, event ${displayText(res.body.id)})`);
|
|
576
|
+
}
|
|
577
|
+
return EXIT_OK;
|
|
578
|
+
}
|
|
579
|
+
/** `reject`: rejects an open approval card with a required reason immediately without interactive confirmation. */
|
|
580
|
+
export async function cmdReject(ctx) {
|
|
581
|
+
const { global: g } = ctx;
|
|
582
|
+
const ref = requireTaskRef(ctx);
|
|
583
|
+
const cardOpt = ctx.opt("card");
|
|
584
|
+
if (cardOpt !== undefined) {
|
|
585
|
+
validateHex64("card", cardOpt);
|
|
586
|
+
}
|
|
587
|
+
const reason = await readRequiredText(ctx, "reason", MAX_SHORT_REASON_CHARS);
|
|
588
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
589
|
+
const task = detail.task;
|
|
590
|
+
const cardId = resolveCardId(ctx, task);
|
|
591
|
+
const payload = { card: cardId, reason };
|
|
592
|
+
if (g.dryRun) {
|
|
593
|
+
if (g.json) {
|
|
594
|
+
emitJson({
|
|
595
|
+
ok: true,
|
|
596
|
+
dry_run: true,
|
|
597
|
+
action: "reject",
|
|
598
|
+
key: task.key,
|
|
599
|
+
root: task.root,
|
|
600
|
+
community: task.community,
|
|
601
|
+
card: cardId,
|
|
602
|
+
reason,
|
|
603
|
+
payload,
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
out(`Dry run: would reject ${displayText(task.key)} (card ${displayText(cardId)}): ${displayText(reason)}`);
|
|
608
|
+
}
|
|
609
|
+
return EXIT_OK;
|
|
610
|
+
}
|
|
611
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "reject"), {
|
|
612
|
+
jsonBody: payload,
|
|
613
|
+
});
|
|
614
|
+
if (g.json) {
|
|
615
|
+
emitJson({ ok: true, id: res.body.id, key: task.key, root: task.root, community: task.community, card: cardId, reason });
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
out(`Rejected ${displayText(task.key)} (card ${displayText(cardId)}, event ${displayText(res.body.id)})`);
|
|
619
|
+
}
|
|
620
|
+
return EXIT_OK;
|
|
621
|
+
}
|
|
622
|
+
/** `publish`: tells the agent to publish (or requests a change with `--change`) at the publish stage. */
|
|
623
|
+
export async function cmdPublish(ctx) {
|
|
624
|
+
const { global: g } = ctx;
|
|
625
|
+
const ref = requireTaskRef(ctx);
|
|
626
|
+
const rawChange = ctx.opt("change");
|
|
627
|
+
let changeText;
|
|
628
|
+
if (rawChange !== undefined) {
|
|
629
|
+
const trimmed = rawChange.trim();
|
|
630
|
+
if (trimmed === "") {
|
|
631
|
+
throw new CliError("--change cannot be empty.", { exitCode: EXIT_VALIDATION });
|
|
632
|
+
}
|
|
633
|
+
if (trimmed.length > MAX_MESSAGE_CHARS) {
|
|
634
|
+
throw new CliError(`--change must be at most ${MAX_MESSAGE_CHARS.toLocaleString("en-US")} characters.`, {
|
|
635
|
+
exitCode: EXIT_VALIDATION,
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
changeText = trimmed;
|
|
639
|
+
}
|
|
640
|
+
const toOpt = ctx.opt("to");
|
|
641
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
642
|
+
const task = detail.task;
|
|
643
|
+
const { agents, names } = await loadDirectory(client, task.community);
|
|
644
|
+
const targetReason = resolveTargetReason(task, "publish", toOpt, agents, `Task ${task.key} is not waiting on publish; pass --to <AGENT> to override.`);
|
|
645
|
+
const action = changeText === undefined ? "publish" : "change";
|
|
646
|
+
const composed = changeText === undefined
|
|
647
|
+
? composeActionPost("publish", task, targetReason, names)
|
|
648
|
+
: composeActionPost("change", task, targetReason, names, changeText);
|
|
649
|
+
checkComposedMessage(composed.text, composed.unavailable);
|
|
650
|
+
const payload = { text: composed.text, mentions: composed.mentions };
|
|
651
|
+
if (g.dryRun) {
|
|
652
|
+
if (g.json) {
|
|
653
|
+
emitJson({ ok: true, dry_run: true, action, key: task.key, root: task.root, community: task.community, payload });
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
out(`Dry run: would send ${action} to ${displayText(task.key)}: ${displayText(composed.text)}`);
|
|
657
|
+
}
|
|
658
|
+
return EXIT_OK;
|
|
659
|
+
}
|
|
660
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "messages"), {
|
|
661
|
+
jsonBody: payload,
|
|
662
|
+
});
|
|
663
|
+
if (g.json) {
|
|
664
|
+
emitJson({
|
|
665
|
+
ok: true,
|
|
666
|
+
id: res.body.id,
|
|
667
|
+
key: task.key,
|
|
668
|
+
root: task.root,
|
|
669
|
+
community: task.community,
|
|
670
|
+
action,
|
|
671
|
+
text: composed.text,
|
|
672
|
+
mentions: composed.mentions,
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
else if (action === "change") {
|
|
676
|
+
out(`Requested change on ${displayText(task.key)} (event ${displayText(res.body.id)})`);
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
out(`Sent publish to ${displayText(task.key)} (event ${displayText(res.body.id)})`);
|
|
680
|
+
}
|
|
681
|
+
return EXIT_OK;
|
|
682
|
+
}
|
|
683
|
+
/** `decide`: records a proposal decision (`accepted`, `rejected`, or `done`) with a required reason. */
|
|
684
|
+
export async function cmdDecide(ctx) {
|
|
685
|
+
const { global: g } = ctx;
|
|
686
|
+
const ref = requireTaskRef(ctx);
|
|
687
|
+
const rawDecision = (ctx.positionals[1] ?? "").trim();
|
|
688
|
+
if (!DECISION_CHOICES.includes(rawDecision)) {
|
|
689
|
+
throw new CliError(`Decision must be one of: ${DECISION_CHOICES.join(", ")} (got '${rawDecision}').`, {
|
|
690
|
+
exitCode: EXIT_VALIDATION,
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
const decision = rawDecision;
|
|
694
|
+
const reason = await readRequiredText(ctx, "reason", MAX_DECIDE_REASON_CHARS);
|
|
695
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
696
|
+
const task = detail.task;
|
|
697
|
+
const { names } = await loadDirectory(client, task.community);
|
|
698
|
+
const targetReason = task.state.reason ?? syntheticReason("decide", "person");
|
|
699
|
+
const composed = composeActionPost(decision, task, targetReason, names, reason);
|
|
700
|
+
const payload = { text: composed.text, mentions: [] };
|
|
701
|
+
if (g.dryRun) {
|
|
702
|
+
if (g.json) {
|
|
703
|
+
emitJson({
|
|
704
|
+
ok: true,
|
|
705
|
+
dry_run: true,
|
|
706
|
+
action: "decide",
|
|
707
|
+
key: task.key,
|
|
708
|
+
root: task.root,
|
|
709
|
+
community: task.community,
|
|
710
|
+
decision,
|
|
711
|
+
reason,
|
|
712
|
+
payload,
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
out(`Dry run: would record decision '${decision}' on ${displayText(task.key)}: ${displayText(composed.text)}`);
|
|
717
|
+
}
|
|
718
|
+
return EXIT_OK;
|
|
719
|
+
}
|
|
720
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "messages"), {
|
|
721
|
+
jsonBody: payload,
|
|
722
|
+
});
|
|
723
|
+
if (g.json) {
|
|
724
|
+
emitJson({
|
|
725
|
+
ok: true,
|
|
726
|
+
id: res.body.id,
|
|
727
|
+
key: task.key,
|
|
728
|
+
root: task.root,
|
|
729
|
+
community: task.community,
|
|
730
|
+
decision,
|
|
731
|
+
reason,
|
|
732
|
+
text: composed.text,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
out(`Recorded decision '${decision}' on ${displayText(task.key)} (event ${displayText(res.body.id)})`);
|
|
737
|
+
}
|
|
738
|
+
return EXIT_OK;
|
|
739
|
+
}
|
|
740
|
+
/** `nudge`: nudges a stalled task, preserving quota-bypass wording when an open nudge reason carries `blocked`/`until`. */
|
|
741
|
+
export async function cmdNudge(ctx) {
|
|
742
|
+
const { global: g } = ctx;
|
|
743
|
+
const ref = requireTaskRef(ctx);
|
|
744
|
+
const toOpt = ctx.opt("to");
|
|
745
|
+
const force = ctx.flag("force");
|
|
746
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
747
|
+
const task = detail.task;
|
|
748
|
+
const { agents, names } = await loadDirectory(client, task.community);
|
|
749
|
+
let targetReason;
|
|
750
|
+
if (task.state.reason?.type === "nudge") {
|
|
751
|
+
targetReason = task.state.reason;
|
|
752
|
+
}
|
|
753
|
+
else if (toOpt !== undefined) {
|
|
754
|
+
const agent = resolveAgent(toOpt, agents);
|
|
755
|
+
targetReason = syntheticReason("nudge", agent.id);
|
|
756
|
+
}
|
|
757
|
+
else if (force) {
|
|
758
|
+
const templateInfo = TEMPLATES[task.template];
|
|
759
|
+
const stallNudge = templateInfo.stall?.nudge;
|
|
760
|
+
if (stallNudge === undefined) {
|
|
761
|
+
throw new CliError(`Task ${task.key} has no open nudge reason and template '${task.template}' has no stall nudge agent; pass --to <AGENT>.`, { exitCode: EXIT_CONFLICT });
|
|
762
|
+
}
|
|
763
|
+
targetReason = syntheticReason("nudge", stallNudge);
|
|
764
|
+
}
|
|
765
|
+
else {
|
|
766
|
+
throw new CliError(`Task ${task.key} has no open nudge reason; pass --to <AGENT> or --force.`, {
|
|
767
|
+
exitCode: EXIT_CONFLICT,
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
const composed = composeActionPost("nudge", task, targetReason, names);
|
|
771
|
+
checkComposedMessage(composed.text, composed.unavailable);
|
|
772
|
+
const payload = { text: composed.text, mentions: composed.mentions };
|
|
773
|
+
if (g.dryRun) {
|
|
774
|
+
if (g.json) {
|
|
775
|
+
emitJson({ ok: true, dry_run: true, action: "nudge", key: task.key, root: task.root, community: task.community, payload });
|
|
776
|
+
}
|
|
777
|
+
else {
|
|
778
|
+
out(`Dry run: would nudge ${displayText(task.key)}: ${displayText(composed.text)}`);
|
|
779
|
+
}
|
|
780
|
+
return EXIT_OK;
|
|
781
|
+
}
|
|
782
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "messages"), {
|
|
783
|
+
jsonBody: payload,
|
|
784
|
+
});
|
|
785
|
+
if (g.json) {
|
|
786
|
+
emitJson({
|
|
787
|
+
ok: true,
|
|
788
|
+
id: res.body.id,
|
|
789
|
+
key: task.key,
|
|
790
|
+
root: task.root,
|
|
791
|
+
community: task.community,
|
|
792
|
+
text: composed.text,
|
|
793
|
+
mentions: composed.mentions,
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
else {
|
|
797
|
+
out(`Nudged ${displayText(task.key)} (event ${displayText(res.body.id)})`);
|
|
798
|
+
}
|
|
799
|
+
return EXIT_OK;
|
|
800
|
+
}
|
|
801
|
+
/** `retry`: asks an agent to retry its last turn, guarding against active quota lock windows unless `--force` is passed. */
|
|
802
|
+
export async function cmdRetry(ctx) {
|
|
803
|
+
const { global: g } = ctx;
|
|
804
|
+
const ref = requireTaskRef(ctx);
|
|
805
|
+
const toOpt = ctx.opt("to");
|
|
806
|
+
const force = ctx.flag("force");
|
|
807
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
808
|
+
const task = detail.task;
|
|
809
|
+
const { agents, names } = await loadDirectory(client, task.community);
|
|
810
|
+
const openReason = task.state.reason;
|
|
811
|
+
if (openReason?.type === "retry" && openReason.until !== undefined && openReason.until > Math.floor(Date.now() / 1000) && !force) {
|
|
812
|
+
throw new CliError(`Task ${task.key} is quota-locked until ${formatUtcTime(openReason.until)}. Pass --force to override.`, { exitCode: EXIT_CONFLICT });
|
|
813
|
+
}
|
|
814
|
+
const targetReason = resolveTargetReason(task, "retry", toOpt, agents, `Task ${task.key} has no open retry reason; pass --to <AGENT>.`);
|
|
815
|
+
const composed = composeActionPost("retry", task, targetReason, names);
|
|
816
|
+
checkComposedMessage(composed.text, composed.unavailable);
|
|
817
|
+
const payload = { text: composed.text, mentions: composed.mentions };
|
|
818
|
+
if (g.dryRun) {
|
|
819
|
+
if (g.json) {
|
|
820
|
+
emitJson({ ok: true, dry_run: true, action: "retry", key: task.key, root: task.root, community: task.community, payload });
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
out(`Dry run: would request retry on ${displayText(task.key)}: ${displayText(composed.text)}`);
|
|
824
|
+
}
|
|
825
|
+
return EXIT_OK;
|
|
826
|
+
}
|
|
827
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "messages"), {
|
|
828
|
+
jsonBody: payload,
|
|
829
|
+
});
|
|
830
|
+
if (g.json) {
|
|
831
|
+
emitJson({
|
|
832
|
+
ok: true,
|
|
833
|
+
id: res.body.id,
|
|
834
|
+
key: task.key,
|
|
835
|
+
root: task.root,
|
|
836
|
+
community: task.community,
|
|
837
|
+
text: composed.text,
|
|
838
|
+
mentions: composed.mentions,
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
out(`Requested retry on ${displayText(task.key)} (event ${displayText(res.body.id)})`);
|
|
843
|
+
}
|
|
844
|
+
return EXIT_OK;
|
|
845
|
+
}
|
|
846
|
+
/** `unblock`: posts an unblock update mentioning the blocked agent. */
|
|
847
|
+
export async function cmdUnblock(ctx) {
|
|
848
|
+
const { global: g } = ctx;
|
|
849
|
+
const ref = requireTaskRef(ctx);
|
|
850
|
+
const text = await readRequiredText(ctx, "text", MAX_MESSAGE_CHARS);
|
|
851
|
+
const toOpt = ctx.opt("to");
|
|
852
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
853
|
+
const task = detail.task;
|
|
854
|
+
const { agents, names } = await loadDirectory(client, task.community);
|
|
855
|
+
const targetReason = resolveTargetReason(task, "unblock", toOpt, agents, `Task ${task.key} has no open unblock reason; pass --to <AGENT>.`);
|
|
856
|
+
const composed = composeActionPost("unblocked", task, targetReason, names, text);
|
|
857
|
+
checkComposedMessage(composed.text, composed.unavailable);
|
|
858
|
+
const payload = { text: composed.text, mentions: composed.mentions };
|
|
859
|
+
if (g.dryRun) {
|
|
860
|
+
if (g.json) {
|
|
861
|
+
emitJson({ ok: true, dry_run: true, action: "unblock", key: task.key, root: task.root, community: task.community, payload });
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
out(`Dry run: would post unblock update on ${displayText(task.key)}: ${displayText(composed.text)}`);
|
|
865
|
+
}
|
|
866
|
+
return EXIT_OK;
|
|
867
|
+
}
|
|
868
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "messages"), {
|
|
869
|
+
jsonBody: payload,
|
|
870
|
+
});
|
|
871
|
+
if (g.json) {
|
|
872
|
+
emitJson({
|
|
873
|
+
ok: true,
|
|
874
|
+
id: res.body.id,
|
|
875
|
+
key: task.key,
|
|
876
|
+
root: task.root,
|
|
877
|
+
community: task.community,
|
|
878
|
+
text: composed.text,
|
|
879
|
+
mentions: composed.mentions,
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
else {
|
|
883
|
+
out(`Posted unblock update on ${displayText(task.key)} (event ${displayText(res.body.id)})`);
|
|
884
|
+
}
|
|
885
|
+
return EXIT_OK;
|
|
886
|
+
}
|
|
887
|
+
function selectResolveEvent(task, events, agents) {
|
|
888
|
+
const agentPubkeys = new Set();
|
|
889
|
+
for (const agent of agents) {
|
|
890
|
+
if (agent.pubkey !== null) {
|
|
891
|
+
agentPubkeys.add(agent.pubkey.toLowerCase());
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
const newestFirst = events
|
|
895
|
+
.map((ev, index) => ({ ev, index }))
|
|
896
|
+
.filter(({ ev }) => ev.kind === 9)
|
|
897
|
+
.sort((a, b) => b.ev.created_at - a.ev.created_at || b.index - a.index)
|
|
898
|
+
.map(({ ev }) => ev);
|
|
899
|
+
const rootLower = task.root.toLowerCase();
|
|
900
|
+
const requesterLower = task.requester?.toLowerCase() ?? null;
|
|
901
|
+
const agentAuthored = newestFirst.find((ev) => agentPubkeys.has(ev.pubkey.toLowerCase()) ||
|
|
902
|
+
(ev.id.toLowerCase() !== rootLower && (requesterLower === null || ev.pubkey.toLowerCase() !== requesterLower)));
|
|
903
|
+
const nonRoot = newestFirst.find((ev) => ev.id.toLowerCase() !== rootLower);
|
|
904
|
+
const selected = agentAuthored ?? nonRoot ?? newestFirst[0];
|
|
905
|
+
if (selected === undefined) {
|
|
906
|
+
throw new CliError(`Task ${task.key} has no message event to resolve.`, { exitCode: EXIT_CONFLICT });
|
|
907
|
+
}
|
|
908
|
+
return selected.id;
|
|
909
|
+
}
|
|
910
|
+
/** `resolve`: marks an answer event as resolved (auto-selecting the newest agent message when `--event` is omitted). */
|
|
911
|
+
export async function cmdResolve(ctx) {
|
|
912
|
+
const { global: g } = ctx;
|
|
913
|
+
const ref = requireTaskRef(ctx);
|
|
914
|
+
const eventOpt = ctx.opt("event");
|
|
915
|
+
const explicitEvent = eventOpt === undefined ? undefined : validateHex64("event", eventOpt);
|
|
916
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
917
|
+
const task = detail.task;
|
|
918
|
+
let eventId;
|
|
919
|
+
if (explicitEvent !== undefined) {
|
|
920
|
+
const matched = detail.events.find((ev) => ev.id.toLowerCase() === explicitEvent);
|
|
921
|
+
if (matched === undefined) {
|
|
922
|
+
throw new CliError(`Event ${explicitEvent} does not belong to task ${task.key}.`, { exitCode: EXIT_VALIDATION });
|
|
923
|
+
}
|
|
924
|
+
eventId = matched.id;
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
const agents = await loadAgents(client, task.community);
|
|
928
|
+
eventId = selectResolveEvent(task, detail.events, agents);
|
|
929
|
+
}
|
|
930
|
+
const payload = { event: eventId };
|
|
931
|
+
if (g.dryRun) {
|
|
932
|
+
if (g.json) {
|
|
933
|
+
emitJson({
|
|
934
|
+
ok: true,
|
|
935
|
+
dry_run: true,
|
|
936
|
+
action: "resolve",
|
|
937
|
+
key: task.key,
|
|
938
|
+
root: task.root,
|
|
939
|
+
community: task.community,
|
|
940
|
+
event: eventId,
|
|
941
|
+
payload,
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
else {
|
|
945
|
+
out(`Dry run: would resolve ${displayText(task.key)} (answered event ${displayText(eventId)}).`);
|
|
946
|
+
}
|
|
947
|
+
return EXIT_OK;
|
|
948
|
+
}
|
|
949
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "resolve"), {
|
|
950
|
+
jsonBody: payload,
|
|
951
|
+
});
|
|
952
|
+
if (g.json) {
|
|
953
|
+
emitJson({ ok: true, id: res.body.id, key: task.key, root: task.root, community: task.community, event: eventId });
|
|
954
|
+
}
|
|
955
|
+
else {
|
|
956
|
+
out(`Resolved ${displayText(task.key)} (answered event ${displayText(eventId)}, reaction ${displayText(res.body.id)})`);
|
|
957
|
+
}
|
|
958
|
+
return EXIT_OK;
|
|
959
|
+
}
|
|
960
|
+
/** `cancel`: cancels an open task immediately without interactive confirmation. */
|
|
961
|
+
export async function cmdCancel(ctx) {
|
|
962
|
+
const { global: g } = ctx;
|
|
963
|
+
const ref = requireTaskRef(ctx);
|
|
964
|
+
const reason = await readOptionalText(ctx, "reason", MAX_SHORT_REASON_CHARS);
|
|
965
|
+
const { client, detail } = await loadTaskDetail(ctx, ref);
|
|
966
|
+
const task = detail.task;
|
|
967
|
+
if (task.col === "done" || task.col === "canceled") {
|
|
968
|
+
throw new CliError(`Task ${task.key} is already ${task.col}.`, { exitCode: EXIT_CONFLICT });
|
|
969
|
+
}
|
|
970
|
+
const payload = reason === undefined ? {} : { reason };
|
|
971
|
+
if (g.dryRun) {
|
|
972
|
+
if (g.json) {
|
|
973
|
+
emitJson({
|
|
974
|
+
ok: true,
|
|
975
|
+
dry_run: true,
|
|
976
|
+
action: "cancel",
|
|
977
|
+
key: task.key,
|
|
978
|
+
root: task.root,
|
|
979
|
+
community: task.community,
|
|
980
|
+
...(reason === undefined ? {} : { reason }),
|
|
981
|
+
payload,
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
out(`Dry run: would cancel ${displayText(task.key)}${reason === undefined ? "" : ` (${displayText(reason)})`}.`);
|
|
986
|
+
}
|
|
987
|
+
return EXIT_OK;
|
|
988
|
+
}
|
|
989
|
+
const res = await client.request("POST", taskEndpoint(task.community, task.root, "cancel"), {
|
|
990
|
+
jsonBody: payload,
|
|
991
|
+
});
|
|
992
|
+
if (g.json) {
|
|
993
|
+
emitJson({
|
|
994
|
+
ok: true,
|
|
995
|
+
id: res.body.id,
|
|
996
|
+
key: task.key,
|
|
997
|
+
root: task.root,
|
|
998
|
+
community: task.community,
|
|
999
|
+
...(reason === undefined ? {} : { reason }),
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
out(`Canceled ${displayText(task.key)} (event ${displayText(res.body.id)})`);
|
|
1004
|
+
}
|
|
1005
|
+
return EXIT_OK;
|
|
1006
|
+
}
|
|
1007
|
+
const TEXT_SOURCE_OPTIONS = {
|
|
1008
|
+
text: { type: "string", placeholder: "TEXT", description: "Message text (at most 65,536 characters)" },
|
|
1009
|
+
"text-file": { type: "string", placeholder: "PATH", description: "Read message text from a UTF-8 file" },
|
|
1010
|
+
"text-stdin": { type: "boolean", description: "Read message text from stdin" },
|
|
1011
|
+
};
|
|
1012
|
+
const SHORT_REASON_OPTIONS = {
|
|
1013
|
+
reason: { type: "string", placeholder: "TEXT", description: "Reason text (at most 2,000 characters)" },
|
|
1014
|
+
"reason-file": { type: "string", placeholder: "PATH", description: "Read reason text from a UTF-8 file" },
|
|
1015
|
+
"reason-stdin": { type: "boolean", description: "Read reason text from stdin" },
|
|
1016
|
+
};
|
|
1017
|
+
const DECIDE_REASON_OPTIONS = {
|
|
1018
|
+
reason: { type: "string", placeholder: "TEXT", description: "Decision reason (at most 65,000 characters)" },
|
|
1019
|
+
"reason-file": { type: "string", placeholder: "PATH", description: "Read decision reason from a UTF-8 file" },
|
|
1020
|
+
"reason-stdin": { type: "boolean", description: "Read decision reason from stdin" },
|
|
1021
|
+
};
|
|
1022
|
+
const CREATE_OPTIONS = {
|
|
1023
|
+
title: { type: "string", placeholder: "TEXT", description: "Task title (at most 200 characters)" },
|
|
1024
|
+
body: { type: "string", placeholder: "TEXT", description: "Task detail body (at most 60,000 characters)" },
|
|
1025
|
+
"body-file": {
|
|
1026
|
+
type: "string",
|
|
1027
|
+
placeholder: "PATH",
|
|
1028
|
+
description: "Read task body (or title + body when --title is omitted) from a UTF-8 file",
|
|
1029
|
+
},
|
|
1030
|
+
"body-stdin": {
|
|
1031
|
+
type: "boolean",
|
|
1032
|
+
description: "Read task body (or title + body when --title is omitted) from stdin",
|
|
1033
|
+
},
|
|
1034
|
+
kind: { type: "string", placeholder: "K", choices: TASK_KIND_CHOICES, description: "Task workflow kind" },
|
|
1035
|
+
channel: { type: "string", placeholder: "C", description: "Target channel slug or ID" },
|
|
1036
|
+
entry: { type: "string", placeholder: "A", description: "Entry agent ID or display name" },
|
|
1037
|
+
priority: { type: "string", placeholder: "P", choices: PRIORITIES, description: "Initial task priority" },
|
|
1038
|
+
labels: { type: "string", placeholder: "L", multiple: true, description: "Comma-separated labels (at most 10 total)" },
|
|
1039
|
+
label: { type: "string", placeholder: "L", multiple: true, description: "Single label (repeatable)" },
|
|
1040
|
+
"draft-id": { type: "string", placeholder: "ID", description: "Existing 16-character draft ID to promote and delete" },
|
|
1041
|
+
force: { type: "boolean", description: "Bypass soft blockers such as an offline entry agent" },
|
|
1042
|
+
};
|
|
1043
|
+
const REPLY_OPTIONS = {
|
|
1044
|
+
...TEXT_SOURCE_OPTIONS,
|
|
1045
|
+
mention: {
|
|
1046
|
+
type: "string",
|
|
1047
|
+
placeholder: "AGENT",
|
|
1048
|
+
multiple: true,
|
|
1049
|
+
description: "Agent selector or 64-hex pubkey to mention (repeatable or CSV, max 50)",
|
|
1050
|
+
},
|
|
1051
|
+
parent: { type: "string", placeholder: "EVENT_ID", description: "Optional 64-hex parent event ID" },
|
|
1052
|
+
answer: { type: "boolean", description: "Format as an @Agent answer using the task's open reason" },
|
|
1053
|
+
};
|
|
1054
|
+
const ANSWER_OPTIONS = {
|
|
1055
|
+
...TEXT_SOURCE_OPTIONS,
|
|
1056
|
+
to: { type: "string", placeholder: "AGENT", description: "Target agent selector when no open answer reason exists" },
|
|
1057
|
+
};
|
|
1058
|
+
const APPROVE_OPTIONS = {
|
|
1059
|
+
card: { type: "string", placeholder: "EVENT_ID", description: "Explicit 64-hex approval card event ID" },
|
|
1060
|
+
};
|
|
1061
|
+
const REJECT_OPTIONS = {
|
|
1062
|
+
...SHORT_REASON_OPTIONS,
|
|
1063
|
+
card: { type: "string", placeholder: "EVENT_ID", description: "Explicit 64-hex approval card event ID" },
|
|
1064
|
+
};
|
|
1065
|
+
const PUBLISH_OPTIONS = {
|
|
1066
|
+
change: { type: "string", placeholder: "TEXT", description: "Request a change instead of publishing" },
|
|
1067
|
+
to: { type: "string", placeholder: "AGENT", description: "Target agent selector when no open publish reason exists" },
|
|
1068
|
+
};
|
|
1069
|
+
const NUDGE_OPTIONS = {
|
|
1070
|
+
to: { type: "string", placeholder: "AGENT", description: "Target agent selector to nudge" },
|
|
1071
|
+
force: { type: "boolean", description: "Fall back to the template's stall nudge agent" },
|
|
1072
|
+
};
|
|
1073
|
+
const RETRY_OPTIONS = {
|
|
1074
|
+
to: { type: "string", placeholder: "AGENT", description: "Target agent selector to ask for a retry" },
|
|
1075
|
+
force: { type: "boolean", description: "Override an active quota lock window" },
|
|
1076
|
+
};
|
|
1077
|
+
const UNBLOCK_OPTIONS = {
|
|
1078
|
+
...TEXT_SOURCE_OPTIONS,
|
|
1079
|
+
to: { type: "string", placeholder: "AGENT", description: "Target agent selector when no open unblock reason exists" },
|
|
1080
|
+
};
|
|
1081
|
+
const RESOLVE_OPTIONS = {
|
|
1082
|
+
event: { type: "string", placeholder: "EVENT_ID", description: "Explicit 64-hex event ID to mark as the answer" },
|
|
1083
|
+
};
|
|
1084
|
+
export const actionCommands = [
|
|
1085
|
+
{
|
|
1086
|
+
name: "create",
|
|
1087
|
+
summary: "Preflight and create a new task with optional priority, labels, and draft promotion",
|
|
1088
|
+
usage: "create [--title TEXT] [--body TEXT | --body-file PATH | --body-stdin] [--kind K] [--channel C] [--entry A] [--priority P] [--labels L] [--label L] [--draft-id ID] [--force]",
|
|
1089
|
+
options: CREATE_OPTIONS,
|
|
1090
|
+
positionals: { min: 0, max: 0 },
|
|
1091
|
+
handler: cmdCreate,
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
name: "reply",
|
|
1095
|
+
summary: "Post a message to a task thread",
|
|
1096
|
+
usage: "reply <TASK_REF> (--text TEXT | --text-file PATH | --text-stdin) [--mention AGENT]... [--parent EVENT_ID] [--answer]",
|
|
1097
|
+
options: REPLY_OPTIONS,
|
|
1098
|
+
positionals: { min: 1, max: 1 },
|
|
1099
|
+
handler: cmdReply,
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
name: "answer",
|
|
1103
|
+
summary: "Answer an agent question on a task",
|
|
1104
|
+
usage: "answer <TASK_REF> (--text TEXT | --text-file PATH | --text-stdin) [--to AGENT]",
|
|
1105
|
+
options: ANSWER_OPTIONS,
|
|
1106
|
+
positionals: { min: 1, max: 1 },
|
|
1107
|
+
handler: cmdAnswer,
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
name: "approve",
|
|
1111
|
+
summary: "Approve an open task approval card",
|
|
1112
|
+
usage: "approve <TASK_REF> [--card EVENT_ID]",
|
|
1113
|
+
options: APPROVE_OPTIONS,
|
|
1114
|
+
positionals: { min: 1, max: 1 },
|
|
1115
|
+
handler: cmdApprove,
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
name: "reject",
|
|
1119
|
+
summary: "Reject an open task approval card with a reason",
|
|
1120
|
+
usage: "reject <TASK_REF> (--reason TEXT | --reason-file PATH | --reason-stdin) [--card EVENT_ID]",
|
|
1121
|
+
options: REJECT_OPTIONS,
|
|
1122
|
+
positionals: { min: 1, max: 1 },
|
|
1123
|
+
handler: cmdReject,
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
name: "publish",
|
|
1127
|
+
summary: "Send publish or request a change at the publish stage",
|
|
1128
|
+
usage: "publish <TASK_REF> [--change TEXT] [--to AGENT]",
|
|
1129
|
+
options: PUBLISH_OPTIONS,
|
|
1130
|
+
positionals: { min: 1, max: 1 },
|
|
1131
|
+
handler: cmdPublish,
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
name: "decide",
|
|
1135
|
+
summary: "Record an accepted, rejected, or done proposal decision",
|
|
1136
|
+
usage: "decide <TASK_REF> <accepted|rejected|done> (--reason TEXT | --reason-file PATH | --reason-stdin)",
|
|
1137
|
+
options: DECIDE_REASON_OPTIONS,
|
|
1138
|
+
positionals: { min: 2, max: 2 },
|
|
1139
|
+
handler: cmdDecide,
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
name: "nudge",
|
|
1143
|
+
summary: "Nudge a stalled task thread to continue",
|
|
1144
|
+
usage: "nudge <TASK_REF> [--to AGENT] [--force]",
|
|
1145
|
+
options: NUDGE_OPTIONS,
|
|
1146
|
+
positionals: { min: 1, max: 1 },
|
|
1147
|
+
handler: cmdNudge,
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
name: "retry",
|
|
1151
|
+
summary: "Ask an agent to retry its last turn",
|
|
1152
|
+
usage: "retry <TASK_REF> [--to AGENT] [--force]",
|
|
1153
|
+
options: RETRY_OPTIONS,
|
|
1154
|
+
positionals: { min: 1, max: 1 },
|
|
1155
|
+
handler: cmdRetry,
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
name: "unblock",
|
|
1159
|
+
summary: "Post an unblock update to a blocked task",
|
|
1160
|
+
usage: "unblock <TASK_REF> (--text TEXT | --text-file PATH | --text-stdin) [--to AGENT]",
|
|
1161
|
+
options: UNBLOCK_OPTIONS,
|
|
1162
|
+
positionals: { min: 1, max: 1 },
|
|
1163
|
+
handler: cmdUnblock,
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
name: "resolve",
|
|
1167
|
+
summary: "Mark a task answer event as resolved",
|
|
1168
|
+
usage: "resolve <TASK_REF> [--event EVENT_ID]",
|
|
1169
|
+
options: RESOLVE_OPTIONS,
|
|
1170
|
+
positionals: { min: 1, max: 1 },
|
|
1171
|
+
handler: cmdResolve,
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
name: "cancel",
|
|
1175
|
+
summary: "Cancel an open task with an optional reason",
|
|
1176
|
+
usage: "cancel <TASK_REF> [--reason TEXT | --reason-file PATH | --reason-stdin]",
|
|
1177
|
+
options: SHORT_REASON_OPTIONS,
|
|
1178
|
+
positionals: { min: 1, max: 1 },
|
|
1179
|
+
handler: cmdCancel,
|
|
1180
|
+
},
|
|
1181
|
+
];
|