@signetai/connector-forge 0.236.0 → 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
@@ -10408,99 +10408,6 @@ var execFileHiddenImpl = (...args) => Reflect.apply(nodeExecFile, undefined, wit
10408
10408
  Object.defineProperty(execFileHiddenImpl, promisify.custom, {
10409
10409
  value: (...args) => Reflect.apply(nodeExecFileAsync, undefined, withWindowsHideArgument(args, 1))
10410
10410
  });
10411
- var MEMORY_CONTENT_SAFETY_POLICY_VERSION = "memory-content-safety-v1";
10412
- var MEMORY_CONTENT_SAFETY_REASONS = [
10413
- "prompt_injection",
10414
- "exfiltration",
10415
- "credential_harvesting",
10416
- "malicious_shell",
10417
- "tool_directive",
10418
- "invisible_unicode"
10419
- ];
10420
- 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;
10421
- var STRONG_DEFENSIVE_CONTEXT_RE = /\b(?:security\s+(?:guidance|discussion|analysis)|threat\s+model|defensive)\b/i;
10422
- var REPORTING_CONTEXT_RE = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b/i;
10423
- 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;
10424
- 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;
10425
- 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;
10426
- var PROMPT_INJECTION_RES = [
10427
- /\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,
10428
- /\b(?:new|following|these)\s+(?:(?:system|developer|assistant|hidden)\s+)?instructions?\b/i,
10429
- /(?:^|\n)\s*(?:system|developer|instruction|prompt)\s*:/im,
10430
- /<\s*(?:system|developer|assistant|instruction|prompt)\b[^>]*>/i,
10431
- /\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
10432
- ];
10433
- var TOOL_DIRECTIVE_RES = [
10434
- /<\s*(?:tool[_-]?call|function[_-]?call|invoke|tool)\b/i,
10435
- /\b(?:assistant|system)\s+to\s*=\s*[a-z0-9_.-]+/i,
10436
- /\b(?:call|invoke|use|run|execute)\s+(?:the\s+)?[a-z0-9_.-]+\s+tool\b/i
10437
- ];
10438
- 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;
10439
- 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;
10440
- 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;
10441
- 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;
10442
- function matchHasDefensiveContext(content, match) {
10443
- if (!match || !match[0])
10444
- return false;
10445
- const start = match.index ?? 0;
10446
- const before = content.slice(Math.max(0, start - 120), start);
10447
- const after = content.slice(start + match[0].length, start + match[0].length + 160);
10448
- 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);
10449
- }
10450
- function hasActionableMatch(content, patterns) {
10451
- return patterns.some((pattern) => {
10452
- const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
10453
- const searchable = new RegExp(pattern.source, flags);
10454
- let match;
10455
- while ((match = searchable.exec(content)) !== null) {
10456
- if (!matchHasDefensiveContext(content, match))
10457
- return true;
10458
- if (match[0].length === 0)
10459
- searchable.lastIndex += 1;
10460
- }
10461
- return false;
10462
- });
10463
- }
10464
- function hasDangerousShell(content) {
10465
- const searchable = new RegExp(DANGEROUS_SHELL_RE.source, `${DANGEROUS_SHELL_RE.flags}g`);
10466
- let match;
10467
- while ((match = searchable.exec(content)) !== null) {
10468
- if (matchHasDefensiveContext(content, match))
10469
- continue;
10470
- const end = (match.index ?? 0) + match[0].length;
10471
- const after = content.slice(end, end + 160);
10472
- if (!STRONG_DEFENSIVE_CONTEXT_RE.test(after) && !REPORTING_AFTER_RE.test(after))
10473
- return true;
10474
- if (match[0].length === 0)
10475
- searchable.lastIndex += 1;
10476
- }
10477
- return false;
10478
- }
10479
- function scanMemoryContent(content) {
10480
- const raw = typeof content === "string" ? content : String(content ?? "");
10481
- const normalized = raw.normalize("NFKC");
10482
- const reasons = new Set;
10483
- if (INVISIBLE_UNICODE_RE.test(raw))
10484
- reasons.add("invisible_unicode");
10485
- if (hasActionableMatch(normalized, PROMPT_INJECTION_RES))
10486
- reasons.add("prompt_injection");
10487
- if (hasActionableMatch(normalized, TOOL_DIRECTIVE_RES))
10488
- reasons.add("tool_directive");
10489
- if (hasActionableMatch(normalized, [EXFILTRATION_RE, EXFILTRATION_REVERSE]))
10490
- reasons.add("exfiltration");
10491
- if (hasActionableMatch(normalized, [CREDENTIAL_HARVESTING_RE]))
10492
- reasons.add("credential_harvesting");
10493
- if (hasDangerousShell(normalized))
10494
- reasons.add("malicious_shell");
10495
- const orderedReasons = MEMORY_CONTENT_SAFETY_REASONS.filter((reason) => reasons.has(reason));
10496
- const status = orderedReasons.length === 0 ? "clean" : orderedReasons.every((reason) => reason === "invisible_unicode") ? "tainted" : "blocked";
10497
- return {
10498
- status,
10499
- contextEligible: status === "clean",
10500
- reasons: orderedReasons,
10501
- policyVersion: MEMORY_CONTENT_SAFETY_POLICY_VERSION
10502
- };
10503
- }
10504
10411
  var DAEMON_DERIVED_MEMORY_SOURCE_TYPES = [
10505
10412
  "extract",
10506
10413
  "aggregate-recall",
@@ -10623,7 +10530,7 @@ function up4(db) {
10623
10530
  function up5(db) {
10624
10531
  db.exec("DROP TABLE IF EXISTS mcp_invocations");
10625
10532
  }
10626
- var MEMORIES_FTS_TOKENIZER = "unicode61";
10533
+ var MEMORIES_FTS_TOKENIZER = "porter unicode61";
10627
10534
  var FTS_STATE_TABLE = "memories_fts_state";
10628
10535
  function normalizeSql(sql) {
10629
10536
  return sql.replace(/\s+/g, " ").trim().toLowerCase();
@@ -10733,10 +10640,7 @@ function readMemoriesFtsSql(db) {
10733
10640
  function memoriesFtsNeedsTokenizerRepair(sql) {
10734
10641
  if (sql === null)
10735
10642
  return false;
10736
- const normalized = normalizeSql(sql);
10737
- if (normalized.includes("porter unicode61"))
10738
- return true;
10739
- return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER}'`);
10643
+ return !normalizeSql(sql).includes(`tokenize='${MEMORIES_FTS_TOKENIZER}'`);
10740
10644
  }
10741
10645
  function up6(db) {
10742
10646
  db.exec(`
@@ -14649,38 +14553,6 @@ function up129(db) {
14649
14553
  ON imported_source_lifecycle(agent_id, status, updated_at DESC);
14650
14554
  `);
14651
14555
  }
14652
- function tableExists2(db, table) {
14653
- return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
14654
- }
14655
- function hasColumn24(db, table, column) {
14656
- return db.prepare(`PRAGMA table_info("${table}")`).all().some((row) => row.name === column);
14657
- }
14658
- function backfill(db, rows, sourceKind, scannedAt) {
14659
- const statement = db.prepare(`INSERT INTO memory_content_safety
14660
- (agent_id, source_kind, source_id, status, context_eligible, reasons_json, policy_version, scanned_at)
14661
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
14662
- ON CONFLICT(agent_id, source_kind, source_id) DO UPDATE SET
14663
- status = excluded.status,
14664
- context_eligible = excluded.context_eligible,
14665
- reasons_json = excluded.reasons_json,
14666
- policy_version = excluded.policy_version,
14667
- scanned_at = excluded.scanned_at`);
14668
- for (const row of rows) {
14669
- const sourceId = row.source_id?.trim();
14670
- if (!sourceId)
14671
- continue;
14672
- const assessment = scanMemoryContent(row.content ?? "");
14673
- 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);
14674
- }
14675
- }
14676
- function backfillTable(db, params) {
14677
- if (!tableExists2(db, params.table) || !hasColumn24(db, params.table, params.sourceIdColumn) || !hasColumn24(db, params.table, params.contentColumn))
14678
- return;
14679
- const agentColumn = hasColumn24(db, params.table, "agent_id") ? "COALESCE(NULLIF(TRIM(agent_id), ''), 'default')" : "'default'";
14680
- const rows = db.prepare(`SELECT ${agentColumn} AS agent_id, ${params.sourceIdColumn} AS source_id, ${params.contentColumn} AS content
14681
- FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
14682
- backfill(db, rows, params.sourceKind, params.scannedAt);
14683
- }
14684
14556
  function up130(db) {
14685
14557
  db.exec(`
14686
14558
  CREATE TABLE IF NOT EXISTS memory_content_safety (
@@ -14700,43 +14572,6 @@ function up130(db) {
14700
14572
  CREATE INDEX IF NOT EXISTS idx_memory_content_safety_eligibility
14701
14573
  ON memory_content_safety(agent_id, source_kind, context_eligible);
14702
14574
  `);
14703
- const scannedAt = new Date().toISOString();
14704
- backfillTable(db, {
14705
- table: "memories",
14706
- sourceKind: "memory",
14707
- sourceIdColumn: "id",
14708
- contentColumn: "content",
14709
- scannedAt
14710
- });
14711
- backfillTable(db, {
14712
- table: "memory_artifacts",
14713
- sourceKind: "artifact",
14714
- sourceIdColumn: "source_path",
14715
- contentColumn: "content",
14716
- scannedAt
14717
- });
14718
- backfillTable(db, {
14719
- table: "session_transcripts",
14720
- sourceKind: "transcript",
14721
- sourceIdColumn: "session_key",
14722
- contentColumn: "content",
14723
- scannedAt
14724
- });
14725
- backfillTable(db, {
14726
- table: "session_summaries",
14727
- sourceKind: "summary",
14728
- sourceIdColumn: "id",
14729
- contentColumn: "content",
14730
- scannedAt
14731
- });
14732
- backfillTable(db, {
14733
- table: "embeddings",
14734
- sourceKind: "source_chunk",
14735
- sourceIdColumn: "id",
14736
- contentColumn: "chunk_text",
14737
- where: "source_type IN ('source_chunk', 'source_obsidian_chunk')",
14738
- scannedAt
14739
- });
14740
14575
  }
14741
14576
  function up131(db) {
14742
14577
  const table = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'dreaming_attention'").get();
@@ -14840,13 +14675,13 @@ function up133(db) {
14840
14675
  AND error IS NOT NULL;
14841
14676
  `);
14842
14677
  }
14843
- function tableExists3(db, table) {
14678
+ function tableExists2(db, table) {
14844
14679
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
14845
14680
  }
14846
14681
  function up134(db) {
14847
- if (!tableExists3(db, "memory_jobs"))
14682
+ if (!tableExists2(db, "memory_jobs"))
14848
14683
  return;
14849
- if (!tableExists3(db, "job_cancellations")) {
14684
+ if (!tableExists2(db, "job_cancellations")) {
14850
14685
  throw new Error("job_cancellations table missing; cannot retire structural jobs without an audit trail");
14851
14686
  }
14852
14687
  db.prepare(`
@@ -15075,12 +14910,12 @@ function up142(db) {
15075
14910
  if (!cols.has(name))
15076
14911
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
15077
14912
  }
15078
- function hasColumn25(db, table, column) {
14913
+ function hasColumn24(db, table, column) {
15079
14914
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
15080
14915
  return rows.some((row) => row.name === column);
15081
14916
  }
15082
14917
  function addColumnIfMissing28(db, table, column, definition) {
15083
- if (!hasColumn25(db, table, column))
14918
+ if (!hasColumn24(db, table, column))
15084
14919
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
15085
14920
  }
15086
14921
  function up143(db) {
@@ -15952,6 +15787,138 @@ function up162(db) {
15952
15787
  END;
15953
15788
  `);
15954
15789
  }
15790
+ function up163(db) {
15791
+ db.exec(`
15792
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_ai;
15793
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_au;
15794
+ DROP INDEX IF EXISTS idx_memory_content_safety_status;
15795
+ DROP INDEX IF EXISTS idx_memory_content_safety_eligibility;
15796
+ DROP TABLE IF EXISTS memory_content_safety;
15797
+ `);
15798
+ }
15799
+ var COLUMNS3 = ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"];
15800
+ function up164(db) {
15801
+ const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
15802
+ for (const column of COLUMNS3) {
15803
+ if (!cols.some((col) => col.name === column)) {
15804
+ db.exec(`ALTER TABLE entity_attributes ADD COLUMN ${column} TEXT`);
15805
+ }
15806
+ }
15807
+ }
15808
+ function up165(db) {
15809
+ const passColumns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
15810
+ if (!passColumns.some((column) => column.name === "scope_key")) {
15811
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN scope_key TEXT");
15812
+ }
15813
+ db.exec(`
15814
+ CREATE TABLE IF NOT EXISTS dreaming_history_nodes (
15815
+ agent_id TEXT NOT NULL,
15816
+ scope_key TEXT NOT NULL,
15817
+ level INTEGER NOT NULL,
15818
+ idx INTEGER NOT NULL,
15819
+ pass_id TEXT,
15820
+ text TEXT NOT NULL,
15821
+ tokens_input INTEGER,
15822
+ tokens_output INTEGER,
15823
+ tokens_cache_read INTEGER,
15824
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
15825
+ PRIMARY KEY (agent_id, scope_key, level, idx)
15826
+ );
15827
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_dreaming_history_nodes_pass
15828
+ ON dreaming_history_nodes(pass_id) WHERE pass_id IS NOT NULL;
15829
+ `);
15830
+ }
15831
+ function up166(db) {
15832
+ const columns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
15833
+ if (!columns.some((column) => column.name === "tokens_peak_context")) {
15834
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN tokens_peak_context INTEGER");
15835
+ }
15836
+ }
15837
+ function up167(db) {
15838
+ const sql = readMemoriesFtsSql(db);
15839
+ if (sql !== null && !memoriesFtsNeedsTokenizerRepair(sql))
15840
+ return;
15841
+ recreateMemoriesFts(db);
15842
+ }
15843
+ function hasTable5(db, table) {
15844
+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
15845
+ }
15846
+ function hasColumn25(db, table, column) {
15847
+ return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
15848
+ }
15849
+ function up168(db) {
15850
+ if (!hasTable5(db, "entity_attributes") || !hasTable5(db, "entity_aspects") || !hasTable5(db, "entities") || !hasColumn25(db, "entity_attributes", "source_root") || !hasColumn25(db, "entities", "source_root")) {
15851
+ return;
15852
+ }
15853
+ const now = new Date().toISOString();
15854
+ db.exec(`
15855
+ CREATE TEMP TABLE retired_source_paragraphs AS
15856
+ SELECT attr.id, attr.memory_id, attr.agent_id, asp.entity_id
15857
+ FROM entity_attributes attr
15858
+ JOIN entity_aspects asp ON asp.id = attr.aspect_id
15859
+ JOIN entities e ON e.id = asp.entity_id
15860
+ WHERE e.entity_type IN ('source_document', 'source_document_reference')
15861
+ AND attr.source_root IS NOT NULL
15862
+ AND attr.source_root = e.source_root
15863
+ AND attr.source_id = e.source_id
15864
+ AND attr.source_root NOT IN ('dreaming', 'dreaming_attention')
15865
+ `);
15866
+ if (hasColumn25(db, "entity_attributes", "memory_id") && hasTable5(db, "memories")) {
15867
+ if (hasTable5(db, "memory_history")) {
15868
+ db.prepare(`INSERT INTO memory_history (id, memory_id, event, old_content, new_content, changed_by, reason, metadata, created_at)
15869
+ SELECT lower(hex(randomblob(16))), mem.id, 'deleted', mem.content, NULL, 'migration:168',
15870
+ 'Source paragraph claims retired', '{"force":true}', ?
15871
+ FROM memories mem
15872
+ JOIN retired_source_paragraphs retired ON retired.memory_id = mem.id
15873
+ WHERE mem.is_deleted = 0`).run(now);
15874
+ }
15875
+ if (hasTable5(db, "derived_memory_sources") && hasColumn25(db, "memories", "stale_at")) {
15876
+ db.prepare(`UPDATE memories
15877
+ SET stale_at = ?
15878
+ WHERE stale_at IS NULL
15879
+ AND is_deleted = 0
15880
+ AND id IN (
15881
+ SELECT dms.derived_memory_id
15882
+ FROM derived_memory_sources dms
15883
+ JOIN retired_source_paragraphs retired ON retired.agent_id = dms.agent_id
15884
+ WHERE (dms.source_kind = 'memory' AND dms.source_id = retired.memory_id)
15885
+ OR (dms.source_kind = 'ontology_claim' AND dms.source_id = retired.id)
15886
+ )`).run(now);
15887
+ }
15888
+ const forget = [
15889
+ "is_deleted = 1",
15890
+ ...["deleted_at", "updated_at"].filter((column) => hasColumn25(db, "memories", column)).map((column) => `${column} = $now`),
15891
+ ...hasColumn25(db, "memories", "updated_by") ? ["updated_by = 'migration:168'"] : [],
15892
+ ...hasColumn25(db, "memories", "version") ? ["version = version + 1"] : []
15893
+ ];
15894
+ db.prepare(`UPDATE memories
15895
+ SET ${forget.join(", ")}
15896
+ WHERE is_deleted = 0
15897
+ AND id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)`).run({ $now: now });
15898
+ if (hasTable5(db, "memory_entity_mentions")) {
15899
+ db.exec(`
15900
+ DELETE FROM memory_entity_mentions
15901
+ WHERE memory_id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)
15902
+ `);
15903
+ }
15904
+ }
15905
+ if (hasTable5(db, "ontology_contradictions")) {
15906
+ db.prepare(`UPDATE ontology_contradictions
15907
+ SET status = 'resolved', resolved_at = ?, resolution_reason = 'source paragraph claims retired', updated_at = ?
15908
+ WHERE status = 'active'
15909
+ AND (left_attribute_id IN (SELECT id FROM retired_source_paragraphs)
15910
+ OR right_attribute_id IN (SELECT id FROM retired_source_paragraphs))`).run(now, now);
15911
+ }
15912
+ db.exec(`
15913
+ DELETE FROM entity_attributes WHERE id IN (SELECT id FROM retired_source_paragraphs);
15914
+ DELETE FROM entity_aspects
15915
+ WHERE entity_id IN (
15916
+ SELECT id FROM entities WHERE entity_type IN ('source_document', 'source_document_reference')
15917
+ )
15918
+ AND NOT EXISTS (SELECT 1 FROM entity_attributes attr WHERE attr.aspect_id = entity_aspects.id);
15919
+ DROP TABLE retired_source_paragraphs;
15920
+ `);
15921
+ }
15955
15922
  var MIGRATIONS = [
15956
15923
  {
15957
15924
  version: 1,
@@ -16961,8 +16928,7 @@ var MIGRATIONS = [
16961
16928
  {
16962
16929
  version: 125,
16963
16930
  name: "memory-content-safety",
16964
- up: up130,
16965
- artifacts: { tables: ["memory_content_safety"] }
16931
+ up: up130
16966
16932
  },
16967
16933
  {
16968
16934
  version: 126,
@@ -17264,6 +17230,48 @@ var MIGRATIONS = [
17264
17230
  name: "generic-entity-prune-scan-generation",
17265
17231
  up: up162,
17266
17232
  artifacts: { tables: ["generic_entity_prune_scan_state"] }
17233
+ },
17234
+ {
17235
+ version: 163,
17236
+ name: "retire-memory-content-safety",
17237
+ up: up163
17238
+ },
17239
+ {
17240
+ version: 164,
17241
+ name: "claim-event-time",
17242
+ up: up164,
17243
+ artifacts: {
17244
+ columns: ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"].map((column) => ({
17245
+ table: "entity_attributes",
17246
+ column
17247
+ }))
17248
+ }
17249
+ },
17250
+ {
17251
+ version: 165,
17252
+ name: "dreaming-history",
17253
+ up: up165,
17254
+ artifacts: {
17255
+ tables: ["dreaming_history_nodes"],
17256
+ indexes: ["idx_dreaming_history_nodes_pass"],
17257
+ columns: [{ table: "dreaming_passes", column: "scope_key" }]
17258
+ }
17259
+ },
17260
+ {
17261
+ version: 166,
17262
+ name: "dreaming-pass-peak-context",
17263
+ up: up166,
17264
+ artifacts: { columns: [{ table: "dreaming_passes", column: "tokens_peak_context" }] }
17265
+ },
17266
+ {
17267
+ version: 167,
17268
+ name: "memories-fts-porter",
17269
+ up: up167
17270
+ },
17271
+ {
17272
+ version: 168,
17273
+ name: "retire-source-paragraph-claims",
17274
+ up: up168
17267
17275
  }
17268
17276
  ];
17269
17277
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
@@ -17505,6 +17513,37 @@ var PIPELINE_PROVIDER_CHOICES = [
17505
17513
  var SYNTHESIS_PROVIDER_CHOICES = PIPELINE_PROVIDER_CHOICES.filter((provider) => provider !== "command");
17506
17514
  var PIPELINE_PROVIDER_SET = new Set(PIPELINE_PROVIDER_CHOICES);
17507
17515
  var SYNTHESIS_PROVIDER_SET = new Set(SYNTHESIS_PROVIDER_CHOICES);
17516
+ var SECRET_NAMES = "(?:access[_-]?token|api[_-]?key|apikey|auth[_-]?token|client[_-]?secret|passw(?:or)?d|refresh[_-]?token|private[_-]?key|secret(?:[_-]?key)?|token)";
17517
+ var SECRET_VALUE = `(?=[^\\s"',;&<>()\\[\\]{}$]*\\d)[^\\s"',;&<>()\\[\\]{}$]{8,}`;
17518
+ var PATTERNS = [
17519
+ {
17520
+ kind: "private_key",
17521
+ pattern: /-----BEGIN (?:[A-Z]+ )*PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )*PRIVATE KEY-----/g
17522
+ },
17523
+ {
17524
+ kind: "provider_key",
17525
+ 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
17526
+ },
17527
+ {
17528
+ kind: "jwt",
17529
+ pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
17530
+ },
17531
+ {
17532
+ kind: "bearer_token",
17533
+ pattern: /\bBearer\s+([A-Za-z0-9._~+/-]{16,}=*)/g,
17534
+ valueGroup: 1
17535
+ },
17536
+ {
17537
+ kind: "secret_assignment",
17538
+ pattern: new RegExp(`\\b${SECRET_NAMES}["']?\\s*[:=]\\s*["']?(${SECRET_VALUE})`, "gi"),
17539
+ valueGroup: 1
17540
+ },
17541
+ {
17542
+ kind: "secret_assignment",
17543
+ pattern: new RegExp(`\\b[A-Z][A-Z0-9_]*(?:API_KEY|TOKEN|SECRET|PASSWORD)\\s*=\\s*["']?(${SECRET_VALUE})`, "g"),
17544
+ valueGroup: 1
17545
+ }
17546
+ ];
17508
17547
  var LOOPBACK_HOST = "127.0.0.1";
17509
17548
  function normalizeLoopbackHost(host) {
17510
17549
  const normalized = host.trim().toLowerCase().replace(/^\[|\]$/g, "");
@@ -28431,99 +28470,6 @@ var execFileHiddenImpl2 = (...args) => Reflect.apply(nodeExecFile2, undefined, w
28431
28470
  Object.defineProperty(execFileHiddenImpl2, promisify2.custom, {
28432
28471
  value: (...args) => Reflect.apply(nodeExecFileAsync2, undefined, withWindowsHideArgument2(args, 1))
28433
28472
  });
28434
- var MEMORY_CONTENT_SAFETY_POLICY_VERSION2 = "memory-content-safety-v1";
28435
- var MEMORY_CONTENT_SAFETY_REASONS2 = [
28436
- "prompt_injection",
28437
- "exfiltration",
28438
- "credential_harvesting",
28439
- "malicious_shell",
28440
- "tool_directive",
28441
- "invisible_unicode"
28442
- ];
28443
- 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;
28444
- var STRONG_DEFENSIVE_CONTEXT_RE2 = /\b(?:security\s+(?:guidance|discussion|analysis)|threat\s+model|defensive)\b/i;
28445
- var REPORTING_CONTEXT_RE2 = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b/i;
28446
- 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;
28447
- 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;
28448
- 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;
28449
- var PROMPT_INJECTION_RES2 = [
28450
- /\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,
28451
- /\b(?:new|following|these)\s+(?:(?:system|developer|assistant|hidden)\s+)?instructions?\b/i,
28452
- /(?:^|\n)\s*(?:system|developer|instruction|prompt)\s*:/im,
28453
- /<\s*(?:system|developer|assistant|instruction|prompt)\b[^>]*>/i,
28454
- /\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
28455
- ];
28456
- var TOOL_DIRECTIVE_RES2 = [
28457
- /<\s*(?:tool[_-]?call|function[_-]?call|invoke|tool)\b/i,
28458
- /\b(?:assistant|system)\s+to\s*=\s*[a-z0-9_.-]+/i,
28459
- /\b(?:call|invoke|use|run|execute)\s+(?:the\s+)?[a-z0-9_.-]+\s+tool\b/i
28460
- ];
28461
- 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;
28462
- 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;
28463
- 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;
28464
- 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;
28465
- function matchHasDefensiveContext2(content, match) {
28466
- if (!match || !match[0])
28467
- return false;
28468
- const start = match.index ?? 0;
28469
- const before = content.slice(Math.max(0, start - 120), start);
28470
- const after = content.slice(start + match[0].length, start + match[0].length + 160);
28471
- 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);
28472
- }
28473
- function hasActionableMatch2(content, patterns) {
28474
- return patterns.some((pattern) => {
28475
- const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
28476
- const searchable = new RegExp(pattern.source, flags);
28477
- let match;
28478
- while ((match = searchable.exec(content)) !== null) {
28479
- if (!matchHasDefensiveContext2(content, match))
28480
- return true;
28481
- if (match[0].length === 0)
28482
- searchable.lastIndex += 1;
28483
- }
28484
- return false;
28485
- });
28486
- }
28487
- function hasDangerousShell2(content) {
28488
- const searchable = new RegExp(DANGEROUS_SHELL_RE2.source, `${DANGEROUS_SHELL_RE2.flags}g`);
28489
- let match;
28490
- while ((match = searchable.exec(content)) !== null) {
28491
- if (matchHasDefensiveContext2(content, match))
28492
- continue;
28493
- const end = (match.index ?? 0) + match[0].length;
28494
- const after = content.slice(end, end + 160);
28495
- if (!STRONG_DEFENSIVE_CONTEXT_RE2.test(after) && !REPORTING_AFTER_RE2.test(after))
28496
- return true;
28497
- if (match[0].length === 0)
28498
- searchable.lastIndex += 1;
28499
- }
28500
- return false;
28501
- }
28502
- function scanMemoryContent2(content) {
28503
- const raw = typeof content === "string" ? content : String(content ?? "");
28504
- const normalized = raw.normalize("NFKC");
28505
- const reasons = new Set;
28506
- if (INVISIBLE_UNICODE_RE2.test(raw))
28507
- reasons.add("invisible_unicode");
28508
- if (hasActionableMatch2(normalized, PROMPT_INJECTION_RES2))
28509
- reasons.add("prompt_injection");
28510
- if (hasActionableMatch2(normalized, TOOL_DIRECTIVE_RES2))
28511
- reasons.add("tool_directive");
28512
- if (hasActionableMatch2(normalized, [EXFILTRATION_RE2, EXFILTRATION_REVERSE2]))
28513
- reasons.add("exfiltration");
28514
- if (hasActionableMatch2(normalized, [CREDENTIAL_HARVESTING_RE2]))
28515
- reasons.add("credential_harvesting");
28516
- if (hasDangerousShell2(normalized))
28517
- reasons.add("malicious_shell");
28518
- const orderedReasons = MEMORY_CONTENT_SAFETY_REASONS2.filter((reason) => reasons.has(reason));
28519
- const status = orderedReasons.length === 0 ? "clean" : orderedReasons.every((reason) => reason === "invisible_unicode") ? "tainted" : "blocked";
28520
- return {
28521
- status,
28522
- contextEligible: status === "clean",
28523
- reasons: orderedReasons,
28524
- policyVersion: MEMORY_CONTENT_SAFETY_POLICY_VERSION2
28525
- };
28526
- }
28527
28473
  var DAEMON_DERIVED_MEMORY_SOURCE_TYPES2 = [
28528
28474
  "extract",
28529
28475
  "aggregate-recall",
@@ -28531,7 +28477,7 @@ var DAEMON_DERIVED_MEMORY_SOURCE_TYPES2 = [
28531
28477
  "checkpoint",
28532
28478
  "dreaming"
28533
28479
  ];
28534
- function up163(db) {
28480
+ function up169(db) {
28535
28481
  const hasColumn = (table, column) => {
28536
28482
  const statement = db.prepare(`SELECT 1 FROM pragma_table_info('${table}') WHERE name = ?`);
28537
28483
  try {
@@ -28646,7 +28592,7 @@ function up410(db) {
28646
28592
  function up510(db) {
28647
28593
  db.exec("DROP TABLE IF EXISTS mcp_invocations");
28648
28594
  }
28649
- var MEMORIES_FTS_TOKENIZER2 = "unicode61";
28595
+ var MEMORIES_FTS_TOKENIZER2 = "porter unicode61";
28650
28596
  var FTS_STATE_TABLE2 = "memories_fts_state";
28651
28597
  function normalizeSql2(sql) {
28652
28598
  return sql.replace(/\s+/g, " ").trim().toLowerCase();
@@ -28756,10 +28702,7 @@ function readMemoriesFtsSql2(db) {
28756
28702
  function memoriesFtsNeedsTokenizerRepair2(sql) {
28757
28703
  if (sql === null)
28758
28704
  return false;
28759
- const normalized = normalizeSql2(sql);
28760
- if (normalized.includes("porter unicode61"))
28761
- return true;
28762
- return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
28705
+ return !normalizeSql2(sql).includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
28763
28706
  }
28764
28707
  function up610(db) {
28765
28708
  db.exec(`
@@ -29184,7 +29127,7 @@ function up1510(db) {
29184
29127
  )
29185
29128
  `);
29186
29129
  }
29187
- function up164(db) {
29130
+ function up1610(db) {
29188
29131
  db.exec(`
29189
29132
  CREATE TABLE IF NOT EXISTS session_scores (
29190
29133
  id TEXT PRIMARY KEY,
@@ -30405,7 +30348,7 @@ function up542(db) {
30405
30348
  );
30406
30349
  `);
30407
30350
  }
30408
- function hasTable5(db, name) {
30351
+ function hasTable6(db, name) {
30409
30352
  return db.prepare(`SELECT name
30410
30353
  FROM sqlite_master
30411
30354
  WHERE type = 'table' AND name = ?
@@ -30435,7 +30378,7 @@ function up552(db) {
30435
30378
  CREATE INDEX IF NOT EXISTS idx_entity_dependency_history_created
30436
30379
  ON entity_dependency_history(created_at DESC);
30437
30380
  `);
30438
- if (!hasTable5(db, "entity_dependencies"))
30381
+ if (!hasTable6(db, "entity_dependencies"))
30439
30382
  return;
30440
30383
  db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_insert");
30441
30384
  db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_update");
@@ -31414,9 +31357,9 @@ function hasColumn112(db, table, column) {
31414
31357
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
31415
31358
  return rows.some((row) => row.name === column);
31416
31359
  }
31417
- var COLUMNS3 = ["harness", "session_id", "tool_use_id", "cwd", "origin", "args"];
31360
+ var COLUMNS4 = ["harness", "session_id", "tool_use_id", "cwd", "origin", "args"];
31418
31361
  function up872(db) {
31419
- for (const column of COLUMNS3) {
31362
+ for (const column of COLUMNS4) {
31420
31363
  if (!hasColumn112(db, "skill_invocations", column)) {
31421
31364
  db.exec(`ALTER TABLE skill_invocations ADD COLUMN ${column} TEXT`);
31422
31365
  }
@@ -31980,7 +31923,7 @@ function up1082(db) {
31980
31923
  )
31981
31924
  `);
31982
31925
  }
31983
- function tableExists4(db, table) {
31926
+ function tableExists3(db, table) {
31984
31927
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) !== undefined;
31985
31928
  }
31986
31929
  function hasColumn162(db, table, column) {
@@ -32002,7 +31945,7 @@ function up1092(db) {
32002
31945
  CREATE INDEX IF NOT EXISTS idx_derived_memory_sources_source
32003
31946
  ON derived_memory_sources(agent_id, source_kind, source_id);
32004
31947
  `);
32005
- if (tableExists4(db, "aggregate_evidence_sources")) {
31948
+ if (tableExists3(db, "aggregate_evidence_sources")) {
32006
31949
  db.exec(`
32007
31950
  INSERT OR IGNORE INTO derived_memory_sources
32008
31951
  (derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
@@ -32010,7 +31953,7 @@ function up1092(db) {
32010
31953
  FROM aggregate_evidence_sources
32011
31954
  `);
32012
31955
  }
32013
- if (tableExists4(db, "aggregate_memory_sources")) {
31956
+ if (tableExists3(db, "aggregate_memory_sources")) {
32014
31957
  db.exec(`
32015
31958
  INSERT OR IGNORE INTO derived_memory_sources
32016
31959
  (derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
@@ -32018,10 +31961,10 @@ function up1092(db) {
32018
31961
  FROM aggregate_memory_sources
32019
31962
  `);
32020
31963
  }
32021
- if (tableExists4(db, "memories") && !hasColumn162(db, "memories", "stale_at")) {
31964
+ if (tableExists3(db, "memories") && !hasColumn162(db, "memories", "stale_at")) {
32022
31965
  db.exec("ALTER TABLE memories ADD COLUMN stale_at TEXT");
32023
31966
  }
32024
- if (tableExists4(db, "memories")) {
31967
+ if (tableExists3(db, "memories")) {
32025
31968
  db.exec(`
32026
31969
  CREATE INDEX IF NOT EXISTS idx_memories_stale_derived
32027
31970
  ON memories(agent_id, stale_at)
@@ -32672,38 +32615,6 @@ function up1292(db) {
32672
32615
  ON imported_source_lifecycle(agent_id, status, updated_at DESC);
32673
32616
  `);
32674
32617
  }
32675
- function tableExists22(db, table) {
32676
- return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
32677
- }
32678
- function hasColumn242(db, table, column) {
32679
- return db.prepare(`PRAGMA table_info("${table}")`).all().some((row) => row.name === column);
32680
- }
32681
- function backfill2(db, rows, sourceKind, scannedAt) {
32682
- const statement = db.prepare(`INSERT INTO memory_content_safety
32683
- (agent_id, source_kind, source_id, status, context_eligible, reasons_json, policy_version, scanned_at)
32684
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
32685
- ON CONFLICT(agent_id, source_kind, source_id) DO UPDATE SET
32686
- status = excluded.status,
32687
- context_eligible = excluded.context_eligible,
32688
- reasons_json = excluded.reasons_json,
32689
- policy_version = excluded.policy_version,
32690
- scanned_at = excluded.scanned_at`);
32691
- for (const row of rows) {
32692
- const sourceId = row.source_id?.trim();
32693
- if (!sourceId)
32694
- continue;
32695
- const assessment = scanMemoryContent2(row.content ?? "");
32696
- 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);
32697
- }
32698
- }
32699
- function backfillTable2(db, params) {
32700
- if (!tableExists22(db, params.table) || !hasColumn242(db, params.table, params.sourceIdColumn) || !hasColumn242(db, params.table, params.contentColumn))
32701
- return;
32702
- const agentColumn = hasColumn242(db, params.table, "agent_id") ? "COALESCE(NULLIF(TRIM(agent_id), ''), 'default')" : "'default'";
32703
- const rows = db.prepare(`SELECT ${agentColumn} AS agent_id, ${params.sourceIdColumn} AS source_id, ${params.contentColumn} AS content
32704
- FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
32705
- backfill2(db, rows, params.sourceKind, params.scannedAt);
32706
- }
32707
32618
  function up1302(db) {
32708
32619
  db.exec(`
32709
32620
  CREATE TABLE IF NOT EXISTS memory_content_safety (
@@ -32723,43 +32634,6 @@ function up1302(db) {
32723
32634
  CREATE INDEX IF NOT EXISTS idx_memory_content_safety_eligibility
32724
32635
  ON memory_content_safety(agent_id, source_kind, context_eligible);
32725
32636
  `);
32726
- const scannedAt = new Date().toISOString();
32727
- backfillTable2(db, {
32728
- table: "memories",
32729
- sourceKind: "memory",
32730
- sourceIdColumn: "id",
32731
- contentColumn: "content",
32732
- scannedAt
32733
- });
32734
- backfillTable2(db, {
32735
- table: "memory_artifacts",
32736
- sourceKind: "artifact",
32737
- sourceIdColumn: "source_path",
32738
- contentColumn: "content",
32739
- scannedAt
32740
- });
32741
- backfillTable2(db, {
32742
- table: "session_transcripts",
32743
- sourceKind: "transcript",
32744
- sourceIdColumn: "session_key",
32745
- contentColumn: "content",
32746
- scannedAt
32747
- });
32748
- backfillTable2(db, {
32749
- table: "session_summaries",
32750
- sourceKind: "summary",
32751
- sourceIdColumn: "id",
32752
- contentColumn: "content",
32753
- scannedAt
32754
- });
32755
- backfillTable2(db, {
32756
- table: "embeddings",
32757
- sourceKind: "source_chunk",
32758
- sourceIdColumn: "id",
32759
- contentColumn: "chunk_text",
32760
- where: "source_type IN ('source_chunk', 'source_obsidian_chunk')",
32761
- scannedAt
32762
- });
32763
32637
  }
32764
32638
  function up1312(db) {
32765
32639
  const table = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'dreaming_attention'").get();
@@ -32863,13 +32737,13 @@ function up1332(db) {
32863
32737
  AND error IS NOT NULL;
32864
32738
  `);
32865
32739
  }
32866
- function tableExists32(db, table) {
32740
+ function tableExists22(db, table) {
32867
32741
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
32868
32742
  }
32869
32743
  function up1342(db) {
32870
- if (!tableExists32(db, "memory_jobs"))
32744
+ if (!tableExists22(db, "memory_jobs"))
32871
32745
  return;
32872
- if (!tableExists32(db, "job_cancellations")) {
32746
+ if (!tableExists22(db, "job_cancellations")) {
32873
32747
  throw new Error("job_cancellations table missing; cannot retire structural jobs without an audit trail");
32874
32748
  }
32875
32749
  db.prepare(`
@@ -33098,12 +32972,12 @@ function up1422(db) {
33098
32972
  if (!cols.has(name))
33099
32973
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
33100
32974
  }
33101
- function hasColumn252(db, table, column) {
32975
+ function hasColumn242(db, table, column) {
33102
32976
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
33103
32977
  return rows.some((row) => row.name === column);
33104
32978
  }
33105
32979
  function addColumnIfMissing282(db, table, column, definition) {
33106
- if (!hasColumn252(db, table, column))
32980
+ if (!hasColumn242(db, table, column))
33107
32981
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
33108
32982
  }
33109
32983
  function up1432(db) {
@@ -33975,6 +33849,138 @@ function up1622(db) {
33975
33849
  END;
33976
33850
  `);
33977
33851
  }
33852
+ function up1632(db) {
33853
+ db.exec(`
33854
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_ai;
33855
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_au;
33856
+ DROP INDEX IF EXISTS idx_memory_content_safety_status;
33857
+ DROP INDEX IF EXISTS idx_memory_content_safety_eligibility;
33858
+ DROP TABLE IF EXISTS memory_content_safety;
33859
+ `);
33860
+ }
33861
+ var COLUMNS32 = ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"];
33862
+ function up1642(db) {
33863
+ const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
33864
+ for (const column of COLUMNS32) {
33865
+ if (!cols.some((col) => col.name === column)) {
33866
+ db.exec(`ALTER TABLE entity_attributes ADD COLUMN ${column} TEXT`);
33867
+ }
33868
+ }
33869
+ }
33870
+ function up1652(db) {
33871
+ const passColumns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
33872
+ if (!passColumns.some((column) => column.name === "scope_key")) {
33873
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN scope_key TEXT");
33874
+ }
33875
+ db.exec(`
33876
+ CREATE TABLE IF NOT EXISTS dreaming_history_nodes (
33877
+ agent_id TEXT NOT NULL,
33878
+ scope_key TEXT NOT NULL,
33879
+ level INTEGER NOT NULL,
33880
+ idx INTEGER NOT NULL,
33881
+ pass_id TEXT,
33882
+ text TEXT NOT NULL,
33883
+ tokens_input INTEGER,
33884
+ tokens_output INTEGER,
33885
+ tokens_cache_read INTEGER,
33886
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
33887
+ PRIMARY KEY (agent_id, scope_key, level, idx)
33888
+ );
33889
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_dreaming_history_nodes_pass
33890
+ ON dreaming_history_nodes(pass_id) WHERE pass_id IS NOT NULL;
33891
+ `);
33892
+ }
33893
+ function up1662(db) {
33894
+ const columns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
33895
+ if (!columns.some((column) => column.name === "tokens_peak_context")) {
33896
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN tokens_peak_context INTEGER");
33897
+ }
33898
+ }
33899
+ function up1672(db) {
33900
+ const sql = readMemoriesFtsSql2(db);
33901
+ if (sql !== null && !memoriesFtsNeedsTokenizerRepair2(sql))
33902
+ return;
33903
+ recreateMemoriesFts2(db);
33904
+ }
33905
+ function hasTable52(db, table) {
33906
+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
33907
+ }
33908
+ function hasColumn252(db, table, column) {
33909
+ return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
33910
+ }
33911
+ function up1682(db) {
33912
+ if (!hasTable52(db, "entity_attributes") || !hasTable52(db, "entity_aspects") || !hasTable52(db, "entities") || !hasColumn252(db, "entity_attributes", "source_root") || !hasColumn252(db, "entities", "source_root")) {
33913
+ return;
33914
+ }
33915
+ const now = new Date().toISOString();
33916
+ db.exec(`
33917
+ CREATE TEMP TABLE retired_source_paragraphs AS
33918
+ SELECT attr.id, attr.memory_id, attr.agent_id, asp.entity_id
33919
+ FROM entity_attributes attr
33920
+ JOIN entity_aspects asp ON asp.id = attr.aspect_id
33921
+ JOIN entities e ON e.id = asp.entity_id
33922
+ WHERE e.entity_type IN ('source_document', 'source_document_reference')
33923
+ AND attr.source_root IS NOT NULL
33924
+ AND attr.source_root = e.source_root
33925
+ AND attr.source_id = e.source_id
33926
+ AND attr.source_root NOT IN ('dreaming', 'dreaming_attention')
33927
+ `);
33928
+ if (hasColumn252(db, "entity_attributes", "memory_id") && hasTable52(db, "memories")) {
33929
+ if (hasTable52(db, "memory_history")) {
33930
+ db.prepare(`INSERT INTO memory_history (id, memory_id, event, old_content, new_content, changed_by, reason, metadata, created_at)
33931
+ SELECT lower(hex(randomblob(16))), mem.id, 'deleted', mem.content, NULL, 'migration:168',
33932
+ 'Source paragraph claims retired', '{"force":true}', ?
33933
+ FROM memories mem
33934
+ JOIN retired_source_paragraphs retired ON retired.memory_id = mem.id
33935
+ WHERE mem.is_deleted = 0`).run(now);
33936
+ }
33937
+ if (hasTable52(db, "derived_memory_sources") && hasColumn252(db, "memories", "stale_at")) {
33938
+ db.prepare(`UPDATE memories
33939
+ SET stale_at = ?
33940
+ WHERE stale_at IS NULL
33941
+ AND is_deleted = 0
33942
+ AND id IN (
33943
+ SELECT dms.derived_memory_id
33944
+ FROM derived_memory_sources dms
33945
+ JOIN retired_source_paragraphs retired ON retired.agent_id = dms.agent_id
33946
+ WHERE (dms.source_kind = 'memory' AND dms.source_id = retired.memory_id)
33947
+ OR (dms.source_kind = 'ontology_claim' AND dms.source_id = retired.id)
33948
+ )`).run(now);
33949
+ }
33950
+ const forget = [
33951
+ "is_deleted = 1",
33952
+ ...["deleted_at", "updated_at"].filter((column) => hasColumn252(db, "memories", column)).map((column) => `${column} = $now`),
33953
+ ...hasColumn252(db, "memories", "updated_by") ? ["updated_by = 'migration:168'"] : [],
33954
+ ...hasColumn252(db, "memories", "version") ? ["version = version + 1"] : []
33955
+ ];
33956
+ db.prepare(`UPDATE memories
33957
+ SET ${forget.join(", ")}
33958
+ WHERE is_deleted = 0
33959
+ AND id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)`).run({ $now: now });
33960
+ if (hasTable52(db, "memory_entity_mentions")) {
33961
+ db.exec(`
33962
+ DELETE FROM memory_entity_mentions
33963
+ WHERE memory_id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)
33964
+ `);
33965
+ }
33966
+ }
33967
+ if (hasTable52(db, "ontology_contradictions")) {
33968
+ db.prepare(`UPDATE ontology_contradictions
33969
+ SET status = 'resolved', resolved_at = ?, resolution_reason = 'source paragraph claims retired', updated_at = ?
33970
+ WHERE status = 'active'
33971
+ AND (left_attribute_id IN (SELECT id FROM retired_source_paragraphs)
33972
+ OR right_attribute_id IN (SELECT id FROM retired_source_paragraphs))`).run(now, now);
33973
+ }
33974
+ db.exec(`
33975
+ DELETE FROM entity_attributes WHERE id IN (SELECT id FROM retired_source_paragraphs);
33976
+ DELETE FROM entity_aspects
33977
+ WHERE entity_id IN (
33978
+ SELECT id FROM entities WHERE entity_type IN ('source_document', 'source_document_reference')
33979
+ )
33980
+ AND NOT EXISTS (SELECT 1 FROM entity_attributes attr WHERE attr.aspect_id = entity_aspects.id);
33981
+ DROP TABLE retired_source_paragraphs;
33982
+ `);
33983
+ }
33978
33984
  var MIGRATIONS2 = [
33979
33985
  {
33980
33986
  version: 1,
@@ -34045,7 +34051,7 @@ var MIGRATIONS2 = [
34045
34051
  {
34046
34052
  version: 11,
34047
34053
  name: "session-scores",
34048
- up: up164,
34054
+ up: up1610,
34049
34055
  artifacts: { tables: ["session_scores"] }
34050
34056
  },
34051
34057
  {
@@ -34984,8 +34990,7 @@ var MIGRATIONS2 = [
34984
34990
  {
34985
34991
  version: 125,
34986
34992
  name: "memory-content-safety",
34987
- up: up1302,
34988
- artifacts: { tables: ["memory_content_safety"] }
34993
+ up: up1302
34989
34994
  },
34990
34995
  {
34991
34996
  version: 126,
@@ -35179,7 +35184,7 @@ var MIGRATIONS2 = [
35179
35184
  {
35180
35185
  version: 151,
35181
35186
  name: "transcript-import-bytes",
35182
- up: up163,
35187
+ up: up169,
35183
35188
  artifacts: {
35184
35189
  tables: [
35185
35190
  "source_import_chunks",
@@ -35287,6 +35292,48 @@ var MIGRATIONS2 = [
35287
35292
  name: "generic-entity-prune-scan-generation",
35288
35293
  up: up1622,
35289
35294
  artifacts: { tables: ["generic_entity_prune_scan_state"] }
35295
+ },
35296
+ {
35297
+ version: 163,
35298
+ name: "retire-memory-content-safety",
35299
+ up: up1632
35300
+ },
35301
+ {
35302
+ version: 164,
35303
+ name: "claim-event-time",
35304
+ up: up1642,
35305
+ artifacts: {
35306
+ columns: ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"].map((column) => ({
35307
+ table: "entity_attributes",
35308
+ column
35309
+ }))
35310
+ }
35311
+ },
35312
+ {
35313
+ version: 165,
35314
+ name: "dreaming-history",
35315
+ up: up1652,
35316
+ artifacts: {
35317
+ tables: ["dreaming_history_nodes"],
35318
+ indexes: ["idx_dreaming_history_nodes_pass"],
35319
+ columns: [{ table: "dreaming_passes", column: "scope_key" }]
35320
+ }
35321
+ },
35322
+ {
35323
+ version: 166,
35324
+ name: "dreaming-pass-peak-context",
35325
+ up: up1662,
35326
+ artifacts: { columns: [{ table: "dreaming_passes", column: "tokens_peak_context" }] }
35327
+ },
35328
+ {
35329
+ version: 167,
35330
+ name: "memories-fts-porter",
35331
+ up: up1672
35332
+ },
35333
+ {
35334
+ version: 168,
35335
+ name: "retire-source-paragraph-claims",
35336
+ up: up1682
35290
35337
  }
35291
35338
  ];
35292
35339
  var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
@@ -35528,6 +35575,37 @@ var PIPELINE_PROVIDER_CHOICES2 = [
35528
35575
  var SYNTHESIS_PROVIDER_CHOICES2 = PIPELINE_PROVIDER_CHOICES2.filter((provider) => provider !== "command");
35529
35576
  var PIPELINE_PROVIDER_SET2 = new Set(PIPELINE_PROVIDER_CHOICES2);
35530
35577
  var SYNTHESIS_PROVIDER_SET2 = new Set(SYNTHESIS_PROVIDER_CHOICES2);
35578
+ var SECRET_NAMES2 = "(?:access[_-]?token|api[_-]?key|apikey|auth[_-]?token|client[_-]?secret|passw(?:or)?d|refresh[_-]?token|private[_-]?key|secret(?:[_-]?key)?|token)";
35579
+ var SECRET_VALUE2 = `(?=[^\\s"',;&<>()\\[\\]{}$]*\\d)[^\\s"',;&<>()\\[\\]{}$]{8,}`;
35580
+ var PATTERNS2 = [
35581
+ {
35582
+ kind: "private_key",
35583
+ pattern: /-----BEGIN (?:[A-Z]+ )*PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )*PRIVATE KEY-----/g
35584
+ },
35585
+ {
35586
+ kind: "provider_key",
35587
+ 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
35588
+ },
35589
+ {
35590
+ kind: "jwt",
35591
+ pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
35592
+ },
35593
+ {
35594
+ kind: "bearer_token",
35595
+ pattern: /\bBearer\s+([A-Za-z0-9._~+/-]{16,}=*)/g,
35596
+ valueGroup: 1
35597
+ },
35598
+ {
35599
+ kind: "secret_assignment",
35600
+ pattern: new RegExp(`\\b${SECRET_NAMES2}["']?\\s*[:=]\\s*["']?(${SECRET_VALUE2})`, "gi"),
35601
+ valueGroup: 1
35602
+ },
35603
+ {
35604
+ kind: "secret_assignment",
35605
+ pattern: new RegExp(`\\b[A-Z][A-Z0-9_]*(?:API_KEY|TOKEN|SECRET|PASSWORD)\\s*=\\s*["']?(${SECRET_VALUE2})`, "g"),
35606
+ valueGroup: 1
35607
+ }
35608
+ ];
35531
35609
  var LOOPBACK_HOST2 = "127.0.0.1";
35532
35610
  var LOCAL_BINDS2 = new Set([LOOPBACK_HOST2, "localhost", "::1", "::ffff:127.0.0.1"]);
35533
35611
  function parseSimpleYaml(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-forge",
3
- "version": "0.236.0",
3
+ "version": "0.237.0",
4
4
  "description": "Signet connector for ForgeCode - installs MCP, identity, and skills integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "typecheck": "tsc --noEmit"
25
25
  },
26
26
  "dependencies": {
27
- "@signetai/connector-base": "0.236.0",
28
- "@signetai/core": "0.236.0"
27
+ "@signetai/connector-base": "0.237.0",
28
+ "@signetai/core": "0.237.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.0.0",