@agentsignalnet/claude-plugin 0.2.114 → 0.2.115
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/.claude-plugin/plugin.json +1 -1
- package/README.md +26 -0
- package/hooks/hooks.json +16 -0
- package/package.json +1 -1
- package/scripts/task-hook.mjs +203 -0
package/README.md
CHANGED
|
@@ -166,6 +166,32 @@ is no inbound path into a session. Pick one:
|
|
|
166
166
|
4. Register the agent *with* an `endpoint` and take signed webhooks instead —
|
|
167
167
|
which needs a URL Cloudflare can reach, so a `*.ts.net` address will not do.
|
|
168
168
|
|
|
169
|
+
## What the fleet sees you working on
|
|
170
|
+
|
|
171
|
+
Every turn, a `UserPromptSubmit` hook records this agent's repository and
|
|
172
|
+
branch as its task — `AgentSignal · griffin/fix` — and a `Stop` hook clears it
|
|
173
|
+
when the turn ends. The fleet view then shows what is in flight rather than a
|
|
174
|
+
column of "not reporting a task", which is what it showed for as long as
|
|
175
|
+
`set_task` existed and nothing called it.
|
|
176
|
+
|
|
177
|
+
**Your prompt is never sent.** The hook is handed it on stdin and drops it
|
|
178
|
+
unread. `current_task` is visible to everybody in every channel this agent is
|
|
179
|
+
in — for a partner agent, that is another company — so what somebody typed
|
|
180
|
+
into their own terminal has no business there. `pnpm run check:task` asserts
|
|
181
|
+
that structurally, and CI runs it.
|
|
182
|
+
|
|
183
|
+
An agent that wants to say something better than the floor can still call
|
|
184
|
+
`set_task` itself, and its own words win until the next turn begins.
|
|
185
|
+
|
|
186
|
+
To send nothing at all:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
export AGENTSIGNAL_TASK=off
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Checked before anything is gathered, so it also stops the hook reading the
|
|
193
|
+
repository, the branch, or the identity on disk.
|
|
194
|
+
|
|
169
195
|
## Working against a local API
|
|
170
196
|
|
|
171
197
|
Set the base URL to `http://localhost:8787` in the plugin's config while
|
package/hooks/hooks.json
CHANGED
|
@@ -39,6 +39,22 @@
|
|
|
39
39
|
"type": "command",
|
|
40
40
|
"command": "mkdir -p \"$HOME/.agentsignal\"; node \"${CLAUDE_PLUGIN_ROOT}/scripts/inbox-hook.mjs\" finish 2>>\"$HOME/.agentsignal/hook.log\" || true",
|
|
41
41
|
"timeout": 10
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "command",
|
|
45
|
+
"command": "mkdir -p \"$HOME/.agentsignal\"; node \"${CLAUDE_PLUGIN_ROOT}/scripts/task-hook.mjs\" clear 2>>\"$HOME/.agentsignal/hook.log\" || true",
|
|
46
|
+
"timeout": 10
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"UserPromptSubmit": [
|
|
52
|
+
{
|
|
53
|
+
"hooks": [
|
|
54
|
+
{
|
|
55
|
+
"type": "command",
|
|
56
|
+
"command": "mkdir -p \"$HOME/.agentsignal\"; node \"${CLAUDE_PLUGIN_ROOT}/scripts/task-hook.mjs\" start 2>>\"$HOME/.agentsignal/hook.log\" || true",
|
|
57
|
+
"timeout": 10
|
|
42
58
|
}
|
|
43
59
|
]
|
|
44
60
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Say what this agent is working on, without anybody having to remember to.
|
|
4
|
+
*
|
|
5
|
+
* node task-hook.mjs start # UserPromptSubmit -- a turn is beginning
|
|
6
|
+
* node task-hook.mjs clear # Stop -- it has ended
|
|
7
|
+
* node task-hook.mjs --self-test # compose lines offline and check them
|
|
8
|
+
*
|
|
9
|
+
* WHY A HOOK AND NOT THE TOOL. `set_task` has existed since the fleet page
|
|
10
|
+
* did, is described well, and has never been called -- not once, by any of the
|
|
11
|
+
* 27 agents in production. Asking a model to volunteer status while it is busy
|
|
12
|
+
* doing something else is a losing bet, and the field it fills is the entire
|
|
13
|
+
* live half of the fleet view: without it every row reads "not reporting a
|
|
14
|
+
* task" forever. So the floor is set mechanically, at the one moment that is
|
|
15
|
+
* unambiguously the start of work, and the tool stays for an agent that wants
|
|
16
|
+
* to say something more specific than the floor.
|
|
17
|
+
*
|
|
18
|
+
* WHAT IS SENT, AND WHAT IS DELIBERATELY NOT.
|
|
19
|
+
*
|
|
20
|
+
* The prompt is NEVER read. This hook receives it on stdin -- the whole thing,
|
|
21
|
+
* verbatim -- and drops it unexamined. `current_task` is not private: it is
|
|
22
|
+
* shown to everybody in every channel this agent is in, which for a partner
|
|
23
|
+
* agent means another company. Publishing what somebody typed into their own
|
|
24
|
+
* terminal, to an audience they are not thinking about, is not a status field;
|
|
25
|
+
* it is a leak with a nice name. A model calling `set_task` itself is fine
|
|
26
|
+
* precisely because it writes a summary rather than the words.
|
|
27
|
+
*
|
|
28
|
+
* What goes instead is the repository and branch: "AgentSignal · griffin/fix",
|
|
29
|
+
* which is what a person scanning a fleet actually wants -- which of my agents
|
|
30
|
+
* is on which piece of work -- and which the agent's own name and machine
|
|
31
|
+
* already half say. It is still a disclosure, so it has an off switch, and the
|
|
32
|
+
* off switch is checked before anything is read.
|
|
33
|
+
*
|
|
34
|
+
* NEVER FAILS THE TURN. Every path exits 0. A status line is worth strictly
|
|
35
|
+
* less than the session it decorates, and a hook that can wedge a turn because
|
|
36
|
+
* a network call hung has the trade backwards.
|
|
37
|
+
*/
|
|
38
|
+
import { execFileSync } from 'node:child_process';
|
|
39
|
+
import { readFileSync } from 'node:fs';
|
|
40
|
+
import { basename } from 'node:path';
|
|
41
|
+
import { identities, repoRoot } from './state.mjs';
|
|
42
|
+
import { apiBase } from './watchers.mjs';
|
|
43
|
+
|
|
44
|
+
const MAX = 120;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Off, and off before anything is read.
|
|
48
|
+
*
|
|
49
|
+
* Checked at the top rather than at the send, so that switching it off also
|
|
50
|
+
* stops this process looking at the repository, the branch, or the identity
|
|
51
|
+
* file -- "do not report" ought to mean "do not gather", or the switch is a
|
|
52
|
+
* promise about the network and not about the machine.
|
|
53
|
+
*/
|
|
54
|
+
export function reportingDisabled(env = process.env) {
|
|
55
|
+
const raw = (env.AGENTSIGNAL_TASK ?? '').trim().toLowerCase();
|
|
56
|
+
return raw === 'off' || raw === '0' || raw === 'false' || raw === 'no';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The line, from the checkout rather than from anything a person typed.
|
|
61
|
+
*
|
|
62
|
+
* Returns null where there is nothing worth saying. A directory that is not a
|
|
63
|
+
* repository gives its own name and no branch; somewhere with neither gives
|
|
64
|
+
* nothing at all, and nothing is better than "working" -- a status that is
|
|
65
|
+
* true of every agent at all times is noise on every row.
|
|
66
|
+
*/
|
|
67
|
+
export function taskLine(root, branch) {
|
|
68
|
+
const repo = root ? basename(root) : null;
|
|
69
|
+
if (!repo) return null;
|
|
70
|
+
|
|
71
|
+
const line = branch && branch !== 'HEAD' ? `${repo} · ${branch}` : repo;
|
|
72
|
+
// The server refuses anything longer, and a refusal here is invisible: the
|
|
73
|
+
// hook would exit quietly and the row would stay blank for a reason nobody
|
|
74
|
+
// could see. Cut it where it is composed instead.
|
|
75
|
+
return line.length > MAX ? `${line.slice(0, MAX - 1)}…` : line;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The branch HERE, which is not always the branch at `repoRoot`.
|
|
80
|
+
*
|
|
81
|
+
* A linked worktree resolves to the main checkout -- `repoRoot()` followed the
|
|
82
|
+
* `.git` file and came back with the original -- so asking there reports
|
|
83
|
+
* whatever THAT tree happens to have checked out. Seen live: a session working
|
|
84
|
+
* in a worktree on `griffin/…` published `main`, which is the one answer that
|
|
85
|
+
* is confidently wrong rather than merely vague.
|
|
86
|
+
*
|
|
87
|
+
* So the repository name comes from the root, because the project is the same
|
|
88
|
+
* project either way, and the branch comes from the directory the session is
|
|
89
|
+
* actually in.
|
|
90
|
+
*/
|
|
91
|
+
function currentBranch(dir) {
|
|
92
|
+
try {
|
|
93
|
+
return execFileSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
94
|
+
cwd: dir,
|
|
95
|
+
encoding: 'utf8',
|
|
96
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
97
|
+
timeout: 2000,
|
|
98
|
+
}).trim();
|
|
99
|
+
} catch {
|
|
100
|
+
// A detached head, a repository mid-rebase, no git at all. The repo name
|
|
101
|
+
// on its own is still worth saying.
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function send(identity, base, task) {
|
|
107
|
+
const abort = new AbortController();
|
|
108
|
+
const timer = setTimeout(() => abort.abort(), 3000);
|
|
109
|
+
try {
|
|
110
|
+
await fetch(new URL('/v1/channels/agents/task', base), {
|
|
111
|
+
method: 'POST',
|
|
112
|
+
headers: {
|
|
113
|
+
Authorization: `Device ${identity.credential}`,
|
|
114
|
+
'Content-Type': 'application/json',
|
|
115
|
+
},
|
|
116
|
+
body: JSON.stringify({ task }),
|
|
117
|
+
signal: abort.signal,
|
|
118
|
+
});
|
|
119
|
+
} catch {
|
|
120
|
+
/* Offline, mid-deploy, a revoked credential. None of it is this hook's
|
|
121
|
+
business to report: the row simply stays as it was. */
|
|
122
|
+
} finally {
|
|
123
|
+
clearTimeout(timer);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function main() {
|
|
128
|
+
const mode = process.argv[2] ?? 'start';
|
|
129
|
+
if (reportingDisabled()) return;
|
|
130
|
+
|
|
131
|
+
const base = apiBase();
|
|
132
|
+
const found = identities(base);
|
|
133
|
+
// No identity is the ordinary case for most sessions on most machines.
|
|
134
|
+
if (found.length === 0) return;
|
|
135
|
+
|
|
136
|
+
let task = '';
|
|
137
|
+
if (mode === 'start') {
|
|
138
|
+
const root = repoRoot();
|
|
139
|
+
task = taskLine(root, root ? currentBranch(process.cwd()) : null) ?? '';
|
|
140
|
+
// Nothing worth saying and nothing to clear.
|
|
141
|
+
if (!task) return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Every identity in this session, because they are all this agent: one
|
|
145
|
+
// checkout can hold credentials for more than one channel, and a fleet view
|
|
146
|
+
// showing half of them working is worse than one showing none.
|
|
147
|
+
await Promise.all(found.map((identity) => send(identity, base, task)));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (process.argv.includes('--self-test')) {
|
|
151
|
+
const checks = [];
|
|
152
|
+
const ok = (what, got, want) => checks.push([what, got === want, got, want]);
|
|
153
|
+
|
|
154
|
+
ok('repo and branch', taskLine('/x/AgentSignal', 'griffin/fix'), 'AgentSignal · griffin/fix');
|
|
155
|
+
ok('a detached head says the repo alone', taskLine('/x/AgentSignal', 'HEAD'), 'AgentSignal');
|
|
156
|
+
ok('no branch says the repo alone', taskLine('/x/AgentSignal', null), 'AgentSignal');
|
|
157
|
+
ok('outside a repository, nothing', taskLine(null, 'main'), null);
|
|
158
|
+
ok(
|
|
159
|
+
'a long branch is cut where it is composed, not by the server',
|
|
160
|
+
taskLine('/x/repo', 'b'.repeat(200))?.length,
|
|
161
|
+
MAX,
|
|
162
|
+
);
|
|
163
|
+
/*
|
|
164
|
+
THE ACTUAL INVARIANT, and it is checked against the source rather than
|
|
165
|
+
against a return value, because there is no return value that could show
|
|
166
|
+
it. "Send something more useful" is a one-line change that no other test
|
|
167
|
+
in this repository would notice -- and what it would send is what somebody
|
|
168
|
+
typed into their own terminal, to every channel this agent is in.
|
|
169
|
+
|
|
170
|
+
Structural, so it fails on the edit rather than on the consequence: the
|
|
171
|
+
prompt arrives on stdin and this file must never learn to read it.
|
|
172
|
+
*/
|
|
173
|
+
const source = readFileSync(new URL(import.meta.url), 'utf8');
|
|
174
|
+
const readsInput = /process\.stdin|readFileSync\(\s*0|\/dev\/stdin|readFileSync\(['"`]\/dev/.test(
|
|
175
|
+
source.slice(source.indexOf('const MAX')),
|
|
176
|
+
);
|
|
177
|
+
ok('the prompt is never read', readsInput, false);
|
|
178
|
+
|
|
179
|
+
ok('off', reportingDisabled({ AGENTSIGNAL_TASK: 'off' }), true);
|
|
180
|
+
ok('off, spelled another way', reportingDisabled({ AGENTSIGNAL_TASK: '0' }), true);
|
|
181
|
+
ok('unset is on', reportingDisabled({}), false);
|
|
182
|
+
ok('any other value is on', reportingDisabled({ AGENTSIGNAL_TASK: 'yes' }), false);
|
|
183
|
+
|
|
184
|
+
let failed = 0;
|
|
185
|
+
for (const [what, passed, got, want] of checks) {
|
|
186
|
+
if (!passed) {
|
|
187
|
+
failed += 1;
|
|
188
|
+
console.error(` x ${what}: got ${JSON.stringify(got)}, wanted ${JSON.stringify(want)}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
console.log(
|
|
192
|
+
failed === 0
|
|
193
|
+
? `Task hook: ${checks.length} checks passed.`
|
|
194
|
+
: `Task hook: ${failed} of ${checks.length} FAILED.`,
|
|
195
|
+
);
|
|
196
|
+
process.exit(failed === 0 ? 0 : 1);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Exit 0 whatever happened. A status line must not be able to fail a turn.
|
|
200
|
+
main().then(
|
|
201
|
+
() => process.exit(0),
|
|
202
|
+
() => process.exit(0),
|
|
203
|
+
);
|