@snoai/mem-claude 2.1.0 → 2.1.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/dist/cli.js +11 -7
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +6 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,6 +25,7 @@ function option(args, name) {
|
|
|
25
25
|
return index >= 0 ? args[index + 1] : undefined;
|
|
26
26
|
}
|
|
27
27
|
const HOOK_COMMANDS = ["session-start", "user-prompt-submit", "stop", "session-end", "pre-tool-use", "post-tool-use", "pre-compact"];
|
|
28
|
+
const STATE_HOOK_COMMANDS = ["permission-request", "approval-response", "interrupt", "notification", "stop-failure"];
|
|
28
29
|
async function main() {
|
|
29
30
|
const [command, ...args] = process.argv.slice(2);
|
|
30
31
|
if (command === "status-line")
|
|
@@ -33,22 +34,25 @@ async function main() {
|
|
|
33
34
|
await observeAgentEvent("claude", args[0] ?? "unknown", await readStdin());
|
|
34
35
|
return 0;
|
|
35
36
|
}
|
|
36
|
-
const input = HOOK_COMMANDS.includes(command ?? "") ? await readStdin() : undefined;
|
|
37
|
+
const input = [...HOOK_COMMANDS, ...STATE_HOOK_COMMANDS].includes(command ?? "") ? await readStdin() : undefined;
|
|
37
38
|
// The Cursor IDE runs Claude Code hooks with Cursor-shaped input; Sno's Cursor hooks own Cursor, so these do nothing there.
|
|
38
39
|
if (input && typeof input === "object" && "cursor_version" in input)
|
|
39
40
|
return 0;
|
|
40
|
-
if (input !== undefined && command)
|
|
41
|
+
if (input !== undefined && command && command !== "stop")
|
|
41
42
|
await observeAgentEvent("claude", command, input);
|
|
43
|
+
if (STATE_HOOK_COMMANDS.includes(command ?? ""))
|
|
44
|
+
return 0;
|
|
42
45
|
// Scripted runs (a temporary directory, `claude -p`) and background-task notices are not conversations; the
|
|
43
46
|
// real-agent release journeys set SNO_CAPTURE_SCRIPTED=1 to be recorded anyway. Measured 2026-10-13: 616 of 785 queued turns.
|
|
44
47
|
if (input && process.env["SNO_CAPTURE_SCRIPTED"] !== "1" && typeof input === "object") {
|
|
45
48
|
const { cwd, prompt } = input;
|
|
46
|
-
if (typeof cwd === "string" && isTemporaryDirectory(cwd))
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
if ((typeof cwd === "string" && isTemporaryDirectory(cwd)) ||
|
|
50
|
+
process.env["CLAUDE_CODE_ENTRYPOINT"]?.startsWith("sdk-") ||
|
|
51
|
+
(typeof prompt === "string" && prompt.trimStart().startsWith("<task-notification>"))) {
|
|
52
|
+
if (command === "stop")
|
|
53
|
+
await stop(input, false);
|
|
51
54
|
return 0;
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
if (command === "session-start") {
|
|
54
58
|
process.stdout.write(`${await composeContinuityContext("claude", "SessionStart", input, () => sessionStart(input))}\n`);
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function sessionStart(raw: unknown): Promise<string>;
|
|
2
2
|
export declare function userPromptSubmit(raw: unknown): Promise<string>;
|
|
3
|
-
export declare function stop(raw: unknown): Promise<void>;
|
|
3
|
+
export declare function stop(raw: unknown, capture?: boolean): Promise<void>;
|
|
4
4
|
export declare function preToolUse(raw: unknown): Promise<void>;
|
|
5
5
|
/** One tool.call per PostToolUse; latency is measured from the matching PreToolUse, 0 when none was recorded. */
|
|
6
6
|
export declare function postToolUse(raw: unknown): Promise<void>;
|
package/dist/hooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { performance } from "node:perf_hooks";
|
|
2
2
|
import { getSnoProfileDir } from "@snoai/observability";
|
|
3
|
-
import { appendObserveLedgerRows, CODING_SKIN_SESSION_QUERY, loadedFilesAtStart, } from "@snoai/memory/coding-skin";
|
|
3
|
+
import { appendObserveLedgerRows, CODING_SKIN_SESSION_QUERY, loadedFilesAtStart, observeAgentEvent, } from "@snoai/memory/coding-skin";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { readCaptureSettings, readRecallSettings } from "./settings.js";
|
|
6
6
|
import { ContractError } from "@snoai/memory/client";
|
|
@@ -212,7 +212,11 @@ async function sendSessionActivity(input, hook) {
|
|
|
212
212
|
}));
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
export async function stop(raw) {
|
|
215
|
+
export async function stop(raw, capture = true) {
|
|
216
|
+
const observation = observeAgentEvent("claude", "stop", raw);
|
|
217
|
+
await Promise.all([observation, capture ? captureStop(raw) : undefined]);
|
|
218
|
+
}
|
|
219
|
+
async function captureStop(raw) {
|
|
216
220
|
const started = performance.now();
|
|
217
221
|
let sessionId;
|
|
218
222
|
try {
|