@yougrowai/node 0.4.0 → 0.6.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.
@@ -0,0 +1,427 @@
1
+ import { spawn } from "node:child_process";
2
+ import * as http from "node:http";
3
+ import * as https from "node:https";
4
+ import { compactEvent, endEvent, parseHookInput, scannedSummary, startEvent, stopEvent } from "./events.js";
5
+ import { commitsBetween, gitFacts } from "./git.js";
6
+ import { readKey, readSavedKey, runProgram } from "./keychain.js";
7
+ import { SCAN_VERSION } from "./scan.js";
8
+ import { cleanUp, HOOK_VERSION, listStates, pathsFor, readConfig, readState, takeLock, takeNotice, updateState } from "./state.js";
9
+ import { partDue, sendTranscript, unsentBytes } from "./transcript.js";
10
+ /**
11
+ * The Work hook's events (K's Work slice, plan section 6b and decision S8), as Claude Code runs
12
+ * them. It never gets in the way: whatever fails, it exits 0 and prints nothing, except the lines
13
+ * SessionStart and PreCompact are for.
14
+ *
15
+ * - SessionStart (waits up to 10 seconds): starts or finds the session; prints the lines Work
16
+ * answers, which Claude Code adds to the model's context before the first prompt, or the one
17
+ * line that says why Work isn't recording. Then any transcript a chat left unsent goes, in the
18
+ * background.
19
+ * - Stop (in the background): last active, turns and new commits, at most once a minute a chat;
20
+ * then the transcript's new lines, at most 4 parts.
21
+ * - PreCompact (waits up to 5 seconds): prints the session's facts for the summary to keep. It
22
+ * sends nothing.
23
+ * - PostCompact (in the background): Claude Code's summary, after the scan.
24
+ * - SessionEnd (waits up to 5 seconds): the end and its reason; the rest of the transcript goes in
25
+ * the background, or with the next start on this computer.
26
+ *
27
+ * It sends only to this copy's `/api/v2/work/sessions/` routes, with the key as a Bearer header.
28
+ */
29
+ export const START_TIMEOUT_MS = 6_000;
30
+ export const END_TIMEOUT_MS = 3_000;
31
+ export const ASYNC_TIMEOUT_MS = 15_000;
32
+ export const PART_TIMEOUT_MS = 60_000;
33
+ /** A stop goes to Work at most once a minute a chat. */
34
+ export const STOP_EVERY_MS = 60_000;
35
+ /** Compaction summaries a chat keeps to send again, at most. */
36
+ const PENDING_MAX = 3;
37
+ const RESPONSE_MAX = 1_000_000;
38
+ const LOOPBACK = new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
39
+ /**
40
+ * A copy's address as its origin, or null: https, or http on this computer only (`npm run local`).
41
+ * Never one with a user or password in it.
42
+ */
43
+ export function copyOrigin(text) {
44
+ if (!text)
45
+ return null;
46
+ let u;
47
+ try {
48
+ u = new URL(text.trim());
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ if (u.username || u.password)
54
+ return null;
55
+ if (u.protocol === "https:" || (u.protocol === "http:" && LOOPBACK.has(u.hostname)))
56
+ return u.origin;
57
+ return null;
58
+ }
59
+ const NO_ANSWER = { status: 0, body: null, retryAfter: null };
60
+ /** One request with Node's own http and https, never longer than `timeoutMs` in all. */
61
+ export const httpRequest = (o) => new Promise((resolve) => {
62
+ let u;
63
+ try {
64
+ u = new URL(o.url);
65
+ }
66
+ catch {
67
+ resolve(NO_ANSWER);
68
+ return;
69
+ }
70
+ const mod = u.protocol === "https:" ? https : u.protocol === "http:" && LOOPBACK.has(u.hostname) ? http : null;
71
+ if (!mod) {
72
+ resolve(NO_ANSWER);
73
+ return;
74
+ }
75
+ let settled = false;
76
+ const done = (a) => {
77
+ if (settled)
78
+ return;
79
+ settled = true;
80
+ clearTimeout(timer);
81
+ resolve(a);
82
+ };
83
+ const headers = { ...o.headers, "user-agent": `yougrow-work-hook/${HOOK_VERSION}`, accept: "application/json" };
84
+ if (o.body)
85
+ headers["content-length"] = String(o.body.length);
86
+ const req = mod.request(u, { method: o.method, headers }, (res) => {
87
+ const chunks = [];
88
+ let size = 0;
89
+ res.on("data", (c) => {
90
+ size += c.length;
91
+ if (size <= RESPONSE_MAX)
92
+ chunks.push(c);
93
+ });
94
+ res.on("end", () => {
95
+ let body = null;
96
+ try {
97
+ const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
98
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
99
+ body = parsed;
100
+ }
101
+ catch {
102
+ body = null;
103
+ }
104
+ const ra = Number(res.headers["retry-after"]);
105
+ done({ status: res.statusCode ?? 0, body, retryAfter: Number.isFinite(ra) && ra > 0 ? ra : null });
106
+ });
107
+ res.on("error", () => done(NO_ANSWER));
108
+ });
109
+ const timer = setTimeout(() => {
110
+ req.destroy();
111
+ done(NO_ANSWER);
112
+ }, o.timeoutMs);
113
+ req.on("error", () => done(NO_ANSWER));
114
+ req.end(o.body);
115
+ });
116
+ /**
117
+ * The installed hook reads its copy from `~/.yougrow/work-hook.json` and its key from where
118
+ * `install` saved it, never from the environment: a `YOUGROW_WORK_KEY` a Claude Code inherits from
119
+ * its terminal may be another app's key. `work-hook run`, for a repo's committed hooks in cloud sessions,
120
+ * reads both from the environment, and does nothing unless `YOUGROW_WORK_URL` is set, or when
121
+ * this computer has the hook installed (which records its chats already).
122
+ */
123
+ export async function connectionFor(mode, d) {
124
+ const config = readConfig(d.paths);
125
+ if (mode === "installed") {
126
+ if (!config)
127
+ return null;
128
+ const url = copyOrigin(config.url);
129
+ const key = url ? await readSavedKey({ store: config.store, account: config.account }, { paths: d.paths, run: d.run }) : null;
130
+ return url && key ? { url, key } : null;
131
+ }
132
+ if (config)
133
+ return null;
134
+ const url = copyOrigin(d.env.YOUGROW_WORK_URL);
135
+ if (!url)
136
+ return null;
137
+ const key = await readKey({ store: "file", account: "", env: d.env }, { paths: d.paths, run: d.run });
138
+ if (key)
139
+ return { url, key };
140
+ return d.env.CLAUDE_CODE_REMOTE === "true" ? { url, key: null } : null;
141
+ }
142
+ const eventsUrl = (c) => `${c.url}/api/v2/work/sessions/events`;
143
+ const headersOf = (c, more) => (c.key ? { authorization: `Bearer ${c.key}`, ...more } : more);
144
+ function post(c, body, timeoutMs, d) {
145
+ return d.request({ method: "POST", url: eventsUrl(c), headers: headersOf(c, { "content-type": "application/json" }), body: Buffer.from(JSON.stringify(body), "utf8"), timeoutMs });
146
+ }
147
+ export function partSender(c, d) {
148
+ return (o) => d.request({
149
+ method: "PUT",
150
+ url: `${c.url}/api/v2/work/sessions/${encodeURIComponent(o.session)}/transcript/${o.part}`,
151
+ headers: headersOf(c, { "content-type": "application/gzip", "x-work-offset": String(o.offset), "x-work-scan": String(o.scan) }),
152
+ body: o.body,
153
+ timeoutMs: PART_TIMEOUT_MS,
154
+ });
155
+ }
156
+ const ok = (a) => (a.status === 200 || a.status === 201) && a.body !== null;
157
+ /** Work didn't answer, or asked to wait: worth sending again later. Any other refusal won't change by sending again. */
158
+ const retryable = (a) => a.status === 0 || a.status === 429 || a.status >= 500;
159
+ const isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
160
+ const whole = (v) => (typeof v === "number" && Number.isSafeInteger(v) && v >= 0 ? v : null);
161
+ /** The transcript's state as Work's answer says it. */
162
+ export function transcriptOf(v) {
163
+ if (!isObject(v))
164
+ return null;
165
+ if (v.on === true) {
166
+ const nextPart = whole(v.nextPart);
167
+ const offset = whole(v.offset);
168
+ if (nextPart === null || nextPart < 1 || offset === null)
169
+ return null;
170
+ return { on: true, nextPart, offset, minScan: whole(v.minScan) ?? 1 };
171
+ }
172
+ if (v.on === false)
173
+ return { on: false, why: typeof v.why === "string" ? v.why.slice(0, 40) : "off", message: typeof v.message === "string" ? v.message.slice(0, 600) : "" };
174
+ return null;
175
+ }
176
+ /**
177
+ * Work's answer to an event, into the chat's state: its session, the facts PreCompact prints, and
178
+ * where the transcript stands. The part to send next is Work's; where the hook reads from is the
179
+ * further of Work's and its own, so lines a person removed with the session never go again.
180
+ */
181
+ export function withAnswer(s, body) {
182
+ const session = typeof body.session === "string" && /^ws_[a-z2-7]{20}$/.test(body.session) ? body.session : s.session;
183
+ const facts = typeof body.facts === "string" && body.facts ? body.facts.slice(0, 9_000) : s.facts;
184
+ const t = transcriptOf(body.transcript);
185
+ const next = { ...s, session, facts, refused: null };
186
+ if (!t)
187
+ return next;
188
+ // Work refused a part for this hook's scan already: it stays off rather than send another Work would refuse.
189
+ if (t.on && t.minScan > SCAN_VERSION && s.transcript?.on === false && s.transcript.why === "hook_old")
190
+ return next;
191
+ return t.on ? { ...next, transcript: t, nextPart: t.nextPart, offset: Math.max(s.offset, t.offset) } : { ...next, transcript: t };
192
+ }
193
+ const contextOf = (a) => (a.body && typeof a.body.context === "string" && a.body.context.trim() ? a.body.context.trim().slice(0, 3_000) : null);
194
+ const errorOf = (a) => (a.body && typeof a.body.error === "string" ? a.body.error.slice(0, 40) : `status_${a.status}`);
195
+ // --- The events ----------------------------------------------------------------------------------
196
+ /** Run one hook event. Never throws: Claude Code's chat goes on whatever happens here. */
197
+ export async function runHookEvent(event, mode, d) {
198
+ try {
199
+ const c = await connectionFor(mode, d);
200
+ if (!c)
201
+ return;
202
+ if (event === "flush")
203
+ return await onFlush(c, d);
204
+ const input = parseHookInput(await d.readInput());
205
+ if (!input)
206
+ return;
207
+ if (event === "start")
208
+ return await onStart(input, c, d);
209
+ if (event === "stop")
210
+ return await onStop(input, c, d);
211
+ if (event === "precompact")
212
+ return onPreCompact(input, d);
213
+ if (event === "compact")
214
+ return await onCompact(input, c, d);
215
+ if (event === "end")
216
+ return await onEnd(input, c, d);
217
+ }
218
+ catch {
219
+ // Never in the way.
220
+ }
221
+ }
222
+ const set = (d, id, change) => updateState(d.paths, id, d.now(), change);
223
+ /** Whether a chat has anything waiting to go: transcript lines or a summary. */
224
+ function waiting(s) {
225
+ return s.pending.length > 0 || (s.transcript?.on === true && unsentBytes(s) > 0);
226
+ }
227
+ async function onStart(input, c, d) {
228
+ const git = input.cwd ? await gitFacts(input.cwd, d.run) : {};
229
+ const body = startEvent(input, git, d.env);
230
+ const a = await post(c, body, START_TIMEOUT_MS, d);
231
+ set(d, input.sessionId, (cur) => {
232
+ const base = {
233
+ ...cur,
234
+ transcriptPath: input.transcriptPath ?? cur.transcriptPath,
235
+ cwd: input.cwd ?? cur.cwd,
236
+ startHead: cur.startHead ?? git.head ?? null,
237
+ sentHead: cur.sentHead ?? git.head ?? null,
238
+ lastPartAt: cur.lastPartAt ?? d.now(),
239
+ };
240
+ if (ok(a))
241
+ return { ...withAnswer(base, a.body), retryStart: null };
242
+ return { ...base, retryStart: retryable(a) ? body : null, refused: retryable(a) ? null : errorOf(a) };
243
+ });
244
+ const lines = [];
245
+ const context = contextOf(a);
246
+ if (context)
247
+ lines.push(context);
248
+ const notice = takeNotice(d.paths);
249
+ if (notice)
250
+ lines.push(notice);
251
+ if (lines.length)
252
+ d.print(lines.join("\n"));
253
+ cleanUp(d.paths, d.now());
254
+ if (listStates(d.paths).some(waiting))
255
+ d.spawnFlush();
256
+ }
257
+ /**
258
+ * A chat with no Work session yet, because Work didn't answer its start, or the hook was installed
259
+ * while it ran: start it now, from a later event. A chat whose start Work refused stays as it is
260
+ * until its next real start.
261
+ */
262
+ async function ensureSession(input, c, d, s) {
263
+ if (s.session || s.refused)
264
+ return s;
265
+ const git = s.retryStart ? {} : input.cwd ? await gitFacts(input.cwd, d.run) : {};
266
+ const body = s.retryStart ?? startEvent({ ...input, source: "resume" }, git, d.env);
267
+ const a = await post(c, body, ASYNC_TIMEOUT_MS, d);
268
+ return set(d, s.agentSessionId, (cur) => {
269
+ if (ok(a))
270
+ return { ...withAnswer(cur, a.body), retryStart: null, startHead: cur.startHead ?? git.head ?? null, sentHead: cur.sentHead ?? git.head ?? null };
271
+ return { ...cur, retryStart: retryable(a) ? body : null, refused: retryable(a) ? null : errorOf(a) };
272
+ });
273
+ }
274
+ /** Summaries whose send failed, oldest first. A refusal drops one; Work not answering keeps the rest for later. */
275
+ async function sendPending(c, d, id) {
276
+ for (;;) {
277
+ const s = readState(d.paths, id);
278
+ const p = s?.pending[0];
279
+ if (!s?.session || !p)
280
+ return;
281
+ const a = await post(c, compactEvent(id, { trigger: p.trigger, summary: p.summary }), ASYNC_TIMEOUT_MS, d);
282
+ if (retryable(a))
283
+ return;
284
+ set(d, id, (cur) => ({ ...(ok(a) ? withAnswer(cur, a.body) : cur), pending: cur.pending.filter((x) => x.at !== p.at) }));
285
+ }
286
+ }
287
+ async function onStop(input, c, d) {
288
+ const id = input.sessionId;
289
+ const now = d.now();
290
+ let s = set(d, id, (cur) => ({ ...cur, turns: cur.turns + 1, transcriptPath: input.transcriptPath ?? cur.transcriptPath, cwd: input.cwd ?? cur.cwd }));
291
+ if (s.lastStopAt === null || now - s.lastStopAt >= STOP_EVERY_MS) {
292
+ // Marked first, so a second Stop within the minute sends nothing.
293
+ s = set(d, id, (cur) => ({ ...cur, lastStopAt: now }));
294
+ s = await ensureSession(input, c, d, s);
295
+ if (s.session) {
296
+ await sendPending(c, d, id);
297
+ const cwd = s.cwd;
298
+ const git = cwd ? await gitFacts(cwd, d.run) : {};
299
+ const commits = cwd && git.head && s.startHead && git.head !== s.sentHead ? await commitsBetween(cwd, s.startHead, git.head, d.run) : null;
300
+ const a = await post(c, stopEvent(id, { turns: s.turns, git, commits }), ASYNC_TIMEOUT_MS, d);
301
+ if (ok(a))
302
+ set(d, id, (cur) => ({ ...withAnswer(cur, a.body), sentHead: commits !== null ? (git.head ?? cur.sentHead) : cur.sentHead }));
303
+ }
304
+ }
305
+ s = readState(d.paths, id) ?? s;
306
+ if (s.session && partDue(s, d.now()))
307
+ await sendTranscript({ paths: d.paths, agentSessionId: id, put: partSender(c, d), now: d.now, maxParts: 4, deadline: d.now() + 5 * 60_000 });
308
+ }
309
+ function onPreCompact(input, d) {
310
+ const s = readState(d.paths, input.sessionId);
311
+ if (s?.facts)
312
+ d.print(s.facts);
313
+ }
314
+ async function onCompact(input, c, d) {
315
+ const summary = input.summary ? scannedSummary(input.summary) : null;
316
+ if (!summary)
317
+ return;
318
+ const id = input.sessionId;
319
+ const trigger = input.trigger ?? "auto";
320
+ let s = readState(d.paths, id) ?? set(d, id, (cur) => ({ ...cur, transcriptPath: input.transcriptPath ?? cur.transcriptPath, cwd: input.cwd ?? cur.cwd }));
321
+ s = await ensureSession(input, c, d, s);
322
+ if (!s.session) {
323
+ if (!s.refused)
324
+ keepPending(d, id, { trigger, summary, at: d.now() });
325
+ return;
326
+ }
327
+ await sendPending(c, d, id);
328
+ const a = await post(c, compactEvent(id, { trigger, summary }), ASYNC_TIMEOUT_MS, d);
329
+ if (ok(a))
330
+ set(d, id, (cur) => withAnswer(cur, a.body));
331
+ else if (retryable(a))
332
+ keepPending(d, id, { trigger, summary, at: d.now() });
333
+ }
334
+ function keepPending(d, id, p) {
335
+ set(d, id, (cur) => ({ ...cur, pending: [...cur.pending, p].slice(-PENDING_MAX) }));
336
+ }
337
+ async function onEnd(input, c, d) {
338
+ const id = input.sessionId;
339
+ const s = readState(d.paths, id);
340
+ if (!s?.session)
341
+ return;
342
+ const a = await post(c, endEvent(id, input.reason), END_TIMEOUT_MS, d);
343
+ const after = ok(a) ? set(d, id, (cur) => withAnswer(cur, a.body)) : s;
344
+ if (waiting(after))
345
+ d.spawnFlush();
346
+ }
347
+ /** What chats left unsent, a chat at a time, with one flush on this computer at once. */
348
+ async function onFlush(c, d) {
349
+ const release = takeLock(d.paths.flushLock, d.now());
350
+ if (!release)
351
+ return;
352
+ try {
353
+ const deadline = d.now() + 5 * 60_000;
354
+ for (const s of listStates(d.paths)) {
355
+ if (d.now() > deadline)
356
+ break;
357
+ if (!s.session || !waiting(s))
358
+ continue;
359
+ await sendPending(c, d, s.agentSessionId);
360
+ await sendTranscript({ paths: d.paths, agentSessionId: s.agentSessionId, put: partSender(c, d), now: d.now, maxParts: 25, deadline });
361
+ }
362
+ }
363
+ finally {
364
+ release();
365
+ }
366
+ }
367
+ // --- The real process ----------------------------------------------------------------------------
368
+ /** Claude Code's input on stdin, whole, at most 8 MB and 2 seconds. */
369
+ export function readStdin(maxBytes = 8 * 1024 * 1024, timeoutMs = 2_000) {
370
+ return new Promise((resolve) => {
371
+ const stdin = process.stdin;
372
+ if (stdin.isTTY) {
373
+ resolve("");
374
+ return;
375
+ }
376
+ const chunks = [];
377
+ let n = 0;
378
+ let finished = false;
379
+ const finish = () => {
380
+ if (finished)
381
+ return;
382
+ finished = true;
383
+ clearTimeout(timer);
384
+ stdin.removeAllListeners("data");
385
+ stdin.destroy();
386
+ resolve(Buffer.concat(chunks).toString("utf8"));
387
+ };
388
+ const timer = setTimeout(finish, timeoutMs);
389
+ stdin.on("data", (chunk) => {
390
+ n += chunk.length;
391
+ if (n > maxBytes) {
392
+ chunks.length = 0;
393
+ finish();
394
+ return;
395
+ }
396
+ chunks.push(chunk);
397
+ });
398
+ stdin.on("end", finish);
399
+ stdin.on("error", finish);
400
+ });
401
+ }
402
+ /** The flush as its own process, detached, so Claude Code never waits for it. */
403
+ export function spawnFlushProcess(mode) {
404
+ const script = process.argv[1];
405
+ if (!script)
406
+ return;
407
+ try {
408
+ const child = spawn(process.execPath, mode === "run" ? [script, "run", "flush"] : [script, "flush"], { detached: true, stdio: "ignore", windowsHide: true, env: process.env });
409
+ child.on("error", () => { });
410
+ child.unref();
411
+ }
412
+ catch {
413
+ // Sent with the next start instead.
414
+ }
415
+ }
416
+ export function realRunDeps(mode, print) {
417
+ return {
418
+ paths: pathsFor(),
419
+ env: process.env,
420
+ now: Date.now,
421
+ readInput: () => readStdin(),
422
+ print,
423
+ request: httpRequest,
424
+ run: runProgram,
425
+ spawnFlush: () => spawnFlushProcess(mode),
426
+ };
427
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The hook's copy of the scan a coding session's words go through before Work keeps them (K's
3
+ * Work slice, decision S11): transcript lines, compaction summaries and the commits' first lines.
4
+ * It runs here, on the person's computer, before anything leaves it, and again on the server
5
+ * before anything is kept.
6
+ *
7
+ * Everything below this comment is the same as the app's src/lib/work/sessions/scan.ts, line for
8
+ * line: change both together. The SDK's test/workHook.scan.test.ts checks they match, and the made
9
+ * up vectors in test/scan-vectors.ts hold both to the same answers.
10
+ *
11
+ * What it finds is replaced with a label and the rest of the line is kept: private keys, Work keys
12
+ * and tokens of known shapes, Authorization headers and passwords in addresses, random looking
13
+ * values given to key, secret, token and password names, email addresses (except at example and
14
+ * test domains), phone numbers written with + or tel:, card numbers and IBANs that pass their
15
+ * checks, and images. A tool result that read a secret file goes whole, in transcript.ts.
16
+ *
17
+ * Honest limit: it finds the shapes it knows. A secret of a new shape, a person's name or a postal
18
+ * address can still get through.
19
+ */
20
+ /** The version of this table. A part says which one scanned it; the server refuses older ones. */
21
+ export declare const SCAN_VERSION = 1;
22
+ /** The oldest scan version the server takes a part from. */
23
+ export declare const SCAN_VERSION_MIN = 1;
24
+ export declare const REMOVED_KINDS: readonly ["private_key", "api_key", "token", "password", "secret", "secret_file", "email", "phone", "card", "bank_account", "image"];
25
+ export type RemovedKind = (typeof REMOVED_KINDS)[number];
26
+ export type RemovedCounts = Partial<Record<RemovedKind, number>>;
27
+ /** What each label says. A secret file's label names the file instead. */
28
+ export declare const REMOVED_WORDS: Record<Exclude<RemovedKind, "secret_file">, string>;
29
+ /** The label a removal leaves: "[removed: API key]", or "[removed: contents of .env.local]" for a secret file. */
30
+ export declare function removedLabel(kind: RemovedKind, file?: string): string;
31
+ /** Counts added together. */
32
+ export declare function addRemoved(a: RemovedCounts, b: RemovedCounts): RemovedCounts;
33
+ /** How many things the counts name. */
34
+ export declare function removedTotal(c: RemovedCounts): number;
35
+ /** The Luhn check card numbers carry. */
36
+ export declare function passesLuhn(digits: string): boolean;
37
+ /** The IBAN check: the country and check digits moved to the end, as a number, leave 1 after dividing by 97. */
38
+ export declare function passesIban(iban: string): boolean;
39
+ /**
40
+ * Whether a value given to a key, secret, token or password name looks random: long enough, more
41
+ * than one kind of character, and not a word, a reference or a placeholder. A password may be
42
+ * shorter than a key.
43
+ */
44
+ export declare function looksRandom(v: string, o: {
45
+ password: boolean;
46
+ }): boolean;
47
+ export interface ScanResult {
48
+ text: string;
49
+ removed: RemovedCounts;
50
+ }
51
+ /** One text through the table: every match replaced with its label, and how many of each. */
52
+ export declare function scanText(text: string): ScanResult;
53
+ /** The labels a text already holds, by kind: what the hook removed before it sent the text. */
54
+ export declare function labelsIn(text: string): RemovedCounts;
55
+ /**
56
+ * Whether a file is one whose contents are secret: `.env` files other than `.env.example`, `.pem`,
57
+ * `.key`, `.p12` and `.pfx` files, `id_rsa` and the other ssh keys, `credentials*.json`, service
58
+ * account files, `.npmrc`, `.netrc` and `.pypirc`: the same kind of list a repo's own Claude Code
59
+ * settings deny reading. Answers the file's own name, or null.
60
+ */
61
+ export declare function secretFileName(path: string): string | null;
62
+ /** The secret file a tool call reads, by its name and input: Read and Grep by their path, Bash by any path its command names. */
63
+ export declare function secretFileOfCall(tool: string, input: unknown): string | null;