@bli-cockpit/telemetry-core 0.1.95 → 0.1.96
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.
|
@@ -8,5 +8,18 @@
|
|
|
8
8
|
* Its own file, and its own `./codex-hooks-trust-guide` export, so a browser
|
|
9
9
|
* component can import one string without pulling in the whole package.
|
|
10
10
|
* Repo copy of the guide: `docs/runbooks/codex-hooks-trust.md` (BLI-23315).
|
|
11
|
+
* Since BLI-24349 the guide leads with doctor's one question; `/hooks` is the fallback.
|
|
11
12
|
*/
|
|
12
13
|
export declare const CODEX_HOOKS_TRUST_GUIDE_URL = "https://tower.buildlaunchiterate.ca/docs/trust-the-bli-memory-hooks-in-codex";
|
|
14
|
+
/** The doctor question, word for word (BLI-24349). Surfaces that tell a person to answer it quote this. */
|
|
15
|
+
export declare const CODEX_HOOKS_TRUST_QUESTION_WORDS = "Auto-trust the BLI Memory hooks in Codex?";
|
|
16
|
+
/** The command that trusts them without the question, for a person who said no earlier. */
|
|
17
|
+
export declare const CODEX_HOOKS_TRUST_COMMAND = "cockpit doctor --trust-codex-hooks";
|
|
18
|
+
/**
|
|
19
|
+
* The one sentence every surface prints for `codex.hooks needs_trust`
|
|
20
|
+
* (BLI-24349): lead with doctor's question, keep `/hooks` as the fallback.
|
|
21
|
+
* `reason` is the receipt's reason label for the piece; `trust_declined` and
|
|
22
|
+
* `managed_hooks_stale` get their own words. Every variant names `/hooks`, so
|
|
23
|
+
* the device doctor's `hook_trust` action keeps matching it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function codexHooksTrustAction(reason?: string | null): string;
|
|
@@ -8,5 +8,26 @@
|
|
|
8
8
|
* Its own file, and its own `./codex-hooks-trust-guide` export, so a browser
|
|
9
9
|
* component can import one string without pulling in the whole package.
|
|
10
10
|
* Repo copy of the guide: `docs/runbooks/codex-hooks-trust.md` (BLI-23315).
|
|
11
|
+
* Since BLI-24349 the guide leads with doctor's one question; `/hooks` is the fallback.
|
|
11
12
|
*/
|
|
12
13
|
export const CODEX_HOOKS_TRUST_GUIDE_URL = "https://tower.buildlaunchiterate.ca/docs/trust-the-bli-memory-hooks-in-codex";
|
|
14
|
+
/** The doctor question, word for word (BLI-24349). Surfaces that tell a person to answer it quote this. */
|
|
15
|
+
export const CODEX_HOOKS_TRUST_QUESTION_WORDS = "Auto-trust the BLI Memory hooks in Codex?";
|
|
16
|
+
/** The command that trusts them without the question, for a person who said no earlier. */
|
|
17
|
+
export const CODEX_HOOKS_TRUST_COMMAND = "cockpit doctor --trust-codex-hooks";
|
|
18
|
+
/**
|
|
19
|
+
* The one sentence every surface prints for `codex.hooks needs_trust`
|
|
20
|
+
* (BLI-24349): lead with doctor's question, keep `/hooks` as the fallback.
|
|
21
|
+
* `reason` is the receipt's reason label for the piece; `trust_declined` and
|
|
22
|
+
* `managed_hooks_stale` get their own words. Every variant names `/hooks`, so
|
|
23
|
+
* the device doctor's `hook_trust` action keeps matching it.
|
|
24
|
+
*/
|
|
25
|
+
export function codexHooksTrustAction(reason) {
|
|
26
|
+
if (reason === "trust_declined") {
|
|
27
|
+
return `The person answered no to "${CODEX_HOOKS_TRUST_QUESTION_WORDS}". To trust them, run \`${CODEX_HOOKS_TRUST_COMMAND}\` in a terminal on the machine (or open Codex and run /hooks). Guide: ${CODEX_HOOKS_TRUST_GUIDE_URL}`;
|
|
28
|
+
}
|
|
29
|
+
if (reason === "managed_hooks_stale") {
|
|
30
|
+
return `BLI Memory's Codex hooks changed since they were trusted: run \`cockpit doctor\` in a terminal on the machine and answer Y to "${CODEX_HOOKS_TRUST_QUESTION_WORDS}" (fallback: open Codex and run /hooks). Guide: ${CODEX_HOOKS_TRUST_GUIDE_URL}`;
|
|
31
|
+
}
|
|
32
|
+
return `Run \`cockpit doctor\` in a terminal on the machine and answer Y to "${CODEX_HOOKS_TRUST_QUESTION_WORDS}" (one password or administrator prompt). Fallback: open Codex and run /hooks. Guide: ${CODEX_HOOKS_TRUST_GUIDE_URL}`;
|
|
33
|
+
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* BLI-24380: BLI Memory is the only memory store. `supermemory` and `both` are
|
|
3
|
+
* retired: a new entry naming them is accepted (never an error) and logged as
|
|
4
|
+
* retired, and receipts queued before the retirement still ship unchanged.
|
|
5
|
+
*/
|
|
6
|
+
export type ExperienceStore = "bli";
|
|
7
|
+
export type RetiredExperienceStore = "supermemory" | "both";
|
|
8
|
+
/** What a stored or queued receipt may carry: today's store or a retired one. */
|
|
9
|
+
export type RecordedExperienceStore = ExperienceStore | RetiredExperienceStore;
|
|
10
|
+
export declare const RETIRED_EXPERIENCE_STORES: readonly RetiredExperienceStore[];
|
|
2
11
|
export type ExperienceVerdict = "win" | "loss" | "noise";
|
|
3
12
|
export interface MemoryExperience {
|
|
4
13
|
id: string;
|
|
5
|
-
store:
|
|
14
|
+
store: RecordedExperienceStore;
|
|
6
15
|
verdict: ExperienceVerdict;
|
|
7
16
|
reason: string;
|
|
8
17
|
created_at: string;
|
|
@@ -14,6 +23,24 @@ export type ExperienceSender = (entry: MemoryExperience) => Promise<{
|
|
|
14
23
|
ok: boolean;
|
|
15
24
|
reason?: string;
|
|
16
25
|
}>;
|
|
26
|
+
export type NormalisedExperienceStore = {
|
|
27
|
+
store: ExperienceStore;
|
|
28
|
+
given: string;
|
|
29
|
+
retired: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
store: null;
|
|
32
|
+
given: "supermemory";
|
|
33
|
+
retired: true;
|
|
34
|
+
reason: "store_retired";
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The one rule every new-entry door shares (CLI, MCP). Omitted means `bli`.
|
|
38
|
+
* `both` records as `bli`: BLI Memory was one of the stores that answered.
|
|
39
|
+
* `supermemory` records nothing: that store is gone, so a verdict about it is
|
|
40
|
+
* not a fact about anything Tower runs. Anything else is a caller error.
|
|
41
|
+
*/
|
|
42
|
+
export declare function normaliseExperienceStore(given: string | undefined): NormalisedExperienceStore;
|
|
43
|
+
/** Validates a receipt. Retired stores stay valid so an old queued receipt still ships. */
|
|
17
44
|
export declare function validateExperience(store: string, verdict: string, reason: string): void;
|
|
18
45
|
export declare function experienceLine(entry: MemoryExperience, agent: string, project: string): string;
|
|
19
46
|
export declare function appendExperience(input: {
|
|
@@ -4,20 +4,42 @@ import { randomUUID } from "node:crypto";
|
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { redactSecretLikeContent } from "./secret-guards-masking.js";
|
|
7
|
+
export const RETIRED_EXPERIENCE_STORES = ["supermemory", "both"];
|
|
8
|
+
/**
|
|
9
|
+
* The one rule every new-entry door shares (CLI, MCP). Omitted means `bli`.
|
|
10
|
+
* `both` records as `bli`: BLI Memory was one of the stores that answered.
|
|
11
|
+
* `supermemory` records nothing: that store is gone, so a verdict about it is
|
|
12
|
+
* not a fact about anything Tower runs. Anything else is a caller error.
|
|
13
|
+
*/
|
|
14
|
+
export function normaliseExperienceStore(given) {
|
|
15
|
+
const value = given ?? "bli";
|
|
16
|
+
if (value === "bli") {
|
|
17
|
+
return { store: "bli", given: value, retired: false };
|
|
18
|
+
}
|
|
19
|
+
if (value === "both") {
|
|
20
|
+
console.error("[memory experience] store retired", JSON.stringify({ given: value, recorded: "bli" }));
|
|
21
|
+
return { store: "bli", given: value, retired: true };
|
|
22
|
+
}
|
|
23
|
+
if (value === "supermemory") {
|
|
24
|
+
console.error("[memory experience] store retired", JSON.stringify({ given: value, recorded: null, reason: "store_retired" }));
|
|
25
|
+
return { store: null, given: value, retired: true, reason: "store_retired" };
|
|
26
|
+
}
|
|
27
|
+
throw new Error("store must be bli (supermemory and both are retired)");
|
|
28
|
+
}
|
|
29
|
+
/** Validates a receipt. Retired stores stay valid so an old queued receipt still ships. */
|
|
7
30
|
export function validateExperience(store, verdict, reason) {
|
|
8
|
-
if (
|
|
9
|
-
throw new Error("store must be bli
|
|
31
|
+
if (store !== "bli" && !RETIRED_EXPERIENCE_STORES.includes(store))
|
|
32
|
+
throw new Error("store must be bli (supermemory and both are retired)");
|
|
10
33
|
if (!["win", "loss", "noise"].includes(verdict))
|
|
11
34
|
throw new Error("verdict must be win, loss or noise");
|
|
12
35
|
if (!reason.trim() || [...reason].length > 500 || /[\r\n\x00-\x1f\x7f]/u.test(reason)) {
|
|
13
36
|
throw new Error("reason must be one nonempty line of at most 500 characters; opinions only, no prompts, memory bodies or secrets");
|
|
14
37
|
}
|
|
15
38
|
}
|
|
16
|
-
const markers = { bli: "[bli]", supermemory: "◪", both: "[bli]+◪" };
|
|
17
39
|
export function experienceLine(entry, agent, project) {
|
|
18
40
|
const stamp = new Date(Date.parse(entry.created_at) + 7 * 3600000).toISOString().slice(0, 16).replace("T", " ");
|
|
19
41
|
const label = (value) => value.replace(/[\r\n·]/gu, " ");
|
|
20
|
-
return `- ${stamp} ICT · ${label(agent)} · ${label(project)} · ${entry.store}
|
|
42
|
+
return `- ${stamp} ICT · ${label(agent)} · ${label(project)} · ${entry.store} [bli] · ${entry.verdict}: ${entry.reason}`;
|
|
21
43
|
}
|
|
22
44
|
function paths(home) {
|
|
23
45
|
return { log: path.join(home, ".codex", "AGENT-EXPERIENCE.md"), queue: path.join(home, ".codex", "agent-experience-outbox") };
|
|
@@ -29,6 +51,9 @@ async function saveReceipt(home, entry) {
|
|
|
29
51
|
await rename(temp, target);
|
|
30
52
|
}
|
|
31
53
|
export async function appendExperience(input, options) {
|
|
54
|
+
// BLI-24380: a new entry records BLI Memory only; callers normalise first.
|
|
55
|
+
if (input.store !== "bli")
|
|
56
|
+
throw new Error("appendExperience records bli only; run normaliseExperienceStore first");
|
|
32
57
|
validateExperience(input.store, input.verdict, input.reason);
|
|
33
58
|
// BLI-12187: the reason is free text an agent wrote and it is uploaded, so the
|
|
34
59
|
// value is masked before the receipt, the local log or the outbox sees it.
|
package/dist/setup-receipt.js
CHANGED
|
@@ -112,7 +112,9 @@ export function setupReceiptPieces(receipt, memory) {
|
|
|
112
112
|
const reason = memory?.reasons?.[key];
|
|
113
113
|
return {
|
|
114
114
|
status: word,
|
|
115
|
-
|
|
115
|
+
// BLI-24349: `ok` keeps one reason, `managed_by_system`, so a machine
|
|
116
|
+
// card can say HOW Codex runs the hooks (no trust step needed).
|
|
117
|
+
...((word !== "ok" || reason === "managed_by_system") && reason ? { reason } : {}),
|
|
116
118
|
};
|
|
117
119
|
};
|
|
118
120
|
return [
|