omnius 1.0.362 → 1.0.364

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/index.js CHANGED
@@ -35832,11 +35832,11 @@ function deleteCustomToolDefinition(name10, scope, repoRoot) {
35832
35832
  const dir = scope === "project" && repoRoot ? projectToolsDir(repoRoot) : globalToolsDir();
35833
35833
  const filePath = join34(dir, `${name10}.json`);
35834
35834
  if (existsSync32(filePath)) {
35835
- const { unlinkSync: unlinkSync35 } = __require("node:fs");
35836
- unlinkSync35(filePath);
35835
+ const { unlinkSync: unlinkSync36 } = __require("node:fs");
35836
+ unlinkSync36(filePath);
35837
35837
  const docsPath = toolDocsPath(name10, scope, repoRoot);
35838
35838
  if (existsSync32(docsPath))
35839
- unlinkSync35(docsPath);
35839
+ unlinkSync36(docsPath);
35840
35840
  if (scope === "project" && repoRoot)
35841
35841
  writeCustomToolRegistry(repoRoot);
35842
35842
  return true;
@@ -115212,7 +115212,7 @@ var require_auto = __commonJS({
115212
115212
  // ../node_modules/acme-client/src/client.js
115213
115213
  var require_client = __commonJS({
115214
115214
  "../node_modules/acme-client/src/client.js"(exports, module) {
115215
- var { createHash: createHash44 } = __require("crypto");
115215
+ var { createHash: createHash45 } = __require("crypto");
115216
115216
  var { getPemBodyAsB64u } = require_crypto();
115217
115217
  var { log: log22 } = require_logger();
115218
115218
  var HttpClient = require_http();
@@ -115523,14 +115523,14 @@ var require_client = __commonJS({
115523
115523
  */
115524
115524
  async getChallengeKeyAuthorization(challenge) {
115525
115525
  const jwk = this.http.getJwk();
115526
- const keysum = createHash44("sha256").update(JSON.stringify(jwk));
115526
+ const keysum = createHash45("sha256").update(JSON.stringify(jwk));
115527
115527
  const thumbprint = keysum.digest("base64url");
115528
115528
  const result = `${challenge.token}.${thumbprint}`;
115529
115529
  if (challenge.type === "http-01") {
115530
115530
  return result;
115531
115531
  }
115532
115532
  if (challenge.type === "dns-01") {
115533
- return createHash44("sha256").update(result).digest("base64url");
115533
+ return createHash45("sha256").update(result).digest("base64url");
115534
115534
  }
115535
115535
  if (challenge.type === "tls-alpn-01") {
115536
115536
  return result;
@@ -258210,7 +258210,7 @@ var require_websocket2 = __commonJS({
258210
258210
  var http6 = __require("http");
258211
258211
  var net5 = __require("net");
258212
258212
  var tls2 = __require("tls");
258213
- var { randomBytes: randomBytes30, createHash: createHash44 } = __require("crypto");
258213
+ var { randomBytes: randomBytes30, createHash: createHash45 } = __require("crypto");
258214
258214
  var { Duplex: Duplex3, Readable } = __require("stream");
258215
258215
  var { URL: URL3 } = __require("url");
258216
258216
  var PerMessageDeflate3 = require_permessage_deflate2();
@@ -258870,7 +258870,7 @@ var require_websocket2 = __commonJS({
258870
258870
  abortHandshake(websocket, socket, "Invalid Upgrade header");
258871
258871
  return;
258872
258872
  }
258873
- const digest3 = createHash44("sha1").update(key + GUID).digest("base64");
258873
+ const digest3 = createHash45("sha1").update(key + GUID).digest("base64");
258874
258874
  if (res.headers["sec-websocket-accept"] !== digest3) {
258875
258875
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
258876
258876
  return;
@@ -259237,7 +259237,7 @@ var require_websocket_server = __commonJS({
259237
259237
  var EventEmitter15 = __require("events");
259238
259238
  var http6 = __require("http");
259239
259239
  var { Duplex: Duplex3 } = __require("stream");
259240
- var { createHash: createHash44 } = __require("crypto");
259240
+ var { createHash: createHash45 } = __require("crypto");
259241
259241
  var extension3 = require_extension2();
259242
259242
  var PerMessageDeflate3 = require_permessage_deflate2();
259243
259243
  var subprotocol3 = require_subprotocol();
@@ -259538,7 +259538,7 @@ var require_websocket_server = __commonJS({
259538
259538
  );
259539
259539
  }
259540
259540
  if (this._state > RUNNING) return abortHandshake(socket, 503);
259541
- const digest3 = createHash44("sha1").update(key + GUID).digest("base64");
259541
+ const digest3 = createHash45("sha1").update(key + GUID).digest("base64");
259542
259542
  const headers = [
259543
259543
  "HTTP/1.1 101 Switching Protocols",
259544
259544
  "Upgrade: websocket",
@@ -272345,13 +272345,13 @@ Justification: ${justification || "(none provided)"}`,
272345
272345
  }
272346
272346
  const snapshot = JSON.stringify(this.selfState, null, 2);
272347
272347
  try {
272348
- const { createHash: createHash44 } = await import("node:crypto");
272348
+ const { createHash: createHash45 } = await import("node:crypto");
272349
272349
  const snapshotDir = join42(this.cwd, ".omnius", "identity", "snapshots");
272350
272350
  await mkdir7(snapshotDir, { recursive: true });
272351
272351
  const version4 = this.selfState.version;
272352
272352
  const snapshotPath = join42(snapshotDir, `v${version4}.json`);
272353
272353
  await writeFile12(snapshotPath, snapshot, "utf8");
272354
- const hash = createHash44("sha256").update(snapshot).digest("hex");
272354
+ const hash = createHash45("sha256").update(snapshot).digest("hex");
272355
272355
  await writeFile12(join42(this.cwd, ".omnius", "identity", "latest-hash.txt"), hash, "utf8");
272356
272356
  let ipfsCid = "";
272357
272357
  try {
@@ -272484,8 +272484,8 @@ New: ${newNarrative.slice(0, 200)}...`,
272484
272484
  }
272485
272485
  // ── Helpers ──────────────────────────────────────────────────────────────
272486
272486
  createDefaultState() {
272487
- const { createHash: createHash44 } = __require("node:crypto");
272488
- const machineId = createHash44("sha256").update(this.cwd).digest("hex").slice(0, 12);
272487
+ const { createHash: createHash45 } = __require("node:crypto");
272488
+ const machineId = createHash45("sha256").update(this.cwd).digest("hex").slice(0, 12);
272489
272489
  return {
272490
272490
  self_id: `omnius-${machineId}`,
272491
272491
  version: 1,
@@ -272567,9 +272567,9 @@ New: ${newNarrative.slice(0, 200)}...`,
272567
272567
  let cid;
272568
272568
  if (this.selfState.version > prevVersion) {
272569
272569
  try {
272570
- const { createHash: createHash44 } = await import("node:crypto");
272570
+ const { createHash: createHash45 } = await import("node:crypto");
272571
272571
  const stateJson = JSON.stringify(this.selfState);
272572
- const hash = createHash44("sha256").update(stateJson).digest("hex").slice(0, 32);
272572
+ const hash = createHash45("sha256").update(stateJson).digest("hex").slice(0, 32);
272573
272573
  const cidsPath = join42(this.cwd, ".omnius", "identity", "cids.json");
272574
272574
  const cidsData = { latest: "", hash, version: this.selfState.version };
272575
272575
  try {
@@ -558468,17 +558468,29 @@ function reconcileClaimsWithEvidence(ledger) {
558468
558468
  const claimTerms = cleanText(claim.text, 300).toLowerCase().split(/[^a-z0-9]+/).filter((part) => part.length >= 4);
558469
558469
  const matches = successfulEvidence.filter((entry) => {
558470
558470
  const haystack = `${entry.toolName ?? ""} ${entry.summary}`.toLowerCase();
558471
- return claimTerms.some((term) => haystack.includes(term));
558471
+ const matchingTerms = claimTerms.filter((term) => haystack.includes(term));
558472
+ const specificMatches = matchingTerms.filter((t2) => !GENERIC_EVIDENCE_TERMS.has(t2));
558473
+ return specificMatches.length >= 1 && matchingTerms.length >= 2;
558472
558474
  });
558473
558475
  const contradictions = failedEvidence.filter((entry) => {
558474
558476
  const haystack = `${entry.toolName ?? ""} ${entry.summary}`.toLowerCase();
558475
- return claimTerms.some((term) => haystack.includes(term));
558477
+ const matchingTerms = claimTerms.filter((term) => haystack.includes(term));
558478
+ const specificMatches = matchingTerms.filter((t2) => !GENERIC_EVIDENCE_TERMS.has(t2));
558479
+ return specificMatches.length >= 1 && matchingTerms.length >= 2;
558476
558480
  });
558477
558481
  if (contradictions.length > 0 && matches.length === 0) {
558478
- return { ...claim, evidenceIds: contradictions.map((entry) => entry.id), status: "contradicted" };
558482
+ return {
558483
+ ...claim,
558484
+ evidenceIds: contradictions.map((entry) => entry.id),
558485
+ status: "contradicted"
558486
+ };
558479
558487
  }
558480
558488
  if (matches.length > 0) {
558481
- return { ...claim, evidenceIds: matches.map((entry) => entry.id), status: "supported" };
558489
+ return {
558490
+ ...claim,
558491
+ evidenceIds: matches.map((entry) => entry.id),
558492
+ status: "supported"
558493
+ };
558482
558494
  }
558483
558495
  return { ...claim, evidenceIds: [], status: "unverified" };
558484
558496
  });
@@ -558561,10 +558573,125 @@ function saveCompletionLedger(filePath, ledger) {
558561
558573
  function loadCompletionLedger(filePath) {
558562
558574
  return JSON.parse(readFileSync64(filePath, "utf8"));
558563
558575
  }
558576
+ var GENERIC_EVIDENCE_TERMS;
558564
558577
  var init_completionLedger = __esm({
558565
558578
  "packages/orchestrator/dist/completionLedger.js"() {
558566
558579
  "use strict";
558567
558580
  init_completionContract();
558581
+ GENERIC_EVIDENCE_TERMS = /* @__PURE__ */ new Set([
558582
+ "file",
558583
+ "read",
558584
+ "write",
558585
+ "search",
558586
+ "list",
558587
+ "get",
558588
+ "find",
558589
+ "show",
558590
+ "view",
558591
+ "open",
558592
+ "close",
558593
+ "check",
558594
+ "run",
558595
+ "exec",
558596
+ "call",
558597
+ "result",
558598
+ "output",
558599
+ "input",
558600
+ "data",
558601
+ "info",
558602
+ "text",
558603
+ "code",
558604
+ "done",
558605
+ "work",
558606
+ "time",
558607
+ "name",
558608
+ "path",
558609
+ "size",
558610
+ "type",
558611
+ "mode",
558612
+ "set",
558613
+ "help",
558614
+ "test",
558615
+ "tests",
558616
+ "testing",
558617
+ "success",
558618
+ "successfully",
558619
+ "completed",
558620
+ "first",
558621
+ "last",
558622
+ "next",
558623
+ "prev",
558624
+ "page",
558625
+ "line",
558626
+ "lines",
558627
+ "count",
558628
+ "value",
558629
+ "values",
558630
+ "args",
558631
+ "argument",
558632
+ "arguments",
558633
+ "param",
558634
+ "parameter",
558635
+ "parameters",
558636
+ "error",
558637
+ "errors",
558638
+ "failed",
558639
+ "failure",
558640
+ "state",
558641
+ "status",
558642
+ "config",
558643
+ "configuration",
558644
+ "option",
558645
+ "options",
558646
+ "default",
558647
+ "current",
558648
+ "previous",
558649
+ "select",
558650
+ "filter",
558651
+ "limit",
558652
+ "match",
558653
+ "matches",
558654
+ "matching",
558655
+ "number",
558656
+ "string",
558657
+ "object",
558658
+ "array",
558659
+ "map",
558660
+ "list",
558661
+ "sort",
558662
+ "order",
558663
+ "group",
558664
+ "total",
558665
+ "summary",
558666
+ "preview",
558667
+ "export",
558668
+ "import",
558669
+ "format",
558670
+ "build",
558671
+ "compile",
558672
+ "deploy",
558673
+ "release",
558674
+ "version",
558675
+ "change",
558676
+ "changes",
558677
+ "update",
558678
+ "updates",
558679
+ "updated",
558680
+ "modify",
558681
+ "modified",
558682
+ "modification",
558683
+ "remove",
558684
+ "removed",
558685
+ "removal",
558686
+ "delete",
558687
+ "deleted",
558688
+ "add",
558689
+ "added",
558690
+ "addition",
558691
+ "create",
558692
+ "created",
558693
+ "creation"
558694
+ ]);
558568
558695
  }
558569
558696
  });
558570
558697
 
@@ -561191,12 +561318,60 @@ var init_lesson_bank = __esm({
561191
561318
  // packages/orchestrator/dist/intervention-replay.js
561192
561319
  import { existsSync as existsSync88, mkdirSync as mkdirSync51, readFileSync as readFileSync67, writeFileSync as writeFileSync41, readdirSync as readdirSync27 } from "node:fs";
561193
561320
  import { join as join98, dirname as dirname30 } from "node:path";
561321
+ import { createHash as createHash26 } from "node:crypto";
561194
561322
  function checkpointDir2(workingDir) {
561195
561323
  return workingDir ? join98(workingDir, ".omnius", "checkpoints") : join98(process.env["HOME"] || ".", ".omnius", "checkpoints");
561196
561324
  }
561197
561325
  function checkpointPath(workingDir, turn) {
561198
561326
  return join98(checkpointDir2(workingDir), `turn-${String(turn).padStart(4, "0")}.json`);
561199
561327
  }
561328
+ function sanitizeMessagesForCheckpoint(messages2) {
561329
+ const result = [...messages2];
561330
+ let lastFrameIdx = -1;
561331
+ for (let i2 = result.length - 1; i2 >= 0; i2--) {
561332
+ const m2 = result[i2];
561333
+ const content = typeof m2.content === "string" ? m2.content : "";
561334
+ if (m2.role === "system" && content.startsWith(CONTEXT_FRAME_MARKER)) {
561335
+ if (lastFrameIdx === -1) {
561336
+ lastFrameIdx = i2;
561337
+ } else {
561338
+ result.splice(i2, 1);
561339
+ }
561340
+ }
561341
+ }
561342
+ const seenSystemDigests = /* @__PURE__ */ new Set();
561343
+ const deduped = [];
561344
+ for (let i2 = 0; i2 < result.length; i2++) {
561345
+ const m2 = result[i2];
561346
+ const content = typeof m2.content === "string" ? m2.content : "";
561347
+ if (m2.role !== "system") {
561348
+ deduped.push(m2);
561349
+ continue;
561350
+ }
561351
+ if (i2 === lastFrameIdx) {
561352
+ deduped.push(m2);
561353
+ continue;
561354
+ }
561355
+ const digest3 = createHash26("sha1").update(content).digest("hex");
561356
+ if (seenSystemDigests.has(digest3))
561357
+ continue;
561358
+ seenSystemDigests.add(digest3);
561359
+ deduped.push(m2);
561360
+ }
561361
+ let sysChars = 0;
561362
+ const capped = [];
561363
+ for (const m2 of deduped) {
561364
+ if (m2.role === "system") {
561365
+ const content = typeof m2.content === "string" ? m2.content : "";
561366
+ if (sysChars + content.length > MAX_CHECKPOINT_SYSTEM_CHARS) {
561367
+ continue;
561368
+ }
561369
+ sysChars += content.length;
561370
+ }
561371
+ capped.push(m2);
561372
+ }
561373
+ return capped;
561374
+ }
561200
561375
  function writeCheckpoint(args) {
561201
561376
  try {
561202
561377
  const snap = {
@@ -561241,9 +561416,12 @@ function pruneOldCheckpoints(args) {
561241
561416
  }
561242
561417
  return removed;
561243
561418
  }
561419
+ var CONTEXT_FRAME_MARKER, MAX_CHECKPOINT_SYSTEM_CHARS;
561244
561420
  var init_intervention_replay = __esm({
561245
561421
  "packages/orchestrator/dist/intervention-replay.js"() {
561246
561422
  "use strict";
561423
+ CONTEXT_FRAME_MARKER = "[ACTIVE CONTEXT FRAME]";
561424
+ MAX_CHECKPOINT_SYSTEM_CHARS = 8e4;
561247
561425
  }
561248
561426
  });
561249
561427
 
@@ -568122,7 +568300,7 @@ import { existsSync as existsSync97, readFileSync as readFileSync75, statSync as
568122
568300
  import { execSync as execSync47 } from "node:child_process";
568123
568301
  import { homedir as homedir32, platform as platform3, arch as arch2, totalmem as totalmem4, freemem as freemem3, hostname as hostname3 } from "node:os";
568124
568302
  import { join as join107 } from "node:path";
568125
- import { createHash as createHash26 } from "node:crypto";
568303
+ import { createHash as createHash27 } from "node:crypto";
568126
568304
  function capturePreflightSnapshot(workingDir) {
568127
568305
  const warnings = [];
568128
568306
  const configFingerprints = {};
@@ -568293,7 +568471,7 @@ function expandPath(p2) {
568293
568471
  return p2;
568294
568472
  }
568295
568473
  function sha2564(s2) {
568296
- return createHash26("sha256").update(s2).digest("hex").slice(0, 16);
568474
+ return createHash27("sha256").update(s2).digest("hex").slice(0, 16);
568297
568475
  }
568298
568476
  function freeDiskBytes(path12 = "/tmp") {
568299
568477
  try {
@@ -570502,8 +570680,9 @@ ${parts.join("\n")}
570502
570680
  } catch {
570503
570681
  }
570504
570682
  }
570505
- _initializeCompletionContract(task, context2) {
570506
- this._completionContractSeedText = [task, context2 ?? ""].map((text2) => String(text2 || "").trim()).filter(Boolean).join("\n\n");
570683
+ _initializeCompletionContract(task, context2, actualUserGoal) {
570684
+ const goalText = actualUserGoal || task;
570685
+ this._completionContractSeedText = [goalText, context2 ?? ""].map((text2) => String(text2 || "").trim()).filter(Boolean).join("\n\n");
570507
570686
  this._completionContract = inferCompletionContractFromTexts([this._completionContractSeedText], task);
570508
570687
  this._persistCompletionContract(this._completionContract);
570509
570688
  return this._completionContract;
@@ -572129,7 +572308,10 @@ ${shellLines.join("\n")}` : "Commands run: none"
572129
572308
  this._saveCompletionLedgerSafe();
572130
572309
  }
572131
572310
  try {
572132
- const _audit = auditCompletionClaims(this._completionLedger.proposedClaims.map((c8) => ({ text: c8.text, status: c8.status })));
572311
+ const _audit = auditCompletionClaims(this._completionLedger.proposedClaims.map((c8) => ({
572312
+ text: c8.text,
572313
+ status: c8.status
572314
+ })));
572133
572315
  if (!_audit.ok) {
572134
572316
  const _checks = _audit.blockers.map((b) => `• [${b.category}] "${b.claim}" → ${b.requiredCheck}`).join("\n");
572135
572317
  this._completionCaveat = [
@@ -574213,7 +574395,11 @@ ${blob}
574213
574395
  } catch {
574214
574396
  }
574215
574397
  }
574216
- callMetaById.set(c8.id, { name: name10, path: path12, argsPreview: rawArgs.slice(0, 120) });
574398
+ callMetaById.set(c8.id, {
574399
+ name: name10,
574400
+ path: path12,
574401
+ argsPreview: rawArgs.slice(0, 120)
574402
+ });
574217
574403
  }
574218
574404
  }
574219
574405
  }
@@ -574399,7 +574585,12 @@ ${blob}
574399
574585
  const list = this._readCoverage.get(iv.key) ?? [];
574400
574586
  const pruned = list.filter((cov) => !(cov.whole === iv.whole && iv.start <= cov.start && cov.end <= iv.end && cov.fingerprint !== fingerprint));
574401
574587
  if (!pruned.some((cov) => cov.fingerprint === fingerprint)) {
574402
- pruned.push({ start: iv.start, end: iv.end, whole: iv.whole, fingerprint });
574588
+ pruned.push({
574589
+ start: iv.start,
574590
+ end: iv.end,
574591
+ whole: iv.whole,
574592
+ fingerprint
574593
+ });
574403
574594
  }
574404
574595
  pruned.sort((a2, b) => b.end - b.start - (a2.end - a2.start));
574405
574596
  this._readCoverage.set(iv.key, pruned.slice(0, 8));
@@ -574840,7 +575031,14 @@ Rewrite it now for ${ctx3.model}.`;
574840
575031
  const suggestions = [];
574841
575032
  const provided = new Set(providedKeys);
574842
575033
  const aliasMap = {
574843
- task: ["prompt", "description", "message", "query", "input", "instructions"],
575034
+ task: [
575035
+ "prompt",
575036
+ "description",
575037
+ "message",
575038
+ "query",
575039
+ "input",
575040
+ "instructions"
575041
+ ],
574844
575042
  prompt: ["task", "message", "query", "input", "text", "instructions"],
574845
575043
  background: ["run_in_background", "background_run", "async"],
574846
575044
  run_in_background: ["background", "background_run", "async"],
@@ -575230,7 +575428,7 @@ Respond with your assessment, then take action.`;
575230
575428
  return scored[0].result;
575231
575429
  }
575232
575430
  /** Run a task through the agentic loop */
575233
- async run(task, context2) {
575431
+ async run(task, context2, actualUserGoal) {
575234
575432
  this.aborted = false;
575235
575433
  this._abortController = new AbortController();
575236
575434
  this._fileWritesThisRun = 0;
@@ -575339,9 +575537,10 @@ Respond with your assessment, then take action.`;
575339
575537
  this._loadResolutionMemory();
575340
575538
  this._pauseResolve = null;
575341
575539
  this.pendingUserMessages.length = 0;
575540
+ const userGoal = (actualUserGoal || cleanedTask).slice(0, 500);
575342
575541
  this._taskState = {
575343
- goal: cleanedTask.slice(0, 500),
575344
- originalGoal: cleanedTask.slice(0, 500),
575542
+ goal: userGoal,
575543
+ originalGoal: userGoal,
575345
575544
  completedSteps: [],
575346
575545
  pendingSteps: [],
575347
575546
  currentStep: "",
@@ -575384,10 +575583,10 @@ Respond with your assessment, then take action.`;
575384
575583
  verbose: false
575385
575584
  });
575386
575585
  this._hookManager.runSessionHook("session_start", this._sessionId);
575387
- this._initializeCompletionContract(task, context2);
575586
+ this._initializeCompletionContract(task, context2, actualUserGoal);
575388
575587
  this._completionLedger = createCompletionLedger({
575389
575588
  runId: this._sessionId,
575390
- goal: cleanedTask
575589
+ goal: userGoal
575391
575590
  });
575392
575591
  this._sessionStartMs = Date.now();
575393
575592
  if (process.env["OMNIUS_DISABLE_PREFLIGHT"] !== "1") {
@@ -575539,8 +575738,22 @@ ${_notes}`;
575539
575738
  try {
575540
575739
  if (!this.options.subAgent) {
575541
575740
  const _imp = Math.min(9, Math.max(3, 3 + Math.floor((task?.length || 0) / 250)));
575542
- const _kw = String(task || "").toLowerCase().match(/[a-z][a-z0-9_-]{3,}/g)?.filter((w) => !["this", "that", "with", "from", "into", "your", "have", "will", "please"].includes(w)).slice(0, 6) ?? [];
575543
- noteAfterTask({ summary: `Task: ${String(task).slice(0, 200)}`, importance: _imp, keywords: _kw });
575741
+ const _kw = String(task || "").toLowerCase().match(/[a-z][a-z0-9_-]{3,}/g)?.filter((w) => ![
575742
+ "this",
575743
+ "that",
575744
+ "with",
575745
+ "from",
575746
+ "into",
575747
+ "your",
575748
+ "have",
575749
+ "will",
575750
+ "please"
575751
+ ].includes(w)).slice(0, 6) ?? [];
575752
+ noteAfterTask({
575753
+ summary: `Task: ${String(task).slice(0, 200)}`,
575754
+ importance: _imp,
575755
+ keywords: _kw
575756
+ });
575544
575757
  }
575545
575758
  } catch {
575546
575759
  }
@@ -576062,10 +576275,11 @@ TASK: ${scrubbedTask}` : scrubbedTask;
576062
576275
  const REG35_KEEP_LAST = 12;
576063
576276
  if (turn > 0 && turn % REG35_CHECKPOINT_EVERY === 0) {
576064
576277
  try {
576278
+ const sanitized = sanitizeMessagesForCheckpoint(messages2);
576065
576279
  writeCheckpoint({
576066
576280
  workingDir: this._workingDirectory || void 0,
576067
576281
  turn,
576068
- messages: messages2,
576282
+ messages: sanitized,
576069
576283
  taskGoal: this._taskState.originalGoal || this._taskState.goal || "",
576070
576284
  notes: `phase=${this._taskState.phase ?? "?"}, completed=${this._taskState.completedSteps?.length ?? 0}`
576071
576285
  });
@@ -577342,8 +577556,8 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
577342
577556
  if (process.env["OMNIUS_DISABLE_ADAPTIVE_RETRIEVAL"] !== "1") {
577343
577557
  const goalForSig = (this._taskState.goal || "").slice(0, 200);
577344
577558
  const recentTools = this._toolSequence.slice(-5).join("|");
577345
- const { createHash: createHash44 } = await import("node:crypto");
577346
- const sig = createHash44("sha256").update(`${goalForSig}::${recentTools}`).digest("hex").slice(0, 16);
577559
+ const { createHash: createHash45 } = await import("node:crypto");
577560
+ const sig = createHash45("sha256").update(`${goalForSig}::${recentTools}`).digest("hex").slice(0, 16);
577347
577561
  if (this._lastPprSig === sig && this._lastPprMemoryLines.length > 0) {
577348
577562
  compacted.push({
577349
577563
  role: "system",
@@ -578394,7 +578608,11 @@ Use the saved fact to continue the promised synthesis or next concrete step, or
578394
578608
  this._adversaryStream.observe({
578395
578609
  turn,
578396
578610
  assistantText: "",
578397
- recentToolOutcomes: this._adversaryToolOutcomes.slice(-8).map((o2) => ({ tool: o2.tool, succeeded: o2.succeeded, preview: o2.preview })),
578611
+ recentToolOutcomes: this._adversaryToolOutcomes.slice(-8).map((o2) => ({
578612
+ tool: o2.tool,
578613
+ succeeded: o2.succeeded,
578614
+ preview: o2.preview
578615
+ })),
578398
578616
  claimsCompletion: false,
578399
578617
  loopSignal: {
578400
578618
  tool: tc.name,
@@ -581778,7 +581996,7 @@ ${this._completionCaveat}` : this._completionCaveat;
581778
581996
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
581779
581997
  });
581780
581998
  try {
581781
- const { mkdirSync: mkdirSync106, readdirSync: readdirSync59, statSync: statSync59, unlinkSync: unlinkSync35, writeFileSync: writeFileSync91 } = __require("node:fs");
581999
+ const { mkdirSync: mkdirSync106, readdirSync: readdirSync59, statSync: statSync59, unlinkSync: unlinkSync36, writeFileSync: writeFileSync91 } = __require("node:fs");
581782
582000
  const { join: join179 } = __require("node:path");
581783
582001
  const contextDir = join179(this._workingDirectory || process.cwd(), ".omnius", "context");
581784
582002
  mkdirSync106(contextDir, { recursive: true });
@@ -581858,7 +582076,7 @@ ${this._completionCaveat}` : this._completionCaveat;
581858
582076
  }
581859
582077
  for (const filePath of toDelete) {
581860
582078
  try {
581861
- unlinkSync35(filePath);
582079
+ unlinkSync36(filePath);
581862
582080
  } catch {
581863
582081
  }
581864
582082
  }
@@ -583425,7 +583643,11 @@ ${trimmedNew}`;
583425
583643
  this._adversaryStream.observe({
583426
583644
  turn,
583427
583645
  assistantText,
583428
- recentToolOutcomes: this._adversaryToolOutcomes.slice(-8).map((o2) => ({ tool: o2.tool, succeeded: o2.succeeded, preview: o2.preview })),
583646
+ recentToolOutcomes: this._adversaryToolOutcomes.slice(-8).map((o2) => ({
583647
+ tool: o2.tool,
583648
+ succeeded: o2.succeeded,
583649
+ preview: o2.preview
583650
+ })),
583429
583651
  claimsCompletion: /task.?complete|all tests pass|\bdone\b|\bcomplete(d)?\b/i.test(assistantText)
583430
583652
  });
583431
583653
  void this._adversaryStream.tick().catch(() => {
@@ -585160,7 +585382,7 @@ ${result}`
585160
585382
  let resizedBase64 = null;
585161
585383
  try {
585162
585384
  const { execSync: execSync63 } = await import("node:child_process");
585163
- const { writeFileSync: writeFileSync91, readFileSync: readFileSync133, unlinkSync: unlinkSync35 } = await import("node:fs");
585385
+ const { writeFileSync: writeFileSync91, readFileSync: readFileSync133, unlinkSync: unlinkSync36 } = await import("node:fs");
585164
585386
  const { join: join179 } = await import("node:path");
585165
585387
  const { tmpdir: tmpdir24 } = await import("node:os");
585166
585388
  const tmpIn = join179(tmpdir24(), `omnius_img_in_${Date.now()}.png`);
@@ -585173,11 +585395,11 @@ ${result}`
585173
585395
  const resizedBuf = readFileSync133(tmpOut);
585174
585396
  resizedBase64 = `data:image/jpeg;base64,${resizedBuf.toString("base64")}`;
585175
585397
  try {
585176
- unlinkSync35(tmpIn);
585398
+ unlinkSync36(tmpIn);
585177
585399
  } catch {
585178
585400
  }
585179
585401
  try {
585180
- unlinkSync35(tmpOut);
585402
+ unlinkSync36(tmpOut);
585181
585403
  } catch {
585182
585404
  }
585183
585405
  } catch {
@@ -588250,7 +588472,7 @@ var init_composite_scorer = __esm({
588250
588472
  });
588251
588473
 
588252
588474
  // packages/orchestrator/dist/memory/materialization-policy.js
588253
- import { createHash as createHash27 } from "node:crypto";
588475
+ import { createHash as createHash28 } from "node:crypto";
588254
588476
  function materializeMemoryItems(items, options2 = {}) {
588255
588477
  const config = options2.config ?? DEFAULT_WEIGHTING_CONFIG;
588256
588478
  const sorted = [...items].sort((a2, b) => b.weight - a2.weight || a2.id.localeCompare(b.id));
@@ -588488,7 +588710,7 @@ function estimateTokens4(text2) {
588488
588710
  return Math.max(1, Math.ceil(text2.length / 4));
588489
588711
  }
588490
588712
  function hashText(text2) {
588491
- return createHash27("sha256").update(text2).digest("hex");
588713
+ return createHash28("sha256").update(text2).digest("hex");
588492
588714
  }
588493
588715
  var init_materialization_policy = __esm({
588494
588716
  "packages/orchestrator/dist/memory/materialization-policy.js"() {
@@ -588652,7 +588874,7 @@ var init_config_loader = __esm({
588652
588874
  });
588653
588875
 
588654
588876
  // packages/orchestrator/dist/memory/stability-tracker.js
588655
- import { createHash as createHash28 } from "node:crypto";
588877
+ import { createHash as createHash29 } from "node:crypto";
588656
588878
  import { existsSync as existsSync101, mkdirSync as mkdirSync56, readFileSync as readFileSync78, writeFileSync as writeFileSync47 } from "node:fs";
588657
588879
  import { dirname as dirname35, join as join111 } from "node:path";
588658
588880
  function stabilityFilePath(repoRoot) {
@@ -588716,7 +588938,7 @@ function computeStabilityHash(item) {
588716
588938
  item.scope.name,
588717
588939
  item.topicKey
588718
588940
  ].join("|");
588719
- return createHash28("sha256").update(normalized).digest("hex");
588941
+ return createHash29("sha256").update(normalized).digest("hex");
588720
588942
  }
588721
588943
  function normalizeContent2(content) {
588722
588944
  return content.replace(/\s+/g, " ").trim();
@@ -592131,10 +592353,10 @@ var init_project_arc = __esm({
592131
592353
  });
592132
592354
 
592133
592355
  // packages/orchestrator/dist/dedup-gate.js
592134
- import { createHash as createHash29 } from "node:crypto";
592356
+ import { createHash as createHash30 } from "node:crypto";
592135
592357
  function fingerprintCall(name10, args) {
592136
592358
  const canon = canonicalize(args);
592137
- return createHash29("sha1").update(`${name10}\0${canon}`).digest("hex").slice(0, 16);
592359
+ return createHash30("sha1").update(`${name10}\0${canon}`).digest("hex").slice(0, 16);
592138
592360
  }
592139
592361
  function canonicalize(value2) {
592140
592362
  if (value2 === null || typeof value2 !== "object")
@@ -596419,7 +596641,7 @@ var require_websocket3 = __commonJS({
596419
596641
  var http6 = __require("http");
596420
596642
  var net5 = __require("net");
596421
596643
  var tls2 = __require("tls");
596422
- var { randomBytes: randomBytes30, createHash: createHash44 } = __require("crypto");
596644
+ var { randomBytes: randomBytes30, createHash: createHash45 } = __require("crypto");
596423
596645
  var { Duplex: Duplex3, Readable } = __require("stream");
596424
596646
  var { URL: URL3 } = __require("url");
596425
596647
  var PerMessageDeflate3 = require_permessage_deflate3();
@@ -597079,7 +597301,7 @@ var require_websocket3 = __commonJS({
597079
597301
  abortHandshake(websocket, socket, "Invalid Upgrade header");
597080
597302
  return;
597081
597303
  }
597082
- const digest3 = createHash44("sha1").update(key + GUID).digest("base64");
597304
+ const digest3 = createHash45("sha1").update(key + GUID).digest("base64");
597083
597305
  if (res.headers["sec-websocket-accept"] !== digest3) {
597084
597306
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
597085
597307
  return;
@@ -597446,7 +597668,7 @@ var require_websocket_server2 = __commonJS({
597446
597668
  var EventEmitter15 = __require("events");
597447
597669
  var http6 = __require("http");
597448
597670
  var { Duplex: Duplex3 } = __require("stream");
597449
- var { createHash: createHash44 } = __require("crypto");
597671
+ var { createHash: createHash45 } = __require("crypto");
597450
597672
  var extension3 = require_extension3();
597451
597673
  var PerMessageDeflate3 = require_permessage_deflate3();
597452
597674
  var subprotocol3 = require_subprotocol2();
@@ -597747,7 +597969,7 @@ var require_websocket_server2 = __commonJS({
597747
597969
  );
597748
597970
  }
597749
597971
  if (this._state > RUNNING) return abortHandshake(socket, 503);
597750
- const digest3 = createHash44("sha1").update(key + GUID).digest("base64");
597972
+ const digest3 = createHash45("sha1").update(key + GUID).digest("base64");
597751
597973
  const headers = [
597752
597974
  "HTTP/1.1 101 Switching Protocols",
597753
597975
  "Upgrade: websocket",
@@ -604143,14 +604365,14 @@ var init_voice_session = __esm({
604143
604365
  });
604144
604366
 
604145
604367
  // packages/cli/src/tui/scoped-personality.ts
604146
- import { createHash as createHash30 } from "node:crypto";
604368
+ import { createHash as createHash31 } from "node:crypto";
604147
604369
  import { appendFileSync as appendFileSync9, existsSync as existsSync107, mkdirSync as mkdirSync64, readFileSync as readFileSync85, writeFileSync as writeFileSync54 } from "node:fs";
604148
604370
  import { join as join121, resolve as resolve50 } from "node:path";
604149
604371
  function safeName(input) {
604150
604372
  return input.replace(/[^A-Za-z0-9_.-]/g, "-").slice(0, 80) || "default";
604151
604373
  }
604152
604374
  function scopeHash(scope) {
604153
- return createHash30("sha1").update(`${scope.kind}:${scope.id}`).digest("hex").slice(0, 16);
604375
+ return createHash31("sha1").update(`${scope.kind}:${scope.id}`).digest("hex").slice(0, 16);
604154
604376
  }
604155
604377
  function scopedPersonalityDir(repoRoot, kind) {
604156
604378
  return resolve50(repoRoot, ".omnius", "scoped-personality", kind);
@@ -604522,7 +604744,7 @@ var init_scoped_personality = __esm({
604522
604744
  });
604523
604745
 
604524
604746
  // packages/cli/src/tui/voice-soul.ts
604525
- import { createHash as createHash31 } from "node:crypto";
604747
+ import { createHash as createHash32 } from "node:crypto";
604526
604748
  import { existsSync as existsSync108, readdirSync as readdirSync35, readFileSync as readFileSync86 } from "node:fs";
604527
604749
  import { basename as basename21, join as join122, resolve as resolve51 } from "node:path";
604528
604750
  function compactText(text2, limit) {
@@ -604537,7 +604759,7 @@ function blockText(text2, limit) {
604537
604759
  ... [truncated]`;
604538
604760
  }
604539
604761
  function scopeStateKey(scope, surface) {
604540
- return createHash31("sha1").update(`${surface}:${scope.kind}:${scope.id}`).digest("hex").slice(0, 16);
604762
+ return createHash32("sha1").update(`${surface}:${scope.kind}:${scope.id}`).digest("hex").slice(0, 16);
604541
604763
  }
604542
604764
  function safeName2(input) {
604543
604765
  return input.replace(/[^A-Za-z0-9_.-]/g, "-").slice(0, 80) || "default";
@@ -607181,7 +607403,7 @@ var init_types3 = __esm({
607181
607403
  });
607182
607404
 
607183
607405
  // packages/cli/src/tui/p2p/secret-vault.ts
607184
- import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes22, scryptSync as scryptSync2, createHash as createHash32 } from "node:crypto";
607406
+ import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes22, scryptSync as scryptSync2, createHash as createHash33 } from "node:crypto";
607185
607407
  import { readFileSync as readFileSync88, writeFileSync as writeFileSync56, existsSync as existsSync110, mkdirSync as mkdirSync66 } from "node:fs";
607186
607408
  import { dirname as dirname38 } from "node:path";
607187
607409
  var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
@@ -607426,7 +607648,7 @@ var init_secret_vault = __esm({
607426
607648
  /** Generate a deterministic fingerprint of vault contents (for sync verification) */
607427
607649
  fingerprint() {
607428
607650
  const names = Array.from(this.secrets.keys()).sort();
607429
- const hash = createHash32("sha256");
607651
+ const hash = createHash33("sha256");
607430
607652
  for (const name10 of names) {
607431
607653
  hash.update(name10 + ":");
607432
607654
  hash.update(this.secrets.get(name10).value);
@@ -607441,7 +607663,7 @@ var init_secret_vault = __esm({
607441
607663
  // packages/cli/src/tui/p2p/peer-mesh.ts
607442
607664
  import { EventEmitter as EventEmitter9 } from "node:events";
607443
607665
  import { createServer as createServer6 } from "node:http";
607444
- import { randomBytes as randomBytes23, createHash as createHash33, generateKeyPairSync } from "node:crypto";
607666
+ import { randomBytes as randomBytes23, createHash as createHash34, generateKeyPairSync } from "node:crypto";
607445
607667
  var PING_INTERVAL_MS, PEER_TIMEOUT_MS, GOSSIP_INTERVAL_MS, MAX_PEERS, PeerMesh;
607446
607668
  var init_peer_mesh = __esm({
607447
607669
  "packages/cli/src/tui/p2p/peer-mesh.ts"() {
@@ -607458,7 +607680,7 @@ var init_peer_mesh = __esm({
607458
607680
  const { publicKey: publicKey2, privateKey } = generateKeyPairSync("ed25519");
607459
607681
  this.publicKey = publicKey2.export({ type: "spki", format: "der" });
607460
607682
  this.privateKey = privateKey.export({ type: "pkcs8", format: "der" });
607461
- this.peerId = createHash33("sha256").update(this.publicKey).digest("base64url").slice(0, 22);
607683
+ this.peerId = createHash34("sha256").update(this.publicKey).digest("base64url").slice(0, 22);
607462
607684
  this.capabilities = options2.capabilities;
607463
607685
  this.displayName = options2.displayName;
607464
607686
  this._authKey = options2.authKey ?? randomBytes23(24).toString("base64url");
@@ -608823,7 +609045,7 @@ __export(omnius_directory_exports, {
608823
609045
  import { appendFileSync as appendFileSync10, cpSync as cpSync2, existsSync as existsSync112, mkdirSync as mkdirSync68, readFileSync as readFileSync90, writeFileSync as writeFileSync58, readdirSync as readdirSync38, statSync as statSync41, unlinkSync as unlinkSync21, openSync as openSync2, closeSync as closeSync2, renameSync as renameSync9, watch as fsWatch2 } from "node:fs";
608824
609046
  import { join as join126, relative as relative12, basename as basename22, dirname as dirname39, resolve as resolve52 } from "node:path";
608825
609047
  import { homedir as homedir38 } from "node:os";
608826
- import { createHash as createHash35 } from "node:crypto";
609048
+ import { createHash as createHash36 } from "node:crypto";
608827
609049
  function isGitRoot(dir) {
608828
609050
  const gitPath = join126(dir, ".git");
608829
609051
  if (!existsSync112(gitPath)) return false;
@@ -609277,7 +609499,7 @@ function buildHandoffPrompt(repoRoot) {
609277
609499
  return lines.join("\n");
609278
609500
  }
609279
609501
  function computeDedupeHash(task, savedAt) {
609280
- return createHash35("sha256").update(`${task}|${savedAt}`).digest("hex").slice(0, 16);
609502
+ return createHash36("sha256").update(`${task}|${savedAt}`).digest("hex").slice(0, 16);
609281
609503
  }
609282
609504
  function generateSessionId() {
609283
609505
  const timestamp = Date.now().toString(36);
@@ -633754,7 +633976,7 @@ __export(commands_exports, {
633754
633976
  });
633755
633977
  import * as nodeOs from "node:os";
633756
633978
  import { execSync as nodeExecSync, spawn as nodeSpawn2 } from "node:child_process";
633757
- import { createHash as createHash36 } from "node:crypto";
633979
+ import { createHash as createHash37 } from "node:crypto";
633758
633980
  import {
633759
633981
  existsSync as existsSync132,
633760
633982
  readFileSync as readFileSync106,
@@ -645879,7 +646101,7 @@ async function collectSponsorMediaStream(args) {
645879
646101
  };
645880
646102
  }
645881
646103
  if (artifact.sha256) {
645882
- const sha = createHash36("sha256").update(bytes).digest("hex");
646104
+ const sha = createHash37("sha256").update(bytes).digest("hex");
645883
646105
  if (sha !== artifact.sha256)
645884
646106
  return { ok: false, error: `Artifact hash mismatch for ${artifactId}` };
645885
646107
  }
@@ -660342,9 +660564,16 @@ var init_soul_observations = __esm({
660342
660564
  });
660343
660565
 
660344
660566
  // packages/cli/src/tui/telegram-channel-dmn.ts
660345
- import { existsSync as existsSync144, mkdirSync as mkdirSync88, readdirSync as readdirSync52, readFileSync as readFileSync117, writeFileSync as writeFileSync76 } from "node:fs";
660567
+ import {
660568
+ existsSync as existsSync144,
660569
+ mkdirSync as mkdirSync88,
660570
+ readdirSync as readdirSync52,
660571
+ readFileSync as readFileSync117,
660572
+ writeFileSync as writeFileSync76,
660573
+ unlinkSync as unlinkSync31
660574
+ } from "node:fs";
660346
660575
  import { join as join156 } from "node:path";
660347
- import { createHash as createHash37 } from "node:crypto";
660576
+ import { createHash as createHash38 } from "node:crypto";
660348
660577
  function safeFilePart(value2) {
660349
660578
  return value2.replace(/[^A-Za-z0-9_.-]+/g, "_").slice(0, 80) || "telegram";
660350
660579
  }
@@ -660352,7 +660581,7 @@ function daydreamRoot(repoRoot) {
660352
660581
  return join156(repoRoot, ".omnius", "telegram-daydreams");
660353
660582
  }
660354
660583
  function sessionDir(repoRoot, sessionKey) {
660355
- const hash = createHash37("sha1").update(sessionKey).digest("hex").slice(0, 20);
660584
+ const hash = createHash38("sha1").update(sessionKey).digest("hex").slice(0, 20);
660356
660585
  return join156(daydreamRoot(repoRoot), safeFilePart(hash));
660357
660586
  }
660358
660587
  function compactLine2(value2, max = 220) {
@@ -660363,7 +660592,9 @@ function isoFromMs(value2) {
660363
660592
  return value2 ? new Date(value2).toISOString() : void 0;
660364
660593
  }
660365
660594
  function topParticipants(input) {
660366
- return [...input.participants].sort((a2, b) => b.messageCount - a2.messageCount || b.lastSeenTs - a2.lastSeenTs).slice(0, 8);
660595
+ return [...input.participants].sort(
660596
+ (a2, b) => b.messageCount - a2.messageCount || b.lastSeenTs - a2.lastSeenTs
660597
+ ).slice(0, 8);
660367
660598
  }
660368
660599
  function recentUserMessages(input) {
660369
660600
  return input.history.filter((entry) => entry.role === "user" && entry.text.trim()).slice(-18);
@@ -660375,7 +660606,9 @@ function buildRelationshipSignals(input) {
660375
660606
  const tones = participant.toneTags.length ? ` tones=${participant.toneTags.slice(0, 5).join(",")}` : "";
660376
660607
  const direct = participant.directAddressCount ? ` direct-addresses=${participant.directAddressCount}` : "";
660377
660608
  const replies = participant.replyCount ? ` replies=${participant.replyCount}` : "";
660378
- signals.push(`${label}: messages=${participant.messageCount}${direct}${replies}${tones}; last="${compactLine2(participant.lastMessage, 160)}"`);
660609
+ signals.push(
660610
+ `${label}: messages=${participant.messageCount}${direct}${replies}${tones}; last="${compactLine2(participant.lastMessage, 160)}"`
660611
+ );
660379
660612
  }
660380
660613
  return signals;
660381
660614
  }
@@ -660384,12 +660617,28 @@ function buildContextEngineeringNotes(input) {
660384
660617
  const recent = recentUserMessages(input);
660385
660618
  const replied = recent.filter((entry) => entry.replyToMessageId);
660386
660619
  const media = recent.filter((entry) => entry.mediaSummary);
660387
- const speakers = new Set(recent.map((entry) => entry.speaker || entry.username || "unknown"));
660388
- notes.push(`Keep the next prompt anchored to ${speakers.size} active participant(s) and ${recent.length} recent user message(s).`);
660389
- if (replied.length > 0) notes.push(`Preserve ${replied.length} reply relationship(s) explicitly; pronouns like this/that likely refer to replied-to content.`);
660390
- if (media.length > 0) notes.push(`Recent media appears in the room; keep paths as tool-only context and avoid exposing local paths in visible Telegram replies.`);
660391
- if (input.memoryCards.length > 0) notes.push(`Use existing scoped memory cards before claiming prior context is unavailable.`);
660392
- if (input.stimulationContext) notes.push("Route decisions should consider the stimulation state but must still infer reply need from the live thread.");
660620
+ const speakers = new Set(
660621
+ recent.map((entry) => entry.speaker || entry.username || "unknown")
660622
+ );
660623
+ notes.push(
660624
+ `Keep the next prompt anchored to ${speakers.size} active participant(s) and ${recent.length} recent user message(s).`
660625
+ );
660626
+ if (replied.length > 0)
660627
+ notes.push(
660628
+ `Preserve ${replied.length} reply relationship(s) explicitly; pronouns like this/that likely refer to replied-to content.`
660629
+ );
660630
+ if (media.length > 0)
660631
+ notes.push(
660632
+ `Recent media appears in the room; keep paths as tool-only context and avoid exposing local paths in visible Telegram replies.`
660633
+ );
660634
+ if (input.memoryCards.length > 0)
660635
+ notes.push(
660636
+ `Use existing scoped memory cards before claiming prior context is unavailable.`
660637
+ );
660638
+ if (input.stimulationContext)
660639
+ notes.push(
660640
+ "Route decisions should consider the stimulation state but must still infer reply need from the live thread."
660641
+ );
660393
660642
  return notes;
660394
660643
  }
660395
660644
  function buildOpenQuestions(input) {
@@ -660398,9 +660647,15 @@ function buildOpenQuestions(input) {
660398
660647
  for (const entry of recent.slice(-10)) {
660399
660648
  const text2 = compactLine2(entry.text, 180);
660400
660649
  if (/[??]\s*$/.test(text2)) {
660401
- questions.push(`${entry.speaker || entry.username || "user"} asked: ${text2}`);
660402
- } else if (/\b(unclear|not sure|maybe|wonder|how do we|what if|why|need to)\b/i.test(text2)) {
660403
- questions.push(`${entry.speaker || entry.username || "user"} left an unresolved thread: ${text2}`);
660650
+ questions.push(
660651
+ `${entry.speaker || entry.username || "user"} asked: ${text2}`
660652
+ );
660653
+ } else if (/\b(unclear|not sure|maybe|wonder|how do we|what if|why|need to)\b/i.test(
660654
+ text2
660655
+ )) {
660656
+ questions.push(
660657
+ `${entry.speaker || entry.username || "user"} left an unresolved thread: ${text2}`
660658
+ );
660404
660659
  }
660405
660660
  }
660406
660661
  return questions.slice(-6);
@@ -660437,7 +660692,7 @@ function buildReplyOpportunities(input, openQuestions) {
660437
660692
  return opportunities;
660438
660693
  }
660439
660694
  function daydreamOpportunityId(input, trigger) {
660440
- return createHash37("sha1").update(`${input.sessionKey}:${input.generatedAtMs}:${trigger}`).digest("hex").slice(0, 16);
660695
+ return createHash38("sha1").update(`${input.sessionKey}:${input.generatedAtMs}:${trigger}`).digest("hex").slice(0, 16);
660441
660696
  }
660442
660697
  function clamp0112(value2) {
660443
660698
  if (!Number.isFinite(value2)) return 0;
@@ -660449,8 +660704,15 @@ function messageLabel(entry) {
660449
660704
  function pushStimulationSignal(signals, signal, source, weight) {
660450
660705
  const cleanSignal = compactLine2(signal, 120);
660451
660706
  const cleanSource = compactLine2(source, 180);
660452
- if (!cleanSignal || signals.some((entry) => entry.signal === cleanSignal && entry.source === cleanSource)) return;
660453
- signals.push({ signal: cleanSignal, source: cleanSource, weight: clamp0112(weight) });
660707
+ if (!cleanSignal || signals.some(
660708
+ (entry) => entry.signal === cleanSignal && entry.source === cleanSource
660709
+ ))
660710
+ return;
660711
+ signals.push({
660712
+ signal: cleanSignal,
660713
+ source: cleanSource,
660714
+ weight: clamp0112(weight)
660715
+ });
660454
660716
  }
660455
660717
  function buildMetaAnalysisSignals(input) {
660456
660718
  const chatLabel = input.chatTitle || input.chatId;
@@ -660467,39 +660729,91 @@ function buildHumanStimulationSignals(input) {
660467
660729
  const participants = topParticipants(input);
660468
660730
  const last2 = recent[recent.length - 1];
660469
660731
  if (input.stimulationContext) {
660470
- pushStimulationSignal(signals, "idle stimulation snapshot available", input.stimulationContext.split("\n").slice(0, 2).join(" / "), 0.42);
660732
+ pushStimulationSignal(
660733
+ signals,
660734
+ "idle stimulation snapshot available",
660735
+ input.stimulationContext.split("\n").slice(0, 2).join(" / "),
660736
+ 0.42
660737
+ );
660471
660738
  }
660472
660739
  if (participants.length > 1) {
660473
- pushStimulationSignal(signals, "multi-person social context", `${participants.length} active participant profiles`, 0.58);
660740
+ pushStimulationSignal(
660741
+ signals,
660742
+ "multi-person social context",
660743
+ `${participants.length} active participant profiles`,
660744
+ 0.58
660745
+ );
660474
660746
  }
660475
660747
  for (const participant of participants.slice(0, 5)) {
660476
660748
  if (participant.directAddressCount > 0) {
660477
- pushStimulationSignal(signals, "direct agent address history", `${participant.username || participant.firstName}: ${participant.directAddressCount} direct address(es)`, 0.74);
660749
+ pushStimulationSignal(
660750
+ signals,
660751
+ "direct agent address history",
660752
+ `${participant.username || participant.firstName}: ${participant.directAddressCount} direct address(es)`,
660753
+ 0.74
660754
+ );
660478
660755
  }
660479
660756
  if (participant.replyCount > 0) {
660480
- pushStimulationSignal(signals, "reply-chain salience", `${participant.username || participant.firstName}: ${participant.replyCount} reply relationship(s)`, 0.68);
660757
+ pushStimulationSignal(
660758
+ signals,
660759
+ "reply-chain salience",
660760
+ `${participant.username || participant.firstName}: ${participant.replyCount} reply relationship(s)`,
660761
+ 0.68
660762
+ );
660481
660763
  }
660482
660764
  if (participant.toneTags.includes("frustrated") || participant.toneTags.includes("technical")) {
660483
- pushStimulationSignal(signals, "high-specificity user state", `${participant.username || participant.firstName}: tones=${participant.toneTags.slice(0, 5).join(",")}`, 0.61);
660765
+ pushStimulationSignal(
660766
+ signals,
660767
+ "high-specificity user state",
660768
+ `${participant.username || participant.firstName}: tones=${participant.toneTags.slice(0, 5).join(",")}`,
660769
+ 0.61
660770
+ );
660484
660771
  }
660485
660772
  }
660486
660773
  for (const entry of recent.slice(-8)) {
660487
660774
  const text2 = compactLine2(entry.text, 160);
660488
660775
  if (/[??]\s*$/.test(text2)) {
660489
- pushStimulationSignal(signals, "open question", `${messageLabel(entry)}: ${text2}`, 0.7);
660776
+ pushStimulationSignal(
660777
+ signals,
660778
+ "open question",
660779
+ `${messageLabel(entry)}: ${text2}`,
660780
+ 0.7
660781
+ );
660490
660782
  }
660491
- if (/\b(wonder|curious|why|how|what if|not sure|maybe|confused|unclear)\b/i.test(text2)) {
660492
- pushStimulationSignal(signals, "curiosity or uncertainty cue", `${messageLabel(entry)}: ${text2}`, 0.64);
660783
+ if (/\b(wonder|curious|why|how|what if|not sure|maybe|confused|unclear)\b/i.test(
660784
+ text2
660785
+ )) {
660786
+ pushStimulationSignal(
660787
+ signals,
660788
+ "curiosity or uncertainty cue",
660789
+ `${messageLabel(entry)}: ${text2}`,
660790
+ 0.64
660791
+ );
660493
660792
  }
660494
660793
  if (entry.mediaSummary) {
660495
- pushStimulationSignal(signals, "multimodal memory cue", `${messageLabel(entry)}: ${entry.mediaSummary}`, 0.66);
660794
+ pushStimulationSignal(
660795
+ signals,
660796
+ "multimodal memory cue",
660797
+ `${messageLabel(entry)}: ${entry.mediaSummary}`,
660798
+ 0.66
660799
+ );
660496
660800
  }
660497
660801
  if (entry.replyToMessageId) {
660498
- pushStimulationSignal(signals, "explicit reply dependency", `${messageLabel(entry)} replied to message ${entry.replyToMessageId}`, 0.72);
660802
+ pushStimulationSignal(
660803
+ signals,
660804
+ "explicit reply dependency",
660805
+ `${messageLabel(entry)} replied to message ${entry.replyToMessageId}`,
660806
+ 0.72
660807
+ );
660499
660808
  }
660500
660809
  }
660501
660810
  if (last2 && /\b(omnius|bot|agent)\b/i.test(last2.text)) {
660502
- pushStimulationSignal(signals, "agent-name mention", `${messageLabel(last2)}: ${compactLine2(last2.text, 160)}`, 0.57);
660811
+ pushStimulationSignal(
660812
+ signals,
660813
+ "agent-name mention",
660814
+ `${messageLabel(last2)}: ${compactLine2(last2.text, 160)}`,
660815
+ 0.57
660816
+ );
660503
660817
  }
660504
660818
  return signals.sort((a2, b) => b.weight - a2.weight).slice(0, 12);
660505
660819
  }
@@ -660512,7 +660826,9 @@ function buildCuriosityThreads(input, openQuestions, stimulationSignals) {
660512
660826
  const threads = [];
660513
660827
  const recent = recentUserMessages(input);
660514
660828
  const sourceEntries = recent.filter(
660515
- (entry) => /[??]\s*$/.test(entry.text) || /\b(wonder|curious|why|how do we|what if|not sure|maybe|need to|unclear|confused)\b/i.test(entry.text) || entry.mediaSummary
660829
+ (entry) => /[??]\s*$/.test(entry.text) || /\b(wonder|curious|why|how do we|what if|not sure|maybe|need to|unclear|confused)\b/i.test(
660830
+ entry.text
660831
+ ) || entry.mediaSummary
660516
660832
  );
660517
660833
  for (const entry of sourceEntries.slice(-6)) {
660518
660834
  const text2 = compactLine2(entry.text, 220);
@@ -660529,7 +660845,10 @@ function buildCuriosityThreads(input, openQuestions, stimulationSignals) {
660529
660845
  });
660530
660846
  }
660531
660847
  for (const question of openQuestions.slice(-4)) {
660532
- if (threads.some((thread) => question.includes(thread.title) || thread.question.includes(question))) continue;
660848
+ if (threads.some(
660849
+ (thread) => question.includes(thread.title) || thread.question.includes(question)
660850
+ ))
660851
+ continue;
660533
660852
  threads.push({
660534
660853
  title: titleFromText(question),
660535
660854
  question,
@@ -660600,13 +660919,19 @@ function buildScopedExplorationTools(input) {
660600
660919
  }
660601
660920
  function participantForThread(input, thread) {
660602
660921
  const sourceIds = new Set(thread.sourceMessages);
660603
- const sourceMessage = input.history.find((entry) => typeof entry.messageId === "number" && sourceIds.has(entry.messageId));
660922
+ const sourceMessage = input.history.find(
660923
+ (entry) => typeof entry.messageId === "number" && sourceIds.has(entry.messageId)
660924
+ );
660604
660925
  if (sourceMessage?.username) {
660605
- return input.participants.find((participant) => participant.username === sourceMessage.username);
660926
+ return input.participants.find(
660927
+ (participant) => participant.username === sourceMessage.username
660928
+ );
660606
660929
  }
660607
660930
  if (sourceMessage?.speaker) {
660608
660931
  const clean5 = sourceMessage.speaker.replace(/^@/, "");
660609
- return input.participants.find((participant) => participant.username === clean5 || participant.firstName === sourceMessage.speaker);
660932
+ return input.participants.find(
660933
+ (participant) => participant.username === clean5 || participant.firstName === sourceMessage.speaker
660934
+ );
660610
660935
  }
660611
660936
  return topParticipants(input)[0];
660612
660937
  }
@@ -660637,9 +660962,17 @@ function buildOutreachPlans(input, curiosityThreads) {
660637
660962
  return plans.slice(0, 8);
660638
660963
  }
660639
660964
  function personaDirectiveLines(personaContext) {
660640
- const lines = (personaContext || "").split("\n").map((line) => compactLine2(line.replace(/^[-#*\s]+/, ""), 180)).filter((line) => line && !/^```/.test(line) && !/^Scope:/.test(line) && !/^Updated:/.test(line)).filter((line) => !/Scoped Personality Profile|Scoped Personality Driver|Messages observed/i.test(line));
660965
+ const lines = (personaContext || "").split("\n").map((line) => compactLine2(line.replace(/^[-#*\s]+/, ""), 180)).filter(
660966
+ (line) => line && !/^```/.test(line) && !/^Scope:/.test(line) && !/^Updated:/.test(line)
660967
+ ).filter(
660968
+ (line) => !/Scoped Personality Profile|Scoped Personality Driver|Messages observed/i.test(
660969
+ line
660970
+ )
660971
+ );
660641
660972
  const selected = lines.filter(
660642
- (line) => /\b(prefer|use|track|mirror|answer|do not|avoid|boundary|relationship|tone|style|guidance)\b/i.test(line)
660973
+ (line) => /\b(prefer|use|track|mirror|answer|do not|avoid|boundary|relationship|tone|style|guidance)\b/i.test(
660974
+ line
660975
+ )
660643
660976
  ).slice(0, 8);
660644
660977
  if (selected.length > 0) return selected;
660645
660978
  return [
@@ -660655,7 +660988,8 @@ function buildPersonaSteering(input) {
660655
660988
  "Maintain high curiosity during private analysis while keeping visible public replies low-intrusion.",
660656
660989
  "Use scoped tool evidence before follow-up; do not turn curiosity into unsolicited claims."
660657
660990
  ]) {
660658
- if (!directives.some((line) => line === required)) directives.push(required);
660991
+ if (!directives.some((line) => line === required))
660992
+ directives.push(required);
660659
660993
  }
660660
660994
  return {
660661
660995
  source: input.personaContext ? "scoped-personality document" : "default Telegram daydream steering",
@@ -660731,7 +661065,11 @@ function buildTelegramChannelDaydream(input, corpus, extraction, extractionCommi
660731
661065
  const relationshipSignals = buildRelationshipSignals(input);
660732
661066
  const contextEngineeringNotes = buildContextEngineeringNotes(input);
660733
661067
  const openQuestions = buildOpenQuestions(input);
660734
- const curiosityThreads = buildCuriosityThreads(input, openQuestions, humanStimulationSignals);
661068
+ const curiosityThreads = buildCuriosityThreads(
661069
+ input,
661070
+ openQuestions,
661071
+ humanStimulationSignals
661072
+ );
660735
661073
  const scopedExplorationTools = buildScopedExplorationTools(input);
660736
661074
  const outreachPlans = buildOutreachPlans(input, curiosityThreads);
660737
661075
  const personaSteering = buildPersonaSteering(input);
@@ -660753,11 +661091,13 @@ function buildTelegramChannelDaydream(input, corpus, extraction, extractionCommi
660753
661091
  kind: "memory_card",
660754
661092
  rationale: "Promote repeated user/channel patterns into scoped memory cards rather than raw transcript clutter."
660755
661093
  } : null
660756
- ].filter((entry) => Boolean(entry));
661094
+ ].filter(
661095
+ (entry) => Boolean(entry)
661096
+ );
660757
661097
  const seed = `${input.sessionKey}:${input.generatedAtMs}:${input.history.length}`;
660758
661098
  return {
660759
661099
  version: 3,
660760
- id: createHash37("sha1").update(seed).digest("hex").slice(0, 16),
661100
+ id: createHash38("sha1").update(seed).digest("hex").slice(0, 16),
660761
661101
  sessionKey: input.sessionKey,
660762
661102
  chatId: input.chatId,
660763
661103
  chatTitle: input.chatTitle,
@@ -660795,7 +661135,10 @@ function buildTelegramChannelDaydream(input, corpus, extraction, extractionCommi
660795
661135
  };
660796
661136
  }
660797
661137
  function formatTelegramChannelDaydreamMarkdown(artifact) {
660798
- const section = (title, lines) => [`## ${title}`, lines.length ? lines.map((line) => `- ${line}`).join("\n") : "- None"].join("\n");
661138
+ const section = (title, lines) => [
661139
+ `## ${title}`,
661140
+ lines.length ? lines.map((line) => `- ${line}`).join("\n") : "- None"
661141
+ ].join("\n");
660799
661142
  return [
660800
661143
  `# Telegram Channel Daydream ${artifact.id}`,
660801
661144
  "",
@@ -660816,51 +661159,71 @@ function formatTelegramChannelDaydreamMarkdown(artifact) {
660816
661159
  Selected seed: ${artifact.selectedSeed.nodeText} (${artifact.selectedSeed.nodeType}, degree ${artifact.selectedSeed.degree})` : "",
660817
661160
  "",
660818
661161
  "## Tags",
660819
- artifact.tagging.length ? artifact.tagging.map((item) => `- ${item.label} [${item.kind}] confidence=${item.confidence.toFixed(2)}${item.sourceMessageIds.length ? ` messages=${item.sourceMessageIds.join(", ")}` : ""}`).join("\n") : "- None",
661162
+ artifact.tagging.length ? artifact.tagging.map(
661163
+ (item) => `- ${item.label} [${item.kind}] confidence=${item.confidence.toFixed(2)}${item.sourceMessageIds.length ? ` messages=${item.sourceMessageIds.join(", ")}` : ""}`
661164
+ ).join("\n") : "- None",
660820
661165
  "",
660821
661166
  "## Summaries",
660822
- artifact.summation.length ? artifact.summation.map((item) => `- ${item.title} [${item.scope}] confidence=${item.confidence.toFixed(2)}
661167
+ artifact.summation.length ? artifact.summation.map(
661168
+ (item) => `- ${item.title} [${item.scope}] confidence=${item.confidence.toFixed(2)}
660823
661169
  ${item.text}${item.sourceMessageIds.length ? `
660824
- messages=${item.sourceMessageIds.join(", ")}` : ""}`).join("\n") : "- None",
661170
+ messages=${item.sourceMessageIds.join(", ")}` : ""}`
661171
+ ).join("\n") : "- None",
660825
661172
  "",
660826
661173
  "## Titles",
660827
- artifact.titling.length ? artifact.titling.map((item) => `- ${item.title} -> ${item.target} confidence=${item.confidence.toFixed(2)}`).join("\n") : "- None",
661174
+ artifact.titling.length ? artifact.titling.map(
661175
+ (item) => `- ${item.title} -> ${item.target} confidence=${item.confidence.toFixed(2)}`
661176
+ ).join("\n") : "- None",
660828
661177
  "",
660829
661178
  "## Extractions",
660830
- artifact.extraction.length ? artifact.extraction.map((item) => `- ${item.kind}: ${item.text} confidence=${item.confidence.toFixed(2)}${item.sourceMessageIds.length ? ` messages=${item.sourceMessageIds.join(", ")}` : ""}`).join("\n") : "- None",
661179
+ artifact.extraction.length ? artifact.extraction.map(
661180
+ (item) => `- ${item.kind}: ${item.text} confidence=${item.confidence.toFixed(2)}${item.sourceMessageIds.length ? ` messages=${item.sourceMessageIds.join(", ")}` : ""}`
661181
+ ).join("\n") : "- None",
660831
661182
  "",
660832
661183
  "## Links",
660833
- artifact.linking.length ? artifact.linking.map((item) => `- ${item.srcNodeText} --${item.relation}--> ${item.dstNodeText} confidence=${item.confidence.toFixed(2)}
661184
+ artifact.linking.length ? artifact.linking.map(
661185
+ (item) => `- ${item.srcNodeText} --${item.relation}--> ${item.dstNodeText} confidence=${item.confidence.toFixed(2)}
660834
661186
  ${item.fact}${item.sourceMessageIds.length ? `
660835
- messages=${item.sourceMessageIds.join(", ")}` : ""}`).join("\n") : "- None",
661187
+ messages=${item.sourceMessageIds.join(", ")}` : ""}`
661188
+ ).join("\n") : "- None",
660836
661189
  "",
660837
661190
  "## Extraction Followups",
660838
- artifact.extractionFollowups.length ? artifact.extractionFollowups.map((item) => `- ${item.target}${item.replyToMessageId ? ` reply_to=${item.replyToMessageId}` : ""} confidence=${item.confidence.toFixed(2)}
660839
- ${item.text || item.rationale}`).join("\n") : "- None",
661191
+ artifact.extractionFollowups.length ? artifact.extractionFollowups.map(
661192
+ (item) => `- ${item.target}${item.replyToMessageId ? ` reply_to=${item.replyToMessageId}` : ""} confidence=${item.confidence.toFixed(2)}
661193
+ ${item.text || item.rationale}`
661194
+ ).join("\n") : "- None",
660840
661195
  "",
660841
661196
  section("Meta-Analysis Signals", artifact.metaAnalysisSignals),
660842
661197
  "",
660843
661198
  "## Human Stimulation Signals",
660844
- artifact.humanStimulationSignals.length ? artifact.humanStimulationSignals.map((item) => `- ${item.signal}: ${item.source} (weight ${item.weight.toFixed(2)})`).join("\n") : "- None",
661199
+ artifact.humanStimulationSignals.length ? artifact.humanStimulationSignals.map(
661200
+ (item) => `- ${item.signal}: ${item.source} (weight ${item.weight.toFixed(2)})`
661201
+ ).join("\n") : "- None",
660845
661202
  "",
660846
661203
  "## Curiosity Threads",
660847
- artifact.curiosityThreads.length ? artifact.curiosityThreads.map((item) => `- ${item.title}
661204
+ artifact.curiosityThreads.length ? artifact.curiosityThreads.map(
661205
+ (item) => `- ${item.title}
660848
661206
  - question: ${item.question}
660849
661207
  - rationale: ${item.rationale}
660850
661208
  - intensity: ${item.intensity.toFixed(2)}${item.sourceMessages.length ? `
660851
- - source messages: ${item.sourceMessages.join(", ")}` : ""}`).join("\n") : "- None",
661209
+ - source messages: ${item.sourceMessages.join(", ")}` : ""}`
661210
+ ).join("\n") : "- None",
660852
661211
  "",
660853
661212
  "## Scoped Exploration Tool Suite",
660854
- artifact.scopedExplorationTools.length ? artifact.scopedExplorationTools.map((item) => `- ${item.name} [${item.visibility}]
661213
+ artifact.scopedExplorationTools.length ? artifact.scopedExplorationTools.map(
661214
+ (item) => `- ${item.name} [${item.visibility}]
660855
661215
  - scope: ${item.scope}
660856
- - use: ${item.use}`).join("\n") : "- None",
661216
+ - use: ${item.use}`
661217
+ ).join("\n") : "- None",
660857
661218
  "",
660858
661219
  "## Outreach Plans",
660859
- artifact.outreachPlans.length ? artifact.outreachPlans.map((item) => `- ${item.target}${item.recipient ? ` -> ${item.recipient}` : ""} [${item.gate}]
661220
+ artifact.outreachPlans.length ? artifact.outreachPlans.map(
661221
+ (item) => `- ${item.target}${item.recipient ? ` -> ${item.recipient}` : ""} [${item.gate}]
660860
661222
  - trigger: ${item.trigger}
660861
661223
  - purpose: ${item.purpose}
660862
661224
  - draft intent: ${item.draftIntent}
660863
- - confidence: ${item.confidence.toFixed(2)}`).join("\n") : "- None",
661225
+ - confidence: ${item.confidence.toFixed(2)}`
661226
+ ).join("\n") : "- None",
660864
661227
  "",
660865
661228
  "## Persona Steering",
660866
661229
  `Source: ${artifact.personaSteering.source}`,
@@ -660873,15 +661236,19 @@ Selected seed: ${artifact.selectedSeed.nodeText} (${artifact.selectedSeed.nodeTy
660873
661236
  section("Open Questions", artifact.openQuestions),
660874
661237
  "",
660875
661238
  "## Reply Opportunities",
660876
- artifact.replyOpportunities.length ? artifact.replyOpportunities.map((item) => `- ${item.trigger}
661239
+ artifact.replyOpportunities.length ? artifact.replyOpportunities.map(
661240
+ (item) => `- ${item.trigger}
660877
661241
  - id: ${item.id}
660878
661242
  - lifecycle: ${item.lifecycle}${item.lifecycleUpdatedAt ? ` at ${item.lifecycleUpdatedAt}` : ""}
660879
661243
  - rationale: ${item.rationale}
660880
661244
  - tone: ${item.suggestedTone}
660881
- - confidence: ${item.confidence.toFixed(2)}`).join("\n") : "- None",
661245
+ - confidence: ${item.confidence.toFixed(2)}`
661246
+ ).join("\n") : "- None",
660882
661247
  "",
660883
661248
  "## Memory Proposals",
660884
- artifact.memoryProposals.length ? artifact.memoryProposals.map((item) => `- ${item.title}: ${item.rationale}${item.sourceMessages.length ? ` (messages ${item.sourceMessages.join(", ")})` : ""}`).join("\n") : "- None",
661249
+ artifact.memoryProposals.length ? artifact.memoryProposals.map(
661250
+ (item) => `- ${item.title}: ${item.rationale}${item.sourceMessages.length ? ` (messages ${item.sourceMessages.join(", ")})` : ""}`
661251
+ ).join("\n") : "- None",
660885
661252
  "",
660886
661253
  "## Artifact Proposals",
660887
661254
  artifact.artifactProposals.length ? artifact.artifactProposals.map((item) => `- ${item.title} [${item.kind}]: ${item.rationale}`).join("\n") : "- None",
@@ -660889,17 +661256,33 @@ Selected seed: ${artifact.selectedSeed.nodeText} (${artifact.selectedSeed.nodeTy
660889
661256
  ## Stimulation Snapshot
660890
661257
 
660891
661258
  \`\`\`text
660892
- ${artifact.stimulationContext}
661259
+ ${artifact.stimulationContext.slice(0, 3e3)}
660893
661260
  \`\`\`` : "",
660894
661261
  artifact.personaContext ? `
660895
661262
  ## Persona Snapshot
660896
661263
 
660897
661264
  \`\`\`text
660898
- ${artifact.personaContext}
661265
+ ${artifact.personaContext.slice(0, 3e3)}
660899
661266
  \`\`\`` : "",
660900
661267
  ""
660901
661268
  ].join("\n");
660902
661269
  }
661270
+ function pruneTelegramChannelDaydreams(repoRoot, sessionKey, keep = DAYDREAM_ARTIFACT_RETENTION_LIMIT) {
661271
+ const dir = sessionDir(repoRoot, sessionKey);
661272
+ if (!existsSync144(dir)) return 0;
661273
+ const files = readdirSync52(dir).filter((f2) => f2.endsWith(".json") || f2.endsWith(".md")).sort();
661274
+ if (files.length <= keep * 2) return 0;
661275
+ const toRemove = files.slice(0, files.length - keep * 2);
661276
+ let removed = 0;
661277
+ for (const file of toRemove) {
661278
+ try {
661279
+ unlinkSync31(join156(dir, file));
661280
+ removed++;
661281
+ } catch {
661282
+ }
661283
+ }
661284
+ return removed;
661285
+ }
660903
661286
  function writeTelegramChannelDaydream(repoRoot, artifact) {
660904
661287
  const dir = sessionDir(repoRoot, artifact.sessionKey);
660905
661288
  mkdirSync88(dir, { recursive: true });
@@ -660907,7 +661290,12 @@ function writeTelegramChannelDaydream(repoRoot, artifact) {
660907
661290
  const jsonPath = join156(dir, `${base3}.json`);
660908
661291
  const markdownPath = join156(dir, `${base3}.md`);
660909
661292
  writeFileSync76(jsonPath, JSON.stringify(artifact, null, 2) + "\n", "utf8");
660910
- writeFileSync76(markdownPath, formatTelegramChannelDaydreamMarkdown(artifact), "utf8");
661293
+ writeFileSync76(
661294
+ markdownPath,
661295
+ formatTelegramChannelDaydreamMarkdown(artifact),
661296
+ "utf8"
661297
+ );
661298
+ pruneTelegramChannelDaydreams(repoRoot, artifact.sessionKey);
660911
661299
  return { dir, jsonPath, markdownPath };
660912
661300
  }
660913
661301
  function latestTelegramChannelDaydream(repoRoot, sessionKey) {
@@ -660916,7 +661304,9 @@ function latestTelegramChannelDaydream(repoRoot, sessionKey) {
660916
661304
  const files = readdirSync52(dir).filter((file) => file.endsWith(".json")).sort();
660917
661305
  for (const file of files.reverse()) {
660918
661306
  try {
660919
- return JSON.parse(readFileSync117(join156(dir, file), "utf8"));
661307
+ return JSON.parse(
661308
+ readFileSync117(join156(dir, file), "utf8")
661309
+ );
660920
661310
  } catch {
660921
661311
  }
660922
661312
  }
@@ -660931,25 +661321,39 @@ function formatTelegramChannelDaydreamContext(artifact) {
660931
661321
  artifact.corpus?.stats ? `Corpus: ${artifact.corpus.stats.selectedEpisodes} selected episode(s), ${artifact.corpus.stats.graphNodesVisited} graph node(s), search limit ${artifact.corpus.stats.vectorSearchLimitUsed}` : "",
660932
661322
  artifact.selectedSeed ? `Selected seed: ${artifact.selectedSeed.nodeText} (degree ${artifact.selectedSeed.degree})` : "",
660933
661323
  artifact.tagging?.length ? `Tags:
660934
- ${artifact.tagging.slice(0, 8).map((item) => `- ${item.label} [${item.kind}] (${item.confidence.toFixed(2)})`).join("\n")}` : "",
661324
+ ${artifact.tagging.slice(0, 8).map(
661325
+ (item) => `- ${item.label} [${item.kind}] (${item.confidence.toFixed(2)})`
661326
+ ).join("\n")}` : "",
660935
661327
  artifact.summation?.length ? `Summaries:
660936
661328
  ${artifact.summation.slice(0, 4).map((item) => `- ${item.title}: ${item.text}`).join("\n")}` : "",
660937
661329
  artifact.extraction?.length ? `Extracted items:
660938
- ${artifact.extraction.slice(0, 6).map((item) => `- ${item.kind}: ${item.text}${item.sourceMessageIds.length ? ` (messages ${item.sourceMessageIds.join(", ")})` : ""}`).join("\n")}` : "",
661330
+ ${artifact.extraction.slice(0, 6).map(
661331
+ (item) => `- ${item.kind}: ${item.text}${item.sourceMessageIds.length ? ` (messages ${item.sourceMessageIds.join(", ")})` : ""}`
661332
+ ).join("\n")}` : "",
660939
661333
  artifact.linking?.length ? `Graph links:
660940
- ${artifact.linking.slice(0, 5).map((item) => `- ${item.srcNodeText} --${item.relation}--> ${item.dstNodeText}`).join("\n")}` : "",
661334
+ ${artifact.linking.slice(0, 5).map(
661335
+ (item) => `- ${item.srcNodeText} --${item.relation}--> ${item.dstNodeText}`
661336
+ ).join("\n")}` : "",
660941
661337
  artifact.extractionFollowups?.length ? `Extraction followups:
660942
- ${artifact.extractionFollowups.slice(0, 4).map((item) => `- ${item.target}${item.replyToMessageId ? ` reply_to=${item.replyToMessageId}` : ""}: ${item.text || item.rationale}`).join("\n")}` : "",
661338
+ ${artifact.extractionFollowups.slice(0, 4).map(
661339
+ (item) => `- ${item.target}${item.replyToMessageId ? ` reply_to=${item.replyToMessageId}` : ""}: ${item.text || item.rationale}`
661340
+ ).join("\n")}` : "",
660943
661341
  artifact.metaAnalysisSignals?.length ? `Meta-analysis signals:
660944
661342
  ${artifact.metaAnalysisSignals.slice(0, 4).map((line) => `- ${line}`).join("\n")}` : "",
660945
661343
  artifact.humanStimulationSignals?.length ? `Human stimulation signals:
660946
- ${artifact.humanStimulationSignals.slice(0, 5).map((item) => `- ${item.signal}: ${item.source} (weight ${item.weight.toFixed(2)})`).join("\n")}` : "",
661344
+ ${artifact.humanStimulationSignals.slice(0, 5).map(
661345
+ (item) => `- ${item.signal}: ${item.source} (weight ${item.weight.toFixed(2)})`
661346
+ ).join("\n")}` : "",
660947
661347
  artifact.curiosityThreads?.length ? `Curiosity threads:
660948
- ${artifact.curiosityThreads.slice(0, 4).map((item) => `- ${item.question} (intensity ${item.intensity.toFixed(2)})`).join("\n")}` : "",
661348
+ ${artifact.curiosityThreads.slice(0, 4).map(
661349
+ (item) => `- ${item.question} (intensity ${item.intensity.toFixed(2)})`
661350
+ ).join("\n")}` : "",
660949
661351
  artifact.scopedExplorationTools?.length ? `Scoped exploration tools:
660950
661352
  ${artifact.scopedExplorationTools.slice(0, 6).map((item) => `- ${item.name}: ${item.scope}; ${item.use}`).join("\n")}` : "",
660951
661353
  artifact.outreachPlans?.length ? `Outreach plans:
660952
- ${artifact.outreachPlans.slice(0, 4).map((item) => `- ${item.target}${item.recipient ? ` -> ${item.recipient}` : ""}: ${item.trigger} (gate ${item.gate}; confidence ${item.confidence.toFixed(2)})`).join("\n")}` : "",
661354
+ ${artifact.outreachPlans.slice(0, 4).map(
661355
+ (item) => `- ${item.target}${item.recipient ? ` -> ${item.recipient}` : ""}: ${item.trigger} (gate ${item.gate}; confidence ${item.confidence.toFixed(2)})`
661356
+ ).join("\n")}` : "",
660953
661357
  artifact.personaSteering?.directives?.length ? `Persona steering:
660954
661358
  ${artifact.personaSteering.directives.slice(0, 5).map((line) => `- ${line}`).join("\n")}` : "",
660955
661359
  artifact.relationshipSignals.length ? `Relationship signals:
@@ -660959,23 +661363,27 @@ ${artifact.contextEngineeringNotes.slice(0, 5).map((line) => `- ${line}`).join("
660959
661363
  artifact.openQuestions.length ? `Open questions:
660960
661364
  ${artifact.openQuestions.slice(0, 4).map((line) => `- ${line}`).join("\n")}` : "",
660961
661365
  artifact.replyOpportunities.length ? `Possible reply opportunities:
660962
- ${artifact.replyOpportunities.slice(0, 3).map((item) => `- ${item.id} [${item.lifecycle}] ${item.trigger} (confidence ${item.confidence.toFixed(2)}; ${item.suggestedTone})`).join("\n")}` : ""
661366
+ ${artifact.replyOpportunities.slice(0, 3).map(
661367
+ (item) => `- ${item.id} [${item.lifecycle}] ${item.trigger} (confidence ${item.confidence.toFixed(2)}; ${item.suggestedTone})`
661368
+ ).join("\n")}` : ""
660963
661369
  ].filter(Boolean);
660964
661370
  return lines.join("\n");
660965
661371
  }
661372
+ var DAYDREAM_ARTIFACT_RETENTION_LIMIT;
660966
661373
  var init_telegram_channel_dmn = __esm({
660967
661374
  "packages/cli/src/tui/telegram-channel-dmn.ts"() {
660968
661375
  "use strict";
661376
+ DAYDREAM_ARTIFACT_RETENTION_LIMIT = 48;
660969
661377
  }
660970
661378
  });
660971
661379
 
660972
661380
  // packages/cli/src/tui/telegram-reflection-corpus.ts
660973
- import { createHash as createHash38 } from "node:crypto";
661381
+ import { createHash as createHash39 } from "node:crypto";
660974
661382
  function telegramReflectionMemoryDbPaths(repoRoot) {
660975
661383
  return omniusMemoryDbPaths(repoRoot);
660976
661384
  }
660977
661385
  function stableHash2(value2, length4 = 16) {
660978
- return createHash38("sha1").update(value2).digest("hex").slice(0, length4);
661386
+ return createHash39("sha1").update(value2).digest("hex").slice(0, length4);
660979
661387
  }
660980
661388
  function clean3(value2) {
660981
661389
  return String(value2 ?? "").replace(/\s+/g, " ").trim();
@@ -661705,7 +662113,7 @@ var init_telegram_reflection_extraction = __esm({
661705
662113
  });
661706
662114
 
661707
662115
  // packages/cli/src/tui/telegram-social-state-types.ts
661708
- import { createHash as createHash39 } from "node:crypto";
662116
+ import { createHash as createHash40 } from "node:crypto";
661709
662117
  function telegramSocialActorKey(actor) {
661710
662118
  if (!actor) return "unknown";
661711
662119
  if (typeof actor.userId === "number") return `user:${actor.userId}`;
@@ -661738,7 +662146,7 @@ function appendUnique(items, value2, max) {
661738
662146
  return next.slice(-max);
661739
662147
  }
661740
662148
  function hashTelegramSocialId(parts) {
661741
- return createHash39("sha1").update(parts.map((part) => String(part ?? "")).join(":")).digest("hex").slice(0, 16);
662149
+ return createHash40("sha1").update(parts.map((part) => String(part ?? "")).join(":")).digest("hex").slice(0, 16);
661742
662150
  }
661743
662151
  function cleanUsername(value2) {
661744
662152
  if (typeof value2 !== "string") return void 0;
@@ -662549,7 +662957,7 @@ __export(vision_ingress_exports, {
662549
662957
  runVisionIngress: () => runVisionIngress
662550
662958
  });
662551
662959
  import { execFileSync as execFileSync10 } from "node:child_process";
662552
- import { existsSync as existsSync145, readFileSync as readFileSync118, unlinkSync as unlinkSync31 } from "node:fs";
662960
+ import { existsSync as existsSync145, readFileSync as readFileSync118, unlinkSync as unlinkSync32 } from "node:fs";
662553
662961
  import { join as join157 } from "node:path";
662554
662962
  function isTesseractAvailable() {
662555
662963
  try {
@@ -662607,7 +663015,7 @@ function advancedOcr(imagePath) {
662607
663015
  const text2 = readFileSync118(txtFile, "utf-8").trim();
662608
663016
  if (text2.length > 0) results.push(text2);
662609
663017
  try {
662610
- unlinkSync31(txtFile);
663018
+ unlinkSync32(txtFile);
662611
663019
  } catch {
662612
663020
  }
662613
663021
  }
@@ -662735,7 +663143,7 @@ var init_vision_ingress = __esm({
662735
663143
  import {
662736
663144
  mkdirSync as mkdirSync89,
662737
663145
  existsSync as existsSync146,
662738
- unlinkSync as unlinkSync32,
663146
+ unlinkSync as unlinkSync33,
662739
663147
  readdirSync as readdirSync53,
662740
663148
  statSync as statSync50,
662741
663149
  statfsSync as statfsSync7,
@@ -662753,7 +663161,7 @@ import {
662753
663161
  } from "node:path";
662754
663162
  import { homedir as homedir51 } from "node:os";
662755
663163
  import { writeFile as writeFileAsync } from "node:fs/promises";
662756
- import { createHash as createHash40, randomBytes as randomBytes26, randomInt } from "node:crypto";
663164
+ import { createHash as createHash41, randomBytes as randomBytes26, randomInt } from "node:crypto";
662757
663165
  function formatModelBytes(bytes) {
662758
663166
  if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";
662759
663167
  const units = ["B", "KB", "MB", "GB", "TB"];
@@ -664019,7 +664427,7 @@ function buildTelegramRuntimeContext(now2 = /* @__PURE__ */ new Date(), repoRoot
664019
664427
  ].filter(Boolean).join("\n");
664020
664428
  }
664021
664429
  function telegramSessionIdFromKey(sessionKey) {
664022
- return `telegram-${createHash40("sha1").update(sessionKey).digest("hex").slice(0, 16)}`;
664430
+ return `telegram-${createHash41("sha1").update(sessionKey).digest("hex").slice(0, 16)}`;
664023
664431
  }
664024
664432
  function normalizeTelegramSubAgentLimit(value2) {
664025
664433
  const parsed = typeof value2 === "number" ? value2 : typeof value2 === "string" && value2.trim() ? Number(value2.trim()) : TELEGRAM_SUB_AGENT_DEFAULT_LIMIT;
@@ -664060,7 +664468,11 @@ function formatTelegramProgressEvent(event) {
664060
664468
  if (event.type === "tool_result") {
664061
664469
  const preview = sanitizeTelegramProgressText(event.content || "", 1500);
664062
664470
  if (isTelegramInternalStatusText(preview)) return null;
664063
- return toolResultBlock(event.toolName || "tool", Boolean(event.success), preview);
664471
+ return toolResultBlock(
664472
+ event.toolName || "tool",
664473
+ Boolean(event.success),
664474
+ preview
664475
+ );
664064
664476
  }
664065
664477
  if (event.type === "status") {
664066
664478
  if (isCodebaseMemoryStatus(event.content || "")) {
@@ -665705,7 +666117,7 @@ Telegram link integrity contract:
665705
666117
  upload: { limit: 20, windowMs: 60 * 6e4 },
665706
666118
  reminder: { limit: 20, windowMs: 24 * 60 * 6e4 }
665707
666119
  };
665708
- TelegramBridge = class {
666120
+ TelegramBridge = class _TelegramBridge {
665709
666121
  constructor(botToken, onMessage, agentConfig, repoRoot, toolPolicyConfig) {
665710
666122
  this.botToken = botToken;
665711
666123
  this.onMessage = onMessage;
@@ -666179,7 +666591,7 @@ Telegram link integrity contract:
666179
666591
  return !!this.adminAuthChallenge && this.adminAuthChallenge.expiresAtMs > Date.now();
666180
666592
  }
666181
666593
  hashAdminAuthCode(code8) {
666182
- return createHash40("sha256").update(`omnius-telegram-admin:${code8.trim()}`).digest("hex");
666594
+ return createHash41("sha256").update(`omnius-telegram-admin:${code8.trim()}`).digest("hex");
666183
666595
  }
666184
666596
  viewIdForMessage(msg) {
666185
666597
  return `telegram-${this.sessionKeyForMessage(msg).replace(/[^A-Za-z0-9_-]/g, "-")}`;
@@ -668241,11 +668653,11 @@ ${mediaContext}` : ""
668241
668653
  return payload;
668242
668654
  }
668243
668655
  telegramConversationPath(sessionKey) {
668244
- const safe = createHash40("sha1").update(sessionKey).digest("hex").slice(0, 20);
668656
+ const safe = createHash41("sha1").update(sessionKey).digest("hex").slice(0, 20);
668245
668657
  return join158(this.telegramConversationDir, `${safe}.json`);
668246
668658
  }
668247
668659
  telegramConversationLedgerPath(sessionKey) {
668248
- const safe = createHash40("sha1").update(sessionKey).digest("hex").slice(0, 20);
668660
+ const safe = createHash41("sha1").update(sessionKey).digest("hex").slice(0, 20);
668249
668661
  return join158(this.telegramConversationDir, `${safe}.events.jsonl`);
668250
668662
  }
668251
668663
  telegramDb() {
@@ -668478,7 +668890,7 @@ ${mediaContext}` : ""
668478
668890
  relationships: Array.isArray(raw.relationships) ? raw.relationships.slice(0, TELEGRAM_ASSOCIATIVE_RELATION_LIMIT).map((fact) => this.normalizeTelegramAssociativeFact(fact)) : [],
668479
668891
  actions: Array.isArray(raw.actions) ? raw.actions.slice(-TELEGRAM_ASSOCIATIVE_ACTION_LIMIT).map((action) => ({
668480
668892
  id: String(
668481
- action.id || createHash40("sha1").update(JSON.stringify(action)).digest("hex").slice(0, 12)
668893
+ action.id || createHash41("sha1").update(JSON.stringify(action)).digest("hex").slice(0, 12)
668482
668894
  ),
668483
668895
  ts: typeof action.ts === "number" ? action.ts : Date.now(),
668484
668896
  role: action.role === "assistant" ? "assistant" : "user",
@@ -668497,7 +668909,7 @@ ${mediaContext}` : ""
668497
668909
  const now2 = Date.now();
668498
668910
  return {
668499
668911
  id: String(
668500
- raw.id || createHash40("sha1").update(text2 || String(now2)).digest("hex").slice(0, 12)
668912
+ raw.id || createHash41("sha1").update(text2 || String(now2)).digest("hex").slice(0, 12)
668501
668913
  ),
668502
668914
  text: text2,
668503
668915
  tags: Array.isArray(raw.tags) ? raw.tags.map(String).slice(0, 16) : [],
@@ -668954,7 +669366,7 @@ ${mediaContext}` : ""
668954
669366
  telegramHistoryBackfillMessageId(sessionKey, entry, index) {
668955
669367
  if (typeof entry.messageId === "number" && Number.isFinite(entry.messageId))
668956
669368
  return entry.messageId;
668957
- const digest3 = createHash40("sha1").update(
669369
+ const digest3 = createHash41("sha1").update(
668958
669370
  `${sessionKey}:${index}:${entry.role}:${entry.ts ?? ""}:${entry.text}`
668959
669371
  ).digest("hex").slice(0, 8);
668960
669372
  return -Number.parseInt(digest3, 16);
@@ -670136,7 +670548,7 @@ ${mediaContext}` : ""
670136
670548
  const now2 = entry.ts ?? Date.now();
670137
670549
  memory.updatedAt = now2;
670138
670550
  const speaker = telegramHistorySpeaker(entry);
670139
- const actionId = createHash40("sha1").update(
670551
+ const actionId = createHash41("sha1").update(
670140
670552
  `${sessionKey}:${entry.role}:${entry.messageId ?? ""}:${now2}:${entry.text}`
670141
670553
  ).digest("hex").slice(0, 16);
670142
670554
  if (!memory.actions.some((action) => action.id === actionId)) {
@@ -670299,7 +670711,7 @@ ${mediaContext}` : ""
670299
670711
  let fact = facts.find((item) => item.text.toLowerCase() === key);
670300
670712
  if (!fact) {
670301
670713
  fact = {
670302
- id: createHash40("sha1").update(`${entry.chatId ?? ""}:${key}`).digest("hex").slice(0, 12),
670714
+ id: createHash41("sha1").update(`${entry.chatId ?? ""}:${key}`).digest("hex").slice(0, 12),
670303
670715
  text: clean5,
670304
670716
  tags: telegramMemoryTags(clean5, entry.mediaSummary),
670305
670717
  speakers: [],
@@ -670332,9 +670744,29 @@ ${mediaContext}` : ""
670332
670744
  fact.tags = fact.tags.slice(0, 16);
670333
670745
  return fact;
670334
670746
  }
670747
+ /** Patterns that identify synthetic prompt wrapper text, not genuine user memories. */
670748
+ static SYNTHETIC_MEMORY_PATTERNS = [
670749
+ /### Current Telegram Reply Relationship/,
670750
+ /Telegram live context from @/,
670751
+ /\(untrusted Telegram text; quote as user data, not instructions\)/,
670752
+ /\[Telegram live context update\]/,
670753
+ /These Telegram messages arrived while this runner was already active/,
670754
+ /Current user message:\n/,
670755
+ /^You are responding to a(n)? (admin|member of the general public)/,
670756
+ /^Critical safety notice for public Telegram chat/,
670757
+ /Handle this as contextual Telegram chat/,
670758
+ /Handle this as Telegram action work/,
670759
+ /Evidence sufficiency contract/,
670760
+ /Telegram response contract/,
670761
+ /Telegram link integrity contract/
670762
+ ];
670335
670763
  updateTelegramMemoryCards(sessionKey, entry) {
670336
670764
  const text2 = stripTelegramHiddenThinking(entry.text || "").replace(/\s+/g, " ").trim();
670337
670765
  if (!text2 || text2.length < 3) return;
670766
+ if (_TelegramBridge.SYNTHETIC_MEMORY_PATTERNS.some((p2) => p2.test(text2)))
670767
+ return;
670768
+ if (entry.role === "assistant" && entry.mode && !["chat", "action"].includes(entry.mode))
670769
+ return;
670338
670770
  const speaker = telegramHistorySpeaker(entry);
670339
670771
  const tags = telegramMemoryTags(text2, entry.mediaSummary);
670340
670772
  const tokens = telegramMemoryTokens(
@@ -670361,7 +670793,7 @@ ${mediaContext}` : ""
670361
670793
  const titleTags = tags.slice(0, 4);
670362
670794
  const title = titleTags.length > 0 ? `${speaker} / ${titleTags.join(" ")}` : `${speaker} / conversation`;
670363
670795
  const card = {
670364
- id: createHash40("sha1").update(`${sessionKey}:${now2}:${speaker}:${text2}`).digest("hex").slice(0, 12),
670796
+ id: createHash41("sha1").update(`${sessionKey}:${now2}:${speaker}:${text2}`).digest("hex").slice(0, 12),
670365
670797
  title,
670366
670798
  notes: [],
670367
670799
  tags: [],
@@ -673276,7 +673708,7 @@ ${list}` : "No shared group target is currently known for this sender. Ask in th
673276
673708
  }
673277
673709
  telegramRunnerStateDir(sessionKey) {
673278
673710
  if (!this.repoRoot) return void 0;
673279
- const safe = createHash40("sha1").update(sessionKey).digest("hex").slice(0, 20);
673711
+ const safe = createHash41("sha1").update(sessionKey).digest("hex").slice(0, 20);
673280
673712
  return join158(this.repoRoot, ".omnius", "telegram-runner-state", safe);
673281
673713
  }
673282
673714
  buildTelegramAdminOverviewContext(currentSessionKey) {
@@ -673733,7 +674165,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
673733
674165
  if (prior.pid !== process.pid) return;
673734
674166
  } catch {
673735
674167
  }
673736
- unlinkSync32(lockFile);
674168
+ unlinkSync33(lockFile);
673737
674169
  } catch {
673738
674170
  }
673739
674171
  }
@@ -675975,7 +676407,8 @@ ${conversationStream}`
675975
676407
  `tool: ${event.toolName}(${argsPreview})`
675976
676408
  );
675977
676409
  } else if (event.type === "tool_result" && event.toolName) {
675978
- if (event.success) subAgent.successfulToolNamesThisRun.add(event.toolName);
676410
+ if (event.success)
676411
+ subAgent.successfulToolNamesThisRun.add(event.toolName);
675979
676412
  const preview = (event.content || "").slice(0, 140);
675980
676413
  this.subAgentViewCallbacks?.onWrite(
675981
676414
  subAgent.viewId,
@@ -676183,7 +676616,7 @@ ${creativeWorkspace}` : ""}`;
676183
676616
  toolContext: ctx3
676184
676617
  }
676185
676618
  },
676186
- () => runner.run(userPrompt, systemCtx)
676619
+ () => runner.run(userPrompt, systemCtx, msg.text)
676187
676620
  );
676188
676621
  subAgent.runnerCompleted = result.completed;
676189
676622
  subAgent.runnerStatus = result.status;
@@ -680160,7 +680593,7 @@ ${text2}`.trim()
680160
680593
  for (const [key, entry] of this.mediaCache) {
680161
680594
  if (now2 - entry.cachedAt > MEDIA_CACHE_TTL_MS) {
680162
680595
  try {
680163
- unlinkSync32(entry.localPath);
680596
+ unlinkSync33(entry.localPath);
680164
680597
  } catch {
680165
680598
  }
680166
680599
  this.mediaCache.delete(key);
@@ -683486,14 +683919,14 @@ var init_access_policy = __esm({
683486
683919
  });
683487
683920
 
683488
683921
  // packages/cli/src/api/project-preferences.ts
683489
- import { createHash as createHash41 } from "node:crypto";
683490
- import { existsSync as existsSync148, mkdirSync as mkdirSync91, readFileSync as readFileSync121, renameSync as renameSync13, writeFileSync as writeFileSync80, unlinkSync as unlinkSync33 } from "node:fs";
683922
+ import { createHash as createHash42 } from "node:crypto";
683923
+ import { existsSync as existsSync148, mkdirSync as mkdirSync91, readFileSync as readFileSync121, renameSync as renameSync13, writeFileSync as writeFileSync80, unlinkSync as unlinkSync34 } from "node:fs";
683491
683924
  import { homedir as homedir53 } from "node:os";
683492
683925
  import { join as join160, resolve as resolve64 } from "node:path";
683493
683926
  import { randomUUID as randomUUID20 } from "node:crypto";
683494
683927
  function projectKey(root) {
683495
683928
  const canonical = resolve64(root);
683496
- return createHash41("sha256").update(canonical).digest("hex").slice(0, 16);
683929
+ return createHash42("sha256").update(canonical).digest("hex").slice(0, 16);
683497
683930
  }
683498
683931
  function projectDir(root) {
683499
683932
  return join160(PROJECTS_DIR, projectKey(root));
@@ -683548,7 +683981,7 @@ function writeProjectPreferences(root, partial) {
683548
683981
  } catch {
683549
683982
  }
683550
683983
  try {
683551
- unlinkSync33(tmp);
683984
+ unlinkSync34(tmp);
683552
683985
  } catch {
683553
683986
  }
683554
683987
  throw err;
@@ -683559,7 +683992,7 @@ function deleteProjectPreferences(root) {
683559
683992
  try {
683560
683993
  const file = prefsPath(root);
683561
683994
  if (!existsSync148(file)) return false;
683562
- unlinkSync33(file);
683995
+ unlinkSync34(file);
683563
683996
  return true;
683564
683997
  } catch {
683565
683998
  return false;
@@ -683787,7 +684220,7 @@ var init_disk_task_output = __esm({
683787
684220
  });
683788
684221
 
683789
684222
  // packages/cli/src/api/http.ts
683790
- import { createHash as createHash42 } from "node:crypto";
684223
+ import { createHash as createHash43 } from "node:crypto";
683791
684224
  function problemDetails(opts) {
683792
684225
  const p2 = {
683793
684226
  type: opts.type ?? "about:blank",
@@ -683850,7 +684283,7 @@ function paginated(items, page2, total) {
683850
684283
  }
683851
684284
  function computeEtag(payload) {
683852
684285
  const json = typeof payload === "string" ? payload : JSON.stringify(payload);
683853
- const hash = createHash42("sha1").update(json).digest("hex").slice(0, 16);
684286
+ const hash = createHash43("sha1").update(json).digest("hex").slice(0, 16);
683854
684287
  return `W/"${hash}"`;
683855
684288
  }
683856
684289
  function checkNotModified(req3, res, etag) {
@@ -701761,14 +702194,14 @@ import {
701761
702194
  existsSync as existsSync160,
701762
702195
  watch as fsWatch4,
701763
702196
  renameSync as renameSync15,
701764
- unlinkSync as unlinkSync34,
702197
+ unlinkSync as unlinkSync35,
701765
702198
  statSync as statSync56,
701766
702199
  openSync as openSync6,
701767
702200
  readSync as readSync2,
701768
702201
  closeSync as closeSync6
701769
702202
  } from "node:fs";
701770
702203
  import { randomBytes as randomBytes28, randomUUID as randomUUID21, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
701771
- import { createHash as createHash43 } from "node:crypto";
702204
+ import { createHash as createHash44 } from "node:crypto";
701772
702205
  function memoryDbPaths3(baseDir = process.cwd()) {
701773
702206
  const dir = join172(baseDir, ".omnius");
701774
702207
  return {
@@ -703096,13 +703529,13 @@ function pruneOldJobs() {
703096
703529
  const ts = ageRef ? Date.parse(ageRef) : NaN;
703097
703530
  if (Number.isFinite(ts) && ts < cutoffMs) {
703098
703531
  try {
703099
- unlinkSync34(path12);
703532
+ unlinkSync35(path12);
703100
703533
  } catch {
703101
703534
  }
703102
703535
  const outFile = path12.replace(/\.json$/, ".output");
703103
703536
  if (existsSync160(outFile)) {
703104
703537
  try {
703105
- unlinkSync34(outFile);
703538
+ unlinkSync35(outFile);
703106
703539
  } catch {
703107
703540
  }
703108
703541
  }
@@ -703112,7 +703545,7 @@ function pruneOldJobs() {
703112
703545
  }
703113
703546
  } catch {
703114
703547
  try {
703115
- unlinkSync34(path12);
703548
+ unlinkSync35(path12);
703116
703549
  pruned++;
703117
703550
  } catch {
703118
703551
  }
@@ -703424,7 +703857,7 @@ function atomicJobWrite(dir, id, job) {
703424
703857
  } catch {
703425
703858
  }
703426
703859
  try {
703427
- unlinkSync34(tmpPath);
703860
+ unlinkSync35(tmpPath);
703428
703861
  } catch {
703429
703862
  }
703430
703863
  }
@@ -707602,7 +708035,7 @@ async function handleRequest(req3, res, ollamaUrl, verbose, runtimeDefaults = {}
707602
708035
  return;
707603
708036
  }
707604
708037
  const { tmpdir: tmpdir24 } = await import("node:os");
707605
- const { writeFileSync: writeFileSync91, unlinkSync: unlinkSync35 } = await import("node:fs");
708038
+ const { writeFileSync: writeFileSync91, unlinkSync: unlinkSync36 } = await import("node:fs");
707606
708039
  const { join: pjoin } = await import("node:path");
707607
708040
  const tmpPath = pjoin(
707608
708041
  tmpdir24(),
@@ -707620,7 +708053,7 @@ async function handleRequest(req3, res, ollamaUrl, verbose, runtimeDefaults = {}
707620
708053
  });
707621
708054
  } finally {
707622
708055
  try {
707623
- unlinkSync35(tmpPath);
708056
+ unlinkSync36(tmpPath);
707624
708057
  } catch {
707625
708058
  }
707626
708059
  }
@@ -710038,7 +710471,7 @@ function listScheduledTasks() {
710038
710471
  );
710039
710472
  const enabled2 = typeof t2?.enabled === "boolean" ? t2.enabled : true;
710040
710473
  const realId = typeof t2?.id === "string" && t2.id ? t2.id : null;
710041
- const fallbackId = createHash43("sha1").update(`${file}#${i2}`).digest("hex").slice(0, 16);
710474
+ const fallbackId = createHash44("sha1").update(`${file}#${i2}`).digest("hex").slice(0, 16);
710042
710475
  const uid = realId || fallbackId;
710043
710476
  const key = `${uid}`;
710044
710477
  if (seen.has(key)) return;
@@ -710176,8 +710609,8 @@ function deleteScheduledById(id) {
710176
710609
  if (typeof entry?.id === "string" && entry.id && !candidates.includes(entry.id))
710177
710610
  candidates.push(entry.id);
710178
710611
  try {
710179
- const { createHash: createHash44 } = require4("node:crypto");
710180
- const fallback = createHash44("sha1").update(`${target.file}#${target.index}`).digest("hex").slice(0, 16);
710612
+ const { createHash: createHash45 } = require4("node:crypto");
710613
+ const fallback = createHash45("sha1").update(`${target.file}#${target.index}`).digest("hex").slice(0, 16);
710181
710614
  if (!candidates.includes(fallback)) candidates.push(fallback);
710182
710615
  } catch {
710183
710616
  }
@@ -710863,8 +711296,8 @@ function startApiServer(options2 = {}) {
710863
711296
  job.startedAt ?? job.completedAt ?? 0
710864
711297
  ).getTime();
710865
711298
  if (jobTime > 0 && jobTime < cutoff && job.status !== "running") {
710866
- const { unlinkSync: unlinkSync35 } = require4("node:fs");
710867
- unlinkSync35(jobPath);
711299
+ const { unlinkSync: unlinkSync36 } = require4("node:fs");
711300
+ unlinkSync36(jobPath);
710868
711301
  }
710869
711302
  } catch {
710870
711303
  }
@@ -713783,7 +714216,19 @@ async function createSteeringIntakeBackend(config, repoRoot) {
713783
714216
  function formatTaskCompletionMeta(meta) {
713784
714217
  if (!meta) return "no prior task metrics recorded";
713785
714218
  const dur = meta.durationMs < 6e4 ? `${(meta.durationMs / 1e3).toFixed(1)}s` : `${Math.floor(meta.durationMs / 6e4)}m ${Math.floor(meta.durationMs % 6e4 / 1e3)}s`;
713786
- return `${meta.turns} turns, ${meta.toolCalls} tool calls, ${dur}, ${meta.model}`;
714219
+ const parts = [
714220
+ `${meta.turns} turns`,
714221
+ `${meta.toolCalls} tool calls`,
714222
+ dur,
714223
+ meta.model
714224
+ ];
714225
+ if (meta.filesModified) parts.push(`${meta.filesModified} files modified`);
714226
+ if (meta.testsPassed !== void 0) parts.push(`${meta.testsPassed} tests passed`);
714227
+ if (meta.buildStatus) parts.push(`build: ${meta.buildStatus}`);
714228
+ if (meta.errors) parts.push(`${meta.errors} errors`);
714229
+ if (meta.tokensUsed) parts.push(`${meta.tokensUsed} tokens`);
714230
+ if (meta.verified !== void 0) parts.push(`verified: ${meta.verified}`);
714231
+ return parts.join(", ");
713787
714232
  }
713788
714233
  function buildNewTaskIntakePacket(ingress, interpretation, previousPrompt, previousSummary, previousMeta) {
713789
714234
  const rawTitle = ingress.rawText?.trim()?.split("\n")[0]?.slice(0, 120) || "task";
@@ -713811,6 +714256,23 @@ function buildNewTaskIntakePacket(ingress, interpretation, previousPrompt, previ
713811
714256
  "",
713812
714257
  "New task:",
713813
714258
  ingress.rawText,
714259
+ "",
714260
+ "Intake validation context:",
714261
+ `- Original prompt included: ${previousPrompt.trim() ? "yes" : "no"}`,
714262
+ `- Original summary included: ${previousSummary.trim() ? "yes" : "no"}`,
714263
+ `- Expanded metrics rendered: ${previousMeta ? "yes" : "no"}`,
714264
+ `- Files touched: ${ingress.filesTouched?.length ?? 0}`,
714265
+ `- Tool calls: ${ingress.toolCallCount ?? 0}`,
714266
+ "",
714267
+ "Expanded metrics detail:",
714268
+ previousMeta ? [
714269
+ ` • filesModified: ${previousMeta.filesModified ?? 0}`,
714270
+ ` • testsPassed: ${previousMeta.testsPassed ?? 0}`,
714271
+ ` • buildStatus: ${previousMeta.buildStatus ?? "skipped"}`,
714272
+ ` • errors: ${previousMeta.errors ?? 0}`,
714273
+ ` • tokensUsed: ${previousMeta.tokensUsed ?? 0}`,
714274
+ ` • verified: ${previousMeta.verified ?? "unverified"}`
714275
+ ].join("\n") : " (no prior metrics)",
713814
714276
  ""
713815
714277
  ];
713816
714278
  if (interpretation) {
@@ -721701,13 +722163,13 @@ ${taskInput}`;
721701
722163
  writeContent(() => renderError(errMsg));
721702
722164
  if (failureStore) {
721703
722165
  try {
721704
- const { createHash: createHash44 } = await import("node:crypto");
722166
+ const { createHash: createHash45 } = await import("node:crypto");
721705
722167
  failureStore.insert({
721706
722168
  taskId: "",
721707
722169
  sessionId: `${Date.now()}`,
721708
722170
  repoRoot,
721709
722171
  failureType: "runtime-error",
721710
- fingerprint: createHash44("sha256").update(errMsg.slice(0, 200)).digest("hex").slice(0, 16),
722172
+ fingerprint: createHash45("sha256").update(errMsg.slice(0, 200)).digest("hex").slice(0, 16),
721711
722173
  filePath: null,
721712
722174
  errorMessage: errMsg.slice(0, 500),
721713
722175
  context: null,