@cydm/pie 4.13.0 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/im-forward/index.js +8099 -8101
- 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/index.js +69 -60
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/builtin/extensions/subagent/index.js +6 -5
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/chunks/{chunk-BQWHLYYZ.js → chunk-26KRUYZH.js} +1 -1
- package/dist/chunks/{chunk-5MCIBDAM.js → chunk-BOQIGMGQ.js} +38 -93
- package/dist/chunks/{chunk-AKC7NMP4.js → chunk-EZZTMDWZ.js} +887 -391
- package/dist/chunks/{chunk-5PCLBIOO.js → chunk-FD3KBPDR.js} +110 -75
- package/dist/chunks/{chunk-NOSNHMA2.js → chunk-IK2FR2YF.js} +2 -1
- package/dist/chunks/{chunk-SXBX2P5R.js → chunk-JJH77AUU.js} +1709 -1577
- package/dist/chunks/{chunk-OGGL6LUN.js → chunk-JKO42HZW.js} +1 -1
- package/dist/chunks/{chunk-3CJLYX5J.js → chunk-KGWKRO7Z.js} +2 -2
- package/dist/chunks/{chunk-G2K4GY6N.js → chunk-MCR4JYI6.js} +103 -12
- package/dist/chunks/{chunk-IZ4DYCJ7.js → chunk-UYDS75SI.js} +810 -726
- package/dist/chunks/{host-image-fallback-MZK633DK.js → host-image-fallback-LPHB5CTL.js} +1 -1
- package/dist/chunks/{manager-cli-OTIMAWO6.js → manager-cli-ZV36YNPJ.js} +187 -173
- package/dist/chunks/{memory-git-Q3UBYOJ4.js → memory-git-ZJN6SPIU.js} +5 -5
- package/dist/chunks/{model-registry-QNEPISBJ.js → model-registry-GLBIUOJR.js} +2 -2
- package/dist/chunks/{read-file-understanding-KCJMSOS7.js → read-file-understanding-DFJPTTSB.js} +5 -5
- package/dist/chunks/{src-TIDKYA5F.js → src-76Q33OY5.js} +1 -1
- package/dist/chunks/{src-D5GN4Q5O.js → src-ALHMJZ5R.js} +2 -2
- package/dist/chunks/{src-7MZZJVOG.js → src-KZ7YID3I.js} +11 -3
- package/dist/chunks/{src-QI47K3W3.js → src-LEXKDSFV.js} +24 -6
- package/dist/chunks/{test-stream-JAJHK44G.js → test-stream-OVGDTXOY.js} +1 -1
- package/dist/cli.js +12910 -12631
- package/models.schema.json +12 -3
- package/package.json +1 -1
- package/dist/chunks/{chunk-3GG342QY.js → chunk-TYCKSYUF.js} +19 -19
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-CBDQJMUI.js";
|
|
5
5
|
import {
|
|
6
6
|
createMemoryLockBackend
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-EZZTMDWZ.js";
|
|
8
8
|
|
|
9
9
|
// src/commands/memory-distill.ts
|
|
10
10
|
import * as fs from "node:fs";
|
|
@@ -143,8 +143,9 @@ function resolveDefaultModelSpecFromSettings() {
|
|
|
143
143
|
return void 0;
|
|
144
144
|
}
|
|
145
145
|
function createWikiModelCall(registry, modelClass, explicitModelSpec, timeoutMs = 18e4, hooks) {
|
|
146
|
-
const
|
|
146
|
+
const resolveTargets = () => {
|
|
147
147
|
const trySpec = (spec) => {
|
|
148
|
+
if (typeof registry.find !== "function" || typeof registry.getApiKey !== "function") return void 0;
|
|
148
149
|
const slash = spec.indexOf("/");
|
|
149
150
|
if (slash <= 0 || slash === spec.length - 1) return void 0;
|
|
150
151
|
const provider = spec.slice(0, slash);
|
|
@@ -160,79 +161,108 @@ function createWikiModelCall(registry, modelClass, explicitModelSpec, timeoutMs
|
|
|
160
161
|
if (!exact) {
|
|
161
162
|
throw new Error(`model "${explicitModelSpec}" is not configured or has no API key`);
|
|
162
163
|
}
|
|
163
|
-
return exact;
|
|
164
|
+
return [exact];
|
|
165
|
+
}
|
|
166
|
+
const targets = [];
|
|
167
|
+
const seen = /* @__PURE__ */ new Set();
|
|
168
|
+
const pushTarget = (entry) => {
|
|
169
|
+
if (!entry?.model || !entry.apiKey) return;
|
|
170
|
+
const key = `${entry.model.provider}/${entry.model.id}`;
|
|
171
|
+
if (seen.has(key)) return;
|
|
172
|
+
seen.add(key);
|
|
173
|
+
targets.push({ model: entry.model, apiKey: entry.apiKey });
|
|
174
|
+
};
|
|
175
|
+
for (const candidate of registry.resolveModelClassCandidates?.(modelClass) ?? []) {
|
|
176
|
+
pushTarget(candidate);
|
|
164
177
|
}
|
|
165
178
|
const byClass = registry.resolveModelClass(modelClass);
|
|
166
|
-
|
|
167
|
-
|
|
179
|
+
pushTarget(byClass);
|
|
180
|
+
if (modelClass === "light") {
|
|
181
|
+
for (const candidate of registry.resolveModelClassCandidates?.("balanced") ?? []) {
|
|
182
|
+
pushTarget(candidate);
|
|
183
|
+
}
|
|
184
|
+
pushTarget(registry.resolveModelClass("balanced"));
|
|
168
185
|
}
|
|
169
186
|
const fallbackSpec = resolveDefaultModelSpecFromSettings();
|
|
170
187
|
if (fallbackSpec) {
|
|
171
|
-
|
|
172
|
-
if (fallback) return fallback;
|
|
188
|
+
pushTarget(trySpec(fallbackSpec));
|
|
173
189
|
}
|
|
174
|
-
|
|
190
|
+
if (targets.length === 0) {
|
|
191
|
+
throw new Error(`no complete model/key pair for class ${modelClass}${byClass.fallbackReason ? `: ${byClass.fallbackReason}` : ""}`);
|
|
192
|
+
}
|
|
193
|
+
return targets;
|
|
175
194
|
};
|
|
176
195
|
return async (prompt, options) => {
|
|
177
|
-
const
|
|
178
|
-
const complete = hooks?.completeFn ?? (await import("./src-
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
const targets = resolveTargets();
|
|
197
|
+
const complete = hooks?.completeFn ?? (await import("./src-76Q33OY5.js")).completeSimple;
|
|
198
|
+
const runCandidate = async (model, apiKey) => {
|
|
199
|
+
const invokeOnce = async () => {
|
|
200
|
+
const controller = new AbortController();
|
|
201
|
+
let timedOut = false;
|
|
202
|
+
const timer = setTimeout(() => {
|
|
203
|
+
timedOut = true;
|
|
204
|
+
controller.abort();
|
|
205
|
+
}, timeoutMs);
|
|
206
|
+
try {
|
|
207
|
+
const message = await complete(
|
|
208
|
+
model,
|
|
209
|
+
{
|
|
210
|
+
systemPrompt: options?.system ?? "You are a disciplined memory curator. Output JSON only.",
|
|
211
|
+
messages: [{ role: "user", content: [{ type: "text", text: prompt }], timestamp: Date.now() }]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
apiKey,
|
|
215
|
+
...model.reasoning ? { reasoning: "low" } : {},
|
|
216
|
+
maxTokens: Math.min(model.maxTokens ?? 32768, 32768),
|
|
217
|
+
signal: controller.signal
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
if (timedOut) {
|
|
221
|
+
const err = new Error(`wiki model call (${model.provider}/${model.id}) timed out after ${timeoutMs}ms`);
|
|
222
|
+
err.noImmediateReplay = true;
|
|
223
|
+
throw err;
|
|
198
224
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
225
|
+
if (message.stopReason && message.stopReason !== "stop") {
|
|
226
|
+
const detail = typeof message.errorMessage === "string" && message.errorMessage.trim() ? `: ${message.errorMessage.trim()}` : "";
|
|
227
|
+
const err = new Error(`wiki model call (${model.provider}/${model.id}) ended with stopReason=${message.stopReason}${detail}`);
|
|
228
|
+
if (message.retryable === false || message.stopReason === "length") {
|
|
229
|
+
err.noImmediateReplay = true;
|
|
230
|
+
}
|
|
231
|
+
throw err;
|
|
232
|
+
}
|
|
233
|
+
return message.content.filter((block) => block.type === "text").map((block) => block.text).join("\n");
|
|
234
|
+
} catch (rawError) {
|
|
235
|
+
if (timedOut && !(rawError instanceof Error && rawError.message.includes("timed out after"))) {
|
|
236
|
+
const err = new Error(`wiki model call (${model.provider}/${model.id}) timed out after ${timeoutMs}ms`);
|
|
209
237
|
err.noImmediateReplay = true;
|
|
238
|
+
throw err;
|
|
210
239
|
}
|
|
211
|
-
throw
|
|
240
|
+
throw rawError;
|
|
241
|
+
} finally {
|
|
242
|
+
clearTimeout(timer);
|
|
212
243
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
244
|
+
};
|
|
245
|
+
try {
|
|
246
|
+
return await invokeOnce();
|
|
247
|
+
} catch (firstError) {
|
|
248
|
+
const msg = firstError instanceof Error ? firstError.message : String(firstError);
|
|
249
|
+
const noReplay = Boolean(firstError?.noImmediateReplay);
|
|
250
|
+
if (noReplay || !isTransientDistillError(msg) || msg.toLowerCase().includes("stopreason=length")) {
|
|
251
|
+
throw firstError;
|
|
219
252
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
clearTimeout(timer);
|
|
253
|
+
await new Promise((resolve2) => setTimeout(resolve2, hooks?.retryDelayMs ?? 1500));
|
|
254
|
+
return await invokeOnce();
|
|
223
255
|
}
|
|
224
256
|
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
throw firstError;
|
|
257
|
+
let lastError;
|
|
258
|
+
for (const target of targets) {
|
|
259
|
+
try {
|
|
260
|
+
return await runCandidate(target.model, target.apiKey);
|
|
261
|
+
} catch (err) {
|
|
262
|
+
lastError = err;
|
|
232
263
|
}
|
|
233
|
-
await new Promise((resolve2) => setTimeout(resolve2, hooks?.retryDelayMs ?? 1500));
|
|
234
|
-
return await invokeOnce();
|
|
235
264
|
}
|
|
265
|
+
throw lastError;
|
|
236
266
|
};
|
|
237
267
|
}
|
|
238
268
|
function isWikiDreamResultRetryable(dreamRes) {
|
|
@@ -326,22 +356,23 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false, sessionsDi
|
|
|
326
356
|
let result;
|
|
327
357
|
let wikiForError;
|
|
328
358
|
try {
|
|
329
|
-
const { ModelRegistry } = await import("./model-registry-
|
|
359
|
+
const { ModelRegistry } = await import("./model-registry-GLBIUOJR.js");
|
|
330
360
|
const { AuthStorage } = await import("./auth-storage-IJEJ2TGE.js");
|
|
331
361
|
const { getSessionsDir } = await import("./config-4EOI5NOU.js");
|
|
332
|
-
const { FileSessionStore } = await import("./src-
|
|
333
|
-
const { WikiStore, runWikiBootstrap,
|
|
334
|
-
const { commitCuratedMemoryBestEffort } = await import("./memory-git-
|
|
362
|
+
const { FileSessionStore } = await import("./src-KZ7YID3I.js");
|
|
363
|
+
const { WikiStore, runWikiBootstrap, runWikiDreamBatches, runWikiGc } = await import("./src-LEXKDSFV.js");
|
|
364
|
+
const { commitCuratedMemoryBestEffort } = await import("./memory-git-ZJN6SPIU.js");
|
|
335
365
|
const wiki = new WikiStore(memoryRoot);
|
|
336
366
|
wikiForError = wiki;
|
|
337
|
-
|
|
367
|
+
const inboxOnly = date === "__inbox__";
|
|
368
|
+
if (!inboxOnly && wiki.hasDreamedDate(date)) {
|
|
338
369
|
result = { ok: true, status: "skipped-ran" };
|
|
339
370
|
} else {
|
|
340
371
|
const registry = new ModelRegistry(AuthStorage.create());
|
|
341
372
|
const cwdFilter = await createExcludeCwdFilter();
|
|
342
373
|
const lightCall = createWikiModelCall(registry, "light", void 0, 12e4);
|
|
343
374
|
const balancedCall = createWikiModelCall(registry, "balanced", void 0, 18e4);
|
|
344
|
-
if (!wiki.exists() && hasLegacyMemorySeed(memoryRoot)) {
|
|
375
|
+
if (!inboxOnly && !wiki.exists() && hasLegacyMemorySeed(memoryRoot)) {
|
|
345
376
|
const boot = await runWikiBootstrap({ memoryRoot, balancedCall });
|
|
346
377
|
log(`[wiki] auto-bootstrap ok=${boot.ok} written=${boot.written.length}${boot.error ? ` error=${boot.error}` : ""}`);
|
|
347
378
|
if (!boot.ok) {
|
|
@@ -358,18 +389,20 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false, sessionsDi
|
|
|
358
389
|
}
|
|
359
390
|
if (!result) {
|
|
360
391
|
const resolvedSessionsDir = sessionsDir ? path.resolve(sessionsDir) : getSessionsDir();
|
|
361
|
-
const dreamRes = await
|
|
392
|
+
const dreamRes = await runWikiDreamBatches({
|
|
362
393
|
sessionStore: new FileSessionStore(resolvedSessionsDir),
|
|
363
394
|
memoryRoot,
|
|
364
|
-
dates: [date],
|
|
395
|
+
dates: inboxOnly ? [] : [date],
|
|
365
396
|
lightCall,
|
|
366
397
|
balancedCall,
|
|
367
398
|
cwdFilter,
|
|
368
399
|
log
|
|
369
400
|
});
|
|
370
|
-
|
|
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}` : ""}`);
|
|
371
404
|
let gcWrote = false;
|
|
372
|
-
if (wiki.exists()) {
|
|
405
|
+
if (!inboxOnly && wiki.exists()) {
|
|
373
406
|
const meta = wiki.readMeta();
|
|
374
407
|
const sevenDaysMs = 7 * 24 * 60 * 60 * 1e3;
|
|
375
408
|
const atCapacityPressure = wiki.listActivePages().length >= 18;
|
|
@@ -381,16 +414,16 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false, sessionsDi
|
|
|
381
414
|
}
|
|
382
415
|
}
|
|
383
416
|
if (dreamRes.written.length > 0 || dreamRes.archived.length > 0 || gcWrote) {
|
|
384
|
-
commitCuratedMemoryBestEffort(memoryRoot, `wiki(dream): ${date}`);
|
|
417
|
+
commitCuratedMemoryBestEffort(memoryRoot, inboxOnly ? "wiki(inbox): merge attested saves" : `wiki(dream): ${date}`);
|
|
385
418
|
}
|
|
386
419
|
if (dreamRes.ok) {
|
|
387
|
-
const status = dreamRes.sessionsHarvested === 0 ? "skipped-empty" : "applied";
|
|
420
|
+
const status = dreamRes.sessionsHarvested === 0 && !dreamRes.inboxMerged ? "skipped-empty" : "applied";
|
|
388
421
|
result = { ok: true, status };
|
|
389
422
|
} else {
|
|
390
423
|
const err = dreamRes.error ?? "wiki dream failed";
|
|
391
424
|
const retryable = isWikiDreamResultRetryable(dreamRes);
|
|
392
425
|
try {
|
|
393
|
-
wiki.recordDreamFailure(err, date);
|
|
426
|
+
wiki.recordDreamFailure(err, inboxOnly ? "inbox" : date);
|
|
394
427
|
} catch {
|
|
395
428
|
}
|
|
396
429
|
result = { ok: false, status: "failed", error: err, retryable };
|
|
@@ -423,7 +456,7 @@ async function runDistillAuto(memoryRoot, days = 7, runner, sessionsDir) {
|
|
|
423
456
|
} catch {
|
|
424
457
|
}
|
|
425
458
|
};
|
|
426
|
-
const { WikiStore, todayKey } = await import("./src-
|
|
459
|
+
const { WikiStore, countWikiInbox, todayKey } = await import("./src-LEXKDSFV.js");
|
|
427
460
|
const wiki = new WikiStore(memoryRoot);
|
|
428
461
|
const today = todayKey(Date.now());
|
|
429
462
|
const dates = [];
|
|
@@ -436,15 +469,17 @@ async function runDistillAuto(memoryRoot, days = 7, runner, sessionsDir) {
|
|
|
436
469
|
dates.push(date);
|
|
437
470
|
}
|
|
438
471
|
}
|
|
439
|
-
|
|
472
|
+
const pendingInbox = countWikiInbox(memoryRoot);
|
|
473
|
+
if (dates.length === 0 && pendingInbox === 0) {
|
|
440
474
|
log("auto: no missing checkpoints in the window");
|
|
441
475
|
return { ok: true, lines: ["memory --auto: no missing checkpoints in the last " + days + " days."] };
|
|
442
476
|
}
|
|
443
|
-
|
|
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)`);
|
|
444
479
|
const lines = [];
|
|
445
480
|
let failures = 0;
|
|
446
481
|
let hasPermanentFailure = false;
|
|
447
|
-
for (const date of
|
|
482
|
+
for (const date of runTargets) {
|
|
448
483
|
const result = await (runner ?? runDistillWorkerMain)(memoryRoot, date, true, sessionsDir);
|
|
449
484
|
if (!result.ok && result.busy) {
|
|
450
485
|
lines.push(`${date}: busy \u2014 another distillation worker is running; next schedule retries`);
|
|
@@ -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-EZZTMDWZ.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",
|