@signetai/signet-memory-openclaw 0.157.4 → 0.158.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/index.js +381 -159
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -600,6 +600,8 @@ var require_Alias = __commonJS((exports) => {
|
|
|
600
600
|
});
|
|
601
601
|
}
|
|
602
602
|
resolve(doc, ctx) {
|
|
603
|
+
if (ctx?.maxAliasCount === 0)
|
|
604
|
+
throw new ReferenceError("Alias resolution is disabled");
|
|
603
605
|
let nodes;
|
|
604
606
|
if (ctx?.aliasResolveCache) {
|
|
605
607
|
nodes = ctx.aliasResolveCache;
|
|
@@ -1629,18 +1631,18 @@ var require_merge = __commonJS((exports) => {
|
|
|
1629
1631
|
};
|
|
1630
1632
|
var isMergeKey = (ctx, key) => (merge.identify(key) || identity.isScalar(key) && (!key.type || key.type === Scalar.Scalar.PLAIN) && merge.identify(key.value)) && ctx?.doc.schema.tags.some((tag) => tag.tag === merge.tag && tag.default);
|
|
1631
1633
|
function addMergeToJSMap(ctx, map, value) {
|
|
1632
|
-
|
|
1633
|
-
if (identity.isSeq(
|
|
1634
|
-
for (const it of
|
|
1634
|
+
const source = resolveAliasValue(ctx, value);
|
|
1635
|
+
if (identity.isSeq(source))
|
|
1636
|
+
for (const it of source.items)
|
|
1635
1637
|
mergeValue(ctx, map, it);
|
|
1636
|
-
else if (Array.isArray(
|
|
1637
|
-
for (const it of
|
|
1638
|
+
else if (Array.isArray(source))
|
|
1639
|
+
for (const it of source)
|
|
1638
1640
|
mergeValue(ctx, map, it);
|
|
1639
1641
|
else
|
|
1640
|
-
mergeValue(ctx, map,
|
|
1642
|
+
mergeValue(ctx, map, source);
|
|
1641
1643
|
}
|
|
1642
1644
|
function mergeValue(ctx, map, value) {
|
|
1643
|
-
const source = ctx
|
|
1645
|
+
const source = resolveAliasValue(ctx, value);
|
|
1644
1646
|
if (!identity.isMap(source))
|
|
1645
1647
|
throw new Error("Merge sources must be maps or map aliases");
|
|
1646
1648
|
const srcMap = source.toJSON(null, ctx, Map);
|
|
@@ -1661,6 +1663,9 @@ var require_merge = __commonJS((exports) => {
|
|
|
1661
1663
|
}
|
|
1662
1664
|
return map;
|
|
1663
1665
|
}
|
|
1666
|
+
function resolveAliasValue(ctx, value) {
|
|
1667
|
+
return ctx && identity.isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
|
1668
|
+
}
|
|
1664
1669
|
exports.addMergeToJSMap = addMergeToJSMap;
|
|
1665
1670
|
exports.isMergeKey = isMergeKey;
|
|
1666
1671
|
exports.merge = merge;
|
|
@@ -2214,7 +2219,7 @@ var require_stringifyNumber = __commonJS((exports) => {
|
|
|
2214
2219
|
if (!isFinite(num))
|
|
2215
2220
|
return isNaN(num) ? ".nan" : num < 0 ? "-.inf" : ".inf";
|
|
2216
2221
|
let n = Object.is(value, -0) ? "-0" : JSON.stringify(value);
|
|
2217
|
-
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") &&
|
|
2222
|
+
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^-?\d/.test(n) && !n.includes("e")) {
|
|
2218
2223
|
let i = n.indexOf(".");
|
|
2219
2224
|
if (i < 0) {
|
|
2220
2225
|
i = n.length;
|
|
@@ -4382,7 +4387,7 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4382
4387
|
while (next === " " || next === "\t")
|
|
4383
4388
|
next = source[++i + 1];
|
|
4384
4389
|
} else if (next === "x" || next === "u" || next === "U") {
|
|
4385
|
-
const length =
|
|
4390
|
+
const length = next === "x" ? 2 : next === "u" ? 4 : 8;
|
|
4386
4391
|
res += parseCharCode(source, i + 1, length, onError);
|
|
4387
4392
|
i += length;
|
|
4388
4393
|
} else {
|
|
@@ -4451,12 +4456,13 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4451
4456
|
const cc = source.substr(offset, length);
|
|
4452
4457
|
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
|
4453
4458
|
const code = ok ? parseInt(cc, 16) : NaN;
|
|
4454
|
-
|
|
4459
|
+
try {
|
|
4460
|
+
return String.fromCodePoint(code);
|
|
4461
|
+
} catch {
|
|
4455
4462
|
const raw = source.substr(offset - 2, length + 2);
|
|
4456
4463
|
onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
4457
4464
|
return raw;
|
|
4458
4465
|
}
|
|
4459
|
-
return String.fromCodePoint(code);
|
|
4460
4466
|
}
|
|
4461
4467
|
exports.resolveFlowScalar = resolveFlowScalar;
|
|
4462
4468
|
});
|
|
@@ -4785,8 +4791,10 @@ ${cb}` : comment;
|
|
|
4785
4791
|
}
|
|
4786
4792
|
}
|
|
4787
4793
|
if (afterDoc) {
|
|
4788
|
-
|
|
4789
|
-
|
|
4794
|
+
for (let i = 0;i < this.errors.length; ++i)
|
|
4795
|
+
doc.errors.push(this.errors[i]);
|
|
4796
|
+
for (let i = 0;i < this.warnings.length; ++i)
|
|
4797
|
+
doc.warnings.push(this.warnings[i]);
|
|
4790
4798
|
} else {
|
|
4791
4799
|
doc.errors = this.errors;
|
|
4792
4800
|
doc.warnings = this.warnings;
|
|
@@ -5488,7 +5496,7 @@ var require_lexer = __commonJS((exports) => {
|
|
|
5488
5496
|
const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
|
|
5489
5497
|
this.indentNext = this.indentValue + 1;
|
|
5490
5498
|
this.indentValue += n;
|
|
5491
|
-
return
|
|
5499
|
+
return "block-start";
|
|
5492
5500
|
}
|
|
5493
5501
|
return "doc";
|
|
5494
5502
|
}
|
|
@@ -5795,26 +5803,37 @@ var require_lexer = __commonJS((exports) => {
|
|
|
5795
5803
|
return 0;
|
|
5796
5804
|
}
|
|
5797
5805
|
*pushIndicators() {
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5806
|
+
let n = 0;
|
|
5807
|
+
loop:
|
|
5808
|
+
while (true) {
|
|
5809
|
+
switch (this.charAt(0)) {
|
|
5810
|
+
case "!":
|
|
5811
|
+
n += yield* this.pushTag();
|
|
5812
|
+
n += yield* this.pushSpaces(true);
|
|
5813
|
+
continue loop;
|
|
5814
|
+
case "&":
|
|
5815
|
+
n += yield* this.pushUntil(isNotAnchorChar);
|
|
5816
|
+
n += yield* this.pushSpaces(true);
|
|
5817
|
+
continue loop;
|
|
5818
|
+
case "-":
|
|
5819
|
+
case "?":
|
|
5820
|
+
case ":": {
|
|
5821
|
+
const inFlow = this.flowLevel > 0;
|
|
5822
|
+
const ch1 = this.charAt(1);
|
|
5823
|
+
if (isEmpty(ch1) || inFlow && flowIndicatorChars.has(ch1)) {
|
|
5824
|
+
if (!inFlow)
|
|
5825
|
+
this.indentNext = this.indentValue + 1;
|
|
5826
|
+
else if (this.flowKey)
|
|
5827
|
+
this.flowKey = false;
|
|
5828
|
+
n += yield* this.pushCount(1);
|
|
5829
|
+
n += yield* this.pushSpaces(true);
|
|
5830
|
+
continue loop;
|
|
5831
|
+
}
|
|
5832
|
+
}
|
|
5814
5833
|
}
|
|
5834
|
+
break loop;
|
|
5815
5835
|
}
|
|
5816
|
-
|
|
5817
|
-
return 0;
|
|
5836
|
+
return n;
|
|
5818
5837
|
}
|
|
5819
5838
|
*pushTag() {
|
|
5820
5839
|
if (this.charAt(1) === "<") {
|
|
@@ -5965,6 +5984,13 @@ var require_parser = __commonJS((exports) => {
|
|
|
5965
5984
|
while (prev[++i]?.type === "space") {}
|
|
5966
5985
|
return prev.splice(i, prev.length);
|
|
5967
5986
|
}
|
|
5987
|
+
function arrayPushArray(target, source) {
|
|
5988
|
+
if (source.length < 1e5)
|
|
5989
|
+
Array.prototype.push.apply(target, source);
|
|
5990
|
+
else
|
|
5991
|
+
for (let i = 0;i < source.length; ++i)
|
|
5992
|
+
target.push(source[i]);
|
|
5993
|
+
}
|
|
5968
5994
|
function fixFlowSeqItems(fc) {
|
|
5969
5995
|
if (fc.start.type === "flow-seq-start") {
|
|
5970
5996
|
for (const it of fc.items) {
|
|
@@ -5974,11 +6000,11 @@ var require_parser = __commonJS((exports) => {
|
|
|
5974
6000
|
delete it.key;
|
|
5975
6001
|
if (isFlowToken(it.value)) {
|
|
5976
6002
|
if (it.value.end)
|
|
5977
|
-
|
|
6003
|
+
arrayPushArray(it.value.end, it.sep);
|
|
5978
6004
|
else
|
|
5979
6005
|
it.value.end = it.sep;
|
|
5980
6006
|
} else
|
|
5981
|
-
|
|
6007
|
+
arrayPushArray(it.start, it.sep);
|
|
5982
6008
|
delete it.sep;
|
|
5983
6009
|
}
|
|
5984
6010
|
}
|
|
@@ -6318,7 +6344,7 @@ var require_parser = __commonJS((exports) => {
|
|
|
6318
6344
|
const prev = map.items[map.items.length - 2];
|
|
6319
6345
|
const end = prev?.value?.end;
|
|
6320
6346
|
if (Array.isArray(end)) {
|
|
6321
|
-
|
|
6347
|
+
arrayPushArray(end, it.start);
|
|
6322
6348
|
end.push(this.sourceToken);
|
|
6323
6349
|
map.items.pop();
|
|
6324
6350
|
return;
|
|
@@ -6506,7 +6532,7 @@ var require_parser = __commonJS((exports) => {
|
|
|
6506
6532
|
const prev = seq.items[seq.items.length - 2];
|
|
6507
6533
|
const end = prev?.value?.end;
|
|
6508
6534
|
if (Array.isArray(end)) {
|
|
6509
|
-
|
|
6535
|
+
arrayPushArray(end, it.start);
|
|
6510
6536
|
end.push(this.sourceToken);
|
|
6511
6537
|
seq.items.pop();
|
|
6512
6538
|
return;
|
|
@@ -7142,6 +7168,7 @@ function buildRememberRequestBody(content, options = {}) {
|
|
|
7142
7168
|
source: options.source
|
|
7143
7169
|
});
|
|
7144
7170
|
}
|
|
7171
|
+
var DAEMON_DERIVED_MEMORY_SOURCE_TYPES = ["extract", "aggregate-recall", "session_end", "checkpoint", "dreaming"];
|
|
7145
7172
|
var MEMORIES_FTS_TOKENIZER = "unicode61";
|
|
7146
7173
|
function normalizeSql(sql) {
|
|
7147
7174
|
return sql.replace(/\s+/g, " ").trim().toLowerCase();
|
|
@@ -10239,6 +10266,243 @@ function up92(db) {
|
|
|
10239
10266
|
ON embeddings_staging(agent_id, source_type, source_id);
|
|
10240
10267
|
`);
|
|
10241
10268
|
}
|
|
10269
|
+
function up93(db) {
|
|
10270
|
+
const columns = db.prepare("PRAGMA table_info(dreaming_state)").all();
|
|
10271
|
+
if (!columns.some((column) => column.name === "evidence_cursor")) {
|
|
10272
|
+
db.exec("ALTER TABLE dreaming_state ADD COLUMN evidence_cursor TEXT");
|
|
10273
|
+
}
|
|
10274
|
+
}
|
|
10275
|
+
var DERIVED_SOURCE_TYPES = DAEMON_DERIVED_MEMORY_SOURCE_TYPES;
|
|
10276
|
+
function hasColumn13(db, table, column) {
|
|
10277
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
10278
|
+
return rows.some((r) => r.name === column);
|
|
10279
|
+
}
|
|
10280
|
+
function up94(db) {
|
|
10281
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name = 'memories'").all();
|
|
10282
|
+
if (tables.length === 0)
|
|
10283
|
+
return;
|
|
10284
|
+
if (!hasColumn13(db, "memories", "memory_kind")) {
|
|
10285
|
+
db.exec("ALTER TABLE memories ADD COLUMN memory_kind TEXT");
|
|
10286
|
+
}
|
|
10287
|
+
if (!hasColumn13(db, "memories", "evidence_meta")) {
|
|
10288
|
+
db.exec("ALTER TABLE memories ADD COLUMN evidence_meta TEXT");
|
|
10289
|
+
}
|
|
10290
|
+
if (hasColumn13(db, "memories", "source_type")) {
|
|
10291
|
+
const placeholders = DERIVED_SOURCE_TYPES.map(() => "?").join(", ");
|
|
10292
|
+
db.prepare(`UPDATE memories
|
|
10293
|
+
SET memory_kind = 'episodic'
|
|
10294
|
+
WHERE memory_kind IS NULL
|
|
10295
|
+
AND (source_type IS NULL OR source_type NOT IN (${placeholders}))`).run(...DERIVED_SOURCE_TYPES);
|
|
10296
|
+
} else {
|
|
10297
|
+
db.exec(`UPDATE memories
|
|
10298
|
+
SET memory_kind = 'episodic'
|
|
10299
|
+
WHERE memory_kind IS NULL`);
|
|
10300
|
+
}
|
|
10301
|
+
}
|
|
10302
|
+
function hasColumn14(db, table, column) {
|
|
10303
|
+
return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
|
|
10304
|
+
}
|
|
10305
|
+
function up95(db) {
|
|
10306
|
+
const hasMemories = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'memories'").get();
|
|
10307
|
+
if (!hasMemories || !hasColumn14(db, "memories", "memory_kind") || !hasColumn14(db, "memories", "type"))
|
|
10308
|
+
return;
|
|
10309
|
+
db.exec("UPDATE memories SET memory_kind = NULL WHERE type = 'session_summary'");
|
|
10310
|
+
}
|
|
10311
|
+
function up96(db) {
|
|
10312
|
+
db.exec("DROP TABLE IF EXISTS ingestion_jobs");
|
|
10313
|
+
}
|
|
10314
|
+
function up97(db) {
|
|
10315
|
+
const columns = db.prepare("PRAGMA table_info(dreaming_state)").all();
|
|
10316
|
+
if (!columns.some((column) => column.name === "last_failure_at")) {
|
|
10317
|
+
db.exec("ALTER TABLE dreaming_state ADD COLUMN last_failure_at TEXT");
|
|
10318
|
+
}
|
|
10319
|
+
db.exec("UPDATE dreaming_state SET last_failure_at = updated_at WHERE consecutive_failures > 0 AND last_failure_at IS NULL");
|
|
10320
|
+
}
|
|
10321
|
+
function up98(db) {
|
|
10322
|
+
db.exec(`
|
|
10323
|
+
CREATE TABLE IF NOT EXISTS dreaming_evidence_exclusions (
|
|
10324
|
+
agent_id TEXT NOT NULL,
|
|
10325
|
+
source_kind TEXT NOT NULL CHECK (source_kind IN ('memory', 'artifact', 'transcript', 'summary')),
|
|
10326
|
+
source_id TEXT NOT NULL,
|
|
10327
|
+
reason TEXT NOT NULL,
|
|
10328
|
+
pass_id TEXT NOT NULL,
|
|
10329
|
+
excluded_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
10330
|
+
requeue_requested_at TEXT,
|
|
10331
|
+
resolved_at TEXT,
|
|
10332
|
+
PRIMARY KEY (agent_id, source_kind, source_id)
|
|
10333
|
+
);
|
|
10334
|
+
CREATE INDEX IF NOT EXISTS idx_dreaming_evidence_exclusions_active
|
|
10335
|
+
ON dreaming_evidence_exclusions (agent_id, resolved_at, requeue_requested_at, excluded_at DESC);
|
|
10336
|
+
`);
|
|
10337
|
+
}
|
|
10338
|
+
function up99(db) {
|
|
10339
|
+
db.exec(`
|
|
10340
|
+
CREATE TABLE IF NOT EXISTS dreaming_tool_calls (
|
|
10341
|
+
id TEXT PRIMARY KEY,
|
|
10342
|
+
agent_id TEXT NOT NULL,
|
|
10343
|
+
pass_id TEXT NOT NULL,
|
|
10344
|
+
sequence INTEGER NOT NULL,
|
|
10345
|
+
tool_call_id TEXT,
|
|
10346
|
+
tool_name TEXT NOT NULL,
|
|
10347
|
+
input_json TEXT NOT NULL,
|
|
10348
|
+
output_json TEXT NOT NULL,
|
|
10349
|
+
success INTEGER NOT NULL,
|
|
10350
|
+
latency_ms INTEGER NOT NULL,
|
|
10351
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
10352
|
+
UNIQUE(agent_id, pass_id, sequence)
|
|
10353
|
+
);
|
|
10354
|
+
CREATE INDEX IF NOT EXISTS idx_dreaming_tool_calls_pass
|
|
10355
|
+
ON dreaming_tool_calls (agent_id, pass_id, sequence ASC);
|
|
10356
|
+
`);
|
|
10357
|
+
}
|
|
10358
|
+
function up100(db) {
|
|
10359
|
+
const columns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
|
|
10360
|
+
if (!columns.some((column) => column.name === "evidence_window_json")) {
|
|
10361
|
+
db.exec("ALTER TABLE dreaming_passes ADD COLUMN evidence_window_json TEXT");
|
|
10362
|
+
}
|
|
10363
|
+
if (!columns.some((column) => column.name === "runbook_json")) {
|
|
10364
|
+
db.exec("ALTER TABLE dreaming_passes ADD COLUMN runbook_json TEXT");
|
|
10365
|
+
}
|
|
10366
|
+
}
|
|
10367
|
+
function up101(db) {
|
|
10368
|
+
db.exec(`
|
|
10369
|
+
CREATE TABLE IF NOT EXISTS dreaming_attention (
|
|
10370
|
+
id TEXT PRIMARY KEY,
|
|
10371
|
+
agent_id TEXT NOT NULL,
|
|
10372
|
+
kind TEXT NOT NULL CHECK (kind IN ('review_due', 'hygiene', 'contested_claim', 'evidence_requeue')),
|
|
10373
|
+
subject_ref TEXT NOT NULL,
|
|
10374
|
+
details_json TEXT NOT NULL DEFAULT '{}',
|
|
10375
|
+
priority INTEGER NOT NULL DEFAULT 0 CHECK (priority >= 0 AND priority <= 100),
|
|
10376
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
10377
|
+
generation INTEGER NOT NULL DEFAULT 0,
|
|
10378
|
+
resolved_at TEXT,
|
|
10379
|
+
resolved_by_pass_id TEXT,
|
|
10380
|
+
UNIQUE(agent_id, kind, subject_ref)
|
|
10381
|
+
);
|
|
10382
|
+
CREATE INDEX IF NOT EXISTS idx_dreaming_attention_pending
|
|
10383
|
+
ON dreaming_attention (agent_id, resolved_at, priority DESC, created_at ASC);
|
|
10384
|
+
`);
|
|
10385
|
+
}
|
|
10386
|
+
function hasColumn15(db, table, column) {
|
|
10387
|
+
return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
|
|
10388
|
+
}
|
|
10389
|
+
function up102(db) {
|
|
10390
|
+
const requiredMemoryColumns = [
|
|
10391
|
+
"content_hash",
|
|
10392
|
+
"normalized_content",
|
|
10393
|
+
"memory_kind",
|
|
10394
|
+
"source_type",
|
|
10395
|
+
"source_path",
|
|
10396
|
+
"agent_id",
|
|
10397
|
+
"visibility",
|
|
10398
|
+
"is_deleted",
|
|
10399
|
+
"extraction_status"
|
|
10400
|
+
];
|
|
10401
|
+
if (!hasColumn15(db, "entity_attributes", "memory_id") || !requiredMemoryColumns.every((column) => hasColumn15(db, "memories", column))) {
|
|
10402
|
+
return;
|
|
10403
|
+
}
|
|
10404
|
+
db.exec(`
|
|
10405
|
+
INSERT OR IGNORE INTO memories
|
|
10406
|
+
(id, content, normalized_content, content_hash, who, why, project,
|
|
10407
|
+
importance, type, tags, pinned, is_deleted, extraction_status,
|
|
10408
|
+
created_at, updated_at, updated_by, source_type, source_id, source_path,
|
|
10409
|
+
agent_id, visibility, memory_kind)
|
|
10410
|
+
SELECT attr.id, attr.content, attr.normalized_content,
|
|
10411
|
+
'semantic-attribute:' || attr.id, 'dreaming', 'Derived semantic attribute', NULL,
|
|
10412
|
+
attr.importance, 'semantic', 'semantic,attribute', 0,
|
|
10413
|
+
CASE WHEN attr.status = 'active' THEN 0 ELSE 1 END, 'completed',
|
|
10414
|
+
attr.created_at, attr.updated_at, 'dreaming', 'dreaming', attr.source_id, attr.source_path,
|
|
10415
|
+
attr.agent_id, 'global', 'derived'
|
|
10416
|
+
FROM entity_attributes attr
|
|
10417
|
+
WHERE attr.memory_id IS NULL
|
|
10418
|
+
`);
|
|
10419
|
+
db.exec(`
|
|
10420
|
+
UPDATE entity_attributes
|
|
10421
|
+
SET memory_id = id
|
|
10422
|
+
WHERE memory_id IS NULL
|
|
10423
|
+
AND EXISTS (SELECT 1 FROM memories WHERE memories.id = entity_attributes.id)
|
|
10424
|
+
`);
|
|
10425
|
+
db.exec(`
|
|
10426
|
+
INSERT OR IGNORE INTO memory_entity_mentions (memory_id, entity_id)
|
|
10427
|
+
SELECT attr.memory_id, aspect.entity_id
|
|
10428
|
+
FROM entity_attributes attr
|
|
10429
|
+
JOIN entity_aspects aspect ON aspect.id = attr.aspect_id AND aspect.agent_id = attr.agent_id
|
|
10430
|
+
WHERE attr.memory_id IS NOT NULL
|
|
10431
|
+
`);
|
|
10432
|
+
db.exec(`
|
|
10433
|
+
UPDATE entities
|
|
10434
|
+
SET mentions = (
|
|
10435
|
+
SELECT COUNT(*) FROM memory_entity_mentions WHERE entity_id = entities.id
|
|
10436
|
+
)
|
|
10437
|
+
WHERE EXISTS (SELECT 1 FROM memory_entity_mentions WHERE entity_id = entities.id)
|
|
10438
|
+
`);
|
|
10439
|
+
}
|
|
10440
|
+
function up103(db) {
|
|
10441
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name IN ('memories', 'entity_attributes')").all();
|
|
10442
|
+
if (tables.length !== 2)
|
|
10443
|
+
return;
|
|
10444
|
+
const memoryColumns = db.prepare("PRAGMA table_info(memories)").all().map((row) => row.name);
|
|
10445
|
+
const attributeColumns = db.prepare("PRAGMA table_info(entity_attributes)").all().map((row) => row.name);
|
|
10446
|
+
if (!memoryColumns.includes("memory_kind") || !attributeColumns.includes("memory_id"))
|
|
10447
|
+
return;
|
|
10448
|
+
db.exec(`
|
|
10449
|
+
UPDATE memories
|
|
10450
|
+
SET memory_kind = 'derived'
|
|
10451
|
+
WHERE memory_kind IS NULL
|
|
10452
|
+
AND id IN (
|
|
10453
|
+
SELECT memory_id FROM entity_attributes WHERE memory_id IS NOT NULL
|
|
10454
|
+
)
|
|
10455
|
+
`);
|
|
10456
|
+
}
|
|
10457
|
+
function tableExists(db, table) {
|
|
10458
|
+
return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) !== undefined;
|
|
10459
|
+
}
|
|
10460
|
+
function hasColumn16(db, table, column) {
|
|
10461
|
+
return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
|
|
10462
|
+
}
|
|
10463
|
+
function up104(db) {
|
|
10464
|
+
db.exec(`
|
|
10465
|
+
CREATE TABLE IF NOT EXISTS derived_memory_sources (
|
|
10466
|
+
derived_memory_id TEXT NOT NULL,
|
|
10467
|
+
source_kind TEXT NOT NULL,
|
|
10468
|
+
source_id TEXT NOT NULL,
|
|
10469
|
+
source_path TEXT,
|
|
10470
|
+
agent_id TEXT NOT NULL,
|
|
10471
|
+
created_at TEXT NOT NULL,
|
|
10472
|
+
PRIMARY KEY (derived_memory_id, source_kind, source_id)
|
|
10473
|
+
);
|
|
10474
|
+
CREATE INDEX IF NOT EXISTS idx_derived_memory_sources_derived
|
|
10475
|
+
ON derived_memory_sources(agent_id, derived_memory_id);
|
|
10476
|
+
CREATE INDEX IF NOT EXISTS idx_derived_memory_sources_source
|
|
10477
|
+
ON derived_memory_sources(agent_id, source_kind, source_id);
|
|
10478
|
+
`);
|
|
10479
|
+
if (tableExists(db, "aggregate_evidence_sources")) {
|
|
10480
|
+
db.exec(`
|
|
10481
|
+
INSERT OR IGNORE INTO derived_memory_sources
|
|
10482
|
+
(derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
|
|
10483
|
+
SELECT aggregate_memory_id, source_kind, source_id, source_path, agent_id, created_at
|
|
10484
|
+
FROM aggregate_evidence_sources
|
|
10485
|
+
`);
|
|
10486
|
+
}
|
|
10487
|
+
if (tableExists(db, "aggregate_memory_sources")) {
|
|
10488
|
+
db.exec(`
|
|
10489
|
+
INSERT OR IGNORE INTO derived_memory_sources
|
|
10490
|
+
(derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
|
|
10491
|
+
SELECT aggregate_memory_id, 'memory', source_memory_id, NULL, agent_id, created_at
|
|
10492
|
+
FROM aggregate_memory_sources
|
|
10493
|
+
`);
|
|
10494
|
+
}
|
|
10495
|
+
if (tableExists(db, "memories") && !hasColumn16(db, "memories", "stale_at")) {
|
|
10496
|
+
db.exec("ALTER TABLE memories ADD COLUMN stale_at TEXT");
|
|
10497
|
+
}
|
|
10498
|
+
if (tableExists(db, "memories")) {
|
|
10499
|
+
db.exec(`
|
|
10500
|
+
CREATE INDEX IF NOT EXISTS idx_memories_stale_derived
|
|
10501
|
+
ON memories(agent_id, stale_at)
|
|
10502
|
+
WHERE stale_at IS NOT NULL AND is_deleted = 0
|
|
10503
|
+
`);
|
|
10504
|
+
}
|
|
10505
|
+
}
|
|
10242
10506
|
var MIGRATIONS = [
|
|
10243
10507
|
{
|
|
10244
10508
|
version: 1,
|
|
@@ -10323,7 +10587,6 @@ var MIGRATIONS = [
|
|
|
10323
10587
|
name: "ingestion-tracking",
|
|
10324
10588
|
up: up13,
|
|
10325
10589
|
artifacts: {
|
|
10326
|
-
tables: ["ingestion_jobs"],
|
|
10327
10590
|
columns: [
|
|
10328
10591
|
{ table: "memories", column: "source_path" },
|
|
10329
10592
|
{ table: "memories", column: "source_section" }
|
|
@@ -10986,6 +11249,87 @@ var MIGRATIONS = [
|
|
|
10986
11249
|
name: "embedding-staging-store",
|
|
10987
11250
|
up: up92,
|
|
10988
11251
|
artifacts: { tables: ["embeddings_staging"] }
|
|
11252
|
+
},
|
|
11253
|
+
{
|
|
11254
|
+
version: 93,
|
|
11255
|
+
name: "dreaming-evidence-cursor",
|
|
11256
|
+
up: up93,
|
|
11257
|
+
artifacts: { columns: [{ table: "dreaming_state", column: "evidence_cursor" }] }
|
|
11258
|
+
},
|
|
11259
|
+
{
|
|
11260
|
+
version: 94,
|
|
11261
|
+
name: "memory-kind",
|
|
11262
|
+
up: up94,
|
|
11263
|
+
artifacts: {
|
|
11264
|
+
columns: [
|
|
11265
|
+
{ table: "memories", column: "memory_kind" },
|
|
11266
|
+
{ table: "memories", column: "evidence_meta" }
|
|
11267
|
+
]
|
|
11268
|
+
}
|
|
11269
|
+
},
|
|
11270
|
+
{
|
|
11271
|
+
version: 95,
|
|
11272
|
+
name: "compaction-recall-projections",
|
|
11273
|
+
up: up95
|
|
11274
|
+
},
|
|
11275
|
+
{
|
|
11276
|
+
version: 96,
|
|
11277
|
+
name: "retire-legacy-ingestion",
|
|
11278
|
+
up: up96
|
|
11279
|
+
},
|
|
11280
|
+
{
|
|
11281
|
+
version: 97,
|
|
11282
|
+
name: "dreaming-failure-backoff",
|
|
11283
|
+
up: up97,
|
|
11284
|
+
artifacts: { columns: [{ table: "dreaming_state", column: "last_failure_at" }] }
|
|
11285
|
+
},
|
|
11286
|
+
{
|
|
11287
|
+
version: 98,
|
|
11288
|
+
name: "dreaming-evidence-exclusions",
|
|
11289
|
+
up: up98,
|
|
11290
|
+
artifacts: { tables: ["dreaming_evidence_exclusions"] }
|
|
11291
|
+
},
|
|
11292
|
+
{
|
|
11293
|
+
version: 99,
|
|
11294
|
+
name: "dreaming-tool-calls",
|
|
11295
|
+
up: up99,
|
|
11296
|
+
artifacts: { tables: ["dreaming_tool_calls"] }
|
|
11297
|
+
},
|
|
11298
|
+
{
|
|
11299
|
+
version: 100,
|
|
11300
|
+
name: "dreaming-runbook",
|
|
11301
|
+
up: up100,
|
|
11302
|
+
artifacts: {
|
|
11303
|
+
columns: [
|
|
11304
|
+
{ table: "dreaming_passes", column: "evidence_window_json" },
|
|
11305
|
+
{ table: "dreaming_passes", column: "runbook_json" }
|
|
11306
|
+
]
|
|
11307
|
+
}
|
|
11308
|
+
},
|
|
11309
|
+
{
|
|
11310
|
+
version: 101,
|
|
11311
|
+
name: "dreaming-attention",
|
|
11312
|
+
up: up101,
|
|
11313
|
+
artifacts: { tables: ["dreaming_attention"] }
|
|
11314
|
+
},
|
|
11315
|
+
{
|
|
11316
|
+
version: 102,
|
|
11317
|
+
name: "attribute-semantic-memories",
|
|
11318
|
+
up: up102
|
|
11319
|
+
},
|
|
11320
|
+
{
|
|
11321
|
+
version: 103,
|
|
11322
|
+
name: "semantic-memory-kind",
|
|
11323
|
+
up: up103
|
|
11324
|
+
},
|
|
11325
|
+
{
|
|
11326
|
+
version: 104,
|
|
11327
|
+
name: "derived-memory-provenance",
|
|
11328
|
+
up: up104,
|
|
11329
|
+
artifacts: {
|
|
11330
|
+
tables: ["derived_memory_sources"],
|
|
11331
|
+
columns: [{ table: "memories", column: "stale_at" }]
|
|
11332
|
+
}
|
|
10989
11333
|
}
|
|
10990
11334
|
];
|
|
10991
11335
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -11322,122 +11666,6 @@ ${parts.join(`
|
|
|
11322
11666
|
`)}`;
|
|
11323
11667
|
}
|
|
11324
11668
|
var home = homedir8();
|
|
11325
|
-
var SKIP_SUBTYPES = new Set([
|
|
11326
|
-
"channel_join",
|
|
11327
|
-
"channel_leave",
|
|
11328
|
-
"channel_topic",
|
|
11329
|
-
"channel_purpose",
|
|
11330
|
-
"channel_name",
|
|
11331
|
-
"channel_archive",
|
|
11332
|
-
"channel_unarchive",
|
|
11333
|
-
"group_join",
|
|
11334
|
-
"group_leave",
|
|
11335
|
-
"group_topic",
|
|
11336
|
-
"group_purpose",
|
|
11337
|
-
"group_name",
|
|
11338
|
-
"group_archive",
|
|
11339
|
-
"group_unarchive",
|
|
11340
|
-
"pinned_item",
|
|
11341
|
-
"unpinned_item",
|
|
11342
|
-
"bot_add",
|
|
11343
|
-
"bot_remove",
|
|
11344
|
-
"tombstone",
|
|
11345
|
-
"file_comment",
|
|
11346
|
-
"sh_room_created",
|
|
11347
|
-
"sh_room_shared"
|
|
11348
|
-
]);
|
|
11349
|
-
var SKIP_TYPES = new Set([
|
|
11350
|
-
"RecipientAdd",
|
|
11351
|
-
"RecipientRemove",
|
|
11352
|
-
"ChannelNameChange",
|
|
11353
|
-
"ChannelIconChange",
|
|
11354
|
-
"ChannelPinnedMessage",
|
|
11355
|
-
"GuildMemberJoin",
|
|
11356
|
-
"UserPremiumGuildSubscription",
|
|
11357
|
-
"UserPremiumGuildSubscriptionTier1",
|
|
11358
|
-
"UserPremiumGuildSubscriptionTier2",
|
|
11359
|
-
"UserPremiumGuildSubscriptionTier3",
|
|
11360
|
-
"ChannelFollowAdd",
|
|
11361
|
-
"GuildDiscoveryDisqualified",
|
|
11362
|
-
"GuildDiscoveryRequalified",
|
|
11363
|
-
"GuildDiscoveryGracePeriodInitialWarning",
|
|
11364
|
-
"GuildDiscoveryGracePeriodFinalWarning",
|
|
11365
|
-
"ThreadCreated",
|
|
11366
|
-
"ApplicationCommand"
|
|
11367
|
-
]);
|
|
11368
|
-
var SKIP_DIRS = new Set([
|
|
11369
|
-
"node_modules",
|
|
11370
|
-
".git",
|
|
11371
|
-
"dist",
|
|
11372
|
-
"build",
|
|
11373
|
-
"out",
|
|
11374
|
-
"target",
|
|
11375
|
-
".next",
|
|
11376
|
-
".nuxt",
|
|
11377
|
-
"__pycache__",
|
|
11378
|
-
".tox",
|
|
11379
|
-
".mypy_cache",
|
|
11380
|
-
".pytest_cache",
|
|
11381
|
-
"venv",
|
|
11382
|
-
".venv",
|
|
11383
|
-
"env",
|
|
11384
|
-
"vendor",
|
|
11385
|
-
"coverage",
|
|
11386
|
-
".cache",
|
|
11387
|
-
".turbo"
|
|
11388
|
-
]);
|
|
11389
|
-
var DOCUMENT_VALID_TYPES = new Set([
|
|
11390
|
-
"fact",
|
|
11391
|
-
"decision",
|
|
11392
|
-
"rationale",
|
|
11393
|
-
"preference",
|
|
11394
|
-
"procedural",
|
|
11395
|
-
"semantic",
|
|
11396
|
-
"system",
|
|
11397
|
-
"configuration",
|
|
11398
|
-
"architectural",
|
|
11399
|
-
"relationship",
|
|
11400
|
-
"episodic",
|
|
11401
|
-
"daily-log"
|
|
11402
|
-
]);
|
|
11403
|
-
var ENTIRE_VALID_TYPES = new Set(["skill", "preference", "decision", "rationale", "procedural", "semantic", "fact"]);
|
|
11404
|
-
var CHAT_VALID_TYPES = new Set(["fact", "decision", "rationale", "preference", "procedural", "semantic", "system"]);
|
|
11405
|
-
var MARKDOWN_EXTS = new Set([".md", ".mdx", ".markdown"]);
|
|
11406
|
-
var TXT_EXTS = new Set([".txt", ".text", ".log", ".rst"]);
|
|
11407
|
-
var PDF_EXTS = new Set([".pdf"]);
|
|
11408
|
-
var CODE_EXTS = new Set([
|
|
11409
|
-
".ts",
|
|
11410
|
-
".tsx",
|
|
11411
|
-
".js",
|
|
11412
|
-
".jsx",
|
|
11413
|
-
".py",
|
|
11414
|
-
".rs",
|
|
11415
|
-
".go",
|
|
11416
|
-
".java",
|
|
11417
|
-
".rb",
|
|
11418
|
-
".php",
|
|
11419
|
-
".swift",
|
|
11420
|
-
".kt",
|
|
11421
|
-
".scala",
|
|
11422
|
-
".c",
|
|
11423
|
-
".cpp",
|
|
11424
|
-
".h",
|
|
11425
|
-
".hpp",
|
|
11426
|
-
".sh",
|
|
11427
|
-
".bash",
|
|
11428
|
-
".zsh",
|
|
11429
|
-
".sql",
|
|
11430
|
-
".yaml",
|
|
11431
|
-
".yml",
|
|
11432
|
-
".toml",
|
|
11433
|
-
".json",
|
|
11434
|
-
".xml",
|
|
11435
|
-
".css",
|
|
11436
|
-
".scss",
|
|
11437
|
-
".html",
|
|
11438
|
-
".htm"
|
|
11439
|
-
]);
|
|
11440
|
-
var SKIP_FILES = new Set([".DS_Store", "Thumbs.db", ".gitkeep", "node_modules", ".git", ".env", ".env.local"]);
|
|
11441
11669
|
|
|
11442
11670
|
// ../../../libs/sdk/dist/index.js
|
|
11443
11671
|
function isRecord2(value) {
|
|
@@ -11652,18 +11880,12 @@ class SignetClientP2 {
|
|
|
11652
11880
|
async deduplicateMemories(opts) {
|
|
11653
11881
|
return this.transport.post("/api/repair/deduplicate", opts ?? {});
|
|
11654
11882
|
}
|
|
11655
|
-
async reclassifyEntities() {
|
|
11656
|
-
return this.transport.post("/api/repair/reclassify-entities", {});
|
|
11657
|
-
}
|
|
11658
11883
|
async pruneChunkGroups() {
|
|
11659
11884
|
return this.transport.post("/api/repair/prune-chunk-groups", {});
|
|
11660
11885
|
}
|
|
11661
11886
|
async pruneSingletonEntities(opts) {
|
|
11662
11887
|
return this.transport.post("/api/repair/prune-singleton-entities", opts ?? {});
|
|
11663
11888
|
}
|
|
11664
|
-
async structuralBackfill() {
|
|
11665
|
-
return this.transport.post("/api/repair/structural-backfill", {});
|
|
11666
|
-
}
|
|
11667
11889
|
async listAgentPresence(opts) {
|
|
11668
11890
|
return this.transport.get("/api/cross-agent/presence", opts);
|
|
11669
11891
|
}
|