@unblocklabs/unblock-memory 0.12.3 → 0.14.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.
- package/README.md +19 -18
- package/defaults.json +162 -0
- package/dist/src/analysis.js +1 -1
- package/dist/src/cluster-review.d.ts +2 -0
- package/dist/src/cluster-review.js +9 -8
- package/dist/src/config.d.ts +9 -6
- package/dist/src/config.js +59 -45
- package/dist/src/curation.d.ts +1 -1
- package/dist/src/decision-client.d.ts +45 -0
- package/dist/src/decision-client.js +87 -0
- package/dist/src/{typesafe.d.ts → decision-ranking.d.ts} +15 -18
- package/dist/src/decision-ranking.js +155 -0
- package/dist/src/{typesafe-review.d.ts → decision-review.d.ts} +13 -9
- package/dist/src/decision-review.js +193 -0
- package/dist/src/defaults.d.ts +8 -0
- package/dist/src/defaults.js +128 -0
- package/dist/src/diagnostics.d.ts +5 -5
- package/dist/src/emotion-baselines.d.ts +28 -3
- package/dist/src/emotion-baselines.js +312 -115
- package/dist/src/evidence-review.d.ts +22 -8
- package/dist/src/evidence-review.js +11 -8
- package/dist/src/extraction-chunk.d.ts +3 -0
- package/dist/src/extraction-chunk.js +25 -6
- package/dist/src/extraction-config.js +4 -2
- package/dist/src/extraction-model.d.ts +25 -17
- package/dist/src/extraction-model.js +232 -104
- package/dist/src/extraction-runtime.d.ts +3 -1
- package/dist/src/extraction-runtime.js +48 -20
- package/dist/src/extraction-source.d.ts +1 -1
- package/dist/src/extraction-source.js +21 -12
- package/dist/src/extraction-store.d.ts +29 -3
- package/dist/src/extraction-store.js +149 -25
- package/dist/src/extraction-worker.d.ts +3 -3
- package/dist/src/extraction-worker.js +250 -95
- package/dist/src/inside-out-runtime.js +43 -30
- package/dist/src/inside-out-sources.js +2 -1
- package/dist/src/inside-out-store.d.ts +2 -2
- package/dist/src/inside-out-store.js +111 -69
- package/dist/src/inside-out.d.ts +10 -9
- package/dist/src/inside-out.js +194 -106
- package/dist/src/manager.d.ts +22 -9
- package/dist/src/manager.js +279 -172
- package/dist/src/memory-database.js +3 -2
- package/dist/src/memory-passage.d.ts +2 -2
- package/dist/src/memory-passage.js +3 -2
- package/dist/src/memory-search.d.ts +4 -2
- package/dist/src/memory-search.js +5 -5
- package/dist/src/memory-whisperer.d.ts +1 -1
- package/dist/src/memory-whisperer.js +195 -129
- package/dist/src/my-turn.d.ts +1 -1
- package/dist/src/my-turn.js +90 -70
- package/dist/src/people-background.d.ts +5 -1
- package/dist/src/people-background.js +31 -7
- package/dist/src/people-dossier-review.d.ts +20 -8
- package/dist/src/people-dossier-review.js +15 -11
- package/dist/src/people-hooks.js +127 -22
- package/dist/src/people-learning-cron.d.ts +1 -1
- package/dist/src/people-learning-cron.js +107 -57
- package/dist/src/people-learning-inventory.d.ts +1 -0
- package/dist/src/people-learning-inventory.js +283 -172
- package/dist/src/people-learning-prompt.js +1 -1
- package/dist/src/people-learning-runtime.d.ts +1 -1
- package/dist/src/people-learning-runtime.js +360 -203
- package/dist/src/people-learning-store.d.ts +27 -4
- package/dist/src/people-learning-store.js +312 -96
- package/dist/src/people-primer-tool.js +13 -10
- package/dist/src/people-primer.d.ts +3 -1
- package/dist/src/people-primer.js +66 -48
- package/dist/src/people-store.d.ts +18 -21
- package/dist/src/people-store.js +188 -64
- package/dist/src/people-tools.js +138 -93
- package/dist/src/plugin.js +19 -18
- package/dist/src/quality-audit.d.ts +2 -0
- package/dist/src/quality-audit.js +11 -9
- package/dist/src/quality-triage.js +4 -3
- package/dist/src/query-generator.js +5 -2
- package/dist/src/response-audit.d.ts +1 -1
- package/dist/src/response-audit.js +78 -44
- package/dist/src/response-config.js +3 -1
- package/dist/src/response-episodes.d.ts +1 -1
- package/dist/src/response-episodes.js +15 -19
- package/dist/src/response-identity.js +2 -1
- package/dist/src/response-judge.d.ts +151 -145
- package/dist/src/response-judge.js +535 -204
- package/dist/src/response-memory.js +2 -1
- package/dist/src/response-outcome.js +9 -8
- package/dist/src/response-reviews.d.ts +29 -1
- package/dist/src/response-reviews.js +113 -15
- package/dist/src/response-runtime.js +10 -9
- package/dist/src/response-stages.d.ts +50 -53
- package/dist/src/response-stages.js +10 -4
- package/dist/src/response-store.d.ts +7 -6
- package/dist/src/response-store.js +335 -212
- package/dist/src/review-tools.d.ts +8 -2
- package/dist/src/review-tools.js +22 -21
- package/dist/src/runtime.d.ts +7 -4
- package/dist/src/runtime.js +625 -98
- package/dist/src/safety-config.js +3 -2
- package/dist/src/safety-whisperer.d.ts +2 -2
- package/dist/src/safety-whisperer.js +90 -73
- package/dist/src/session-sync.d.ts +3 -1
- package/dist/src/session-sync.js +202 -96
- package/dist/src/skill-whisperer.d.ts +2 -2
- package/dist/src/skill-whisperer.js +55 -32
- package/dist/src/slack-directory.js +3 -2
- package/dist/src/training-gate.d.ts +9 -22
- package/dist/src/training-gate.js +34 -36
- package/dist/src/training-input.js +4 -3
- package/dist/src/training-judge.d.ts +9 -16
- package/dist/src/training-judge.js +6 -5
- package/dist/src/training-models.d.ts +1 -1
- package/dist/src/training-models.js +9 -7
- package/dist/src/training-queries.d.ts +14 -9
- package/dist/src/training-queries.js +374 -231
- package/dist/src/training-retrieval.d.ts +17 -27
- package/dist/src/training-retrieval.js +186 -139
- package/dist/src/training-runtime.d.ts +3 -0
- package/dist/src/training-runtime.js +76 -18
- package/dist/src/training-store.d.ts +18 -3
- package/dist/src/training-store.js +141 -52
- package/dist/src/training.js +9 -11
- package/dist/src/whisperer-context.d.ts +13 -0
- package/dist/src/whisperer-context.js +22 -1
- package/docs/configuration.md +83 -64
- package/docs/extraction.md +26 -35
- package/docs/memory-training.md +7 -6
- package/docs/people-learning.md +2 -2
- package/docs/peoplesql.md +6 -6
- package/docs/response-audit.md +10 -8
- package/docs/retrieval.md +43 -47
- package/openclaw.plugin.json +76 -75
- package/package.json +5 -2
- package/skills/memory-curator/SKILL.md +1 -1
- package/skills/people-whisperer/SKILL.md +1 -1
- package/dist/src/typesafe-client.d.ts +0 -30
- package/dist/src/typesafe-client.js +0 -92
- package/dist/src/typesafe-review.js +0 -154
- package/dist/src/typesafe.js +0 -147
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { basename, isAbsolute } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const here = new URL(import.meta.url);
|
|
5
|
+
// Use the package-root copy even when tsc emits a type-import copy under dist/.
|
|
6
|
+
const bundledPath = new URL(basename(fileURLToPath(new URL("../", here))) === "dist"
|
|
7
|
+
? "../../defaults.json" : "../defaults.json", here);
|
|
8
|
+
const reasoningLevels = ["none", "minimal", "low", "medium", "high", "xhigh"];
|
|
9
|
+
const probabilities = new Set([
|
|
10
|
+
"minProposalConfidence", "minSupport", "minRetention", "minReplacement", "gateThreshold",
|
|
11
|
+
"defaultMinUsefulness", "minDecisionUsefulness", "defaultMinScore", "nudgeMaxProbability",
|
|
12
|
+
"defaultMinProbability", "minClaimSupport", "minRedundancy", "minClusterConfidence",
|
|
13
|
+
"defaultMinNoise", "triageNoiseThreshold", "triageEvidenceHigh", "triageEvidenceLow",
|
|
14
|
+
"primerUncertainFloor", "scoreHigh", "scoreLow",
|
|
15
|
+
]);
|
|
16
|
+
const ranges = {
|
|
17
|
+
"decisionModel.timeoutMs": [1, 10_000],
|
|
18
|
+
"decisionModel.unboundedTimeoutMs": [1, 60_000],
|
|
19
|
+
"extraction.proposalTimeoutMs": [1, 60_000],
|
|
20
|
+
"extraction.validationTimeoutMs": [1, 60_000],
|
|
21
|
+
"extraction.intervalMinutes": [0, 1440],
|
|
22
|
+
"extraction.historyMessages": [0, 20],
|
|
23
|
+
"extraction.maxBatches": [1, 50],
|
|
24
|
+
"extraction.inputLimitTokens": [1, 32_000],
|
|
25
|
+
"training.decisionTimeoutMs": [1, 60_000],
|
|
26
|
+
"memoryWhisperer.defaultMaxHints": [1, 3],
|
|
27
|
+
"memoryWhisperer.defaultCooldownTurns": [0, 1000],
|
|
28
|
+
"memoryWhisperer.defaultTimeoutMs": [1, 10_000],
|
|
29
|
+
"skillWhisperer.defaultHistoryMessages": [0, Number.MAX_SAFE_INTEGER],
|
|
30
|
+
"skillWhisperer.defaultCooldownTurns": [0, Number.MAX_SAFE_INTEGER],
|
|
31
|
+
"myTurn.defaultHistoryMessages": [1, 50],
|
|
32
|
+
"safetyWhisperer.defaultHistoryMessages": [0, 20],
|
|
33
|
+
"safetyWhisperer.defaultTimeoutMs": [1, 10_000],
|
|
34
|
+
"people.defaultWhispererMaxChars": [1, 4000],
|
|
35
|
+
"people.defaultTodosMaxOpen": [1, 10_000],
|
|
36
|
+
"responseAudit.defaultHistoryMessages": [0, 20],
|
|
37
|
+
"responseAudit.defaultLookbackDays": [1, 90],
|
|
38
|
+
"responseAudit.defaultMaxEpisodes": [1, 100],
|
|
39
|
+
"responseAudit.defaultIntervalMinutes": [0, 1440],
|
|
40
|
+
"insideOut.defaultIntervalMinutes": [0, 10080],
|
|
41
|
+
"insideOut.defaultMaxInteractions": [1, 10000],
|
|
42
|
+
"insideOut.defaultMaxContextTokens": [256, 30_000],
|
|
43
|
+
"insideOut.defaultBaselineMinInteractions": [1, 10000],
|
|
44
|
+
};
|
|
45
|
+
function record(value) {
|
|
46
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
47
|
+
}
|
|
48
|
+
function readJson(path) {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error(`Cannot load operational defaults from ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function validUrl(value, http) {
|
|
57
|
+
try {
|
|
58
|
+
const url = new URL(value);
|
|
59
|
+
const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
60
|
+
return !/[\s?#]/u.test(value) && (url.protocol === "https:" ||
|
|
61
|
+
(url.protocol === "http:" && (http === "any" || (http === "loopback" && loopback)))) &&
|
|
62
|
+
!url.username && !url.password && !url.hash && !url.search;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function validLeaf(base, value, path, key) {
|
|
69
|
+
if (typeof base === "number" && typeof value === "number") {
|
|
70
|
+
if (probabilities.has(key))
|
|
71
|
+
return Number.isFinite(value) && value >= 0 && value <= 1;
|
|
72
|
+
const [min, max] = ranges[path] ?? [1, key.endsWith("Ms") ? 2_147_483_647 : Number.MAX_SAFE_INTEGER];
|
|
73
|
+
return Number.isSafeInteger(value) && value >= min && value <= max;
|
|
74
|
+
}
|
|
75
|
+
if (typeof base !== "string" || typeof value !== "string")
|
|
76
|
+
return false;
|
|
77
|
+
if (path === "memoryWhisperer.defaultApiEndpoint")
|
|
78
|
+
return value === "" || validUrl(value, "any");
|
|
79
|
+
if (path === "decisionModel.endpoint")
|
|
80
|
+
return validUrl(value, "loopback");
|
|
81
|
+
if (path === "people.slackApiUrl")
|
|
82
|
+
return validUrl(value, "none");
|
|
83
|
+
if (path === "training.teacherReasoning")
|
|
84
|
+
return reasoningLevels.includes(value);
|
|
85
|
+
if (path === "training.teacherModel")
|
|
86
|
+
return /^[^/\s]+\/[^\s]+$/u.test(value);
|
|
87
|
+
return value.trim() === value && value.length > 0 && !/\s/u.test(value);
|
|
88
|
+
}
|
|
89
|
+
function merge(base, patch, parent = "") {
|
|
90
|
+
if (!record(patch))
|
|
91
|
+
throw new Error(`Invalid operational default ${parent || "(root)"}: expected an object`);
|
|
92
|
+
for (const key of Object.keys(patch)) {
|
|
93
|
+
if (!Object.hasOwn(base, key))
|
|
94
|
+
throw new Error(`Unknown operational default ${parent ? `${parent}.` : ""}${key}`);
|
|
95
|
+
}
|
|
96
|
+
return Object.freeze(Object.fromEntries(Object.entries(base).map(([key, fallback]) => {
|
|
97
|
+
const path = parent ? `${parent}.${key}` : key;
|
|
98
|
+
const value = Object.hasOwn(patch, key) ? patch[key] : fallback;
|
|
99
|
+
if (record(fallback))
|
|
100
|
+
return [key, merge(fallback, value, path)];
|
|
101
|
+
if (!validLeaf(fallback, value, path, key))
|
|
102
|
+
throw new Error(`Invalid operational default ${path}: wrong type or out of range`);
|
|
103
|
+
return [key, value];
|
|
104
|
+
})));
|
|
105
|
+
}
|
|
106
|
+
/** An explicit override path takes precedence over the process-wide environment setting. */
|
|
107
|
+
export function loadOperationalDefaults(overridePath = process.env.UNBLOCK_MEMORY_DEFAULTS_FILE) {
|
|
108
|
+
if (overridePath !== undefined && !isAbsolute(overridePath)) {
|
|
109
|
+
throw new Error("UNBLOCK_MEMORY_DEFAULTS_FILE / operational defaults path must be absolute");
|
|
110
|
+
}
|
|
111
|
+
const base = readJson(bundledPath);
|
|
112
|
+
if (!record(base))
|
|
113
|
+
throw new Error("Bundled defaults.json must be an object");
|
|
114
|
+
const result = merge(base, overridePath === undefined ? {} : readJson(overridePath));
|
|
115
|
+
const { extraction, training, quality, responseAudit } = result;
|
|
116
|
+
if (extraction.inputTargetTokens > extraction.inputLimitTokens ||
|
|
117
|
+
extraction.historyTokenBudget + extraction.promptReserveTokens >= extraction.inputTargetTokens) {
|
|
118
|
+
throw new Error("Invalid operational defaults: extraction history, reserve, target and limit token budgets conflict");
|
|
119
|
+
}
|
|
120
|
+
if (extraction.heartbeatMs >= extraction.leaseMs || training.heartbeatMs >= training.leaseMs) {
|
|
121
|
+
throw new Error("Invalid operational defaults: extraction and training heartbeats must be shorter than their leases");
|
|
122
|
+
}
|
|
123
|
+
if (quality.triageEvidenceLow > quality.triageEvidenceHigh || responseAudit.scoreLow > responseAudit.scoreHigh) {
|
|
124
|
+
throw new Error("Invalid operational defaults: low score threshold exceeds high score threshold");
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
export const DEFAULTS = loadOperationalDefaults();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RetrievalTelemetry } from "./retrieval-telemetry.js";
|
|
2
2
|
type Whisperer = "skill" | "memory" | "safety" | "myTurn";
|
|
3
|
-
type Outcome = "missing_key" | "
|
|
3
|
+
type Outcome = "missing_key" | "decision_disabled" | "no_candidates" | "rejected" | "cooldown" | "emitted" | "failed" | "timed_out" | "cancelled" | "unavailable" | "payload_limit" | "redundancy_unavailable" | "queries_generated" | "generation_fallback" | "judge_candidate_failed" | "input_too_large" | "excluded" | "no_scenarios" | "empty_request" | "no_match" | "flagged" | "missing_identity" | "partial_response";
|
|
4
4
|
/** Process-local, content-free and bounded. Agent IDs are keys, never included in snapshots. */
|
|
5
5
|
export declare class WhispererDiagnostics {
|
|
6
6
|
#private;
|
|
@@ -16,7 +16,7 @@ export declare class WhispererDiagnostics {
|
|
|
16
16
|
failed?: number | undefined;
|
|
17
17
|
timed_out?: number | undefined;
|
|
18
18
|
missing_key?: number | undefined;
|
|
19
|
-
|
|
19
|
+
decision_disabled?: number | undefined;
|
|
20
20
|
no_candidates?: number | undefined;
|
|
21
21
|
rejected?: number | undefined;
|
|
22
22
|
cooldown?: number | undefined;
|
|
@@ -41,7 +41,7 @@ export declare class WhispererDiagnostics {
|
|
|
41
41
|
failed?: number | undefined;
|
|
42
42
|
timed_out?: number | undefined;
|
|
43
43
|
missing_key?: number | undefined;
|
|
44
|
-
|
|
44
|
+
decision_disabled?: number | undefined;
|
|
45
45
|
no_candidates?: number | undefined;
|
|
46
46
|
rejected?: number | undefined;
|
|
47
47
|
cooldown?: number | undefined;
|
|
@@ -66,7 +66,7 @@ export declare class WhispererDiagnostics {
|
|
|
66
66
|
failed?: number | undefined;
|
|
67
67
|
timed_out?: number | undefined;
|
|
68
68
|
missing_key?: number | undefined;
|
|
69
|
-
|
|
69
|
+
decision_disabled?: number | undefined;
|
|
70
70
|
no_candidates?: number | undefined;
|
|
71
71
|
rejected?: number | undefined;
|
|
72
72
|
cooldown?: number | undefined;
|
|
@@ -94,7 +94,7 @@ export declare class WhispererDiagnostics {
|
|
|
94
94
|
failed?: number | undefined;
|
|
95
95
|
timed_out?: number | undefined;
|
|
96
96
|
missing_key?: number | undefined;
|
|
97
|
-
|
|
97
|
+
decision_disabled?: number | undefined;
|
|
98
98
|
no_candidates?: number | undefined;
|
|
99
99
|
rejected?: number | undefined;
|
|
100
100
|
cooldown?: number | undefined;
|
|
@@ -45,6 +45,7 @@ export declare function refreshEmotionBaselines(db: DatabaseSync, options: {
|
|
|
45
45
|
minInteractions: number;
|
|
46
46
|
now?: number;
|
|
47
47
|
recompare?: boolean;
|
|
48
|
+
expectedGenerations?: ReadonlyMap<string, number>;
|
|
48
49
|
}): {
|
|
49
50
|
snapshots: number;
|
|
50
51
|
comparisons: number;
|
|
@@ -110,8 +111,32 @@ export declare function emotionBaselineHistory(db: DatabaseSync, options?: {
|
|
|
110
111
|
cumulative: Summary;
|
|
111
112
|
}[];
|
|
112
113
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
114
|
+
* Snapshot of refresh inputs only (settings, current week, People tables, grades, and purge generations).
|
|
115
|
+
* Captures input fingerprint and per-person purge generations in one read snapshot so purges committing
|
|
116
|
+
* after the pre-pass snapshot are fenced out before refreshEmotionBaselines runs.
|
|
117
|
+
*/
|
|
118
|
+
export declare function baselineInputSnapshot(db: DatabaseSync, options: {
|
|
119
|
+
minInteractions: number;
|
|
120
|
+
now: number;
|
|
121
|
+
}): {
|
|
122
|
+
inputFingerprint: string;
|
|
123
|
+
personGenerations: Map<string, number>;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Computes input fingerprint, full fingerprint, and purge generations inside one consistent SQLite
|
|
127
|
+
* read snapshot so pre-pass fencing and post-pass certification never mix pre- and post-commit state.
|
|
128
|
+
*/
|
|
129
|
+
export declare function baselineFingerprints(db: DatabaseSync, options: {
|
|
130
|
+
minInteractions: number;
|
|
131
|
+
now: number;
|
|
132
|
+
}): {
|
|
133
|
+
inputFingerprint: string;
|
|
134
|
+
fullFingerprint: string;
|
|
135
|
+
personGenerations: Map<string, number>;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Changes whenever a refresh input could: grades, links, people, purge generations, stored results,
|
|
139
|
+
* the current week, grades crossing `now`, or settings. Equal fingerprints mean a refresh would write nothing.
|
|
115
140
|
*/
|
|
116
141
|
export declare function baselineFingerprint(db: DatabaseSync, options: {
|
|
117
142
|
minInteractions: number;
|
|
@@ -119,7 +144,7 @@ export declare function baselineFingerprint(db: DatabaseSync, options: {
|
|
|
119
144
|
}): string;
|
|
120
145
|
/**
|
|
121
146
|
* Delete one person's baselines and assessment history. With `grades`, also erase their six
|
|
122
|
-
* probabilities and person link, keeping a tombstone so the reply is never sent to
|
|
147
|
+
* probabilities and person link, keeping a tombstone so the reply is never sent to the decision model again.
|
|
123
148
|
*/
|
|
124
149
|
export declare function purgeEmotionProfile(db: DatabaseSync, personId: string, options?: {
|
|
125
150
|
grades?: boolean;
|