@signetai/connector-openclaw 0.236.1 → 0.237.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.
Files changed (2) hide show
  1. package/dist/index.js +439 -361
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -10381,99 +10381,6 @@ var execFileHiddenImpl = (...args) => Reflect.apply(nodeExecFile, undefined, wit
10381
10381
  Object.defineProperty(execFileHiddenImpl, promisify.custom, {
10382
10382
  value: (...args) => Reflect.apply(nodeExecFileAsync, undefined, withWindowsHideArgument(args, 1))
10383
10383
  });
10384
- var MEMORY_CONTENT_SAFETY_POLICY_VERSION = "memory-content-safety-v1";
10385
- var MEMORY_CONTENT_SAFETY_REASONS = [
10386
- "prompt_injection",
10387
- "exfiltration",
10388
- "credential_harvesting",
10389
- "malicious_shell",
10390
- "tool_directive",
10391
- "invisible_unicode"
10392
- ];
10393
- var INVISIBLE_UNICODE_RE = /(?:\u034f|[\u00ad\u061c\u070f\u180e\u200b\u200c\u200e\u200f\u202a-\u202e\u2060\u2066-\u2069\u206a-\u206f\ufeff]|[\u{e0000}-\u{e007f}])/u;
10394
- var STRONG_DEFENSIVE_CONTEXT_RE = /\b(?:security\s+(?:guidance|discussion|analysis)|threat\s+model|defensive)\b/i;
10395
- var REPORTING_CONTEXT_RE = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b/i;
10396
- var REPORTING_BEFORE_RE = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b[\s\S]{0,80}\b(?:say\w*|read\w*|show\w*|flag\w*|detect\w*|describ\w*|demonstrat\w*|contain\w*|match\w*|pattern)\b/i;
10397
- var REPORTING_AFTER_RE = /\b(?:detector|scanner|classif\w*|flag\w*|pattern|dangerous|unsafe|malicious|hostile|should|would|must|never|do not|don't|avoid|quoted)\b/i;
10398
- var NEGATED_DIRECTIVE_RE = /\b(?:never|do not|don't|should not|must not|cannot|can't|avoid|prevent|detect|mitigat\w*)\b[\s\S]{0,80}$/i;
10399
- var PROMPT_INJECTION_RES = [
10400
- /\b(?:ignore|disregard|override|forget|bypass)\b[\s\S]{0,100}\b(?:previous|prior|above|earlier|system|developer|assistant|safety|security)?\s*(?:instructions?|rules?|prompt|message)\b/i,
10401
- /\b(?:new|following|these)\s+(?:(?:system|developer|assistant|hidden)\s+)?instructions?\b/i,
10402
- /(?:^|\n)\s*(?:system|developer|instruction|prompt)\s*:/im,
10403
- /<\s*(?:system|developer|assistant|instruction|prompt)\b[^>]*>/i,
10404
- /\b(?:you are now|act as|roleplay as|pretend to be)\b[\s\S]{0,80}\b(?:system|admin|developer|unrestricted|jailbreak|different agent)\b/i
10405
- ];
10406
- var TOOL_DIRECTIVE_RES = [
10407
- /<\s*(?:tool[_-]?call|function[_-]?call|invoke|tool)\b/i,
10408
- /\b(?:assistant|system)\s+to\s*=\s*[a-z0-9_.-]+/i,
10409
- /\b(?:call|invoke|use|run|execute)\s+(?:the\s+)?[a-z0-9_.-]+\s+tool\b/i
10410
- ];
10411
- var EXFILTRATION_RE = /\b(?:reveal|show|print|send|upload|exfiltrat\w*|dump|forward|leak|transmit|export)\b[\s\S]{0,120}(?:\b(?:system\s+prompt|hidden\s+instructions?|secret(?:s)?|credential(?:s)?|password(?:s)?|api\s*keys?|tokens?|private\s+keys?|environment\s+variables?)\b|\.env\b|~\/(?:\.ssh)\/\S+|\/etc\/(?:shadow|passwd)\b)/i;
10412
- var EXFILTRATION_REVERSE = /(?:\b(?:system\s+prompt|hidden\s+instructions?|secret(?:s)?|credential(?:s)?|password(?:s)?|api\s*keys?|tokens?|private\s+keys?|environment\s+variables?)\b|\.env\b|~\/(?:\.ssh)\/\S+|\/etc\/(?:shadow|passwd)\b)[\s\S]{0,120}\b(?:reveal|show|print|send|upload|exfiltrat\w*|dump|forward|leak|transmit|export)\b/i;
10413
- var CREDENTIAL_HARVESTING_RE = /\b(?:enter|paste|provide|share|send|give|submit|type|hand over)\b[\s\S]{0,80}\b(?:password|api\s*key|token|secret|credential|private\s+key)\b/i;
10414
- var DANGEROUS_SHELL_RE = /\b(?:curl|wget)\b[^\n]{0,240}\|\s*(?:ba|z|fi)?sh\b|\brm\s+-rf\s+(?:\/|~|\.ssh)[^\n]{0,240}|\b(?:cat|head|tail)\s+~\/?\.ssh\/(?:id_[a-z]+|authorized_keys)\b|\b(?:printenv|env)\b[^\n]{0,120}\b(?:curl|wget|send|upload|post)\b/i;
10415
- function matchHasDefensiveContext(content, match) {
10416
- if (!match || !match[0])
10417
- return false;
10418
- const start = match.index ?? 0;
10419
- const before = content.slice(Math.max(0, start - 120), start);
10420
- const after = content.slice(start + match[0].length, start + match[0].length + 160);
10421
- return STRONG_DEFENSIVE_CONTEXT_RE.test(match[0]) || NEGATED_DIRECTIVE_RE.test(before) || STRONG_DEFENSIVE_CONTEXT_RE.test(before) || STRONG_DEFENSIVE_CONTEXT_RE.test(after) || REPORTING_BEFORE_RE.test(before) || REPORTING_CONTEXT_RE.test(before) && REPORTING_AFTER_RE.test(after);
10422
- }
10423
- function hasActionableMatch(content, patterns) {
10424
- return patterns.some((pattern) => {
10425
- const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
10426
- const searchable = new RegExp(pattern.source, flags);
10427
- let match;
10428
- while ((match = searchable.exec(content)) !== null) {
10429
- if (!matchHasDefensiveContext(content, match))
10430
- return true;
10431
- if (match[0].length === 0)
10432
- searchable.lastIndex += 1;
10433
- }
10434
- return false;
10435
- });
10436
- }
10437
- function hasDangerousShell(content) {
10438
- const searchable = new RegExp(DANGEROUS_SHELL_RE.source, `${DANGEROUS_SHELL_RE.flags}g`);
10439
- let match;
10440
- while ((match = searchable.exec(content)) !== null) {
10441
- if (matchHasDefensiveContext(content, match))
10442
- continue;
10443
- const end = (match.index ?? 0) + match[0].length;
10444
- const after = content.slice(end, end + 160);
10445
- if (!STRONG_DEFENSIVE_CONTEXT_RE.test(after) && !REPORTING_AFTER_RE.test(after))
10446
- return true;
10447
- if (match[0].length === 0)
10448
- searchable.lastIndex += 1;
10449
- }
10450
- return false;
10451
- }
10452
- function scanMemoryContent(content) {
10453
- const raw = typeof content === "string" ? content : String(content ?? "");
10454
- const normalized = raw.normalize("NFKC");
10455
- const reasons = new Set;
10456
- if (INVISIBLE_UNICODE_RE.test(raw))
10457
- reasons.add("invisible_unicode");
10458
- if (hasActionableMatch(normalized, PROMPT_INJECTION_RES))
10459
- reasons.add("prompt_injection");
10460
- if (hasActionableMatch(normalized, TOOL_DIRECTIVE_RES))
10461
- reasons.add("tool_directive");
10462
- if (hasActionableMatch(normalized, [EXFILTRATION_RE, EXFILTRATION_REVERSE]))
10463
- reasons.add("exfiltration");
10464
- if (hasActionableMatch(normalized, [CREDENTIAL_HARVESTING_RE]))
10465
- reasons.add("credential_harvesting");
10466
- if (hasDangerousShell(normalized))
10467
- reasons.add("malicious_shell");
10468
- const orderedReasons = MEMORY_CONTENT_SAFETY_REASONS.filter((reason) => reasons.has(reason));
10469
- const status = orderedReasons.length === 0 ? "clean" : orderedReasons.every((reason) => reason === "invisible_unicode") ? "tainted" : "blocked";
10470
- return {
10471
- status,
10472
- contextEligible: status === "clean",
10473
- reasons: orderedReasons,
10474
- policyVersion: MEMORY_CONTENT_SAFETY_POLICY_VERSION
10475
- };
10476
- }
10477
10384
  var DAEMON_DERIVED_MEMORY_SOURCE_TYPES = [
10478
10385
  "extract",
10479
10386
  "aggregate-recall",
@@ -10596,7 +10503,7 @@ function up4(db) {
10596
10503
  function up5(db) {
10597
10504
  db.exec("DROP TABLE IF EXISTS mcp_invocations");
10598
10505
  }
10599
- var MEMORIES_FTS_TOKENIZER = "unicode61";
10506
+ var MEMORIES_FTS_TOKENIZER = "porter unicode61";
10600
10507
  var FTS_STATE_TABLE = "memories_fts_state";
10601
10508
  function normalizeSql(sql) {
10602
10509
  return sql.replace(/\s+/g, " ").trim().toLowerCase();
@@ -10706,10 +10613,7 @@ function readMemoriesFtsSql(db) {
10706
10613
  function memoriesFtsNeedsTokenizerRepair(sql) {
10707
10614
  if (sql === null)
10708
10615
  return false;
10709
- const normalized = normalizeSql(sql);
10710
- if (normalized.includes("porter unicode61"))
10711
- return true;
10712
- return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER}'`);
10616
+ return !normalizeSql(sql).includes(`tokenize='${MEMORIES_FTS_TOKENIZER}'`);
10713
10617
  }
10714
10618
  function up6(db) {
10715
10619
  db.exec(`
@@ -14622,38 +14526,6 @@ function up129(db) {
14622
14526
  ON imported_source_lifecycle(agent_id, status, updated_at DESC);
14623
14527
  `);
14624
14528
  }
14625
- function tableExists2(db, table) {
14626
- return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
14627
- }
14628
- function hasColumn24(db, table, column) {
14629
- return db.prepare(`PRAGMA table_info("${table}")`).all().some((row) => row.name === column);
14630
- }
14631
- function backfill(db, rows, sourceKind, scannedAt) {
14632
- const statement = db.prepare(`INSERT INTO memory_content_safety
14633
- (agent_id, source_kind, source_id, status, context_eligible, reasons_json, policy_version, scanned_at)
14634
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
14635
- ON CONFLICT(agent_id, source_kind, source_id) DO UPDATE SET
14636
- status = excluded.status,
14637
- context_eligible = excluded.context_eligible,
14638
- reasons_json = excluded.reasons_json,
14639
- policy_version = excluded.policy_version,
14640
- scanned_at = excluded.scanned_at`);
14641
- for (const row of rows) {
14642
- const sourceId = row.source_id?.trim();
14643
- if (!sourceId)
14644
- continue;
14645
- const assessment = scanMemoryContent(row.content ?? "");
14646
- statement.run(row.agent_id?.trim() || "default", sourceKind, sourceId, assessment.status, assessment.contextEligible ? 1 : 0, JSON.stringify(assessment.reasons), MEMORY_CONTENT_SAFETY_POLICY_VERSION, scannedAt);
14647
- }
14648
- }
14649
- function backfillTable(db, params) {
14650
- if (!tableExists2(db, params.table) || !hasColumn24(db, params.table, params.sourceIdColumn) || !hasColumn24(db, params.table, params.contentColumn))
14651
- return;
14652
- const agentColumn = hasColumn24(db, params.table, "agent_id") ? "COALESCE(NULLIF(TRIM(agent_id), ''), 'default')" : "'default'";
14653
- const rows = db.prepare(`SELECT ${agentColumn} AS agent_id, ${params.sourceIdColumn} AS source_id, ${params.contentColumn} AS content
14654
- FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
14655
- backfill(db, rows, params.sourceKind, params.scannedAt);
14656
- }
14657
14529
  function up130(db) {
14658
14530
  db.exec(`
14659
14531
  CREATE TABLE IF NOT EXISTS memory_content_safety (
@@ -14673,43 +14545,6 @@ function up130(db) {
14673
14545
  CREATE INDEX IF NOT EXISTS idx_memory_content_safety_eligibility
14674
14546
  ON memory_content_safety(agent_id, source_kind, context_eligible);
14675
14547
  `);
14676
- const scannedAt = new Date().toISOString();
14677
- backfillTable(db, {
14678
- table: "memories",
14679
- sourceKind: "memory",
14680
- sourceIdColumn: "id",
14681
- contentColumn: "content",
14682
- scannedAt
14683
- });
14684
- backfillTable(db, {
14685
- table: "memory_artifacts",
14686
- sourceKind: "artifact",
14687
- sourceIdColumn: "source_path",
14688
- contentColumn: "content",
14689
- scannedAt
14690
- });
14691
- backfillTable(db, {
14692
- table: "session_transcripts",
14693
- sourceKind: "transcript",
14694
- sourceIdColumn: "session_key",
14695
- contentColumn: "content",
14696
- scannedAt
14697
- });
14698
- backfillTable(db, {
14699
- table: "session_summaries",
14700
- sourceKind: "summary",
14701
- sourceIdColumn: "id",
14702
- contentColumn: "content",
14703
- scannedAt
14704
- });
14705
- backfillTable(db, {
14706
- table: "embeddings",
14707
- sourceKind: "source_chunk",
14708
- sourceIdColumn: "id",
14709
- contentColumn: "chunk_text",
14710
- where: "source_type IN ('source_chunk', 'source_obsidian_chunk')",
14711
- scannedAt
14712
- });
14713
14548
  }
14714
14549
  function up131(db) {
14715
14550
  const table = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'dreaming_attention'").get();
@@ -14813,13 +14648,13 @@ function up133(db) {
14813
14648
  AND error IS NOT NULL;
14814
14649
  `);
14815
14650
  }
14816
- function tableExists3(db, table) {
14651
+ function tableExists2(db, table) {
14817
14652
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
14818
14653
  }
14819
14654
  function up134(db) {
14820
- if (!tableExists3(db, "memory_jobs"))
14655
+ if (!tableExists2(db, "memory_jobs"))
14821
14656
  return;
14822
- if (!tableExists3(db, "job_cancellations")) {
14657
+ if (!tableExists2(db, "job_cancellations")) {
14823
14658
  throw new Error("job_cancellations table missing; cannot retire structural jobs without an audit trail");
14824
14659
  }
14825
14660
  db.prepare(`
@@ -15048,12 +14883,12 @@ function up142(db) {
15048
14883
  if (!cols.has(name))
15049
14884
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
15050
14885
  }
15051
- function hasColumn25(db, table, column) {
14886
+ function hasColumn24(db, table, column) {
15052
14887
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
15053
14888
  return rows.some((row) => row.name === column);
15054
14889
  }
15055
14890
  function addColumnIfMissing28(db, table, column, definition) {
15056
- if (!hasColumn25(db, table, column))
14891
+ if (!hasColumn24(db, table, column))
15057
14892
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
15058
14893
  }
15059
14894
  function up143(db) {
@@ -15925,6 +15760,138 @@ function up162(db) {
15925
15760
  END;
15926
15761
  `);
15927
15762
  }
15763
+ function up163(db) {
15764
+ db.exec(`
15765
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_ai;
15766
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_au;
15767
+ DROP INDEX IF EXISTS idx_memory_content_safety_status;
15768
+ DROP INDEX IF EXISTS idx_memory_content_safety_eligibility;
15769
+ DROP TABLE IF EXISTS memory_content_safety;
15770
+ `);
15771
+ }
15772
+ var COLUMNS3 = ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"];
15773
+ function up164(db) {
15774
+ const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
15775
+ for (const column of COLUMNS3) {
15776
+ if (!cols.some((col) => col.name === column)) {
15777
+ db.exec(`ALTER TABLE entity_attributes ADD COLUMN ${column} TEXT`);
15778
+ }
15779
+ }
15780
+ }
15781
+ function up165(db) {
15782
+ const passColumns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
15783
+ if (!passColumns.some((column) => column.name === "scope_key")) {
15784
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN scope_key TEXT");
15785
+ }
15786
+ db.exec(`
15787
+ CREATE TABLE IF NOT EXISTS dreaming_history_nodes (
15788
+ agent_id TEXT NOT NULL,
15789
+ scope_key TEXT NOT NULL,
15790
+ level INTEGER NOT NULL,
15791
+ idx INTEGER NOT NULL,
15792
+ pass_id TEXT,
15793
+ text TEXT NOT NULL,
15794
+ tokens_input INTEGER,
15795
+ tokens_output INTEGER,
15796
+ tokens_cache_read INTEGER,
15797
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
15798
+ PRIMARY KEY (agent_id, scope_key, level, idx)
15799
+ );
15800
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_dreaming_history_nodes_pass
15801
+ ON dreaming_history_nodes(pass_id) WHERE pass_id IS NOT NULL;
15802
+ `);
15803
+ }
15804
+ function up166(db) {
15805
+ const columns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
15806
+ if (!columns.some((column) => column.name === "tokens_peak_context")) {
15807
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN tokens_peak_context INTEGER");
15808
+ }
15809
+ }
15810
+ function up167(db) {
15811
+ const sql = readMemoriesFtsSql(db);
15812
+ if (sql !== null && !memoriesFtsNeedsTokenizerRepair(sql))
15813
+ return;
15814
+ recreateMemoriesFts(db);
15815
+ }
15816
+ function hasTable5(db, table) {
15817
+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
15818
+ }
15819
+ function hasColumn25(db, table, column) {
15820
+ return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
15821
+ }
15822
+ function up168(db) {
15823
+ if (!hasTable5(db, "entity_attributes") || !hasTable5(db, "entity_aspects") || !hasTable5(db, "entities") || !hasColumn25(db, "entity_attributes", "source_root") || !hasColumn25(db, "entities", "source_root")) {
15824
+ return;
15825
+ }
15826
+ const now = new Date().toISOString();
15827
+ db.exec(`
15828
+ CREATE TEMP TABLE retired_source_paragraphs AS
15829
+ SELECT attr.id, attr.memory_id, attr.agent_id, asp.entity_id
15830
+ FROM entity_attributes attr
15831
+ JOIN entity_aspects asp ON asp.id = attr.aspect_id
15832
+ JOIN entities e ON e.id = asp.entity_id
15833
+ WHERE e.entity_type IN ('source_document', 'source_document_reference')
15834
+ AND attr.source_root IS NOT NULL
15835
+ AND attr.source_root = e.source_root
15836
+ AND attr.source_id = e.source_id
15837
+ AND attr.source_root NOT IN ('dreaming', 'dreaming_attention')
15838
+ `);
15839
+ if (hasColumn25(db, "entity_attributes", "memory_id") && hasTable5(db, "memories")) {
15840
+ if (hasTable5(db, "memory_history")) {
15841
+ db.prepare(`INSERT INTO memory_history (id, memory_id, event, old_content, new_content, changed_by, reason, metadata, created_at)
15842
+ SELECT lower(hex(randomblob(16))), mem.id, 'deleted', mem.content, NULL, 'migration:168',
15843
+ 'Source paragraph claims retired', '{"force":true}', ?
15844
+ FROM memories mem
15845
+ JOIN retired_source_paragraphs retired ON retired.memory_id = mem.id
15846
+ WHERE mem.is_deleted = 0`).run(now);
15847
+ }
15848
+ if (hasTable5(db, "derived_memory_sources") && hasColumn25(db, "memories", "stale_at")) {
15849
+ db.prepare(`UPDATE memories
15850
+ SET stale_at = ?
15851
+ WHERE stale_at IS NULL
15852
+ AND is_deleted = 0
15853
+ AND id IN (
15854
+ SELECT dms.derived_memory_id
15855
+ FROM derived_memory_sources dms
15856
+ JOIN retired_source_paragraphs retired ON retired.agent_id = dms.agent_id
15857
+ WHERE (dms.source_kind = 'memory' AND dms.source_id = retired.memory_id)
15858
+ OR (dms.source_kind = 'ontology_claim' AND dms.source_id = retired.id)
15859
+ )`).run(now);
15860
+ }
15861
+ const forget = [
15862
+ "is_deleted = 1",
15863
+ ...["deleted_at", "updated_at"].filter((column) => hasColumn25(db, "memories", column)).map((column) => `${column} = $now`),
15864
+ ...hasColumn25(db, "memories", "updated_by") ? ["updated_by = 'migration:168'"] : [],
15865
+ ...hasColumn25(db, "memories", "version") ? ["version = version + 1"] : []
15866
+ ];
15867
+ db.prepare(`UPDATE memories
15868
+ SET ${forget.join(", ")}
15869
+ WHERE is_deleted = 0
15870
+ AND id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)`).run({ $now: now });
15871
+ if (hasTable5(db, "memory_entity_mentions")) {
15872
+ db.exec(`
15873
+ DELETE FROM memory_entity_mentions
15874
+ WHERE memory_id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)
15875
+ `);
15876
+ }
15877
+ }
15878
+ if (hasTable5(db, "ontology_contradictions")) {
15879
+ db.prepare(`UPDATE ontology_contradictions
15880
+ SET status = 'resolved', resolved_at = ?, resolution_reason = 'source paragraph claims retired', updated_at = ?
15881
+ WHERE status = 'active'
15882
+ AND (left_attribute_id IN (SELECT id FROM retired_source_paragraphs)
15883
+ OR right_attribute_id IN (SELECT id FROM retired_source_paragraphs))`).run(now, now);
15884
+ }
15885
+ db.exec(`
15886
+ DELETE FROM entity_attributes WHERE id IN (SELECT id FROM retired_source_paragraphs);
15887
+ DELETE FROM entity_aspects
15888
+ WHERE entity_id IN (
15889
+ SELECT id FROM entities WHERE entity_type IN ('source_document', 'source_document_reference')
15890
+ )
15891
+ AND NOT EXISTS (SELECT 1 FROM entity_attributes attr WHERE attr.aspect_id = entity_aspects.id);
15892
+ DROP TABLE retired_source_paragraphs;
15893
+ `);
15894
+ }
15928
15895
  var MIGRATIONS = [
15929
15896
  {
15930
15897
  version: 1,
@@ -16934,8 +16901,7 @@ var MIGRATIONS = [
16934
16901
  {
16935
16902
  version: 125,
16936
16903
  name: "memory-content-safety",
16937
- up: up130,
16938
- artifacts: { tables: ["memory_content_safety"] }
16904
+ up: up130
16939
16905
  },
16940
16906
  {
16941
16907
  version: 126,
@@ -17237,6 +17203,48 @@ var MIGRATIONS = [
17237
17203
  name: "generic-entity-prune-scan-generation",
17238
17204
  up: up162,
17239
17205
  artifacts: { tables: ["generic_entity_prune_scan_state"] }
17206
+ },
17207
+ {
17208
+ version: 163,
17209
+ name: "retire-memory-content-safety",
17210
+ up: up163
17211
+ },
17212
+ {
17213
+ version: 164,
17214
+ name: "claim-event-time",
17215
+ up: up164,
17216
+ artifacts: {
17217
+ columns: ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"].map((column) => ({
17218
+ table: "entity_attributes",
17219
+ column
17220
+ }))
17221
+ }
17222
+ },
17223
+ {
17224
+ version: 165,
17225
+ name: "dreaming-history",
17226
+ up: up165,
17227
+ artifacts: {
17228
+ tables: ["dreaming_history_nodes"],
17229
+ indexes: ["idx_dreaming_history_nodes_pass"],
17230
+ columns: [{ table: "dreaming_passes", column: "scope_key" }]
17231
+ }
17232
+ },
17233
+ {
17234
+ version: 166,
17235
+ name: "dreaming-pass-peak-context",
17236
+ up: up166,
17237
+ artifacts: { columns: [{ table: "dreaming_passes", column: "tokens_peak_context" }] }
17238
+ },
17239
+ {
17240
+ version: 167,
17241
+ name: "memories-fts-porter",
17242
+ up: up167
17243
+ },
17244
+ {
17245
+ version: 168,
17246
+ name: "retire-source-paragraph-claims",
17247
+ up: up168
17240
17248
  }
17241
17249
  ];
17242
17250
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
@@ -17471,6 +17479,37 @@ var PIPELINE_PROVIDER_CHOICES = [
17471
17479
  var SYNTHESIS_PROVIDER_CHOICES = PIPELINE_PROVIDER_CHOICES.filter((provider) => provider !== "command");
17472
17480
  var PIPELINE_PROVIDER_SET = new Set(PIPELINE_PROVIDER_CHOICES);
17473
17481
  var SYNTHESIS_PROVIDER_SET = new Set(SYNTHESIS_PROVIDER_CHOICES);
17482
+ var SECRET_NAMES = "(?:access[_-]?token|api[_-]?key|apikey|auth[_-]?token|client[_-]?secret|passw(?:or)?d|refresh[_-]?token|private[_-]?key|secret(?:[_-]?key)?|token)";
17483
+ var SECRET_VALUE = `(?=[^\\s"',;&<>()\\[\\]{}$]*\\d)[^\\s"',;&<>()\\[\\]{}$]{8,}`;
17484
+ var PATTERNS = [
17485
+ {
17486
+ kind: "private_key",
17487
+ pattern: /-----BEGIN (?:[A-Z]+ )*PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )*PRIVATE KEY-----/g
17488
+ },
17489
+ {
17490
+ kind: "provider_key",
17491
+ pattern: /\b(?:(?:AKIA|ASIA)[0-9A-Z]{16}|github_pat_[A-Za-z0-9_]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|sk-(?:ant-|proj-)?[A-Za-z0-9_-]{20,}|(?:sk|rk)_(?:live|test)_[0-9A-Za-z]{16,}|xox[abprs]-[A-Za-z0-9-]{10,}|AIza[0-9A-Za-z_-]{35}|glpat-[A-Za-z0-9_-]{20,}|npm_[A-Za-z0-9]{36})\b/g
17492
+ },
17493
+ {
17494
+ kind: "jwt",
17495
+ pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
17496
+ },
17497
+ {
17498
+ kind: "bearer_token",
17499
+ pattern: /\bBearer\s+([A-Za-z0-9._~+/-]{16,}=*)/g,
17500
+ valueGroup: 1
17501
+ },
17502
+ {
17503
+ kind: "secret_assignment",
17504
+ pattern: new RegExp(`\\b${SECRET_NAMES}["']?\\s*[:=]\\s*["']?(${SECRET_VALUE})`, "gi"),
17505
+ valueGroup: 1
17506
+ },
17507
+ {
17508
+ kind: "secret_assignment",
17509
+ pattern: new RegExp(`\\b[A-Z][A-Z0-9_]*(?:API_KEY|TOKEN|SECRET|PASSWORD)\\s*=\\s*["']?(${SECRET_VALUE})`, "g"),
17510
+ valueGroup: 1
17511
+ }
17512
+ ];
17474
17513
  var LOOPBACK_HOST = "127.0.0.1";
17475
17514
  var LOCAL_BINDS = new Set([LOOPBACK_HOST, "localhost", "::1", "::ffff:127.0.0.1"]);
17476
17515
  var native = null;
@@ -30130,99 +30169,6 @@ var execFileHiddenImpl2 = (...args) => Reflect.apply(nodeExecFile2, undefined, w
30130
30169
  Object.defineProperty(execFileHiddenImpl2, promisify2.custom, {
30131
30170
  value: (...args) => Reflect.apply(nodeExecFileAsync2, undefined, withWindowsHideArgument2(args, 1))
30132
30171
  });
30133
- var MEMORY_CONTENT_SAFETY_POLICY_VERSION2 = "memory-content-safety-v1";
30134
- var MEMORY_CONTENT_SAFETY_REASONS2 = [
30135
- "prompt_injection",
30136
- "exfiltration",
30137
- "credential_harvesting",
30138
- "malicious_shell",
30139
- "tool_directive",
30140
- "invisible_unicode"
30141
- ];
30142
- var INVISIBLE_UNICODE_RE2 = /(?:\u034f|[\u00ad\u061c\u070f\u180e\u200b\u200c\u200e\u200f\u202a-\u202e\u2060\u2066-\u2069\u206a-\u206f\ufeff]|[\u{e0000}-\u{e007f}])/u;
30143
- var STRONG_DEFENSIVE_CONTEXT_RE2 = /\b(?:security\s+(?:guidance|discussion|analysis)|threat\s+model|defensive)\b/i;
30144
- var REPORTING_CONTEXT_RE2 = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b/i;
30145
- var REPORTING_BEFORE_RE2 = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b[\s\S]{0,80}\b(?:say\w*|read\w*|show\w*|flag\w*|detect\w*|describ\w*|demonstrat\w*|contain\w*|match\w*|pattern)\b/i;
30146
- var REPORTING_AFTER_RE2 = /\b(?:detector|scanner|classif\w*|flag\w*|pattern|dangerous|unsafe|malicious|hostile|should|would|must|never|do not|don't|avoid|quoted)\b/i;
30147
- var NEGATED_DIRECTIVE_RE2 = /\b(?:never|do not|don't|should not|must not|cannot|can't|avoid|prevent|detect|mitigat\w*)\b[\s\S]{0,80}$/i;
30148
- var PROMPT_INJECTION_RES2 = [
30149
- /\b(?:ignore|disregard|override|forget|bypass)\b[\s\S]{0,100}\b(?:previous|prior|above|earlier|system|developer|assistant|safety|security)?\s*(?:instructions?|rules?|prompt|message)\b/i,
30150
- /\b(?:new|following|these)\s+(?:(?:system|developer|assistant|hidden)\s+)?instructions?\b/i,
30151
- /(?:^|\n)\s*(?:system|developer|instruction|prompt)\s*:/im,
30152
- /<\s*(?:system|developer|assistant|instruction|prompt)\b[^>]*>/i,
30153
- /\b(?:you are now|act as|roleplay as|pretend to be)\b[\s\S]{0,80}\b(?:system|admin|developer|unrestricted|jailbreak|different agent)\b/i
30154
- ];
30155
- var TOOL_DIRECTIVE_RES2 = [
30156
- /<\s*(?:tool[_-]?call|function[_-]?call|invoke|tool)\b/i,
30157
- /\b(?:assistant|system)\s+to\s*=\s*[a-z0-9_.-]+/i,
30158
- /\b(?:call|invoke|use|run|execute)\s+(?:the\s+)?[a-z0-9_.-]+\s+tool\b/i
30159
- ];
30160
- var EXFILTRATION_RE2 = /\b(?:reveal|show|print|send|upload|exfiltrat\w*|dump|forward|leak|transmit|export)\b[\s\S]{0,120}(?:\b(?:system\s+prompt|hidden\s+instructions?|secret(?:s)?|credential(?:s)?|password(?:s)?|api\s*keys?|tokens?|private\s+keys?|environment\s+variables?)\b|\.env\b|~\/(?:\.ssh)\/\S+|\/etc\/(?:shadow|passwd)\b)/i;
30161
- var EXFILTRATION_REVERSE2 = /(?:\b(?:system\s+prompt|hidden\s+instructions?|secret(?:s)?|credential(?:s)?|password(?:s)?|api\s*keys?|tokens?|private\s+keys?|environment\s+variables?)\b|\.env\b|~\/(?:\.ssh)\/\S+|\/etc\/(?:shadow|passwd)\b)[\s\S]{0,120}\b(?:reveal|show|print|send|upload|exfiltrat\w*|dump|forward|leak|transmit|export)\b/i;
30162
- var CREDENTIAL_HARVESTING_RE2 = /\b(?:enter|paste|provide|share|send|give|submit|type|hand over)\b[\s\S]{0,80}\b(?:password|api\s*key|token|secret|credential|private\s+key)\b/i;
30163
- var DANGEROUS_SHELL_RE2 = /\b(?:curl|wget)\b[^\n]{0,240}\|\s*(?:ba|z|fi)?sh\b|\brm\s+-rf\s+(?:\/|~|\.ssh)[^\n]{0,240}|\b(?:cat|head|tail)\s+~\/?\.ssh\/(?:id_[a-z]+|authorized_keys)\b|\b(?:printenv|env)\b[^\n]{0,120}\b(?:curl|wget|send|upload|post)\b/i;
30164
- function matchHasDefensiveContext2(content, match) {
30165
- if (!match || !match[0])
30166
- return false;
30167
- const start = match.index ?? 0;
30168
- const before = content.slice(Math.max(0, start - 120), start);
30169
- const after = content.slice(start + match[0].length, start + match[0].length + 160);
30170
- return STRONG_DEFENSIVE_CONTEXT_RE2.test(match[0]) || NEGATED_DIRECTIVE_RE2.test(before) || STRONG_DEFENSIVE_CONTEXT_RE2.test(before) || STRONG_DEFENSIVE_CONTEXT_RE2.test(after) || REPORTING_BEFORE_RE2.test(before) || REPORTING_CONTEXT_RE2.test(before) && REPORTING_AFTER_RE2.test(after);
30171
- }
30172
- function hasActionableMatch2(content, patterns) {
30173
- return patterns.some((pattern) => {
30174
- const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
30175
- const searchable = new RegExp(pattern.source, flags);
30176
- let match;
30177
- while ((match = searchable.exec(content)) !== null) {
30178
- if (!matchHasDefensiveContext2(content, match))
30179
- return true;
30180
- if (match[0].length === 0)
30181
- searchable.lastIndex += 1;
30182
- }
30183
- return false;
30184
- });
30185
- }
30186
- function hasDangerousShell2(content) {
30187
- const searchable = new RegExp(DANGEROUS_SHELL_RE2.source, `${DANGEROUS_SHELL_RE2.flags}g`);
30188
- let match;
30189
- while ((match = searchable.exec(content)) !== null) {
30190
- if (matchHasDefensiveContext2(content, match))
30191
- continue;
30192
- const end = (match.index ?? 0) + match[0].length;
30193
- const after = content.slice(end, end + 160);
30194
- if (!STRONG_DEFENSIVE_CONTEXT_RE2.test(after) && !REPORTING_AFTER_RE2.test(after))
30195
- return true;
30196
- if (match[0].length === 0)
30197
- searchable.lastIndex += 1;
30198
- }
30199
- return false;
30200
- }
30201
- function scanMemoryContent2(content) {
30202
- const raw = typeof content === "string" ? content : String(content ?? "");
30203
- const normalized = raw.normalize("NFKC");
30204
- const reasons = new Set;
30205
- if (INVISIBLE_UNICODE_RE2.test(raw))
30206
- reasons.add("invisible_unicode");
30207
- if (hasActionableMatch2(normalized, PROMPT_INJECTION_RES2))
30208
- reasons.add("prompt_injection");
30209
- if (hasActionableMatch2(normalized, TOOL_DIRECTIVE_RES2))
30210
- reasons.add("tool_directive");
30211
- if (hasActionableMatch2(normalized, [EXFILTRATION_RE2, EXFILTRATION_REVERSE2]))
30212
- reasons.add("exfiltration");
30213
- if (hasActionableMatch2(normalized, [CREDENTIAL_HARVESTING_RE2]))
30214
- reasons.add("credential_harvesting");
30215
- if (hasDangerousShell2(normalized))
30216
- reasons.add("malicious_shell");
30217
- const orderedReasons = MEMORY_CONTENT_SAFETY_REASONS2.filter((reason) => reasons.has(reason));
30218
- const status = orderedReasons.length === 0 ? "clean" : orderedReasons.every((reason) => reason === "invisible_unicode") ? "tainted" : "blocked";
30219
- return {
30220
- status,
30221
- contextEligible: status === "clean",
30222
- reasons: orderedReasons,
30223
- policyVersion: MEMORY_CONTENT_SAFETY_POLICY_VERSION2
30224
- };
30225
- }
30226
30172
  var DAEMON_DERIVED_MEMORY_SOURCE_TYPES2 = [
30227
30173
  "extract",
30228
30174
  "aggregate-recall",
@@ -30230,7 +30176,7 @@ var DAEMON_DERIVED_MEMORY_SOURCE_TYPES2 = [
30230
30176
  "checkpoint",
30231
30177
  "dreaming"
30232
30178
  ];
30233
- function up163(db) {
30179
+ function up169(db) {
30234
30180
  const hasColumn = (table, column) => {
30235
30181
  const statement = db.prepare(`SELECT 1 FROM pragma_table_info('${table}') WHERE name = ?`);
30236
30182
  try {
@@ -30345,7 +30291,7 @@ function up410(db) {
30345
30291
  function up510(db) {
30346
30292
  db.exec("DROP TABLE IF EXISTS mcp_invocations");
30347
30293
  }
30348
- var MEMORIES_FTS_TOKENIZER2 = "unicode61";
30294
+ var MEMORIES_FTS_TOKENIZER2 = "porter unicode61";
30349
30295
  var FTS_STATE_TABLE2 = "memories_fts_state";
30350
30296
  function normalizeSql2(sql) {
30351
30297
  return sql.replace(/\s+/g, " ").trim().toLowerCase();
@@ -30455,10 +30401,7 @@ function readMemoriesFtsSql2(db) {
30455
30401
  function memoriesFtsNeedsTokenizerRepair2(sql) {
30456
30402
  if (sql === null)
30457
30403
  return false;
30458
- const normalized = normalizeSql2(sql);
30459
- if (normalized.includes("porter unicode61"))
30460
- return true;
30461
- return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
30404
+ return !normalizeSql2(sql).includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
30462
30405
  }
30463
30406
  function up610(db) {
30464
30407
  db.exec(`
@@ -30883,7 +30826,7 @@ function up1510(db) {
30883
30826
  )
30884
30827
  `);
30885
30828
  }
30886
- function up164(db) {
30829
+ function up1610(db) {
30887
30830
  db.exec(`
30888
30831
  CREATE TABLE IF NOT EXISTS session_scores (
30889
30832
  id TEXT PRIMARY KEY,
@@ -32104,7 +32047,7 @@ function up542(db) {
32104
32047
  );
32105
32048
  `);
32106
32049
  }
32107
- function hasTable5(db, name) {
32050
+ function hasTable6(db, name) {
32108
32051
  return db.prepare(`SELECT name
32109
32052
  FROM sqlite_master
32110
32053
  WHERE type = 'table' AND name = ?
@@ -32134,7 +32077,7 @@ function up552(db) {
32134
32077
  CREATE INDEX IF NOT EXISTS idx_entity_dependency_history_created
32135
32078
  ON entity_dependency_history(created_at DESC);
32136
32079
  `);
32137
- if (!hasTable5(db, "entity_dependencies"))
32080
+ if (!hasTable6(db, "entity_dependencies"))
32138
32081
  return;
32139
32082
  db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_insert");
32140
32083
  db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_update");
@@ -33113,9 +33056,9 @@ function hasColumn112(db, table, column) {
33113
33056
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
33114
33057
  return rows.some((row) => row.name === column);
33115
33058
  }
33116
- var COLUMNS3 = ["harness", "session_id", "tool_use_id", "cwd", "origin", "args"];
33059
+ var COLUMNS4 = ["harness", "session_id", "tool_use_id", "cwd", "origin", "args"];
33117
33060
  function up872(db) {
33118
- for (const column of COLUMNS3) {
33061
+ for (const column of COLUMNS4) {
33119
33062
  if (!hasColumn112(db, "skill_invocations", column)) {
33120
33063
  db.exec(`ALTER TABLE skill_invocations ADD COLUMN ${column} TEXT`);
33121
33064
  }
@@ -33679,7 +33622,7 @@ function up1082(db) {
33679
33622
  )
33680
33623
  `);
33681
33624
  }
33682
- function tableExists4(db, table) {
33625
+ function tableExists3(db, table) {
33683
33626
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) !== undefined;
33684
33627
  }
33685
33628
  function hasColumn162(db, table, column) {
@@ -33701,7 +33644,7 @@ function up1092(db) {
33701
33644
  CREATE INDEX IF NOT EXISTS idx_derived_memory_sources_source
33702
33645
  ON derived_memory_sources(agent_id, source_kind, source_id);
33703
33646
  `);
33704
- if (tableExists4(db, "aggregate_evidence_sources")) {
33647
+ if (tableExists3(db, "aggregate_evidence_sources")) {
33705
33648
  db.exec(`
33706
33649
  INSERT OR IGNORE INTO derived_memory_sources
33707
33650
  (derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
@@ -33709,7 +33652,7 @@ function up1092(db) {
33709
33652
  FROM aggregate_evidence_sources
33710
33653
  `);
33711
33654
  }
33712
- if (tableExists4(db, "aggregate_memory_sources")) {
33655
+ if (tableExists3(db, "aggregate_memory_sources")) {
33713
33656
  db.exec(`
33714
33657
  INSERT OR IGNORE INTO derived_memory_sources
33715
33658
  (derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
@@ -33717,10 +33660,10 @@ function up1092(db) {
33717
33660
  FROM aggregate_memory_sources
33718
33661
  `);
33719
33662
  }
33720
- if (tableExists4(db, "memories") && !hasColumn162(db, "memories", "stale_at")) {
33663
+ if (tableExists3(db, "memories") && !hasColumn162(db, "memories", "stale_at")) {
33721
33664
  db.exec("ALTER TABLE memories ADD COLUMN stale_at TEXT");
33722
33665
  }
33723
- if (tableExists4(db, "memories")) {
33666
+ if (tableExists3(db, "memories")) {
33724
33667
  db.exec(`
33725
33668
  CREATE INDEX IF NOT EXISTS idx_memories_stale_derived
33726
33669
  ON memories(agent_id, stale_at)
@@ -34371,38 +34314,6 @@ function up1292(db) {
34371
34314
  ON imported_source_lifecycle(agent_id, status, updated_at DESC);
34372
34315
  `);
34373
34316
  }
34374
- function tableExists22(db, table) {
34375
- return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
34376
- }
34377
- function hasColumn242(db, table, column) {
34378
- return db.prepare(`PRAGMA table_info("${table}")`).all().some((row) => row.name === column);
34379
- }
34380
- function backfill2(db, rows, sourceKind, scannedAt) {
34381
- const statement = db.prepare(`INSERT INTO memory_content_safety
34382
- (agent_id, source_kind, source_id, status, context_eligible, reasons_json, policy_version, scanned_at)
34383
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
34384
- ON CONFLICT(agent_id, source_kind, source_id) DO UPDATE SET
34385
- status = excluded.status,
34386
- context_eligible = excluded.context_eligible,
34387
- reasons_json = excluded.reasons_json,
34388
- policy_version = excluded.policy_version,
34389
- scanned_at = excluded.scanned_at`);
34390
- for (const row of rows) {
34391
- const sourceId = row.source_id?.trim();
34392
- if (!sourceId)
34393
- continue;
34394
- const assessment = scanMemoryContent2(row.content ?? "");
34395
- statement.run(row.agent_id?.trim() || "default", sourceKind, sourceId, assessment.status, assessment.contextEligible ? 1 : 0, JSON.stringify(assessment.reasons), MEMORY_CONTENT_SAFETY_POLICY_VERSION2, scannedAt);
34396
- }
34397
- }
34398
- function backfillTable2(db, params) {
34399
- if (!tableExists22(db, params.table) || !hasColumn242(db, params.table, params.sourceIdColumn) || !hasColumn242(db, params.table, params.contentColumn))
34400
- return;
34401
- const agentColumn = hasColumn242(db, params.table, "agent_id") ? "COALESCE(NULLIF(TRIM(agent_id), ''), 'default')" : "'default'";
34402
- const rows = db.prepare(`SELECT ${agentColumn} AS agent_id, ${params.sourceIdColumn} AS source_id, ${params.contentColumn} AS content
34403
- FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
34404
- backfill2(db, rows, params.sourceKind, params.scannedAt);
34405
- }
34406
34317
  function up1302(db) {
34407
34318
  db.exec(`
34408
34319
  CREATE TABLE IF NOT EXISTS memory_content_safety (
@@ -34422,43 +34333,6 @@ function up1302(db) {
34422
34333
  CREATE INDEX IF NOT EXISTS idx_memory_content_safety_eligibility
34423
34334
  ON memory_content_safety(agent_id, source_kind, context_eligible);
34424
34335
  `);
34425
- const scannedAt = new Date().toISOString();
34426
- backfillTable2(db, {
34427
- table: "memories",
34428
- sourceKind: "memory",
34429
- sourceIdColumn: "id",
34430
- contentColumn: "content",
34431
- scannedAt
34432
- });
34433
- backfillTable2(db, {
34434
- table: "memory_artifacts",
34435
- sourceKind: "artifact",
34436
- sourceIdColumn: "source_path",
34437
- contentColumn: "content",
34438
- scannedAt
34439
- });
34440
- backfillTable2(db, {
34441
- table: "session_transcripts",
34442
- sourceKind: "transcript",
34443
- sourceIdColumn: "session_key",
34444
- contentColumn: "content",
34445
- scannedAt
34446
- });
34447
- backfillTable2(db, {
34448
- table: "session_summaries",
34449
- sourceKind: "summary",
34450
- sourceIdColumn: "id",
34451
- contentColumn: "content",
34452
- scannedAt
34453
- });
34454
- backfillTable2(db, {
34455
- table: "embeddings",
34456
- sourceKind: "source_chunk",
34457
- sourceIdColumn: "id",
34458
- contentColumn: "chunk_text",
34459
- where: "source_type IN ('source_chunk', 'source_obsidian_chunk')",
34460
- scannedAt
34461
- });
34462
34336
  }
34463
34337
  function up1312(db) {
34464
34338
  const table = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'dreaming_attention'").get();
@@ -34562,13 +34436,13 @@ function up1332(db) {
34562
34436
  AND error IS NOT NULL;
34563
34437
  `);
34564
34438
  }
34565
- function tableExists32(db, table) {
34439
+ function tableExists22(db, table) {
34566
34440
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
34567
34441
  }
34568
34442
  function up1342(db) {
34569
- if (!tableExists32(db, "memory_jobs"))
34443
+ if (!tableExists22(db, "memory_jobs"))
34570
34444
  return;
34571
- if (!tableExists32(db, "job_cancellations")) {
34445
+ if (!tableExists22(db, "job_cancellations")) {
34572
34446
  throw new Error("job_cancellations table missing; cannot retire structural jobs without an audit trail");
34573
34447
  }
34574
34448
  db.prepare(`
@@ -34797,12 +34671,12 @@ function up1422(db) {
34797
34671
  if (!cols.has(name))
34798
34672
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
34799
34673
  }
34800
- function hasColumn252(db, table, column) {
34674
+ function hasColumn242(db, table, column) {
34801
34675
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
34802
34676
  return rows.some((row) => row.name === column);
34803
34677
  }
34804
34678
  function addColumnIfMissing282(db, table, column, definition) {
34805
- if (!hasColumn252(db, table, column))
34679
+ if (!hasColumn242(db, table, column))
34806
34680
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
34807
34681
  }
34808
34682
  function up1432(db) {
@@ -35674,6 +35548,138 @@ function up1622(db) {
35674
35548
  END;
35675
35549
  `);
35676
35550
  }
35551
+ function up1632(db) {
35552
+ db.exec(`
35553
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_ai;
35554
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_au;
35555
+ DROP INDEX IF EXISTS idx_memory_content_safety_status;
35556
+ DROP INDEX IF EXISTS idx_memory_content_safety_eligibility;
35557
+ DROP TABLE IF EXISTS memory_content_safety;
35558
+ `);
35559
+ }
35560
+ var COLUMNS32 = ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"];
35561
+ function up1642(db) {
35562
+ const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
35563
+ for (const column of COLUMNS32) {
35564
+ if (!cols.some((col) => col.name === column)) {
35565
+ db.exec(`ALTER TABLE entity_attributes ADD COLUMN ${column} TEXT`);
35566
+ }
35567
+ }
35568
+ }
35569
+ function up1652(db) {
35570
+ const passColumns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
35571
+ if (!passColumns.some((column) => column.name === "scope_key")) {
35572
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN scope_key TEXT");
35573
+ }
35574
+ db.exec(`
35575
+ CREATE TABLE IF NOT EXISTS dreaming_history_nodes (
35576
+ agent_id TEXT NOT NULL,
35577
+ scope_key TEXT NOT NULL,
35578
+ level INTEGER NOT NULL,
35579
+ idx INTEGER NOT NULL,
35580
+ pass_id TEXT,
35581
+ text TEXT NOT NULL,
35582
+ tokens_input INTEGER,
35583
+ tokens_output INTEGER,
35584
+ tokens_cache_read INTEGER,
35585
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
35586
+ PRIMARY KEY (agent_id, scope_key, level, idx)
35587
+ );
35588
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_dreaming_history_nodes_pass
35589
+ ON dreaming_history_nodes(pass_id) WHERE pass_id IS NOT NULL;
35590
+ `);
35591
+ }
35592
+ function up1662(db) {
35593
+ const columns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
35594
+ if (!columns.some((column) => column.name === "tokens_peak_context")) {
35595
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN tokens_peak_context INTEGER");
35596
+ }
35597
+ }
35598
+ function up1672(db) {
35599
+ const sql = readMemoriesFtsSql2(db);
35600
+ if (sql !== null && !memoriesFtsNeedsTokenizerRepair2(sql))
35601
+ return;
35602
+ recreateMemoriesFts2(db);
35603
+ }
35604
+ function hasTable52(db, table) {
35605
+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
35606
+ }
35607
+ function hasColumn252(db, table, column) {
35608
+ return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
35609
+ }
35610
+ function up1682(db) {
35611
+ if (!hasTable52(db, "entity_attributes") || !hasTable52(db, "entity_aspects") || !hasTable52(db, "entities") || !hasColumn252(db, "entity_attributes", "source_root") || !hasColumn252(db, "entities", "source_root")) {
35612
+ return;
35613
+ }
35614
+ const now = new Date().toISOString();
35615
+ db.exec(`
35616
+ CREATE TEMP TABLE retired_source_paragraphs AS
35617
+ SELECT attr.id, attr.memory_id, attr.agent_id, asp.entity_id
35618
+ FROM entity_attributes attr
35619
+ JOIN entity_aspects asp ON asp.id = attr.aspect_id
35620
+ JOIN entities e ON e.id = asp.entity_id
35621
+ WHERE e.entity_type IN ('source_document', 'source_document_reference')
35622
+ AND attr.source_root IS NOT NULL
35623
+ AND attr.source_root = e.source_root
35624
+ AND attr.source_id = e.source_id
35625
+ AND attr.source_root NOT IN ('dreaming', 'dreaming_attention')
35626
+ `);
35627
+ if (hasColumn252(db, "entity_attributes", "memory_id") && hasTable52(db, "memories")) {
35628
+ if (hasTable52(db, "memory_history")) {
35629
+ db.prepare(`INSERT INTO memory_history (id, memory_id, event, old_content, new_content, changed_by, reason, metadata, created_at)
35630
+ SELECT lower(hex(randomblob(16))), mem.id, 'deleted', mem.content, NULL, 'migration:168',
35631
+ 'Source paragraph claims retired', '{"force":true}', ?
35632
+ FROM memories mem
35633
+ JOIN retired_source_paragraphs retired ON retired.memory_id = mem.id
35634
+ WHERE mem.is_deleted = 0`).run(now);
35635
+ }
35636
+ if (hasTable52(db, "derived_memory_sources") && hasColumn252(db, "memories", "stale_at")) {
35637
+ db.prepare(`UPDATE memories
35638
+ SET stale_at = ?
35639
+ WHERE stale_at IS NULL
35640
+ AND is_deleted = 0
35641
+ AND id IN (
35642
+ SELECT dms.derived_memory_id
35643
+ FROM derived_memory_sources dms
35644
+ JOIN retired_source_paragraphs retired ON retired.agent_id = dms.agent_id
35645
+ WHERE (dms.source_kind = 'memory' AND dms.source_id = retired.memory_id)
35646
+ OR (dms.source_kind = 'ontology_claim' AND dms.source_id = retired.id)
35647
+ )`).run(now);
35648
+ }
35649
+ const forget = [
35650
+ "is_deleted = 1",
35651
+ ...["deleted_at", "updated_at"].filter((column) => hasColumn252(db, "memories", column)).map((column) => `${column} = $now`),
35652
+ ...hasColumn252(db, "memories", "updated_by") ? ["updated_by = 'migration:168'"] : [],
35653
+ ...hasColumn252(db, "memories", "version") ? ["version = version + 1"] : []
35654
+ ];
35655
+ db.prepare(`UPDATE memories
35656
+ SET ${forget.join(", ")}
35657
+ WHERE is_deleted = 0
35658
+ AND id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)`).run({ $now: now });
35659
+ if (hasTable52(db, "memory_entity_mentions")) {
35660
+ db.exec(`
35661
+ DELETE FROM memory_entity_mentions
35662
+ WHERE memory_id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)
35663
+ `);
35664
+ }
35665
+ }
35666
+ if (hasTable52(db, "ontology_contradictions")) {
35667
+ db.prepare(`UPDATE ontology_contradictions
35668
+ SET status = 'resolved', resolved_at = ?, resolution_reason = 'source paragraph claims retired', updated_at = ?
35669
+ WHERE status = 'active'
35670
+ AND (left_attribute_id IN (SELECT id FROM retired_source_paragraphs)
35671
+ OR right_attribute_id IN (SELECT id FROM retired_source_paragraphs))`).run(now, now);
35672
+ }
35673
+ db.exec(`
35674
+ DELETE FROM entity_attributes WHERE id IN (SELECT id FROM retired_source_paragraphs);
35675
+ DELETE FROM entity_aspects
35676
+ WHERE entity_id IN (
35677
+ SELECT id FROM entities WHERE entity_type IN ('source_document', 'source_document_reference')
35678
+ )
35679
+ AND NOT EXISTS (SELECT 1 FROM entity_attributes attr WHERE attr.aspect_id = entity_aspects.id);
35680
+ DROP TABLE retired_source_paragraphs;
35681
+ `);
35682
+ }
35677
35683
  var MIGRATIONS2 = [
35678
35684
  {
35679
35685
  version: 1,
@@ -35744,7 +35750,7 @@ var MIGRATIONS2 = [
35744
35750
  {
35745
35751
  version: 11,
35746
35752
  name: "session-scores",
35747
- up: up164,
35753
+ up: up1610,
35748
35754
  artifacts: { tables: ["session_scores"] }
35749
35755
  },
35750
35756
  {
@@ -36683,8 +36689,7 @@ var MIGRATIONS2 = [
36683
36689
  {
36684
36690
  version: 125,
36685
36691
  name: "memory-content-safety",
36686
- up: up1302,
36687
- artifacts: { tables: ["memory_content_safety"] }
36692
+ up: up1302
36688
36693
  },
36689
36694
  {
36690
36695
  version: 126,
@@ -36878,7 +36883,7 @@ var MIGRATIONS2 = [
36878
36883
  {
36879
36884
  version: 151,
36880
36885
  name: "transcript-import-bytes",
36881
- up: up163,
36886
+ up: up169,
36882
36887
  artifacts: {
36883
36888
  tables: [
36884
36889
  "source_import_chunks",
@@ -36986,6 +36991,48 @@ var MIGRATIONS2 = [
36986
36991
  name: "generic-entity-prune-scan-generation",
36987
36992
  up: up1622,
36988
36993
  artifacts: { tables: ["generic_entity_prune_scan_state"] }
36994
+ },
36995
+ {
36996
+ version: 163,
36997
+ name: "retire-memory-content-safety",
36998
+ up: up1632
36999
+ },
37000
+ {
37001
+ version: 164,
37002
+ name: "claim-event-time",
37003
+ up: up1642,
37004
+ artifacts: {
37005
+ columns: ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"].map((column) => ({
37006
+ table: "entity_attributes",
37007
+ column
37008
+ }))
37009
+ }
37010
+ },
37011
+ {
37012
+ version: 165,
37013
+ name: "dreaming-history",
37014
+ up: up1652,
37015
+ artifacts: {
37016
+ tables: ["dreaming_history_nodes"],
37017
+ indexes: ["idx_dreaming_history_nodes_pass"],
37018
+ columns: [{ table: "dreaming_passes", column: "scope_key" }]
37019
+ }
37020
+ },
37021
+ {
37022
+ version: 166,
37023
+ name: "dreaming-pass-peak-context",
37024
+ up: up1662,
37025
+ artifacts: { columns: [{ table: "dreaming_passes", column: "tokens_peak_context" }] }
37026
+ },
37027
+ {
37028
+ version: 167,
37029
+ name: "memories-fts-porter",
37030
+ up: up1672
37031
+ },
37032
+ {
37033
+ version: 168,
37034
+ name: "retire-source-paragraph-claims",
37035
+ up: up1682
36989
37036
  }
36990
37037
  ];
36991
37038
  var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
@@ -37227,6 +37274,37 @@ var PIPELINE_PROVIDER_CHOICES2 = [
37227
37274
  var SYNTHESIS_PROVIDER_CHOICES2 = PIPELINE_PROVIDER_CHOICES2.filter((provider) => provider !== "command");
37228
37275
  var PIPELINE_PROVIDER_SET2 = new Set(PIPELINE_PROVIDER_CHOICES2);
37229
37276
  var SYNTHESIS_PROVIDER_SET2 = new Set(SYNTHESIS_PROVIDER_CHOICES2);
37277
+ var SECRET_NAMES2 = "(?:access[_-]?token|api[_-]?key|apikey|auth[_-]?token|client[_-]?secret|passw(?:or)?d|refresh[_-]?token|private[_-]?key|secret(?:[_-]?key)?|token)";
37278
+ var SECRET_VALUE2 = `(?=[^\\s"',;&<>()\\[\\]{}$]*\\d)[^\\s"',;&<>()\\[\\]{}$]{8,}`;
37279
+ var PATTERNS2 = [
37280
+ {
37281
+ kind: "private_key",
37282
+ pattern: /-----BEGIN (?:[A-Z]+ )*PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )*PRIVATE KEY-----/g
37283
+ },
37284
+ {
37285
+ kind: "provider_key",
37286
+ pattern: /\b(?:(?:AKIA|ASIA)[0-9A-Z]{16}|github_pat_[A-Za-z0-9_]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|sk-(?:ant-|proj-)?[A-Za-z0-9_-]{20,}|(?:sk|rk)_(?:live|test)_[0-9A-Za-z]{16,}|xox[abprs]-[A-Za-z0-9-]{10,}|AIza[0-9A-Za-z_-]{35}|glpat-[A-Za-z0-9_-]{20,}|npm_[A-Za-z0-9]{36})\b/g
37287
+ },
37288
+ {
37289
+ kind: "jwt",
37290
+ pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
37291
+ },
37292
+ {
37293
+ kind: "bearer_token",
37294
+ pattern: /\bBearer\s+([A-Za-z0-9._~+/-]{16,}=*)/g,
37295
+ valueGroup: 1
37296
+ },
37297
+ {
37298
+ kind: "secret_assignment",
37299
+ pattern: new RegExp(`\\b${SECRET_NAMES2}["']?\\s*[:=]\\s*["']?(${SECRET_VALUE2})`, "gi"),
37300
+ valueGroup: 1
37301
+ },
37302
+ {
37303
+ kind: "secret_assignment",
37304
+ pattern: new RegExp(`\\b[A-Z][A-Z0-9_]*(?:API_KEY|TOKEN|SECRET|PASSWORD)\\s*=\\s*["']?(${SECRET_VALUE2})`, "g"),
37305
+ valueGroup: 1
37306
+ }
37307
+ ];
37230
37308
  var LOOPBACK_HOST2 = "127.0.0.1";
37231
37309
  var LOCAL_BINDS2 = new Set([LOOPBACK_HOST2, "localhost", "::1", "::ffff:127.0.0.1"]);
37232
37310
  var native2 = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-openclaw",
3
- "version": "0.236.1",
3
+ "version": "0.237.0",
4
4
  "description": "Signet connector for OpenClaw - configures workspace and memory hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,8 +25,8 @@
25
25
  "test": "bun test"
26
26
  },
27
27
  "dependencies": {
28
- "@signetai/connector-base": "0.236.1",
29
- "@signetai/core": "0.236.1"
28
+ "@signetai/connector-base": "0.237.0",
29
+ "@signetai/core": "0.237.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.0.0",