@cydm/pie 3.0.0 → 4.0.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 +8 -4
- package/dist/builtin/extensions/cron/index.js +130 -21
- package/dist/builtin/extensions/im-forward/README.md +20 -5
- package/dist/builtin/extensions/im-forward/index.js +415 -142
- package/dist/builtin/extensions/memory/index.js +71 -20
- package/dist/builtin/extensions/pie-ipc/README.md +2 -2
- package/dist/builtin/extensions/pie-ipc/index.js +269 -30
- package/dist/builtin/extensions/pie-proc/README.md +93 -0
- package/dist/builtin/extensions/pie-proc/index.js +630 -0
- package/dist/builtin/extensions/pie-proc/package.json +11 -0
- 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/builtin/skills/tui-use/tui-use-daemon.cjs +49 -0
- package/dist/chunks/{chunk-7FEPQHYX.js → chunk-FDLLNPIE.js} +143 -53
- package/dist/chunks/{chunk-3BC5KGDQ.js → chunk-JQRZLVPY.js} +12 -1
- package/dist/chunks/{chunk-GH4VW2OT.js → chunk-NCP264ZE.js} +8 -2
- package/dist/chunks/{chunk-YRR6C43W.js → chunk-QX6WS73C.js} +1 -1
- package/dist/chunks/{chunk-OEQYEYB3.js → chunk-TDKNKNPL.js} +5 -5
- package/dist/chunks/{chunk-BUDXV3TR.js → chunk-UOZHQ73X.js} +3 -3
- package/dist/chunks/{chunk-3FRKOFSP.js → chunk-WK4N5HT5.js} +32 -22
- package/dist/chunks/chunk-X6LBWHK3.js +37 -0
- package/dist/chunks/concierge-cli-PIOGXKDR.js +939 -0
- package/dist/chunks/{model-registry-LI5THXV4.js → model-registry-YA6U366L.js} +2 -2
- package/dist/chunks/{src-AE3OCAE6.js → src-AB7PLORG.js} +6 -4
- package/dist/chunks/{src-YG5M2H44.js → src-ODLT57PQ.js} +2 -2
- package/dist/chunks/{src-66XSMIAM.js → src-XSLD2IQ2.js} +1 -1
- package/dist/chunks/{src-RVTDUSPJ.js → src-ZZZO4HSR.js} +3 -3
- package/dist/chunks/{test-stream-JBWXKOQA.js → test-stream-GIUD5JWS.js} +1 -1
- package/dist/cli.js +962 -174
- package/package.json +105 -105
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
executeManageTodoList,
|
|
9
9
|
executionStateToTodos,
|
|
10
10
|
restoreExecutionState
|
|
11
|
-
} from "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
13
|
-
import "../../../chunks/chunk-
|
|
14
|
-
import "../../../chunks/chunk-
|
|
11
|
+
} from "../../../chunks/chunk-FDLLNPIE.js";
|
|
12
|
+
import "../../../chunks/chunk-WK4N5HT5.js";
|
|
13
|
+
import "../../../chunks/chunk-NCP264ZE.js";
|
|
14
|
+
import "../../../chunks/chunk-JQRZLVPY.js";
|
|
15
15
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
16
16
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
17
17
|
|
|
@@ -7071,6 +7071,51 @@ function resolveExecutable(file, cwd = process.cwd(), env = process.env) {
|
|
|
7071
7071
|
}
|
|
7072
7072
|
|
|
7073
7073
|
// vendor/tui-use/src/session.ts
|
|
7074
|
+
var import_node_child_process = require("node:child_process");
|
|
7075
|
+
async function listDescendants(rootPid) {
|
|
7076
|
+
if (process.platform === "win32") return [];
|
|
7077
|
+
const out = [];
|
|
7078
|
+
const frontier = [rootPid];
|
|
7079
|
+
const seen = /* @__PURE__ */ new Set([rootPid]);
|
|
7080
|
+
while (frontier.length > 0) {
|
|
7081
|
+
const parent = frontier.shift();
|
|
7082
|
+
const children = await new Promise((resolve) => {
|
|
7083
|
+
(0, import_node_child_process.execFile)("pgrep", ["-P", String(parent)], { timeout: 2e3 }, (error, stdout) => {
|
|
7084
|
+
resolve(error ? [] : stdout.split("\n").map((l) => parseInt(l, 10)).filter((n) => Number.isInteger(n) && n > 0));
|
|
7085
|
+
});
|
|
7086
|
+
});
|
|
7087
|
+
for (const child of children) {
|
|
7088
|
+
if (!seen.has(child)) {
|
|
7089
|
+
seen.add(child);
|
|
7090
|
+
out.push(child);
|
|
7091
|
+
frontier.push(child);
|
|
7092
|
+
}
|
|
7093
|
+
}
|
|
7094
|
+
}
|
|
7095
|
+
return out;
|
|
7096
|
+
}
|
|
7097
|
+
async function sweepDescendants(pids) {
|
|
7098
|
+
const alive = (pid) => {
|
|
7099
|
+
try {
|
|
7100
|
+
process.kill(pid, 0);
|
|
7101
|
+
return true;
|
|
7102
|
+
} catch {
|
|
7103
|
+
return false;
|
|
7104
|
+
}
|
|
7105
|
+
};
|
|
7106
|
+
for (const pid of pids) {
|
|
7107
|
+
if (alive(pid)) {
|
|
7108
|
+
try {
|
|
7109
|
+
process.kill(pid, "SIGKILL");
|
|
7110
|
+
} catch {
|
|
7111
|
+
}
|
|
7112
|
+
}
|
|
7113
|
+
}
|
|
7114
|
+
const deadline = Date.now() + 2e3;
|
|
7115
|
+
while (Date.now() < deadline && pids.some(alive)) {
|
|
7116
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
7117
|
+
}
|
|
7118
|
+
}
|
|
7074
7119
|
function getCellStyle(cell) {
|
|
7075
7120
|
return {
|
|
7076
7121
|
fg: cell.getFgColor(),
|
|
@@ -7475,6 +7520,7 @@ Supported keys: ${supported}`
|
|
|
7475
7520
|
}
|
|
7476
7521
|
async killProcess() {
|
|
7477
7522
|
if (this._status === "running") {
|
|
7523
|
+
const descendants = await listDescendants(this.ptyProcess.pid);
|
|
7478
7524
|
this.ptyProcess.kill();
|
|
7479
7525
|
let deadline = Date.now() + 1e3;
|
|
7480
7526
|
while (this._status === "running" && Date.now() < deadline) {
|
|
@@ -7493,6 +7539,9 @@ Supported keys: ${supported}`
|
|
|
7493
7539
|
if (this._status === "running") {
|
|
7494
7540
|
throw new Error(`Session ${this.id} did not exit after kill.`);
|
|
7495
7541
|
}
|
|
7542
|
+
if (process.platform !== "win32" && descendants.length > 0) {
|
|
7543
|
+
await sweepDescendants(descendants);
|
|
7544
|
+
}
|
|
7496
7545
|
}
|
|
7497
7546
|
}
|
|
7498
7547
|
dispose() {
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
parseEntryIdSeq,
|
|
14
14
|
readAncestryPage,
|
|
15
15
|
requestInteraction
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WK4N5HT5.js";
|
|
17
17
|
import {
|
|
18
18
|
Agent,
|
|
19
19
|
getToolCallerIdentity
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-NCP264ZE.js";
|
|
21
21
|
import {
|
|
22
22
|
AssistantMessageEventStream,
|
|
23
23
|
completeSimple,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
getFileSystem,
|
|
26
26
|
hashText,
|
|
27
27
|
streamSimple
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-JQRZLVPY.js";
|
|
29
29
|
import {
|
|
30
30
|
Type
|
|
31
31
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -5627,6 +5627,7 @@ function createFileObservationState(options = {}) {
|
|
|
5627
5627
|
const maxFiles = Math.max(1, Math.floor(options.maxFiles ?? 100));
|
|
5628
5628
|
const maxRangesPerFile = Math.max(0, Math.floor(options.maxRangesPerFile ?? 8));
|
|
5629
5629
|
let generation = 0;
|
|
5630
|
+
let lastClear;
|
|
5630
5631
|
function touchFile(absolutePath, observed) {
|
|
5631
5632
|
files.delete(absolutePath);
|
|
5632
5633
|
files.set(absolutePath, observed);
|
|
@@ -5755,9 +5756,13 @@ function createFileObservationState(options = {}) {
|
|
|
5755
5756
|
getGeneration() {
|
|
5756
5757
|
return generation;
|
|
5757
5758
|
},
|
|
5758
|
-
clear() {
|
|
5759
|
+
clear(reason) {
|
|
5759
5760
|
files.clear();
|
|
5760
5761
|
generation++;
|
|
5762
|
+
lastClear = reason ? { reason, timestamp: Date.now() } : void 0;
|
|
5763
|
+
},
|
|
5764
|
+
getLastClear() {
|
|
5765
|
+
return lastClear;
|
|
5761
5766
|
}
|
|
5762
5767
|
};
|
|
5763
5768
|
}
|
|
@@ -7736,9 +7741,11 @@ function createEditTool(cwd, options) {
|
|
|
7736
7741
|
const summary = fileObservationState.describeObservation(absolutePath);
|
|
7737
7742
|
const knownByWrite = fileObservationState.getCompleteTextSnapshot(absolutePath) !== void 0;
|
|
7738
7743
|
if ((!summary || summary.readCount === 0) && !knownByWrite) {
|
|
7744
|
+
const lastClear = fileObservationState.getLastClear?.();
|
|
7745
|
+
const resetNote = lastClear ? ` Note: the session's read ledger was reset by ${lastClear.reason} at ${new Date(lastClear.timestamp).toISOString()} \u2014 if you read this file before that reset, its content is no longer in your context and must be re-read.` : "";
|
|
7739
7746
|
if (signal) signal.removeEventListener("abort", onAbort);
|
|
7740
7747
|
resolve4(createEditErrorResult({
|
|
7741
|
-
message: `edit_file blocked: ${path8} has not been read in this session
|
|
7748
|
+
message: `edit_file blocked: ${path8} has not been read in this session.${resetNote}`,
|
|
7742
7749
|
matchKind: "none",
|
|
7743
7750
|
errorReason: "old_text_not_found",
|
|
7744
7751
|
oldTextOccurrences: 0,
|
|
@@ -13805,7 +13812,8 @@ var DEFAULT_MEMORY_INJECTION_BUDGET = {
|
|
|
13805
13812
|
memory: 600,
|
|
13806
13813
|
threads: 300,
|
|
13807
13814
|
project: 600,
|
|
13808
|
-
recentDigest: 300
|
|
13815
|
+
recentDigest: 300,
|
|
13816
|
+
soul: 200
|
|
13809
13817
|
};
|
|
13810
13818
|
var DEFAULT_MEMORY_DISTILL_LIMITS = {
|
|
13811
13819
|
maxPatchOps: 5,
|
|
@@ -13818,7 +13826,8 @@ var DEFAULT_MEMORY_DISTILL_LIMITS = {
|
|
|
13818
13826
|
|
|
13819
13827
|
// ../../packages/shared-headless-capabilities/src/memory/redact.ts
|
|
13820
13828
|
var REDACTED = "[REDACTED]";
|
|
13821
|
-
var SECRET_KEY_NAMES = "(?:api[_-]?key|apikey|secret|token|password|passwd|pwd|access[_-]?token|refresh[_-]?token|id[_-]?token|auth[_-]?token|authorization|credential|client[_-]?secret|private[_-]?key|aws[_-]?secret[_-]?access[_-]?key|secret[_-]?access[_-]?key)";
|
|
13829
|
+
var SECRET_KEY_NAMES = "(?:api[_-]?key|apikey|npm[_-]?token|node[_-]?auth[_-]?token|gh[_-]?token|git[_-]?token|docker[_-]?token|vault[_-]?token|jwt[_-]?secret|session[_-]?secret|secret[_-]?key|client[_-]?key[_-]?data|client[_-]?certificate[_-]?data|secret|token|password|passwd|pwd|access[_-]?token|refresh[_-]?token|id[_-]?token|auth[_-]?token|authorization|credential|client[_-]?secret|private[_-]?key|aws[_-]?secret[_-]?access[_-]?key|secret[_-]?access[_-]?key)";
|
|
13830
|
+
var KEY_ANCHOR = "(?:^|[^A-Za-z0-9])";
|
|
13822
13831
|
var PATTERNS = [
|
|
13823
13832
|
// PEM blocks, including truncated/encrypted ones: mask from BEGIN to the
|
|
13824
13833
|
// matching END or, when the block is cut off, to the end of input.
|
|
@@ -13865,7 +13874,7 @@ function mask(value) {
|
|
|
13865
13874
|
}
|
|
13866
13875
|
function redactQuotedAssignments(text, counts) {
|
|
13867
13876
|
const opener = new RegExp(
|
|
13868
|
-
`("${SECRET_KEY_NAMES}"|'${SECRET_KEY_NAMES}'
|
|
13877
|
+
`(${KEY_ANCHOR}(?:"${SECRET_KEY_NAMES}"|'${SECRET_KEY_NAMES}'|${SECRET_KEY_NAMES}))(\\s*[:=]\\s*)(["'])`,
|
|
13869
13878
|
"gi"
|
|
13870
13879
|
);
|
|
13871
13880
|
let result = "";
|
|
@@ -13912,25 +13921,34 @@ function redactQuotedAssignments(text, counts) {
|
|
|
13912
13921
|
var SCHEME_WORDS = "bearer|basic|digest|negotiate|ntlm|hawk|oauth|token|apikey";
|
|
13913
13922
|
function redactUnquotedAssignments(text, counts) {
|
|
13914
13923
|
const re = new RegExp(
|
|
13915
|
-
|
|
13924
|
+
`(${KEY_ANCHOR}(?:"${SECRET_KEY_NAMES}"|'${SECRET_KEY_NAMES}'|${SECRET_KEY_NAMES}))(\\s*[=:]\\s*)("[^"]*"|'[^']*'|[^\\s]+)`,
|
|
13916
13925
|
"gi"
|
|
13917
13926
|
);
|
|
13918
13927
|
return text.replace(re, (...groups) => {
|
|
13919
|
-
const
|
|
13928
|
+
const full = String(groups[0]);
|
|
13929
|
+
const keyForm = String(groups[1]);
|
|
13930
|
+
const separator = String(groups[2]);
|
|
13920
13931
|
const value = String(groups[3] ?? "");
|
|
13921
|
-
if (value.startsWith('"') || value.startsWith("'"))
|
|
13922
|
-
|
|
13932
|
+
if (value.startsWith('"') && value.endsWith('"') && value.length > 1 || value.startsWith("'") && value.endsWith("'") && value.length > 1) {
|
|
13933
|
+
return full;
|
|
13934
|
+
}
|
|
13935
|
+
const key = keyForm.toLowerCase();
|
|
13936
|
+
const isAuthorizationKey = /(?:^|[^\\w-])(?:"|')?(proxy-)?authorization(?:"|')?$/i.test(key);
|
|
13923
13937
|
if (isAuthorizationKey && new RegExp(`^${SCHEME_WORDS}$`, "i").test(value)) {
|
|
13924
|
-
return
|
|
13938
|
+
return full;
|
|
13925
13939
|
}
|
|
13926
13940
|
counts["key-assign"] = (counts["key-assign"] ?? 0) + 1;
|
|
13927
|
-
|
|
13941
|
+
if (/["']$/.test(value) && !/^["']/.test(value)) {
|
|
13942
|
+
return `${keyForm}${separator}${REDACTED}${value.slice(-1)}`;
|
|
13943
|
+
}
|
|
13944
|
+
return `${keyForm}${separator}${REDACTED}`;
|
|
13928
13945
|
});
|
|
13929
13946
|
}
|
|
13930
13947
|
function redactText(input) {
|
|
13931
13948
|
const counts = {};
|
|
13932
13949
|
if (!input) return { text: input, counts };
|
|
13933
|
-
let text =
|
|
13950
|
+
let text = redactBlockScalars(input, counts);
|
|
13951
|
+
text = redactQuotedAssignments(text, counts);
|
|
13934
13952
|
text = redactUnquotedAssignments(text, counts);
|
|
13935
13953
|
for (const { name, regex } of PATTERNS) {
|
|
13936
13954
|
const re = new RegExp(regex.source, regex.flags);
|
|
@@ -13957,6 +13975,45 @@ function redactText(input) {
|
|
|
13957
13975
|
function looksLikeSecretPresent(text) {
|
|
13958
13976
|
return redactText(text).text !== text;
|
|
13959
13977
|
}
|
|
13978
|
+
function redactBlockScalars(text, counts) {
|
|
13979
|
+
const re = new RegExp(
|
|
13980
|
+
`(${KEY_ANCHOR}(?:"${SECRET_KEY_NAMES}"|'${SECRET_KEY_NAMES}'|${SECRET_KEY_NAMES}))(\\s*[:=]\\s*)([|>](?:(?:[1-9][+-]?)|(?:[+-][1-9]?))?[ \\t]*(?:#.*)?)(?=\\r?
|
|
13981
|
+
|$)`,
|
|
13982
|
+
"gi"
|
|
13983
|
+
);
|
|
13984
|
+
let result = "";
|
|
13985
|
+
let cursor = 0;
|
|
13986
|
+
let match2;
|
|
13987
|
+
while ((match2 = re.exec(text)) !== null) {
|
|
13988
|
+
if (match2.index < cursor) continue;
|
|
13989
|
+
const valueStart = match2.index + match2[0].length;
|
|
13990
|
+
const keyLineStart = text.lastIndexOf("\n", match2.index) + 1;
|
|
13991
|
+
const keyIndent = /^(?:[ \t]*)/.exec(text.slice(keyLineStart))[0].length;
|
|
13992
|
+
let lastConsumed = valueStart;
|
|
13993
|
+
let contentLines = 0;
|
|
13994
|
+
const lines = text.slice(valueStart).split("\n");
|
|
13995
|
+
for (const line of lines) {
|
|
13996
|
+
if (line.trim() === "") {
|
|
13997
|
+
lastConsumed += line.length + 1;
|
|
13998
|
+
continue;
|
|
13999
|
+
}
|
|
14000
|
+
const indent = line.length - line.replace(/^[ \t]+/, "").length;
|
|
14001
|
+
if (indent > keyIndent) {
|
|
14002
|
+
lastConsumed += line.length + 1;
|
|
14003
|
+
contentLines++;
|
|
14004
|
+
continue;
|
|
14005
|
+
}
|
|
14006
|
+
lastConsumed -= 1;
|
|
14007
|
+
break;
|
|
14008
|
+
}
|
|
14009
|
+
if (contentLines === 0) continue;
|
|
14010
|
+
counts["key-block"] = (counts["key-block"] ?? 0) + 1;
|
|
14011
|
+
result += text.slice(cursor, valueStart) + REDACTED;
|
|
14012
|
+
cursor = lastConsumed;
|
|
14013
|
+
}
|
|
14014
|
+
result += text.slice(cursor);
|
|
14015
|
+
return result;
|
|
14016
|
+
}
|
|
13960
14017
|
|
|
13961
14018
|
// ../../packages/shared-headless-capabilities/src/memory/store.ts
|
|
13962
14019
|
import * as fs2 from "node:fs";
|
|
@@ -14310,6 +14367,18 @@ var MemoryStore = class _MemoryStore {
|
|
|
14310
14367
|
return void 0;
|
|
14311
14368
|
}
|
|
14312
14369
|
}
|
|
14370
|
+
/** SOUL.md static persona (v2 stage E): human-maintained, NEVER
|
|
14371
|
+
* auto-edited by pie. Absent file = no persona injection (silent skip —
|
|
14372
|
+
* a persona is never mandatory). Read is size-capped defensively. */
|
|
14373
|
+
readSoul(maxChars = 4e3) {
|
|
14374
|
+
try {
|
|
14375
|
+
const text = fs2.readFileSync(path4.join(this.root, "SOUL.md"), "utf8");
|
|
14376
|
+
const trimmed = text.trim();
|
|
14377
|
+
return trimmed.length > 0 ? trimmed.slice(0, maxChars) : void 0;
|
|
14378
|
+
} catch {
|
|
14379
|
+
return void 0;
|
|
14380
|
+
}
|
|
14381
|
+
}
|
|
14313
14382
|
listJournalDates() {
|
|
14314
14383
|
try {
|
|
14315
14384
|
return fs2.readdirSync(path4.join(this.root, JOURNAL_DIR)).filter((name) => /^\d{4}-\d{2}-\d{2}\.md$/.test(name)).map((name) => name.slice(0, -3)).sort();
|
|
@@ -14357,7 +14426,8 @@ var MemoryStore = class _MemoryStore {
|
|
|
14357
14426
|
// ------------------------------------------------------------------
|
|
14358
14427
|
// Snapshots & rollback
|
|
14359
14428
|
// ------------------------------------------------------------------
|
|
14360
|
-
/** Snapshot
|
|
14429
|
+
/** Snapshot entries, state, and global surfaces before a patch (not the archive).
|
|
14430
|
+
* Project surfaces are regenerated on rollback. Returns the snapshot id. */
|
|
14361
14431
|
snapshot(label) {
|
|
14362
14432
|
const id = `snap-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}-${label.replace(/[^a-z0-9-]/gi, "")}`;
|
|
14363
14433
|
const dir = path4.join(this.root, SNAPSHOTS_DIR, id);
|
|
@@ -14463,6 +14533,10 @@ var MemoryStore = class _MemoryStore {
|
|
|
14463
14533
|
// ------------------------------------------------------------------
|
|
14464
14534
|
/** Hard cap on one transaction's ops (docs/memory.md: bounded patches). */
|
|
14465
14535
|
static MAX_PATCH_OPS = 8;
|
|
14536
|
+
/** Retention window backing the skipConflicts retire re-verification:
|
|
14537
|
+
* mirrors limits.retireUnusedAfterDays (default 90d; see
|
|
14538
|
+
* buildRetentionOps) without importing the limits type here. */
|
|
14539
|
+
static RETIRE_UNUSED_CUTOFF_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
14466
14540
|
/**
|
|
14467
14541
|
* Validate + apply a content transaction. Every persisted text field is
|
|
14468
14542
|
* redacted here — the store is the last-chance boundary, so model output
|
|
@@ -14484,6 +14558,11 @@ var MemoryStore = class _MemoryStore {
|
|
|
14484
14558
|
const entry = current.find((candidate) => candidate.id === op.id);
|
|
14485
14559
|
if (!entry) continue;
|
|
14486
14560
|
if (op.expectText !== void 0 && entry.text !== op.expectText) continue;
|
|
14561
|
+
if (op.op === "retire" && op.policy) {
|
|
14562
|
+
const cutoff = op.decidedCutoff ?? Date.now() - _MemoryStore.RETIRE_UNUSED_CUTOFF_MS;
|
|
14563
|
+
const lastUse = Math.max(entry.lastAccessed, entry.lastConsumedAt ?? 0);
|
|
14564
|
+
if (entry.usageCount !== 0 || lastUse >= cutoff) continue;
|
|
14565
|
+
}
|
|
14487
14566
|
}
|
|
14488
14567
|
if (op.op === "add" && current.some((entry) => entry.id === op.entry.id)) continue;
|
|
14489
14568
|
effective.push(op);
|
|
@@ -14526,7 +14605,10 @@ var MemoryStore = class _MemoryStore {
|
|
|
14526
14605
|
entry.text = op.text;
|
|
14527
14606
|
for (const evidence of op.evidence) {
|
|
14528
14607
|
const quote = redactText(evidence.quote).text;
|
|
14529
|
-
if (quote)
|
|
14608
|
+
if (!quote) continue;
|
|
14609
|
+
const key = `${evidence.sessionId}\0${quote.slice(0, 240)}`;
|
|
14610
|
+
if (entry.evidence.some((existing) => `${existing.sessionId}\0${existing.quote.slice(0, 240)}` === key)) continue;
|
|
14611
|
+
entry.evidence.push({ sessionId: evidence.sessionId, quote: quote.slice(0, 240) });
|
|
14530
14612
|
}
|
|
14531
14613
|
}
|
|
14532
14614
|
} else {
|
|
@@ -14544,7 +14626,7 @@ var MemoryStore = class _MemoryStore {
|
|
|
14544
14626
|
fs2.mkdirSync(path4.dirname(archivePath), { recursive: true });
|
|
14545
14627
|
fs2.appendFileSync(archivePath, archived.map((entry) => JSON.stringify(entry)).join("\n") + "\n");
|
|
14546
14628
|
}
|
|
14547
|
-
const projectKeys = new Set(entries.filter((entry) => entry.projectKey).map((entry) => entry.projectKey));
|
|
14629
|
+
const projectKeys = /* @__PURE__ */ new Set([...this.listProjectKeys(), ...entries.filter((entry) => entry.projectKey).map((entry) => entry.projectKey)]);
|
|
14548
14630
|
this.renderSurfaces([...projectKeys]);
|
|
14549
14631
|
return { applied: ops.length, snapshotId };
|
|
14550
14632
|
}
|
|
@@ -14557,20 +14639,19 @@ var MemoryStore = class _MemoryStore {
|
|
|
14557
14639
|
* already distilled.
|
|
14558
14640
|
*/
|
|
14559
14641
|
applyPatch(patch, options = {}) {
|
|
14560
|
-
if (patch.ops.length === 0) {
|
|
14561
|
-
return this.transaction(() => {
|
|
14562
|
-
const state = this.loadState();
|
|
14563
|
-
const prior = state.runs[patch.date];
|
|
14564
|
-
state.runs[patch.date] = { ranAt: Date.now(), ops: prior?.ops ?? 0, gated: Boolean(options.gated) };
|
|
14565
|
-
this.writeState(state);
|
|
14566
|
-
return { applied: 0, snapshotId: "" };
|
|
14567
|
-
});
|
|
14568
|
-
}
|
|
14569
14642
|
return this.transaction(() => {
|
|
14570
|
-
const applied = this.applyEntryPatchLocked(patch.ops, patch.date, { skipConflicts: true });
|
|
14643
|
+
const applied = patch.ops.length ? this.applyEntryPatchLocked(patch.ops, patch.date, { skipConflicts: true }) : { applied: 0, snapshotId: "" };
|
|
14644
|
+
if (applied.applied === 0) {
|
|
14645
|
+
const keys = new Set(this.listProjectKeys());
|
|
14646
|
+
for (const entry of this.loadEntries()) if (entry.projectKey) keys.add(entry.projectKey);
|
|
14647
|
+
for (const op of patch.ops) {
|
|
14648
|
+
if (op.op === "add" && op.entry.projectKey) keys.add(op.entry.projectKey);
|
|
14649
|
+
}
|
|
14650
|
+
this.renderSurfaces([...keys]);
|
|
14651
|
+
}
|
|
14571
14652
|
const state = this.loadState();
|
|
14572
14653
|
const prior = state.runs[patch.date];
|
|
14573
|
-
state.runs[patch.date] = { ranAt: Date.now(), ops: (prior?.ops ?? 0) +
|
|
14654
|
+
state.runs[patch.date] = { ranAt: Date.now(), ops: (prior?.ops ?? 0) + applied.applied, gated: Boolean(options.gated) };
|
|
14574
14655
|
this.writeState(state);
|
|
14575
14656
|
return applied;
|
|
14576
14657
|
});
|
|
@@ -15010,7 +15091,7 @@ function synthesizePatch(input) {
|
|
|
15010
15091
|
}
|
|
15011
15092
|
function buildRetentionOps(entries, limits = DEFAULT_MEMORY_DISTILL_LIMITS, now = Date.now(), refreshedIds = /* @__PURE__ */ new Set()) {
|
|
15012
15093
|
const cutoff = now - limits.retireUnusedAfterDays * 24 * 60 * 60 * 1e3;
|
|
15013
|
-
return entries.filter((entry) => !refreshedIds.has(entry.id) && entry.usageCount === 0 && entry.lastAccessed < cutoff).map((entry) => ({ op: "retire", id: entry.id, reason: `unused since ${new Date(entry.lastAccessed).toISOString()}`, expectText: entry.text }));
|
|
15094
|
+
return entries.filter((entry) => !refreshedIds.has(entry.id) && entry.usageCount === 0 && entry.lastAccessed < cutoff).map((entry) => ({ op: "retire", id: entry.id, reason: `unused since ${new Date(entry.lastAccessed).toISOString()}`, expectText: entry.text, policy: true, decidedCutoff: cutoff }));
|
|
15014
15095
|
}
|
|
15015
15096
|
var SYNTHESIZE_SYSTEM = "You are a memory consolidation engine. You write concise, factual, source-grounded prose in the requested language.";
|
|
15016
15097
|
async function writeJournalNarrative(input) {
|
|
@@ -15258,10 +15339,13 @@ function isGenericZhWindow(window) {
|
|
|
15258
15339
|
return false;
|
|
15259
15340
|
}
|
|
15260
15341
|
function entryConsumedIn(entry, output) {
|
|
15342
|
+
return materialConsumedIn(entry.text, entry.evidence.map((ev) => ev.quote), output);
|
|
15343
|
+
}
|
|
15344
|
+
function materialConsumedIn(text, quotes, output) {
|
|
15261
15345
|
if (!output) return false;
|
|
15262
15346
|
const anchors = [];
|
|
15263
|
-
const collect = (
|
|
15264
|
-
for (const run of
|
|
15347
|
+
const collect = (source) => {
|
|
15348
|
+
for (const run of source.matchAll(/[\u4e00-\u9fff]+/g)) {
|
|
15265
15349
|
for (let size = 4; size <= 6 && size <= run[0].length; size += 1) {
|
|
15266
15350
|
for (let i = 0; i + size <= run[0].length; i += 1) {
|
|
15267
15351
|
const window = run[0].slice(i, i + size);
|
|
@@ -15269,15 +15353,15 @@ function entryConsumedIn(entry, output) {
|
|
|
15269
15353
|
}
|
|
15270
15354
|
}
|
|
15271
15355
|
}
|
|
15272
|
-
const words =
|
|
15356
|
+
const words = source.split(/[^A-Za-z0-9._-]+/).filter(Boolean);
|
|
15273
15357
|
for (let i = 0; i + 1 < words.length; i += 1) {
|
|
15274
15358
|
const pair = `${words[i]} ${words[i + 1]}`;
|
|
15275
15359
|
if (pair.replace(/ /g, "").length < 10) continue;
|
|
15276
15360
|
if (!GENERIC_LATIN_PAIRS.has(pair.toLowerCase())) anchors.push(pair);
|
|
15277
15361
|
}
|
|
15278
15362
|
};
|
|
15279
|
-
collect(
|
|
15280
|
-
for (const
|
|
15363
|
+
collect(text);
|
|
15364
|
+
for (const quote of quotes) collect(quote);
|
|
15281
15365
|
const normalized = [...new Set(anchors.map((a) => a.toLowerCase()))];
|
|
15282
15366
|
const WIDTH_FOLD = { "\uFF0C": ",", "\u3002": ".", "\uFF1B": ";", "\u3001": ",", "\uFF01": "!", "\uFF1F": "?", "\uFF08": "(", "\uFF09": ")", "\u3010": "[", "\u3011": "]", "\uFF1A": ":" };
|
|
15283
15367
|
const folded = output.toLowerCase().replace(/[,。;、!?()【】:]/g, (ch) => WIDTH_FOLD[ch] ?? ch);
|
|
@@ -15508,28 +15592,33 @@ ${redactText(narrative).text.trim()}
|
|
|
15508
15592
|
deps.memoryStore.writeJournal(date, redactText(digest).text);
|
|
15509
15593
|
journalWritten = true;
|
|
15510
15594
|
}
|
|
15511
|
-
if (deps.memoryStore.hasRun(date)) {
|
|
15512
|
-
return { date, status: "skipped-ran", sessions: sessions.length, patchOps: 0, journalWritten };
|
|
15513
|
-
}
|
|
15514
|
-
if (deps.gated) {
|
|
15515
|
-
if (ops.length === 0) {
|
|
15516
|
-
recordCheckpoint(deps.memoryStore, date, 0, false, now());
|
|
15517
|
-
return { date, status: "applied", sessions: sessions.length, patchOps: 0, journalWritten };
|
|
15518
|
-
}
|
|
15519
|
-
queueGatedPatch(deps.memoryStore, { date, ops });
|
|
15520
|
-
return { date, status: "queued", sessions: sessions.length, patchOps: ops.length, journalWritten };
|
|
15521
|
-
}
|
|
15522
15595
|
try {
|
|
15523
|
-
|
|
15524
|
-
deps.memoryStore.
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15596
|
+
const outcome = deps.memoryStore.transaction(() => {
|
|
15597
|
+
if (deps.memoryStore.hasRun(date)) {
|
|
15598
|
+
return { date, status: "skipped-ran", patchOps: 0 };
|
|
15599
|
+
}
|
|
15600
|
+
if (deps.gated) {
|
|
15601
|
+
if (ops.length === 0) {
|
|
15602
|
+
recordCheckpoint(deps.memoryStore, date, 0, false, now());
|
|
15603
|
+
return { date, status: "applied", patchOps: 0 };
|
|
15604
|
+
}
|
|
15605
|
+
queueGatedPatch(deps.memoryStore, { date, ops });
|
|
15606
|
+
return { date, status: "queued", patchOps: ops.length };
|
|
15607
|
+
}
|
|
15608
|
+
if (ops.length === 0) {
|
|
15609
|
+
recordCheckpoint(deps.memoryStore, date, 0, false, now());
|
|
15610
|
+
return { date, status: "applied", patchOps: 0 };
|
|
15611
|
+
}
|
|
15612
|
+
const result = deps.memoryStore.applyPatch({ date, ops });
|
|
15613
|
+
if (result.applied === 0) {
|
|
15614
|
+
return { date, status: "applied", patchOps: 0 };
|
|
15615
|
+
}
|
|
15616
|
+
return { date, status: "applied", patchOps: ops.length };
|
|
15617
|
+
});
|
|
15618
|
+
return { ...outcome, sessions: sessions.length, journalWritten };
|
|
15528
15619
|
} catch (error) {
|
|
15529
15620
|
return failure(date, error, "apply");
|
|
15530
15621
|
}
|
|
15531
|
-
log(`[memory] ${date}: ${ops.length} ops applied across ${sessions.length} sessions`);
|
|
15532
|
-
return { date, status: "applied", sessions: sessions.length, patchOps: ops.length, journalWritten };
|
|
15533
15622
|
}
|
|
15534
15623
|
function recordCheckpoint(store, date, ops, gated, now) {
|
|
15535
15624
|
store.transaction(() => {
|
|
@@ -15805,6 +15894,7 @@ export {
|
|
|
15805
15894
|
recordAccess,
|
|
15806
15895
|
recordInjection,
|
|
15807
15896
|
entryConsumedIn,
|
|
15897
|
+
materialConsumedIn,
|
|
15808
15898
|
recordConsumption,
|
|
15809
15899
|
consumptionSummary,
|
|
15810
15900
|
searchMemory,
|
|
@@ -10887,10 +10887,21 @@ function validateToolArguments(tool, toolCall) {
|
|
|
10887
10887
|
}
|
|
10888
10888
|
const path = firstError.path || "/";
|
|
10889
10889
|
const hint = buildArgumentHint(tool.parameters, firstError.path || "", args);
|
|
10890
|
+
const lengthHint = buildLengthHint(firstError, args, path);
|
|
10890
10891
|
throw new Error(
|
|
10891
|
-
`Invalid arguments for tool "${tool.name}" at ${path}: ${firstError.message}${hint ? `; ${hint}` : ""}`
|
|
10892
|
+
`Invalid arguments for tool "${tool.name}" at ${path}: ${firstError.message}${lengthHint ? ` ${lengthHint}` : ""}${hint ? `; ${hint}` : ""}`
|
|
10892
10893
|
);
|
|
10893
10894
|
}
|
|
10895
|
+
function buildLengthHint(error, args, path) {
|
|
10896
|
+
if (error.type !== ValueErrorType.StringMaxLength && error.type !== ValueErrorType.StringMinLength) return "";
|
|
10897
|
+
const direction = error.type === ValueErrorType.StringMaxLength ? "trim to at most the limit" : "extend to at least the minimum";
|
|
10898
|
+
let value = args;
|
|
10899
|
+
for (const segment of path.split("/").filter(Boolean)) {
|
|
10900
|
+
value = value?.[segment];
|
|
10901
|
+
}
|
|
10902
|
+
if (typeof value !== "string") return "";
|
|
10903
|
+
return `(got length ${value.length} \u2014 ${direction} and retry)`;
|
|
10904
|
+
}
|
|
10894
10905
|
function buildArgumentHint(schema, errorPath, args) {
|
|
10895
10906
|
const parentPath = errorPath.includes("/") ? errorPath.slice(0, errorPath.lastIndexOf("/")) : "";
|
|
10896
10907
|
const node = resolveSchemaNode(schema, parentPath);
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
disposeModelTransports,
|
|
5
5
|
streamSimple,
|
|
6
6
|
validateToolArguments
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-JQRZLVPY.js";
|
|
8
8
|
|
|
9
9
|
// ../../packages/agent-core/src/failure.ts
|
|
10
10
|
function getAgentFailureMetadata(error) {
|
|
@@ -321,6 +321,8 @@ async function executeToolCalls(tools, assistantMessage, signal, stream, getStee
|
|
|
321
321
|
let isError = false;
|
|
322
322
|
let executionArgs = toolCall.arguments;
|
|
323
323
|
let started = false;
|
|
324
|
+
const startedAt = Date.now();
|
|
325
|
+
let completedAt = startedAt;
|
|
324
326
|
const pushToolStart = () => {
|
|
325
327
|
if (started) return;
|
|
326
328
|
started = true;
|
|
@@ -356,6 +358,7 @@ async function executeToolCalls(tools, assistantMessage, signal, stream, getStee
|
|
|
356
358
|
});
|
|
357
359
|
});
|
|
358
360
|
isError = isError || !!result.isError;
|
|
361
|
+
completedAt = Date.now();
|
|
359
362
|
} catch (e) {
|
|
360
363
|
pushToolStart();
|
|
361
364
|
result = {
|
|
@@ -363,6 +366,7 @@ async function executeToolCalls(tools, assistantMessage, signal, stream, getStee
|
|
|
363
366
|
details: {}
|
|
364
367
|
};
|
|
365
368
|
isError = true;
|
|
369
|
+
completedAt = Date.now();
|
|
366
370
|
try {
|
|
367
371
|
await hooks?.onError?.(e instanceof Error ? e : new Error(String(e)), {
|
|
368
372
|
toolName: toolCall.name,
|
|
@@ -393,7 +397,9 @@ async function executeToolCalls(tools, assistantMessage, signal, stream, getStee
|
|
|
393
397
|
content: result.content,
|
|
394
398
|
details: result.details,
|
|
395
399
|
isError,
|
|
396
|
-
|
|
400
|
+
startedAt,
|
|
401
|
+
durationMs: completedAt - startedAt,
|
|
402
|
+
timestamp: completedAt
|
|
397
403
|
};
|
|
398
404
|
results.push(toolResultMessage);
|
|
399
405
|
stream.push({ type: "message_start", message: toolResultMessage });
|
|
@@ -171,11 +171,11 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
171
171
|
let result;
|
|
172
172
|
let ledger;
|
|
173
173
|
try {
|
|
174
|
-
const { ModelRegistry } = await import("./model-registry-
|
|
174
|
+
const { ModelRegistry } = await import("./model-registry-YA6U366L.js");
|
|
175
175
|
const { AuthStorage } = await import("./auth-storage-3EGM3VTK.js");
|
|
176
176
|
const { getSessionsDir } = await import("./config-74AUVDLT.js");
|
|
177
|
-
const { FileSessionStore } = await import("./src-
|
|
178
|
-
const { MemoryStore, runDistillation } = await import("./src-
|
|
177
|
+
const { FileSessionStore } = await import("./src-ZZZO4HSR.js");
|
|
178
|
+
const { MemoryStore, runDistillation } = await import("./src-AB7PLORG.js");
|
|
179
179
|
const store = new MemoryStore(memoryRoot);
|
|
180
180
|
ledger = store;
|
|
181
181
|
const registry = new ModelRegistry(AuthStorage.create());
|
|
@@ -190,7 +190,7 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
|
|
|
190
190
|
if (!resolved.model || !resolved.apiKey) {
|
|
191
191
|
throw new Error(`no complete model/key pair for class ${modelClass}${resolved.fallbackReason ? `: ${resolved.fallbackReason}` : ""}`);
|
|
192
192
|
}
|
|
193
|
-
const { completeSimple } = await import("./src-
|
|
193
|
+
const { completeSimple } = await import("./src-XSLD2IQ2.js");
|
|
194
194
|
const message = await withModelTimeout(
|
|
195
195
|
completeSimple(
|
|
196
196
|
resolved.model,
|
|
@@ -252,7 +252,7 @@ async function runDistillAuto(memoryRoot, days = 7) {
|
|
|
252
252
|
} catch {
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
|
-
const { MemoryStore, todayKey } = await import("./src-
|
|
255
|
+
const { MemoryStore, todayKey } = await import("./src-AB7PLORG.js");
|
|
256
256
|
const store = new MemoryStore(memoryRoot);
|
|
257
257
|
const today = todayKey(Date.now());
|
|
258
258
|
const dates = [];
|
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
createSharedWebSearchTool,
|
|
11
11
|
defaultShellKindForPlatform,
|
|
12
12
|
interpretShellExit
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-FDLLNPIE.js";
|
|
14
14
|
import {
|
|
15
15
|
requestInteraction
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WK4N5HT5.js";
|
|
17
17
|
import {
|
|
18
18
|
EMPTY_ASSISTANT_CONTENT_ERROR,
|
|
19
19
|
OPENAI_COMPAT_PROTOCOL_ERROR_CODE,
|
|
20
20
|
getLogger
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-JQRZLVPY.js";
|
|
22
22
|
import {
|
|
23
23
|
Type
|
|
24
24
|
} from "./chunk-XXGYUYXI.js";
|