@cydm/pie 4.13.1 → 4.14.1
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/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/cron/index.js +70 -17
- package/dist/builtin/extensions/im-forward/index.js +8094 -8100
- package/dist/builtin/extensions/mcp-adapter/index.js +86 -81
- package/dist/builtin/extensions/memory/index.js +30 -7
- package/dist/builtin/extensions/pie-ipc/index.js +13 -18
- package/dist/builtin/extensions/pie-proc/README.md +12 -3
- package/dist/builtin/extensions/pie-proc/index.js +145 -96
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/builtin/extensions/subagent/index.js +5 -5
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/chunks/{chunk-6Z54UHXM.js → chunk-2WLKAMOH.js} +21 -16
- package/dist/chunks/{chunk-3F2CSVNH.js → chunk-DJ4LO7PQ.js} +2 -1
- package/dist/chunks/{chunk-MCR4JYI6.js → chunk-IM7DLPPY.js} +74 -8
- package/dist/chunks/{chunk-HSMO2BEA.js → chunk-IQDVL34H.js} +24 -19
- package/dist/chunks/{chunk-DT22BBZL.js → chunk-OQCKDEEE.js} +1 -1
- package/dist/chunks/{chunk-26KRUYZH.js → chunk-SAXKBFX3.js} +1 -1
- package/dist/chunks/{chunk-CCPNHS6B.js → chunk-SYZR74QO.js} +1582 -1570
- package/dist/chunks/{chunk-UCVPNLCO.js → chunk-TNRZEQD5.js} +2 -2
- package/dist/chunks/{chunk-NHWWRE3T.js → chunk-TTSQWGAT.js} +727 -719
- package/dist/chunks/{chunk-XPJHZRTN.js → chunk-X3ZVZB2R.js} +1133 -381
- package/dist/chunks/{host-image-fallback-LGWYQMLA.js → host-image-fallback-AEKY2LSZ.js} +1 -1
- package/dist/chunks/{manager-cli-OTIMAWO6.js → manager-cli-ZV36YNPJ.js} +187 -173
- package/dist/chunks/{memory-git-7SRO5KLB.js → memory-git-G56IXFWU.js} +5 -5
- package/dist/chunks/{model-registry-IWOOAMLZ.js → model-registry-4LM2I6FR.js} +2 -2
- package/dist/chunks/{read-file-understanding-3TYWVOLX.js → read-file-understanding-GTNZHAK5.js} +5 -5
- package/dist/chunks/{src-WA2O2O2V.js → src-3YJ4UVEC.js} +3 -3
- package/dist/chunks/{src-ALHMJZ5R.js → src-APNP4M4N.js} +2 -2
- package/dist/chunks/{src-D2ICRXWW.js → src-T6AUO53N.js} +24 -6
- package/dist/chunks/{src-76Q33OY5.js → src-TNUD7EDH.js} +1 -1
- package/dist/chunks/{test-stream-OVGDTXOY.js → test-stream-EF2DHEHV.js} +1 -1
- package/dist/cli.js +3131 -3013
- package/package.json +1 -1
- package/dist/chunks/{chunk-3GG342QY.js → chunk-TYCKSYUF.js} +19 -19
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
createSharedWebSearchTool,
|
|
11
11
|
defaultShellKindForPlatform,
|
|
12
12
|
interpretShellExit
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-X3ZVZB2R.js";
|
|
14
14
|
import {
|
|
15
15
|
classifyDefaultFailure,
|
|
16
16
|
isDefaultContextOverflowError,
|
|
17
17
|
requestInteraction
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SYZR74QO.js";
|
|
19
19
|
import {
|
|
20
20
|
getLogger
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-IM7DLPPY.js";
|
|
22
22
|
import {
|
|
23
23
|
Type
|
|
24
24
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -172,11 +172,9 @@ function createTraceTransportSink(noteRuntimeEvent) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// src/capabilities/bash/index.ts
|
|
175
|
-
import { spawn
|
|
176
|
-
import { closeSync
|
|
177
|
-
import {
|
|
178
|
-
import { join, resolve } from "path";
|
|
179
|
-
import { createHash, randomBytes } from "crypto";
|
|
175
|
+
import { spawn as spawn2 } from "child_process";
|
|
176
|
+
import { closeSync as closeSync2, openSync as openSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
177
|
+
import { createHash as createHash2 } from "crypto";
|
|
180
178
|
|
|
181
179
|
// src/capabilities/bash/truncate.ts
|
|
182
180
|
var DEFAULT_MAX_LINES = 400;
|
|
@@ -535,7 +533,12 @@ var PowerShellDisplay = class {
|
|
|
535
533
|
}
|
|
536
534
|
};
|
|
537
535
|
|
|
538
|
-
// src/capabilities/bash/
|
|
536
|
+
// src/capabilities/bash/runtime.ts
|
|
537
|
+
import { spawn, spawnSync } from "child_process";
|
|
538
|
+
import { closeSync, createWriteStream, existsSync, openSync, statSync, unlinkSync } from "fs";
|
|
539
|
+
import { tmpdir } from "os";
|
|
540
|
+
import { join, resolve } from "path";
|
|
541
|
+
import { randomBytes } from "crypto";
|
|
539
542
|
function buildBashSchema(commandDescription) {
|
|
540
543
|
return Type.Object({
|
|
541
544
|
command: Type.String({ description: commandDescription }),
|
|
@@ -899,6 +902,8 @@ function killProcessTree(pid, leaderExited) {
|
|
|
899
902
|
}
|
|
900
903
|
}
|
|
901
904
|
}
|
|
905
|
+
|
|
906
|
+
// src/capabilities/bash/index.ts
|
|
902
907
|
function createBashTool(defaultCwd, options) {
|
|
903
908
|
const contract = buildShellToolContract(options?.platform);
|
|
904
909
|
const recentCommands = /* @__PURE__ */ new Map();
|
|
@@ -1051,7 +1056,7 @@ function createBashTool(defaultCwd, options) {
|
|
|
1051
1056
|
let shellExitAt = 0;
|
|
1052
1057
|
let lastPipeActivityAt = 0;
|
|
1053
1058
|
const spawnCommand = buildSpawnCommand(resolvedShell, effectiveCommand);
|
|
1054
|
-
const child = (options?.spawnProcess ??
|
|
1059
|
+
const child = (options?.spawnProcess ?? spawn2)(spawnCommand.file, spawnCommand.args, {
|
|
1055
1060
|
shell: spawnCommand.shell,
|
|
1056
1061
|
cwd: workingDir,
|
|
1057
1062
|
env: (() => {
|
|
@@ -1231,13 +1236,13 @@ ${fullOutput}`;
|
|
|
1231
1236
|
let outputText = truncation.content || "(no output)";
|
|
1232
1237
|
if (truncation.truncated && !tempFilePath) {
|
|
1233
1238
|
const path3 = getTempFilePath();
|
|
1234
|
-
const fd =
|
|
1239
|
+
const fd = openSync2(path3, "wx", 384);
|
|
1235
1240
|
tempFilePath = path3;
|
|
1236
1241
|
retainedOutputArtifacts.add(path3);
|
|
1237
1242
|
try {
|
|
1238
|
-
|
|
1243
|
+
writeFileSync2(fd, fullBuffer);
|
|
1239
1244
|
} finally {
|
|
1240
|
-
|
|
1245
|
+
closeSync2(fd);
|
|
1241
1246
|
}
|
|
1242
1247
|
}
|
|
1243
1248
|
await finishTempFileStream(tempFileStream);
|
|
@@ -1319,7 +1324,7 @@ ${commandNonzeroHint}`;
|
|
|
1319
1324
|
}
|
|
1320
1325
|
const repeatedCommand = rememberCommandResult(
|
|
1321
1326
|
`${resolvedShell}\0${workingDir}\0${effectiveCommand}`,
|
|
1322
|
-
|
|
1327
|
+
createHash2("sha256").update(JSON.stringify({ code, sig, timedOut, outputText })).digest("hex")
|
|
1323
1328
|
);
|
|
1324
1329
|
details.repeatedCommand = repeatedCommand;
|
|
1325
1330
|
if (repeatedCommand.count > 1 && repeatedCommand.sameResult) {
|
|
@@ -1353,7 +1358,7 @@ ${commandNonzeroHint}`;
|
|
|
1353
1358
|
}
|
|
1354
1359
|
|
|
1355
1360
|
// src/capabilities/rendered-page-reader.ts
|
|
1356
|
-
import { spawn as
|
|
1361
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
1357
1362
|
import { createRequire } from "node:module";
|
|
1358
1363
|
import * as fs from "node:fs";
|
|
1359
1364
|
import * as os from "node:os";
|
|
@@ -1373,7 +1378,7 @@ function resolveMcpScript() {
|
|
|
1373
1378
|
function runAxi(args, options = {}) {
|
|
1374
1379
|
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
1375
1380
|
return new Promise((resolve2, reject) => {
|
|
1376
|
-
const child =
|
|
1381
|
+
const child = spawn3(process.execPath, [resolveAxiCli(), ...args], {
|
|
1377
1382
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1378
1383
|
shell: false,
|
|
1379
1384
|
env: options.env,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
redactText
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-X3ZVZB2R.js";
|
|
5
5
|
|
|
6
6
|
// src/commands/memory-git.ts
|
|
7
7
|
import { execFileSync } from "node:child_process";
|
|
@@ -14,6 +14,7 @@ var REQUIRED_IGNORE_RULES = [
|
|
|
14
14
|
"evidence-ledger.json",
|
|
15
15
|
".gated-patches.json",
|
|
16
16
|
".snapshots/",
|
|
17
|
+
"inbox/",
|
|
17
18
|
"wiki/.meta.json",
|
|
18
19
|
"projects/*/meta.json",
|
|
19
20
|
"*.lock",
|
|
@@ -5300,12 +5300,13 @@ var ResponsesEventReducer = class {
|
|
|
5300
5300
|
events.push(...this.appendTextDelta(raw, "text"));
|
|
5301
5301
|
break;
|
|
5302
5302
|
case "response.output_text.done":
|
|
5303
|
-
this.
|
|
5303
|
+
events.push(...this.onTextDone(raw, "text"));
|
|
5304
5304
|
break;
|
|
5305
5305
|
case "response.refusal.delta":
|
|
5306
5306
|
events.push(...this.appendTextDelta(raw, "refusal"));
|
|
5307
5307
|
break;
|
|
5308
5308
|
case "response.refusal.done":
|
|
5309
|
+
events.push(...this.onTextDone(raw, "refusal"));
|
|
5309
5310
|
break;
|
|
5310
5311
|
case "response.reasoning_summary_text.delta":
|
|
5311
5312
|
case "response.reasoning_text.delta":
|
|
@@ -5435,16 +5436,30 @@ var ResponsesEventReducer = class {
|
|
|
5435
5436
|
throw new ResponsesProtocolError("response.content_part.added is missing a valid content_index.");
|
|
5436
5437
|
}
|
|
5437
5438
|
if (state.kind !== "message") return [];
|
|
5438
|
-
|
|
5439
|
+
const existing = state.blocks.get(partIndex);
|
|
5440
|
+
if (existing?.started) {
|
|
5439
5441
|
throw new ResponsesProtocolError(`Responses stream reused content_index ${partIndex} on one message item.`);
|
|
5440
5442
|
}
|
|
5441
5443
|
if (partType !== "output_text" && partType !== "refusal") {
|
|
5442
5444
|
return [];
|
|
5443
5445
|
}
|
|
5446
|
+
if (existing) {
|
|
5447
|
+
existing.started = true;
|
|
5448
|
+
return [{ type: "text_start", contentIndex: existing.contentIndex, partial: this.output }];
|
|
5449
|
+
}
|
|
5450
|
+
if (partIndex > 0 && partIndex <= 32) {
|
|
5451
|
+
for (let idx = 0; idx < partIndex; idx += 1) {
|
|
5452
|
+
if (state.blocks.has(idx)) continue;
|
|
5453
|
+
const placeholder = { type: "text", text: "" };
|
|
5454
|
+
this.output.content.push(placeholder);
|
|
5455
|
+
state.blocks.set(idx, { block: placeholder, contentIndex: this.output.content.length - 1, started: false });
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5444
5458
|
const block = { type: "text", text: "" };
|
|
5445
5459
|
this.output.content.push(block);
|
|
5446
|
-
|
|
5447
|
-
|
|
5460
|
+
const contentIndex = this.output.content.length - 1;
|
|
5461
|
+
state.blocks.set(partIndex, { block, contentIndex, started: true });
|
|
5462
|
+
return [{ type: "text_start", contentIndex, partial: this.output }];
|
|
5448
5463
|
}
|
|
5449
5464
|
messageBlockFor(raw) {
|
|
5450
5465
|
const { state } = this.lookupItem(raw, ["message"], "message");
|
|
@@ -5454,7 +5469,7 @@ var ResponsesEventReducer = class {
|
|
|
5454
5469
|
throw new ResponsesProtocolError(`Responses event "${raw.type}" is missing a valid content_index.`);
|
|
5455
5470
|
}
|
|
5456
5471
|
const entry = state.blocks.get(partIndex);
|
|
5457
|
-
if (!entry) {
|
|
5472
|
+
if (!entry || !entry.started) {
|
|
5458
5473
|
throw new ResponsesProtocolError(
|
|
5459
5474
|
`Responses event "${raw.type}" references content_index ${partIndex} that was never added.`
|
|
5460
5475
|
);
|
|
@@ -5468,8 +5483,16 @@ var ResponsesEventReducer = class {
|
|
|
5468
5483
|
entry.block.text += delta;
|
|
5469
5484
|
return [{ type: "text_delta", contentIndex: entry.contentIndex, delta, partial: this.output }];
|
|
5470
5485
|
}
|
|
5471
|
-
|
|
5472
|
-
this.messageBlockFor(raw);
|
|
5486
|
+
onTextDone(raw, kind) {
|
|
5487
|
+
const entry = this.messageBlockFor(raw);
|
|
5488
|
+
if (entry.block.text.length === 0) {
|
|
5489
|
+
const fallback = kind === "refusal" ? raw.refusal : raw.text;
|
|
5490
|
+
if (typeof fallback === "string" && fallback.length > 0) {
|
|
5491
|
+
entry.block.text = fallback;
|
|
5492
|
+
return [{ type: "text_delta", contentIndex: entry.contentIndex, delta: fallback, partial: this.output }];
|
|
5493
|
+
}
|
|
5494
|
+
}
|
|
5495
|
+
return [];
|
|
5473
5496
|
}
|
|
5474
5497
|
appendReasoningDelta(raw) {
|
|
5475
5498
|
const delta = raw.delta;
|
|
@@ -5519,7 +5542,39 @@ ${delta}`;
|
|
|
5519
5542
|
switch (state.kind) {
|
|
5520
5543
|
case "message": {
|
|
5521
5544
|
const events = [];
|
|
5522
|
-
|
|
5545
|
+
const doneParts = Array.isArray(item.content) ? item.content : [];
|
|
5546
|
+
for (let idx = 0; idx < doneParts.length; idx += 1) {
|
|
5547
|
+
const part = doneParts[idx];
|
|
5548
|
+
if (!isRecord(part)) continue;
|
|
5549
|
+
const partType = part.type;
|
|
5550
|
+
if (partType !== "output_text" && partType !== "refusal") continue;
|
|
5551
|
+
const fallback = partType === "refusal" ? typeof part.refusal === "string" ? part.refusal : "" : typeof part.text === "string" ? part.text : "";
|
|
5552
|
+
const existing = state.blocks.get(idx);
|
|
5553
|
+
if (existing) {
|
|
5554
|
+
if (!existing.started) {
|
|
5555
|
+
existing.started = true;
|
|
5556
|
+
existing.block.text = fallback;
|
|
5557
|
+
events.push({ type: "text_start", contentIndex: existing.contentIndex, partial: this.output });
|
|
5558
|
+
if (fallback.length > 0) {
|
|
5559
|
+
events.push({ type: "text_delta", contentIndex: existing.contentIndex, delta: fallback, partial: this.output });
|
|
5560
|
+
}
|
|
5561
|
+
} else if (existing.block.text.length === 0 && fallback.length > 0) {
|
|
5562
|
+
existing.block.text = fallback;
|
|
5563
|
+
events.push({ type: "text_delta", contentIndex: existing.contentIndex, delta: fallback, partial: this.output });
|
|
5564
|
+
}
|
|
5565
|
+
} else {
|
|
5566
|
+
const block = { type: "text", text: fallback };
|
|
5567
|
+
this.output.content.push(block);
|
|
5568
|
+
const contentIndex = this.output.content.length - 1;
|
|
5569
|
+
state.blocks.set(idx, { block, contentIndex, started: true });
|
|
5570
|
+
events.push({ type: "text_start", contentIndex, partial: this.output });
|
|
5571
|
+
if (fallback.length > 0) {
|
|
5572
|
+
events.push({ type: "text_delta", contentIndex, delta: fallback, partial: this.output });
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5575
|
+
}
|
|
5576
|
+
const ordered = [...state.blocks.entries()].filter(([, entry]) => entry.started).sort((a, b) => a[0] - b[0]);
|
|
5577
|
+
for (const [, { block, contentIndex }] of ordered) {
|
|
5523
5578
|
events.push({ type: "text_end", contentIndex, content: block.text, partial: this.output });
|
|
5524
5579
|
}
|
|
5525
5580
|
return events;
|
|
@@ -5663,6 +5718,11 @@ ${delta}`;
|
|
|
5663
5718
|
if (stopReason === "toolUse" && this.toolCallStates.length === 0) {
|
|
5664
5719
|
stopReason = "stop";
|
|
5665
5720
|
}
|
|
5721
|
+
if (stopReason === "stop" && !hasAssistantContent(this.output)) {
|
|
5722
|
+
this.output.stopReason = "error";
|
|
5723
|
+
this.output.errorMessage = EMPTY_ASSISTANT_CONTENT_ERROR;
|
|
5724
|
+
return [{ type: "error", reason: "error", error: this.output }];
|
|
5725
|
+
}
|
|
5666
5726
|
this.output.stopReason = stopReason;
|
|
5667
5727
|
void terminalType;
|
|
5668
5728
|
return [{ type: "done", reason: stopReason, message: this.output }];
|
|
@@ -7547,6 +7607,9 @@ function streamResponsesSSE(model, context, options) {
|
|
|
7547
7607
|
stream2.push(assistantEvent);
|
|
7548
7608
|
}
|
|
7549
7609
|
if (reducer.isTerminal) {
|
|
7610
|
+
if (reducer.message.stopReason === "error" && reducer.message.errorMessage === EMPTY_ASSISTANT_CONTENT_ERROR) {
|
|
7611
|
+
logEmptyAssistantContentError(new EmptyAssistantContentError(), model, options);
|
|
7612
|
+
}
|
|
7550
7613
|
terminalAccepted = true;
|
|
7551
7614
|
phase = "terminal_accepted";
|
|
7552
7615
|
clearTotalTimer();
|
|
@@ -8245,6 +8308,9 @@ function streamResponsesWS(model, context, options) {
|
|
|
8245
8308
|
}
|
|
8246
8309
|
}
|
|
8247
8310
|
finished = true;
|
|
8311
|
+
if (reducer.message.stopReason === "error" && reducer.message.errorMessage === EMPTY_ASSISTANT_CONTENT_ERROR) {
|
|
8312
|
+
logEmptyAssistantContentError(new EmptyAssistantContentError(), model, options);
|
|
8313
|
+
}
|
|
8248
8314
|
clearRequestTimers();
|
|
8249
8315
|
retryDecision = reducer.message.remoteFailure ? `remote_${reducer.message.remoteFailure.category}` : "terminal";
|
|
8250
8316
|
lifecycle("terminal_accepted", {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-CBDQJMUI.js";
|
|
5
5
|
import {
|
|
6
6
|
createMemoryLockBackend
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-X3ZVZB2R.js";
|
|
8
8
|
|
|
9
9
|
// src/commands/memory-distill.ts
|
|
10
10
|
import * as fs from "node:fs";
|
|
@@ -194,7 +194,7 @@ function createWikiModelCall(registry, modelClass, explicitModelSpec, timeoutMs
|
|
|
194
194
|
};
|
|
195
195
|
return async (prompt, options) => {
|
|
196
196
|
const targets = resolveTargets();
|
|
197
|
-
const complete = hooks?.completeFn ?? (await import("./src-
|
|
197
|
+
const complete = hooks?.completeFn ?? (await import("./src-TNUD7EDH.js")).completeSimple;
|
|
198
198
|
const runCandidate = async (model, apiKey) => {
|
|
199
199
|
const invokeOnce = async () => {
|
|
200
200
|
const controller = new AbortController();
|
|
@@ -356,22 +356,23 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false, sessionsDi
|
|
|
356
356
|
let result;
|
|
357
357
|
let wikiForError;
|
|
358
358
|
try {
|
|
359
|
-
const { ModelRegistry } = await import("./model-registry-
|
|
359
|
+
const { ModelRegistry } = await import("./model-registry-4LM2I6FR.js");
|
|
360
360
|
const { AuthStorage } = await import("./auth-storage-IJEJ2TGE.js");
|
|
361
361
|
const { getSessionsDir } = await import("./config-4EOI5NOU.js");
|
|
362
|
-
const { FileSessionStore } = await import("./src-
|
|
363
|
-
const { WikiStore, runWikiBootstrap,
|
|
364
|
-
const { commitCuratedMemoryBestEffort } = await import("./memory-git-
|
|
362
|
+
const { FileSessionStore } = await import("./src-3YJ4UVEC.js");
|
|
363
|
+
const { WikiStore, runWikiBootstrap, runWikiDreamBatches, runWikiGc } = await import("./src-T6AUO53N.js");
|
|
364
|
+
const { commitCuratedMemoryBestEffort } = await import("./memory-git-G56IXFWU.js");
|
|
365
365
|
const wiki = new WikiStore(memoryRoot);
|
|
366
366
|
wikiForError = wiki;
|
|
367
|
-
|
|
367
|
+
const inboxOnly = date === "__inbox__";
|
|
368
|
+
if (!inboxOnly && wiki.hasDreamedDate(date)) {
|
|
368
369
|
result = { ok: true, status: "skipped-ran" };
|
|
369
370
|
} else {
|
|
370
371
|
const registry = new ModelRegistry(AuthStorage.create());
|
|
371
372
|
const cwdFilter = await createExcludeCwdFilter();
|
|
372
373
|
const lightCall = createWikiModelCall(registry, "light", void 0, 12e4);
|
|
373
374
|
const balancedCall = createWikiModelCall(registry, "balanced", void 0, 18e4);
|
|
374
|
-
if (!wiki.exists() && hasLegacyMemorySeed(memoryRoot)) {
|
|
375
|
+
if (!inboxOnly && !wiki.exists() && hasLegacyMemorySeed(memoryRoot)) {
|
|
375
376
|
const boot = await runWikiBootstrap({ memoryRoot, balancedCall });
|
|
376
377
|
log(`[wiki] auto-bootstrap ok=${boot.ok} written=${boot.written.length}${boot.error ? ` error=${boot.error}` : ""}`);
|
|
377
378
|
if (!boot.ok) {
|
|
@@ -388,18 +389,20 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false, sessionsDi
|
|
|
388
389
|
}
|
|
389
390
|
if (!result) {
|
|
390
391
|
const resolvedSessionsDir = sessionsDir ? path.resolve(sessionsDir) : getSessionsDir();
|
|
391
|
-
const dreamRes = await
|
|
392
|
+
const dreamRes = await runWikiDreamBatches({
|
|
392
393
|
sessionStore: new FileSessionStore(resolvedSessionsDir),
|
|
393
394
|
memoryRoot,
|
|
394
|
-
dates: [date],
|
|
395
|
+
dates: inboxOnly ? [] : [date],
|
|
395
396
|
lightCall,
|
|
396
397
|
balancedCall,
|
|
397
398
|
cwdFilter,
|
|
398
399
|
log
|
|
399
400
|
});
|
|
400
|
-
|
|
401
|
+
const batchNote = dreamRes.batchesRun > 1 ? ` batches=${dreamRes.batchesRun}` : "";
|
|
402
|
+
const inboxNote = dreamRes.inboxMerged ? ` inbox=${dreamRes.inboxMerged}` : "";
|
|
403
|
+
log(`[wiki] dream ${inboxOnly ? "inbox" : date}: ok=${dreamRes.ok} sessions=${dreamRes.sessionsHarvested} signals=${dreamRes.signalsAuthenticated} written=${dreamRes.written.length}${batchNote}${inboxNote}${dreamRes.error ? ` error=${dreamRes.error}` : ""}`);
|
|
401
404
|
let gcWrote = false;
|
|
402
|
-
if (wiki.exists()) {
|
|
405
|
+
if (!inboxOnly && wiki.exists()) {
|
|
403
406
|
const meta = wiki.readMeta();
|
|
404
407
|
const sevenDaysMs = 7 * 24 * 60 * 60 * 1e3;
|
|
405
408
|
const atCapacityPressure = wiki.listActivePages().length >= 18;
|
|
@@ -411,16 +414,16 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false, sessionsDi
|
|
|
411
414
|
}
|
|
412
415
|
}
|
|
413
416
|
if (dreamRes.written.length > 0 || dreamRes.archived.length > 0 || gcWrote) {
|
|
414
|
-
commitCuratedMemoryBestEffort(memoryRoot, `wiki(dream): ${date}`);
|
|
417
|
+
commitCuratedMemoryBestEffort(memoryRoot, inboxOnly ? "wiki(inbox): merge attested saves" : `wiki(dream): ${date}`);
|
|
415
418
|
}
|
|
416
419
|
if (dreamRes.ok) {
|
|
417
|
-
const status = dreamRes.sessionsHarvested === 0 ? "skipped-empty" : "applied";
|
|
420
|
+
const status = dreamRes.sessionsHarvested === 0 && !dreamRes.inboxMerged ? "skipped-empty" : "applied";
|
|
418
421
|
result = { ok: true, status };
|
|
419
422
|
} else {
|
|
420
423
|
const err = dreamRes.error ?? "wiki dream failed";
|
|
421
424
|
const retryable = isWikiDreamResultRetryable(dreamRes);
|
|
422
425
|
try {
|
|
423
|
-
wiki.recordDreamFailure(err, date);
|
|
426
|
+
wiki.recordDreamFailure(err, inboxOnly ? "inbox" : date);
|
|
424
427
|
} catch {
|
|
425
428
|
}
|
|
426
429
|
result = { ok: false, status: "failed", error: err, retryable };
|
|
@@ -453,7 +456,7 @@ async function runDistillAuto(memoryRoot, days = 7, runner, sessionsDir) {
|
|
|
453
456
|
} catch {
|
|
454
457
|
}
|
|
455
458
|
};
|
|
456
|
-
const { WikiStore, todayKey } = await import("./src-
|
|
459
|
+
const { WikiStore, countWikiInbox, todayKey } = await import("./src-T6AUO53N.js");
|
|
457
460
|
const wiki = new WikiStore(memoryRoot);
|
|
458
461
|
const today = todayKey(Date.now());
|
|
459
462
|
const dates = [];
|
|
@@ -466,15 +469,17 @@ async function runDistillAuto(memoryRoot, days = 7, runner, sessionsDir) {
|
|
|
466
469
|
dates.push(date);
|
|
467
470
|
}
|
|
468
471
|
}
|
|
469
|
-
|
|
472
|
+
const pendingInbox = countWikiInbox(memoryRoot);
|
|
473
|
+
if (dates.length === 0 && pendingInbox === 0) {
|
|
470
474
|
log("auto: no missing checkpoints in the window");
|
|
471
475
|
return { ok: true, lines: ["memory --auto: no missing checkpoints in the last " + days + " days."] };
|
|
472
476
|
}
|
|
473
|
-
|
|
477
|
+
const runTargets = dates.length > 0 ? dates : ["__inbox__"];
|
|
478
|
+
log(dates.length > 0 ? `auto: ${dates.length} missing date(s): ${dates.join(", ")}` : `auto: draining ${pendingInbox} pending inbox item(s)`);
|
|
474
479
|
const lines = [];
|
|
475
480
|
let failures = 0;
|
|
476
481
|
let hasPermanentFailure = false;
|
|
477
|
-
for (const date of
|
|
482
|
+
for (const date of runTargets) {
|
|
478
483
|
const result = await (runner ?? runDistillWorkerMain)(memoryRoot, date, true, sessionsDir);
|
|
479
484
|
if (!result.ok && result.busy) {
|
|
480
485
|
lines.push(`${date}: busy \u2014 another distillation worker is running; next schedule retries`);
|