@remnic/plugin-openclaw 1.0.34 → 1.0.36

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.
Files changed (87) hide show
  1. package/README.md +59 -10
  2. package/dist/{calibration-JD4AU7FB.js → calibration-RKL2LRW4.js} +4 -4
  3. package/dist/{capsule-cli-GBM3WPAM.js → capsule-cli-EHZPMXBC.js} +2 -2
  4. package/dist/{capsule-crypto-K3IRTKRH.js → capsule-crypto-JS67OSWM.js} +3 -3
  5. package/dist/capsule-export-YPDWRB3C.js +17 -0
  6. package/dist/capsule-import-SWPOFG6F.js +16 -0
  7. package/dist/{capsule-merge-IWOQ34KL.js → capsule-merge-YXAF7ZJW.js} +7 -7
  8. package/dist/{causal-chain-WYN5QOPS.js → causal-chain-BVTOWZKC.js} +4 -4
  9. package/dist/{causal-consolidation-DSLFN64P.js → causal-consolidation-DRPM2KOE.js} +13 -10
  10. package/dist/{causal-retrieval-NZHQOZOE.js → causal-retrieval-XAP6QKHZ.js} +4 -5
  11. package/dist/{causal-trajectory-graph-VBPE2WPM.js → causal-trajectory-graph-ZWQWZ7N5.js} +2 -2
  12. package/dist/{chunk-5LE4HTVL.js → chunk-25J4PXDH.js} +0 -18
  13. package/dist/{chunk-FGTYFLL5.js → chunk-3IHGISUN.js} +29 -32
  14. package/dist/{chunk-6UFI73TJ.js → chunk-3IKMUNW5.js} +53 -46
  15. package/dist/{chunk-EXDYWXMB.js → chunk-4XDQ3KEC.js} +1 -2
  16. package/dist/{chunk-4UA6KMRO.js → chunk-6O3H3DPL.js} +2 -2
  17. package/dist/{chunk-7NMHI4IC.js → chunk-BLC3RQNV.js} +5 -555
  18. package/dist/{chunk-4G2XCSD2.js → chunk-BZ4EYURA.js} +0 -5
  19. package/dist/{chunk-4LYQ4ONL.js → chunk-E4RM7637.js} +1 -1
  20. package/dist/{chunk-TDRJVMUP.js → chunk-EH4AXGRO.js} +0 -12
  21. package/dist/{chunk-ZXLYEVOP.js → chunk-G3CZA4SD.js} +60 -362
  22. package/dist/chunk-I2KLQ2HA.js +22 -0
  23. package/dist/chunk-IO5WWY6A.js +156 -0
  24. package/dist/{contradiction-scan-U3QKHWQN.js → chunk-JC3FCKYL.js} +191 -87
  25. package/dist/{chunk-SVSQAG6M.js → chunk-KC7KSQR4.js} +47 -28
  26. package/dist/chunk-LZCGPRHS.js +228 -0
  27. package/dist/{chunk-CXM7EBAO.js → chunk-MXFJXUHC.js} +1 -1
  28. package/dist/{chunk-L6I4MQKO.js → chunk-NNAN63QK.js} +6 -6
  29. package/dist/{chunk-VRGUUHBV.js → chunk-NUWDSTP7.js} +1 -1
  30. package/dist/{chunk-6OJAU466.js → chunk-QMUQV5NP.js} +0 -1
  31. package/dist/{chunk-LLUROTZJ.js → chunk-QQXJODFL.js} +9 -9
  32. package/dist/{chunk-6F6EKSVP.js → chunk-QXXEF7VI.js} +1 -1
  33. package/dist/{chunk-NDZNURDM.js → chunk-SEGEX7W4.js} +73 -241
  34. package/dist/{chunk-7NUFIRM3.js → chunk-SWOYEQN2.js} +97 -21
  35. package/dist/chunk-TH5FF5SC.js +16 -0
  36. package/dist/chunk-UZJ7EERS.js +272 -0
  37. package/dist/chunk-YJYZMLD5.js +360 -0
  38. package/dist/{chunk-NKVIN6RD.js → chunk-YKV4EFUI.js} +84 -2
  39. package/dist/{chunk-SSFTU6LP.js → chunk-ZS6VABML.js} +4 -4
  40. package/dist/{cipher-VHAFCG7Z.js → cipher-E23BHBSO.js} +1 -1
  41. package/dist/{consolidation-undo-5ZSX4MWO.js → consolidation-undo-FKJZCJHS.js} +2 -2
  42. package/dist/contradiction-review-WJRWNQ5N.js +29 -0
  43. package/dist/contradiction-scan-5X423QGT.js +12 -0
  44. package/dist/{dreams-ledger-3I52ISYR.js → dreams-ledger-KDX44I7R.js} +1 -1
  45. package/dist/{engine-57HLTQBN.js → engine-5P774HTZ.js} +6 -6
  46. package/dist/{extraction-judge-telemetry-GHOTVYMP.js → extraction-judge-telemetry-O4ZVGLTU.js} +1 -1
  47. package/dist/{fallback-llm-33SPYXQY.js → fallback-llm-43UMEXNJ.js} +3 -3
  48. package/dist/{first-start-migration-I24M2JEE.js → first-start-migration-H2SAXAGR.js} +4 -4
  49. package/dist/{forget-NI4RBDPB.js → forget-ZECIDNL5.js} +1 -1
  50. package/dist/{fs-utils-PZRI2HDZ.js → fs-utils-OYXSZSVV.js} +12 -2
  51. package/dist/{graph-edge-decay-5CVKWBYH.js → graph-edge-decay-24ZKD5QL.js} +5 -5
  52. package/dist/index.js +7187 -71983
  53. package/dist/{kdf-H5B23ZM2.js → kdf-RXKIWHRU.js} +1 -1
  54. package/dist/legacy-hook-compat-QHHKF4GK.js +2 -0
  55. package/dist/{logger-TNOKCH7X.js → logger-XG7JKLPS.js} +1 -1
  56. package/dist/{memory-governance-FEQCA35V.js → memory-governance-6K4M4YXD.js} +5 -5
  57. package/dist/{metadata-JAGIWHEA.js → metadata-WK2TRPYZ.js} +1 -1
  58. package/dist/{migrate-from-identity-anchor-7MMSPEUM.js → migrate-from-identity-anchor-SNDNKHZD.js} +1 -1
  59. package/dist/path-ZKO74XXC.js +7 -0
  60. package/dist/{peers-KRFXWRQ6.js → peers-W53WSDXG.js} +1 -1
  61. package/dist/{purge-XN2VSPZ2.js → purge-IKJISXEQ.js} +1 -1
  62. package/dist/resolution-BN35OXDS.js +11 -0
  63. package/dist/{secure-store-A4NGCNXV.js → secure-store-F75I54O5.js} +3 -3
  64. package/dist/{state-PVISYXRH.js → state-4ITLYMAU.js} +1 -1
  65. package/dist/{state-store-N6TFBFSP.js → state-store-ET3ADVY5.js} +3 -3
  66. package/dist/{storage-R3V6ZFQT.js → storage-5EY6T7ON.js} +3 -3
  67. package/dist/{tier-stats-IZNW66NC.js → tier-stats-ZRQBV6G2.js} +4 -4
  68. package/dist/{trace-NJESSGH7.js → trace-IL2Y34EH.js} +1 -1
  69. package/dist/{tui-MGK2LYJY.js → tui-7KRDCMYK.js} +1 -1
  70. package/dist/{types-R4DO7AKM.js → types-7L34HYDW.js} +3 -3
  71. package/openclaw.plugin.json +153 -20
  72. package/package.json +18 -9
  73. package/scripts/faiss_index.py +756 -0
  74. package/scripts/faiss_requirements.txt +3 -0
  75. package/dist/capsule-export-IXVERCQG.js +0 -17
  76. package/dist/capsule-import-IA6VIOPQ.js +0 -16
  77. package/dist/chunk-3GUF7RQI.js +0 -559
  78. package/dist/chunk-7OQEPGQF.js +0 -533
  79. package/dist/chunk-DIZW6H5J.js +0 -136
  80. package/dist/chunk-FQRSVYY4.js +0 -110
  81. package/dist/chunk-GUSMRW4H.js +0 -12
  82. package/dist/chunk-MLKGABMK.js +0 -9
  83. package/dist/chunk-WPINX4MF.js +0 -380
  84. package/dist/contradiction-review-SVGBS3V5.js +0 -21
  85. package/dist/legacy-hook-compat-XQ7FP6FV.js +0 -35
  86. package/dist/path-JIEGNWFL.js +0 -7
  87. package/dist/resolution-YITUVUTH.js +0 -100
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  external_exports
3
- } from "./chunk-EXDYWXMB.js";
3
+ } from "./chunk-4XDQ3KEC.js";
4
4
  import {
5
5
  StorageManager,
6
6
  parseContinuityImprovementLoops,
7
7
  sanitizeMemoryContent
8
- } from "./chunk-ZXLYEVOP.js";
8
+ } from "./chunk-G3CZA4SD.js";
9
9
  import {
10
10
  log
11
11
  } from "./chunk-UFU5GGGA.js";
12
12
  import {
13
13
  expandTildePath
14
- } from "./chunk-TDRJVMUP.js";
14
+ } from "./chunk-EH4AXGRO.js";
15
15
 
16
16
  // ../remnic-core/src/compounding/engine.ts
17
17
  import { createHash } from "crypto";
@@ -48,558 +48,9 @@ var SharedFeedbackEntrySchema = external_exports.object({
48
48
  evidenceWindowEnd: external_exports.string().min(8).optional(),
49
49
  refs: external_exports.array(external_exports.string()).optional()
50
50
  });
51
- function safeSlug(s) {
52
- let slug = s.toLowerCase().replace(/[^a-z0-9]+/g, "-");
53
- let start = 0;
54
- while (start < slug.length && slug[start] === "-") start++;
55
- let end = slug.length;
56
- while (end > start && slug[end - 1] === "-") end--;
57
- return slug.slice(start, end).slice(0, 80) || "output";
58
- }
59
- function ymd(d) {
60
- return d.toISOString().slice(0, 10);
61
- }
62
- var CROSS_SIGNAL_STOPWORDS = /* @__PURE__ */ new Set([
63
- "a",
64
- "an",
65
- "and",
66
- "are",
67
- "as",
68
- "at",
69
- "be",
70
- "by",
71
- "for",
72
- "from",
73
- "has",
74
- "have",
75
- "in",
76
- "is",
77
- "it",
78
- "of",
79
- "on",
80
- "or",
81
- "that",
82
- "the",
83
- "this",
84
- "to",
85
- "was",
86
- "were",
87
- "with",
88
- "agent",
89
- "output",
90
- "today",
91
- "daily",
92
- "notes",
93
- "note",
94
- "summary"
95
- ]);
96
- function extractTopicTokens(text, maxTokens = 12) {
97
- const seen = /* @__PURE__ */ new Set();
98
- const out = [];
99
- const tokens = text.toLowerCase().replace(/[^a-z0-9\s]/g, " ").split(/\s+/).map((token) => token.trim()).filter((token) => token.length >= 4).filter((token) => !CROSS_SIGNAL_STOPWORDS.has(token));
100
- for (const token of tokens) {
101
- if (seen.has(token)) continue;
102
- seen.add(token);
103
- out.push(token);
104
- if (out.length >= maxTokens) break;
105
- }
106
- return out;
107
- }
108
- function stripYamlFrontmatter(text) {
109
- if (!text.startsWith("---\n")) return text;
110
- const closing = text.indexOf("\n---\n", 4);
111
- if (closing === -1) return text;
112
- return text.slice(closing + 5);
113
- }
114
- function semanticRoot(token) {
115
- let root = token.toLowerCase();
116
- if (root.endsWith("izations") && root.length > 9) {
117
- root = `${root.slice(0, -8)}ize`;
118
- } else if (root.endsWith("ization") && root.length > 8) {
119
- root = `${root.slice(0, -7)}ize`;
120
- } else if (root.endsWith("isations") && root.length > 9) {
121
- root = `${root.slice(0, -8)}ise`;
122
- } else if (root.endsWith("isation") && root.length > 8) {
123
- root = `${root.slice(0, -7)}ise`;
124
- } else {
125
- const suffixes = [
126
- "ations",
127
- "ation",
128
- "ments",
129
- "ment",
130
- "ingly",
131
- "edly",
132
- "ings",
133
- "ing",
134
- "ers",
135
- "er",
136
- "ies",
137
- "ied",
138
- "ions",
139
- "ion",
140
- "es",
141
- "ed",
142
- "s"
143
- ];
144
- for (const suffix of suffixes) {
145
- if (root.length > suffix.length + 3 && root.endsWith(suffix)) {
146
- root = root.slice(0, -suffix.length);
147
- break;
148
- }
149
- }
150
- }
151
- if (root.length > 4 && root.endsWith("e")) {
152
- root = root.slice(0, -1);
153
- }
154
- return root;
155
- }
156
- function mergeOverlaps(base, extra) {
157
- const merged = /* @__PURE__ */ new Map();
158
- for (const entry of [...base, ...extra]) {
159
- const existing = merged.get(entry.token);
160
- if (existing) {
161
- for (const agent of entry.agents) existing.agents.add(agent);
162
- for (const sourcePath of entry.sourcePaths) existing.sourcePaths.add(sourcePath);
163
- } else {
164
- merged.set(entry.token, {
165
- agents: new Set(entry.agents),
166
- sourcePaths: new Set(entry.sourcePaths)
167
- });
168
- }
169
- }
170
- return [...merged.entries()].map(([token, value]) => ({
171
- token,
172
- agents: [...value.agents].sort(),
173
- sourcePaths: [...value.sourcePaths].sort(),
174
- agentCount: value.agents.size
175
- })).filter((entry) => entry.agentCount >= 2).sort((a, b) => b.agentCount - a.agentCount || a.token.localeCompare(b.token));
176
- }
177
- async function computeSemanticOverlapCandidates(sources, maxCandidates, timeoutAtMs) {
178
- const tokenRows = [];
179
- for (const source of sources) {
180
- for (const token of source.topics) {
181
- if (Date.now() >= timeoutAtMs) return { overlaps: [], candidateCount: tokenRows.length, timedOut: true };
182
- await new Promise((resolve) => setImmediate(resolve));
183
- tokenRows.push({ token, agent: source.agent, path: source.path });
184
- if (tokenRows.length >= maxCandidates) break;
185
- }
186
- if (tokenRows.length >= maxCandidates) break;
187
- }
188
- const byRoot = /* @__PURE__ */ new Map();
189
- for (const row of tokenRows) {
190
- if (Date.now() >= timeoutAtMs) return { overlaps: [], candidateCount: tokenRows.length, timedOut: true };
191
- await new Promise((resolve) => setImmediate(resolve));
192
- const root = semanticRoot(row.token);
193
- if (root.length < 4) continue;
194
- const rootGroup = byRoot.get(root) ?? /* @__PURE__ */ new Map();
195
- const tokenGroup = rootGroup.get(row.token) ?? { agents: /* @__PURE__ */ new Set(), paths: /* @__PURE__ */ new Set() };
196
- tokenGroup.agents.add(row.agent);
197
- tokenGroup.paths.add(row.path);
198
- rootGroup.set(row.token, tokenGroup);
199
- byRoot.set(root, rootGroup);
200
- }
201
- const overlaps = [];
202
- for (const [root, tokenMap] of byRoot.entries()) {
203
- if (Date.now() >= timeoutAtMs) return { overlaps: [], candidateCount: tokenRows.length, timedOut: true };
204
- await new Promise((resolve) => setImmediate(resolve));
205
- if (tokenMap.size < 2) continue;
206
- const agents = /* @__PURE__ */ new Set();
207
- const sourcePaths = /* @__PURE__ */ new Set();
208
- for (const value of tokenMap.values()) {
209
- for (const agent of value.agents) agents.add(agent);
210
- for (const sourcePath of value.paths) sourcePaths.add(sourcePath);
211
- }
212
- if (agents.size < 2) continue;
213
- overlaps.push({
214
- token: `semantic:${root}`,
215
- agents: [...agents].sort(),
216
- sourcePaths: [...sourcePaths].sort(),
217
- agentCount: agents.size
218
- });
219
- }
220
- overlaps.sort((a, b) => b.agentCount - a.agentCount || a.token.localeCompare(b.token));
221
- return {
222
- overlaps,
223
- candidateCount: tokenRows.length,
224
- timedOut: false
225
- };
226
- }
227
- async function computeSemanticOverlapsWithTimeout(sources, timeoutMs, maxCandidates) {
228
- const safeTimeoutMs = Math.max(1, Math.floor(timeoutMs));
229
- const safeMaxCandidates = Math.max(0, Math.floor(maxCandidates));
230
- if (safeMaxCandidates === 0 || sources.length === 0) {
231
- return { overlaps: [], candidateCount: 0, timedOut: false };
232
- }
233
- const timeoutAtMs = Date.now() + safeTimeoutMs;
234
- return computeSemanticOverlapCandidates(sources, safeMaxCandidates, timeoutAtMs);
235
- }
236
- function feedbackDecisionPriority(decision) {
237
- switch (decision) {
238
- case "rejected":
239
- return 3;
240
- case "approved_with_feedback":
241
- return 2;
242
- case "approved":
243
- return 1;
244
- }
245
- }
246
- function feedbackSeverityPriority(severity) {
247
- switch (severity) {
248
- case "high":
249
- return 3;
250
- case "medium":
251
- return 2;
252
- case "low":
253
- return 1;
254
- default:
255
- return 0;
256
- }
257
- }
258
- function compareFeedbackPriority(a, b) {
259
- return feedbackDecisionPriority(b.decision) - feedbackDecisionPriority(a.decision) || feedbackSeverityPriority(b.severity) - feedbackSeverityPriority(a.severity) || a.date.localeCompare(b.date);
260
- }
261
- function formatFeedbackLine(entry) {
262
- const extras = [`feedback: ${entry.date}`];
263
- if (entry.severity) extras.push(`severity: ${entry.severity}`);
264
- if (entry.refs?.length) extras.push(`refs: ${entry.refs.join(", ")}`);
265
- return `- [${entry.agent}] ${entry.decision}: ${entry.reason} [${extras.join("; ")}]`;
266
- }
267
- function formatOverlapLine(entry) {
268
- return `- \`${entry.token}\` (${entry.agentCount} agents: ${entry.agents.join(", ")}) [sources: ${entry.sourcePaths.join(", ")}]`;
269
- }
270
51
  function resolveSharedContextDir(config) {
271
52
  return typeof config.sharedContextDir === "string" && config.sharedContextDir.length > 0 ? expandTildePath(config.sharedContextDir) : path.join(expandTildePath(config.workspaceDir), "shared-context");
272
53
  }
273
- var SharedContextManager = class {
274
- constructor(config) {
275
- this.config = config;
276
- const base = resolveSharedContextDir(config);
277
- this.dir = base;
278
- this.prioritiesPath = path.join(base, "priorities.md");
279
- this.prioritiesInboxPath = path.join(base, "priorities.inbox.md");
280
- this.outputsDir = path.join(base, "agent-outputs");
281
- this.roundtableDir = path.join(base, "roundtable");
282
- this.feedbackDir = path.join(base, "feedback");
283
- this.feedbackInboxPath = path.join(this.feedbackDir, "inbox.jsonl");
284
- this.crossSignalsDir = path.join(base, "cross-signals");
285
- }
286
- config;
287
- dir;
288
- prioritiesPath;
289
- prioritiesInboxPath;
290
- outputsDir;
291
- roundtableDir;
292
- feedbackDir;
293
- feedbackInboxPath;
294
- crossSignalsDir;
295
- async ensureStructure() {
296
- await mkdir(this.dir, { recursive: true });
297
- await mkdir(this.outputsDir, { recursive: true });
298
- await mkdir(this.roundtableDir, { recursive: true });
299
- await mkdir(this.feedbackDir, { recursive: true });
300
- await mkdir(this.crossSignalsDir, { recursive: true });
301
- await mkdir(path.join(this.dir, "staging"), { recursive: true });
302
- await mkdir(path.join(this.dir, "kpis"), { recursive: true });
303
- await mkdir(path.join(this.dir, "calendar"), { recursive: true });
304
- await mkdir(path.join(this.dir, "content-calendar"), { recursive: true });
305
- await this.ensureFile(
306
- this.prioritiesPath,
307
- [
308
- "# Priorities",
309
- "",
310
- "This is the shared priority stack. Agents should read this before acting.",
311
- "",
312
- "## Current",
313
- "- (empty)",
314
- "",
315
- "## Notes",
316
- "- (empty)",
317
- ""
318
- ].join("\n")
319
- );
320
- await this.ensureFile(
321
- this.prioritiesInboxPath,
322
- [
323
- "# Priorities Inbox",
324
- "",
325
- "Append-only inbox. Curator merges into priorities.md.",
326
- ""
327
- ].join("\n")
328
- );
329
- await this.ensureFile(this.feedbackInboxPath, "");
330
- }
331
- async ensureFile(fp, content) {
332
- try {
333
- await stat(fp);
334
- } catch {
335
- await writeFile(fp, content, "utf-8");
336
- }
337
- }
338
- async readPriorities() {
339
- try {
340
- return await fileReader(this.prioritiesPath, "utf-8");
341
- } catch {
342
- return "";
343
- }
344
- }
345
- async readLatestRoundtable() {
346
- try {
347
- const files = (await readdir(this.roundtableDir)).filter((f) => f.endsWith(".md")).sort().reverse();
348
- const fp = files[0] ? path.join(this.roundtableDir, files[0]) : null;
349
- if (!fp) return "";
350
- return await fileReader(fp, "utf-8");
351
- } catch {
352
- return "";
353
- }
354
- }
355
- async readLatestCrossSignals() {
356
- try {
357
- const files = (await readdir(this.crossSignalsDir)).filter((f) => f.endsWith(".md")).sort().reverse();
358
- const fp = files[0] ? path.join(this.crossSignalsDir, files[0]) : null;
359
- if (!fp) return "";
360
- return await fileReader(fp, "utf-8");
361
- } catch {
362
- return "";
363
- }
364
- }
365
- async writeAgentOutput(opts) {
366
- const createdAt = opts.createdAt ?? /* @__PURE__ */ new Date();
367
- const date = ymd(createdAt);
368
- const time = createdAt.toISOString().slice(11, 19).replace(/:/g, "");
369
- const slug = safeSlug(opts.title);
370
- const dir = path.join(this.outputsDir, opts.agentId, date);
371
- await mkdir(dir, { recursive: true });
372
- const fp = path.join(dir, `${time}-${slug}.md`);
373
- const body = `---
374
- kind: agent_output
375
- agent: ${opts.agentId}
376
- createdAt: ${createdAt.toISOString()}
377
- title: ${opts.title.replace(/\n/g, " ").slice(0, 200)}
378
- ---
379
-
380
- ` + opts.content.trimEnd() + "\n";
381
- await writeFile(fp, body, "utf-8");
382
- return fp;
383
- }
384
- async appendFeedback(entry) {
385
- const parsed = SharedFeedbackEntrySchema.parse(entry);
386
- await appendFile(this.feedbackInboxPath, JSON.stringify(parsed) + "\n", "utf-8");
387
- }
388
- async appendPrioritiesInbox(opts) {
389
- const stamp = (/* @__PURE__ */ new Date()).toISOString();
390
- const lines = [
391
- "",
392
- `## ${stamp} (${opts.agentId})`,
393
- "",
394
- opts.text.trimEnd(),
395
- ""
396
- ].join("\n");
397
- await appendFile(this.prioritiesInboxPath, lines, "utf-8");
398
- }
399
- async synthesizeCrossSignals(opts) {
400
- const date = opts.date ?? ymd(/* @__PURE__ */ new Date());
401
- const maxSummaryItems = Math.max(1, opts.maxSummaryItems ?? 8);
402
- const outputs = [];
403
- try {
404
- const agents = await readdir(this.outputsDir, { withFileTypes: true });
405
- for (const a of agents) {
406
- if (!a.isDirectory()) continue;
407
- const dayDir = path.join(this.outputsDir, a.name, date);
408
- try {
409
- const files = (await readdir(dayDir)).filter((f) => f.endsWith(".md")).sort();
410
- for (const f of files) {
411
- const p = path.join(dayDir, f);
412
- const raw = await fileReader(p, "utf-8");
413
- const title = (raw.match(/^title:\s*(.+)$/m)?.[1] ?? f).trim();
414
- outputs.push({ agent: a.name, path: p, title, raw });
415
- }
416
- } catch {
417
- }
418
- }
419
- } catch {
420
- }
421
- const feedback = [];
422
- try {
423
- const raw = await fileReader(this.feedbackInboxPath, "utf-8");
424
- for (const line of raw.split("\n")) {
425
- if (!line.trim()) continue;
426
- try {
427
- const obj = JSON.parse(line);
428
- const parsed = SharedFeedbackEntrySchema.safeParse(obj);
429
- if (!parsed.success) continue;
430
- if (String(parsed.data.date).startsWith(date)) feedback.push(parsed.data);
431
- } catch {
432
- }
433
- }
434
- } catch {
435
- }
436
- const sources = outputs.map((output) => {
437
- const body = stripYamlFrontmatter(output.raw);
438
- return {
439
- agent: output.agent,
440
- path: output.path,
441
- title: output.title,
442
- topics: extractTopicTokens(`${output.title}
443
- ${body}`)
444
- };
445
- });
446
- const overlapMap = /* @__PURE__ */ new Map();
447
- for (const source of sources) {
448
- for (const token of source.topics) {
449
- const existing = overlapMap.get(token);
450
- if (existing) {
451
- existing.agents.add(source.agent);
452
- existing.sourcePaths.add(source.path);
453
- } else {
454
- overlapMap.set(token, {
455
- agents: /* @__PURE__ */ new Set([source.agent]),
456
- sourcePaths: /* @__PURE__ */ new Set([source.path])
457
- });
458
- }
459
- }
460
- }
461
- const overlaps = [...overlapMap.entries()].map(([token, v]) => ({
462
- token,
463
- agents: [...v.agents].sort(),
464
- sourcePaths: [...v.sourcePaths].sort(),
465
- agentCount: v.agents.size
466
- })).filter((entry) => entry.agentCount >= 2).sort((a, b) => b.agentCount - a.agentCount || a.token.localeCompare(b.token));
467
- const semanticEnabled = this.config.sharedCrossSignalSemanticEnabled === true || this.config.crossSignalsSemanticEnabled === true;
468
- const semanticTimeoutMs = this.config.sharedCrossSignalSemanticTimeoutMs ?? this.config.crossSignalsSemanticTimeoutMs ?? 4e3;
469
- const semanticMaxCandidates = this.config.sharedCrossSignalSemanticMaxCandidates ?? 120;
470
- let semanticApplied = false;
471
- let semanticTimedOut = false;
472
- let semanticCandidateCount = 0;
473
- let semanticAddedOverlapCount = 0;
474
- let mergedOverlaps = overlaps;
475
- if (semanticEnabled) {
476
- try {
477
- const semanticResult = await computeSemanticOverlapsWithTimeout(
478
- sources,
479
- semanticTimeoutMs,
480
- semanticMaxCandidates
481
- );
482
- semanticTimedOut = semanticResult.timedOut;
483
- semanticCandidateCount = semanticResult.candidateCount;
484
- if (!semanticResult.timedOut && semanticResult.overlaps.length > 0) {
485
- mergedOverlaps = mergeOverlaps(overlaps, semanticResult.overlaps);
486
- semanticAddedOverlapCount = Math.max(0, mergedOverlaps.length - overlaps.length);
487
- semanticApplied = semanticAddedOverlapCount > 0;
488
- }
489
- } catch (err) {
490
- log.warn(`shared-context semantic cross-signals failed; fail-open to deterministic output: ${err}`);
491
- }
492
- }
493
- const feedbackByDecision = {
494
- approved: 0,
495
- approved_with_feedback: 0,
496
- rejected: 0
497
- };
498
- for (const entry of feedback) {
499
- feedbackByDecision[entry.decision] += 1;
500
- }
501
- const report = {
502
- date,
503
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
504
- sourceCount: sources.length,
505
- feedbackCount: feedback.length,
506
- feedbackByDecision,
507
- feedbackEntries: [...feedback].sort(compareFeedbackPriority),
508
- sources,
509
- overlaps: mergedOverlaps,
510
- semantic: {
511
- enabled: semanticEnabled,
512
- applied: semanticApplied,
513
- timedOut: semanticTimedOut,
514
- candidateCount: semanticCandidateCount,
515
- maxCandidates: Math.max(0, Math.floor(semanticMaxCandidates)),
516
- addedOverlapCount: semanticAddedOverlapCount
517
- }
518
- };
519
- const crossSignalsPath = path.join(this.crossSignalsDir, `${date}.json`);
520
- await writeFile(crossSignalsPath, `${JSON.stringify(report, null, 2)}
521
- `, "utf-8");
522
- const recurringThemeLines = mergedOverlaps.length === 0 ? ["- No multi-agent topic overlap detected."] : mergedOverlaps.slice(0, maxSummaryItems).map((entry) => formatOverlapLine(entry));
523
- const riskSignals = [...feedback].filter((entry) => entry.decision !== "approved" || entry.severity === "high" || entry.severity === "medium").sort(compareFeedbackPriority).slice(0, maxSummaryItems);
524
- const riskLines = riskSignals.length === 0 ? ["- No explicit blockers or elevated review risks recorded."] : riskSignals.map((entry) => formatFeedbackLine(entry));
525
- const promotionCandidates = mergedOverlaps.filter((entry) => entry.agentCount >= 3).slice(0, maxSummaryItems);
526
- const promotionLines = promotionCandidates.length === 0 ? ["- No promotion candidates yet."] : promotionCandidates.map(
527
- (entry) => `- Consider promoting \`${entry.token}\` into priorities or operating rules [sources: ${entry.sourcePaths.join(", ")}]`
528
- );
529
- const crossSignalsMarkdown = [
530
- `# Cross-Signals \u2014 ${date}`,
531
- "",
532
- "## Overview",
533
- `- Source outputs analyzed: ${sources.length}`,
534
- `- Feedback entries analyzed: ${feedback.length}`,
535
- `- Decision totals: approved=${feedbackByDecision.approved}, approved_with_feedback=${feedbackByDecision.approved_with_feedback}, rejected=${feedbackByDecision.rejected}`,
536
- `- Semantic enhancer: ${semanticEnabled ? semanticTimedOut ? "enabled (timed out, fail-open)" : semanticApplied ? "enabled (applied)" : "enabled (no additional overlaps)" : "disabled"}`,
537
- `- JSON report: ${crossSignalsPath}`,
538
- "",
539
- "## Recurring Themes",
540
- ...recurringThemeLines,
541
- "",
542
- "## Risks And Blockers",
543
- ...riskLines,
544
- "",
545
- "## Potential Promotions",
546
- ...promotionLines,
547
- "",
548
- "## Sources",
549
- ...sources.length === 0 ? ["- (none)"] : sources.map(
550
- (source) => `- [${source.agent}] ${source.title} (${source.path})`
551
- ),
552
- ""
553
- ].join("\n");
554
- const crossSignalsMarkdownPath = path.join(this.crossSignalsDir, `${date}.md`);
555
- await writeFile(crossSignalsMarkdownPath, crossSignalsMarkdown, "utf-8");
556
- return {
557
- date,
558
- crossSignalsPath,
559
- crossSignalsMarkdownPath,
560
- overlapCount: mergedOverlaps.length,
561
- report
562
- };
563
- }
564
- async curateDaily(opts) {
565
- const date = opts.date ?? ymd(/* @__PURE__ */ new Date());
566
- const maxChars = Math.max(2e3, opts.maxChars ?? 2e4);
567
- const crossSignals = await this.synthesizeCrossSignals({ date });
568
- const feedbackLines = crossSignals.report.feedbackEntries.length === 0 ? ["- (none)"] : crossSignals.report.feedbackEntries.map((entry) => formatFeedbackLine(entry));
569
- const overlapBullets = crossSignals.report.overlaps.length === 0 ? ["- No multi-agent topic overlap detected."] : crossSignals.report.overlaps.slice(0, 8).map((entry) => formatOverlapLine(entry));
570
- const md = [
571
- `# Roundtable \u2014 ${date}`,
572
- "",
573
- "## Notable Agent Outputs",
574
- ...crossSignals.report.sources.length === 0 ? ["- (none)"] : crossSignals.report.sources.map((source) => `- ${source.title} (${source.path})`),
575
- "",
576
- "## Feedback (Approve/Reject)",
577
- ...feedbackLines,
578
- "",
579
- "## Cross-Signals",
580
- `- Source outputs analyzed: ${crossSignals.report.sourceCount}`,
581
- `- Feedback entries analyzed: ${crossSignals.report.feedbackCount}`,
582
- `- Decision totals: approved=${crossSignals.report.feedbackByDecision.approved}, approved_with_feedback=${crossSignals.report.feedbackByDecision.approved_with_feedback}, rejected=${crossSignals.report.feedbackByDecision.rejected}`,
583
- `- Semantic enhancer: ${crossSignals.report.semantic.enabled ? crossSignals.report.semantic.timedOut ? "enabled (timed out, fail-open)" : crossSignals.report.semantic.applied ? "enabled (applied)" : "enabled (no additional overlaps)" : "disabled"}`,
584
- `- Cross-signals JSON: ${crossSignals.crossSignalsPath}`,
585
- `- Cross-signals markdown: ${crossSignals.crossSignalsMarkdownPath}`,
586
- ...overlapBullets,
587
- ""
588
- ];
589
- const out = md.join("\n");
590
- const trimmed = out.length > maxChars ? out.slice(0, maxChars) + "\n\n...(trimmed)\n" : out;
591
- const roundtablePath = path.join(this.roundtableDir, `${date}.md`);
592
- await writeFile(roundtablePath, trimmed, "utf-8");
593
- log.info(`shared-context curated daily roundtable: ${roundtablePath}`);
594
- return {
595
- date,
596
- roundtablePath,
597
- crossSignalsPath: crossSignals.crossSignalsPath,
598
- crossSignalsMarkdownPath: crossSignals.crossSignalsMarkdownPath,
599
- overlapCount: crossSignals.overlapCount
600
- };
601
- }
602
- };
603
54
 
604
55
  // ../remnic-core/src/compounding/engine.ts
605
56
  var COMPOUNDING_VERSION = 2;
@@ -842,7 +293,7 @@ var CompoundingEngine = class {
842
293
  let promotionCandidates = this.config.compoundingSemanticEnabled ? this.derivePromotionCandidates(outcomeSummary, mistakes.registry, rubrics) : [];
843
294
  if (this.config.cmcConsolidationEnabled) {
844
295
  try {
845
- const { deriveCausalPromotionCandidates, materializeAfterCausalConsolidation } = await import("./causal-consolidation-DSLFN64P.js");
296
+ const { deriveCausalPromotionCandidates, materializeAfterCausalConsolidation } = await import("./causal-consolidation-DRPM2KOE.js");
846
297
  const causalCandidates = await deriveCausalPromotionCandidates({
847
298
  memoryDir: this.config.memoryDir,
848
299
  causalTrajectoryStoreDir: this.config.causalTrajectoryStoreDir,
@@ -875,7 +326,7 @@ var CompoundingEngine = class {
875
326
  }
876
327
  if (this.config.calibrationEnabled) {
877
328
  try {
878
- const { runCalibrationConsolidation } = await import("./calibration-JD4AU7FB.js");
329
+ const { runCalibrationConsolidation } = await import("./calibration-RKL2LRW4.js");
879
330
  const calRules = await runCalibrationConsolidation({
880
331
  memoryDir: this.config.memoryDir,
881
332
  gatewayConfig: this.config.gatewayConfig,
@@ -1839,7 +1290,6 @@ var CompoundingEngine = class {
1839
1290
  };
1840
1291
 
1841
1292
  export {
1842
- SharedContextManager,
1843
1293
  defaultTierMigrationCycleBudget,
1844
1294
  CompoundingEngine
1845
1295
  };
@@ -11,9 +11,6 @@ function clamp01(value) {
11
11
  if (value > 1) return 1;
12
12
  return value;
13
13
  }
14
- function clampLifecycleThreshold(value) {
15
- return clamp01(value);
16
- }
17
14
  function parseIsoMs(value) {
18
15
  if (!value) return null;
19
16
  const ms = Date.parse(value);
@@ -178,9 +175,7 @@ function decideLifecycleTransition(memory, policy, now, signals) {
178
175
 
179
176
  export {
180
177
  clamp01,
181
- clampLifecycleThreshold,
182
178
  daysSince,
183
- resolveLifecycleState,
184
179
  computeLifecycleValueInputs,
185
180
  decideLifecycleTransition
186
181
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  external_exports
3
- } from "./chunk-EXDYWXMB.js";
3
+ } from "./chunk-4XDQ3KEC.js";
4
4
 
5
5
  // ../remnic-core/src/transfer/types.ts
6
6
  var ExportManifestV1Schema = external_exports.object({
@@ -31,17 +31,6 @@ function readEnvVar(name) {
31
31
  function resolveHomeDir() {
32
32
  return readEnvVar("HOME") || os.homedir();
33
33
  }
34
- function cloneEnv() {
35
- return { ...getEnvMap() ?? {} };
36
- }
37
- function mergeEnv(overrides) {
38
- const merged = cloneEnv();
39
- for (const [key, value] of Object.entries(overrides)) {
40
- if (typeof value === "string") merged[key] = value;
41
- else delete merged[key];
42
- }
43
- return merged;
44
- }
45
34
 
46
35
  // ../remnic-core/src/utils/path.ts
47
36
  function expandTildePath(p) {
@@ -55,6 +44,5 @@ function expandTildePath(p) {
55
44
  export {
56
45
  readEnvVar,
57
46
  resolveHomeDir,
58
- mergeEnv,
59
47
  expandTildePath
60
48
  };