pendingyou 0.43.1 → 0.43.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/CHANGELOG.md +68 -0
- package/dist/apps/codex-midturn.js +164 -0
- package/dist/apps/codex-wake.js +106 -13
- package/dist/apps/codex.js +9 -1
- package/dist/apps/opencode-plugin.js +11 -5
- package/dist/apps/pi-extension.js +9 -5
- package/dist/args.js +6 -0
- package/dist/drafter/claude-code.js +119 -0
- package/dist/drafter/config.js +35 -0
- package/dist/drafter/eval.js +188 -0
- package/dist/drafter/own-messages.js +18 -0
- package/dist/drafter/prompt.js +124 -0
- package/dist/drafter/tiers.js +106 -0
- package/dist/drafter/types.js +10 -0
- package/dist/drafter/validate.js +240 -0
- package/dist/format.js +1 -1
- package/dist/handed.js +4 -1
- package/dist/io.js +6 -1
- package/dist/main.js +4 -0
- package/dist/midturn.js +54 -0
- package/dist/permission.js +11 -2
- package/dist/pickup.js +12 -2
- package/dist/presence.js +18 -3
- package/dist/setup.js +8 -2
- package/dist/stopcheck.js +16 -0
- 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 +254 -15
- package/mod/hooks/wake.js +167 -7
- package/package.json +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { BLANK, isSecretName, looksLikeToken, redactTokens } from "../redact.js";
|
|
2
|
+
import { cutTo } from "./prompt.js";
|
|
3
|
+
const STOP = new Set([
|
|
4
|
+
'the',
|
|
5
|
+
'and',
|
|
6
|
+
'for',
|
|
7
|
+
'with',
|
|
8
|
+
'that',
|
|
9
|
+
'this',
|
|
10
|
+
'from',
|
|
11
|
+
'into',
|
|
12
|
+
'your',
|
|
13
|
+
'you',
|
|
14
|
+
'are',
|
|
15
|
+
'was',
|
|
16
|
+
'its',
|
|
17
|
+
'it’s',
|
|
18
|
+
"it's",
|
|
19
|
+
'not',
|
|
20
|
+
'but',
|
|
21
|
+
'now',
|
|
22
|
+
'then',
|
|
23
|
+
]);
|
|
24
|
+
const plain = (text) => text
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.replace(/[“”"‘’'`*_]/g, '')
|
|
27
|
+
.replace(/\s+/g, ' ')
|
|
28
|
+
.trim();
|
|
29
|
+
const words = (text) => plain(text)
|
|
30
|
+
.split(/[^\p{L}\p{N}#./-]+/u)
|
|
31
|
+
.map((word) => word.replace(/^[./-]+|[./-]+$/g, ''))
|
|
32
|
+
.filter((word) => word.length >= 3 && !STOP.has(word));
|
|
33
|
+
export function grounded(label, message) {
|
|
34
|
+
const said = new Set(words(message));
|
|
35
|
+
const own = words(label);
|
|
36
|
+
if (own.length === 0)
|
|
37
|
+
return plain(message).includes(plain(label)) && plain(label) !== '';
|
|
38
|
+
const found = own.filter((word) => said.has(word)).length;
|
|
39
|
+
return own.length <= 2 ? found === own.length : found / own.length >= 0.8;
|
|
40
|
+
}
|
|
41
|
+
export function sameAsk(a, b) {
|
|
42
|
+
const left = new Set(words(a));
|
|
43
|
+
const right = new Set(words(b));
|
|
44
|
+
const [short, long] = left.size <= right.size ? [left, right] : [right, left];
|
|
45
|
+
if (short.size < 3)
|
|
46
|
+
return [...short].every((word) => long.has(word)) && short.size === long.size;
|
|
47
|
+
const shared = [...short].filter((word) => long.has(word)).length;
|
|
48
|
+
return shared / short.size >= 0.7;
|
|
49
|
+
}
|
|
50
|
+
const RECOMMENDS = /\b(?:i(?:'|’)d|i would|i(?:'|’)m leaning|i lean|i recommend|recommend(?:ed|ation)?|suggest(?:ed|ion)?|my (?:pick|vote|choice)|i prefer|go with|best bet)\b/i;
|
|
51
|
+
export const stepIn = (step, message) => plain(step).length > 0 && plain(message).includes(plain(step));
|
|
52
|
+
const URL = /\bhttps?:\/\/[^\s<>()\]"'`]+/g;
|
|
53
|
+
export function safeLink(url) {
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = new globalThis.URL(url);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
parsed.username = '';
|
|
62
|
+
parsed.password = '';
|
|
63
|
+
for (const [name, value] of [...parsed.searchParams])
|
|
64
|
+
if (isSecretName(name) || looksLikeToken(value))
|
|
65
|
+
parsed.searchParams.set(name, BLANK);
|
|
66
|
+
return parsed.toString();
|
|
67
|
+
}
|
|
68
|
+
export function linksOf(message) {
|
|
69
|
+
const found = [];
|
|
70
|
+
for (const match of message.matchAll(URL)) {
|
|
71
|
+
const url = safeLink(match[0].replace(/[.,;:!?]+$/, ''));
|
|
72
|
+
if (url && !found.includes(url))
|
|
73
|
+
found.push(url);
|
|
74
|
+
}
|
|
75
|
+
return found;
|
|
76
|
+
}
|
|
77
|
+
function onlyTheirLinks(text, message, broken) {
|
|
78
|
+
return text.replace(URL, (url) => {
|
|
79
|
+
if (message.includes(url.replace(/[.,;:!?]+$/, '')))
|
|
80
|
+
return url;
|
|
81
|
+
broken.add('url');
|
|
82
|
+
return '';
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const tidy = (text, max, message, broken) => cutTo(redactTokens(onlyTheirLinks(text, message, broken))
|
|
86
|
+
.replace(/\s+/g, ' ')
|
|
87
|
+
.trim(), max);
|
|
88
|
+
function checkOptions(options, recommended, message, broken) {
|
|
89
|
+
const kept = options.filter((option) => {
|
|
90
|
+
if (grounded(option.label, message))
|
|
91
|
+
return true;
|
|
92
|
+
broken.add('option');
|
|
93
|
+
return false;
|
|
94
|
+
});
|
|
95
|
+
const enough = kept.length >= 2 ? kept : [];
|
|
96
|
+
let pick = recommended && enough.some((option) => option.label === recommended) ? recommended : null;
|
|
97
|
+
if (recommended && !pick)
|
|
98
|
+
broken.add('recommended');
|
|
99
|
+
if (pick && !RECOMMENDS.test(message)) {
|
|
100
|
+
broken.add('recommended');
|
|
101
|
+
pick = null;
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
options: enough.map((option) => ({ label: cutTo(option.label, 80) })),
|
|
105
|
+
recommended: pick,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function checkCard(card, message, broken) {
|
|
109
|
+
const steps = card.steps.filter((step) => {
|
|
110
|
+
if (stepIn(step, message))
|
|
111
|
+
return true;
|
|
112
|
+
broken.add('step');
|
|
113
|
+
return false;
|
|
114
|
+
});
|
|
115
|
+
const base = {
|
|
116
|
+
title: tidy(card.title, 90, message, broken),
|
|
117
|
+
summary: tidy(card.summary, 400, message, broken),
|
|
118
|
+
steps,
|
|
119
|
+
};
|
|
120
|
+
const questions = card.questions
|
|
121
|
+
.map((question) => ({
|
|
122
|
+
id: question.id.replace(/[^A-Za-z0-9_-]/g, '').slice(0, 40) || 'q',
|
|
123
|
+
title: tidy(question.title, 140, message, broken),
|
|
124
|
+
...checkOptions(question.options, question.recommended, message, broken),
|
|
125
|
+
}))
|
|
126
|
+
.filter((question) => question.title);
|
|
127
|
+
if (card.questions.length === 1 || card.questions.length > 4)
|
|
128
|
+
broken.add('grouped');
|
|
129
|
+
if (questions.length >= 2 && questions.length <= 4)
|
|
130
|
+
return [{ ...base, options: [], recommended: null, questions }];
|
|
131
|
+
if (questions.length === 1) {
|
|
132
|
+
const [only] = questions;
|
|
133
|
+
return [
|
|
134
|
+
{
|
|
135
|
+
...base,
|
|
136
|
+
title: only.title || base.title,
|
|
137
|
+
options: only.options,
|
|
138
|
+
recommended: only.recommended,
|
|
139
|
+
questions: [],
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
return [
|
|
144
|
+
{ ...base, ...checkOptions(card.options, card.recommended, message, broken), questions: [] },
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
export function check(verdict, input) {
|
|
148
|
+
const message = input.final;
|
|
149
|
+
const broken = new Set();
|
|
150
|
+
const open = new Set(input.openCards.map((card) => card.requestId));
|
|
151
|
+
const settles = verdict.settles.filter((id) => {
|
|
152
|
+
if (open.has(id))
|
|
153
|
+
return true;
|
|
154
|
+
broken.add('settles');
|
|
155
|
+
return false;
|
|
156
|
+
});
|
|
157
|
+
let kind = verdict.kind;
|
|
158
|
+
let also = verdict.also;
|
|
159
|
+
if (input.promptKind !== 'person') {
|
|
160
|
+
if (kind === 'answer') {
|
|
161
|
+
broken.add('answer-from-agent');
|
|
162
|
+
kind = also ?? 'none';
|
|
163
|
+
also = null;
|
|
164
|
+
}
|
|
165
|
+
else if (also === 'answer') {
|
|
166
|
+
broken.add('answer-from-agent');
|
|
167
|
+
also = null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const asks = [kind, also].some((each) => each === 'question' || each === 'step');
|
|
171
|
+
const cards = !asks || verdict.covered
|
|
172
|
+
? []
|
|
173
|
+
: verdict.cards.flatMap((card) => checkCard(card, message, broken)).slice(0, 3);
|
|
174
|
+
const up = [...input.turnCards, ...input.openCards.map((card) => card.title)];
|
|
175
|
+
const fresh = cards.filter((card) => card.title && !up.some((title) => sameAsk(card.title, title)));
|
|
176
|
+
const duplicates = cards.filter((card) => card.title).length - fresh.length;
|
|
177
|
+
return {
|
|
178
|
+
verdict: {
|
|
179
|
+
...verdict,
|
|
180
|
+
covered: verdict.covered || (duplicates > 0 && fresh.length === 0),
|
|
181
|
+
kind,
|
|
182
|
+
also,
|
|
183
|
+
settles,
|
|
184
|
+
answerTitle: tidy(verdict.answerTitle, 90, message, broken),
|
|
185
|
+
outcome: tidy(verdict.outcome, 200, message, broken),
|
|
186
|
+
},
|
|
187
|
+
cards: fresh,
|
|
188
|
+
duplicates,
|
|
189
|
+
links: linksOf(message),
|
|
190
|
+
broken: [...broken],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export function isVerdict(value) {
|
|
194
|
+
if (typeof value !== 'object' || value === null)
|
|
195
|
+
return false;
|
|
196
|
+
const v = value;
|
|
197
|
+
const kinds = ['question', 'step', 'answer', 'none'];
|
|
198
|
+
const list = (item) => Array.isArray(item);
|
|
199
|
+
const options = (item) => list(item) &&
|
|
200
|
+
item.every((option) => typeof option === 'object' &&
|
|
201
|
+
option !== null &&
|
|
202
|
+
typeof option.label === 'string');
|
|
203
|
+
const pick = (item) => item === null || typeof item === 'string';
|
|
204
|
+
const cardOk = (card) => {
|
|
205
|
+
if (typeof card !== 'object' || card === null)
|
|
206
|
+
return false;
|
|
207
|
+
const c = card;
|
|
208
|
+
return (typeof c.title === 'string' &&
|
|
209
|
+
typeof c.summary === 'string' &&
|
|
210
|
+
options(c.options) &&
|
|
211
|
+
pick(c.recommended) &&
|
|
212
|
+
list(c.questions) &&
|
|
213
|
+
c.questions.every((question) => {
|
|
214
|
+
if (typeof question !== 'object' || question === null)
|
|
215
|
+
return false;
|
|
216
|
+
const q = question;
|
|
217
|
+
return (typeof q.id === 'string' &&
|
|
218
|
+
typeof q.title === 'string' &&
|
|
219
|
+
options(q.options) &&
|
|
220
|
+
pick(q.recommended));
|
|
221
|
+
}) &&
|
|
222
|
+
list(c.steps) &&
|
|
223
|
+
c.steps.every((step) => typeof step === 'string'));
|
|
224
|
+
};
|
|
225
|
+
return (kinds.includes(v.kind) &&
|
|
226
|
+
(v.also === null || (kinds.includes(v.also) && v.also !== 'none')) &&
|
|
227
|
+
typeof v.confidence === 'number' &&
|
|
228
|
+
v.confidence >= 0 &&
|
|
229
|
+
v.confidence <= 1 &&
|
|
230
|
+
typeof v.covered === 'boolean' &&
|
|
231
|
+
(v.stakes === 'normal' || v.stakes === 'high') &&
|
|
232
|
+
typeof v.inTheirName === 'boolean' &&
|
|
233
|
+
typeof v.shows === 'boolean' &&
|
|
234
|
+
list(v.cards) &&
|
|
235
|
+
v.cards.every(cardOk) &&
|
|
236
|
+
typeof v.answerTitle === 'string' &&
|
|
237
|
+
list(v.settles) &&
|
|
238
|
+
v.settles.every((id) => typeof id === 'string') &&
|
|
239
|
+
typeof v.outcome === 'string');
|
|
240
|
+
}
|
package/dist/format.js
CHANGED
|
@@ -25,7 +25,7 @@ export const HANDED_REPLY = 'on the question handed to you';
|
|
|
25
25
|
export const HANDED_TALK_TODO = 'If you know now, answer_delegated with your answer and how you know; if you need more, reply_in_thread to “asker”; if it’s your person’s to decide, reply_in_thread with escalate true; if not, hand_back with what you checked.';
|
|
26
26
|
export function isHandedWake(text) {
|
|
27
27
|
const first = text.trimStart().split('\n')[0] ?? '';
|
|
28
|
-
return (first.startsWith(HANDED_PREFIX) ||
|
|
28
|
+
return (first.startsWith(`${HANDED_PREFIX} `) ||
|
|
29
29
|
(first.startsWith('Pending You: ') && first.includes(` ${HANDED_REPLY}, `)));
|
|
30
30
|
}
|
|
31
31
|
export function latestTalk(heard, from) {
|
package/dist/handed.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clip, HANDED_PREFIX, HANDED_REPLY, HANDED_TALK_TODO, HANDED_TODO, latestTalk, modeWords, } from "./format.js";
|
|
2
2
|
export const HANDED_FOR_MS = 12 * 60 * 60_000;
|
|
3
|
+
export const OPEN_FOR_MS = 15 * 60_000;
|
|
3
4
|
export const HANDED_GRACE_MS = 5 * 60_000;
|
|
4
5
|
const TITLE_CHARS = 80;
|
|
5
6
|
const NAME_CHARS = 60;
|
|
@@ -21,7 +22,9 @@ export function inFolder(session, task, home) {
|
|
|
21
22
|
const there = folderKey(task, home);
|
|
22
23
|
return here === there || here.startsWith(there === '/' ? '/' : `${there}/`);
|
|
23
24
|
}
|
|
24
|
-
const latest = (list) => [...list].sort((a, b) => b.
|
|
25
|
+
const latest = (list) => [...list].sort((a, b) => Number(b.open === true) - Number(a.open === true) ||
|
|
26
|
+
b.at - a.at ||
|
|
27
|
+
a.thread.localeCompare(b.thread))[0]?.thread ?? null;
|
|
25
28
|
export function chooseThread(heard, sessions, options) {
|
|
26
29
|
const live = sessions.filter((session) => session.live);
|
|
27
30
|
const here = (session) => heard.cwd === undefined || inFolder(session.cwd, heard.cwd, options.home);
|
package/dist/io.js
CHANGED
|
@@ -8,9 +8,10 @@ export function runProgram(command, args, timeoutMs = 60_000, options = {}) {
|
|
|
8
8
|
let child;
|
|
9
9
|
try {
|
|
10
10
|
child = spawn(command, [...args], {
|
|
11
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
11
|
+
stdio: [options.stdin === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'],
|
|
12
12
|
windowsHide: true,
|
|
13
13
|
...(options.env ? { env: options.env } : {}),
|
|
14
|
+
...(options.cwd ? { cwd: options.cwd } : {}),
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
catch {
|
|
@@ -34,6 +35,10 @@ export function runProgram(command, args, timeoutMs = 60_000, options = {}) {
|
|
|
34
35
|
});
|
|
35
36
|
child.on('error', (error) => done(error.code === 'ENOENT' ? 127 : 1));
|
|
36
37
|
child.on('close', (code) => done(code ?? 1));
|
|
38
|
+
if (options.stdin !== undefined) {
|
|
39
|
+
child.stdin?.on('error', () => { });
|
|
40
|
+
child.stdin?.end(options.stdin);
|
|
41
|
+
}
|
|
37
42
|
});
|
|
38
43
|
}
|
|
39
44
|
export function execProgram(command, args, options) {
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HOOK_DEADLINE_MS, refreshInBackground, SignInNeeded, Unavailable } from "./api.js";
|
|
2
2
|
import { setAnswerWait } from "./apps/codex.js";
|
|
3
|
+
import { heardHook } from "./apps/codex-midturn.js";
|
|
3
4
|
import { listen, listenHanded, posted } from "./apps/codex-wake.js";
|
|
4
5
|
import { DEFAULT_APP } from "./apps/ids.js";
|
|
5
6
|
import { appModule } from "./apps/registry.js";
|
|
@@ -52,6 +53,8 @@ async function run(io, command, hook = { fallback: '' }) {
|
|
|
52
53
|
case 'posted':
|
|
53
54
|
case 'named':
|
|
54
55
|
return posted(io, { origin: command.origin, app: command.app ?? DEFAULT_APP });
|
|
56
|
+
case 'heard':
|
|
57
|
+
return heardHook(io);
|
|
55
58
|
case 'permission':
|
|
56
59
|
case 'permission-done':
|
|
57
60
|
case 'notify': {
|
|
@@ -70,6 +73,7 @@ async function run(io, command, hook = { fallback: '' }) {
|
|
|
70
73
|
...(command.agentName ? { name: command.agentName } : {}),
|
|
71
74
|
...(command.transcript ? { transcript: command.transcript } : {}),
|
|
72
75
|
...(command.keep ? { keep: true } : {}),
|
|
76
|
+
...(command.fork ? { fork: true } : {}),
|
|
73
77
|
...(command.pid ? { pid: command.pid } : {}),
|
|
74
78
|
...(command.at ? { at: command.at } : {}),
|
|
75
79
|
});
|
package/dist/midturn.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const MID_TURN_TITLE_CHARS = 60;
|
|
2
|
+
export const MID_TURN_SHOWN = 3;
|
|
3
|
+
function midTitle(title) {
|
|
4
|
+
const flat = title.replace(/\s+/g, ' ').trim().replaceAll('“', '‘').replaceAll('”', '’');
|
|
5
|
+
const chars = [...flat];
|
|
6
|
+
return chars.length <= MID_TURN_TITLE_CHARS
|
|
7
|
+
? flat
|
|
8
|
+
: `${chars
|
|
9
|
+
.slice(0, MID_TURN_TITLE_CHARS - 1)
|
|
10
|
+
.join('')
|
|
11
|
+
.trimEnd()}…`;
|
|
12
|
+
}
|
|
13
|
+
function midPhrase(item) {
|
|
14
|
+
const titled = `“${midTitle(item.title)}” (${item.requestId})`;
|
|
15
|
+
switch (item.kind) {
|
|
16
|
+
case 'answered':
|
|
17
|
+
return `your person answered ${titled}`;
|
|
18
|
+
case 'wrote':
|
|
19
|
+
return `your person wrote to you on ${titled}`;
|
|
20
|
+
case 'replied':
|
|
21
|
+
return `your person replied to your answer ${titled}`;
|
|
22
|
+
case 'word':
|
|
23
|
+
return `there’s word on ${titled}`;
|
|
24
|
+
case 'fallback':
|
|
25
|
+
return `nobody answered ${titled} in time, so its fallback is due`;
|
|
26
|
+
case 'withdrawn':
|
|
27
|
+
return `${titled} was withdrawn`;
|
|
28
|
+
case 'handed':
|
|
29
|
+
return `your person handed you ${titled}`;
|
|
30
|
+
case 'handed-reply':
|
|
31
|
+
return `there’s a reply on the question handed to you, ${titled}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const midRead = (item) => `get_request${item.name ? ` (name “${item.name}”)` : ''}`;
|
|
35
|
+
export function midTurnText(items) {
|
|
36
|
+
if (items.length === 0)
|
|
37
|
+
return null;
|
|
38
|
+
if (items.length === 1) {
|
|
39
|
+
const item = items[0];
|
|
40
|
+
if (item.kind === 'withdrawn')
|
|
41
|
+
return `Pending You, while you were working: ${midPhrase(item)}. Nothing to do.`;
|
|
42
|
+
return `Pending You, while you were working: ${midPhrase(item)}. Read it now with ${midRead(item)}, and act on it at the next sensible point in this task.`;
|
|
43
|
+
}
|
|
44
|
+
const shown = items.slice(0, MID_TURN_SHOWN);
|
|
45
|
+
const more = items.length - shown.length;
|
|
46
|
+
return [
|
|
47
|
+
'Pending You, while you were working:',
|
|
48
|
+
...shown.map((item) => item.kind === 'withdrawn'
|
|
49
|
+
? `- ${midPhrase(item)}: nothing to do.`
|
|
50
|
+
: `- ${midPhrase(item)}: ${midRead(item)}.`),
|
|
51
|
+
...(more > 0 ? [`- and ${more} more: list_pending with your name.`] : []),
|
|
52
|
+
'Read each now, and act on them at the next sensible point in this task.',
|
|
53
|
+
].join('\n');
|
|
54
|
+
}
|
package/dist/permission.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
2
|
import { open, readdir, rm, stat } from 'node:fs/promises';
|
|
3
3
|
import { basename, dirname, join } from 'node:path';
|
|
4
|
+
import { tellHeard } from "./apps/codex-midturn.js";
|
|
4
5
|
import { threadNames } from "./apps/codex-wake.js";
|
|
5
6
|
import { APP_NAMES } from "./apps/ids.js";
|
|
6
7
|
import { DEFAULT_ORIGIN } from "./args.js";
|
|
@@ -477,9 +478,15 @@ export async function permissionHook(io, options) {
|
|
|
477
478
|
await asked(io, options.origin, input, app);
|
|
478
479
|
break;
|
|
479
480
|
case 'PostToolUse':
|
|
480
|
-
case 'PostToolUseFailure':
|
|
481
|
+
case 'PostToolUseFailure': {
|
|
481
482
|
await ran(io, input, app);
|
|
483
|
+
if (app === 'codex' && input.hook_event_name === 'PostToolUse') {
|
|
484
|
+
const told = await tellHeard(io, input);
|
|
485
|
+
if (told)
|
|
486
|
+
io.out(told);
|
|
487
|
+
}
|
|
482
488
|
break;
|
|
489
|
+
}
|
|
483
490
|
case 'Notification':
|
|
484
491
|
if (app === CLAUDE)
|
|
485
492
|
await notified(io, options.origin, input);
|
|
@@ -559,7 +566,7 @@ export async function computerOf(io, origin, app) {
|
|
|
559
566
|
return cut(named ?? (machineOf(io.host) || 'this computer'), 60);
|
|
560
567
|
}
|
|
561
568
|
const tilde = (io, path) => shortPath(path, io.home, 200);
|
|
562
|
-
export async function sessionName(path) {
|
|
569
|
+
export async function sessionName(path, after) {
|
|
563
570
|
if (!path)
|
|
564
571
|
return null;
|
|
565
572
|
let file;
|
|
@@ -585,6 +592,8 @@ export async function sessionName(path) {
|
|
|
585
592
|
}
|
|
586
593
|
if (!isObject(entry) || entry.type !== 'assistant' || entry.isSidechain === true)
|
|
587
594
|
return null;
|
|
595
|
+
if (after !== undefined && !(Date.parse(text(entry.timestamp)) >= after))
|
|
596
|
+
return null;
|
|
588
597
|
const message = isObject(entry.message) ? entry.message : {};
|
|
589
598
|
const blocks = Array.isArray(message.content) ? message.content : [];
|
|
590
599
|
for (const block of [...blocks].reverse()) {
|
package/dist/pickup.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getJson, postJson, SignInNeeded, Unavailable } from "./api.js";
|
|
2
|
+
import { turnBegan } from "./apps/codex-midturn.js";
|
|
2
3
|
import { computerNames, hearsOnly, keepListening, markAskedTurn, markHandedTurn, sessionFor, threadAnsweredAt, threadCards, threadNames, touchThread, } from "./apps/codex-wake.js";
|
|
3
4
|
import { APP_NAMES, DEFAULT_APP } from "./apps/ids.js";
|
|
4
5
|
import { asksQuestion, ownWords } from "./asked.js";
|
|
@@ -23,7 +24,7 @@ export const READ_FOR_MS = 24 * 60 * 60_000;
|
|
|
23
24
|
export const ANSWERS_ASKED = 20;
|
|
24
25
|
export const ANSWERS_SHOWN = 5;
|
|
25
26
|
export const REMINDER = 'Pending You: anything you need from your person also goes on a card.';
|
|
26
|
-
export const UNCHECKED = "Pending You couldn't check for answers just now: call list_pending before you go on.";
|
|
27
|
+
export const UNCHECKED = "Pending You couldn't check for answers just now: call list_pending with your name before you go on.";
|
|
27
28
|
export const OPEN_SHOWN = 3;
|
|
28
29
|
export const OPEN_TITLE = 50;
|
|
29
30
|
export const OPEN_NAME = 24;
|
|
@@ -186,6 +187,12 @@ export async function pickup(io, options, hook = { fallback: '' }) {
|
|
|
186
187
|
const known = mode === 'handoff' && app === DEFAULT_APP && input.session
|
|
187
188
|
? (await readSaid(io, app).catch(() => ({})))[input.session]
|
|
188
189
|
: undefined;
|
|
190
|
+
const branchedAt = app === DEFAULT_APP && input.session
|
|
191
|
+
? input.source === 'fork'
|
|
192
|
+
? io.now()
|
|
193
|
+
: (known ??
|
|
194
|
+
(await readSaid(io, app).catch(() => ({})))[input.session])?.fork
|
|
195
|
+
: undefined;
|
|
189
196
|
if (app === 'codex')
|
|
190
197
|
await keepPresent(io, origin, input.session, input.given ? cwd : null);
|
|
191
198
|
else if (app === DEFAULT_APP && (mode === 'pickup' || input.session))
|
|
@@ -195,6 +202,7 @@ export async function pickup(io, options, hook = { fallback: '' }) {
|
|
|
195
202
|
cwd: input.given ? cwd : null,
|
|
196
203
|
transcript: input.transcript,
|
|
197
204
|
again: mode === 'handoff',
|
|
205
|
+
...(input.source === 'fork' ? { fork: true } : {}),
|
|
198
206
|
});
|
|
199
207
|
if (app === DEFAULT_APP && mode === 'pickup' && input.session && (await herdrTarget(io)))
|
|
200
208
|
io.background(reportCommand(app, {
|
|
@@ -221,10 +229,12 @@ export async function pickup(io, options, hook = { fallback: '' }) {
|
|
|
221
229
|
else if (app === 'codex' && mode === 'handoff' && input.turn && asksQuestion(input.prompt))
|
|
222
230
|
await markAskedTurn(io, input.turn, app).catch(() => { });
|
|
223
231
|
}
|
|
232
|
+
if (app === 'codex' && mode === 'handoff' && input.session)
|
|
233
|
+
await turnBegan(io, input.session, input.turn ?? null);
|
|
224
234
|
if (app === 'codex' && input.session)
|
|
225
235
|
await keepListening(io, origin, input.session);
|
|
226
236
|
const claudeNames = app === DEFAULT_APP
|
|
227
|
-
? sessionName(input.transcript ?? undefined).then((name) =>
|
|
237
|
+
? sessionName(input.transcript ?? undefined, branchedAt).then((name) => name ? [name] : [])
|
|
228
238
|
: null;
|
|
229
239
|
const named = claudeNames ? (await claudeNames)[0] : undefined;
|
|
230
240
|
const asker = await askerOf(io, origin, app, {
|
package/dist/presence.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto';
|
|
|
2
2
|
import { mkdir, readdir, readFile, rm, rmdir, stat, utimes, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { postJson, SignInNeeded } from "./api.js";
|
|
5
|
-
import { reportThreads, threadNames } from "./apps/codex-wake.js";
|
|
5
|
+
import { keepListening, markOpen, reportThreads, threadNames } from "./apps/codex-wake.js";
|
|
6
6
|
import { DEFAULT_ORIGIN } from "./args.js";
|
|
7
7
|
import { readCredential } from "./credentials.js";
|
|
8
8
|
import { configDir, readJson, withLock, writeWhole } from "./files.js";
|
|
@@ -41,8 +41,14 @@ async function nameFor(io, command) {
|
|
|
41
41
|
const given = presenceName(command.name);
|
|
42
42
|
if (given)
|
|
43
43
|
return given;
|
|
44
|
-
if (command.app === 'claude-code')
|
|
45
|
-
|
|
44
|
+
if (command.app === 'claude-code') {
|
|
45
|
+
const branched = command.fork
|
|
46
|
+
? (command.at ?? io.now())
|
|
47
|
+
: command.session
|
|
48
|
+
? (await readSaid(io, command.app))[command.session]?.fork
|
|
49
|
+
: undefined;
|
|
50
|
+
return (await sessionName(command.transcript, branched)) ?? null;
|
|
51
|
+
}
|
|
46
52
|
if (!command.session)
|
|
47
53
|
return null;
|
|
48
54
|
const names = await threadNames(io, command.app, command.session).catch(() => []);
|
|
@@ -112,6 +118,7 @@ export async function readSaid(io, app) {
|
|
|
112
118
|
typeof value.at === 'number') {
|
|
113
119
|
const since = numberOr(value.since);
|
|
114
120
|
const mod = numberOr(value.mod);
|
|
121
|
+
const fork = numberOr(value.fork);
|
|
115
122
|
const cwd = text(value.cwd);
|
|
116
123
|
const name = text(value.name);
|
|
117
124
|
sessions[id] = {
|
|
@@ -119,6 +126,7 @@ export async function readSaid(io, app) {
|
|
|
119
126
|
at: value.at,
|
|
120
127
|
...(since !== undefined ? { since } : {}),
|
|
121
128
|
...(mod !== undefined ? { mod } : {}),
|
|
129
|
+
...(fork !== undefined ? { fork } : {}),
|
|
122
130
|
...(cwd ? { cwd } : {}),
|
|
123
131
|
...(name ? { name } : {}),
|
|
124
132
|
};
|
|
@@ -159,11 +167,14 @@ async function sendOnce(io, command) {
|
|
|
159
167
|
state: command.state,
|
|
160
168
|
at,
|
|
161
169
|
...(mod ? { mod: at } : {}),
|
|
170
|
+
...(command.fork ? { fork: at } : {}),
|
|
162
171
|
...(cwd ? { cwd } : {}),
|
|
163
172
|
...(name ? { name } : {}),
|
|
164
173
|
});
|
|
165
174
|
if (noted.newer)
|
|
166
175
|
return null;
|
|
176
|
+
if (command.app !== 'claude-code')
|
|
177
|
+
await markOpen(io, command.app, command.session, command.state, at);
|
|
167
178
|
if (command.state === 'live' &&
|
|
168
179
|
noted.before?.state === 'closed' &&
|
|
169
180
|
at - noted.before.at < REOPEN_MS)
|
|
@@ -190,6 +201,7 @@ export function presenceArgs(origin, app, fields) {
|
|
|
190
201
|
...(fields.name ? ['--name', fields.name] : []),
|
|
191
202
|
...(fields.transcript ? ['--transcript', fields.transcript] : []),
|
|
192
203
|
...(fields.keep ? ['--keep'] : []),
|
|
204
|
+
...(fields.fork ? ['--fork'] : []),
|
|
193
205
|
...(fields.pid ? ['--pid', String(fields.pid)] : []),
|
|
194
206
|
...(fields.at ? ['--at', String(fields.at)] : []),
|
|
195
207
|
...(origin === DEFAULT_ORIGIN ? [] : ['--origin', origin]),
|
|
@@ -213,6 +225,7 @@ export async function announce(io, origin, app, fields) {
|
|
|
213
225
|
session,
|
|
214
226
|
...(fields.cwd ? { cwd: fields.cwd } : {}),
|
|
215
227
|
...(fields.transcript ? { transcript: fields.transcript } : {}),
|
|
228
|
+
...(fields.fork ? { fork: true } : {}),
|
|
216
229
|
at: io.now(),
|
|
217
230
|
}));
|
|
218
231
|
}
|
|
@@ -318,6 +331,8 @@ async function keep(io, command) {
|
|
|
318
331
|
const outcome = await sendOnce(io, { ...command, state: 'live', at: io.now() });
|
|
319
332
|
if (outcome && GIVE_UP.has(outcome))
|
|
320
333
|
speaking = false;
|
|
334
|
+
else
|
|
335
|
+
await keepListening(io, command.origin, session);
|
|
321
336
|
}
|
|
322
337
|
if (badges)
|
|
323
338
|
await reportThreads(io, app, { session, at: io.now() });
|
package/dist/setup.js
CHANGED
|
@@ -13,7 +13,7 @@ export function setupOf(heard) {
|
|
|
13
13
|
const setup = heard.setup;
|
|
14
14
|
if (typeof setup !== 'object' || setup === null)
|
|
15
15
|
return null;
|
|
16
|
-
const { reported, verified, test } = setup;
|
|
16
|
+
const { reported, verified, test, used } = setup;
|
|
17
17
|
if (typeof reported !== 'boolean' || typeof verified !== 'boolean')
|
|
18
18
|
return null;
|
|
19
19
|
const card = typeof test === 'object' && test !== null ? test : null;
|
|
@@ -24,6 +24,7 @@ export function setupOf(heard) {
|
|
|
24
24
|
return {
|
|
25
25
|
reported,
|
|
26
26
|
verified,
|
|
27
|
+
...(used === true ? { used: true } : {}),
|
|
27
28
|
...(ok
|
|
28
29
|
? {
|
|
29
30
|
test: {
|
|
@@ -51,7 +52,7 @@ export function setupLine(app, heard, setup) {
|
|
|
51
52
|
? `Pending You: your person answered setup’s test question (${requestId}), asked by “${name}”. If you’re ${name}, ${pickUp(`name “${name}”`)} If you aren’t, leave it to ${name}.`
|
|
52
53
|
: `Pending You: your person answered setup’s test question (${requestId}). C${pickUp('with your name').slice(1)}`;
|
|
53
54
|
}
|
|
54
|
-
if (setup.test)
|
|
55
|
+
if (setup.test || setup.used)
|
|
55
56
|
return null;
|
|
56
57
|
if (setup.reported)
|
|
57
58
|
return `Pending You: ${title} is connected, but setup’s test question isn’t sent yet. ${setupCalls(app, false)}`;
|
|
@@ -86,6 +87,7 @@ export async function setupReminder(io, options) {
|
|
|
86
87
|
return null;
|
|
87
88
|
}
|
|
88
89
|
}
|
|
90
|
+
export const SETUP_IN_USE = 'finished. It’s in use, so its unfinished test question no longer matters.';
|
|
89
91
|
export function setupStatus(appName, setup) {
|
|
90
92
|
if (!setup)
|
|
91
93
|
return null;
|
|
@@ -95,5 +97,9 @@ export function setupStatus(appName, setup) {
|
|
|
95
97
|
return 'its test card is waiting on you in Pending You';
|
|
96
98
|
if (setup.test?.turn === 'agent')
|
|
97
99
|
return `you answered its test card; ${appName} picks it up next`;
|
|
100
|
+
if (setup.used)
|
|
101
|
+
return SETUP_IN_USE;
|
|
102
|
+
if (setup.reported)
|
|
103
|
+
return `reported, but its test question isn’t sent yet. Start ${appName} (or restart it); if it doesn’t finish by itself, say “${FINISH_SAY}”`;
|
|
98
104
|
return `waiting for its first session. Start ${appName} (or restart it); if it doesn’t finish by itself, say “${FINISH_SAY}”`;
|
|
99
105
|
}
|
package/dist/stopcheck.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { open } from 'node:fs/promises';
|
|
2
2
|
import { getJson } from "./api.js";
|
|
3
3
|
import { codexSeesAnswers } from "./apps/codex.js";
|
|
4
|
+
import { hasHeard, turnEnded } from "./apps/codex-midturn.js";
|
|
4
5
|
import { markNudged, turnRecord } from "./apps/codex-wake.js";
|
|
5
6
|
import { APP_NAMES, DEFAULT_APP } from "./apps/ids.js";
|
|
7
|
+
import { DEFAULT_ORIGIN } from "./args.js";
|
|
6
8
|
import { asksQuestion, wordsOf } from "./asked.js";
|
|
7
9
|
import { asksToTypeHere, cardFits, confirmReason, sessionLink } from "./confirm.js";
|
|
8
10
|
import { readCredential } from "./credentials.js";
|
|
@@ -414,6 +416,20 @@ export async function stopcheck(io, options) {
|
|
|
414
416
|
event: 'stop',
|
|
415
417
|
subagents: subagentsRunning(input),
|
|
416
418
|
});
|
|
419
|
+
if (app === 'codex' &&
|
|
420
|
+
typeof input.session_id === 'string' &&
|
|
421
|
+
input.stop_hook_active !== true) {
|
|
422
|
+
await turnEnded(io, input.session_id, typeof input.turn_id === 'string' ? input.turn_id : null);
|
|
423
|
+
if (await hasHeard(io, input.session_id))
|
|
424
|
+
io.background([
|
|
425
|
+
'listen',
|
|
426
|
+
'--app',
|
|
427
|
+
'codex',
|
|
428
|
+
'--thread',
|
|
429
|
+
input.session_id,
|
|
430
|
+
...(options.origin === DEFAULT_ORIGIN ? [] : ['--origin', options.origin]),
|
|
431
|
+
]);
|
|
432
|
+
}
|
|
417
433
|
if (input.stop_hook_active === true)
|
|
418
434
|
return 0;
|
|
419
435
|
if (!(await readCredential(io, options.origin, app)))
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.43.
|
|
1
|
+
export const VERSION = '0.43.3';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pendingyou-wake",
|
|
3
3
|
"displayName": "Pending You",
|
|
4
|
-
"version": "2.61.
|
|
4
|
+
"version": "2.61.3",
|
|
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.61.
|
|
7
|
+
Generated from recordplane/pendingyou (packages/claude-plugin/src/wake) with Pending You’s guide 2.61.3; send changes there.
|