@bli-cockpit/telemetry-core 0.1.107 → 0.1.109
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/harness-text.d.ts +35 -0
- package/dist/harness-text.js +60 -0
- package/dist/image-descriptions.d.ts +4 -3
- package/dist/image-descriptions.js +5 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TEXT THE AGENT HOST INJECTED IS NOT A MEMORY (BLI-26056).
|
|
3
|
+
*
|
|
4
|
+
* Claude Code puts its own text into the conversation as if it were a user turn: `<system-reminder>` blocks (a
|
|
5
|
+
* file's CLAUDE.md, a skill list, the "[SYSTEM NOTIFICATION - NOT USER INPUT] This is an automated background-task
|
|
6
|
+
* event" notice) and bare `<task-notification>` blocks when a background command or agent reports back. Nobody wrote
|
|
7
|
+
* those words. The Stop hook read them as the person's turn and saved them; when extraction then failed, the door's
|
|
8
|
+
* verbatim fallback (BLI-3713) stored the whole block as a memory (two such rows were found on 2026-11-20).
|
|
9
|
+
*
|
|
10
|
+
* This is the one place that knows those wrappers, for every capture path: the Stop and PreCompact hooks strip them
|
|
11
|
+
* before they send anything, and `POST /api/memory/save` strips them again for clients that predate the hooks' fix.
|
|
12
|
+
*
|
|
13
|
+
* A closed textual test, like the prompt hook's `automated-event.ts`: only CLOSED blocks are taken out, so a sentence
|
|
14
|
+
* that merely names the tag ("Claude Code wraps notices in <system-reminder>") is left alone. An unclosed block stays
|
|
15
|
+
* as text: when in doubt, keep what the person may have written.
|
|
16
|
+
*/
|
|
17
|
+
/** The first line of the host's automated-event notice, which can also arrive outside a reminder block. */
|
|
18
|
+
export declare const HARNESS_AUTOMATED_NOTICE_MARKER = "[SYSTEM NOTIFICATION - NOT USER INPUT]";
|
|
19
|
+
export interface HarnessTextReading {
|
|
20
|
+
/** The text with every closed harness block taken out (trimmed). Equal to the input, trimmed, when none was found. */
|
|
21
|
+
text: string;
|
|
22
|
+
/** How many blocks were taken out. Counts only, never content. */
|
|
23
|
+
removedBlocks: number;
|
|
24
|
+
/** True when harness text was found and nothing a person wrote is left. */
|
|
25
|
+
harnessOnly: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function stripHarnessText(input: string): HarnessTextReading;
|
|
28
|
+
/**
|
|
29
|
+
* True when a stored memory body is harness text saved before this filter existed: the Stop hook's `User: ` label
|
|
30
|
+
* (or the bare text) opening with a reminder or notification, AND nothing a person wrote left in that user turn once
|
|
31
|
+
* the closed harness blocks are taken out. Claude Code also puts reminders in front of real prompts, so a body that
|
|
32
|
+
* merely STARTS with one ("User: <system-reminder>…</system-reminder> fix the login bug") is a real exchange and is
|
|
33
|
+
* never matched. Used by the cleanup script and its test; a memory that later quotes a tag is not touched either.
|
|
34
|
+
*/
|
|
35
|
+
export declare function looksLikeSavedHarnessText(body: string): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TEXT THE AGENT HOST INJECTED IS NOT A MEMORY (BLI-26056).
|
|
3
|
+
*
|
|
4
|
+
* Claude Code puts its own text into the conversation as if it were a user turn: `<system-reminder>` blocks (a
|
|
5
|
+
* file's CLAUDE.md, a skill list, the "[SYSTEM NOTIFICATION - NOT USER INPUT] This is an automated background-task
|
|
6
|
+
* event" notice) and bare `<task-notification>` blocks when a background command or agent reports back. Nobody wrote
|
|
7
|
+
* those words. The Stop hook read them as the person's turn and saved them; when extraction then failed, the door's
|
|
8
|
+
* verbatim fallback (BLI-3713) stored the whole block as a memory (two such rows were found on 2026-11-20).
|
|
9
|
+
*
|
|
10
|
+
* This is the one place that knows those wrappers, for every capture path: the Stop and PreCompact hooks strip them
|
|
11
|
+
* before they send anything, and `POST /api/memory/save` strips them again for clients that predate the hooks' fix.
|
|
12
|
+
*
|
|
13
|
+
* A closed textual test, like the prompt hook's `automated-event.ts`: only CLOSED blocks are taken out, so a sentence
|
|
14
|
+
* that merely names the tag ("Claude Code wraps notices in <system-reminder>") is left alone. An unclosed block stays
|
|
15
|
+
* as text: when in doubt, keep what the person may have written.
|
|
16
|
+
*/
|
|
17
|
+
/** Every closed reminder block. The host writes them; a person never types one. */
|
|
18
|
+
const REMINDER_BLOCK = /<system-reminder>[\s\S]*?<\/system-reminder>/gu;
|
|
19
|
+
/** Every closed background-task notification. */
|
|
20
|
+
const NOTIFICATION_BLOCK = /<task-notification>[\s\S]*?<\/task-notification>/gu;
|
|
21
|
+
/** The first line of the host's automated-event notice, which can also arrive outside a reminder block. */
|
|
22
|
+
export const HARNESS_AUTOMATED_NOTICE_MARKER = "[SYSTEM NOTIFICATION - NOT USER INPUT]";
|
|
23
|
+
export function stripHarnessText(input) {
|
|
24
|
+
if (!input.includes("<system-reminder>") && !input.includes("<task-notification>") && !input.includes(HARNESS_AUTOMATED_NOTICE_MARKER)) {
|
|
25
|
+
return { text: input.trim(), removedBlocks: 0, harnessOnly: false };
|
|
26
|
+
}
|
|
27
|
+
let removedBlocks = 0;
|
|
28
|
+
const count = () => {
|
|
29
|
+
removedBlocks += 1;
|
|
30
|
+
return "";
|
|
31
|
+
};
|
|
32
|
+
// Reminders first: a notification wrapped inside one leaves with it, and is counted once.
|
|
33
|
+
let text = input.replace(REMINDER_BLOCK, count).replace(NOTIFICATION_BLOCK, count);
|
|
34
|
+
// The notice can arrive bare (its reminder unclosed or already stripped by the host): it and everything after it up to
|
|
35
|
+
// a blank line is the host's paragraph. Only taken out when it OPENS a line, so a quotation mid-sentence stays.
|
|
36
|
+
text = text.replace(/(^|\n)[ \t]*\[SYSTEM NOTIFICATION - NOT USER INPUT\][\s\S]*?(?=\n[ \t]*\n|$)/gu, (_match, lead) => {
|
|
37
|
+
removedBlocks += 1;
|
|
38
|
+
return lead;
|
|
39
|
+
});
|
|
40
|
+
const trimmed = text.replace(/\n{3,}/gu, "\n\n").trim();
|
|
41
|
+
return { text: trimmed, removedBlocks, harnessOnly: removedBlocks > 0 && trimmed.length === 0 };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* True when a stored memory body is harness text saved before this filter existed: the Stop hook's `User: ` label
|
|
45
|
+
* (or the bare text) opening with a reminder or notification, AND nothing a person wrote left in that user turn once
|
|
46
|
+
* the closed harness blocks are taken out. Claude Code also puts reminders in front of real prompts, so a body that
|
|
47
|
+
* merely STARTS with one ("User: <system-reminder>…</system-reminder> fix the login bug") is a real exchange and is
|
|
48
|
+
* never matched. Used by the cleanup script and its test; a memory that later quotes a tag is not touched either.
|
|
49
|
+
*/
|
|
50
|
+
export function looksLikeSavedHarnessText(body) {
|
|
51
|
+
const trimmed = body.trimStart();
|
|
52
|
+
const label = /^User(?: \(truncated\))?:\s*…?\s*/u.exec(trimmed);
|
|
53
|
+
const head = label ? trimmed.slice(label[0].length) : trimmed;
|
|
54
|
+
if (!head.startsWith("<system-reminder>") && !head.startsWith("<task-notification>") && !head.startsWith(HARNESS_AUTOMATED_NOTICE_MARKER))
|
|
55
|
+
return false;
|
|
56
|
+
// The Stop hook writes `User: <turn>\n\nAssistant: <reply>`; only the user turn decides.
|
|
57
|
+
const reply = head.indexOf("\n\nAssistant: ");
|
|
58
|
+
const userTurn = reply >= 0 ? head.slice(0, reply) : head;
|
|
59
|
+
return stripHarnessText(userTurn).harnessOnly;
|
|
60
|
+
}
|
|
@@ -39,13 +39,14 @@ export declare function modeDropsImages(mode: ImageHandlingMode): boolean;
|
|
|
39
39
|
export declare function modeStoresImages(mode: ImageHandlingMode): boolean;
|
|
40
40
|
/**
|
|
41
41
|
* The FLEET DEFAULT and the fallback: the mode a machine uses when Tower has no setting for it and it
|
|
42
|
-
* has never heard from Tower. Default is
|
|
42
|
+
* has never heard from Tower. Default is drop (described images become markers and the transcript is
|
|
43
|
+
* slimmed), on fleet-wide since 2026-11-27; a per-machine row can still put one machine back on keep.
|
|
43
44
|
*
|
|
44
45
|
* Since BLI-17273 the mode is decided PER MACHINE. The `collector_image_mode:<device_id>` row in
|
|
45
46
|
* `public.system_settings` (`cockpit settings switches set collector_image_mode:<device_id> describe_and_drop`)
|
|
46
47
|
* rides the reply to the sync-start receipt, the collector caches the last value it saw, and that
|
|
47
|
-
* value overrides this constant for that machine only.
|
|
48
|
-
*
|
|
48
|
+
* value overrides this constant for that machine only. The dashboard mirrors this constant as
|
|
49
|
+
* `COLLECTOR_IMAGE_MODE_DEFAULT`, which is what a machine with no row is told; change both together.
|
|
49
50
|
*/
|
|
50
51
|
export declare const IMAGE_HANDLING_MODE: ImageHandlingMode;
|
|
51
52
|
/**
|
|
@@ -29,15 +29,16 @@ export function modeStoresImages(mode) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* The FLEET DEFAULT and the fallback: the mode a machine uses when Tower has no setting for it and it
|
|
32
|
-
* has never heard from Tower. Default is
|
|
32
|
+
* has never heard from Tower. Default is drop (described images become markers and the transcript is
|
|
33
|
+
* slimmed), on fleet-wide since 2026-11-27; a per-machine row can still put one machine back on keep.
|
|
33
34
|
*
|
|
34
35
|
* Since BLI-17273 the mode is decided PER MACHINE. The `collector_image_mode:<device_id>` row in
|
|
35
36
|
* `public.system_settings` (`cockpit settings switches set collector_image_mode:<device_id> describe_and_drop`)
|
|
36
37
|
* rides the reply to the sync-start receipt, the collector caches the last value it saw, and that
|
|
37
|
-
* value overrides this constant for that machine only.
|
|
38
|
-
*
|
|
38
|
+
* value overrides this constant for that machine only. The dashboard mirrors this constant as
|
|
39
|
+
* `COLLECTOR_IMAGE_MODE_DEFAULT`, which is what a machine with no row is told; change both together.
|
|
39
40
|
*/
|
|
40
|
-
export const IMAGE_HANDLING_MODE = "
|
|
41
|
+
export const IMAGE_HANDLING_MODE = "describe_and_drop";
|
|
41
42
|
// ---------------------------------------------------------------------------
|
|
42
43
|
// Limits
|
|
43
44
|
// ---------------------------------------------------------------------------
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./ingest-dto.js";
|
|
|
26
26
|
export * from "./local-config.js";
|
|
27
27
|
export * from "./memory-daemon-endpoint.js";
|
|
28
28
|
export * from "./memory-hook-stats.js";
|
|
29
|
+
export * from "./harness-text.js";
|
|
29
30
|
export * from "./memory-hook-hours.js";
|
|
30
31
|
export * from "./sync-revive-contract.js";
|
|
31
32
|
export * from "./memory-capture-contract.js";
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./ingest-dto.js";
|
|
|
26
26
|
export * from "./local-config.js";
|
|
27
27
|
export * from "./memory-daemon-endpoint.js";
|
|
28
28
|
export * from "./memory-hook-stats.js";
|
|
29
|
+
export * from "./harness-text.js";
|
|
29
30
|
export * from "./memory-hook-hours.js";
|
|
30
31
|
export * from "./sync-revive-contract.js";
|
|
31
32
|
export * from "./memory-capture-contract.js";
|