@pxlabz/tasq-cli 0.1.1 → 0.1.3
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/.tasq-skill.md +135 -0
- package/README.md +40 -4
- package/dist/tasq.js +533 -173
- package/examples/mention-runner.sh +110 -0
- package/package.json +4 -2
package/.tasq-skill.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tasq
|
|
3
|
+
description: Read and write Tasq tasks, projects, threads, comments and mentions from the shell with the `tasq` CLI. Use when you are working in a repository whose issues live in Tasq, when someone asks you to look at a task by its key (ENG-42), when you need to comment on or update a task, or when you are running as a Tasq agent and want to receive the mentions and thread messages addressed to you. Covers authentication, the full command reference, the mention-reply-ack workflow, threads, exit codes, and the agent isolation rule.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tasq
|
|
7
|
+
|
|
8
|
+
Tasq is a task tracker whose write path is one action registry, reachable equally by a person in the web app and by an agent holding a key — the same permission checks and the same audit trail either way. The `tasq` CLI is that surface for a shell.
|
|
9
|
+
|
|
10
|
+
Tasq is not an agent runtime. It stores work, delivers mentions addressed to you, and records what you did. It never starts, supervises, or schedules you; that harness is the owner's.
|
|
11
|
+
|
|
12
|
+
## When to use it
|
|
13
|
+
|
|
14
|
+
- A task key like `ENG-42` appears in a request, a branch name, or a commit message.
|
|
15
|
+
- You have been asked to read, create, update, or comment on a task.
|
|
16
|
+
- You are running under a Tasq agent key and want the mentions queued for you.
|
|
17
|
+
|
|
18
|
+
Do not reach for it to store notes that belong in the repository, and do not create tasks nobody asked for.
|
|
19
|
+
|
|
20
|
+
## Authentication
|
|
21
|
+
|
|
22
|
+
The CLI reads its credentials from the environment. Nothing needs to be installed beyond the CLI itself.
|
|
23
|
+
|
|
24
|
+
| Variable | Meaning |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `TASQ_API_KEY` | Agent key (`tq_ag_…`). This is what you hold when you run as an agent. |
|
|
27
|
+
| `TASQ_WORKSPACE` | Default workspace slug, so commands need no `--workspace`. |
|
|
28
|
+
| `TASQ_API_URL` | API origin. Defaults to `https://tasq.pxlabz.com`. |
|
|
29
|
+
|
|
30
|
+
A human instead runs `tasq auth login` once, which stores a user token. If `TASQ_API_KEY` is set it wins over any stored token. Never print a key, and never write one into a file in the repository.
|
|
31
|
+
|
|
32
|
+
## Command reference
|
|
33
|
+
|
|
34
|
+
Global flags, valid on every command: `-w, --workspace <slug>`, `--api-url <url>`, `--json`. Task refs accept the human key (`ENG-42`) or the UUID.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
tasq workspace list
|
|
38
|
+
tasq workspace use <slug>
|
|
39
|
+
|
|
40
|
+
tasq task list [--team <identifier>] [--status <name>] [--assignee <id>]
|
|
41
|
+
[--priority urgent|high|medium|low|none] [--project <id>]
|
|
42
|
+
[--cycle <id>] [-q, --q <text>] [--include-archived]
|
|
43
|
+
tasq task view <ref>
|
|
44
|
+
tasq task create <title> [--team <identifier>] [--description <markdown>]
|
|
45
|
+
[--priority <priority>] [--project <id>]
|
|
46
|
+
[--labels <a,b,c>]
|
|
47
|
+
tasq task update <ref> [--title <title>] [--description <markdown>]
|
|
48
|
+
[--priority <priority>] [--status <name>]
|
|
49
|
+
|
|
50
|
+
tasq comment add <ref> <body> [--reply-to <commentRef>] [--thread <threadId>]
|
|
51
|
+
[--mention <agentName>]…
|
|
52
|
+
tasq comment add --project <id|name> <body> [--reply-to <commentRef>]
|
|
53
|
+
[--thread <threadId>] [--mention <agentName>]…
|
|
54
|
+
|
|
55
|
+
tasq thread view <threadId>
|
|
56
|
+
tasq thread context <threadId> [--markdown]
|
|
57
|
+
|
|
58
|
+
tasq events listen [--wait <seconds>] [--once]
|
|
59
|
+
tasq events ack <id>…
|
|
60
|
+
|
|
61
|
+
tasq project list
|
|
62
|
+
tasq cycle current [--team <identifier>]
|
|
63
|
+
|
|
64
|
+
tasq auth login [--email <email>]
|
|
65
|
+
tasq auth logout
|
|
66
|
+
tasq auth whoami
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`--mention` is repeatable and matches an agent name exactly, ignoring case.
|
|
70
|
+
|
|
71
|
+
`task view` and `thread view` print every message with its id on the header line, as ` <createdAt> <author> #<id>` with the body indented beneath it. That `#<id>` is what `--reply-to` and `--thread` take; the `ENG-42#<id>` form is also accepted. The parent must be a message on the same task or project.
|
|
72
|
+
|
|
73
|
+
`--thread <threadId>` is an alias for `--reply-to` that reads right when you are answering an event: the `threadId` an event carries is exactly what it wants. Passing both is fine if they name the same message; two different ids is a usage error.
|
|
74
|
+
|
|
75
|
+
A comment goes on a task or a project, never both and never neither: give the task ref as the argument, or pass `--project <id|name>` instead. Project names match exactly, ignoring case.
|
|
76
|
+
|
|
77
|
+
## When you are mentioned
|
|
78
|
+
|
|
79
|
+
`tasq events listen` prints NDJSON — one compact JSON object per line, per event — whatever `--json` says, because it is meant to be read by a loop. Each object carries ids only: `{ id, kind, workspace, taskId, taskKey, projectId, threadId, commentId, mentionedBy, deliveryCount, createdAt }`. `kind` is `mention` or `thread_message`; exactly one of `taskId` and `projectId` is set. There is no comment body in the event, on purpose: every read you make from those ids goes through your policy, so you see exactly what you are allowed to see.
|
|
80
|
+
|
|
81
|
+
The loop is:
|
|
82
|
+
|
|
83
|
+
1. **Listen.** `tasq events listen --wait 20`. Each poll holds the connection open for up to 25 seconds and costs one read, so a listener is about three reads a minute.
|
|
84
|
+
2. **Read the task.** `tasq task view <taskKey> --json`. This is where the body of the mention, the rest of the thread, and the task's state come from.
|
|
85
|
+
3. **Gather context.** `tasq thread context <threadId>` assembles the entity, the transcript and the recent activity in one call — see **Threads** below. The `task view` payload carries the same comments and activity log if the mention is on a task and you want the raw shape. Read before you write.
|
|
86
|
+
4. **Reply in the thread.** `tasq comment add <taskKey> "…" --thread <threadId>`, using the `threadId` from the event so your answer lands in the conversation rather than at the bottom. On a project mention, `tasq comment add --project <id|name> "…" --thread <threadId>`.
|
|
87
|
+
5. **Acknowledge.** `tasq events ack <eventId>`, and only after the work is done.
|
|
88
|
+
|
|
89
|
+
Ack last, deliberately. An unacknowledged event is offered again ten minutes after delivery, so a crash between step 2 and step 4 costs nothing; an event acked up front is gone. On a 429 the listener sleeps for `Retry-After` and carries on rather than exiting, so do not wrap it in a restart loop that would spend the same budget twice.
|
|
90
|
+
|
|
91
|
+
`examples/mention-runner.sh` in this package is a working reference for steps 1 and 5. It is an example, not a product.
|
|
92
|
+
|
|
93
|
+
## Threads
|
|
94
|
+
|
|
95
|
+
A thread is a root message and its replies, on a task or on a project. Its id — the `threadId` an event carries — is the root message's id.
|
|
96
|
+
|
|
97
|
+
Two event kinds reach you, and they mean different things:
|
|
98
|
+
|
|
99
|
+
- **`mention`** is a request addressed to you. Somebody typed your name. Read it and act.
|
|
100
|
+
- **`thread_message`** is a later human message in a thread you are already in — you were mentioned in it once, or you have spoken in it, so Tasq keeps sending you the conversation without the human re-typing `@`. Read it, and reply only if it actually needs you. Most of the time it is context, not a request; a thread does not need you to answer every turn.
|
|
101
|
+
|
|
102
|
+
Start from the context bundle rather than guessing which entity the thread is on:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
tasq thread context <threadId>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
That prints a Markdown prompt with four sections in a fixed order — **Entity**, **Thread**, **Recent activity**, **Participants** — covering the task or project the thread hangs off, the transcript so far, what else happened on that entity, and who is in the conversation. `--json` gives the same bundle raw if you would rather branch on the fields. The lists are capped (last 50 messages, last 20 activity rows, description cut at 8k chars); anything cut says so, so a `_(showing last 50 of 130 messages)_` line means there is more you are not seeing.
|
|
109
|
+
|
|
110
|
+
`tasq thread view <threadId>` is the short form: the entity line and the transcript with each message's id, when all you need is an id to reply to.
|
|
111
|
+
|
|
112
|
+
Reply into the thread with the id the event gave you, whichever entity it is on:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
tasq comment add <taskKey> "…" --thread <threadId>
|
|
116
|
+
tasq comment add --project <projectName> "…" --thread <threadId>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Acknowledge both kinds the same way, with `tasq events ack <eventId>`, and only after you are done — including when you decide a `thread_message` needed nothing from you. An unacked event comes back in ten minutes.
|
|
120
|
+
|
|
121
|
+
Isolation still holds inside a thread: another agent's messages never reach you, and yours never wake another agent. If a thread needs work you cannot do, say so in the thread for a person to pick up.
|
|
122
|
+
|
|
123
|
+
## Exit codes
|
|
124
|
+
|
|
125
|
+
| Code | Meaning |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| 0 | Success |
|
|
128
|
+
| 1 | Error; details on stderr |
|
|
129
|
+
| 2 | Usage error — a bad flag, or a `--mention` name matching no agent or more than one |
|
|
130
|
+
| 3 | Rate limited; the message says when to retry. `events listen` never exits here — it waits and continues |
|
|
131
|
+
| 4 | Your policy denied the action. Do not retry it; say what was refused |
|
|
132
|
+
|
|
133
|
+
## Isolation
|
|
134
|
+
|
|
135
|
+
Agents do not deliver mentions to each other. If you `--mention` another agent, the mention is recorded as suppressed and never delivered — the CLI tells you so on the line it prints. The same holds for threads: a message you post never produces a `thread_message` event for any other agent participant, and another agent's messages never reach you. Escalate to a person in the thread instead of trying to hand work to another agent.
|
package/README.md
CHANGED
|
@@ -27,7 +27,9 @@ TASQ_API_KEY=tq_ag_… TASQ_WORKSPACE=acme tasq task list
|
|
|
27
27
|
```
|
|
28
28
|
tasq workspace list | use <slug>
|
|
29
29
|
tasq task list | view <ref> | create | update <ref>
|
|
30
|
-
tasq comment add <ref>
|
|
30
|
+
tasq comment add <ref> <body> [--reply-to <commentRef>] [--mention <agentName>]…
|
|
31
|
+
tasq events listen [--wait <seconds>] [--once]
|
|
32
|
+
tasq events ack <id>…
|
|
31
33
|
tasq project list
|
|
32
34
|
tasq cycle current
|
|
33
35
|
tasq auth login | logout
|
|
@@ -35,6 +37,40 @@ tasq auth login | logout
|
|
|
35
37
|
|
|
36
38
|
Every command takes `--json` for raw output and `-w, --workspace <slug>` to override the default. Task refs accept either the human key (`ENG-42`) or the UUID.
|
|
37
39
|
|
|
40
|
+
### Mentions and replies
|
|
41
|
+
|
|
42
|
+
`--mention <agentName>` is repeatable and matches an agent's name exactly, ignoring case. Two agents answering to one name is a usage error (exit 2) rather than a guess. After the comment is written, one line per mention says `delivered to <name>`, or `<name>: suppressed: agents are isolated` when one agent mentioned another — agents do not deliver mentions to each other in this release.
|
|
43
|
+
|
|
44
|
+
`--reply-to` takes a comment id, or the `ENG-42#<id>` form `task view` prints. The parent must be a comment on the same task.
|
|
45
|
+
|
|
46
|
+
### Listening for mentions
|
|
47
|
+
|
|
48
|
+
`tasq events listen` streams NDJSON — one compact JSON object per line, per event — whatever `--json` says, because the output is meant for a runner loop rather than a reader:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
TASQ_API_KEY=tq_ag_… TASQ_WORKSPACE=acme tasq events listen --wait 20 |
|
|
52
|
+
while read -r event; do handle "$event"; done
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Each poll holds the connection open for up to `--wait` seconds (0-25; the server clamps) and is charged once against the read budget, so `--wait 20` costs at most three reads a minute of the 120 available. An empty response means the window expired with nothing waiting, and the listener reconnects at once. On a 429 it sleeps for `Retry-After` and carries on rather than exiting, so a supervised runner cannot turn a rate limit into a restart loop that burns the same budget. Ctrl-C aborts the in-flight poll and exits 0.
|
|
56
|
+
|
|
57
|
+
Events stay deliverable until acknowledged: `tasq events ack <id>…` marks them, and an unacked event is offered again ten minutes after it was delivered. A runner that crashes mid-work therefore sees the event once more rather than losing it.
|
|
58
|
+
|
|
59
|
+
## For agents
|
|
60
|
+
|
|
61
|
+
Two files ship with the package for the agent side of this.
|
|
62
|
+
|
|
63
|
+
- **`.tasq-skill.md`** — a skill file written for a coding agent: what Tasq is, when to reach for it, the full command reference, the mention → read → reply → ack workflow, the exit codes, and the isolation rule. Point your harness at it, or read it yourself.
|
|
64
|
+
- **`examples/mention-runner.sh`** — a reference loop over `tasq events listen`. It exports `TASQ_EVENT_ID`, `TASQ_EVENT_KIND`, `TASQ_EVENT_TASK_KEY`, `TASQ_EVENT_TASK_ID`, `TASQ_EVENT_COMMENT_ID` and `TASQ_EVENT_MENTIONED_BY`, runs `$TASQ_AGENT_CMD` once per event, and acks only when that command exits 0 so a failure is redelivered rather than lost.
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
TASQ_API_KEY=tq_ag_… TASQ_WORKSPACE=acme \
|
|
68
|
+
TASQ_AGENT_CMD='claude -p "handle $TASQ_EVENT_TASK_KEY"' \
|
|
69
|
+
./node_modules/@pxlabz/tasq-cli/examples/mention-runner.sh --wait 20
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Both are examples. Tasq stores and delivers the event; it never runs your agent.
|
|
73
|
+
|
|
38
74
|
## Configuration
|
|
39
75
|
|
|
40
76
|
| Source | Purpose |
|
|
@@ -51,8 +87,8 @@ Every command takes `--json` for raw output and `-w, --workspace <slug>` to over
|
|
|
51
87
|
| --- | --- |
|
|
52
88
|
| 0 | Success |
|
|
53
89
|
| 1 | Error (details on stderr) |
|
|
54
|
-
| 2 | Usage error |
|
|
55
|
-
| 3 | Rate limited; the message includes when to retry |
|
|
90
|
+
| 2 | Usage error — including an `--mention` name that matches no agent or more than one |
|
|
91
|
+
| 3 | Rate limited; the message includes when to retry. `events listen` does not exit here: it sleeps for `Retry-After` and carries on |
|
|
56
92
|
| 4 | The agent's policy denied the action |
|
|
57
93
|
|
|
58
|
-
Built as a single file on top of [`@pxlabz/tasq-sdk`](https://www.npmjs.com/package/@pxlabz/tasq-sdk). Node 20 or newer.
|
|
94
|
+
Built as a single file on top of [`@pxlabz/tasq-sdk`](https://www.npmjs.com/package/@pxlabz/tasq-sdk). Node 20.3 or newer (for `AbortSignal.any`).
|
package/dist/tasq.js
CHANGED
|
@@ -774,8 +774,8 @@ ${itemIndentStr}`);
|
|
|
774
774
|
const rawLines = str.split(/\r\n|\n/);
|
|
775
775
|
const chunkPattern = /[\s]*[^\s]+/g;
|
|
776
776
|
const wrappedLines = [];
|
|
777
|
-
rawLines.forEach((
|
|
778
|
-
const chunks =
|
|
777
|
+
rawLines.forEach((line2) => {
|
|
778
|
+
const chunks = line2.match(chunkPattern);
|
|
779
779
|
if (chunks === null) {
|
|
780
780
|
wrappedLines.push("");
|
|
781
781
|
return;
|
|
@@ -3682,13 +3682,13 @@ var require_utils = __commonJS({
|
|
|
3682
3682
|
state[info.set] = info.to;
|
|
3683
3683
|
}
|
|
3684
3684
|
}
|
|
3685
|
-
function readState(
|
|
3685
|
+
function readState(line2) {
|
|
3686
3686
|
let code = codeRegex(true);
|
|
3687
|
-
let controlChars = code.exec(
|
|
3687
|
+
let controlChars = code.exec(line2);
|
|
3688
3688
|
let state = {};
|
|
3689
3689
|
while (controlChars !== null) {
|
|
3690
3690
|
updateState(state, controlChars);
|
|
3691
|
-
controlChars = code.exec(
|
|
3691
|
+
controlChars = code.exec(line2);
|
|
3692
3692
|
}
|
|
3693
3693
|
return state;
|
|
3694
3694
|
}
|
|
@@ -3824,7 +3824,7 @@ var require_utils = __commonJS({
|
|
|
3824
3824
|
function wordWrap(maxLength, input) {
|
|
3825
3825
|
let lines = [];
|
|
3826
3826
|
let split = input.split(/(\s+)/g);
|
|
3827
|
-
let
|
|
3827
|
+
let line2 = [];
|
|
3828
3828
|
let lineLength = 0;
|
|
3829
3829
|
let whitespace;
|
|
3830
3830
|
for (let i = 0; i < split.length; i += 2) {
|
|
@@ -3835,37 +3835,37 @@ var require_utils = __commonJS({
|
|
|
3835
3835
|
}
|
|
3836
3836
|
if (newLength > maxLength) {
|
|
3837
3837
|
if (lineLength !== 0) {
|
|
3838
|
-
lines.push(
|
|
3838
|
+
lines.push(line2.join(""));
|
|
3839
3839
|
}
|
|
3840
|
-
|
|
3840
|
+
line2 = [word];
|
|
3841
3841
|
lineLength = strlen(word);
|
|
3842
3842
|
} else {
|
|
3843
|
-
|
|
3843
|
+
line2.push(whitespace || "", word);
|
|
3844
3844
|
lineLength = newLength;
|
|
3845
3845
|
}
|
|
3846
3846
|
whitespace = split[i + 1];
|
|
3847
3847
|
}
|
|
3848
3848
|
if (lineLength) {
|
|
3849
|
-
lines.push(
|
|
3849
|
+
lines.push(line2.join(""));
|
|
3850
3850
|
}
|
|
3851
3851
|
return lines;
|
|
3852
3852
|
}
|
|
3853
3853
|
function textWrap(maxLength, input) {
|
|
3854
3854
|
let lines = [];
|
|
3855
|
-
let
|
|
3855
|
+
let line2 = "";
|
|
3856
3856
|
function pushLine(str, ws) {
|
|
3857
|
-
if (
|
|
3858
|
-
|
|
3859
|
-
while (
|
|
3860
|
-
lines.push(
|
|
3861
|
-
|
|
3857
|
+
if (line2.length && ws) line2 += ws;
|
|
3858
|
+
line2 += str;
|
|
3859
|
+
while (line2.length > maxLength) {
|
|
3860
|
+
lines.push(line2.slice(0, maxLength));
|
|
3861
|
+
line2 = line2.slice(maxLength);
|
|
3862
3862
|
}
|
|
3863
3863
|
}
|
|
3864
3864
|
let split = input.split(/(\s+)/g);
|
|
3865
3865
|
for (let i = 0; i < split.length; i += 2) {
|
|
3866
3866
|
pushLine(split[i], i && split[i - 1]);
|
|
3867
3867
|
}
|
|
3868
|
-
if (
|
|
3868
|
+
if (line2.length) lines.push(line2);
|
|
3869
3869
|
return lines;
|
|
3870
3870
|
}
|
|
3871
3871
|
function multiLineWordWrap(maxLength, input, wrapOnWordBoundary = true) {
|
|
@@ -3881,10 +3881,10 @@ var require_utils = __commonJS({
|
|
|
3881
3881
|
let state = {};
|
|
3882
3882
|
let output = [];
|
|
3883
3883
|
for (let i = 0; i < input.length; i++) {
|
|
3884
|
-
let
|
|
3885
|
-
state = readState(
|
|
3884
|
+
let line2 = rewindState(state, input[i]);
|
|
3885
|
+
state = readState(line2);
|
|
3886
3886
|
let temp = Object.assign({}, state);
|
|
3887
|
-
output.push(unwindState(temp,
|
|
3887
|
+
output.push(unwindState(temp, line2));
|
|
3888
3888
|
}
|
|
3889
3889
|
return output;
|
|
3890
3890
|
}
|
|
@@ -4661,7 +4661,7 @@ var require_cell = __commonJS({
|
|
|
4661
4661
|
wrapLines(computedLines) {
|
|
4662
4662
|
const lines = utils.colorizeLines(computedLines);
|
|
4663
4663
|
if (this.href) {
|
|
4664
|
-
return lines.map((
|
|
4664
|
+
return lines.map((line2) => utils.hyperlink(this.href, line2));
|
|
4665
4665
|
}
|
|
4666
4666
|
return lines;
|
|
4667
4667
|
}
|
|
@@ -4809,10 +4809,10 @@ var require_cell = __commonJS({
|
|
|
4809
4809
|
let leftPadding = utils.repeat(" ", this.paddingLeft);
|
|
4810
4810
|
let right = drawRight ? this.chars["right"] : "";
|
|
4811
4811
|
let rightPadding = utils.repeat(" ", this.paddingRight);
|
|
4812
|
-
let
|
|
4812
|
+
let line2 = this.lines[lineNum];
|
|
4813
4813
|
let len = this.width - (this.paddingLeft + this.paddingRight);
|
|
4814
|
-
if (forceTruncationSymbol)
|
|
4815
|
-
let content = utils.truncate(
|
|
4814
|
+
if (forceTruncationSymbol) line2 += this.truncate || "\u2026";
|
|
4815
|
+
let content = utils.truncate(line2, len, this.truncate);
|
|
4816
4816
|
content = utils.pad(content, len, " ", this.hAlign);
|
|
4817
4817
|
content = leftPadding + content + rightPadding;
|
|
4818
4818
|
return this.stylizeLine(left, content, right);
|
|
@@ -5274,11 +5274,11 @@ var require_table = __commonJS({
|
|
|
5274
5274
|
};
|
|
5275
5275
|
Table2.reset = () => debug.reset();
|
|
5276
5276
|
function doDraw(row, lineNum, result) {
|
|
5277
|
-
let
|
|
5277
|
+
let line2 = [];
|
|
5278
5278
|
row.forEach(function(cell) {
|
|
5279
|
-
|
|
5279
|
+
line2.push(cell.draw(lineNum));
|
|
5280
5280
|
});
|
|
5281
|
-
let str =
|
|
5281
|
+
let str = line2.join("");
|
|
5282
5282
|
if (str.length) result.push(str);
|
|
5283
5283
|
}
|
|
5284
5284
|
module.exports = Table2;
|
|
@@ -6409,131 +6409,6 @@ var {
|
|
|
6409
6409
|
Help
|
|
6410
6410
|
} = import_index.default;
|
|
6411
6411
|
|
|
6412
|
-
// package.json
|
|
6413
|
-
var package_default = {
|
|
6414
|
-
name: "@pxlabz/tasq-cli",
|
|
6415
|
-
version: "0.1.1",
|
|
6416
|
-
description: "Command-line client for Tasq, for humans and agents alike",
|
|
6417
|
-
keywords: [
|
|
6418
|
-
"tasq",
|
|
6419
|
-
"cli",
|
|
6420
|
-
"agents",
|
|
6421
|
-
"project-management"
|
|
6422
|
-
],
|
|
6423
|
-
license: "MIT",
|
|
6424
|
-
author: "Paul Cedrick Artigo",
|
|
6425
|
-
homepage: "https://github.com/pxlabz/tasq/tree/main/packages/cli#readme",
|
|
6426
|
-
repository: {
|
|
6427
|
-
type: "git",
|
|
6428
|
-
url: "git+https://github.com/pxlabz/tasq.git",
|
|
6429
|
-
directory: "packages/cli"
|
|
6430
|
-
},
|
|
6431
|
-
bugs: {
|
|
6432
|
-
url: "https://github.com/pxlabz/tasq/issues"
|
|
6433
|
-
},
|
|
6434
|
-
private: false,
|
|
6435
|
-
type: "module",
|
|
6436
|
-
bin: {
|
|
6437
|
-
tasq: "./dist/tasq.js"
|
|
6438
|
-
},
|
|
6439
|
-
files: [
|
|
6440
|
-
"dist",
|
|
6441
|
-
"README.md",
|
|
6442
|
-
"LICENSE"
|
|
6443
|
-
],
|
|
6444
|
-
publishConfig: {
|
|
6445
|
-
access: "public"
|
|
6446
|
-
},
|
|
6447
|
-
engines: {
|
|
6448
|
-
node: ">=20"
|
|
6449
|
-
},
|
|
6450
|
-
scripts: {
|
|
6451
|
-
build: "tsup && chmod +x dist/tasq.js",
|
|
6452
|
-
typecheck: "tsc --project tsconfig.json --noEmit",
|
|
6453
|
-
lint: "cd ../.. && bun --bun ./node_modules/oxlint/bin/oxlint packages/cli",
|
|
6454
|
-
test: "bun test"
|
|
6455
|
-
},
|
|
6456
|
-
dependencies: {
|
|
6457
|
-
"@clack/prompts": "^0.11.0",
|
|
6458
|
-
"cli-table3": "^0.6.5",
|
|
6459
|
-
commander: "^14.0.0"
|
|
6460
|
-
},
|
|
6461
|
-
devDependencies: {
|
|
6462
|
-
"@pxlabz/tasq-sdk": "workspace:*",
|
|
6463
|
-
"@types/bun": "^1.3.12",
|
|
6464
|
-
tsup: "^8.5.0",
|
|
6465
|
-
typescript: "^5.7.2"
|
|
6466
|
-
}
|
|
6467
|
-
};
|
|
6468
|
-
|
|
6469
|
-
// src/config.ts
|
|
6470
|
-
import {
|
|
6471
|
-
chmodSync,
|
|
6472
|
-
mkdirSync,
|
|
6473
|
-
readFileSync,
|
|
6474
|
-
writeFileSync
|
|
6475
|
-
} from "fs";
|
|
6476
|
-
import { homedir } from "os";
|
|
6477
|
-
import { join } from "path";
|
|
6478
|
-
var DEFAULT_API_URL = "https://tasq.pxlabz.com";
|
|
6479
|
-
function configDir(env) {
|
|
6480
|
-
if (env.TASQ_CONFIG_DIR !== void 0) return env.TASQ_CONFIG_DIR;
|
|
6481
|
-
const base = env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
|
|
6482
|
-
return join(base, "tasq");
|
|
6483
|
-
}
|
|
6484
|
-
function configFilePath(env) {
|
|
6485
|
-
return join(configDir(env), "config.json");
|
|
6486
|
-
}
|
|
6487
|
-
function readStoredConfig(env) {
|
|
6488
|
-
let raw;
|
|
6489
|
-
try {
|
|
6490
|
-
raw = readFileSync(configFilePath(env), "utf8");
|
|
6491
|
-
} catch {
|
|
6492
|
-
return {};
|
|
6493
|
-
}
|
|
6494
|
-
try {
|
|
6495
|
-
const parsed = JSON.parse(raw);
|
|
6496
|
-
return parsed ?? {};
|
|
6497
|
-
} catch {
|
|
6498
|
-
return {};
|
|
6499
|
-
}
|
|
6500
|
-
}
|
|
6501
|
-
function saveConfig(patch, env) {
|
|
6502
|
-
const dir = configDir(env);
|
|
6503
|
-
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
6504
|
-
const merged = { ...readStoredConfig(env), ...patch };
|
|
6505
|
-
for (const key of Object.keys(merged)) {
|
|
6506
|
-
if (merged[key] === void 0) delete merged[key];
|
|
6507
|
-
}
|
|
6508
|
-
const path = configFilePath(env);
|
|
6509
|
-
writeFileSync(path, `${JSON.stringify(merged, null, 2)}
|
|
6510
|
-
`, { mode: 384 });
|
|
6511
|
-
chmodSync(path, 384);
|
|
6512
|
-
}
|
|
6513
|
-
function credentialFrom(env, stored) {
|
|
6514
|
-
if (env.TASQ_API_KEY !== void 0 && env.TASQ_API_KEY !== "") {
|
|
6515
|
-
return { agentKey: env.TASQ_API_KEY };
|
|
6516
|
-
}
|
|
6517
|
-
if (env.TASQ_USER_TOKEN !== void 0 && env.TASQ_USER_TOKEN !== "") {
|
|
6518
|
-
return { userToken: env.TASQ_USER_TOKEN };
|
|
6519
|
-
}
|
|
6520
|
-
if (stored.userToken !== void 0 && stored.userToken !== "") {
|
|
6521
|
-
return { userToken: stored.userToken };
|
|
6522
|
-
}
|
|
6523
|
-
return void 0;
|
|
6524
|
-
}
|
|
6525
|
-
function loadConfig(input) {
|
|
6526
|
-
const { env, flags } = input;
|
|
6527
|
-
const stored = readStoredConfig(env);
|
|
6528
|
-
return {
|
|
6529
|
-
apiUrl: flags.apiUrl ?? env.TASQ_API_URL ?? stored.apiUrl ?? DEFAULT_API_URL,
|
|
6530
|
-
workspace: flags.workspace ?? env.TASQ_WORKSPACE ?? stored.workspace,
|
|
6531
|
-
credential: credentialFrom(env, stored),
|
|
6532
|
-
json: flags.json === true,
|
|
6533
|
-
env
|
|
6534
|
-
};
|
|
6535
|
-
}
|
|
6536
|
-
|
|
6537
6412
|
// ../sdk/src/prefixes.ts
|
|
6538
6413
|
var AGENT_KEY_PREFIX = "tq_ag_";
|
|
6539
6414
|
var USER_TOKEN_PREFIX = "tq_us_";
|
|
@@ -6670,7 +6545,7 @@ var TasqClient = class _TasqClient {
|
|
|
6670
6545
|
this.#fetch = options.fetch ?? globalThis.fetch;
|
|
6671
6546
|
}
|
|
6672
6547
|
async #request(path, init = {}) {
|
|
6673
|
-
const { anonymous = false, ...requestInit } = init;
|
|
6548
|
+
const { anonymous = false, timeoutMs, ...requestInit } = init;
|
|
6674
6549
|
const headers = new Headers(requestInit.headers);
|
|
6675
6550
|
if (!anonymous) {
|
|
6676
6551
|
if (this.#token === void 0) throw noCredentialError();
|
|
@@ -6680,9 +6555,15 @@ var TasqClient = class _TasqClient {
|
|
|
6680
6555
|
headers.set("content-type", "application/json");
|
|
6681
6556
|
}
|
|
6682
6557
|
headers.set("accept", "application/json");
|
|
6558
|
+
const timeout = timeoutMs === void 0 ? void 0 : AbortSignal.timeout(timeoutMs);
|
|
6559
|
+
const signals = [requestInit.signal, timeout].filter(
|
|
6560
|
+
(candidate) => candidate != null
|
|
6561
|
+
);
|
|
6562
|
+
const signal = signals.length === 0 ? void 0 : signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
6683
6563
|
const response = await this.#fetch(`${this.#baseUrl}${path}`, {
|
|
6684
6564
|
...requestInit,
|
|
6685
|
-
headers
|
|
6565
|
+
headers,
|
|
6566
|
+
signal
|
|
6686
6567
|
});
|
|
6687
6568
|
if (!response.ok) {
|
|
6688
6569
|
throw await this.#toError(response);
|
|
@@ -6704,8 +6585,8 @@ var TasqClient = class _TasqClient {
|
|
|
6704
6585
|
};
|
|
6705
6586
|
return toTasqError(response.status, body, retryAfter);
|
|
6706
6587
|
}
|
|
6707
|
-
#get(path, params) {
|
|
6708
|
-
return this.#request(`${path}${queryString(params)}
|
|
6588
|
+
#get(path, params, options) {
|
|
6589
|
+
return this.#request(`${path}${queryString(params)}`, options);
|
|
6709
6590
|
}
|
|
6710
6591
|
workspaces = {
|
|
6711
6592
|
list: async () => (await this.#get("/workspaces")).workspaces,
|
|
@@ -6730,6 +6611,20 @@ var TasqClient = class _TasqClient {
|
|
|
6730
6611
|
`/workspaces/${encodeURIComponent(slug)}/projects/${encodeURIComponent(projectId)}`
|
|
6731
6612
|
)).project
|
|
6732
6613
|
};
|
|
6614
|
+
threads = {
|
|
6615
|
+
/**
|
|
6616
|
+
* The context bundle for one thread: the entity it hangs off, the
|
|
6617
|
+
* transcript, recent activity, and the participants (D-6).
|
|
6618
|
+
*
|
|
6619
|
+
* Authorized by the entity's own read rule, so a read-only agent may
|
|
6620
|
+
* pull it. Lists are capped per D-8 with `truncated` flags.
|
|
6621
|
+
*/
|
|
6622
|
+
context: (slug, threadId, options) => this.#get(
|
|
6623
|
+
`/workspaces/${encodeURIComponent(slug)}/threads/${encodeURIComponent(threadId)}/context`,
|
|
6624
|
+
void 0,
|
|
6625
|
+
options
|
|
6626
|
+
)
|
|
6627
|
+
};
|
|
6733
6628
|
cycles = {
|
|
6734
6629
|
list: async (slug, filters2) => (await this.#get(
|
|
6735
6630
|
`/workspaces/${encodeURIComponent(slug)}/cycles`,
|
|
@@ -6753,6 +6648,33 @@ var TasqClient = class _TasqClient {
|
|
|
6753
6648
|
agents = {
|
|
6754
6649
|
policy: (slug, agentId) => this.#get(
|
|
6755
6650
|
`/workspaces/${encodeURIComponent(slug)}/agents/${encodeURIComponent(agentId)}/policy`
|
|
6651
|
+
),
|
|
6652
|
+
/**
|
|
6653
|
+
* Long-poll for mentions addressed to the agent behind this key.
|
|
6654
|
+
*
|
|
6655
|
+
* The same call acks: ids passed as `ack` are marked before the select
|
|
6656
|
+
* runs, so a runner's next poll is also its acknowledgement of the last
|
|
6657
|
+
* batch (D-5). Agent keys only.
|
|
6658
|
+
*/
|
|
6659
|
+
events: (slug, query = {}, options) => this.#get(
|
|
6660
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/me/events`,
|
|
6661
|
+
{
|
|
6662
|
+
wait: query.wait,
|
|
6663
|
+
limit: query.limit,
|
|
6664
|
+
ack: query.ack === void 0 || query.ack.length === 0 ? void 0 : query.ack.join(",")
|
|
6665
|
+
},
|
|
6666
|
+
options
|
|
6667
|
+
)
|
|
6668
|
+
};
|
|
6669
|
+
members = {
|
|
6670
|
+
list: async (slug) => (await this.#get(
|
|
6671
|
+
`/workspaces/${encodeURIComponent(slug)}/members`
|
|
6672
|
+
)).members
|
|
6673
|
+
};
|
|
6674
|
+
notifications = {
|
|
6675
|
+
list: (slug, query = {}) => this.#get(
|
|
6676
|
+
`/workspaces/${encodeURIComponent(slug)}/notifications`,
|
|
6677
|
+
{ unread: query.unread === true ? 1 : void 0 }
|
|
6756
6678
|
)
|
|
6757
6679
|
};
|
|
6758
6680
|
auth = {
|
|
@@ -6844,6 +6766,133 @@ function reportError(error, io2) {
|
|
|
6844
6766
|
return EXIT_ERROR;
|
|
6845
6767
|
}
|
|
6846
6768
|
|
|
6769
|
+
// package.json
|
|
6770
|
+
var package_default = {
|
|
6771
|
+
name: "@pxlabz/tasq-cli",
|
|
6772
|
+
version: "0.1.3",
|
|
6773
|
+
description: "Command-line client for Tasq, for humans and agents alike",
|
|
6774
|
+
keywords: [
|
|
6775
|
+
"tasq",
|
|
6776
|
+
"cli",
|
|
6777
|
+
"agents",
|
|
6778
|
+
"project-management"
|
|
6779
|
+
],
|
|
6780
|
+
license: "MIT",
|
|
6781
|
+
author: "Paul Cedrick Artigo",
|
|
6782
|
+
homepage: "https://github.com/pxlabz/tasq/tree/main/packages/cli#readme",
|
|
6783
|
+
repository: {
|
|
6784
|
+
type: "git",
|
|
6785
|
+
url: "git+https://github.com/pxlabz/tasq.git",
|
|
6786
|
+
directory: "packages/cli"
|
|
6787
|
+
},
|
|
6788
|
+
bugs: {
|
|
6789
|
+
url: "https://github.com/pxlabz/tasq/issues"
|
|
6790
|
+
},
|
|
6791
|
+
private: false,
|
|
6792
|
+
type: "module",
|
|
6793
|
+
bin: {
|
|
6794
|
+
tasq: "./dist/tasq.js"
|
|
6795
|
+
},
|
|
6796
|
+
files: [
|
|
6797
|
+
"dist",
|
|
6798
|
+
"examples",
|
|
6799
|
+
".tasq-skill.md",
|
|
6800
|
+
"README.md",
|
|
6801
|
+
"LICENSE"
|
|
6802
|
+
],
|
|
6803
|
+
publishConfig: {
|
|
6804
|
+
access: "public"
|
|
6805
|
+
},
|
|
6806
|
+
engines: {
|
|
6807
|
+
node: ">=20.3"
|
|
6808
|
+
},
|
|
6809
|
+
scripts: {
|
|
6810
|
+
build: "tsup && chmod +x dist/tasq.js",
|
|
6811
|
+
typecheck: "tsc --project tsconfig.json --noEmit",
|
|
6812
|
+
lint: "cd ../.. && bun --bun ./node_modules/oxlint/bin/oxlint packages/cli",
|
|
6813
|
+
test: "bun test"
|
|
6814
|
+
},
|
|
6815
|
+
dependencies: {
|
|
6816
|
+
"@clack/prompts": "^0.11.0",
|
|
6817
|
+
"cli-table3": "^0.6.5",
|
|
6818
|
+
commander: "^14.0.0"
|
|
6819
|
+
},
|
|
6820
|
+
devDependencies: {
|
|
6821
|
+
"@pxlabz/tasq-sdk": "workspace:*",
|
|
6822
|
+
"@types/bun": "^1.3.12",
|
|
6823
|
+
tsup: "^8.5.0",
|
|
6824
|
+
typescript: "^5.7.2"
|
|
6825
|
+
}
|
|
6826
|
+
};
|
|
6827
|
+
|
|
6828
|
+
// src/config.ts
|
|
6829
|
+
import {
|
|
6830
|
+
chmodSync,
|
|
6831
|
+
mkdirSync,
|
|
6832
|
+
readFileSync,
|
|
6833
|
+
writeFileSync
|
|
6834
|
+
} from "fs";
|
|
6835
|
+
import { homedir } from "os";
|
|
6836
|
+
import { join } from "path";
|
|
6837
|
+
var DEFAULT_API_URL = "https://tasq.pxlabz.com";
|
|
6838
|
+
function configDir(env) {
|
|
6839
|
+
if (env.TASQ_CONFIG_DIR !== void 0) return env.TASQ_CONFIG_DIR;
|
|
6840
|
+
const base = env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
|
|
6841
|
+
return join(base, "tasq");
|
|
6842
|
+
}
|
|
6843
|
+
function configFilePath(env) {
|
|
6844
|
+
return join(configDir(env), "config.json");
|
|
6845
|
+
}
|
|
6846
|
+
function readStoredConfig(env) {
|
|
6847
|
+
let raw;
|
|
6848
|
+
try {
|
|
6849
|
+
raw = readFileSync(configFilePath(env), "utf8");
|
|
6850
|
+
} catch {
|
|
6851
|
+
return {};
|
|
6852
|
+
}
|
|
6853
|
+
try {
|
|
6854
|
+
const parsed = JSON.parse(raw);
|
|
6855
|
+
return parsed ?? {};
|
|
6856
|
+
} catch {
|
|
6857
|
+
return {};
|
|
6858
|
+
}
|
|
6859
|
+
}
|
|
6860
|
+
function saveConfig(patch, env) {
|
|
6861
|
+
const dir = configDir(env);
|
|
6862
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
6863
|
+
const merged = { ...readStoredConfig(env), ...patch };
|
|
6864
|
+
for (const key of Object.keys(merged)) {
|
|
6865
|
+
if (merged[key] === void 0) delete merged[key];
|
|
6866
|
+
}
|
|
6867
|
+
const path = configFilePath(env);
|
|
6868
|
+
writeFileSync(path, `${JSON.stringify(merged, null, 2)}
|
|
6869
|
+
`, { mode: 384 });
|
|
6870
|
+
chmodSync(path, 384);
|
|
6871
|
+
}
|
|
6872
|
+
function credentialFrom(env, stored) {
|
|
6873
|
+
if (env.TASQ_API_KEY !== void 0 && env.TASQ_API_KEY !== "") {
|
|
6874
|
+
return { agentKey: env.TASQ_API_KEY };
|
|
6875
|
+
}
|
|
6876
|
+
if (env.TASQ_USER_TOKEN !== void 0 && env.TASQ_USER_TOKEN !== "") {
|
|
6877
|
+
return { userToken: env.TASQ_USER_TOKEN };
|
|
6878
|
+
}
|
|
6879
|
+
if (stored.userToken !== void 0 && stored.userToken !== "") {
|
|
6880
|
+
return { userToken: stored.userToken };
|
|
6881
|
+
}
|
|
6882
|
+
return void 0;
|
|
6883
|
+
}
|
|
6884
|
+
function loadConfig(input) {
|
|
6885
|
+
const { env, flags } = input;
|
|
6886
|
+
const stored = readStoredConfig(env);
|
|
6887
|
+
return {
|
|
6888
|
+
apiUrl: flags.apiUrl ?? env.TASQ_API_URL ?? stored.apiUrl ?? DEFAULT_API_URL,
|
|
6889
|
+
workspace: flags.workspace ?? env.TASQ_WORKSPACE ?? stored.workspace,
|
|
6890
|
+
credential: credentialFrom(env, stored),
|
|
6891
|
+
json: flags.json === true,
|
|
6892
|
+
env
|
|
6893
|
+
};
|
|
6894
|
+
}
|
|
6895
|
+
|
|
6847
6896
|
// src/context.ts
|
|
6848
6897
|
function createClient(config) {
|
|
6849
6898
|
if (config.credential === void 0) {
|
|
@@ -6924,6 +6973,9 @@ function formatWorkspaces(workspaces) {
|
|
|
6924
6973
|
])
|
|
6925
6974
|
);
|
|
6926
6975
|
}
|
|
6976
|
+
function line(io2, value) {
|
|
6977
|
+
io2.out(JSON.stringify(value));
|
|
6978
|
+
}
|
|
6927
6979
|
|
|
6928
6980
|
// src/commands/auth.ts
|
|
6929
6981
|
var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
@@ -7027,17 +7079,139 @@ async function resolveTaskId(client, slug, ref) {
|
|
|
7027
7079
|
}
|
|
7028
7080
|
|
|
7029
7081
|
// src/commands/comment.ts
|
|
7030
|
-
|
|
7031
|
-
|
|
7082
|
+
var UUID_PATTERN2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
7083
|
+
function commentIdOf(ref) {
|
|
7084
|
+
const hash = ref.lastIndexOf("#");
|
|
7085
|
+
return hash === -1 ? ref.trim() : ref.slice(hash + 1).trim();
|
|
7086
|
+
}
|
|
7087
|
+
function resolveParentId(comments, entityLabel, ref) {
|
|
7088
|
+
const id = commentIdOf(ref);
|
|
7089
|
+
const found = comments.find((comment) => comment.id === id);
|
|
7090
|
+
if (found === void 0) {
|
|
7091
|
+
throw new UsageError(
|
|
7092
|
+
`"${ref}" is not a comment on ${entityLabel}. Replies must stay on the same task or project.`
|
|
7093
|
+
);
|
|
7094
|
+
}
|
|
7095
|
+
return found.id;
|
|
7096
|
+
}
|
|
7097
|
+
function replyRef(options) {
|
|
7098
|
+
const { replyTo, thread } = options;
|
|
7099
|
+
if (replyTo === void 0) return thread;
|
|
7100
|
+
if (thread === void 0) return replyTo;
|
|
7101
|
+
if (commentIdOf(replyTo) !== commentIdOf(thread)) {
|
|
7102
|
+
throw new UsageError(
|
|
7103
|
+
`--thread "${thread}" and --reply-to "${replyTo}" name different comments. Pass one.`
|
|
7104
|
+
);
|
|
7105
|
+
}
|
|
7106
|
+
return replyTo;
|
|
7107
|
+
}
|
|
7108
|
+
function resolveMentions(members, names) {
|
|
7109
|
+
const agents = members.filter(
|
|
7110
|
+
(member) => member.type === "agent" && member.agentId !== null
|
|
7111
|
+
);
|
|
7112
|
+
return names.map((name) => {
|
|
7113
|
+
const wanted = name.trim().toLowerCase();
|
|
7114
|
+
const matched = agents.filter(
|
|
7115
|
+
(agent) => (agent.name ?? "").toLowerCase() === wanted
|
|
7116
|
+
);
|
|
7117
|
+
if (matched.length === 0) {
|
|
7118
|
+
throw new UsageError(
|
|
7119
|
+
`No agent named "${name}" in this workspace. Run "tasq workspace members" to see the names.`
|
|
7120
|
+
);
|
|
7121
|
+
}
|
|
7122
|
+
if (matched.length > 1) {
|
|
7123
|
+
throw new UsageError(
|
|
7124
|
+
`"${name}" matches ${matched.length} agents. Rename one, or pass the agent id.`
|
|
7125
|
+
);
|
|
7126
|
+
}
|
|
7127
|
+
return matched[0]?.agentId ?? "";
|
|
7128
|
+
});
|
|
7129
|
+
}
|
|
7130
|
+
function mentionLine(state, name) {
|
|
7131
|
+
const who = name ?? "an agent";
|
|
7132
|
+
return state === "suppressed" ? `${who}: suppressed: agents are isolated` : `delivered to ${who}`;
|
|
7133
|
+
}
|
|
7134
|
+
async function resolveProjectId(ctx, slug, ref) {
|
|
7135
|
+
const trimmed = ref.trim();
|
|
7136
|
+
if (UUID_PATTERN2.test(trimmed)) return trimmed;
|
|
7137
|
+
const wanted = trimmed.toLowerCase();
|
|
7138
|
+
const projects = await ctx.client.projects.list(slug);
|
|
7139
|
+
const matched = projects.filter(
|
|
7140
|
+
(project) => project.name.toLowerCase() === wanted
|
|
7141
|
+
);
|
|
7142
|
+
if (matched.length === 0) {
|
|
7143
|
+
throw new UsageError(
|
|
7144
|
+
`No project named "${ref}" in this workspace. Run "tasq project list" to see the names.`
|
|
7145
|
+
);
|
|
7146
|
+
}
|
|
7147
|
+
if (matched.length > 1) {
|
|
7148
|
+
throw new UsageError(
|
|
7149
|
+
`"${ref}" matches ${matched.length} projects. Pass the project id.`
|
|
7150
|
+
);
|
|
7151
|
+
}
|
|
7152
|
+
return matched[0]?.id ?? "";
|
|
7153
|
+
}
|
|
7154
|
+
function commentPositionals(first, second, project) {
|
|
7155
|
+
if (second !== void 0) return { taskRef: first, body: second };
|
|
7156
|
+
if (project === void 0) {
|
|
7157
|
+
throw new UsageError(
|
|
7158
|
+
"Nothing to comment on. Pass a task key such as ENG-42, or --project <id|name>."
|
|
7159
|
+
);
|
|
7160
|
+
}
|
|
7161
|
+
return { taskRef: void 0, body: first };
|
|
7162
|
+
}
|
|
7163
|
+
async function resolveTarget(ctx, slug, taskRef, project) {
|
|
7164
|
+
if (taskRef !== void 0 && project !== void 0) {
|
|
7165
|
+
throw new UsageError(
|
|
7166
|
+
"Pass either a task or --project <id|name>, not both."
|
|
7167
|
+
);
|
|
7168
|
+
}
|
|
7169
|
+
if (project !== void 0) {
|
|
7170
|
+
const projectId = await resolveProjectId(ctx, slug, project);
|
|
7171
|
+
const detail = await ctx.client.projects.get(slug, projectId);
|
|
7172
|
+
return {
|
|
7173
|
+
input: { projectId: detail.id },
|
|
7174
|
+
label: detail.name,
|
|
7175
|
+
comments: detail.comments
|
|
7176
|
+
};
|
|
7177
|
+
}
|
|
7178
|
+
if (taskRef === void 0) {
|
|
7179
|
+
throw new UsageError(
|
|
7180
|
+
"Nothing to comment on. Pass a task key such as ENG-42, or --project <id|name>."
|
|
7181
|
+
);
|
|
7182
|
+
}
|
|
7032
7183
|
const taskId = await resolveTaskId(ctx.client, slug, taskRef);
|
|
7033
7184
|
const task = await ctx.client.tasks.get(slug, taskId);
|
|
7034
|
-
|
|
7035
|
-
taskId: task.id,
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7185
|
+
return {
|
|
7186
|
+
input: { taskId: task.id },
|
|
7187
|
+
label: task.identifier,
|
|
7188
|
+
comments: task.comments
|
|
7189
|
+
};
|
|
7190
|
+
}
|
|
7191
|
+
async function commentAdd(ctx, taskRef, body, options = {}) {
|
|
7192
|
+
const slug = requireWorkspace(ctx.config);
|
|
7193
|
+
const target = await resolveTarget(ctx, slug, taskRef, options.project);
|
|
7194
|
+
const names = options.mention ?? [];
|
|
7195
|
+
const members = names.length === 0 ? [] : await ctx.client.members.list(slug);
|
|
7196
|
+
const mentions = resolveMentions(members, names);
|
|
7197
|
+
const input = { ...target.input, body };
|
|
7198
|
+
const parent = replyRef(options);
|
|
7199
|
+
if (parent !== void 0) {
|
|
7200
|
+
input.parentId = resolveParentId(target.comments, target.label, parent);
|
|
7201
|
+
}
|
|
7202
|
+
if (mentions.length > 0) input.mentions = mentions;
|
|
7203
|
+
const added = await ctx.client.dispatch("comment.add", slug, input);
|
|
7204
|
+
if (ctx.config.json) {
|
|
7205
|
+
ctx.io.out(jsonOutput(added.result));
|
|
7206
|
+
return;
|
|
7207
|
+
}
|
|
7208
|
+
ctx.io.out(`Comment added to ${target.label}.`);
|
|
7209
|
+
const nameById = new Map(
|
|
7210
|
+
members.map((member) => [member.agentId, member.name])
|
|
7040
7211
|
);
|
|
7212
|
+
for (const mention of added.result.mentions ?? []) {
|
|
7213
|
+
ctx.io.out(mentionLine(mention.state, nameById.get(mention.agentId)));
|
|
7214
|
+
}
|
|
7041
7215
|
}
|
|
7042
7216
|
|
|
7043
7217
|
// src/commands/cycle.ts
|
|
@@ -7070,6 +7244,47 @@ async function cycleCurrent(ctx, options) {
|
|
|
7070
7244
|
}
|
|
7071
7245
|
}
|
|
7072
7246
|
|
|
7247
|
+
// src/commands/events.ts
|
|
7248
|
+
function defaultSleep(ms) {
|
|
7249
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7250
|
+
}
|
|
7251
|
+
function isAbort(error, signal) {
|
|
7252
|
+
if (signal?.aborted === true) return true;
|
|
7253
|
+
return error.name === "AbortError";
|
|
7254
|
+
}
|
|
7255
|
+
async function eventsListen(ctx, options = {}, deps = {}) {
|
|
7256
|
+
const slug = requireWorkspace(ctx.config);
|
|
7257
|
+
const sleep = deps.sleep ?? defaultSleep;
|
|
7258
|
+
const wait = options.wait ?? 20;
|
|
7259
|
+
for (; ; ) {
|
|
7260
|
+
if (deps.signal?.aborted === true) return;
|
|
7261
|
+
let page;
|
|
7262
|
+
try {
|
|
7263
|
+
page = await ctx.client.agents.events(
|
|
7264
|
+
slug,
|
|
7265
|
+
{ wait },
|
|
7266
|
+
{ signal: deps.signal }
|
|
7267
|
+
);
|
|
7268
|
+
} catch (thrown) {
|
|
7269
|
+
if (!(thrown instanceof Error)) throw thrown;
|
|
7270
|
+
const error = thrown;
|
|
7271
|
+
if (isAbort(error, deps.signal)) return;
|
|
7272
|
+
if (error instanceof TasqRateLimitError) {
|
|
7273
|
+
await sleep(error.retryAfterSeconds * 1e3);
|
|
7274
|
+
continue;
|
|
7275
|
+
}
|
|
7276
|
+
throw error;
|
|
7277
|
+
}
|
|
7278
|
+
for (const event of page.events) line(ctx.io, event);
|
|
7279
|
+
if (options.once === true) return;
|
|
7280
|
+
}
|
|
7281
|
+
}
|
|
7282
|
+
async function eventsAck(ctx, ids) {
|
|
7283
|
+
const slug = requireWorkspace(ctx.config);
|
|
7284
|
+
const page = await ctx.client.agents.events(slug, { wait: 0, ack: ids });
|
|
7285
|
+
line(ctx.io, { acked: page.acked });
|
|
7286
|
+
}
|
|
7287
|
+
|
|
7073
7288
|
// src/commands/project.ts
|
|
7074
7289
|
async function projectList(ctx) {
|
|
7075
7290
|
const slug = requireWorkspace(ctx.config);
|
|
@@ -7077,6 +7292,109 @@ async function projectList(ctx) {
|
|
|
7077
7292
|
ctx.io.out(ctx.config.json ? jsonOutput(projects) : formatProjects(projects));
|
|
7078
7293
|
}
|
|
7079
7294
|
|
|
7295
|
+
// src/render/thread-context.ts
|
|
7296
|
+
function entityHeading(entity) {
|
|
7297
|
+
return entity.key === null ? `**${entity.title}**` : `**${entity.key}** \u2014 ${entity.title}`;
|
|
7298
|
+
}
|
|
7299
|
+
function entityFacts(entity) {
|
|
7300
|
+
const facts = [`- Type: ${entity.type}`, `- Status: ${entity.status ?? "\u2014"}`];
|
|
7301
|
+
if (entity.type === "task") {
|
|
7302
|
+
facts.push(`- Project: ${entity.project?.name ?? "\u2014"}`);
|
|
7303
|
+
return facts;
|
|
7304
|
+
}
|
|
7305
|
+
const teams = entity.teams.map((team) => `${team.name} (${team.identifier})`).join(", ");
|
|
7306
|
+
facts.push(`- Teams: ${teams === "" ? "\u2014" : teams}`);
|
|
7307
|
+
return facts;
|
|
7308
|
+
}
|
|
7309
|
+
function entitySection(entity) {
|
|
7310
|
+
const rows = [entityHeading(entity), "", ...entityFacts(entity), ""];
|
|
7311
|
+
rows.push(
|
|
7312
|
+
entity.description === null || entity.description === "" ? "_No description._" : entity.description
|
|
7313
|
+
);
|
|
7314
|
+
if (entity.descriptionTruncated) rows.push("", "_(description truncated)_");
|
|
7315
|
+
return rows.join("\n");
|
|
7316
|
+
}
|
|
7317
|
+
function messageLine(message) {
|
|
7318
|
+
const author = message.authorName ?? "unknown";
|
|
7319
|
+
const type = message.authorType ?? "unknown";
|
|
7320
|
+
return `- **${author}** (${type}, ${message.createdAt}): ${message.body}`;
|
|
7321
|
+
}
|
|
7322
|
+
function threadSection(thread) {
|
|
7323
|
+
const rows = [];
|
|
7324
|
+
if (thread.truncated) {
|
|
7325
|
+
rows.push(
|
|
7326
|
+
`_(showing last ${thread.messages.length} of ${thread.total} messages)_`,
|
|
7327
|
+
""
|
|
7328
|
+
);
|
|
7329
|
+
}
|
|
7330
|
+
if (thread.messages.length === 0) {
|
|
7331
|
+
rows.push("_none_");
|
|
7332
|
+
return rows.join("\n");
|
|
7333
|
+
}
|
|
7334
|
+
rows.push(...thread.messages.map(messageLine));
|
|
7335
|
+
return rows.join("\n");
|
|
7336
|
+
}
|
|
7337
|
+
function activitySection(activity) {
|
|
7338
|
+
if (activity.length === 0) return "_none_";
|
|
7339
|
+
return activity.map(
|
|
7340
|
+
(entry) => `- ${entry.createdAt} ${entry.actorName ?? "unknown"}: ${entry.summary}`
|
|
7341
|
+
).join("\n");
|
|
7342
|
+
}
|
|
7343
|
+
function participantsSection(participants) {
|
|
7344
|
+
if (participants.length === 0) return "_none_";
|
|
7345
|
+
return participants.map(
|
|
7346
|
+
(participant) => `- ${participant.name ?? "unknown"} (${participant.type}, joined via ${participant.joinedVia})`
|
|
7347
|
+
).join("\n");
|
|
7348
|
+
}
|
|
7349
|
+
function renderThreadContext(bundle) {
|
|
7350
|
+
return [
|
|
7351
|
+
"## Entity",
|
|
7352
|
+
"",
|
|
7353
|
+
entitySection(bundle.entity),
|
|
7354
|
+
"",
|
|
7355
|
+
"## Thread",
|
|
7356
|
+
"",
|
|
7357
|
+
threadSection(bundle.thread),
|
|
7358
|
+
"",
|
|
7359
|
+
"## Recent activity",
|
|
7360
|
+
"",
|
|
7361
|
+
activitySection(bundle.recentActivity),
|
|
7362
|
+
"",
|
|
7363
|
+
"## Participants",
|
|
7364
|
+
"",
|
|
7365
|
+
participantsSection(bundle.participants)
|
|
7366
|
+
].join("\n");
|
|
7367
|
+
}
|
|
7368
|
+
|
|
7369
|
+
// src/commands/thread.ts
|
|
7370
|
+
function entityLine(entity) {
|
|
7371
|
+
const name = entity.key === null ? entity.title : `${entity.key} \xB7 ${entity.title}`;
|
|
7372
|
+
return `${name} (${entity.status ?? "\u2014"})`;
|
|
7373
|
+
}
|
|
7374
|
+
async function threadView(ctx, threadId) {
|
|
7375
|
+
const slug = requireWorkspace(ctx.config);
|
|
7376
|
+
const bundle = await ctx.client.threads.context(slug, threadId);
|
|
7377
|
+
if (ctx.config.json) {
|
|
7378
|
+
ctx.io.out(jsonOutput(bundle));
|
|
7379
|
+
return;
|
|
7380
|
+
}
|
|
7381
|
+
ctx.io.out(entityLine(bundle.entity));
|
|
7382
|
+
ctx.io.out("");
|
|
7383
|
+
ctx.io.out(`Messages (${bundle.thread.total})`);
|
|
7384
|
+
for (const message of bundle.thread.messages) {
|
|
7385
|
+
const author = message.authorName ?? "unknown";
|
|
7386
|
+
ctx.io.out(` ${message.createdAt} ${author} #${message.id}`);
|
|
7387
|
+
ctx.io.out(` ${message.body}`);
|
|
7388
|
+
}
|
|
7389
|
+
}
|
|
7390
|
+
async function threadContext(ctx, threadId, _options = {}) {
|
|
7391
|
+
const slug = requireWorkspace(ctx.config);
|
|
7392
|
+
const bundle = await ctx.client.threads.context(slug, threadId);
|
|
7393
|
+
ctx.io.out(
|
|
7394
|
+
ctx.config.json ? jsonOutput(bundle) : renderThreadContext(bundle)
|
|
7395
|
+
);
|
|
7396
|
+
}
|
|
7397
|
+
|
|
7080
7398
|
// src/commands/task.ts
|
|
7081
7399
|
var PRIORITIES = ["urgent", "high", "medium", "low", "none"];
|
|
7082
7400
|
function priority(value) {
|
|
@@ -7150,7 +7468,8 @@ async function taskView(ctx, taskRef) {
|
|
|
7150
7468
|
ctx.io.out(`Comments (${task.comments.length})`);
|
|
7151
7469
|
for (const comment of task.comments) {
|
|
7152
7470
|
const author = comment.author?.name ?? comment.author?.email ?? "unknown";
|
|
7153
|
-
ctx.io.out(` ${comment.createdAt} ${author}
|
|
7471
|
+
ctx.io.out(` ${comment.createdAt} ${author} #${comment.id}`);
|
|
7472
|
+
ctx.io.out(` ${comment.body}`);
|
|
7154
7473
|
}
|
|
7155
7474
|
ctx.io.out("");
|
|
7156
7475
|
ctx.io.out(`Activity (${task.activityLog.length})`);
|
|
@@ -7292,7 +7611,7 @@ async function workspaceUse(ctx, slug) {
|
|
|
7292
7611
|
);
|
|
7293
7612
|
}
|
|
7294
7613
|
|
|
7295
|
-
// src/
|
|
7614
|
+
// src/program.ts
|
|
7296
7615
|
function contextFor(program2, io2) {
|
|
7297
7616
|
const flags = program2.opts();
|
|
7298
7617
|
const config = loadConfig({
|
|
@@ -7351,9 +7670,48 @@ function buildProgram(io2) {
|
|
|
7351
7670
|
status: options.status
|
|
7352
7671
|
});
|
|
7353
7672
|
});
|
|
7354
|
-
const comment = program2.command("comment").description("Task comments");
|
|
7355
|
-
comment.command("add").argument("<
|
|
7356
|
-
|
|
7673
|
+
const comment = program2.command("comment").description("Task and project comments");
|
|
7674
|
+
comment.command("add").argument("<taskRefOrBody>", "task identifier or id, or the body with --project").argument("[body]", "comment body, when a task was given").description("Add a comment to a task or a project").usage("[options] <taskRef> <body>\n tasq comment add [options] --project <projectRef> <body>").option("--project <projectRef>", "project id or name, instead of a task").option("--reply-to <commentRef>", "comment id, or ENG-42#<id>, to reply to").option("--thread <threadId>", "thread root id, an alias for --reply-to").option(
|
|
7675
|
+
"--mention <agentName>",
|
|
7676
|
+
"agent to mention, repeatable",
|
|
7677
|
+
(value, previous) => [
|
|
7678
|
+
...previous ?? [],
|
|
7679
|
+
value
|
|
7680
|
+
]
|
|
7681
|
+
).action(
|
|
7682
|
+
async (taskRefOrBody, maybeBody, options) => {
|
|
7683
|
+
const { taskRef, body } = commentPositionals(
|
|
7684
|
+
taskRefOrBody,
|
|
7685
|
+
maybeBody,
|
|
7686
|
+
options.project
|
|
7687
|
+
);
|
|
7688
|
+
await commentAdd(contextFor(program2, io2), taskRef, body, options);
|
|
7689
|
+
}
|
|
7690
|
+
);
|
|
7691
|
+
const thread = program2.command("thread").description("Conversations on a task or a project");
|
|
7692
|
+
thread.command("view").argument("<threadId>", "thread root comment id").description("Show a thread with its message ids").action(async (threadId) => {
|
|
7693
|
+
await threadView(contextFor(program2, io2), threadId);
|
|
7694
|
+
});
|
|
7695
|
+
thread.command("context").argument("<threadId>", "thread root comment id").description("Print the thread's context bundle as a Markdown prompt").option("--markdown", "render Markdown (the default)").action(async (threadId, options) => {
|
|
7696
|
+
await threadContext(contextFor(program2, io2), threadId, options);
|
|
7697
|
+
});
|
|
7698
|
+
const events = program2.command("events").description("Mentions addressed to this agent");
|
|
7699
|
+
events.command("listen").description("Stream mentions as NDJSON, one JSON object per line").option("--wait <seconds>", "seconds to hold each poll open, 0-25", "20").option("--once", "return after the first response").action(async (options) => {
|
|
7700
|
+
const controller = new AbortController();
|
|
7701
|
+
const stop = () => controller.abort();
|
|
7702
|
+
process.once("SIGINT", stop);
|
|
7703
|
+
try {
|
|
7704
|
+
await eventsListen(
|
|
7705
|
+
contextFor(program2, io2),
|
|
7706
|
+
{ wait: Number(options.wait), once: options.once },
|
|
7707
|
+
{ signal: controller.signal }
|
|
7708
|
+
);
|
|
7709
|
+
} finally {
|
|
7710
|
+
process.removeListener("SIGINT", stop);
|
|
7711
|
+
}
|
|
7712
|
+
});
|
|
7713
|
+
events.command("ack").argument("<id...>", "event ids to acknowledge").description("Acknowledge delivered events").action(async (ids) => {
|
|
7714
|
+
await eventsAck(contextFor(program2, io2), ids);
|
|
7357
7715
|
});
|
|
7358
7716
|
const project = program2.command("project").description("Projects");
|
|
7359
7717
|
project.command("list").description("List projects").action(run((ctx) => projectList(ctx)));
|
|
@@ -7373,6 +7731,8 @@ function buildProgram(io2) {
|
|
|
7373
7731
|
auth.command("whoami").description("Show the current principal").action(run((ctx) => authWhoami(ctx)));
|
|
7374
7732
|
return program2;
|
|
7375
7733
|
}
|
|
7734
|
+
|
|
7735
|
+
// src/index.ts
|
|
7376
7736
|
async function main(argv, io2) {
|
|
7377
7737
|
try {
|
|
7378
7738
|
await buildProgram(io2).parseAsync(argv, { from: "user" });
|
|
@@ -7390,12 +7750,12 @@ async function main(argv, io2) {
|
|
|
7390
7750
|
}
|
|
7391
7751
|
}
|
|
7392
7752
|
var io = {
|
|
7393
|
-
out: (
|
|
7394
|
-
process.stdout.write(`${
|
|
7753
|
+
out: (line2) => {
|
|
7754
|
+
process.stdout.write(`${line2}
|
|
7395
7755
|
`);
|
|
7396
7756
|
},
|
|
7397
|
-
err: (
|
|
7398
|
-
process.stderr.write(`${
|
|
7757
|
+
err: (line2) => {
|
|
7758
|
+
process.stderr.write(`${line2}
|
|
7399
7759
|
`);
|
|
7400
7760
|
}
|
|
7401
7761
|
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Example mention runner — NOT part of the Tasq product.
|
|
3
|
+
#
|
|
4
|
+
# Tasq stores and delivers mentions; it never runs your agent. This script is
|
|
5
|
+
# the smallest honest example of the harness side, which is yours to own: it
|
|
6
|
+
# reads `tasq events listen` line by line, hands each event to a command of
|
|
7
|
+
# your choosing through the environment, and acknowledges the event only when
|
|
8
|
+
# that command succeeds. Copy it, rewrite it, or ignore it.
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# TASQ_API_KEY=tq_ag_… \
|
|
12
|
+
# TASQ_WORKSPACE=acme \
|
|
13
|
+
# TASQ_AGENT_CMD='claude -p "handle $TASQ_EVENT_TASK_KEY"' \
|
|
14
|
+
# ./mention-runner.sh [--wait 20]
|
|
15
|
+
#
|
|
16
|
+
# Environment:
|
|
17
|
+
# TASQ_AGENT_CMD Required. Shell command run once per event, with the
|
|
18
|
+
# TASQ_EVENT_* variables below exported into it.
|
|
19
|
+
# TASQ_API_KEY The agent key. TASQ_WORKSPACE and TASQ_API_URL are read by
|
|
20
|
+
# the CLI itself; see `tasq --help`.
|
|
21
|
+
#
|
|
22
|
+
# Exported per event:
|
|
23
|
+
# TASQ_EVENT_ID, TASQ_EVENT_KIND, TASQ_EVENT_TASK_KEY, TASQ_EVENT_TASK_ID,
|
|
24
|
+
# TASQ_EVENT_PROJECT_ID, TASQ_EVENT_THREAD_ID, TASQ_EVENT_COMMENT_ID,
|
|
25
|
+
# TASQ_EVENT_MENTIONED_BY
|
|
26
|
+
#
|
|
27
|
+
# Event kinds: `mention` is a request addressed to the agent; `thread_message`
|
|
28
|
+
# is a follow-up in a thread it already joined. Both are handed to the same
|
|
29
|
+
# command here — deciding whether a follow-up needs a reply is the agent's
|
|
30
|
+
# job, not the runner's. An unrecognised kind is acked and skipped rather than
|
|
31
|
+
# handed to a command that was never written for it.
|
|
32
|
+
#
|
|
33
|
+
# Acking is deliberate: an event the command failed on is left unacked, and
|
|
34
|
+
# Tasq offers it again ten minutes later. A crash loses no work.
|
|
35
|
+
|
|
36
|
+
set -euo pipefail
|
|
37
|
+
|
|
38
|
+
: "${TASQ_AGENT_CMD:?Set TASQ_AGENT_CMD to the command that handles one event}"
|
|
39
|
+
|
|
40
|
+
TASQ_BIN="${TASQ_BIN:-tasq}"
|
|
41
|
+
|
|
42
|
+
# jq if it is there, a node one-liner if it is not. Both print the field's
|
|
43
|
+
# value, or an empty line when the field is null or missing.
|
|
44
|
+
if command -v jq > /dev/null 2>&1; then
|
|
45
|
+
field() { printf '%s' "$1" | jq -r --arg f "$2" '.[$f] // empty'; }
|
|
46
|
+
else
|
|
47
|
+
field() {
|
|
48
|
+
printf '%s' "$1" | node -e '
|
|
49
|
+
let raw = ""
|
|
50
|
+
process.stdin.on("data", (chunk) => { raw += chunk })
|
|
51
|
+
process.stdin.on("end", () => {
|
|
52
|
+
const value = JSON.parse(raw)[process.argv[1]]
|
|
53
|
+
process.stdout.write(value == null ? "" : String(value))
|
|
54
|
+
})
|
|
55
|
+
' "$2"
|
|
56
|
+
}
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
"$TASQ_BIN" events listen "$@" | while IFS= read -r event; do
|
|
60
|
+
[[ -z "$event" ]] && continue
|
|
61
|
+
|
|
62
|
+
TASQ_EVENT_ID="$(field "$event" id)"
|
|
63
|
+
TASQ_EVENT_KIND="$(field "$event" kind)"
|
|
64
|
+
TASQ_EVENT_TASK_KEY="$(field "$event" taskKey)"
|
|
65
|
+
TASQ_EVENT_TASK_ID="$(field "$event" taskId)"
|
|
66
|
+
TASQ_EVENT_PROJECT_ID="$(field "$event" projectId)"
|
|
67
|
+
TASQ_EVENT_THREAD_ID="$(field "$event" threadId)"
|
|
68
|
+
TASQ_EVENT_COMMENT_ID="$(field "$event" commentId)"
|
|
69
|
+
TASQ_EVENT_MENTIONED_BY="$(printf '%s' "$event" | {
|
|
70
|
+
if command -v jq > /dev/null 2>&1; then
|
|
71
|
+
jq -r '.mentionedBy.name // empty'
|
|
72
|
+
else
|
|
73
|
+
node -e '
|
|
74
|
+
let raw = ""
|
|
75
|
+
process.stdin.on("data", (chunk) => { raw += chunk })
|
|
76
|
+
process.stdin.on("end", () => {
|
|
77
|
+
const by = JSON.parse(raw).mentionedBy
|
|
78
|
+
process.stdout.write(by?.name == null ? "" : String(by.name))
|
|
79
|
+
})
|
|
80
|
+
'
|
|
81
|
+
fi
|
|
82
|
+
})"
|
|
83
|
+
|
|
84
|
+
export TASQ_EVENT_ID TASQ_EVENT_KIND TASQ_EVENT_TASK_KEY \
|
|
85
|
+
TASQ_EVENT_TASK_ID TASQ_EVENT_PROJECT_ID TASQ_EVENT_THREAD_ID \
|
|
86
|
+
TASQ_EVENT_COMMENT_ID TASQ_EVENT_MENTIONED_BY
|
|
87
|
+
|
|
88
|
+
TASQ_EVENT_ENTITY="${TASQ_EVENT_TASK_KEY:-${TASQ_EVENT_PROJECT_ID:-?}}"
|
|
89
|
+
|
|
90
|
+
echo "→ ${TASQ_EVENT_KIND} on ${TASQ_EVENT_ENTITY} (${TASQ_EVENT_ID})" >&2
|
|
91
|
+
|
|
92
|
+
case "$TASQ_EVENT_KIND" in
|
|
93
|
+
mention | thread_message)
|
|
94
|
+
# `set -e` must not kill the loop on a handler failure: the whole point
|
|
95
|
+
# is to leave that event unacked and keep listening.
|
|
96
|
+
if sh -c "$TASQ_AGENT_CMD"; then
|
|
97
|
+
"$TASQ_BIN" events ack "$TASQ_EVENT_ID"
|
|
98
|
+
else
|
|
99
|
+
echo " handler failed; leaving ${TASQ_EVENT_ID} unacked for redelivery" >&2
|
|
100
|
+
fi
|
|
101
|
+
;;
|
|
102
|
+
*)
|
|
103
|
+
# A kind this runner predates. Acking clears it from the queue rather
|
|
104
|
+
# than letting Tasq redeliver it every ten minutes forever; teach the
|
|
105
|
+
# case above about it before the handler can do anything useful with it.
|
|
106
|
+
echo " unknown event kind \"${TASQ_EVENT_KIND}\"; acking and skipping" >&2
|
|
107
|
+
"$TASQ_BIN" events ack "$TASQ_EVENT_ID"
|
|
108
|
+
;;
|
|
109
|
+
esac
|
|
110
|
+
done
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pxlabz/tasq-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Command-line client for Tasq, for humans and agents alike",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tasq",
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
|
+
"examples",
|
|
30
|
+
".tasq-skill.md",
|
|
29
31
|
"README.md",
|
|
30
32
|
"LICENSE"
|
|
31
33
|
],
|
|
@@ -33,7 +35,7 @@
|
|
|
33
35
|
"access": "public"
|
|
34
36
|
},
|
|
35
37
|
"engines": {
|
|
36
|
-
"node": ">=20"
|
|
38
|
+
"node": ">=20.3"
|
|
37
39
|
},
|
|
38
40
|
"scripts": {
|
|
39
41
|
"build": "tsup && chmod +x dist/tasq.js",
|