pendingyou 0.45.1 → 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 CHANGED
@@ -1,5 +1,21 @@
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
+
3
19
  ## 0.45.1 (2026-11-19)
4
20
 
5
21
  Found by the first live run of Antigravity.
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 latest = (await readSaid(io, 'claude-code').catch(() => ({})))[session];
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/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/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.45.1';
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.0",
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.0; send changes there.
7
+ Generated from recordplane/pendingyou (packages/claude-plugin/src/wake) with Pending You’s guide 2.63.1; send changes there.
@@ -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 $.fs.read(`${config}/presence/claude-code.json`), live.sessionId);
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
- live.book = readBook(await $.store.get(keyOf(live.sessionId)));
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.1",
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",