pendingyou 0.45.0 → 0.45.2
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 +33 -1
- package/README.md +3 -2
- package/dist/apps/antigravity.js +8 -4
- package/dist/hold.js +4 -3
- package/dist/loaded.js +25 -1
- package/dist/pickup.js +1 -1
- package/dist/presence.js +7 -0
- package/dist/setup.js +1 -1
- package/dist/version.js +1 -1
- package/mod/.claude-plugin/plugin.json +1 -1
- package/mod/README.md +1 -1
- package/mod/hooks/register.js +51 -3
- package/mod/hooks/wake.js +63 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.45.2 (2026-11-19)
|
|
4
|
+
|
|
5
|
+
- **A Claude Code session that goes on under a new id keeps its cards across a reload.** One session kept running
|
|
6
|
+
while Claude Code gave it a new session id, and the wake mod never heard about it. The mod kept waking it, but kept
|
|
7
|
+
its cards under the old id. When `init` updates the mod, the session reloads it under the new id, and it would have
|
|
8
|
+
found no cards there, so your answers to them wouldn't have woken it. Now a session that reloads and finds no cards
|
|
9
|
+
under its id waits about 6 minutes. If one other open session can only have been this same process under its old id
|
|
10
|
+
(same name, same folder, its mod running until the reload, and nothing heard from it since), the session takes that
|
|
11
|
+
session's cards. It writes them under the new id before removing the old copy.
|
|
12
|
+
- **`init` and the next message tell such a session apart from a truly unwoken one.** A session the mod has no note
|
|
13
|
+
for counts as woken only when another session with the same name and folder looks like this same process under its
|
|
14
|
+
old id: it was heard of first, its mod has said it's open since the new id began (in the last 15 minutes), and its
|
|
15
|
+
hooks went quiet when the new id began. If both sessions are still being used, or the record is from before 0.45.2,
|
|
16
|
+
you're still told to restart. Presence now records when Claude Code's hooks last said a session was open.
|
|
17
|
+
- The Pending You plugin carries the same mod: guide 2.63.1 (version only).
|
|
18
|
+
|
|
19
|
+
## 0.45.1 (2026-11-19)
|
|
20
|
+
|
|
21
|
+
Found by the first live run of Antigravity.
|
|
22
|
+
|
|
23
|
+
- **Antigravity's background wait starts.** After asking you something, an Antigravity conversation starts a wait in
|
|
24
|
+
the background that wakes it when you answer. It never started: Antigravity runs commands in a terminal, and there
|
|
25
|
+
npm stopped to ask whether to install pendingyou, a question nobody answers in the background. So your answer woke
|
|
26
|
+
nothing. The wait is now `npx -y pendingyou hold <requestId>`, which doesn't ask. Antigravity's permission rule for
|
|
27
|
+
it becomes `command(npx -y pendingyou hold)`: run `npx -y pendingyou@latest init --app antigravity` again at a
|
|
28
|
+
terminal and say yes to add it (`status` says it's missing until then). The old rule stays until `uninstall`, which
|
|
29
|
+
takes out both. Claude Code's wait is unchanged: npm doesn't ask there.
|
|
30
|
+
- **Antigravity finishes setup without a shell command.** When "Finish setting up Pending You" came in a conversation
|
|
31
|
+
continued with `agy -c`, the agent read the whole guide, which Antigravity saved to a file, and then ran a shell
|
|
32
|
+
command to read it, behind Antigravity's "Run this command?" prompt. The rules `init` writes now carry setup's three
|
|
33
|
+
calls, so no guide, file or command is needed.
|
|
34
|
+
|
|
3
35
|
## 0.45.0 (2026-11-19)
|
|
4
36
|
|
|
5
37
|
- **Antigravity, as a first version to try.** `npx -y pendingyou@latest init --app antigravity` sets up Google's
|
|
@@ -17,7 +49,7 @@
|
|
|
17
49
|
takes out exactly what `init` added. Restart agy afterwards: it loads plugins as it starts.
|
|
18
50
|
- **What doesn't work yet in Antigravity.** Its permission prompts don't come to your cards: you answer them in agy.
|
|
19
51
|
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
|
|
52
|
+
started itself in the background after asking (`npx pendingyou hold <requestId>`; `npx -y` since 0.45.1); one that didn't start a hold hears
|
|
21
53
|
it with your next message. An answer the agent posts (`post_answer`) isn't known to the conversation until later. If
|
|
22
54
|
you send the same message twice in a row while a command the agent started is still running, the second is taken
|
|
23
55
|
for a hold waking it, and answers waiting for you aren't read with it.
|
package/README.md
CHANGED
|
@@ -211,7 +211,8 @@ back on). It loads plugins as it starts, so restart it afterwards (`/exit`, then
|
|
|
211
211
|
up again).
|
|
212
212
|
|
|
213
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
|
|
214
|
+
agent starts: after it posts a card it runs `npx -y pendingyou hold <requestId>` as a background command (the `-y`
|
|
215
|
+
because agy runs commands in a terminal, where npx would otherwise stop to ask before installing), which ends when
|
|
215
216
|
you answer and so wakes it (inside agy, the hold listens with Antigravity's own sign-in). An answer that waits for your
|
|
216
217
|
next message comes with it.
|
|
217
218
|
|
|
@@ -226,7 +227,7 @@ Antigravity asks you before each Pending You tool call and each shell command. `
|
|
|
226
227
|
|
|
227
228
|
```json
|
|
228
229
|
"mcp(pendingyou_pendingyou/*)",
|
|
229
|
-
"command(npx pendingyou hold)"
|
|
230
|
+
"command(npx -y pendingyou hold)"
|
|
230
231
|
```
|
|
231
232
|
|
|
232
233
|
It asks first, at a terminal, apart from the rest, and adds nothing when there's nobody to ask or with `--yes`; run
|
package/dist/apps/antigravity.js
CHANGED
|
@@ -8,7 +8,7 @@ import { isOurHook, originArgs } from "../hooks.js";
|
|
|
8
8
|
import { editJson, isObject, readObject } from "../json.js";
|
|
9
9
|
import { removePresenceFiles } from "../presence.js";
|
|
10
10
|
import { foundBy, headlessReason } from "../remote.js";
|
|
11
|
-
import { connectionTitle, FINISH_SAY, setupOf, setupStatus } from "../setup.js";
|
|
11
|
+
import { connectionTitle, FINISH_SAY, setupCalls, setupOf, setupStatus } from "../setup.js";
|
|
12
12
|
import { VERSION } from "../version.js";
|
|
13
13
|
import { AGY_HOOK_EVENTS, AGY_POST_TOOL_MATCHER, agyHookFiles } from "./antigravity-hooks.js";
|
|
14
14
|
import { threadFiles } from "./codex-wake.js";
|
|
@@ -37,7 +37,7 @@ export const EAGER_TOOLS = [
|
|
|
37
37
|
];
|
|
38
38
|
export const PERMISSION_RULES = [
|
|
39
39
|
'mcp(pendingyou_pendingyou/*)',
|
|
40
|
-
'command(npx pendingyou hold)',
|
|
40
|
+
'command(npx -y pendingyou hold)',
|
|
41
41
|
];
|
|
42
42
|
const FILES = [
|
|
43
43
|
'plugin.json',
|
|
@@ -160,7 +160,11 @@ export function rulesFile(stub, origin) {
|
|
|
160
160
|
|
|
161
161
|
${body ? `${body}\n\n` : ''}## Answers in Antigravity
|
|
162
162
|
|
|
163
|
-
An idle Antigravity conversation hears your person’s answer only through a hold you start: right after you post a card (post_request) or an answer (post_answer), run \`${holdCommand('<requestId>', origin)}\` as a background command (run_command with a short WaitMsBeforeAsync), then keep working or end your turn. When it finishes it says what came: act on it as it says. Answers waiting at your person’s next message come with it.
|
|
163
|
+
An idle Antigravity conversation hears your person’s answer only through a hold you start: right after you post a card (post_request) or an answer (post_answer), run \`${holdCommand('<requestId>', origin, undefined, 'antigravity')}\` as a background command (run_command with a short WaitMsBeforeAsync), then keep working or end your turn. When it finishes it says what came: act on it as it says. Answers waiting at your person’s next message come with it.
|
|
164
|
+
|
|
165
|
+
## Finishing setup
|
|
166
|
+
|
|
167
|
+
When your person says “${FINISH_SAY}”, or asks you to finish setting up Pending You, this is all of it: don’t ask whoami for the guide, and run no command to read anything. ${setupCalls('antigravity', true)}
|
|
164
168
|
`;
|
|
165
169
|
}
|
|
166
170
|
export function hooksFile(line) {
|
|
@@ -683,7 +687,7 @@ export const antigravity = {
|
|
|
683
687
|
connected && hooksOk
|
|
684
688
|
? ' ok Presence: tells Pending You when a conversation is open (its keeper says so every 5 minutes while agy runs)'
|
|
685
689
|
: ` Presence: off: it needs ${connected ? 'the hooks' : 'Antigravity signed in through this computer’s own connection'}`,
|
|
686
|
-
` Wake: an idle conversation hears your answer through the hold it starts in the background (${holdCommand('<requestId>', origin)}); otherwise with your next message`,
|
|
690
|
+
` Wake: an idle conversation hears your answer through the hold it starts in the background (${holdCommand('<requestId>', origin, undefined, 'antigravity')}); otherwise with your next message`,
|
|
687
691
|
];
|
|
688
692
|
const setup = setupStatus(NAME, signIn.state === 'ok' ? setupOf(signIn.for) : null);
|
|
689
693
|
if (setup)
|
package/dist/hold.js
CHANGED
|
@@ -19,9 +19,10 @@ export function durationText(ms) {
|
|
|
19
19
|
return `${ms / 60_000}m`;
|
|
20
20
|
return `${Math.round(ms / 1000)}s`;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export const holdWords = (app = DEFAULT_APP) => app === 'antigravity' ? 'npx -y pendingyou hold' : 'npx pendingyou hold';
|
|
23
|
+
export function holdCommand(requestId, origin = DEFAULT_ORIGIN, timeoutMs = DEFAULT_TIMEOUT_MS, app = DEFAULT_APP) {
|
|
23
24
|
return [
|
|
24
|
-
|
|
25
|
+
`${holdWords(app)} ${requestId}`,
|
|
25
26
|
...(origin === DEFAULT_ORIGIN ? [] : [`--origin ${origin}`]),
|
|
26
27
|
...(timeoutMs === DEFAULT_TIMEOUT_MS ? [] : [`--timeout ${durationText(timeoutMs)}`]),
|
|
27
28
|
].join(' ');
|
|
@@ -58,7 +59,7 @@ export async function hold(io, options) {
|
|
|
58
59
|
return 0;
|
|
59
60
|
}
|
|
60
61
|
const app = await holdApp(io);
|
|
61
|
-
const again = holdCommand(requestId, origin, options.timeoutMs);
|
|
62
|
+
const again = holdCommand(requestId, origin, options.timeoutMs, app);
|
|
62
63
|
const started = io.now();
|
|
63
64
|
const deadline = started + options.timeoutMs;
|
|
64
65
|
const print = (lines) => io.out(`${lines.join('\n')}\n`);
|
package/dist/loaded.js
CHANGED
|
@@ -7,6 +7,7 @@ import { claimUnwoken } from "./state.js";
|
|
|
7
7
|
const SESSION = /^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/;
|
|
8
8
|
export const LOADED_GRACE_MS = 15_000;
|
|
9
9
|
export const OPEN_FOR_MS = 12 * 60 * 60_000;
|
|
10
|
+
export const MOD_BEAT_MS = 15 * 60_000;
|
|
10
11
|
const KEEP_NOTES_MS = 7 * 24 * 60 * 60_000;
|
|
11
12
|
const notesDir = (io) => join(configDir(io), 'wake', 'sessions');
|
|
12
13
|
export const loadedPath = (io, session) => join(notesDir(io), `${session}.json`);
|
|
@@ -24,15 +25,36 @@ export async function modLoaded(io, session, said) {
|
|
|
24
25
|
return false;
|
|
25
26
|
return stat(loadedPath(io, session)).then(() => true, () => false);
|
|
26
27
|
}
|
|
28
|
+
export const HOOK_SLACK_MS = 60_000;
|
|
29
|
+
export function wokenAlongside(sessions, session, now) {
|
|
30
|
+
const mine = sessions[session];
|
|
31
|
+
const since = mine?.since;
|
|
32
|
+
if (!mine?.name || !mine.cwd || since === undefined)
|
|
33
|
+
return false;
|
|
34
|
+
return Object.entries(sessions).some(([id, other]) => id !== session &&
|
|
35
|
+
other.state === 'live' &&
|
|
36
|
+
other.mod !== undefined &&
|
|
37
|
+
now - other.mod <= MOD_BEAT_MS &&
|
|
38
|
+
other.name === mine.name &&
|
|
39
|
+
other.cwd === mine.cwd &&
|
|
40
|
+
other.since !== undefined &&
|
|
41
|
+
other.since < since &&
|
|
42
|
+
other.mod > since &&
|
|
43
|
+
other.hook !== undefined &&
|
|
44
|
+
other.hook <= since + HOOK_SLACK_MS);
|
|
45
|
+
}
|
|
27
46
|
export async function unwokenLine(io, origin, session, said) {
|
|
28
47
|
try {
|
|
29
48
|
if (!session || !SESSION.test(session))
|
|
30
49
|
return null;
|
|
31
50
|
if (!(await modConfigured(io)))
|
|
32
51
|
return null;
|
|
33
|
-
const
|
|
52
|
+
const sessions = await readSaid(io, 'claude-code').catch(() => ({}));
|
|
53
|
+
const latest = sessions[session];
|
|
34
54
|
if ((await modLoaded(io, session, said)) || latest?.mod)
|
|
35
55
|
return null;
|
|
56
|
+
if (wokenAlongside(sessions, session, io.now()))
|
|
57
|
+
return null;
|
|
36
58
|
if (said?.since !== undefined && io.now() - said.since < LOADED_GRACE_MS)
|
|
37
59
|
return null;
|
|
38
60
|
if (!(await claimUnwoken(io, session)))
|
|
@@ -51,6 +73,8 @@ export async function unwokenSessions(io) {
|
|
|
51
73
|
continue;
|
|
52
74
|
if (await modLoaded(io, session, each))
|
|
53
75
|
continue;
|
|
76
|
+
if (wokenAlongside(said, session, io.now()))
|
|
77
|
+
continue;
|
|
54
78
|
found.push({
|
|
55
79
|
session,
|
|
56
80
|
at: each.at,
|
package/dist/pickup.js
CHANGED
|
@@ -322,7 +322,7 @@ export async function pickup(io, options, hook = { fallback: '' }) {
|
|
|
322
322
|
return 0;
|
|
323
323
|
}
|
|
324
324
|
const again = (id) => app === DEFAULT_APP || app === 'antigravity'
|
|
325
|
-
? `run \`${holdCommand(id, origin)}\` in the background`
|
|
325
|
+
? `run \`${holdCommand(id, origin, undefined, app)}\` in the background`
|
|
326
326
|
: `carry on: Pending You wakes this ${app === 'codex' ? 'thread' : 'session'} when they write back`;
|
|
327
327
|
io.out(`${[
|
|
328
328
|
headerOf(starts, fresh.length, claimed.length),
|
package/dist/presence.js
CHANGED
|
@@ -123,6 +123,7 @@ export async function readSaid(io, app) {
|
|
|
123
123
|
typeof value.at === 'number') {
|
|
124
124
|
const since = numberOr(value.since);
|
|
125
125
|
const mod = numberOr(value.mod);
|
|
126
|
+
const hook = numberOr(value.hook);
|
|
126
127
|
const fork = numberOr(value.fork);
|
|
127
128
|
const cwd = text(value.cwd);
|
|
128
129
|
const name = text(value.name);
|
|
@@ -131,6 +132,7 @@ export async function readSaid(io, app) {
|
|
|
131
132
|
at: value.at,
|
|
132
133
|
...(since !== undefined ? { since } : {}),
|
|
133
134
|
...(mod !== undefined ? { mod } : {}),
|
|
135
|
+
...(hook !== undefined ? { hook } : {}),
|
|
134
136
|
...(fork !== undefined ? { fork } : {}),
|
|
135
137
|
...(cwd ? { cwd } : {}),
|
|
136
138
|
...(name ? { name } : {}),
|
|
@@ -152,6 +154,9 @@ async function noteSaid(io, app, session, said) {
|
|
|
152
154
|
...(said.mod !== undefined || before?.mod !== undefined
|
|
153
155
|
? { mod: Math.max(said.mod ?? 0, before?.mod ?? 0) }
|
|
154
156
|
: {}),
|
|
157
|
+
...(said.hook !== undefined || before?.hook !== undefined
|
|
158
|
+
? { hook: Math.max(said.hook ?? 0, before?.hook ?? 0) }
|
|
159
|
+
: {}),
|
|
155
160
|
};
|
|
156
161
|
const now = io.now();
|
|
157
162
|
for (const [id, each] of Object.entries(sessions))
|
|
@@ -168,10 +173,12 @@ async function sendOnce(io, command) {
|
|
|
168
173
|
const cwd = presenceCwd(command.cwd, io.home);
|
|
169
174
|
const name = await nameFor(io, command);
|
|
170
175
|
const mod = command.app === 'claude-code' && command.state === 'live' && !command.transcript;
|
|
176
|
+
const hook = command.app === 'claude-code' && command.state === 'live' && Boolean(command.transcript);
|
|
171
177
|
const noted = await noteSaid(io, command.app, command.session, {
|
|
172
178
|
state: command.state,
|
|
173
179
|
at,
|
|
174
180
|
...(mod ? { mod: at } : {}),
|
|
181
|
+
...(hook ? { hook: at } : {}),
|
|
175
182
|
...(command.fork ? { fork: at } : {}),
|
|
176
183
|
...(cwd ? { cwd } : {}),
|
|
177
184
|
...(name ? { name } : {}),
|
package/dist/setup.js
CHANGED
|
@@ -40,7 +40,7 @@ export function setupOf(heard) {
|
|
|
40
40
|
}
|
|
41
41
|
export function setupCalls(app, stopFirst) {
|
|
42
42
|
const third = app === 'antigravity'
|
|
43
|
-
? '3. post_request a short test question in that testAreaId, start its hold in the background as your rules say (npx pendingyou hold with its requestId), tell your person it’s on its way, and end your turn: the hold wakes you when they answer, so don’t ask them to type anything.'
|
|
43
|
+
? '3. post_request a short test question in that testAreaId, start its hold in the background as your rules say (npx -y pendingyou hold with its requestId), tell your person it’s on its way, and end your turn: the hold wakes you when they answer, so don’t ask them to type anything.'
|
|
44
44
|
: '3. post_request a short test question in that testAreaId, tell your person it’s on its way, and end your turn: you’re woken when they answer, so don’t ask them to type anything.';
|
|
45
45
|
return `Three calls, nothing to install or approve: 1. whoami with your name.${stopFirst ? ' If it says app.setUp is true, another session did this: stop.' : ''} 2. report_setup with source ${app}, your name, skillSaved true, hears instant, and skillVersion set to whoami’s skill.latest. Its answer has a testAreaId. ${third}`;
|
|
46
46
|
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.45.
|
|
1
|
+
export const VERSION = '0.45.2';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pendingyou-wake",
|
|
3
3
|
"displayName": "Pending You",
|
|
4
|
-
"version": "2.63.
|
|
4
|
+
"version": "2.63.1",
|
|
5
5
|
"description": "Wakes Claude Code when your person answers a Pending You card it posted, even while it sits idle. Installed by `npx pendingyou init`.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "RecordPlane",
|
package/mod/README.md
CHANGED
|
@@ -4,4 +4,4 @@ The pendingyou command line’s copy of the Pending You plugin’s wake mod, for
|
|
|
4
4
|
|
|
5
5
|
In each session it learns the cards the session posts to Pending You, checks them through the session’s own Pending You connection, and starts a turn when your person answers, writes back or a fallback comes due, or hands the session a question from another of their assistants (CLI 0.14.0), even while it sits idle. It answers `npx pendingyou hold` itself, so nothing waits in the background, and shows “2 waiting on you” under the prompt, after the plugin’s name. With the Pending You plugin installed too, only one copy acts.
|
|
6
6
|
|
|
7
|
-
Generated from recordplane/pendingyou (packages/claude-plugin/src/wake) with Pending You’s guide 2.63.
|
|
7
|
+
Generated from recordplane/pendingyou (packages/claude-plugin/src/wake) with Pending You’s guide 2.63.1; send changes there.
|
package/mod/hooks/register.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated from packages/claude-plugin/src/wake/register.ts in recordplane/pendingyou: edit that, then run
|
|
2
2
|
// `pnpm --filter @pendingyou/claude-plugin generate`.
|
|
3
3
|
|
|
4
|
-
import { argumentsOf, BOOK_TOUCH_MS, blockedNote, CLAIM_PREFIX, CLAIM_RENEW_MS, CLI_COPY, cardTool, checkArgs, checked, claimedElsewhere, claimHeld, claimLapsesAt, claimLease, cliConfigOf, connectionOf, dueCards, emptyBook, failed, folderOf, graceAfter, graceEnds, HANDED_FAST_MS, HANDED_FOR_MS, HANDED_READS, HERDR_EVERY_MS, HERDR_RUN_MS, handedDue, handedNext, handedOf, handedText, handedView, herdrArgv, herdrPayload, holdOf, holdReply, inHerdr, isFresh, isRefusal, isStale, isWaitingOnYou, KEEP_MS, keepsBook, LISTEN_RUN_MS, LISTENER_KEY, learn, leaseFor, leaseHolder, listenArgv, listened, loadedNote, loadedPath, mayListen, midTurnKindOf, midTurnText, momentOf, nameKept, newerElsewhere, originOf, PRESENCE_EVERY_MS, PRESENCE_RUN_MS, presenceArgv, presenceNameOf, prompted, put, readBook, readClaim, readListener, readSetup, readSignal, readSince, readWait, resultObject, retellDue, SETUP_AFTER_MS, SETUP_RETRY_MS, SETUP_SERVER, SETUP_TRIES, SIGNAL_KEY, settle, setUpOf, setupNeeded, setupPrompt, stateOf, statusText, TICK_MS, takesHanded, told, toTell, unreadWake, untold, used, wakeText, wordsOf, } from "./wake.js";
|
|
4
|
+
import { ADOPT_AFTER_MS, adopted, argumentsOf, BOOK_TOUCH_MS, blockedNote, CLAIM_PREFIX, CLAIM_RENEW_MS, CLI_COPY, cardTool, checkArgs, checked, claimedElsewhere, claimHeld, claimLapsesAt, claimLease, cliConfigOf, connectionOf, dueCards, earlierOf, emptyBook, failed, folderOf, graceAfter, graceEnds, HANDED_FAST_MS, HANDED_FOR_MS, HANDED_READS, HERDR_EVERY_MS, HERDR_RUN_MS, handedDue, handedNext, handedOf, handedText, handedView, herdrArgv, herdrPayload, holdOf, holdReply, inHerdr, isFresh, isRefusal, isStale, isWaitingOnYou, KEEP_MS, keepsBook, LISTEN_RUN_MS, LISTENER_KEY, learn, leaseFor, leaseHolder, listenArgv, listened, loadedNote, loadedPath, mayListen, midTurnKindOf, midTurnText, momentOf, nameKept, newerElsewhere, originOf, PRESENCE_EVERY_MS, PRESENCE_RUN_MS, presenceArgv, presenceNameOf, prompted, put, readBook, readClaim, readListener, readSetup, readSignal, readSince, readWait, resultObject, retellDue, SETUP_AFTER_MS, SETUP_RETRY_MS, SETUP_SERVER, SETUP_TRIES, SIGNAL_KEY, settle, setUpOf, setupNeeded, setupPrompt, stateOf, statusText, stillQuiet, TICK_MS, takesHanded, told, toTell, unreadWake, untold, used, wakeText, wordsOf, } from "./wake.js";
|
|
5
5
|
const UNHEARD = { error: 'unavailable' };
|
|
6
6
|
const RETRY_MS = 60_000;
|
|
7
7
|
const live = {
|
|
@@ -37,6 +37,7 @@ const live = {
|
|
|
37
37
|
signalSeen: 0,
|
|
38
38
|
words: new Map(),
|
|
39
39
|
wordless: new Set(),
|
|
40
|
+
earlier: null,
|
|
40
41
|
};
|
|
41
42
|
const keyOf = (sessionId) => `session:${sessionId}`;
|
|
42
43
|
function blockedServer() {
|
|
@@ -597,12 +598,54 @@ async function startPresence($) {
|
|
|
597
598
|
await sayLive($);
|
|
598
599
|
live.presenceTimer = $.clock.every(PRESENCE_EVERY_MS, () => sayLive($));
|
|
599
600
|
}
|
|
601
|
+
async function presenceRecord($) {
|
|
602
|
+
const config = cliConfigOf($.plugin.root, $.plugin.name);
|
|
603
|
+
if (!config)
|
|
604
|
+
return null;
|
|
605
|
+
try {
|
|
606
|
+
return await $.fs.read(`${config}/presence/claude-code.json`);
|
|
607
|
+
}
|
|
608
|
+
catch {
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
async function lookEarlier($) {
|
|
613
|
+
try {
|
|
614
|
+
live.earlier = earlierOf(await presenceRecord($), live.sessionId, await $.clock.now());
|
|
615
|
+
if (live.earlier)
|
|
616
|
+
$.clock.after(ADOPT_AFTER_MS, () => adoptEarlier($));
|
|
617
|
+
}
|
|
618
|
+
catch { }
|
|
619
|
+
}
|
|
620
|
+
async function adoptEarlier($) {
|
|
621
|
+
try {
|
|
622
|
+
const earlier = live.earlier;
|
|
623
|
+
live.earlier = null;
|
|
624
|
+
if (!earlier || !live.sessionId || earlier.id === live.sessionId)
|
|
625
|
+
return;
|
|
626
|
+
if (!stillQuiet(await presenceRecord($), earlier))
|
|
627
|
+
return;
|
|
628
|
+
const kept = readBook(await $.store.get(keyOf(earlier.id)));
|
|
629
|
+
if (Object.keys(kept.cards).length === 0 && !kept.seenAt)
|
|
630
|
+
return;
|
|
631
|
+
live.book = adopted(live.book, kept);
|
|
632
|
+
if (kept.seenAt && kept.seenAt > live.seenAt) {
|
|
633
|
+
live.seenAt = kept.seenAt;
|
|
634
|
+
live.handedAt = 0;
|
|
635
|
+
}
|
|
636
|
+
await save($);
|
|
637
|
+
await $.store.delete(keyOf(earlier.id));
|
|
638
|
+
showCards($);
|
|
639
|
+
soon($);
|
|
640
|
+
}
|
|
641
|
+
catch { }
|
|
642
|
+
}
|
|
600
643
|
async function recallName($) {
|
|
601
644
|
try {
|
|
602
645
|
const config = cliConfigOf($.plugin.root, $.plugin.name);
|
|
603
646
|
if (live.book.name || live.book.fork || !config || !live.sessionId)
|
|
604
647
|
return;
|
|
605
|
-
const name = presenceNameOf(await
|
|
648
|
+
const name = presenceNameOf(await presenceRecord($), live.sessionId);
|
|
606
649
|
if (!name)
|
|
607
650
|
return;
|
|
608
651
|
const now = await $.clock.now();
|
|
@@ -623,7 +666,11 @@ async function recallName($) {
|
|
|
623
666
|
async function start($, e) {
|
|
624
667
|
live.me = $.plugin.name;
|
|
625
668
|
live.sessionId = await $.session.id();
|
|
626
|
-
|
|
669
|
+
const kept = await $.store.get(keyOf(live.sessionId));
|
|
670
|
+
live.book = readBook(kept);
|
|
671
|
+
live.earlier = null;
|
|
672
|
+
if (kept === undefined)
|
|
673
|
+
await lookEarlier($);
|
|
627
674
|
await recallName($);
|
|
628
675
|
freshHanded();
|
|
629
676
|
await folderOfSession($, e.cwd);
|
|
@@ -647,6 +694,7 @@ async function switchSession($, e) {
|
|
|
647
694
|
const carried = e.source === 'fork' ? { ...forked, fork: true } : null;
|
|
648
695
|
const was = live.sessionId;
|
|
649
696
|
live.sessionId = id;
|
|
697
|
+
live.earlier = null;
|
|
650
698
|
const held = live.held;
|
|
651
699
|
live.held = [];
|
|
652
700
|
await giveBack($, held, was);
|
package/mod/hooks/wake.js
CHANGED
|
@@ -1082,6 +1082,69 @@ export function presenceNameOf(record, sessionId) {
|
|
|
1082
1082
|
const said = sessions[sessionId];
|
|
1083
1083
|
return isObject(said) ? text(said.name, 120) : undefined;
|
|
1084
1084
|
}
|
|
1085
|
+
export const EARLIER_RECENT_MS = PRESENCE_EVERY_MS + 60_000;
|
|
1086
|
+
export const ADOPT_AFTER_MS = PRESENCE_EVERY_MS + 60_000;
|
|
1087
|
+
export const HOOK_SLACK_MS = 60_000;
|
|
1088
|
+
function presenceEntry(sessions, id) {
|
|
1089
|
+
if (!Object.hasOwn(sessions, id))
|
|
1090
|
+
return null;
|
|
1091
|
+
const said = sessions[id];
|
|
1092
|
+
if (!isObject(said))
|
|
1093
|
+
return null;
|
|
1094
|
+
return {
|
|
1095
|
+
state: said.state,
|
|
1096
|
+
at: count(said.at),
|
|
1097
|
+
since: count(said.since),
|
|
1098
|
+
mod: count(said.mod),
|
|
1099
|
+
hook: count(said.hook),
|
|
1100
|
+
cwd: text(said.cwd, 400),
|
|
1101
|
+
name: text(said.name, 120),
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
const sessionsOf = (record) => {
|
|
1105
|
+
const parsed = typeof record === 'string' ? parseJson(record) : record;
|
|
1106
|
+
return isObject(parsed) && isObject(parsed.sessions) ? parsed.sessions : null;
|
|
1107
|
+
};
|
|
1108
|
+
export function earlierOf(record, me, now) {
|
|
1109
|
+
const sessions = sessionsOf(record);
|
|
1110
|
+
const mine = sessions ? presenceEntry(sessions, me) : null;
|
|
1111
|
+
if (!sessions || !mine?.name || !mine.cwd || mine.since === undefined)
|
|
1112
|
+
return null;
|
|
1113
|
+
const since = mine.since;
|
|
1114
|
+
const found = [];
|
|
1115
|
+
for (const id of Object.keys(sessions)) {
|
|
1116
|
+
if (id === me)
|
|
1117
|
+
continue;
|
|
1118
|
+
const other = presenceEntry(sessions, id);
|
|
1119
|
+
if (other?.state !== 'live' || other.at === undefined)
|
|
1120
|
+
continue;
|
|
1121
|
+
if (other.name !== mine.name || other.cwd !== mine.cwd)
|
|
1122
|
+
continue;
|
|
1123
|
+
if (other.since === undefined || other.since >= since)
|
|
1124
|
+
continue;
|
|
1125
|
+
if (other.mod === undefined || other.mod <= since || now - other.mod > EARLIER_RECENT_MS)
|
|
1126
|
+
continue;
|
|
1127
|
+
if (other.hook !== undefined && other.hook > since + HOOK_SLACK_MS)
|
|
1128
|
+
continue;
|
|
1129
|
+
found.push({ id, at: other.at });
|
|
1130
|
+
}
|
|
1131
|
+
return found.length === 1 ? (found[0] ?? null) : null;
|
|
1132
|
+
}
|
|
1133
|
+
export function stillQuiet(record, earlier) {
|
|
1134
|
+
const sessions = sessionsOf(record);
|
|
1135
|
+
const now = sessions ? presenceEntry(sessions, earlier.id) : null;
|
|
1136
|
+
return now?.state === 'live' && now.at === earlier.at;
|
|
1137
|
+
}
|
|
1138
|
+
export function adopted(own, earlier) {
|
|
1139
|
+
const seenAt = Math.max(own.seenAt ?? 0, earlier.seenAt ?? 0);
|
|
1140
|
+
return {
|
|
1141
|
+
...own,
|
|
1142
|
+
...(own.name || !earlier.name ? {} : { name: earlier.name }),
|
|
1143
|
+
...(own.server || !earlier.server ? {} : { server: earlier.server }),
|
|
1144
|
+
...(seenAt ? { seenAt } : {}),
|
|
1145
|
+
cards: { ...earlier.cards, ...own.cards },
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1085
1148
|
export function presenceArgv(config, origin, session) {
|
|
1086
1149
|
return [
|
|
1087
1150
|
`${config}/bin/pendingyou-hook`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pendingyou",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.2",
|
|
4
4
|
"description": "Pending You for your coding agents: one command sets up Claude Code, Codex, OpenCode, Pi and Antigravity to ask you through Pending You and hear your answers, even while they sit idle.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pendingyou",
|