@signetai/connector-codex 0.193.1 → 0.193.2

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 +389 -13
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -6917,6 +6917,99 @@ var PIPELINE_PROVIDER_CHOICES = [
6917
6917
  var SYNTHESIS_PROVIDER_CHOICES = PIPELINE_PROVIDER_CHOICES.filter((provider) => provider !== "command");
6918
6918
  var PIPELINE_PROVIDER_SET = new Set(PIPELINE_PROVIDER_CHOICES);
6919
6919
  var SYNTHESIS_PROVIDER_SET = new Set(SYNTHESIS_PROVIDER_CHOICES);
6920
+ var MEMORY_CONTENT_SAFETY_POLICY_VERSION = "memory-content-safety-v1";
6921
+ var MEMORY_CONTENT_SAFETY_REASONS = [
6922
+ "prompt_injection",
6923
+ "exfiltration",
6924
+ "credential_harvesting",
6925
+ "malicious_shell",
6926
+ "tool_directive",
6927
+ "invisible_unicode"
6928
+ ];
6929
+ 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;
6930
+ var STRONG_DEFENSIVE_CONTEXT_RE = /\b(?:security\s+(?:guidance|discussion|analysis)|threat\s+model|defensive)\b/i;
6931
+ var REPORTING_CONTEXT_RE = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b/i;
6932
+ 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;
6933
+ 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;
6934
+ 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;
6935
+ var PROMPT_INJECTION_RES = [
6936
+ /\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,
6937
+ /\b(?:new|following|these)\s+(?:(?:system|developer|assistant|hidden)\s+)?instructions?\b/i,
6938
+ /(?:^|\n)\s*(?:system|developer|instruction|prompt)\s*:/im,
6939
+ /<\s*(?:system|developer|assistant|instruction|prompt)\b[^>]*>/i,
6940
+ /\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
6941
+ ];
6942
+ var TOOL_DIRECTIVE_RES = [
6943
+ /<\s*(?:tool[_-]?call|function[_-]?call|invoke|tool)\b/i,
6944
+ /\b(?:assistant|system)\s+to\s*=\s*[a-z0-9_.-]+/i,
6945
+ /\b(?:call|invoke|use|run|execute)\s+(?:the\s+)?[a-z0-9_.-]+\s+tool\b/i
6946
+ ];
6947
+ 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;
6948
+ 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;
6949
+ 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;
6950
+ 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;
6951
+ function matchHasDefensiveContext(content, match) {
6952
+ if (!match || !match[0])
6953
+ return false;
6954
+ const start = match.index ?? 0;
6955
+ const before = content.slice(Math.max(0, start - 120), start);
6956
+ const after = content.slice(start + match[0].length, start + match[0].length + 160);
6957
+ 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);
6958
+ }
6959
+ function hasActionableMatch(content, patterns) {
6960
+ return patterns.some((pattern) => {
6961
+ const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
6962
+ const searchable = new RegExp(pattern.source, flags);
6963
+ let match;
6964
+ while ((match = searchable.exec(content)) !== null) {
6965
+ if (!matchHasDefensiveContext(content, match))
6966
+ return true;
6967
+ if (match[0].length === 0)
6968
+ searchable.lastIndex += 1;
6969
+ }
6970
+ return false;
6971
+ });
6972
+ }
6973
+ function hasDangerousShell(content) {
6974
+ const searchable = new RegExp(DANGEROUS_SHELL_RE.source, `${DANGEROUS_SHELL_RE.flags}g`);
6975
+ let match;
6976
+ while ((match = searchable.exec(content)) !== null) {
6977
+ if (matchHasDefensiveContext(content, match))
6978
+ continue;
6979
+ const end = (match.index ?? 0) + match[0].length;
6980
+ const after = content.slice(end, end + 160);
6981
+ if (!STRONG_DEFENSIVE_CONTEXT_RE.test(after) && !REPORTING_AFTER_RE.test(after))
6982
+ return true;
6983
+ if (match[0].length === 0)
6984
+ searchable.lastIndex += 1;
6985
+ }
6986
+ return false;
6987
+ }
6988
+ function scanMemoryContent(content) {
6989
+ const raw = typeof content === "string" ? content : String(content ?? "");
6990
+ const normalized = raw.normalize("NFKC");
6991
+ const reasons = new Set;
6992
+ if (INVISIBLE_UNICODE_RE.test(raw))
6993
+ reasons.add("invisible_unicode");
6994
+ if (hasActionableMatch(normalized, PROMPT_INJECTION_RES))
6995
+ reasons.add("prompt_injection");
6996
+ if (hasActionableMatch(normalized, TOOL_DIRECTIVE_RES))
6997
+ reasons.add("tool_directive");
6998
+ if (hasActionableMatch(normalized, [EXFILTRATION_RE, EXFILTRATION_REVERSE]))
6999
+ reasons.add("exfiltration");
7000
+ if (hasActionableMatch(normalized, [CREDENTIAL_HARVESTING_RE]))
7001
+ reasons.add("credential_harvesting");
7002
+ if (hasDangerousShell(normalized))
7003
+ reasons.add("malicious_shell");
7004
+ const orderedReasons = MEMORY_CONTENT_SAFETY_REASONS.filter((reason) => reasons.has(reason));
7005
+ const status = orderedReasons.length === 0 ? "clean" : orderedReasons.every((reason) => reason === "invisible_unicode") ? "tainted" : "blocked";
7006
+ return {
7007
+ status,
7008
+ contextEligible: status === "clean",
7009
+ reasons: orderedReasons,
7010
+ policyVersion: MEMORY_CONTENT_SAFETY_POLICY_VERSION
7011
+ };
7012
+ }
6920
7013
  var DAEMON_DERIVED_MEMORY_SOURCE_TYPES = ["extract", "aggregate-recall", "session_end", "checkpoint", "dreaming"];
6921
7014
  var MEMORIES_FTS_TOKENIZER = "unicode61";
6922
7015
  function normalizeSql(sql) {
@@ -10895,6 +10988,95 @@ function up124(db) {
10895
10988
  ON imported_source_lifecycle(agent_id, status, updated_at DESC);
10896
10989
  `);
10897
10990
  }
10991
+ function tableExists2(db, table) {
10992
+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
10993
+ }
10994
+ function hasColumn24(db, table, column) {
10995
+ return db.prepare(`PRAGMA table_info("${table}")`).all().some((row) => row.name === column);
10996
+ }
10997
+ function backfill(db, rows, sourceKind, scannedAt) {
10998
+ const statement = db.prepare(`INSERT INTO memory_content_safety
10999
+ (agent_id, source_kind, source_id, status, context_eligible, reasons_json, policy_version, scanned_at)
11000
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
11001
+ ON CONFLICT(agent_id, source_kind, source_id) DO UPDATE SET
11002
+ status = excluded.status,
11003
+ context_eligible = excluded.context_eligible,
11004
+ reasons_json = excluded.reasons_json,
11005
+ policy_version = excluded.policy_version,
11006
+ scanned_at = excluded.scanned_at`);
11007
+ for (const row of rows) {
11008
+ const sourceId = row.source_id?.trim();
11009
+ if (!sourceId)
11010
+ continue;
11011
+ const assessment = scanMemoryContent(row.content ?? "");
11012
+ 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);
11013
+ }
11014
+ }
11015
+ function backfillTable(db, params) {
11016
+ if (!tableExists2(db, params.table) || !hasColumn24(db, params.table, params.sourceIdColumn) || !hasColumn24(db, params.table, params.contentColumn))
11017
+ return;
11018
+ const agentColumn = hasColumn24(db, params.table, "agent_id") ? "COALESCE(NULLIF(TRIM(agent_id), ''), 'default')" : "'default'";
11019
+ const rows = db.prepare(`SELECT ${agentColumn} AS agent_id, ${params.sourceIdColumn} AS source_id, ${params.contentColumn} AS content
11020
+ FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
11021
+ backfill(db, rows, params.sourceKind, params.scannedAt);
11022
+ }
11023
+ function up125(db) {
11024
+ db.exec(`
11025
+ CREATE TABLE IF NOT EXISTS memory_content_safety (
11026
+ agent_id TEXT NOT NULL,
11027
+ source_kind TEXT NOT NULL CHECK (source_kind IN ('memory', 'artifact', 'transcript', 'summary', 'source_chunk')),
11028
+ source_id TEXT NOT NULL,
11029
+ status TEXT NOT NULL CHECK (status IN ('clean', 'tainted', 'blocked')),
11030
+ context_eligible INTEGER NOT NULL CHECK (context_eligible IN (0, 1)),
11031
+ reasons_json TEXT NOT NULL DEFAULT '[]',
11032
+ policy_version TEXT NOT NULL,
11033
+ scanned_at TEXT NOT NULL,
11034
+ PRIMARY KEY (agent_id, source_kind, source_id)
11035
+ );
11036
+
11037
+ CREATE INDEX IF NOT EXISTS idx_memory_content_safety_status
11038
+ ON memory_content_safety(agent_id, status, source_kind);
11039
+ CREATE INDEX IF NOT EXISTS idx_memory_content_safety_eligibility
11040
+ ON memory_content_safety(agent_id, source_kind, context_eligible);
11041
+ `);
11042
+ const scannedAt = new Date().toISOString();
11043
+ backfillTable(db, {
11044
+ table: "memories",
11045
+ sourceKind: "memory",
11046
+ sourceIdColumn: "id",
11047
+ contentColumn: "content",
11048
+ scannedAt
11049
+ });
11050
+ backfillTable(db, {
11051
+ table: "memory_artifacts",
11052
+ sourceKind: "artifact",
11053
+ sourceIdColumn: "source_path",
11054
+ contentColumn: "content",
11055
+ scannedAt
11056
+ });
11057
+ backfillTable(db, {
11058
+ table: "session_transcripts",
11059
+ sourceKind: "transcript",
11060
+ sourceIdColumn: "session_key",
11061
+ contentColumn: "content",
11062
+ scannedAt
11063
+ });
11064
+ backfillTable(db, {
11065
+ table: "session_summaries",
11066
+ sourceKind: "summary",
11067
+ sourceIdColumn: "id",
11068
+ contentColumn: "content",
11069
+ scannedAt
11070
+ });
11071
+ backfillTable(db, {
11072
+ table: "embeddings",
11073
+ sourceKind: "source_chunk",
11074
+ sourceIdColumn: "id",
11075
+ contentColumn: "chunk_text",
11076
+ where: "source_type IN ('source_chunk', 'source_obsidian_chunk')",
11077
+ scannedAt
11078
+ });
11079
+ }
10898
11080
  var MIGRATIONS = [
10899
11081
  {
10900
11082
  version: 1,
@@ -11903,6 +12085,12 @@ var MIGRATIONS = [
11903
12085
  artifacts: {
11904
12086
  tables: ["imported_source_lifecycle"]
11905
12087
  }
12088
+ },
12089
+ {
12090
+ version: 125,
12091
+ name: "memory-content-safety",
12092
+ up: up125,
12093
+ artifacts: { tables: ["memory_content_safety"] }
11906
12094
  }
11907
12095
  ];
11908
12096
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
@@ -19235,6 +19423,99 @@ var PIPELINE_PROVIDER_CHOICES2 = [
19235
19423
  var SYNTHESIS_PROVIDER_CHOICES2 = PIPELINE_PROVIDER_CHOICES2.filter((provider) => provider !== "command");
19236
19424
  var PIPELINE_PROVIDER_SET2 = new Set(PIPELINE_PROVIDER_CHOICES2);
19237
19425
  var SYNTHESIS_PROVIDER_SET2 = new Set(SYNTHESIS_PROVIDER_CHOICES2);
19426
+ var MEMORY_CONTENT_SAFETY_POLICY_VERSION2 = "memory-content-safety-v1";
19427
+ var MEMORY_CONTENT_SAFETY_REASONS2 = [
19428
+ "prompt_injection",
19429
+ "exfiltration",
19430
+ "credential_harvesting",
19431
+ "malicious_shell",
19432
+ "tool_directive",
19433
+ "invisible_unicode"
19434
+ ];
19435
+ 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;
19436
+ var STRONG_DEFENSIVE_CONTEXT_RE2 = /\b(?:security\s+(?:guidance|discussion|analysis)|threat\s+model|defensive)\b/i;
19437
+ var REPORTING_CONTEXT_RE2 = /\b(?:example|illustrat\w*|sample|quote|quoted|detector|scanner|classif\w*)\b/i;
19438
+ 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;
19439
+ 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;
19440
+ 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;
19441
+ var PROMPT_INJECTION_RES2 = [
19442
+ /\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,
19443
+ /\b(?:new|following|these)\s+(?:(?:system|developer|assistant|hidden)\s+)?instructions?\b/i,
19444
+ /(?:^|\n)\s*(?:system|developer|instruction|prompt)\s*:/im,
19445
+ /<\s*(?:system|developer|assistant|instruction|prompt)\b[^>]*>/i,
19446
+ /\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
19447
+ ];
19448
+ var TOOL_DIRECTIVE_RES2 = [
19449
+ /<\s*(?:tool[_-]?call|function[_-]?call|invoke|tool)\b/i,
19450
+ /\b(?:assistant|system)\s+to\s*=\s*[a-z0-9_.-]+/i,
19451
+ /\b(?:call|invoke|use|run|execute)\s+(?:the\s+)?[a-z0-9_.-]+\s+tool\b/i
19452
+ ];
19453
+ 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;
19454
+ 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;
19455
+ 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;
19456
+ 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;
19457
+ function matchHasDefensiveContext2(content, match) {
19458
+ if (!match || !match[0])
19459
+ return false;
19460
+ const start = match.index ?? 0;
19461
+ const before = content.slice(Math.max(0, start - 120), start);
19462
+ const after = content.slice(start + match[0].length, start + match[0].length + 160);
19463
+ 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);
19464
+ }
19465
+ function hasActionableMatch2(content, patterns) {
19466
+ return patterns.some((pattern) => {
19467
+ const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
19468
+ const searchable = new RegExp(pattern.source, flags);
19469
+ let match;
19470
+ while ((match = searchable.exec(content)) !== null) {
19471
+ if (!matchHasDefensiveContext2(content, match))
19472
+ return true;
19473
+ if (match[0].length === 0)
19474
+ searchable.lastIndex += 1;
19475
+ }
19476
+ return false;
19477
+ });
19478
+ }
19479
+ function hasDangerousShell2(content) {
19480
+ const searchable = new RegExp(DANGEROUS_SHELL_RE2.source, `${DANGEROUS_SHELL_RE2.flags}g`);
19481
+ let match;
19482
+ while ((match = searchable.exec(content)) !== null) {
19483
+ if (matchHasDefensiveContext2(content, match))
19484
+ continue;
19485
+ const end = (match.index ?? 0) + match[0].length;
19486
+ const after = content.slice(end, end + 160);
19487
+ if (!STRONG_DEFENSIVE_CONTEXT_RE2.test(after) && !REPORTING_AFTER_RE2.test(after))
19488
+ return true;
19489
+ if (match[0].length === 0)
19490
+ searchable.lastIndex += 1;
19491
+ }
19492
+ return false;
19493
+ }
19494
+ function scanMemoryContent2(content) {
19495
+ const raw = typeof content === "string" ? content : String(content ?? "");
19496
+ const normalized = raw.normalize("NFKC");
19497
+ const reasons = new Set;
19498
+ if (INVISIBLE_UNICODE_RE2.test(raw))
19499
+ reasons.add("invisible_unicode");
19500
+ if (hasActionableMatch2(normalized, PROMPT_INJECTION_RES2))
19501
+ reasons.add("prompt_injection");
19502
+ if (hasActionableMatch2(normalized, TOOL_DIRECTIVE_RES2))
19503
+ reasons.add("tool_directive");
19504
+ if (hasActionableMatch2(normalized, [EXFILTRATION_RE2, EXFILTRATION_REVERSE2]))
19505
+ reasons.add("exfiltration");
19506
+ if (hasActionableMatch2(normalized, [CREDENTIAL_HARVESTING_RE2]))
19507
+ reasons.add("credential_harvesting");
19508
+ if (hasDangerousShell2(normalized))
19509
+ reasons.add("malicious_shell");
19510
+ const orderedReasons = MEMORY_CONTENT_SAFETY_REASONS2.filter((reason) => reasons.has(reason));
19511
+ const status = orderedReasons.length === 0 ? "clean" : orderedReasons.every((reason) => reason === "invisible_unicode") ? "tainted" : "blocked";
19512
+ return {
19513
+ status,
19514
+ contextEligible: status === "clean",
19515
+ reasons: orderedReasons,
19516
+ policyVersion: MEMORY_CONTENT_SAFETY_POLICY_VERSION2
19517
+ };
19518
+ }
19238
19519
  var DAEMON_DERIVED_MEMORY_SOURCE_TYPES2 = ["extract", "aggregate-recall", "session_end", "checkpoint", "dreaming"];
19239
19520
  var MEMORIES_FTS_TOKENIZER2 = "unicode61";
19240
19521
  function normalizeSql2(sql) {
@@ -19286,7 +19567,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
19286
19567
  return true;
19287
19568
  return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
19288
19569
  }
19289
- function up125(db) {
19570
+ function up126(db) {
19290
19571
  db.exec(`
19291
19572
  CREATE TABLE IF NOT EXISTS schema_migrations (
19292
19573
  version INTEGER PRIMARY KEY,
@@ -19375,12 +19656,12 @@ function up125(db) {
19375
19656
  } catch {}
19376
19657
  createMemoriesFts2(db);
19377
19658
  }
19378
- function hasColumn24(db, table, column) {
19659
+ function hasColumn25(db, table, column) {
19379
19660
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
19380
19661
  return rows.some((r) => r.name === column);
19381
19662
  }
19382
19663
  function addColumnIfMissing27(db, table, column, definition) {
19383
- if (!hasColumn24(db, table, column)) {
19664
+ if (!hasColumn25(db, table, column)) {
19384
19665
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
19385
19666
  }
19386
19667
  }
@@ -19530,12 +19811,12 @@ function up310(db) {
19530
19811
  WHERE content_hash IS NOT NULL AND is_deleted = 0
19531
19812
  `);
19532
19813
  }
19533
- function hasColumn25(db, table, column) {
19814
+ function hasColumn26(db, table, column) {
19534
19815
  const rows = db.prepare(`PRAGMA table_info(${table})`).all();
19535
19816
  return rows.some((r) => r.name === column);
19536
19817
  }
19537
19818
  function addColumnIfMissing32(db, table, column, definition) {
19538
- if (!hasColumn25(db, table, column)) {
19819
+ if (!hasColumn26(db, table, column)) {
19539
19820
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
19540
19821
  }
19541
19822
  }
@@ -19729,7 +20010,7 @@ function up1110(db) {
19729
20010
  ON session_scores(session_key);
19730
20011
  `);
19731
20012
  }
19732
- function up126(db) {
20013
+ function up127(db) {
19733
20014
  db.exec(`
19734
20015
  CREATE TABLE IF NOT EXISTS scheduled_tasks (
19735
20016
  id TEXT PRIMARY KEY,
@@ -22521,7 +22802,7 @@ function up1032(db) {
22521
22802
  )
22522
22803
  `);
22523
22804
  }
22524
- function tableExists2(db, table) {
22805
+ function tableExists3(db, table) {
22525
22806
  return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) !== undefined;
22526
22807
  }
22527
22808
  function hasColumn162(db, table, column) {
@@ -22543,7 +22824,7 @@ function up1042(db) {
22543
22824
  CREATE INDEX IF NOT EXISTS idx_derived_memory_sources_source
22544
22825
  ON derived_memory_sources(agent_id, source_kind, source_id);
22545
22826
  `);
22546
- if (tableExists2(db, "aggregate_evidence_sources")) {
22827
+ if (tableExists3(db, "aggregate_evidence_sources")) {
22547
22828
  db.exec(`
22548
22829
  INSERT OR IGNORE INTO derived_memory_sources
22549
22830
  (derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
@@ -22551,7 +22832,7 @@ function up1042(db) {
22551
22832
  FROM aggregate_evidence_sources
22552
22833
  `);
22553
22834
  }
22554
- if (tableExists2(db, "aggregate_memory_sources")) {
22835
+ if (tableExists3(db, "aggregate_memory_sources")) {
22555
22836
  db.exec(`
22556
22837
  INSERT OR IGNORE INTO derived_memory_sources
22557
22838
  (derived_memory_id, source_kind, source_id, source_path, agent_id, created_at)
@@ -22559,10 +22840,10 @@ function up1042(db) {
22559
22840
  FROM aggregate_memory_sources
22560
22841
  `);
22561
22842
  }
22562
- if (tableExists2(db, "memories") && !hasColumn162(db, "memories", "stale_at")) {
22843
+ if (tableExists3(db, "memories") && !hasColumn162(db, "memories", "stale_at")) {
22563
22844
  db.exec("ALTER TABLE memories ADD COLUMN stale_at TEXT");
22564
22845
  }
22565
- if (tableExists2(db, "memories")) {
22846
+ if (tableExists3(db, "memories")) {
22566
22847
  db.exec(`
22567
22848
  CREATE INDEX IF NOT EXISTS idx_memories_stale_derived
22568
22849
  ON memories(agent_id, stale_at)
@@ -23213,11 +23494,100 @@ function up1242(db) {
23213
23494
  ON imported_source_lifecycle(agent_id, status, updated_at DESC);
23214
23495
  `);
23215
23496
  }
23497
+ function tableExists22(db, table) {
23498
+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
23499
+ }
23500
+ function hasColumn242(db, table, column) {
23501
+ return db.prepare(`PRAGMA table_info("${table}")`).all().some((row) => row.name === column);
23502
+ }
23503
+ function backfill2(db, rows, sourceKind, scannedAt) {
23504
+ const statement = db.prepare(`INSERT INTO memory_content_safety
23505
+ (agent_id, source_kind, source_id, status, context_eligible, reasons_json, policy_version, scanned_at)
23506
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
23507
+ ON CONFLICT(agent_id, source_kind, source_id) DO UPDATE SET
23508
+ status = excluded.status,
23509
+ context_eligible = excluded.context_eligible,
23510
+ reasons_json = excluded.reasons_json,
23511
+ policy_version = excluded.policy_version,
23512
+ scanned_at = excluded.scanned_at`);
23513
+ for (const row of rows) {
23514
+ const sourceId = row.source_id?.trim();
23515
+ if (!sourceId)
23516
+ continue;
23517
+ const assessment = scanMemoryContent2(row.content ?? "");
23518
+ 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);
23519
+ }
23520
+ }
23521
+ function backfillTable2(db, params) {
23522
+ if (!tableExists22(db, params.table) || !hasColumn242(db, params.table, params.sourceIdColumn) || !hasColumn242(db, params.table, params.contentColumn))
23523
+ return;
23524
+ const agentColumn = hasColumn242(db, params.table, "agent_id") ? "COALESCE(NULLIF(TRIM(agent_id), ''), 'default')" : "'default'";
23525
+ const rows = db.prepare(`SELECT ${agentColumn} AS agent_id, ${params.sourceIdColumn} AS source_id, ${params.contentColumn} AS content
23526
+ FROM ${params.table}${params.where ? ` WHERE ${params.where}` : ""}`).all();
23527
+ backfill2(db, rows, params.sourceKind, params.scannedAt);
23528
+ }
23529
+ function up1252(db) {
23530
+ db.exec(`
23531
+ CREATE TABLE IF NOT EXISTS memory_content_safety (
23532
+ agent_id TEXT NOT NULL,
23533
+ source_kind TEXT NOT NULL CHECK (source_kind IN ('memory', 'artifact', 'transcript', 'summary', 'source_chunk')),
23534
+ source_id TEXT NOT NULL,
23535
+ status TEXT NOT NULL CHECK (status IN ('clean', 'tainted', 'blocked')),
23536
+ context_eligible INTEGER NOT NULL CHECK (context_eligible IN (0, 1)),
23537
+ reasons_json TEXT NOT NULL DEFAULT '[]',
23538
+ policy_version TEXT NOT NULL,
23539
+ scanned_at TEXT NOT NULL,
23540
+ PRIMARY KEY (agent_id, source_kind, source_id)
23541
+ );
23542
+
23543
+ CREATE INDEX IF NOT EXISTS idx_memory_content_safety_status
23544
+ ON memory_content_safety(agent_id, status, source_kind);
23545
+ CREATE INDEX IF NOT EXISTS idx_memory_content_safety_eligibility
23546
+ ON memory_content_safety(agent_id, source_kind, context_eligible);
23547
+ `);
23548
+ const scannedAt = new Date().toISOString();
23549
+ backfillTable2(db, {
23550
+ table: "memories",
23551
+ sourceKind: "memory",
23552
+ sourceIdColumn: "id",
23553
+ contentColumn: "content",
23554
+ scannedAt
23555
+ });
23556
+ backfillTable2(db, {
23557
+ table: "memory_artifacts",
23558
+ sourceKind: "artifact",
23559
+ sourceIdColumn: "source_path",
23560
+ contentColumn: "content",
23561
+ scannedAt
23562
+ });
23563
+ backfillTable2(db, {
23564
+ table: "session_transcripts",
23565
+ sourceKind: "transcript",
23566
+ sourceIdColumn: "session_key",
23567
+ contentColumn: "content",
23568
+ scannedAt
23569
+ });
23570
+ backfillTable2(db, {
23571
+ table: "session_summaries",
23572
+ sourceKind: "summary",
23573
+ sourceIdColumn: "id",
23574
+ contentColumn: "content",
23575
+ scannedAt
23576
+ });
23577
+ backfillTable2(db, {
23578
+ table: "embeddings",
23579
+ sourceKind: "source_chunk",
23580
+ sourceIdColumn: "id",
23581
+ contentColumn: "chunk_text",
23582
+ where: "source_type IN ('source_chunk', 'source_obsidian_chunk')",
23583
+ scannedAt
23584
+ });
23585
+ }
23216
23586
  var MIGRATIONS2 = [
23217
23587
  {
23218
23588
  version: 1,
23219
23589
  name: "baseline",
23220
- up: up125,
23590
+ up: up126,
23221
23591
  artifacts: { tables: ["memories", "conversations", "embeddings"] }
23222
23592
  },
23223
23593
  {
@@ -23289,7 +23659,7 @@ var MIGRATIONS2 = [
23289
23659
  {
23290
23660
  version: 12,
23291
23661
  name: "scheduled-tasks",
23292
- up: up126,
23662
+ up: up127,
23293
23663
  artifacts: { tables: ["scheduled_tasks", "task_runs"] }
23294
23664
  },
23295
23665
  {
@@ -24221,6 +24591,12 @@ var MIGRATIONS2 = [
24221
24591
  artifacts: {
24222
24592
  tables: ["imported_source_lifecycle"]
24223
24593
  }
24594
+ },
24595
+ {
24596
+ version: 125,
24597
+ name: "memory-content-safety",
24598
+ up: up1252,
24599
+ artifacts: { tables: ["memory_content_safety"] }
24224
24600
  }
24225
24601
  ];
24226
24602
  var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-codex",
3
- "version": "0.193.1",
3
+ "version": "0.193.2",
4
4
  "description": "Signet connector for Codex 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.193.1",
28
- "@signetai/core": "0.193.1"
27
+ "@signetai/connector-base": "0.193.2",
28
+ "@signetai/core": "0.193.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.0.0",