@unblocklabs/unblock-memory 0.12.2 → 0.13.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/dist/src/analysis.js +1 -1
- package/dist/src/cluster-review.d.ts +2 -0
- package/dist/src/cluster-review.js +3 -3
- package/dist/src/config.d.ts +9 -6
- package/dist/src/config.js +31 -20
- package/dist/src/curation.d.ts +1 -1
- package/dist/src/decision-client.d.ts +39 -0
- package/dist/src/decision-client.js +74 -0
- package/dist/src/{typesafe.d.ts → decision-ranking.d.ts} +15 -18
- package/dist/src/decision-ranking.js +154 -0
- package/dist/src/{typesafe-review.d.ts → decision-review.d.ts} +13 -9
- package/dist/src/decision-review.js +192 -0
- package/dist/src/diagnostics.d.ts +5 -5
- package/dist/src/emotion-baselines.d.ts +28 -3
- package/dist/src/emotion-baselines.js +309 -113
- package/dist/src/evidence-review.d.ts +22 -8
- package/dist/src/evidence-review.js +4 -4
- package/dist/src/extraction-chunk.d.ts +3 -0
- package/dist/src/extraction-chunk.js +23 -5
- package/dist/src/extraction-model.d.ts +2 -0
- package/dist/src/extraction-model.js +73 -48
- package/dist/src/extraction-runtime.d.ts +3 -1
- package/dist/src/extraction-runtime.js +43 -16
- package/dist/src/extraction-source.d.ts +1 -1
- package/dist/src/extraction-source.js +19 -11
- package/dist/src/extraction-store.d.ts +28 -3
- package/dist/src/extraction-store.js +145 -23
- package/dist/src/extraction-worker.d.ts +1 -0
- package/dist/src/extraction-worker.js +246 -93
- package/dist/src/inside-out-runtime.js +41 -29
- package/dist/src/inside-out-store.d.ts +2 -2
- package/dist/src/inside-out-store.js +110 -69
- package/dist/src/inside-out.d.ts +10 -9
- package/dist/src/inside-out.js +190 -105
- package/dist/src/manager.d.ts +22 -9
- package/dist/src/manager.js +275 -169
- 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 +189 -127
- package/dist/src/my-turn.d.ts +1 -1
- package/dist/src/my-turn.js +87 -68
- package/dist/src/people-background.d.ts +4 -0
- package/dist/src/people-background.js +29 -6
- package/dist/src/people-dossier-review.d.ts +20 -8
- package/dist/src/people-dossier-review.js +11 -8
- 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 +106 -57
- package/dist/src/people-learning-inventory.d.ts +1 -0
- package/dist/src/people-learning-inventory.js +281 -171
- 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 +423 -204
- 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 +8 -6
- package/dist/src/people-primer.d.ts +3 -1
- package/dist/src/people-primer.js +61 -44
- package/dist/src/people-store.d.ts +18 -21
- package/dist/src/people-store.js +186 -63
- package/dist/src/people-tools.js +136 -92
- package/dist/src/plugin.js +16 -16
- package/dist/src/quality-audit.d.ts +2 -0
- package/dist/src/quality-audit.js +8 -7
- package/dist/src/query-generator.d.ts +1 -1
- package/dist/src/query-generator.js +15 -8
- package/dist/src/response-audit.d.ts +1 -1
- package/dist/src/response-audit.js +76 -43
- package/dist/src/response-episodes.d.ts +1 -1
- package/dist/src/response-episodes.js +12 -17
- package/dist/src/response-judge.d.ts +151 -145
- package/dist/src/response-judge.js +535 -204
- package/dist/src/response-reviews.d.ts +29 -1
- package/dist/src/response-reviews.js +110 -13
- package/dist/src/response-runtime.js +8 -8
- 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 +332 -210
- package/dist/src/response-text.d.ts +2 -0
- package/dist/src/response-text.js +182 -36
- package/dist/src/review-tools.d.ts +8 -2
- package/dist/src/review-tools.js +18 -18
- package/dist/src/runtime.d.ts +7 -4
- package/dist/src/runtime.js +624 -98
- package/dist/src/safety-whisperer.d.ts +2 -2
- package/dist/src/safety-whisperer.js +88 -71
- package/dist/src/session-sync.d.ts +3 -1
- package/dist/src/session-sync.js +200 -95
- package/dist/src/skill-whisperer.d.ts +1 -1
- package/dist/src/skill-whisperer.js +52 -30
- package/dist/src/training-gate.d.ts +8 -21
- package/dist/src/training-gate.js +32 -35
- package/dist/src/training-judge.d.ts +9 -16
- package/dist/src/training-judge.js +5 -5
- package/dist/src/training-queries.d.ts +13 -8
- package/dist/src/training-queries.js +370 -228
- package/dist/src/training-retrieval.d.ts +14 -24
- package/dist/src/training-retrieval.js +182 -136
- 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 +138 -50
- package/dist/src/training.js +8 -11
- package/dist/src/whisperer-context.d.ts +14 -0
- package/dist/src/whisperer-context.js +22 -1
- package/docs/configuration.md +76 -63
- package/docs/extraction.md +9 -7
- 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 +40 -37
- package/openclaw.plugin.json +40 -26
- package/package.json +3 -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
|
@@ -14,83 +14,132 @@ function containsDeclaration(actual, expected) {
|
|
|
14
14
|
return fields && source ? Object.entries(fields).every(([key, value]) => containsDeclaration(source[key], value))
|
|
15
15
|
: isDeepStrictEqual(actual, expected);
|
|
16
16
|
}
|
|
17
|
+
function parseDeclarationKey(value) {
|
|
18
|
+
if (typeof value !== "string" || !value.startsWith(PREFIX))
|
|
19
|
+
return undefined;
|
|
20
|
+
const rest = value.slice(PREFIX.length);
|
|
21
|
+
const split = rest.lastIndexOf(":");
|
|
22
|
+
if (split <= 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
const agentId = rest.slice(0, split), kind = rest.slice(split + 1);
|
|
25
|
+
if (kind !== "nightly" && kind !== "weekly")
|
|
26
|
+
return undefined;
|
|
27
|
+
return { agentId, kind };
|
|
28
|
+
}
|
|
29
|
+
function matchesLearningJob(job, agentId, kind, key, legacyJobIds) {
|
|
30
|
+
if (job.agentId !== agentId)
|
|
31
|
+
return false;
|
|
32
|
+
if (job.declarationKey === key || job.name === key || job.name === legacyNames[kind])
|
|
33
|
+
return true;
|
|
34
|
+
if (!legacyJobIds?.includes(String(job.id)))
|
|
35
|
+
return false;
|
|
36
|
+
const payload = record(job.payload);
|
|
37
|
+
return payload?.kind === "agentTurn" &&
|
|
38
|
+
String(payload.message).includes(`people-${kind === "nightly" ? "nightly-dreaming" : "weekly-validation"}.md`);
|
|
39
|
+
}
|
|
17
40
|
export const LEARNING_TOOLS = ["read", "memory_people_learning", "memory_people_inspect", "memory_people_update",
|
|
18
41
|
"memory_people_prime", "memory_search", "memory_get"];
|
|
19
42
|
/** Service-owned cron, not bundled-only scheduleSessionTurn.
|
|
20
43
|
* Stable declarations make a lost add response/reload safe. Legacy history stays on disabled originals.
|
|
21
44
|
*/
|
|
22
|
-
export async function reconcilePeopleLearning(cron, cfg, config, active = () => true) {
|
|
45
|
+
export async function reconcilePeopleLearning(cron, cfg, config, active = () => true, onRecognize) {
|
|
46
|
+
const all = await cron.list({ includeDisabled: true });
|
|
47
|
+
if (!Array.isArray(all))
|
|
48
|
+
throw new Error("Unsupported service cron.list response");
|
|
23
49
|
const jobs = [];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
const recognized = new Map();
|
|
51
|
+
for (const item of all) {
|
|
52
|
+
const job = record(item);
|
|
53
|
+
if (!job || !nonBlank(job.id))
|
|
54
|
+
throw new Error("Invalid cron job inventory");
|
|
55
|
+
jobs.push(job);
|
|
56
|
+
const parsed = parseDeclarationKey(job.declarationKey);
|
|
57
|
+
if (parsed && job.agentId === parsed.agentId) {
|
|
58
|
+
const id = String(job.id);
|
|
59
|
+
recognized.set(`${parsed.agentId}:${id}`, { id, agentId: parsed.agentId, kind: parsed.kind });
|
|
33
60
|
}
|
|
34
61
|
}
|
|
35
|
-
const
|
|
62
|
+
const planned = [];
|
|
36
63
|
for (const agentId of listAgentIds(cfg)) {
|
|
37
64
|
const options = learningForAgent(config, agentId);
|
|
38
65
|
for (const kind of ["nightly", "weekly"]) {
|
|
39
66
|
const key = `${PREFIX}${agentId}:${kind}`;
|
|
40
|
-
const matches = jobs.filter(job => job
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const primary = matches.find(job => job.declarationKey === key);
|
|
45
|
-
const legacy = matches.filter(job => job.declarationKey !== key);
|
|
46
|
-
const migrationPaused = config.agents?.[agentId]?.enabled !== true &&
|
|
47
|
-
(primary ? String(primary.description).includes("[migration-paused]") : legacy.length > 0 && legacy.every(job => job.enabled === false));
|
|
48
|
-
const enabled = options.enabled && options[kind] && !migrationPaused;
|
|
49
|
-
if (!primary && !legacy.length && !enabled)
|
|
50
|
-
continue;
|
|
51
|
-
const desired = {
|
|
52
|
-
declarationKey: key, agentId, name: key,
|
|
53
|
-
description: "Plugin-owned private People Whisperer review; opt out in people.learning." + (migrationPaused ? " [migration-paused]" : ""),
|
|
54
|
-
enabled, schedule: { kind: "cron", expr: options[`${kind}Schedule`],
|
|
55
|
-
tz: options.timezone ?? resolveTimezone(cfg.agents?.defaults?.userTimezone), staggerMs: 0 },
|
|
56
|
-
sessionTarget: "isolated", wakeMode: "now", deleteAfterRun: false,
|
|
57
|
-
payload: { kind: "agentTurn", message: peopleLearningPrompt(kind, agentId), timeoutSeconds: kind === "nightly" ? 2700 : 3600,
|
|
58
|
-
toolsAllow: LEARNING_TOOLS },
|
|
59
|
-
delivery: { mode: "none" }, failureAlert: false,
|
|
60
|
-
};
|
|
61
|
-
if (!active())
|
|
62
|
-
return result;
|
|
63
|
-
let id;
|
|
64
|
-
if (primary) {
|
|
65
|
-
id = String(primary.id);
|
|
67
|
+
const matches = jobs.filter(job => matchesLearningJob(job, agentId, kind, key, options.legacyJobIds));
|
|
68
|
+
for (const match of matches) {
|
|
69
|
+
const id = String(match.id);
|
|
70
|
+
recognized.set(`${agentId}:${id}`, { id, agentId, kind });
|
|
66
71
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
planned.push({ agentId, kind, options, key, matches });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Surface durably declared AND exact agent-scoped legacy matches immediately
|
|
76
|
+
// before any scheduler mutation so partial-reconcile or cron.add failures
|
|
77
|
+
// never leave active cron runs unrecognized by private-session hooks.
|
|
78
|
+
if (recognized.size && active())
|
|
79
|
+
onRecognize?.([...recognized.values()], false);
|
|
80
|
+
const result = [], owned = new Set();
|
|
81
|
+
for (const { agentId, kind, options, key, matches } of planned) {
|
|
82
|
+
const primary = matches.find(job => job.declarationKey === key);
|
|
83
|
+
const legacy = matches.filter(job => job.declarationKey !== key);
|
|
84
|
+
const migrationPaused = config.agents?.[agentId]?.enabled !== true &&
|
|
85
|
+
(primary ? String(primary.description).includes("[migration-paused]") : legacy.length > 0 && legacy.every(job => job.enabled === false));
|
|
86
|
+
const enabled = options.enabled && options[kind] && !migrationPaused;
|
|
87
|
+
if (!primary && !legacy.length && !enabled)
|
|
88
|
+
continue;
|
|
89
|
+
const desired = {
|
|
90
|
+
declarationKey: key, agentId, name: key,
|
|
91
|
+
description: "Plugin-owned private People Whisperer review; opt out in people.learning." + (migrationPaused ? " [migration-paused]" : ""),
|
|
92
|
+
enabled, schedule: {
|
|
93
|
+
kind: "cron", expr: options[`${kind}Schedule`],
|
|
94
|
+
tz: options.timezone ?? resolveTimezone(cfg.agents?.defaults?.userTimezone), staggerMs: 0,
|
|
95
|
+
},
|
|
96
|
+
sessionTarget: "isolated", wakeMode: "now", deleteAfterRun: false,
|
|
97
|
+
payload: {
|
|
98
|
+
kind: "agentTurn", message: peopleLearningPrompt(kind, agentId), timeoutSeconds: kind === "nightly" ? 2700 : 3600,
|
|
99
|
+
toolsAllow: LEARNING_TOOLS,
|
|
100
|
+
},
|
|
101
|
+
delivery: { mode: "none" }, failureAlert: false,
|
|
102
|
+
};
|
|
103
|
+
if (!active())
|
|
104
|
+
return result;
|
|
105
|
+
let id;
|
|
106
|
+
if (primary) {
|
|
107
|
+
id = String(primary.id);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// declarationKey is creation-only in the installed SDK. Never "migrate"
|
|
111
|
+
// it through update, which silently ignores that field. Create disabled
|
|
112
|
+
// before pausing the originals so a lost reply cannot leave two runners.
|
|
113
|
+
const added = record(await cron.add({ ...desired, enabled: false }));
|
|
114
|
+
const addedId = nonBlank(added?.id) ?? nonBlank(record(added?.job)?.id);
|
|
115
|
+
if (!addedId)
|
|
116
|
+
throw new Error("Cron creation unconfirmed; retry reconciliation with the same declaration key");
|
|
117
|
+
id = addedId;
|
|
118
|
+
const created = { id, agentId, kind };
|
|
119
|
+
recognized.set(`${agentId}:${id}`, created);
|
|
120
|
+
if (active())
|
|
121
|
+
onRecognize?.([created], false);
|
|
87
122
|
}
|
|
123
|
+
owned.add(id);
|
|
124
|
+
const entry = { id, agentId, kind };
|
|
125
|
+
recognized.set(`${agentId}:${id}`, entry);
|
|
126
|
+
result.push(entry);
|
|
127
|
+
// Keep duplicate IDs and histories recoverable, but prevent a second run.
|
|
128
|
+
for (const duplicate of matches)
|
|
129
|
+
if (duplicate.id !== id && duplicate.enabled !== false && active()) {
|
|
130
|
+
await cron.update(String(duplicate.id), { enabled: false });
|
|
131
|
+
}
|
|
132
|
+
const { declarationKey: _key, ...patch } = desired;
|
|
133
|
+
if (active() && (!primary || !containsDeclaration(primary, patch)))
|
|
134
|
+
await cron.update(id, patch);
|
|
88
135
|
}
|
|
89
136
|
// Only this exact namespace is owned. Never sweep other agents' maintenance jobs.
|
|
90
137
|
for (const job of jobs)
|
|
91
138
|
if (String(job.declarationKey ?? "").startsWith(PREFIX) && !owned.has(String(job.id)) && job.enabled !== false && active()) {
|
|
92
139
|
await cron.update(String(job.id), { enabled: false });
|
|
93
140
|
}
|
|
141
|
+
if (active())
|
|
142
|
+
onRecognize?.([...recognized.values()], true);
|
|
94
143
|
return result;
|
|
95
144
|
}
|
|
96
145
|
export function learningSession(sessionKey, jobs) {
|
|
@@ -44,6 +44,7 @@ export type ReviewManifest = {
|
|
|
44
44
|
inventoryPending?: boolean;
|
|
45
45
|
};
|
|
46
46
|
export declare function dossierAssertions(personId: string, dossier: PersonDossier): ReviewAssertion[];
|
|
47
|
+
/** Atomically publishes a flushed 0o600 private JSON artifact; never accepts a truncated partial file. */
|
|
47
48
|
export declare function privateJson(root: string, name: string, value: unknown): string;
|
|
48
49
|
export declare function inventoryPeople(options: {
|
|
49
50
|
agentId: string;
|