@pushary/agent-hooks 1.9.148 → 1.9.149
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 +4 -0
- package/data/openclaw-plugin/package.json +8 -2
- package/dist/bin/pushary-bell-hook.js +4 -5
- package/dist/bin/pushary-claude.js +4 -5
- package/dist/bin/pushary-codex-bridge.js +5 -5
- package/dist/bin/pushary-codex-hook.js +4 -5
- package/dist/bin/pushary-codex-session.js +1 -1
- package/dist/bin/pushary-daemon.js +3 -4
- package/dist/bin/pushary-elicitation-hook.js +4 -5
- package/dist/bin/pushary-gemini-bridge.js +4 -4
- package/dist/bin/pushary-gemini-hook.js +4 -5
- package/dist/bin/pushary-hook.js +5 -6
- package/dist/bin/pushary-notification-hook.js +4 -5
- package/dist/bin/pushary-opencode-hook.js +4 -5
- package/dist/bin/pushary-permission-denied-hook.js +5 -6
- package/dist/bin/pushary-permission-hook.js +5 -6
- package/dist/bin/pushary-post-hook.js +4 -5
- package/dist/bin/pushary-prompt-hook.js +4 -5
- package/dist/bin/pushary-session-end-hook.js +4 -5
- package/dist/bin/pushary-session-start-hook.js +4 -5
- package/dist/bin/pushary-setup.js +2 -3
- package/dist/bin/pushary-stop-hook.js +4 -5
- package/dist/bin/pushary-stopfailure-hook.js +4 -5
- package/dist/bin/pushary-transcript-register.js +4 -5
- package/dist/bin/pushary-transcripts.js +13 -14
- package/dist/{chunk-B6RTPP3X.js → chunk-26TXJ35O.js} +1 -1
- package/dist/{chunk-YOP7LFHW.js → chunk-2CVRVHUQ.js} +2 -2
- package/dist/{chunk-XMSDA5WA.js → chunk-352FIVVH.js} +41 -1
- package/dist/{chunk-BPKB7BI4.js → chunk-35IODIBL.js} +17 -2
- package/dist/{chunk-5ZIYTFPW.js → chunk-5HAA7C4X.js} +59 -177
- package/dist/{chunk-UFGFO7QB.js → chunk-F6ESGEWU.js} +1 -1
- package/dist/{chunk-UL2NNDKD.js → chunk-MUTMXSQZ.js} +128 -2
- package/dist/{chunk-S4HS6VTI.js → chunk-OJUW7QW2.js} +2 -4
- package/dist/{chunk-VPMSV35B.js → chunk-ZIPPDZ5B.js} +1 -1
- package/dist/{codex-session-launch-4YJR4ZGN.js → codex-session-launch-73EQE6IL.js} +5 -5
- package/dist/src/index.js +5 -6
- package/package.json +1 -1
- package/dist/chunk-VAE5JBR5.js +0 -46
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
macAppHistoryDecision
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-OJUW7QW2.js";
|
|
5
5
|
import {
|
|
6
6
|
TRANSCRIPT_SYNC_NOTICE
|
|
7
7
|
} from "../chunk-PH3MVQCQ.js";
|
|
@@ -12,17 +12,9 @@ import {
|
|
|
12
12
|
exitOnHelpFlag
|
|
13
13
|
} from "../chunk-6HO36P3A.js";
|
|
14
14
|
import {
|
|
15
|
-
assertVerifiedPhone,
|
|
16
|
-
clearPin,
|
|
17
15
|
clearSnapshotRecipientPins,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
recipientPinFile,
|
|
21
|
-
snapshotRecipientPinFile,
|
|
22
|
-
trustPhoneRecipient,
|
|
23
|
-
verifyTrustedRecipients
|
|
24
|
-
} from "../chunk-5ZIYTFPW.js";
|
|
25
|
-
import "../chunk-VAE5JBR5.js";
|
|
16
|
+
snapshotRecipientPinFile
|
|
17
|
+
} from "../chunk-5HAA7C4X.js";
|
|
26
18
|
import "../chunk-G66WIAST.js";
|
|
27
19
|
import "../chunk-XZGQZDFP.js";
|
|
28
20
|
import "../chunk-QTQRQZIU.js";
|
|
@@ -33,9 +25,16 @@ import {
|
|
|
33
25
|
parseFlags
|
|
34
26
|
} from "../chunk-YPY4YCIZ.js";
|
|
35
27
|
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
assertVerifiedPhone,
|
|
29
|
+
clearPin,
|
|
30
|
+
fetchTranscriptRecipients,
|
|
31
|
+
fingerprint,
|
|
32
|
+
loadPin,
|
|
33
|
+
recipientPinFile,
|
|
34
|
+
trustPhoneRecipient,
|
|
35
|
+
verifyTrustedRecipients
|
|
36
|
+
} from "../chunk-MUTMXSQZ.js";
|
|
37
|
+
import "../chunk-352FIVVH.js";
|
|
39
38
|
import {
|
|
40
39
|
transcriptEnvironmentPreference,
|
|
41
40
|
transcriptsEnabled
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
postLiveSession,
|
|
5
5
|
postLiveSessionUntilAccepted,
|
|
6
6
|
startLiveSessionHeartbeat
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-35IODIBL.js";
|
|
8
8
|
import {
|
|
9
9
|
CommandReceipts,
|
|
10
10
|
controllerCommandSchema
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-F6ESGEWU.js";
|
|
12
12
|
import {
|
|
13
13
|
SESSION_IDLE_TIMEOUT_MS,
|
|
14
14
|
describeIdleWindow,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeJsonAtomic
|
|
3
|
+
} from "./chunk-TODDEIYG.js";
|
|
1
4
|
import {
|
|
2
5
|
__export
|
|
3
6
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -4043,6 +4046,43 @@ var coerce = {
|
|
|
4043
4046
|
};
|
|
4044
4047
|
var NEVER = INVALID;
|
|
4045
4048
|
|
|
4049
|
+
// src/transcript-read-positions.ts
|
|
4050
|
+
import { lstatSync, readFileSync } from "fs";
|
|
4051
|
+
var OWNER_ONLY_FILE_MODE = 384;
|
|
4052
|
+
var MAXIMUM_READ_POSITIONS_BYTES = 4 * 1024 * 1024;
|
|
4053
|
+
var transcriptReadPositionSchema = external_exports.object({
|
|
4054
|
+
identity: external_exports.string().nullable(),
|
|
4055
|
+
offset: external_exports.number().int().nonnegative(),
|
|
4056
|
+
startedBeforeEpoch: external_exports.boolean()
|
|
4057
|
+
});
|
|
4058
|
+
var savedReadPositionsSchema = external_exports.object({ positions: external_exports.record(external_exports.string(), transcriptReadPositionSchema) });
|
|
4059
|
+
var ownedOnlyByThisUser = (info) => !process.getuid || info.uid === process.getuid() && (info.mode & 511) === OWNER_ONLY_FILE_MODE;
|
|
4060
|
+
var readOwnerOnlyJson = (path, maximumBytes) => {
|
|
4061
|
+
const info = lstatSync(path);
|
|
4062
|
+
if (!info.isFile() || info.nlink !== 1 || !ownedOnlyByThisUser(info) || info.size > maximumBytes) return null;
|
|
4063
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
4064
|
+
};
|
|
4065
|
+
var savedTranscriptReadPositions = (file) => ({
|
|
4066
|
+
load: () => {
|
|
4067
|
+
try {
|
|
4068
|
+
return new Map(Object.entries(savedReadPositionsSchema.parse(readOwnerOnlyJson(file, MAXIMUM_READ_POSITIONS_BYTES)).positions));
|
|
4069
|
+
} catch {
|
|
4070
|
+
return /* @__PURE__ */ new Map();
|
|
4071
|
+
}
|
|
4072
|
+
},
|
|
4073
|
+
save: (positions) => {
|
|
4074
|
+
try {
|
|
4075
|
+
writeJsonAtomic(file, { positions: Object.fromEntries(positions) }, OWNER_ONLY_FILE_MODE);
|
|
4076
|
+
} catch {
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
});
|
|
4081
|
+
|
|
4046
4082
|
export {
|
|
4047
|
-
external_exports
|
|
4083
|
+
external_exports,
|
|
4084
|
+
transcriptReadPositionSchema,
|
|
4085
|
+
ownedOnlyByThisUser,
|
|
4086
|
+
readOwnerOnlyJson,
|
|
4087
|
+
savedTranscriptReadPositions
|
|
4048
4088
|
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildTranscriptRecords,
|
|
3
|
+
changedRecipientsMessage,
|
|
3
4
|
decodePublicKey,
|
|
4
5
|
encryptRecord,
|
|
5
6
|
fetchTranscriptRecipients,
|
|
6
7
|
generateSessionKey,
|
|
7
8
|
recordSealerFor,
|
|
9
|
+
savePin,
|
|
8
10
|
uploadTranscriptRecords,
|
|
11
|
+
verifyAnchoredRecipients,
|
|
9
12
|
wrapSessionKey
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-MUTMXSQZ.js";
|
|
11
14
|
|
|
12
15
|
// src/live-session.ts
|
|
13
16
|
var LIVE_TRANSCRIPT_LIMITS = { queuedRecords: 100, recordCharacters: 32 * 1024 };
|
|
@@ -70,6 +73,7 @@ var LiveTranscriptRelay = class {
|
|
|
70
73
|
sealRecord = encryptRecord;
|
|
71
74
|
keyUploaded = false;
|
|
72
75
|
keyRejected = false;
|
|
76
|
+
warnedAboutRecipients = false;
|
|
73
77
|
flushing = null;
|
|
74
78
|
add(value) {
|
|
75
79
|
if (this.keyRejected) return;
|
|
@@ -95,7 +99,7 @@ var LiveTranscriptRelay = class {
|
|
|
95
99
|
try {
|
|
96
100
|
if (!this.sessionKey) {
|
|
97
101
|
const recipients = await fetchTranscriptRecipients(this.options.apiKey, this.options.baseUrl);
|
|
98
|
-
if (!recipients) return false;
|
|
102
|
+
if (!recipients || !this.acceptsRecipients(recipients)) return false;
|
|
99
103
|
this.sessionKey = generateSessionKey();
|
|
100
104
|
this.wrappedKey = wrapSessionKey(this.sessionKey, decodePublicKey(recipients.phonePublicKey));
|
|
101
105
|
this.sealRecord = recordSealerFor(recipients.phoneReadsCompressedRecords);
|
|
@@ -133,6 +137,17 @@ var LiveTranscriptRelay = class {
|
|
|
133
137
|
return false;
|
|
134
138
|
}
|
|
135
139
|
}
|
|
140
|
+
acceptsRecipients(recipients) {
|
|
141
|
+
const verdict = verifyAnchoredRecipients(recipients);
|
|
142
|
+
if (verdict.kind === "match") return true;
|
|
143
|
+
if (verdict.kind === "first-use") return savePin(verdict.pin);
|
|
144
|
+
if (!this.warnedAboutRecipients) {
|
|
145
|
+
this.warnedAboutRecipients = true;
|
|
146
|
+
process.stderr.write(`${changedRecipientsMessage(verdict, recipients)}
|
|
147
|
+
`);
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
136
151
|
};
|
|
137
152
|
|
|
138
153
|
export {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ownedOnlyByThisUser,
|
|
3
|
-
readOwnerOnlyJson,
|
|
4
|
-
savedTranscriptReadPositions
|
|
5
|
-
} from "./chunk-VAE5JBR5.js";
|
|
6
1
|
import {
|
|
7
2
|
SESSION_HISTORY_RETENTION_DAYS
|
|
8
3
|
} from "./chunk-G66WIAST.js";
|
|
@@ -17,18 +12,24 @@ import {
|
|
|
17
12
|
} from "./chunk-WQJ5NJ35.js";
|
|
18
13
|
import {
|
|
19
14
|
buildTranscriptRecords,
|
|
15
|
+
changedRecipientsMessage,
|
|
20
16
|
decodePublicKey,
|
|
21
17
|
decryptRecord,
|
|
22
18
|
encryptRecord,
|
|
23
19
|
fetchTranscriptRecipients,
|
|
24
20
|
generateSessionKey,
|
|
21
|
+
recipientPinFile,
|
|
25
22
|
recordSealerFor,
|
|
23
|
+
savePin,
|
|
26
24
|
uploadTranscriptRecords,
|
|
25
|
+
verifyAnchoredRecipients,
|
|
27
26
|
wrapSessionKey
|
|
28
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-MUTMXSQZ.js";
|
|
29
28
|
import {
|
|
30
|
-
external_exports
|
|
31
|
-
|
|
29
|
+
external_exports,
|
|
30
|
+
ownedOnlyByThisUser,
|
|
31
|
+
savedTranscriptReadPositions
|
|
32
|
+
} from "./chunk-352FIVVH.js";
|
|
32
33
|
import {
|
|
33
34
|
transcriptEnvironmentPreference,
|
|
34
35
|
transcriptsEnabled
|
|
@@ -61,126 +62,14 @@ import {
|
|
|
61
62
|
redactSecretsFromContent
|
|
62
63
|
} from "./chunk-O5ARO3JM.js";
|
|
63
64
|
|
|
64
|
-
// src/transcript-recipient-pin.ts
|
|
65
|
-
import { createHash } from "crypto";
|
|
66
|
-
import { mkdirSync, rmSync } from "fs";
|
|
67
|
-
import { homedir } from "os";
|
|
68
|
-
import { dirname, join } from "path";
|
|
69
|
-
var recipientPinFile = () => process.env.PUSHARY_RECIPIENT_PIN_FILE?.trim() || join(homedir(), ".pushary", "recipients.json");
|
|
70
|
-
var asPin = (offer) => ({
|
|
71
|
-
phonePublicKey: offer.phonePublicKey,
|
|
72
|
-
providerKeyId: offer.provider?.keyId ?? null,
|
|
73
|
-
providerPublicKey: offer.provider?.publicKey ?? null
|
|
74
|
-
});
|
|
75
|
-
var pinnedRecipientsSchema = external_exports.object({
|
|
76
|
-
phonePublicKey: external_exports.string().min(1).max(256),
|
|
77
|
-
providerKeyId: external_exports.string().min(1).max(256).nullable().default(null),
|
|
78
|
-
providerPublicKey: external_exports.string().min(1).max(256).nullable().default(null)
|
|
79
|
-
});
|
|
80
|
-
var loadPin = (path = recipientPinFile()) => {
|
|
81
|
-
try {
|
|
82
|
-
return pinnedRecipientsSchema.parse(readOwnerOnlyJson(path, 16384));
|
|
83
|
-
} catch (error) {
|
|
84
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
|
|
85
|
-
throw new Error("Existing history trust could not be read. Nothing was replaced.");
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
var savePin = (pin, path = recipientPinFile()) => {
|
|
89
|
-
try {
|
|
90
|
-
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
91
|
-
writeJsonAtomicDurable(path, pin, 384);
|
|
92
|
-
return true;
|
|
93
|
-
} catch {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
var clearPin = () => {
|
|
98
|
-
try {
|
|
99
|
-
rmSync(recipientPinFile(), { force: true });
|
|
100
|
-
} catch {
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
var verifyRecipients = (offer, pinned) => {
|
|
104
|
-
if (!pinned) return { kind: "first-use", pin: asPin(offer) };
|
|
105
|
-
const next = asPin(offer);
|
|
106
|
-
const changed = [];
|
|
107
|
-
if (next.phonePublicKey !== pinned.phonePublicKey) changed.push("the phone key this machine seals to");
|
|
108
|
-
if (next.providerKeyId !== pinned.providerKeyId) changed.push("the compliance recovery key id");
|
|
109
|
-
if (next.providerPublicKey !== pinned.providerPublicKey) changed.push("the compliance recovery key");
|
|
110
|
-
return changed.length === 0 ? { kind: "match" } : { kind: "changed", changed };
|
|
111
|
-
};
|
|
112
|
-
var fingerprint = (publicKey) => createHash("sha256").update(publicKey).digest("hex");
|
|
113
|
-
var changedRecipientsMessage = (verdict, offer) => [
|
|
114
|
-
"[pushary] Transcript sync stopped: the keys this machine seals transcripts to have changed.",
|
|
115
|
-
...verdict.changed.map((what) => `[pushary] changed: ${what}`),
|
|
116
|
-
`[pushary] now offered: phone ${fingerprint(offer.phonePublicKey)}${offer.provider ? `, recovery ${offer.provider.keyId.slice(0, 8)}` : ", no recovery key"}`,
|
|
117
|
-
"[pushary] If you reinstalled the app or rotated a key, this is expected. Compare the",
|
|
118
|
-
"[pushary] fingerprint above with the one in the app under Settings, then run:",
|
|
119
|
-
"[pushary] pushary transcripts trust --fingerprint <fingerprint-from-phone-settings>",
|
|
120
|
-
"[pushary] Until then nothing is uploaded, so no turn is sealed to a key you have not seen."
|
|
121
|
-
].join("\n");
|
|
122
|
-
|
|
123
|
-
// src/transcript-phone-trust.ts
|
|
124
|
-
import { createHash as createHash2 } from "crypto";
|
|
125
|
-
import { mkdirSync as mkdirSync2 } from "fs";
|
|
126
|
-
import { dirname as dirname2, join as join2 } from "path";
|
|
127
|
-
var approvedPhoneSchema = external_exports.object({ version: external_exports.literal(1), sourcePinHash: external_exports.string().regex(/^[a-f0-9]{64}$/), phonePublicKey: external_exports.string().min(1).max(256) });
|
|
128
|
-
var pinHash = (pin) => createHash2("sha256").update(JSON.stringify(pin)).digest("hex");
|
|
129
|
-
var approvalFile = (path, pin, publicKey) => join2(`${path}.trusted-phones`, `${pinHash(pin)}-${fingerprint(publicKey)}.json`);
|
|
130
|
-
var sameRecoveryRecipient = (offer, pin) => (offer.provider?.keyId ?? null) === pin.providerKeyId && (offer.provider?.publicKey ?? null) === pin.providerPublicKey;
|
|
131
|
-
var canonicalPublicKey = (key) => {
|
|
132
|
-
const bytes = Buffer.from(key, "base64");
|
|
133
|
-
return bytes.length === 32 && bytes.toString("base64") === key;
|
|
134
|
-
};
|
|
135
|
-
var phoneWasApproved = (offer, pin, path) => {
|
|
136
|
-
try {
|
|
137
|
-
const approval = approvedPhoneSchema.parse(readOwnerOnlyJson(approvalFile(path, pin, offer.phonePublicKey), 16384));
|
|
138
|
-
if (approval.sourcePinHash !== pinHash(pin) || approval.phonePublicKey !== offer.phonePublicKey) throw new Error("Mismatched approval");
|
|
139
|
-
return true;
|
|
140
|
-
} catch (error) {
|
|
141
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
|
|
142
|
-
throw new Error("Saved phone verification could not be read. Nothing was replaced.");
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
var verifyTrustedRecipients = (offer, path = recipientPinFile()) => {
|
|
146
|
-
const pin = loadPin(path);
|
|
147
|
-
const verdict = verifyRecipients(offer, pin);
|
|
148
|
-
if (verdict.kind !== "changed" || !pin || !sameRecoveryRecipient(offer, pin)) return verdict;
|
|
149
|
-
return phoneWasApproved(offer, pin, path) ? { kind: "match" } : verdict;
|
|
150
|
-
};
|
|
151
|
-
var verifyAnchoredRecipients = (offer, path = recipientPinFile(), anchorPath) => {
|
|
152
|
-
const verdict = verifyTrustedRecipients(offer, path);
|
|
153
|
-
if (verdict.kind !== "first-use" || anchorPath === void 0 || loadPin(anchorPath) === null) return verdict;
|
|
154
|
-
const anchored = verifyTrustedRecipients(offer, anchorPath);
|
|
155
|
-
return anchored.kind === "match" ? verdict : anchored;
|
|
156
|
-
};
|
|
157
|
-
var assertVerifiedPhone = (offer, pin, expectedFingerprint) => {
|
|
158
|
-
if (!canonicalPublicKey(offer.phonePublicKey) || fingerprint(offer.phonePublicKey) !== expectedFingerprint.trim().toLowerCase()) {
|
|
159
|
-
throw new Error("The fingerprint does not match this phone. Nothing was changed.");
|
|
160
|
-
}
|
|
161
|
-
if (!pin) throw new Error("No existing history trust was found. Nothing was changed.");
|
|
162
|
-
if (!sameRecoveryRecipient(offer, pin)) throw new Error("The recovery recipient also changed. Phone verification cannot approve that change.");
|
|
163
|
-
};
|
|
164
|
-
var trustPhoneRecipient = (request) => {
|
|
165
|
-
const { offer, pinFile } = request;
|
|
166
|
-
const pin = loadPin(pinFile);
|
|
167
|
-
assertVerifiedPhone(offer, pin, request.expectedFingerprint);
|
|
168
|
-
if (!pin) throw new Error("No existing history trust was found.");
|
|
169
|
-
if (verifyTrustedRecipients(offer, pinFile).kind === "match") return "already_trusted";
|
|
170
|
-
const path = approvalFile(pinFile, pin, offer.phonePublicKey);
|
|
171
|
-
mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
|
|
172
|
-
writeJsonAtomicDurable(path, { version: 1, sourcePinHash: pinHash(pin), phonePublicKey: offer.phonePublicKey }, 384);
|
|
173
|
-
return "trusted";
|
|
174
|
-
};
|
|
175
|
-
|
|
176
65
|
// src/transcript-registration.ts
|
|
177
|
-
import { createHash as
|
|
66
|
+
import { createHash as createHash4 } from "crypto";
|
|
178
67
|
import { lstatSync as lstatSync3, readFileSync as readFileSync6, readdirSync as readdirSync2, realpathSync, statSync as statSync3, unlinkSync as unlinkSync2 } from "fs";
|
|
179
|
-
import { basename, dirname as
|
|
68
|
+
import { basename, dirname as dirname2, isAbsolute, join as join5, relative, resolve as resolve2, sep } from "path";
|
|
180
69
|
|
|
181
70
|
// src/claude-display-draft.ts
|
|
182
71
|
import { closeSync, fstatSync, lstatSync, openSync, readFileSync, readSync, unlinkSync } from "fs";
|
|
183
|
-
import { join
|
|
72
|
+
import { join } from "path";
|
|
184
73
|
|
|
185
74
|
// src/transcript-redaction.ts
|
|
186
75
|
var redactDraft = (text, complete = false) => {
|
|
@@ -233,7 +122,7 @@ var stateSchema = external_exports.object({
|
|
|
233
122
|
startedAt: external_exports.number().int().positive(),
|
|
234
123
|
updatedAt: external_exports.number().int().positive()
|
|
235
124
|
});
|
|
236
|
-
var fileFor = (id, directory) =>
|
|
125
|
+
var fileFor = (id, directory) => join(directory, `${id}.display`);
|
|
237
126
|
var readState = (sessionId, runtime) => {
|
|
238
127
|
if (!identifier.safeParse(sessionId).success) return null;
|
|
239
128
|
try {
|
|
@@ -263,13 +152,13 @@ var readDisplayDraft = (sessionId, runtime) => {
|
|
|
263
152
|
};
|
|
264
153
|
|
|
265
154
|
// src/transcript-session-key.ts
|
|
266
|
-
import { existsSync, mkdirSync
|
|
267
|
-
import { homedir
|
|
268
|
-
import { join as
|
|
269
|
-
var sessionKeyDirectory = () => process.env.PUSHARY_SESSION_KEY_DIR?.trim() ||
|
|
155
|
+
import { existsSync, mkdirSync, readFileSync as readFileSync2, readdirSync, rmSync, statSync } from "fs";
|
|
156
|
+
import { homedir } from "os";
|
|
157
|
+
import { join as join2 } from "path";
|
|
158
|
+
var sessionKeyDirectory = () => process.env.PUSHARY_SESSION_KEY_DIR?.trim() || join2(homedir(), ".pushary", "sessions");
|
|
270
159
|
var SESSION_DISPLAY_TTL_MS = 48 * 60 * 60 * 1e3;
|
|
271
160
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]{1,128}$/;
|
|
272
|
-
var fileFor2 = (sessionId, directory) => SAFE_SESSION_ID.test(sessionId) ?
|
|
161
|
+
var fileFor2 = (sessionId, directory) => SAFE_SESSION_ID.test(sessionId) ? join2(directory, `${sessionId}.json`) : null;
|
|
273
162
|
var loadSessionKey = (sessionId, directory = sessionKeyDirectory()) => {
|
|
274
163
|
const path = fileFor2(sessionId, directory);
|
|
275
164
|
if (!path || !existsSync(path)) return null;
|
|
@@ -293,7 +182,7 @@ var saveSessionKey = (sessionId, value, directory = sessionKeyDirectory()) => {
|
|
|
293
182
|
const path = fileFor2(sessionId, directory);
|
|
294
183
|
if (!path) return false;
|
|
295
184
|
try {
|
|
296
|
-
|
|
185
|
+
mkdirSync(directory, { recursive: true, mode: 448 });
|
|
297
186
|
writeJsonAtomicDurable(path, {
|
|
298
187
|
sessionKey: Buffer.from(value.sessionKey).toString("base64"),
|
|
299
188
|
wrappedKey: value.wrappedKey,
|
|
@@ -313,10 +202,10 @@ var sweepStaleSessionDisplays = (now = Date.now(), dir = sessionKeyDirectory())
|
|
|
313
202
|
try {
|
|
314
203
|
for (const name of readdirSync(dir)) {
|
|
315
204
|
if (!name.endsWith(".display")) continue;
|
|
316
|
-
const path =
|
|
205
|
+
const path = join2(dir, name);
|
|
317
206
|
try {
|
|
318
207
|
if (now - statSync(path).mtimeMs <= SESSION_DISPLAY_TTL_MS) continue;
|
|
319
|
-
|
|
208
|
+
rmSync(path, { force: true });
|
|
320
209
|
removed += 1;
|
|
321
210
|
} catch {
|
|
322
211
|
}
|
|
@@ -423,8 +312,8 @@ var startDisplayPublisher = (options) => {
|
|
|
423
312
|
};
|
|
424
313
|
|
|
425
314
|
// src/transcript-reader.ts
|
|
426
|
-
import { createHash as
|
|
427
|
-
import { join as
|
|
315
|
+
import { createHash as createHash3 } from "crypto";
|
|
316
|
+
import { join as join3 } from "path";
|
|
428
317
|
import { closeSync as closeSync3, fstatSync as fstatSync3, openSync as openSync3, readFileSync as readFileSync5, readSync as readSync2, statSync as statSync2 } from "fs";
|
|
429
318
|
|
|
430
319
|
// src/transcript-source.ts
|
|
@@ -483,7 +372,7 @@ var transcriptLinesSince = (lines, oldestLineMs, dropCompactionSummaries) => lin
|
|
|
483
372
|
import { closeSync as closeSync2, fstatSync as fstatSync2, openSync as openSync2, readFileSync as readFileSync3 } from "fs";
|
|
484
373
|
|
|
485
374
|
// src/transcript-snapshot-source.ts
|
|
486
|
-
import { createHash
|
|
375
|
+
import { createHash } from "crypto";
|
|
487
376
|
var identity = external_exports.string().min(1).max(256);
|
|
488
377
|
var timestamp = external_exports.string().refine((value) => Number.isFinite(Date.parse(value)));
|
|
489
378
|
var geminiTool = external_exports.object({ id: identity, name: external_exports.string(), args: external_exports.record(external_exports.string(), external_exports.unknown()), result: external_exports.unknown().optional(), status: external_exports.string() });
|
|
@@ -609,10 +498,10 @@ var parseCursorSnapshot = (text) => {
|
|
|
609
498
|
const record = JSON.parse(line);
|
|
610
499
|
if (isRecord(record) && (record.type === "metadata" || record.type === "turn_ended")) continue;
|
|
611
500
|
const message = cursorMessage.parse(record);
|
|
612
|
-
const
|
|
613
|
-
const occurrence = occurrences.get(
|
|
614
|
-
occurrences.set(
|
|
615
|
-
messages.push({ id: `cursor:${
|
|
501
|
+
const fingerprint = createHash("sha256").update(canonicalJsonText(message)).digest("hex");
|
|
502
|
+
const occurrence = occurrences.get(fingerprint) ?? 0;
|
|
503
|
+
occurrences.set(fingerprint, occurrence + 1);
|
|
504
|
+
messages.push({ id: `cursor:${fingerprint}:${occurrence}`, role: message.role, content: message.message.content });
|
|
616
505
|
}
|
|
617
506
|
return messages;
|
|
618
507
|
};
|
|
@@ -667,11 +556,11 @@ var readTranscriptSnapshot = (path, source, sessionId) => {
|
|
|
667
556
|
};
|
|
668
557
|
|
|
669
558
|
// src/transcript-snapshot-journal.ts
|
|
670
|
-
import { lstatSync as lstatSync2, mkdirSync as
|
|
671
|
-
import { dirname
|
|
559
|
+
import { lstatSync as lstatSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync4 } from "fs";
|
|
560
|
+
import { dirname } from "path";
|
|
672
561
|
|
|
673
562
|
// src/transcript-projection.ts
|
|
674
|
-
import { createHash as
|
|
563
|
+
import { createHash as createHash2 } from "crypto";
|
|
675
564
|
var newestWithinUploadLimits = (messages, limits) => {
|
|
676
565
|
let start = messages.length;
|
|
677
566
|
let contentBytes = 0;
|
|
@@ -700,7 +589,7 @@ var projectTranscriptSnapshot = (previous, messages, older) => {
|
|
|
700
589
|
const order = message.sourcePosition;
|
|
701
590
|
if (!message.id || message.id.length > 256 || Object.hasOwn(entries, message.id)) throw new Error("Invalid or duplicate history message identity");
|
|
702
591
|
const record = { timestamp: message.timestamp, observedAtMs: message.observedAtMs, historyMessage: { role: message.role, content: message.content } };
|
|
703
|
-
const digest =
|
|
592
|
+
const digest = createHash2("sha256").update(JSON.stringify(record)).digest("hex");
|
|
704
593
|
entries[message.id] = { digest, order };
|
|
705
594
|
const earlier = previous?.entries[message.id];
|
|
706
595
|
if (earlier?.digest === digest && earlier.order === order) continue;
|
|
@@ -796,7 +685,7 @@ var TranscriptSnapshotJournal = class {
|
|
|
796
685
|
}
|
|
797
686
|
store(next) {
|
|
798
687
|
if (Buffer.byteLength(JSON.stringify(next)) > MAXIMUM_JOURNAL_BYTES) throw new Error("History checkpoint exceeds its size limit");
|
|
799
|
-
|
|
688
|
+
mkdirSync2(dirname(this.path), { recursive: true, mode: 448 });
|
|
800
689
|
writeJsonAtomicDurable(this.path, next, 384);
|
|
801
690
|
this.current = journalSchema.parse(next);
|
|
802
691
|
}
|
|
@@ -908,8 +797,8 @@ var caughtUpReadStillCurrent = (caughtUp, version, nowMs) => caughtUp !== null &
|
|
|
908
797
|
var UNCHANGED_SNAPSHOT_READ = { lines: [], acknowledge: () => "unchanged" };
|
|
909
798
|
var snapshotReader = (options, source) => {
|
|
910
799
|
const { path, epoch } = options;
|
|
911
|
-
const binding =
|
|
912
|
-
const journalPath =
|
|
800
|
+
const binding = createHash3("sha256").update(JSON.stringify([options.baseUrl, options.apiKey, options.machineId, options.sessionId, source, path])).digest("hex");
|
|
801
|
+
const journalPath = join3(options.keyDirectory, "snapshots", binding + ".json");
|
|
913
802
|
const epochStart = epoch?.startedAtMs ?? 0;
|
|
914
803
|
const backfill = epoch ? epoch.backfill : SESSION_HISTORY_BACKFILL;
|
|
915
804
|
let journal;
|
|
@@ -964,11 +853,11 @@ var transcriptHealthReporter = (target) => {
|
|
|
964
853
|
};
|
|
965
854
|
|
|
966
855
|
// src/transcript-sync.ts
|
|
967
|
-
import { join as
|
|
856
|
+
import { join as join4, resolve } from "path";
|
|
968
857
|
var claudeTranscriptPath = (cwd, sessionId) => {
|
|
969
858
|
const projectId = resolve(cwd).replace(/[^a-zA-Z0-9-]/g, "-");
|
|
970
859
|
const configDir = claudeConfigDir();
|
|
971
|
-
return
|
|
860
|
+
return join4(configDir, "projects", projectId, `${sessionId}.jsonl`);
|
|
972
861
|
};
|
|
973
862
|
var createSyncState = () => ({
|
|
974
863
|
sessionKey: null,
|
|
@@ -1236,7 +1125,7 @@ var startTranscriptSync = (opts) => {
|
|
|
1236
1125
|
};
|
|
1237
1126
|
|
|
1238
1127
|
// src/transcript-registration.ts
|
|
1239
|
-
import { homedir as
|
|
1128
|
+
import { homedir as homedir2 } from "os";
|
|
1240
1129
|
var storedRegistrationSchema = external_exports.object({
|
|
1241
1130
|
sessionId: external_exports.string().min(1).max(128),
|
|
1242
1131
|
cwd: external_exports.string(),
|
|
@@ -1251,15 +1140,15 @@ var storedRegistrationSchema = external_exports.object({
|
|
|
1251
1140
|
endedAt: external_exports.number().positive().optional(),
|
|
1252
1141
|
drained: external_exports.boolean().optional()
|
|
1253
1142
|
});
|
|
1254
|
-
var defaultRegistryDirectory = () => process.env.PUSHARY_TRANSCRIPT_REGISTRY_DIR ||
|
|
1143
|
+
var defaultRegistryDirectory = () => process.env.PUSHARY_TRANSCRIPT_REGISTRY_DIR || join5(pusharyDir(), "transcript-capture");
|
|
1255
1144
|
var cliRegistry = (apiKey = getApiKey()) => ({ apiKey, baseUrl: getBaseUrl(), directory: defaultRegistryDirectory() });
|
|
1256
|
-
var accountFor = (registry) =>
|
|
1145
|
+
var accountFor = (registry) => createHash4("sha256").update(`${registry.baseUrl}\0${registry.apiKey}`).digest("hex");
|
|
1257
1146
|
var TTL = 48 * 60 * 60 * 1e3;
|
|
1258
|
-
var registeredReadPositionsFile = (registry) =>
|
|
1147
|
+
var registeredReadPositionsFile = (registry) => join5(registry.directory, "read-positions", `${accountFor(registry)}.json`);
|
|
1259
1148
|
var SNAPSHOT_KEYS_DIRECTORY_NAME = "snapshot-keys";
|
|
1260
1149
|
var SNAPSHOT_RECIPIENT_PIN_FILE_NAME = "recipients.json";
|
|
1261
|
-
var snapshotKeyDirectory = (registry) =>
|
|
1262
|
-
var snapshotRecipientPinFile = (registry = cliRegistry()) =>
|
|
1150
|
+
var snapshotKeyDirectory = (registry) => join5(registry.directory, SNAPSHOT_KEYS_DIRECTORY_NAME, accountFor(registry));
|
|
1151
|
+
var snapshotRecipientPinFile = (registry = cliRegistry()) => join5(snapshotKeyDirectory(registry), SNAPSHOT_RECIPIENT_PIN_FILE_NAME);
|
|
1263
1152
|
var entryAt = (path) => {
|
|
1264
1153
|
try {
|
|
1265
1154
|
return lstatSync3(path);
|
|
@@ -1274,9 +1163,9 @@ var removedPinFile = (path) => {
|
|
|
1274
1163
|
return true;
|
|
1275
1164
|
};
|
|
1276
1165
|
var clearSnapshotRecipientPins = (registryDirectory = defaultRegistryDirectory()) => {
|
|
1277
|
-
const accounts =
|
|
1166
|
+
const accounts = join5(registryDirectory, SNAPSHOT_KEYS_DIRECTORY_NAME);
|
|
1278
1167
|
if (!entryAt(accounts)?.isDirectory()) return false;
|
|
1279
|
-
return readdirSync2(accounts, { withFileTypes: true }).filter((account) => account.isDirectory()).map((account) => removedPinFile(
|
|
1168
|
+
return readdirSync2(accounts, { withFileTypes: true }).filter((account) => account.isDirectory()).map((account) => removedPinFile(join5(accounts, account.name, SNAPSHOT_RECIPIENT_PIN_FILE_NAME))).includes(true);
|
|
1280
1169
|
};
|
|
1281
1170
|
var read = (path) => {
|
|
1282
1171
|
if (statSync3(path).size > 16384) throw new Error("History registration exceeds its size limit");
|
|
@@ -1285,7 +1174,7 @@ var read = (path) => {
|
|
|
1285
1174
|
var consent = (record) => record.consentOverride ?? readTranscriptPreference() ?? true;
|
|
1286
1175
|
var withoutTrailingSlash = (url) => url.replace(/\/+$/, "");
|
|
1287
1176
|
var sameServer = (url, registry) => withoutTrailingSlash(url) === withoutTrailingSlash(registry.baseUrl);
|
|
1288
|
-
var fileFor3 = (registry, sessionId) =>
|
|
1177
|
+
var fileFor3 = (registry, sessionId) => join5(registry.directory, `${createHash4("sha256").update(accountFor(registry) + sessionId).digest("hex")}.json`);
|
|
1289
1178
|
var permitted = (registry, raw) => raw.account === accountFor(registry) && consent(raw) && !raw.drained && (raw.source !== "claude" || !!raw.expectedSiteId || !macOwnsClaudeHooks(raw.cwd)) && (!raw.expectedSiteId || raw.expectedSiteId === raw.verifiedSiteId && !!raw.expectedBaseUrl && sameServer(raw.expectedBaseUrl, registry));
|
|
1290
1179
|
var registeredTranscriptEnabled = (apiKey, sessionId, registry = cliRegistry(apiKey)) => {
|
|
1291
1180
|
try {
|
|
@@ -1295,9 +1184,9 @@ var registeredTranscriptEnabled = (apiKey, sessionId, registry = cliRegistry(api
|
|
|
1295
1184
|
}
|
|
1296
1185
|
};
|
|
1297
1186
|
var macOwnsClaudeHooks = (cwd) => [
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1187
|
+
join5(claudeConfigDir(), "settings.json"),
|
|
1188
|
+
join5(cwd, ".claude", "settings.json"),
|
|
1189
|
+
join5(cwd, ".claude", "settings.local.json")
|
|
1301
1190
|
].some((path) => {
|
|
1302
1191
|
try {
|
|
1303
1192
|
return hookOwnerOf(JSON.parse(readFileSync6(path, "utf8"))) === "app";
|
|
@@ -1307,13 +1196,13 @@ var macOwnsClaudeHooks = (cwd) => [
|
|
|
1307
1196
|
});
|
|
1308
1197
|
var TRANSCRIPT_ROOT_NAME = { claude: "projects", codex: "sessions", gemini: "tmp", cursor: "projects", hermes: "hermes-history" };
|
|
1309
1198
|
var transcriptRoots = (source) => {
|
|
1310
|
-
const home =
|
|
1311
|
-
if (source === "codex") return [
|
|
1312
|
-
if (source === "cursor") return [
|
|
1313
|
-
if (source === "hermes") return [
|
|
1314
|
-
if (source === "gemini") return [
|
|
1199
|
+
const home = homedir2();
|
|
1200
|
+
if (source === "codex") return [join5(codexHome(), TRANSCRIPT_ROOT_NAME.codex)];
|
|
1201
|
+
if (source === "cursor") return [join5(home, ".cursor", TRANSCRIPT_ROOT_NAME.cursor)];
|
|
1202
|
+
if (source === "hermes") return [join5(home, ".pushary", TRANSCRIPT_ROOT_NAME.hermes)];
|
|
1203
|
+
if (source === "gemini") return [join5(process.env.GEMINI_CLI_HOME || home, ".gemini", "tmp"), join5(home, ".cache", ".gemini", "tmp")];
|
|
1315
1204
|
const configured = process.env.CLAUDE_CONFIG_DIR;
|
|
1316
|
-
return [
|
|
1205
|
+
return [join5(configured || join5(home, ".claude"), TRANSCRIPT_ROOT_NAME.claude), join5(home, ".claude", TRANSCRIPT_ROOT_NAME.claude)];
|
|
1317
1206
|
};
|
|
1318
1207
|
var isAgentTranscriptRoot = (root, source) => isAbsolute(root) && resolve2(root) === root && basename(root) === TRANSCRIPT_ROOT_NAME[source];
|
|
1319
1208
|
var acceptedTranscriptRoots = (source, registeredRoot) => typeof registeredRoot === "string" && isAgentTranscriptRoot(registeredRoot, source) ? [...transcriptRoots(source), registeredRoot] : transcriptRoots(source);
|
|
@@ -1322,8 +1211,8 @@ var resolvedSourcePath = (path) => {
|
|
|
1322
1211
|
try {
|
|
1323
1212
|
return realpathSync(absolute);
|
|
1324
1213
|
} catch {
|
|
1325
|
-
const parent =
|
|
1326
|
-
return parent === absolute ? absolute :
|
|
1214
|
+
const parent = dirname2(absolute);
|
|
1215
|
+
return parent === absolute ? absolute : join5(resolvedSourcePath(parent), basename(absolute));
|
|
1327
1216
|
}
|
|
1328
1217
|
};
|
|
1329
1218
|
var transcriptRootContaining = (candidate, roots) => {
|
|
@@ -1343,7 +1232,7 @@ var captureRegistration = (source, value, registeredRoot) => {
|
|
|
1343
1232
|
const segments = relative(root, path).split(sep);
|
|
1344
1233
|
if (source === "hermes" && (segments.length !== 2 || !/^[a-f0-9]{64}$/.test(segments[0] ?? "") || basename(path) !== `${sessionId}.json`)) return null;
|
|
1345
1234
|
if (source === "gemini" && (segments.length !== 3 || segments[1] !== "chats" || !basename(path).startsWith("session-"))) return null;
|
|
1346
|
-
if (source === "cursor" && (segments[1] !== "agent-transcripts" || basename(path) !== `${sessionId}.jsonl` || !(segments.length === 3 || segments.length === 4 && basename(
|
|
1235
|
+
if (source === "cursor" && (segments[1] !== "agent-transcripts" || basename(path) !== `${sessionId}.jsonl` || !(segments.length === 3 || segments.length === 4 && basename(dirname2(path)) === sessionId))) return null;
|
|
1347
1236
|
return { sessionId, cwd: input.cwd, path, source, root };
|
|
1348
1237
|
};
|
|
1349
1238
|
var SESSION_END_EVENT = "SessionEnd";
|
|
@@ -1417,7 +1306,7 @@ var startRegisteredTranscripts = (apiKey, machineId, options = {}) => {
|
|
|
1417
1306
|
try {
|
|
1418
1307
|
let unreadable = 0;
|
|
1419
1308
|
const files = readdirSync2(registry.directory).filter((name) => name.endsWith(".json")).flatMap((name) => {
|
|
1420
|
-
const path =
|
|
1309
|
+
const path = join5(registry.directory, name);
|
|
1421
1310
|
try {
|
|
1422
1311
|
const time = statSync3(path).mtimeMs;
|
|
1423
1312
|
if (Date.now() - time > TTL) {
|
|
@@ -1516,13 +1405,6 @@ var startRegisteredTranscripts = (apiKey, machineId, options = {}) => {
|
|
|
1516
1405
|
};
|
|
1517
1406
|
|
|
1518
1407
|
export {
|
|
1519
|
-
recipientPinFile,
|
|
1520
|
-
loadPin,
|
|
1521
|
-
clearPin,
|
|
1522
|
-
fingerprint,
|
|
1523
|
-
verifyTrustedRecipients,
|
|
1524
|
-
assertVerifiedPhone,
|
|
1525
|
-
trustPhoneRecipient,
|
|
1526
1408
|
redactDraft,
|
|
1527
1409
|
startDraftPublisher,
|
|
1528
1410
|
claudeTranscriptPath,
|