@cydm/pie 4.7.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -27
- package/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/cron/index.js +916 -162
- package/dist/builtin/extensions/im-forward/README.md +24 -7
- package/dist/builtin/extensions/im-forward/index.js +6823 -3683
- package/dist/builtin/extensions/memory/index.js +76 -28
- package/dist/builtin/extensions/pie-ipc/README.md +2 -2
- package/dist/builtin/extensions/pie-ipc/index.js +421 -27
- package/dist/builtin/extensions/pie-proc/README.md +7 -7
- package/dist/builtin/extensions/pie-proc/index.js +453 -97
- package/dist/builtin/extensions/plan-mode/index.js +5 -5
- package/dist/builtin/extensions/subagent/index.js +8 -8
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +35 -24
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +391 -123
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chunk-HAUDUMDO.js +795 -0
- package/dist/builtin/skills/chrome-devtools-axi/{cli-NLPMVDGG.js → cli-K7ESY3XD.js} +1437 -231
- package/dist/builtin/skills/computer-use-axi/SKILL.md +26 -8
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +465 -83
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-runtime.js +75 -22
- package/dist/builtin/skills/tui-use/tui-use-daemon.cjs +451 -43
- package/dist/chunks/{chunk-3W3SXVPB.js → chunk-4UIUMTHG.js} +993 -371
- package/dist/chunks/chunk-6WKBQZWM.js +19 -0
- package/dist/chunks/{chunk-5KI4Y4LA.js → chunk-BA4Z27XT.js} +4 -3
- package/dist/chunks/{chunk-BLDI2GRF.js → chunk-DBDU3RRN.js} +1364 -446
- package/dist/chunks/{chunk-LAJXWOKS.js → chunk-EEC5PJTC.js} +11 -9
- package/dist/chunks/chunk-IZKHSUNQ.js +30 -0
- package/dist/chunks/{chunk-Y3I2UV5Y.js → chunk-LRHNAG4V.js} +349 -288
- package/dist/chunks/chunk-OU33ROFD.js +717 -0
- package/dist/chunks/{chunk-Z2FKA2ZH.js → chunk-PN6B54VT.js} +104 -22
- package/dist/chunks/{chunk-NHV2CALB.js → chunk-WYXUF4MP.js} +388 -32
- package/dist/chunks/{chunk-4PR34UZF.js → chunk-Z5KL6AO2.js} +159 -145
- package/dist/chunks/{host-image-fallback-N7RHNPYN.js → host-image-fallback-RASJSVZY.js} +1 -1
- package/dist/chunks/{manager-cli-NEZA46M5.js → manager-cli-Y6HM3MHA.js} +5 -5
- package/dist/chunks/{model-registry-3XAHXXTA.js → model-registry-5TLYILYR.js} +2 -2
- package/dist/chunks/{read-file-understanding-FMPXR6EJ.js → read-file-understanding-VPKDBV23.js} +5 -5
- package/dist/chunks/{src-B44QWSGM.js → src-2XI5P62J.js} +2 -2
- package/dist/chunks/{src-EGXFJ3WA.js → src-6QGGDHIW.js} +3 -3
- package/dist/chunks/{src-Q7LU27C2.js → src-CCEENRKC.js} +31 -1
- package/dist/chunks/{src-CLE5ILN4.js → src-DI4MCAGT.js} +20 -4
- package/dist/chunks/{test-stream-OR3EJBNF.js → test-stream-SYVWIPPW.js} +2 -2
- package/dist/cli.js +1918 -1489
- package/models.schema.json +271 -0
- package/package.json +2 -2
- package/dist/builtin/skills/chrome-devtools-axi/chunk-WOGAQ4P5.js +0 -399
- package/dist/chunks/chunk-7UAUDXZW.js +0 -1425
- package/dist/chunks/{chunk-CGSFBWOM.js → chunk-WBL73KRI.js} +3 -3
- package/dist/chunks/{manager-upgrade-CTU3ISCW.js → manager-upgrade-LSTOHBUV.js} +3 -3
|
@@ -21,11 +21,15 @@ function readDistillWorkerLog(memoryRoot, limit = 20) {
|
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
var MEMORY_DISTILL_RETRYABLE_EXIT_CODE = 75;
|
|
25
|
+
function distillExitCode(result) {
|
|
26
|
+
return result.ok ? 0 : result.retryable ? MEMORY_DISTILL_RETRYABLE_EXIT_CODE : 1;
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
return spawnDistillCli(memoryRoot, ["--
|
|
28
|
+
function spawnDistillWorker(memoryRoot, date, sessionsDir) {
|
|
29
|
+
return spawnDistillCli(memoryRoot, ["--date", date, ...sessionsDir ? ["--sessions-dir", sessionsDir] : []]);
|
|
30
|
+
}
|
|
31
|
+
function spawnDistillAutoWorker(memoryRoot, sessionsDir) {
|
|
32
|
+
return spawnDistillCli(memoryRoot, ["--auto", ...sessionsDir ? ["--sessions-dir", sessionsDir] : []]);
|
|
29
33
|
}
|
|
30
34
|
function spawnDistillCli(memoryRoot, modeArgs) {
|
|
31
35
|
const logPath = distillWorkerLogPath(memoryRoot);
|
|
@@ -156,7 +160,28 @@ async function readExcludeCwds() {
|
|
|
156
160
|
return [];
|
|
157
161
|
}
|
|
158
162
|
}
|
|
159
|
-
|
|
163
|
+
function isTransientDistillError(message) {
|
|
164
|
+
const lower = message.toLowerCase();
|
|
165
|
+
if (/^(?:(?:harvest|evidence|apply):\s*)?memory store is contended \(write\.lock\)/i.test(message.trim())) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
if (/^(?:harvest|evidence|apply):/i.test(message)) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
if (/^(?:distill:[^:]+:\s*)?distill (?:response contains no json array|response contains invalid json|response is not an array|candidate is not an object|candidate has invalid shape|quote is implausibly long)/i.test(
|
|
172
|
+
message.trim()
|
|
173
|
+
)) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
if (lower.includes("no complete model/key pair") || lower.includes("invalid api key") || lower.includes("unauthorized") || lower.includes("forbidden") || lower.includes("eacces") || lower.includes("eperm") || lower.includes("erofs") || lower.includes("enospc")) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
if (lower.includes("syntaxerror") || lower.includes("invalid json") || lower.includes("in json at position")) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return lower.includes("timed out") || lower.includes("timeout") || lower.includes("rate limit") || lower.includes("too many requests") || lower.includes("overloaded") || lower.includes("temporarily unavailable") || lower.includes("service unavailable") || lower.includes("bad gateway") || lower.includes("gateway timeout") || lower.includes("fetch failed") || lower.includes("connection error") || lower.includes("network error") || lower.includes("socket hang up") || lower.includes("econnreset") || lower.includes("econnrefused") || lower.includes("etimedout") || lower.includes("enotfound") || lower.includes("eai_again") || lower.includes("stopreason=length") || /(?:^|:\s*|http\s+|status(?:\s*code)?\s*[:=]?\s*)(?:429|500|502|503|504|529)\b/.test(lower);
|
|
183
|
+
}
|
|
184
|
+
async function runDistillWorkerMain(memoryRoot, date, noExit = false, sessionsDir) {
|
|
160
185
|
const log = (message) => {
|
|
161
186
|
try {
|
|
162
187
|
fs.appendFileSync(distillWorkerLogPath(memoryRoot), `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
@@ -171,11 +196,11 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
171
196
|
let result;
|
|
172
197
|
let ledger;
|
|
173
198
|
try {
|
|
174
|
-
const { ModelRegistry } = await import("./model-registry-
|
|
199
|
+
const { ModelRegistry } = await import("./model-registry-5TLYILYR.js");
|
|
175
200
|
const { AuthStorage } = await import("./auth-storage-C3FZMT7J.js");
|
|
176
201
|
const { getSessionsDir } = await import("./config-4EOI5NOU.js");
|
|
177
|
-
const { FileSessionStore } = await import("./src-
|
|
178
|
-
const { MemoryStore, runDistillation } = await import("./src-
|
|
202
|
+
const { FileSessionStore } = await import("./src-6QGGDHIW.js");
|
|
203
|
+
const { MemoryStore, runDistillation } = await import("./src-DI4MCAGT.js");
|
|
179
204
|
const store = new MemoryStore(memoryRoot);
|
|
180
205
|
ledger = store;
|
|
181
206
|
const registry = new ModelRegistry(AuthStorage.create());
|
|
@@ -190,7 +215,7 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
190
215
|
if (!resolved.model || !resolved.apiKey) {
|
|
191
216
|
throw new Error(`no complete model/key pair for class ${modelClass}${resolved.fallbackReason ? `: ${resolved.fallbackReason}` : ""}`);
|
|
192
217
|
}
|
|
193
|
-
const { completeSimple } = await import("./src-
|
|
218
|
+
const { completeSimple } = await import("./src-CCEENRKC.js");
|
|
194
219
|
const message = await withModelTimeout(
|
|
195
220
|
completeSimple(
|
|
196
221
|
resolved.model,
|
|
@@ -207,13 +232,15 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
207
232
|
`memory ${modelClass} model call`
|
|
208
233
|
);
|
|
209
234
|
if (message.stopReason && message.stopReason !== "stop") {
|
|
210
|
-
|
|
235
|
+
const detail = typeof message.errorMessage === "string" && message.errorMessage.trim() ? `: ${message.errorMessage.trim()}` : "";
|
|
236
|
+
throw new Error(`memory model call ended with stopReason=${message.stopReason}${detail}`);
|
|
211
237
|
}
|
|
212
238
|
return message.content.filter((block) => block.type === "text").map((block) => block.text).join("\n");
|
|
213
239
|
};
|
|
240
|
+
const resolvedSessionsDir = sessionsDir ? path.resolve(sessionsDir) : getSessionsDir();
|
|
214
241
|
const distilled = await runDistillation(
|
|
215
242
|
{
|
|
216
|
-
sessionStore: new FileSessionStore(
|
|
243
|
+
sessionStore: new FileSessionStore(resolvedSessionsDir),
|
|
217
244
|
memoryStore: store,
|
|
218
245
|
lightCall: modelCall("light"),
|
|
219
246
|
balancedCall: modelCall("balanced"),
|
|
@@ -229,7 +256,9 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
229
256
|
} else {
|
|
230
257
|
ledger?.clearFailures(date);
|
|
231
258
|
}
|
|
232
|
-
|
|
259
|
+
const ok = distilled.status === "applied" || distilled.status === "skipped-ran" || distilled.status === "skipped-empty";
|
|
260
|
+
const retryable = !ok && distilled.error !== void 0 && isTransientDistillError(distilled.error);
|
|
261
|
+
result = { ok, status: distilled.status, error: distilled.error, ...retryable ? { retryable: true } : {} };
|
|
233
262
|
} catch (error) {
|
|
234
263
|
const message = error instanceof Error ? error.message : String(error);
|
|
235
264
|
log(`failed ${date}: ${message}`);
|
|
@@ -237,17 +266,18 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
237
266
|
ledger?.recordFailure(date, message);
|
|
238
267
|
} catch {
|
|
239
268
|
}
|
|
240
|
-
|
|
269
|
+
const retryable = isTransientDistillError(message);
|
|
270
|
+
result = { ok: false, error: message, ...retryable ? { retryable: true } : {} };
|
|
241
271
|
} finally {
|
|
242
272
|
release();
|
|
243
273
|
}
|
|
244
274
|
if (!noExit) {
|
|
245
|
-
const exitCode = result
|
|
275
|
+
const exitCode = distillExitCode(result);
|
|
246
276
|
setTimeout(() => process.exit(exitCode), 50).unref?.();
|
|
247
277
|
}
|
|
248
278
|
return result;
|
|
249
279
|
}
|
|
250
|
-
async function runDistillAuto(memoryRoot, days = 7, runner) {
|
|
280
|
+
async function runDistillAuto(memoryRoot, days = 7, runner, sessionsDir) {
|
|
251
281
|
const log = (message) => {
|
|
252
282
|
try {
|
|
253
283
|
fs.appendFileSync(distillWorkerLogPath(memoryRoot), `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
@@ -255,16 +285,55 @@ async function runDistillAuto(memoryRoot, days = 7, runner) {
|
|
|
255
285
|
} catch {
|
|
256
286
|
}
|
|
257
287
|
};
|
|
258
|
-
const { MemoryStore, todayKey } = await import("./src-
|
|
288
|
+
const { MemoryStore, todayKey, harvestSessionsForDate } = await import("./src-DI4MCAGT.js");
|
|
259
289
|
const store = new MemoryStore(memoryRoot);
|
|
260
290
|
const today = todayKey(Date.now());
|
|
261
291
|
const dates = [];
|
|
292
|
+
let pinnedSessionStore;
|
|
293
|
+
let recoveryCwdFilter;
|
|
294
|
+
if (sessionsDir) {
|
|
295
|
+
try {
|
|
296
|
+
const { FileSessionStore } = await import("./src-6QGGDHIW.js");
|
|
297
|
+
pinnedSessionStore = new FileSessionStore(path.resolve(sessionsDir));
|
|
298
|
+
const excludeCwds = await readExcludeCwds();
|
|
299
|
+
if (excludeCwds.length > 0) {
|
|
300
|
+
recoveryCwdFilter = (cwd) => {
|
|
301
|
+
if (!cwd) return true;
|
|
302
|
+
const normalized = normalizeCwdPath(cwd);
|
|
303
|
+
return !excludeCwds.some((excluded) => pathContains(excluded, normalized));
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
} catch {
|
|
307
|
+
}
|
|
308
|
+
}
|
|
262
309
|
for (let offset = days; offset >= 1; offset -= 1) {
|
|
263
310
|
const probe = /* @__PURE__ */ new Date();
|
|
264
311
|
probe.setDate(probe.getDate() - offset);
|
|
265
312
|
const date = todayKey(probe.getTime());
|
|
266
313
|
if (date === today) continue;
|
|
267
|
-
if (!store.hasRun(date))
|
|
314
|
+
if (!store.hasRun(date)) {
|
|
315
|
+
dates.push(date);
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
if (pinnedSessionStore) {
|
|
319
|
+
const run = store.loadState().runs[date];
|
|
320
|
+
if (run && run.ops === 0 && !run.gated && !store.readJournal(date)) {
|
|
321
|
+
try {
|
|
322
|
+
if (harvestSessionsForDate(pinnedSessionStore, date, { maxCharsPerSession: 256, cwdFilter: recoveryCwdFilter }).length > 0) {
|
|
323
|
+
store.transaction(() => {
|
|
324
|
+
const state = store.loadState();
|
|
325
|
+
const latest = state.runs[date];
|
|
326
|
+
if (latest && latest.ops === 0 && !latest.gated && !store.readJournal(date)) {
|
|
327
|
+
delete state.runs[date];
|
|
328
|
+
store.writeState(state);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
dates.push(date);
|
|
332
|
+
}
|
|
333
|
+
} catch {
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
268
337
|
}
|
|
269
338
|
if (dates.length === 0) {
|
|
270
339
|
log("auto: no missing checkpoints in the window");
|
|
@@ -275,8 +344,9 @@ async function runDistillAuto(memoryRoot, days = 7, runner) {
|
|
|
275
344
|
let ok = true;
|
|
276
345
|
let deferred = false;
|
|
277
346
|
let failures = 0;
|
|
347
|
+
let hasPermanentFailure = false;
|
|
278
348
|
for (const date of dates) {
|
|
279
|
-
const result = await (runner ?? runDistillWorkerMain)(memoryRoot, date, true);
|
|
349
|
+
const result = await (runner ?? runDistillWorkerMain)(memoryRoot, date, true, sessionsDir);
|
|
280
350
|
if (!result.ok && result.busy) {
|
|
281
351
|
lines.push(`${date}: busy \u2014 another distillation worker is running; next schedule retries`);
|
|
282
352
|
deferred = true;
|
|
@@ -286,17 +356,29 @@ async function runDistillAuto(memoryRoot, days = 7, runner) {
|
|
|
286
356
|
if (!result.ok) {
|
|
287
357
|
ok = false;
|
|
288
358
|
failures += 1;
|
|
289
|
-
|
|
359
|
+
const isRetryable = result.retryable ?? (result.error !== void 0 && isTransientDistillError(result.error));
|
|
360
|
+
if (!isRetryable) hasPermanentFailure = true;
|
|
361
|
+
log(`auto: ${date} failed (${isRetryable ? "transient/retryable" : "permanent"}); continuing the remaining dates`);
|
|
290
362
|
}
|
|
291
363
|
}
|
|
292
|
-
if (failures > 0)
|
|
293
|
-
|
|
294
|
-
|
|
364
|
+
if (failures > 0) {
|
|
365
|
+
lines.push(
|
|
366
|
+
hasPermanentFailure ? `${failures} date(s) failed (includes permanent config/storage failure; inspect log)` : `${failures} date(s) failed (transient/retryable; next run retries them)`
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
const succeeded = failures === 0;
|
|
370
|
+
const retryable = failures > 0 && !hasPermanentFailure;
|
|
371
|
+
if (!process.env.NODE_TEST_CONTEXT) {
|
|
372
|
+
const code = distillExitCode({ ok: succeeded, retryable });
|
|
373
|
+
setTimeout(() => process.exit(code), 50).unref?.();
|
|
374
|
+
}
|
|
375
|
+
return { ok: succeeded, ...retryable ? { retryable: true } : {}, lines };
|
|
295
376
|
}
|
|
296
377
|
|
|
297
378
|
export {
|
|
298
379
|
distillWorkerLogPath,
|
|
299
380
|
readDistillWorkerLog,
|
|
381
|
+
distillExitCode,
|
|
300
382
|
spawnDistillWorker,
|
|
301
383
|
spawnDistillAutoWorker,
|
|
302
384
|
runDistillWorkerMain,
|