pendingyou 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.45.0 (2026-11-19)
4
+
5
+ - **Antigravity, as a first version to try.** `npx -y pendingyou@latest init --app antigravity` sets up Google's
6
+ Antigravity CLI (`agy` 1.5.12 or later), alone or beside other agents (`--app codex,antigravity`), with its own
7
+ connection and the same one approval. It is set up only when you name it: `init` with no `--app` leaves Antigravity
8
+ and `~/.gemini` alone even when agy is installed, and `status` shows it once it's set up. It writes one plugin of
9
+ Pending You's in `~/.gemini/config/plugins/pendingyou/`: its MCP server through the bridge, with the tools every
10
+ task uses loaded at once; the guide's short version as always-on rules, and the skill; and hooks that hand it your
11
+ answers as a conversation starts and with each message, and ask it once to put on a card what it leaves you only in
12
+ chat. agy doesn't hand that hook the reply, so it reads the reply's last words from the end of agy's own transcript.
13
+ After the agent posts a card, the hooks ask Pending You for the conversation's open cards, because agy doesn't hand
14
+ them the card's id: the conversation knows the card at once, and so do its Herdr badges. `init` asks you, apart from
15
+ the rest, whether Antigravity may run Pending You's tools and its hold without asking each time (two rules in
16
+ `~/.gemini/antigravity-cli/settings.json`), and adds none when there's nobody to ask or with `--yes`. `uninstall`
17
+ takes out exactly what `init` added. Restart agy afterwards: it loads plugins as it starts.
18
+ - **What doesn't work yet in Antigravity.** Its permission prompts don't come to your cards: you answer them in agy.
19
+ Nothing outside Antigravity can start a turn in it, so an idle conversation hears your answer only through a hold it
20
+ started itself in the background after asking (`npx pendingyou hold <requestId>`); one that didn't start a hold hears
21
+ it with your next message. An answer the agent posts (`post_answer`) isn't known to the conversation until later. If
22
+ you send the same message twice in a row while a command the agent started is still running, the second is taken
23
+ for a hold waking it, and answers waiting for you aren't read with it.
24
+
25
+ ## 0.44.1 (2026-11-19)
26
+
27
+ Found by the first live tests of Codex 0.170.0, OpenCode 2.3.2 and Pi 1.5.2.
28
+
29
+ - **A reply on an open card wakes Pi and OpenCode.** When you wrote back on a card (“Before I answer: how long can it
30
+ be?”) while a Pi or OpenCode session sat idle, nothing woke it: it heard your words only with your next message. The
31
+ session's listener read its cards before each wait for news, so a card posted during that wait, and written on
32
+ before it ended, was missed for good. The same could happen to an answer, less often, and to Codex on a second card
33
+ posted while the first one's listener ran. A question you hand a session was never affected.
34
+ - **A reply that ends on a question reaches you as a card.** An assistant that ended on “Should the next file be
35
+ called alpha.txt or beta.txt?” settled with the question only in chat: the check that puts what an assistant leaves
36
+ you in chat on a card counted a question only when it said “you”. Now a reply whose last sentence is a question
37
+ counts, in every app (Claude Code, Codex, OpenCode and Pi), outside code, quotes and a closing aside in parentheses,
38
+ and not a question it goes on to answer itself.
39
+ - **A question already on one of the session's open cards no longer nags.** When all a reply leaves you is questions
40
+ and each is one of the session's open cards (“Still waiting: which DNS host for the new domain?”), the assistant
41
+ isn't asked to post it again. It asks Pending You for those cards (1.5 seconds at most); when Pending You can't say
42
+ in time, it lets the reply stand. The words an assistant is asked with are unchanged.
43
+ - **An assistant shows as running as soon as it has a name.** A session said it was open before it had said its name,
44
+ and Pending You knows a session's agent by its name, so a new Pi, OpenCode or Codex session wasn't shown running for
45
+ up to 5 minutes after it introduced itself. Now it says so again, with its name, the moment it gives one.
46
+ - After `npx -y pendingyou@latest init`: restart Pi (or `/reload` in it) and OpenCode 1.x so their listeners run the
47
+ new version; OpenCode 2.x reloads the plugin by itself. A Codex thread's listener runs the new version the next
48
+ time one starts (when it has no card left, or after 8 hours, it stops). Nothing to restart for the rest: the check
49
+ on a reply's last words and the name sent with a session's presence run the new version at once.
50
+
3
51
  ## 0.44.0 (2026-11-18)
4
52
 
5
53
  - **OpenCode 2.x: Pending You's plugin loads again.** OpenCode 2.0.0 and later refused the plugin that `init` wrote
package/README.md CHANGED
@@ -2,14 +2,15 @@
2
2
 
3
3
  Pending You for your coding agents. Your agents ask you in [Pending You](https://www.pendingyou.com) when you're away;
4
4
  this command sets Claude Code, Codex, OpenCode and Pi up to ask there and to hear your answer the moment it's ready,
5
- even while they sit idle at the prompt.
5
+ even while they sit idle at the prompt. Antigravity too, as a first version to try, when you name it
6
+ (`--app antigravity`, [below](#antigravity)).
6
7
 
7
8
  ```sh
8
9
  npx -y pendingyou@latest init
9
10
  ```
10
11
 
11
12
  Run it once on each computer, in a terminal. It finds the agents on the computer (Claude Code, Codex, OpenCode, Pi;
12
- `--app` names some), says what it found, and for each one:
13
+ `--app` names some, and only `--app antigravity` sets Antigravity up), says what it found, and for each one:
13
14
 
14
15
  - connects it to Pending You through **this computer's own sign-in**: its own connection ("Claude Code on Ann-MBP",
15
16
  "Codex on Ann-MBP" on your Assistants page), which its MCP server and its hooks share, so there's nothing to
@@ -186,6 +187,51 @@ Pending You's tools are there.
186
187
  Then run `/reload` in each Pi session that's open, or start `pi`. Pi's shell waits for a command to end, so in Pi
187
188
  `npx pendingyou hold` answers at once instead of waiting.
188
189
 
190
+ ## Antigravity
191
+
192
+ Google's Antigravity CLI 1.5.12 or later (the `agy` command), as a first version to try: `init` sets it up only when
193
+ you name it, alone or with others (`npx -y pendingyou@latest init --app antigravity`, or `--app codex,antigravity`).
194
+ With no `--app` it never looks for agy or touches `~/.gemini`, and `status` shows Antigravity once it's set up.
195
+ Everything is one plugin, Pending You's, in a folder of its own that `init` writes whole:
196
+ `~/.gemini/config/plugins/pendingyou/`, with
197
+
198
+ - `mcp_config.json`: the bridge as a local server, with its own connection here ("Antigravity on Ann-MBP"), and the
199
+ tools every task uses loaded with each conversation (`"tools": {"post_request": {"eager": true}, …}`; agy loads the
200
+ rest when the model asks for them). `--oauth` puts Pending You's address there instead, which Antigravity signs in to
201
+ by itself. A `pendingyou` server you added to `~/.gemini/config/mcp_config.json` yourself would be a second one:
202
+ `init` asks to take it out (and `uninstall` puts it back), or keeps it and adds none.
203
+ - `rules/AGENTS.md`: the guide's short version, always on while the plugin is (agy doesn't give a server's own
204
+ instructions to its model), and how answers reach an Antigravity conversation; `skills/pendingyou/SKILL.md`.
205
+ - `hooks.json`: the same hooks' script as the other agents', as a conversation starts (its first message), at each
206
+ turn's first model call, after Pending You's tools and as a turn ends (once). Each line ends `|| echo '{}'`: agy
207
+ reads a JSON object from every hook.
208
+
209
+ agy finds the plugin and turns it on by itself (`agy plugin disable pendingyou` turns it off, and `init` never turns it
210
+ back on). It loads plugins as it starts, so restart it afterwards (`/exit`, then `agy`; `agy -c` picks the conversation
211
+ up again).
212
+
213
+ Nothing outside Antigravity can start a turn in it, so an idle conversation hears your answer only through a hold its
214
+ agent starts: after it posts a card it runs `npx pendingyou hold <requestId>` as a background command, which ends when
215
+ you answer and so wakes it (inside agy, the hold listens with Antigravity's own sign-in). An answer that waits for your
216
+ next message comes with it.
217
+
218
+ What's known not to work yet: a permission prompt in Antigravity doesn't become a card (you answer it in agy), and an
219
+ idle conversation hears an answer only through a hold it started. As a turn ends, the hooks read its last message from
220
+ the end of agy's own transcript, to catch a question left only in chat. After a card is posted they ask Pending You for
221
+ the conversation's open cards, since agy doesn't hand them the card's id (an answer, `post_answer`, isn't learned so).
222
+ The same message sent twice in a row reads as a hold's wake when the turn before left a command running.
223
+
224
+ Antigravity asks you before each Pending You tool call and each shell command. `init` can allow both for you, in
225
+ `~/.gemini/antigravity-cli/settings.json`'s `permissions.allow` (your other settings kept as they were):
226
+
227
+ ```json
228
+ "mcp(pendingyou_pendingyou/*)",
229
+ "command(npx pendingyou hold)"
230
+ ```
231
+
232
+ It asks first, at a terminal, apart from the rest, and adds nothing when there's nobody to ask or with `--yes`; run
233
+ `init --app antigravity` again at a terminal to add them later. `uninstall` takes out only the ones it added.
234
+
189
235
  ## Nothing left only in chat
190
236
 
191
237
  Deep into a long conversation, Claude Code tends to end a turn with a question for you, a step only you can do, or a
@@ -359,6 +405,8 @@ its folder (under `~` only) and `live` or `closed`. Pending You counts a session
359
405
  idle 30 minutes) says closed.
360
406
  - **OpenCode and Pi**: the plugin and the extension, as a session starts and every 5 minutes while the app runs, and
361
407
  closed as it goes.
408
+ - **Antigravity**: as a conversation's first message comes, Codex's small process in the background, every 5 minutes
409
+ while agy runs, and closed once it's gone (agy has no hook for a conversation's end).
362
410
 
363
411
  It's never in your way: the hooks only start it in the background, each send gives up after 3 seconds, and a Pending
364
412
  You from before presence is taken quietly. A sign-in that only hears (`--oauth`) sends nothing. `npx pendingyou status`
@@ -0,0 +1,326 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { open } from 'node:fs/promises';
3
+ import { isAbsolute, join } from 'node:path';
4
+ import { DEFAULT_ORIGIN } from "../args.js";
5
+ import { configDir, readJson, withLock, writeWhole } from "../files.js";
6
+ import { isHandedWake } from "../format.js";
7
+ export const AGY_HOOK_EVENTS = {
8
+ pickup: 'SessionStart',
9
+ handoff: 'PreInvocation',
10
+ posted: 'PostToolUse',
11
+ stopcheck: 'Stop',
12
+ };
13
+ export const isAgyHook = (name) => name in AGY_HOOK_EVENTS;
14
+ export const AGY_MCP_CALLERS = new Set(['call_mcp_tool', 'mcp_tool']);
15
+ export const AGY_EAGER_TOOL = /^(?:mcp_{1,2})?([A-Za-z0-9-]*pendingyou[A-Za-z0-9_-]*?)_{1,2}(post_request|post_answer|update_request|reply_in_thread|cancel_request|answer_delegated|hand_back|whoami|list_pending|get_request)$/i;
16
+ export const AGY_POST_TOOL_MATCHER = '.*mcp.*|.*pendingyou.*';
17
+ export const AGY_TRANSCRIPT_CAP = 4 * 1024 * 1024;
18
+ const CHUNK = 64 * 1024;
19
+ const NOT_SETTLED = new Set(['USER_CANCELED', 'ERROR']);
20
+ const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
21
+ const text = (value) => (typeof value === 'string' && value.trim() ? value : null);
22
+ export function agyToolCall(toolCall) {
23
+ if (!isObject(toolCall) || typeof toolCall.name !== 'string')
24
+ return null;
25
+ const args = isObject(toolCall.args) ? toolCall.args : {};
26
+ let server = null;
27
+ let tool = null;
28
+ let input = args;
29
+ if (AGY_MCP_CALLERS.has(toolCall.name)) {
30
+ server = text(args.ServerName ?? args.serverName ?? args.server_name ?? args.server);
31
+ tool = text(args.ToolName ?? args.toolName ?? args.tool_name ?? args.tool);
32
+ input = args.Arguments ?? args.arguments ?? {};
33
+ }
34
+ else {
35
+ const eager = AGY_EAGER_TOOL.exec(toolCall.name);
36
+ if (eager) {
37
+ server = eager[1] ?? null;
38
+ tool = eager[2] ?? null;
39
+ input = args.Arguments ?? args.arguments ?? args;
40
+ }
41
+ }
42
+ if (!server || !tool || !/pendingyou/i.test(server) || !/^[a-z_]{1,40}$/.test(tool))
43
+ return null;
44
+ if (typeof input === 'string')
45
+ try {
46
+ input = JSON.parse(input);
47
+ }
48
+ catch {
49
+ input = {};
50
+ }
51
+ if (!isObject(input))
52
+ return { name: `mcp__pendingyou__${tool}`, input: {} };
53
+ const { toolSummary: _summary, ...own } = input;
54
+ return { name: `mcp__pendingyou__${tool}`, input: own };
55
+ }
56
+ const turnsPath = (io) => join(configDir(io), 'antigravity-turns.json');
57
+ const KEEP_TURN_MS = 24 * 60 * 60_000;
58
+ const KEEP_TURNS = 200;
59
+ async function readTurns(io) {
60
+ const file = await readJson(turnsPath(io)).catch(() => null);
61
+ const found = {};
62
+ if (isObject(file?.conversations))
63
+ for (const [id, value] of Object.entries(file.conversations))
64
+ if (isObject(value) && typeof value.turn === 'string' && typeof value.at === 'number')
65
+ found[id] = {
66
+ turn: value.turn,
67
+ at: value.at,
68
+ ...(typeof value.input === 'string' ? { input: value.input } : {}),
69
+ ...(value.woken === true ? { woken: true } : {}),
70
+ ...(value.idle === true ? { idle: true } : {}),
71
+ };
72
+ return found;
73
+ }
74
+ async function writeTurns(io, conversations) {
75
+ const now = io.now();
76
+ const kept = Object.entries(conversations)
77
+ .filter(([, each]) => now - each.at < KEEP_TURN_MS)
78
+ .sort((a, b) => b[1].at - a[1].at)
79
+ .slice(0, KEEP_TURNS);
80
+ await writeWhole(turnsPath(io), `${JSON.stringify({ version: 1, conversations: Object.fromEntries(kept) }, null, 2)}\n`, { secret: true });
81
+ }
82
+ const hashOf = (words) => createHash('sha256').update(words).digest('hex').slice(0, 32);
83
+ async function noteTurn(io, conversation, turn, prompt) {
84
+ let woken = false;
85
+ try {
86
+ const path = turnsPath(io);
87
+ await withLock(path, io, async () => {
88
+ const conversations = await readTurns(io);
89
+ const now = io.now();
90
+ const before = conversations[conversation];
91
+ const input = prompt === null ? undefined : hashOf(prompt);
92
+ woken = Boolean(before && before.turn !== turn && input && before.input === input && before.idle !== true);
93
+ conversations[conversation] = {
94
+ turn,
95
+ at: now,
96
+ ...(input ? { input } : {}),
97
+ ...(woken ? { woken: true } : {}),
98
+ };
99
+ await writeTurns(io, conversations);
100
+ });
101
+ }
102
+ catch { }
103
+ return woken;
104
+ }
105
+ async function noteStop(io, conversation, fullyIdle) {
106
+ if (typeof fullyIdle !== 'boolean')
107
+ return;
108
+ try {
109
+ const path = turnsPath(io);
110
+ await withLock(path, io, async () => {
111
+ const conversations = await readTurns(io);
112
+ const now = conversations[conversation];
113
+ if (!now || (now.idle === true) === fullyIdle)
114
+ return;
115
+ const { idle: _idle, ...rest } = now;
116
+ conversations[conversation] = { ...rest, ...(fullyIdle ? { idle: true } : {}) };
117
+ await writeTurns(io, conversations);
118
+ });
119
+ }
120
+ catch { }
121
+ }
122
+ async function turnOf(io, conversation) {
123
+ const found = (await readTurns(io).catch(() => ({})))[conversation];
124
+ return found && io.now() - found.at < KEEP_TURN_MS ? found : null;
125
+ }
126
+ export const agyHookFiles = (io) => [turnsPath(io)];
127
+ export async function agyFinalMessage(path, cap = AGY_TRANSCRIPT_CAP) {
128
+ let file;
129
+ try {
130
+ file = await open(path, 'r');
131
+ }
132
+ catch {
133
+ return null;
134
+ }
135
+ try {
136
+ let position = (await file.stat()).size;
137
+ let bytesRead = 0;
138
+ let carry = Buffer.alloc(0);
139
+ const texts = [];
140
+ let newest = true;
141
+ const take = (raw) => {
142
+ if (!raw.trim())
143
+ return 'more';
144
+ let step;
145
+ try {
146
+ step = JSON.parse(raw);
147
+ }
148
+ catch {
149
+ return newest ? 'unknown' : 'whole';
150
+ }
151
+ newest = false;
152
+ if (!isObject(step) || step.type !== 'PLANNER_RESPONSE')
153
+ return 'whole';
154
+ if (Array.isArray(step.tool_calls) && step.tool_calls.length > 0)
155
+ return 'whole';
156
+ if (typeof step.content === 'string' && step.content.trim())
157
+ texts.unshift(step.content);
158
+ return 'more';
159
+ };
160
+ const said = () => texts.join('\n').trim() || null;
161
+ while (position > 0 && bytesRead < cap) {
162
+ const length = Math.min(CHUNK, position, cap - bytesRead);
163
+ position -= length;
164
+ const chunk = Buffer.alloc(length);
165
+ await file.read(chunk, 0, length, position);
166
+ bytesRead += length;
167
+ let buffer = Buffer.concat([chunk, carry]);
168
+ let newline = buffer.lastIndexOf(10);
169
+ while (newline !== -1) {
170
+ const taken = take(buffer.subarray(newline + 1).toString('utf8'));
171
+ if (taken === 'unknown')
172
+ return null;
173
+ if (taken === 'whole')
174
+ return said();
175
+ buffer = buffer.subarray(0, newline);
176
+ newline = buffer.lastIndexOf(10);
177
+ }
178
+ carry = buffer;
179
+ }
180
+ if (position > 0)
181
+ return null;
182
+ const taken = take(carry.toString('utf8'));
183
+ return taken === 'unknown' ? null : said();
184
+ }
185
+ catch {
186
+ return null;
187
+ }
188
+ finally {
189
+ await file.close().catch(() => { });
190
+ }
191
+ }
192
+ const squash = (value) => typeof value === 'string' ? value.trim().replace(/\s+/g, ' ') : '';
193
+ async function postedCard(io, origin, session, cwd, args) {
194
+ try {
195
+ const title = squash(args.title);
196
+ if (!title)
197
+ return null;
198
+ const [{ openCards }, { threadCards }] = await Promise.all([
199
+ import("../stopcheck.js"),
200
+ import("./codex-wake.js"),
201
+ ]);
202
+ const label = isObject(args.session) ? text(args.session.label) : null;
203
+ const name = label ?? text(args.name);
204
+ const open = await openCards(io, origin, cwd, 'antigravity', { id: session, transcript: null, name }, 'none');
205
+ if (!open?.length)
206
+ return null;
207
+ const known = new Set(await threadCards(io, 'antigravity', session).catch(() => []));
208
+ const fresh = open.filter((card) => card.requestId && !known.has(card.requestId) && squash(card.title) === title);
209
+ return fresh.length === 1 ? (fresh[0]?.requestId ?? null) : null;
210
+ }
211
+ catch {
212
+ return null;
213
+ }
214
+ }
215
+ export async function agyInput(io, command, input, origin = DEFAULT_ORIGIN) {
216
+ const session = text(input.conversationId);
217
+ const folders = Array.isArray(input.workspacePaths) ? input.workspacePaths : [];
218
+ const cwd = text(input.cwd) ?? text(folders[0]);
219
+ const prompt = text(input.lastUserInput);
220
+ const common = {
221
+ ...(session ? { session_id: session } : {}),
222
+ ...(cwd ? { cwd } : {}),
223
+ };
224
+ switch (command) {
225
+ case 'pickup':
226
+ return { ...common, source: 'startup', ...(prompt ? { prompt } : {}) };
227
+ case 'handoff': {
228
+ const call = typeof input.invocationNum === 'number' ? input.invocationNum : 0;
229
+ if (call !== 0)
230
+ return null;
231
+ const steps = typeof input.initialNumSteps === 'number' ? input.initialNumSteps : 0;
232
+ const turn = session ? `${session}:${steps}` : null;
233
+ const woken = session && turn ? await noteTurn(io, session, turn, prompt) : false;
234
+ return {
235
+ ...common,
236
+ ...(prompt && !woken ? { prompt } : {}),
237
+ ...(woken ? { woken: true } : {}),
238
+ ...(turn ? { turn_id: turn } : {}),
239
+ };
240
+ }
241
+ case 'posted': {
242
+ if (text(input.error))
243
+ return null;
244
+ const call = agyToolCall(input.toolCall);
245
+ if (!call || !session)
246
+ return null;
247
+ const turn = await turnOf(io, session);
248
+ const card = call.name === 'mcp__pendingyou__post_request' && cwd
249
+ ? await postedCard(io, origin, session, cwd, call.input)
250
+ : null;
251
+ return {
252
+ ...common,
253
+ ...(turn ? { turn_id: turn.turn } : {}),
254
+ tool_name: call.name,
255
+ tool_input: call.input,
256
+ ...(card ? { tool_response: { structuredContent: { requestId: card } } } : {}),
257
+ };
258
+ }
259
+ case 'stopcheck': {
260
+ if (session)
261
+ await noteStop(io, session, input.fullyIdle);
262
+ if (NOT_SETTLED.has(String(input.terminationReason ?? '')))
263
+ return null;
264
+ const turn = session ? await turnOf(io, session) : null;
265
+ const active = input.continuationActive === true ||
266
+ (typeof input.executionNum === 'number' && input.executionNum > 0);
267
+ const path = text(input.transcriptPath);
268
+ const final = !active && path && isAbsolute(path) && path.endsWith('.jsonl')
269
+ ? await agyFinalMessage(path)
270
+ : null;
271
+ const own = turn?.woken ? null : prompt;
272
+ return {
273
+ ...common,
274
+ ...(turn ? { turn_id: turn.turn } : {}),
275
+ stop_hook_active: active,
276
+ ...(final ? { last_assistant_message: final } : {}),
277
+ ...(own ? { prompt: own } : {}),
278
+ handed: own !== null && isHandedWake(own),
279
+ };
280
+ }
281
+ }
282
+ }
283
+ export function agyOutput(command, printed) {
284
+ const said = printed.trim();
285
+ if (!said)
286
+ return {};
287
+ if (command === 'pickup' || command === 'handoff')
288
+ return { injectSteps: [{ systemMessage: { systemMessage: said } }] };
289
+ if (command === 'stopcheck')
290
+ for (const line of said.split('\n'))
291
+ try {
292
+ const parsed = JSON.parse(line);
293
+ if (isObject(parsed) && parsed.decision === 'block' && typeof parsed.reason === 'string')
294
+ return { decision: 'continue', reason: parsed.reason };
295
+ }
296
+ catch { }
297
+ return {};
298
+ }
299
+ export async function antigravityHook(io, command, origin, run) {
300
+ let answer = {};
301
+ try {
302
+ const raw = await io.readStdin(1000).catch(() => '');
303
+ let input = {};
304
+ try {
305
+ const parsed = JSON.parse(raw);
306
+ if (isObject(parsed))
307
+ input = parsed;
308
+ }
309
+ catch { }
310
+ const read = await agyInput(io, command, input, origin);
311
+ if (read) {
312
+ let printed = '';
313
+ await run({
314
+ ...io,
315
+ readStdin: async () => JSON.stringify(read),
316
+ out: (said) => {
317
+ printed += said;
318
+ },
319
+ });
320
+ answer = agyOutput(command, printed);
321
+ }
322
+ }
323
+ catch { }
324
+ io.out(`${JSON.stringify(answer)}\n`);
325
+ return 0;
326
+ }