@signetai/connector-gemini 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
@@ -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
  var LOCAL_BINDS = new Set([LOOPBACK_HOST, "localhost", "::1", "::ffff:127.0.0.1"]);
17510
17549
  var WORKSPACE_ENV_KEYS = ["SIGNET_PATH", "SIGNET_WORKSPACE"];
@@ -28317,99 +28356,6 @@ var execFileHiddenImpl2 = (...args) => Reflect.apply(nodeExecFile2, undefined, w
28317
28356
  Object.defineProperty(execFileHiddenImpl2, promisify2.custom, {
28318
28357
  value: (...args) => Reflect.apply(nodeExecFileAsync2, undefined, withWindowsHideArgument2(args, 1))
28319
28358
  });
28320
- var MEMORY_CONTENT_SAFETY_POLICY_VERSION2 = "memory-content-safety-v1";
28321
- var MEMORY_CONTENT_SAFETY_REASONS2 = [
28322
- "prompt_injection",
28323
- "exfiltration",
28324
- "credential_harvesting",
28325
- "malicious_shell",
28326
- "tool_directive",
28327
- "invisible_unicode"
28328
- ];
28329
- 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;
28330
- var STRONG_DEFENSIVE_CONTEXT_RE2 = /\b(?:security\s+(?:guidance|discussion|analysis)|threat\s+model|defensive)\b/i;
28331
- var REPORTING_CONTEXT_RE2 = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b/i;
28332
- 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;
28333
- 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;
28334
- 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;
28335
- var PROMPT_INJECTION_RES2 = [
28336
- /\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,
28337
- /\b(?:new|following|these)\s+(?:(?:system|developer|assistant|hidden)\s+)?instructions?\b/i,
28338
- /(?:^|\n)\s*(?:system|developer|instruction|prompt)\s*:/im,
28339
- /<\s*(?:system|developer|assistant|instruction|prompt)\b[^>]*>/i,
28340
- /\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
28341
- ];
28342
- var TOOL_DIRECTIVE_RES2 = [
28343
- /<\s*(?:tool[_-]?call|function[_-]?call|invoke|tool)\b/i,
28344
- /\b(?:assistant|system)\s+to\s*=\s*[a-z0-9_.-]+/i,
28345
- /\b(?:call|invoke|use|run|execute)\s+(?:the\s+)?[a-z0-9_.-]+\s+tool\b/i
28346
- ];
28347
- 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;
28348
- 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;
28349
- 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;
28350
- 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;
28351
- function matchHasDefensiveContext2(content, match) {
28352
- if (!match || !match[0])
28353
- return false;
28354
- const start = match.index ?? 0;
28355
- const before = content.slice(Math.max(0, start - 120), start);
28356
- const after = content.slice(start + match[0].length, start + match[0].length + 160);
28357
- 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);
28358
- }
28359
- function hasActionableMatch2(content, patterns) {
28360
- return patterns.some((pattern) => {
28361
- const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
28362
- const searchable = new RegExp(pattern.source, flags);
28363
- let match;
28364
- while ((match = searchable.exec(content)) !== null) {
28365
- if (!matchHasDefensiveContext2(content, match))
28366
- return true;
28367
- if (match[0].length === 0)
28368
- searchable.lastIndex += 1;
28369
- }
28370
- return false;
28371
- });
28372
- }
28373
- function hasDangerousShell2(content) {
28374
- const searchable = new RegExp(DANGEROUS_SHELL_RE2.source, `${DANGEROUS_SHELL_RE2.flags}g`);
28375
- let match;
28376
- while ((match = searchable.exec(content)) !== null) {
28377
- if (matchHasDefensiveContext2(content, match))
28378
- continue;
28379
- const end = (match.index ?? 0) + match[0].length;
28380
- const after = content.slice(end, end + 160);
28381
- if (!STRONG_DEFENSIVE_CONTEXT_RE2.test(after) && !REPORTING_AFTER_RE2.test(after))
28382
- return true;
28383
- if (match[0].length === 0)
28384
- searchable.lastIndex += 1;
28385
- }
28386
- return false;
28387
- }
28388
- function scanMemoryContent2(content) {
28389
- const raw = typeof content === "string" ? content : String(content ?? "");
28390
- const normalized = raw.normalize("NFKC");
28391
- const reasons = new Set;
28392
- if (INVISIBLE_UNICODE_RE2.test(raw))
28393
- reasons.add("invisible_unicode");
28394
- if (hasActionableMatch2(normalized, PROMPT_INJECTION_RES2))
28395
- reasons.add("prompt_injection");
28396
- if (hasActionableMatch2(normalized, TOOL_DIRECTIVE_RES2))
28397
- reasons.add("tool_directive");
28398
- if (hasActionableMatch2(normalized, [EXFILTRATION_RE2, EXFILTRATION_REVERSE2]))
28399
- reasons.add("exfiltration");
28400
- if (hasActionableMatch2(normalized, [CREDENTIAL_HARVESTING_RE2]))
28401
- reasons.add("credential_harvesting");
28402
- if (hasDangerousShell2(normalized))
28403
- reasons.add("malicious_shell");
28404
- const orderedReasons = MEMORY_CONTENT_SAFETY_REASONS2.filter((reason) => reasons.has(reason));
28405
- const status = orderedReasons.length === 0 ? "clean" : orderedReasons.every((reason) => reason === "invisible_unicode") ? "tainted" : "blocked";
28406
- return {
28407
- status,
28408
- contextEligible: status === "clean",
28409
- reasons: orderedReasons,
28410
- policyVersion: MEMORY_CONTENT_SAFETY_POLICY_VERSION2
28411
- };
28412
- }
28413
28359
  var DAEMON_DERIVED_MEMORY_SOURCE_TYPES2 = [
28414
28360
  "extract",
28415
28361
  "aggregate-recall",
@@ -28417,7 +28363,7 @@ var DAEMON_DERIVED_MEMORY_SOURCE_TYPES2 = [
28417
28363
  "checkpoint",
28418
28364
  "dreaming"
28419
28365
  ];
28420
- function up163(db) {
28366
+ function up169(db) {
28421
28367
  const hasColumn = (table, column) => {
28422
28368
  const statement = db.prepare(`SELECT 1 FROM pragma_table_info('${table}') WHERE name = ?`);
28423
28369
  try {
@@ -28532,7 +28478,7 @@ function up410(db) {
28532
28478
  function up510(db) {
28533
28479
  db.exec("DROP TABLE IF EXISTS mcp_invocations");
28534
28480
  }
28535
- var MEMORIES_FTS_TOKENIZER2 = "unicode61";
28481
+ var MEMORIES_FTS_TOKENIZER2 = "porter unicode61";
28536
28482
  var FTS_STATE_TABLE2 = "memories_fts_state";
28537
28483
  function normalizeSql2(sql) {
28538
28484
  return sql.replace(/\s+/g, " ").trim().toLowerCase();
@@ -28642,10 +28588,7 @@ function readMemoriesFtsSql2(db) {
28642
28588
  function memoriesFtsNeedsTokenizerRepair2(sql) {
28643
28589
  if (sql === null)
28644
28590
  return false;
28645
- const normalized = normalizeSql2(sql);
28646
- if (normalized.includes("porter unicode61"))
28647
- return true;
28648
- return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
28591
+ return !normalizeSql2(sql).includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
28649
28592
  }
28650
28593
  function up610(db) {
28651
28594
  db.exec(`
@@ -29070,7 +29013,7 @@ function up1510(db) {
29070
29013
  )
29071
29014
  `);
29072
29015
  }
29073
- function up164(db) {
29016
+ function up1610(db) {
29074
29017
  db.exec(`
29075
29018
  CREATE TABLE IF NOT EXISTS session_scores (
29076
29019
  id TEXT PRIMARY KEY,
@@ -30291,7 +30234,7 @@ function up542(db) {
30291
30234
  );
30292
30235
  `);
30293
30236
  }
30294
- function hasTable5(db, name) {
30237
+ function hasTable6(db, name) {
30295
30238
  return db.prepare(`SELECT name
30296
30239
  FROM sqlite_master
30297
30240
  WHERE type = 'table' AND name = ?
@@ -30321,7 +30264,7 @@ function up552(db) {
30321
30264
  CREATE INDEX IF NOT EXISTS idx_entity_dependency_history_created
30322
30265
  ON entity_dependency_history(created_at DESC);
30323
30266
  `);
30324
- if (!hasTable5(db, "entity_dependencies"))
30267
+ if (!hasTable6(db, "entity_dependencies"))
30325
30268
  return;
30326
30269
  db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_insert");
30327
30270
  db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_update");
@@ -31300,9 +31243,9 @@ function hasColumn112(db, table, column) {
31300
31243
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
31301
31244
  return rows.some((row) => row.name === column);
31302
31245
  }
31303
- var COLUMNS3 = ["harness", "session_id", "tool_use_id", "cwd", "origin", "args"];
31246
+ var COLUMNS4 = ["harness", "session_id", "tool_use_id", "cwd", "origin", "args"];
31304
31247
  function up872(db) {
31305
- for (const column of COLUMNS3) {
31248
+ for (const column of COLUMNS4) {
31306
31249
  if (!hasColumn112(db, "skill_invocations", column)) {
31307
31250
  db.exec(`ALTER TABLE skill_invocations ADD COLUMN ${column} TEXT`);
31308
31251
  }
@@ -31866,7 +31809,7 @@ function up1082(db) {
31866
31809
  )
31867
31810
  `);
31868
31811
  }
31869
- function tableExists4(db, table) {
31812
+ function tableExists3(db, table) {
31870
31813
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) !== undefined;
31871
31814
  }
31872
31815
  function hasColumn162(db, table, column) {
@@ -31888,7 +31831,7 @@ function up1092(db) {
31888
31831
  CREATE INDEX IF NOT EXISTS idx_derived_memory_sources_source
31889
31832
  ON derived_memory_sources(agent_id, source_kind, source_id);
31890
31833
  `);
31891
- if (tableExists4(db, "aggregate_evidence_sources")) {
31834
+ if (tableExists3(db, "aggregate_evidence_sources")) {
31892
31835
  db.exec(`
31893
31836
  INSERT OR IGNORE INTO derived_memory_sources
31894
31837
  (derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
@@ -31896,7 +31839,7 @@ function up1092(db) {
31896
31839
  FROM aggregate_evidence_sources
31897
31840
  `);
31898
31841
  }
31899
- if (tableExists4(db, "aggregate_memory_sources")) {
31842
+ if (tableExists3(db, "aggregate_memory_sources")) {
31900
31843
  db.exec(`
31901
31844
  INSERT OR IGNORE INTO derived_memory_sources
31902
31845
  (derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
@@ -31904,10 +31847,10 @@ function up1092(db) {
31904
31847
  FROM aggregate_memory_sources
31905
31848
  `);
31906
31849
  }
31907
- if (tableExists4(db, "memories") && !hasColumn162(db, "memories", "stale_at")) {
31850
+ if (tableExists3(db, "memories") && !hasColumn162(db, "memories", "stale_at")) {
31908
31851
  db.exec("ALTER TABLE memories ADD COLUMN stale_at TEXT");
31909
31852
  }
31910
- if (tableExists4(db, "memories")) {
31853
+ if (tableExists3(db, "memories")) {
31911
31854
  db.exec(`
31912
31855
  CREATE INDEX IF NOT EXISTS idx_memories_stale_derived
31913
31856
  ON memories(agent_id, stale_at)
@@ -32558,38 +32501,6 @@ function up1292(db) {
32558
32501
  ON imported_source_lifecycle(agent_id, status, updated_at DESC);
32559
32502
  `);
32560
32503
  }
32561
- function tableExists22(db, table) {
32562
- return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
32563
- }
32564
- function hasColumn242(db, table, column) {
32565
- return db.prepare(`PRAGMA table_info("${table}")`).all().some((row) => row.name === column);
32566
- }
32567
- function backfill2(db, rows, sourceKind, scannedAt) {
32568
- const statement = db.prepare(`INSERT INTO memory_content_safety
32569
- (agent_id, source_kind, source_id, status, context_eligible, reasons_json, policy_version, scanned_at)
32570
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
32571
- ON CONFLICT(agent_id, source_kind, source_id) DO UPDATE SET
32572
- status = excluded.status,
32573
- context_eligible = excluded.context_eligible,
32574
- reasons_json = excluded.reasons_json,
32575
- policy_version = excluded.policy_version,
32576
- scanned_at = excluded.scanned_at`);
32577
- for (const row of rows) {
32578
- const sourceId = row.source_id?.trim();
32579
- if (!sourceId)
32580
- continue;
32581
- const assessment = scanMemoryContent2(row.content ?? "");
32582
- 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);
32583
- }
32584
- }
32585
- function backfillTable2(db, params) {
32586
- if (!tableExists22(db, params.table) || !hasColumn242(db, params.table, params.sourceIdColumn) || !hasColumn242(db, params.table, params.contentColumn))
32587
- return;
32588
- const agentColumn = hasColumn242(db, params.table, "agent_id") ? "COALESCE(NULLIF(TRIM(agent_id), ''), 'default')" : "'default'";
32589
- const rows = db.prepare(`SELECT ${agentColumn} AS agent_id, ${params.sourceIdColumn} AS source_id, ${params.contentColumn} AS content
32590
- FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
32591
- backfill2(db, rows, params.sourceKind, params.scannedAt);
32592
- }
32593
32504
  function up1302(db) {
32594
32505
  db.exec(`
32595
32506
  CREATE TABLE IF NOT EXISTS memory_content_safety (
@@ -32609,43 +32520,6 @@ function up1302(db) {
32609
32520
  CREATE INDEX IF NOT EXISTS idx_memory_content_safety_eligibility
32610
32521
  ON memory_content_safety(agent_id, source_kind, context_eligible);
32611
32522
  `);
32612
- const scannedAt = new Date().toISOString();
32613
- backfillTable2(db, {
32614
- table: "memories",
32615
- sourceKind: "memory",
32616
- sourceIdColumn: "id",
32617
- contentColumn: "content",
32618
- scannedAt
32619
- });
32620
- backfillTable2(db, {
32621
- table: "memory_artifacts",
32622
- sourceKind: "artifact",
32623
- sourceIdColumn: "source_path",
32624
- contentColumn: "content",
32625
- scannedAt
32626
- });
32627
- backfillTable2(db, {
32628
- table: "session_transcripts",
32629
- sourceKind: "transcript",
32630
- sourceIdColumn: "session_key",
32631
- contentColumn: "content",
32632
- scannedAt
32633
- });
32634
- backfillTable2(db, {
32635
- table: "session_summaries",
32636
- sourceKind: "summary",
32637
- sourceIdColumn: "id",
32638
- contentColumn: "content",
32639
- scannedAt
32640
- });
32641
- backfillTable2(db, {
32642
- table: "embeddings",
32643
- sourceKind: "source_chunk",
32644
- sourceIdColumn: "id",
32645
- contentColumn: "chunk_text",
32646
- where: "source_type IN ('source_chunk', 'source_obsidian_chunk')",
32647
- scannedAt
32648
- });
32649
32523
  }
32650
32524
  function up1312(db) {
32651
32525
  const table = db.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'dreaming_attention'").get();
@@ -32749,13 +32623,13 @@ function up1332(db) {
32749
32623
  AND error IS NOT NULL;
32750
32624
  `);
32751
32625
  }
32752
- function tableExists32(db, table) {
32626
+ function tableExists22(db, table) {
32753
32627
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
32754
32628
  }
32755
32629
  function up1342(db) {
32756
- if (!tableExists32(db, "memory_jobs"))
32630
+ if (!tableExists22(db, "memory_jobs"))
32757
32631
  return;
32758
- if (!tableExists32(db, "job_cancellations")) {
32632
+ if (!tableExists22(db, "job_cancellations")) {
32759
32633
  throw new Error("job_cancellations table missing; cannot retire structural jobs without an audit trail");
32760
32634
  }
32761
32635
  db.prepare(`
@@ -32984,12 +32858,12 @@ function up1422(db) {
32984
32858
  if (!cols.has(name))
32985
32859
  db.exec(`ALTER TABLE dreaming_passes ADD COLUMN ${name} ${type}`);
32986
32860
  }
32987
- function hasColumn252(db, table, column) {
32861
+ function hasColumn242(db, table, column) {
32988
32862
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
32989
32863
  return rows.some((row) => row.name === column);
32990
32864
  }
32991
32865
  function addColumnIfMissing282(db, table, column, definition) {
32992
- if (!hasColumn252(db, table, column))
32866
+ if (!hasColumn242(db, table, column))
32993
32867
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
32994
32868
  }
32995
32869
  function up1432(db) {
@@ -33861,6 +33735,138 @@ function up1622(db) {
33861
33735
  END;
33862
33736
  `);
33863
33737
  }
33738
+ function up1632(db) {
33739
+ db.exec(`
33740
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_ai;
33741
+ DROP TRIGGER IF EXISTS memory_content_safety_head_freshness_au;
33742
+ DROP INDEX IF EXISTS idx_memory_content_safety_status;
33743
+ DROP INDEX IF EXISTS idx_memory_content_safety_eligibility;
33744
+ DROP TABLE IF EXISTS memory_content_safety;
33745
+ `);
33746
+ }
33747
+ var COLUMNS32 = ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"];
33748
+ function up1642(db) {
33749
+ const cols = db.prepare("PRAGMA table_info(entity_attributes)").all();
33750
+ for (const column of COLUMNS32) {
33751
+ if (!cols.some((col) => col.name === column)) {
33752
+ db.exec(`ALTER TABLE entity_attributes ADD COLUMN ${column} TEXT`);
33753
+ }
33754
+ }
33755
+ }
33756
+ function up1652(db) {
33757
+ const passColumns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
33758
+ if (!passColumns.some((column) => column.name === "scope_key")) {
33759
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN scope_key TEXT");
33760
+ }
33761
+ db.exec(`
33762
+ CREATE TABLE IF NOT EXISTS dreaming_history_nodes (
33763
+ agent_id TEXT NOT NULL,
33764
+ scope_key TEXT NOT NULL,
33765
+ level INTEGER NOT NULL,
33766
+ idx INTEGER NOT NULL,
33767
+ pass_id TEXT,
33768
+ text TEXT NOT NULL,
33769
+ tokens_input INTEGER,
33770
+ tokens_output INTEGER,
33771
+ tokens_cache_read INTEGER,
33772
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
33773
+ PRIMARY KEY (agent_id, scope_key, level, idx)
33774
+ );
33775
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_dreaming_history_nodes_pass
33776
+ ON dreaming_history_nodes(pass_id) WHERE pass_id IS NOT NULL;
33777
+ `);
33778
+ }
33779
+ function up1662(db) {
33780
+ const columns = db.prepare("PRAGMA table_info(dreaming_passes)").all();
33781
+ if (!columns.some((column) => column.name === "tokens_peak_context")) {
33782
+ db.exec("ALTER TABLE dreaming_passes ADD COLUMN tokens_peak_context INTEGER");
33783
+ }
33784
+ }
33785
+ function up1672(db) {
33786
+ const sql = readMemoriesFtsSql2(db);
33787
+ if (sql !== null && !memoriesFtsNeedsTokenizerRepair2(sql))
33788
+ return;
33789
+ recreateMemoriesFts2(db);
33790
+ }
33791
+ function hasTable52(db, table) {
33792
+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
33793
+ }
33794
+ function hasColumn252(db, table, column) {
33795
+ return db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column);
33796
+ }
33797
+ function up1682(db) {
33798
+ if (!hasTable52(db, "entity_attributes") || !hasTable52(db, "entity_aspects") || !hasTable52(db, "entities") || !hasColumn252(db, "entity_attributes", "source_root") || !hasColumn252(db, "entities", "source_root")) {
33799
+ return;
33800
+ }
33801
+ const now = new Date().toISOString();
33802
+ db.exec(`
33803
+ CREATE TEMP TABLE retired_source_paragraphs AS
33804
+ SELECT attr.id, attr.memory_id, attr.agent_id, asp.entity_id
33805
+ FROM entity_attributes attr
33806
+ JOIN entity_aspects asp ON asp.id = attr.aspect_id
33807
+ JOIN entities e ON e.id = asp.entity_id
33808
+ WHERE e.entity_type IN ('source_document', 'source_document_reference')
33809
+ AND attr.source_root IS NOT NULL
33810
+ AND attr.source_root = e.source_root
33811
+ AND attr.source_id = e.source_id
33812
+ AND attr.source_root NOT IN ('dreaming', 'dreaming_attention')
33813
+ `);
33814
+ if (hasColumn252(db, "entity_attributes", "memory_id") && hasTable52(db, "memories")) {
33815
+ if (hasTable52(db, "memory_history")) {
33816
+ db.prepare(`INSERT INTO memory_history (id, memory_id, event, old_content, new_content, changed_by, reason, metadata, created_at)
33817
+ SELECT lower(hex(randomblob(16))), mem.id, 'deleted', mem.content, NULL, 'migration:168',
33818
+ 'Source paragraph claims retired', '{"force":true}', ?
33819
+ FROM memories mem
33820
+ JOIN retired_source_paragraphs retired ON retired.memory_id = mem.id
33821
+ WHERE mem.is_deleted = 0`).run(now);
33822
+ }
33823
+ if (hasTable52(db, "derived_memory_sources") && hasColumn252(db, "memories", "stale_at")) {
33824
+ db.prepare(`UPDATE memories
33825
+ SET stale_at = ?
33826
+ WHERE stale_at IS NULL
33827
+ AND is_deleted = 0
33828
+ AND id IN (
33829
+ SELECT dms.derived_memory_id
33830
+ FROM derived_memory_sources dms
33831
+ JOIN retired_source_paragraphs retired ON retired.agent_id = dms.agent_id
33832
+ WHERE (dms.source_kind = 'memory' AND dms.source_id = retired.memory_id)
33833
+ OR (dms.source_kind = 'ontology_claim' AND dms.source_id = retired.id)
33834
+ )`).run(now);
33835
+ }
33836
+ const forget = [
33837
+ "is_deleted = 1",
33838
+ ...["deleted_at", "updated_at"].filter((column) => hasColumn252(db, "memories", column)).map((column) => `${column} = $now`),
33839
+ ...hasColumn252(db, "memories", "updated_by") ? ["updated_by = 'migration:168'"] : [],
33840
+ ...hasColumn252(db, "memories", "version") ? ["version = version + 1"] : []
33841
+ ];
33842
+ db.prepare(`UPDATE memories
33843
+ SET ${forget.join(", ")}
33844
+ WHERE is_deleted = 0
33845
+ AND id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)`).run({ $now: now });
33846
+ if (hasTable52(db, "memory_entity_mentions")) {
33847
+ db.exec(`
33848
+ DELETE FROM memory_entity_mentions
33849
+ WHERE memory_id IN (SELECT memory_id FROM retired_source_paragraphs WHERE memory_id IS NOT NULL)
33850
+ `);
33851
+ }
33852
+ }
33853
+ if (hasTable52(db, "ontology_contradictions")) {
33854
+ db.prepare(`UPDATE ontology_contradictions
33855
+ SET status = 'resolved', resolved_at = ?, resolution_reason = 'source paragraph claims retired', updated_at = ?
33856
+ WHERE status = 'active'
33857
+ AND (left_attribute_id IN (SELECT id FROM retired_source_paragraphs)
33858
+ OR right_attribute_id IN (SELECT id FROM retired_source_paragraphs))`).run(now, now);
33859
+ }
33860
+ db.exec(`
33861
+ DELETE FROM entity_attributes WHERE id IN (SELECT id FROM retired_source_paragraphs);
33862
+ DELETE FROM entity_aspects
33863
+ WHERE entity_id IN (
33864
+ SELECT id FROM entities WHERE entity_type IN ('source_document', 'source_document_reference')
33865
+ )
33866
+ AND NOT EXISTS (SELECT 1 FROM entity_attributes attr WHERE attr.aspect_id = entity_aspects.id);
33867
+ DROP TABLE retired_source_paragraphs;
33868
+ `);
33869
+ }
33864
33870
  var MIGRATIONS2 = [
33865
33871
  {
33866
33872
  version: 1,
@@ -33931,7 +33937,7 @@ var MIGRATIONS2 = [
33931
33937
  {
33932
33938
  version: 11,
33933
33939
  name: "session-scores",
33934
- up: up164,
33940
+ up: up1610,
33935
33941
  artifacts: { tables: ["session_scores"] }
33936
33942
  },
33937
33943
  {
@@ -34870,8 +34876,7 @@ var MIGRATIONS2 = [
34870
34876
  {
34871
34877
  version: 125,
34872
34878
  name: "memory-content-safety",
34873
- up: up1302,
34874
- artifacts: { tables: ["memory_content_safety"] }
34879
+ up: up1302
34875
34880
  },
34876
34881
  {
34877
34882
  version: 126,
@@ -35065,7 +35070,7 @@ var MIGRATIONS2 = [
35065
35070
  {
35066
35071
  version: 151,
35067
35072
  name: "transcript-import-bytes",
35068
- up: up163,
35073
+ up: up169,
35069
35074
  artifacts: {
35070
35075
  tables: [
35071
35076
  "source_import_chunks",
@@ -35173,6 +35178,48 @@ var MIGRATIONS2 = [
35173
35178
  name: "generic-entity-prune-scan-generation",
35174
35179
  up: up1622,
35175
35180
  artifacts: { tables: ["generic_entity_prune_scan_state"] }
35181
+ },
35182
+ {
35183
+ version: 163,
35184
+ name: "retire-memory-content-safety",
35185
+ up: up1632
35186
+ },
35187
+ {
35188
+ version: 164,
35189
+ name: "claim-event-time",
35190
+ up: up1642,
35191
+ artifacts: {
35192
+ columns: ["occurred_start", "occurred_end", "valid_from", "valid_until", "time_precision"].map((column) => ({
35193
+ table: "entity_attributes",
35194
+ column
35195
+ }))
35196
+ }
35197
+ },
35198
+ {
35199
+ version: 165,
35200
+ name: "dreaming-history",
35201
+ up: up1652,
35202
+ artifacts: {
35203
+ tables: ["dreaming_history_nodes"],
35204
+ indexes: ["idx_dreaming_history_nodes_pass"],
35205
+ columns: [{ table: "dreaming_passes", column: "scope_key" }]
35206
+ }
35207
+ },
35208
+ {
35209
+ version: 166,
35210
+ name: "dreaming-pass-peak-context",
35211
+ up: up1662,
35212
+ artifacts: { columns: [{ table: "dreaming_passes", column: "tokens_peak_context" }] }
35213
+ },
35214
+ {
35215
+ version: 167,
35216
+ name: "memories-fts-porter",
35217
+ up: up1672
35218
+ },
35219
+ {
35220
+ version: 168,
35221
+ name: "retire-source-paragraph-claims",
35222
+ up: up1682
35176
35223
  }
35177
35224
  ];
35178
35225
  var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
@@ -35414,6 +35461,37 @@ var PIPELINE_PROVIDER_CHOICES2 = [
35414
35461
  var SYNTHESIS_PROVIDER_CHOICES2 = PIPELINE_PROVIDER_CHOICES2.filter((provider) => provider !== "command");
35415
35462
  var PIPELINE_PROVIDER_SET2 = new Set(PIPELINE_PROVIDER_CHOICES2);
35416
35463
  var SYNTHESIS_PROVIDER_SET2 = new Set(SYNTHESIS_PROVIDER_CHOICES2);
35464
+ var SECRET_NAMES2 = "(?:access[_-]?token|api[_-]?key|apikey|auth[_-]?token|client[_-]?secret|passw(?:or)?d|refresh[_-]?token|private[_-]?key|secret(?:[_-]?key)?|token)";
35465
+ var SECRET_VALUE2 = `(?=[^\\s"',;&<>()\\[\\]{}$]*\\d)[^\\s"',;&<>()\\[\\]{}$]{8,}`;
35466
+ var PATTERNS2 = [
35467
+ {
35468
+ kind: "private_key",
35469
+ pattern: /-----BEGIN (?:[A-Z]+ )*PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )*PRIVATE KEY-----/g
35470
+ },
35471
+ {
35472
+ kind: "provider_key",
35473
+ 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
35474
+ },
35475
+ {
35476
+ kind: "jwt",
35477
+ pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
35478
+ },
35479
+ {
35480
+ kind: "bearer_token",
35481
+ pattern: /\bBearer\s+([A-Za-z0-9._~+/-]{16,}=*)/g,
35482
+ valueGroup: 1
35483
+ },
35484
+ {
35485
+ kind: "secret_assignment",
35486
+ pattern: new RegExp(`\\b${SECRET_NAMES2}["']?\\s*[:=]\\s*["']?(${SECRET_VALUE2})`, "gi"),
35487
+ valueGroup: 1
35488
+ },
35489
+ {
35490
+ kind: "secret_assignment",
35491
+ pattern: new RegExp(`\\b[A-Z][A-Z0-9_]*(?:API_KEY|TOKEN|SECRET|PASSWORD)\\s*=\\s*["']?(${SECRET_VALUE2})`, "g"),
35492
+ valueGroup: 1
35493
+ }
35494
+ ];
35417
35495
  var LOOPBACK_HOST2 = "127.0.0.1";
35418
35496
  var LOCAL_BINDS2 = new Set([LOOPBACK_HOST2, "localhost", "::1", "::ffff:127.0.0.1"]);
35419
35497
  function parseSimpleYaml(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-gemini",
3
- "version": "0.236.1",
3
+ "version": "0.237.0",
4
4
  "description": "Signet connector for Gemini CLI",
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.1",
28
- "@signetai/core": "0.236.1"
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",