@signetai/connector-codex 0.185.4 → 0.185.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +529 -27
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
3
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
4
4
|
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, readdirSync, rmSync, statSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { basename as basename3, dirname as dirname6, join as join4 } from "node:path";
|
|
@@ -12,6 +12,7 @@ import { dirname as dirname5, isAbsolute, join as join3, relative, sep } from "n
|
|
|
12
12
|
import { createRequire } from "node:module";
|
|
13
13
|
import { dirname, join } from "node:path";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
15
16
|
import { createRequire as createRequire2 } from "node:module";
|
|
16
17
|
import { homedir as homedir4 } from "node:os";
|
|
17
18
|
import { dirname as dirname3, join as join6, resolve as resolve2 } from "node:path";
|
|
@@ -10543,6 +10544,240 @@ function up116(db) {
|
|
|
10543
10544
|
ON cross_agent_messages(delivery_path, delivery_state, delivery_lease_expires_at, delivery_updated_at);
|
|
10544
10545
|
`);
|
|
10545
10546
|
}
|
|
10547
|
+
function hasTable4(db, table) {
|
|
10548
|
+
return db.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
|
|
10549
|
+
}
|
|
10550
|
+
function addColumnIfMissing25(db, table, column, definition) {
|
|
10551
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
10552
|
+
if (columns.some((row) => row.name === column))
|
|
10553
|
+
return;
|
|
10554
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
10555
|
+
}
|
|
10556
|
+
function tableColumns(db, table) {
|
|
10557
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
10558
|
+
return new Set(rows.map((row) => typeof row.name === "string" ? row.name : ""));
|
|
10559
|
+
}
|
|
10560
|
+
function hashTranscript(content) {
|
|
10561
|
+
return createHash("sha256").update(content, "utf8").digest("hex");
|
|
10562
|
+
}
|
|
10563
|
+
function backfillTranscriptHashes(db) {
|
|
10564
|
+
const columns = tableColumns(db, "session_transcripts");
|
|
10565
|
+
if (!columns.has("content_hash") || !columns.has("content"))
|
|
10566
|
+
return;
|
|
10567
|
+
const rows = db.prepare("SELECT session_key, agent_id, content FROM session_transcripts WHERE content_hash IS NULL").all();
|
|
10568
|
+
const update = db.prepare("UPDATE session_transcripts SET content_hash = ? WHERE agent_id = ? AND session_key = ? AND content_hash IS NULL");
|
|
10569
|
+
for (const row of rows) {
|
|
10570
|
+
if (typeof row.content !== "string" || typeof row.session_key !== "string")
|
|
10571
|
+
continue;
|
|
10572
|
+
update.run(hashTranscript(row.content), typeof row.agent_id === "string" ? row.agent_id : "default", row.session_key);
|
|
10573
|
+
}
|
|
10574
|
+
}
|
|
10575
|
+
var COMPLETION_BOUNDARY_REASONS = new Set(["session_closed", "session_clear", "stale_session", "ttl_expired"]);
|
|
10576
|
+
function summaryJobTimestamp(job) {
|
|
10577
|
+
return job.completed_at ?? job.ended_at ?? job.captured_at ?? job.created_at ?? new Date(0).toISOString();
|
|
10578
|
+
}
|
|
10579
|
+
function laterTimestamp(current, candidate) {
|
|
10580
|
+
if (current === null)
|
|
10581
|
+
return candidate;
|
|
10582
|
+
if (candidate === null)
|
|
10583
|
+
return current;
|
|
10584
|
+
const currentMillis = Date.parse(current);
|
|
10585
|
+
const candidateMillis = Date.parse(candidate);
|
|
10586
|
+
if (Number.isFinite(currentMillis) && Number.isFinite(candidateMillis)) {
|
|
10587
|
+
return candidateMillis > currentMillis ? candidate : current;
|
|
10588
|
+
}
|
|
10589
|
+
return candidate > current ? candidate : current;
|
|
10590
|
+
}
|
|
10591
|
+
function isCompletionBoundary(job, columns) {
|
|
10592
|
+
return columns.has("trigger") && job.trigger === "session_end" || columns.has("boundary_reason") && COMPLETION_BOUNDARY_REASONS.has(job.boundary_reason ?? "");
|
|
10593
|
+
}
|
|
10594
|
+
function mergeTranscriptContent(current, next) {
|
|
10595
|
+
if (current.length === 0)
|
|
10596
|
+
return next;
|
|
10597
|
+
if (next.length === 0 || current === next || current.includes(next))
|
|
10598
|
+
return current;
|
|
10599
|
+
if (next.includes(current))
|
|
10600
|
+
return next;
|
|
10601
|
+
return `${current}
|
|
10602
|
+
${next}`;
|
|
10603
|
+
}
|
|
10604
|
+
function backfillTranscriptsFromSummaryJobs(db) {
|
|
10605
|
+
if (!hasTable4(db, "summary_jobs"))
|
|
10606
|
+
return;
|
|
10607
|
+
const summaryColumns = tableColumns(db, "summary_jobs");
|
|
10608
|
+
if (!summaryColumns.has("transcript"))
|
|
10609
|
+
return;
|
|
10610
|
+
const select = (name) => summaryColumns.has(name) ? `"${name}" AS "${name}"` : `NULL AS "${name}"`;
|
|
10611
|
+
const jobs = db.prepare(`SELECT ${[
|
|
10612
|
+
"id",
|
|
10613
|
+
"session_key",
|
|
10614
|
+
"transcript",
|
|
10615
|
+
"harness",
|
|
10616
|
+
"project",
|
|
10617
|
+
"agent_id",
|
|
10618
|
+
"trigger",
|
|
10619
|
+
"boundary_reason",
|
|
10620
|
+
"captured_at",
|
|
10621
|
+
"ended_at",
|
|
10622
|
+
"completed_at",
|
|
10623
|
+
"created_at"
|
|
10624
|
+
].map(select).join(", ")} FROM summary_jobs`).all();
|
|
10625
|
+
const candidates = new Map;
|
|
10626
|
+
for (const job of jobs) {
|
|
10627
|
+
if (typeof job.transcript !== "string" || job.transcript.trim().length === 0)
|
|
10628
|
+
continue;
|
|
10629
|
+
const agentId = typeof job.agent_id === "string" && job.agent_id.length > 0 ? job.agent_id : "default";
|
|
10630
|
+
const sessionKey = typeof job.session_key === "string" && job.session_key.trim().length > 0 ? job.session_key : `legacy-summary-job:${job.id ?? hashTranscript(`${summaryJobTimestamp(job)}\x00${job.transcript}`)}`;
|
|
10631
|
+
const key = `${agentId}\x00${sessionKey}`;
|
|
10632
|
+
const current = candidates.get(key);
|
|
10633
|
+
const timestamp = summaryJobTimestamp(job);
|
|
10634
|
+
const boundary = isCompletionBoundary(job, summaryColumns);
|
|
10635
|
+
const createdAt = job.captured_at ?? job.created_at ?? job.ended_at ?? timestamp;
|
|
10636
|
+
if (!current) {
|
|
10637
|
+
candidates.set(key, {
|
|
10638
|
+
sessionKey,
|
|
10639
|
+
job: { ...job, agent_id: agentId },
|
|
10640
|
+
content: job.transcript,
|
|
10641
|
+
createdAt,
|
|
10642
|
+
completedAt: boundary ? timestamp : null
|
|
10643
|
+
});
|
|
10644
|
+
continue;
|
|
10645
|
+
}
|
|
10646
|
+
const currentTimestamp = summaryJobTimestamp(current.job);
|
|
10647
|
+
const preferred = timestamp > currentTimestamp || timestamp === currentTimestamp && job.transcript.length > current.content.length ? { ...job, agent_id: agentId } : current.job;
|
|
10648
|
+
candidates.set(key, {
|
|
10649
|
+
sessionKey,
|
|
10650
|
+
job: preferred,
|
|
10651
|
+
content: mergeTranscriptContent(current.content, job.transcript),
|
|
10652
|
+
createdAt: current.createdAt < createdAt ? current.createdAt : createdAt,
|
|
10653
|
+
completedAt: laterTimestamp(current.completedAt, boundary ? timestamp : null)
|
|
10654
|
+
});
|
|
10655
|
+
}
|
|
10656
|
+
const transcriptColumns = tableColumns(db, "session_transcripts");
|
|
10657
|
+
const hasUpdated = transcriptColumns.has("updated_at");
|
|
10658
|
+
const hasCompleted = transcriptColumns.has("completed_at");
|
|
10659
|
+
const hasHash = transcriptColumns.has("content_hash");
|
|
10660
|
+
const insertColumns = ["session_key", "content", "harness", "project", "agent_id", "created_at"];
|
|
10661
|
+
if (hasUpdated)
|
|
10662
|
+
insertColumns.push("updated_at");
|
|
10663
|
+
if (hasCompleted)
|
|
10664
|
+
insertColumns.push("completed_at");
|
|
10665
|
+
if (hasHash)
|
|
10666
|
+
insertColumns.push("content_hash");
|
|
10667
|
+
const insert = db.prepare(`INSERT OR IGNORE INTO session_transcripts (${insertColumns.join(", ")}) VALUES (${insertColumns.map(() => "?").join(", ")})`);
|
|
10668
|
+
const existing = db.prepare("SELECT content, completed_at FROM session_transcripts WHERE agent_id = ? AND session_key = ?");
|
|
10669
|
+
for (const candidate of candidates.values()) {
|
|
10670
|
+
const job = candidate.job;
|
|
10671
|
+
const agentId = job.agent_id ?? "default";
|
|
10672
|
+
const existingRow = existing.get(agentId, candidate.sessionKey);
|
|
10673
|
+
if (existingRow != null) {
|
|
10674
|
+
const previousContent = typeof existingRow.content === "string" ? existingRow.content : "";
|
|
10675
|
+
const mergedContent = mergeTranscriptContent(previousContent, candidate.content);
|
|
10676
|
+
const completedAt = typeof existingRow.completed_at === "string" && existingRow.completed_at.length > 0 ? existingRow.completed_at : candidate.completedAt;
|
|
10677
|
+
const assignments = ["content = ?"];
|
|
10678
|
+
const values2 = [mergedContent];
|
|
10679
|
+
if (hasUpdated && mergedContent !== previousContent) {
|
|
10680
|
+
assignments.push("updated_at = ?");
|
|
10681
|
+
values2.push(candidate.createdAt);
|
|
10682
|
+
}
|
|
10683
|
+
if (hasCompleted && completedAt && !existingRow.completed_at) {
|
|
10684
|
+
assignments.push("completed_at = ?");
|
|
10685
|
+
values2.push(completedAt);
|
|
10686
|
+
}
|
|
10687
|
+
if (hasHash) {
|
|
10688
|
+
assignments.push("content_hash = ?");
|
|
10689
|
+
values2.push(hashTranscript(mergedContent));
|
|
10690
|
+
}
|
|
10691
|
+
values2.push(agentId, candidate.sessionKey);
|
|
10692
|
+
db.prepare(`UPDATE session_transcripts SET ${assignments.join(", ")} WHERE agent_id = ? AND session_key = ?`).run(...values2);
|
|
10693
|
+
continue;
|
|
10694
|
+
}
|
|
10695
|
+
const values = [
|
|
10696
|
+
candidate.sessionKey,
|
|
10697
|
+
candidate.content,
|
|
10698
|
+
job.harness ?? null,
|
|
10699
|
+
job.project ?? null,
|
|
10700
|
+
agentId,
|
|
10701
|
+
candidate.createdAt
|
|
10702
|
+
];
|
|
10703
|
+
if (hasUpdated)
|
|
10704
|
+
values.push(candidate.createdAt);
|
|
10705
|
+
if (hasCompleted)
|
|
10706
|
+
values.push(candidate.completedAt);
|
|
10707
|
+
if (hasHash)
|
|
10708
|
+
values.push(hashTranscript(candidate.content));
|
|
10709
|
+
insert.run(...values);
|
|
10710
|
+
}
|
|
10711
|
+
}
|
|
10712
|
+
function up117(db) {
|
|
10713
|
+
if (!hasTable4(db, "session_transcripts"))
|
|
10714
|
+
return;
|
|
10715
|
+
addColumnIfMissing25(db, "session_transcripts", "completed_at", "TEXT");
|
|
10716
|
+
addColumnIfMissing25(db, "session_transcripts", "content_hash", "TEXT");
|
|
10717
|
+
backfillTranscriptHashes(db);
|
|
10718
|
+
if (hasTable4(db, "transcript_capture_jobs")) {
|
|
10719
|
+
const captureColumns = db.prepare("PRAGMA table_info(transcript_capture_jobs)").all();
|
|
10720
|
+
if (captureColumns.some((row) => row.name === "summary_status")) {
|
|
10721
|
+
db.exec("UPDATE transcript_capture_jobs SET summary_status = 'not_requested' WHERE summary_status IN ('pending', 'failed', 'skipped')");
|
|
10722
|
+
}
|
|
10723
|
+
}
|
|
10724
|
+
if (hasTable4(db, "summary_jobs")) {
|
|
10725
|
+
backfillTranscriptsFromSummaryJobs(db);
|
|
10726
|
+
backfillTranscriptHashes(db);
|
|
10727
|
+
const summaryColumns = tableColumns(db, "summary_jobs");
|
|
10728
|
+
const timestampParts = ["completed_at", "ended_at", "captured_at", "created_at"].filter((column) => summaryColumns.has(column)).map((column) => `sj.${column}`);
|
|
10729
|
+
const timestampValue = timestampParts.length === 1 ? timestampParts[0] : `COALESCE(${timestampParts.join(", ")})`;
|
|
10730
|
+
const completionTimestamp = timestampValue ? `MAX(${timestampValue})` : "NULL";
|
|
10731
|
+
const boundaryParts = [
|
|
10732
|
+
summaryColumns.has("trigger") ? "sj.trigger = 'session_end'" : null,
|
|
10733
|
+
summaryColumns.has("boundary_reason") ? "sj.boundary_reason IN ('session_closed', 'session_clear', 'stale_session', 'ttl_expired')" : null
|
|
10734
|
+
].filter((part) => part !== null);
|
|
10735
|
+
const boundaryPredicate = boundaryParts.length > 0 ? `(${boundaryParts.join(" OR ")})` : "1=1";
|
|
10736
|
+
const agentPredicate = summaryColumns.has("agent_id") ? "sj.agent_id = session_transcripts.agent_id" : "session_transcripts.agent_id = 'default'";
|
|
10737
|
+
if (completionTimestamp !== "NULL") {
|
|
10738
|
+
db.exec(`
|
|
10739
|
+
UPDATE session_transcripts
|
|
10740
|
+
SET completed_at = COALESCE(
|
|
10741
|
+
completed_at,
|
|
10742
|
+
(
|
|
10743
|
+
SELECT ${completionTimestamp}
|
|
10744
|
+
FROM summary_jobs AS sj
|
|
10745
|
+
WHERE ${agentPredicate}
|
|
10746
|
+
AND sj.session_key = session_transcripts.session_key
|
|
10747
|
+
AND ${boundaryPredicate}
|
|
10748
|
+
)
|
|
10749
|
+
)
|
|
10750
|
+
WHERE completed_at IS NULL;
|
|
10751
|
+
`);
|
|
10752
|
+
}
|
|
10753
|
+
db.exec("DELETE FROM summary_jobs");
|
|
10754
|
+
}
|
|
10755
|
+
const completionIndexColumns = ["agent_id", "completed_at"];
|
|
10756
|
+
if (tableColumns(db, "session_transcripts").has("updated_at"))
|
|
10757
|
+
completionIndexColumns.push("updated_at");
|
|
10758
|
+
db.exec(`
|
|
10759
|
+
CREATE INDEX IF NOT EXISTS idx_st_agent_completed
|
|
10760
|
+
ON session_transcripts(${completionIndexColumns.join(", ")});
|
|
10761
|
+
CREATE INDEX IF NOT EXISTS idx_st_agent_hash
|
|
10762
|
+
ON session_transcripts(agent_id, content_hash);
|
|
10763
|
+
`);
|
|
10764
|
+
}
|
|
10765
|
+
function up118(db) {
|
|
10766
|
+
db.exec(`
|
|
10767
|
+
CREATE INDEX IF NOT EXISTS idx_memory_jobs_pressure_status
|
|
10768
|
+
ON memory_jobs(status)
|
|
10769
|
+
WHERE status IN ('pending', 'leased') AND job_type <> 'extract';
|
|
10770
|
+
CREATE INDEX IF NOT EXISTS idx_memory_jobs_pressure_created_at
|
|
10771
|
+
ON memory_jobs(created_at)
|
|
10772
|
+
WHERE status IN ('pending', 'leased') AND job_type <> 'extract';
|
|
10773
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_pressure_status
|
|
10774
|
+
ON summary_jobs(status)
|
|
10775
|
+
WHERE status IN ('pending', 'leased');
|
|
10776
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_pressure_created_at
|
|
10777
|
+
ON summary_jobs(created_at)
|
|
10778
|
+
WHERE status IN ('pending', 'leased');
|
|
10779
|
+
`);
|
|
10780
|
+
}
|
|
10546
10781
|
var MIGRATIONS = [
|
|
10547
10782
|
{
|
|
10548
10783
|
version: 1,
|
|
@@ -11482,6 +11717,22 @@ var MIGRATIONS = [
|
|
|
11482
11717
|
{ table: "cross_agent_messages", column: "acp_target_agent_name" }
|
|
11483
11718
|
]
|
|
11484
11719
|
}
|
|
11720
|
+
},
|
|
11721
|
+
{
|
|
11722
|
+
version: 117,
|
|
11723
|
+
name: "retire-summary-worker",
|
|
11724
|
+
up: up117,
|
|
11725
|
+
artifacts: {
|
|
11726
|
+
columns: [
|
|
11727
|
+
{ table: "session_transcripts", column: "completed_at" },
|
|
11728
|
+
{ table: "session_transcripts", column: "content_hash" }
|
|
11729
|
+
]
|
|
11730
|
+
}
|
|
11731
|
+
},
|
|
11732
|
+
{
|
|
11733
|
+
version: 118,
|
|
11734
|
+
name: "queue-pressure-indices",
|
|
11735
|
+
up: up118
|
|
11485
11736
|
}
|
|
11486
11737
|
];
|
|
11487
11738
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -11909,6 +12160,7 @@ function resolveRemoteDaemonUrl() {
|
|
|
11909
12160
|
import { createRequire as createRequire3 } from "node:module";
|
|
11910
12161
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
11911
12162
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
12163
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
11912
12164
|
import { homedir as homedir2 } from "os";
|
|
11913
12165
|
import { join as join22 } from "path";
|
|
11914
12166
|
import { createRequire as createRequire22 } from "node:module";
|
|
@@ -18864,7 +19116,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
18864
19116
|
return true;
|
|
18865
19117
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
18866
19118
|
}
|
|
18867
|
-
function
|
|
19119
|
+
function up119(db) {
|
|
18868
19120
|
db.exec(`
|
|
18869
19121
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
18870
19122
|
version INTEGER PRIMARY KEY,
|
|
@@ -18957,27 +19209,27 @@ function hasColumn22(db, table, column) {
|
|
|
18957
19209
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
18958
19210
|
return rows.some((r) => r.name === column);
|
|
18959
19211
|
}
|
|
18960
|
-
function
|
|
19212
|
+
function addColumnIfMissing26(db, table, column, definition) {
|
|
18961
19213
|
if (!hasColumn22(db, table, column)) {
|
|
18962
19214
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
18963
19215
|
}
|
|
18964
19216
|
}
|
|
18965
19217
|
function up210(db) {
|
|
18966
|
-
|
|
18967
|
-
|
|
18968
|
-
|
|
18969
|
-
|
|
18970
|
-
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
|
|
18978
|
-
|
|
18979
|
-
|
|
18980
|
-
|
|
19218
|
+
addColumnIfMissing26(db, "memories", "content_hash", "TEXT");
|
|
19219
|
+
addColumnIfMissing26(db, "memories", "normalized_content", "TEXT");
|
|
19220
|
+
addColumnIfMissing26(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
19221
|
+
addColumnIfMissing26(db, "memories", "deleted_at", "TEXT");
|
|
19222
|
+
addColumnIfMissing26(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
19223
|
+
addColumnIfMissing26(db, "memories", "embedding_model", "TEXT");
|
|
19224
|
+
addColumnIfMissing26(db, "memories", "extraction_model", "TEXT");
|
|
19225
|
+
addColumnIfMissing26(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
19226
|
+
addColumnIfMissing26(db, "memories", "who", "TEXT");
|
|
19227
|
+
addColumnIfMissing26(db, "memories", "why", "TEXT");
|
|
19228
|
+
addColumnIfMissing26(db, "memories", "project", "TEXT");
|
|
19229
|
+
addColumnIfMissing26(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
19230
|
+
addColumnIfMissing26(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
19231
|
+
addColumnIfMissing26(db, "memories", "last_accessed", "TEXT");
|
|
19232
|
+
addColumnIfMissing26(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
18981
19233
|
db.exec(`
|
|
18982
19234
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
18983
19235
|
id TEXT PRIMARY KEY,
|
|
@@ -19073,7 +19325,7 @@ function up210(db) {
|
|
|
19073
19325
|
ON memory_entity_mentions(entity_id);
|
|
19074
19326
|
`);
|
|
19075
19327
|
}
|
|
19076
|
-
function
|
|
19328
|
+
function addColumnIfMissing27(db, table, column, definition) {
|
|
19077
19329
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
19078
19330
|
if (rows.some((r) => r.name === column))
|
|
19079
19331
|
return false;
|
|
@@ -19081,8 +19333,8 @@ function addColumnIfMissing26(db, table, column, definition) {
|
|
|
19081
19333
|
return true;
|
|
19082
19334
|
}
|
|
19083
19335
|
function up310(db) {
|
|
19084
|
-
|
|
19085
|
-
|
|
19336
|
+
addColumnIfMissing27(db, "memories", "why", "TEXT");
|
|
19337
|
+
addColumnIfMissing27(db, "memories", "project", "TEXT");
|
|
19086
19338
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
19087
19339
|
db.exec(`
|
|
19088
19340
|
UPDATE memories
|
|
@@ -19287,7 +19539,7 @@ function up1010(db) {
|
|
|
19287
19539
|
)
|
|
19288
19540
|
`);
|
|
19289
19541
|
}
|
|
19290
|
-
function
|
|
19542
|
+
function up1110(db) {
|
|
19291
19543
|
db.exec(`
|
|
19292
19544
|
CREATE TABLE IF NOT EXISTS session_scores (
|
|
19293
19545
|
id TEXT PRIMARY KEY,
|
|
@@ -20508,7 +20760,7 @@ function up492(db) {
|
|
|
20508
20760
|
);
|
|
20509
20761
|
`);
|
|
20510
20762
|
}
|
|
20511
|
-
function
|
|
20763
|
+
function hasTable5(db, name) {
|
|
20512
20764
|
return db.prepare(`SELECT name
|
|
20513
20765
|
FROM sqlite_master
|
|
20514
20766
|
WHERE type = 'table' AND name = ?
|
|
@@ -20538,7 +20790,7 @@ function up502(db) {
|
|
|
20538
20790
|
CREATE INDEX IF NOT EXISTS idx_entity_dependency_history_created
|
|
20539
20791
|
ON entity_dependency_history(created_at DESC);
|
|
20540
20792
|
`);
|
|
20541
|
-
if (!
|
|
20793
|
+
if (!hasTable5(db, "entity_dependencies"))
|
|
20542
20794
|
return;
|
|
20543
20795
|
db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_insert");
|
|
20544
20796
|
db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_update");
|
|
@@ -22440,11 +22692,245 @@ function up1162(db) {
|
|
|
22440
22692
|
ON cross_agent_messages(delivery_path, delivery_state, delivery_lease_expires_at, delivery_updated_at);
|
|
22441
22693
|
`);
|
|
22442
22694
|
}
|
|
22695
|
+
function hasTable42(db, table) {
|
|
22696
|
+
return db.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
|
|
22697
|
+
}
|
|
22698
|
+
function addColumnIfMissing252(db, table, column, definition) {
|
|
22699
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
22700
|
+
if (columns.some((row) => row.name === column))
|
|
22701
|
+
return;
|
|
22702
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
22703
|
+
}
|
|
22704
|
+
function tableColumns2(db, table) {
|
|
22705
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
22706
|
+
return new Set(rows.map((row) => typeof row.name === "string" ? row.name : ""));
|
|
22707
|
+
}
|
|
22708
|
+
function hashTranscript2(content) {
|
|
22709
|
+
return createHash2("sha256").update(content, "utf8").digest("hex");
|
|
22710
|
+
}
|
|
22711
|
+
function backfillTranscriptHashes2(db) {
|
|
22712
|
+
const columns = tableColumns2(db, "session_transcripts");
|
|
22713
|
+
if (!columns.has("content_hash") || !columns.has("content"))
|
|
22714
|
+
return;
|
|
22715
|
+
const rows = db.prepare("SELECT session_key, agent_id, content FROM session_transcripts WHERE content_hash IS NULL").all();
|
|
22716
|
+
const update = db.prepare("UPDATE session_transcripts SET content_hash = ? WHERE agent_id = ? AND session_key = ? AND content_hash IS NULL");
|
|
22717
|
+
for (const row of rows) {
|
|
22718
|
+
if (typeof row.content !== "string" || typeof row.session_key !== "string")
|
|
22719
|
+
continue;
|
|
22720
|
+
update.run(hashTranscript2(row.content), typeof row.agent_id === "string" ? row.agent_id : "default", row.session_key);
|
|
22721
|
+
}
|
|
22722
|
+
}
|
|
22723
|
+
var COMPLETION_BOUNDARY_REASONS2 = new Set(["session_closed", "session_clear", "stale_session", "ttl_expired"]);
|
|
22724
|
+
function summaryJobTimestamp2(job) {
|
|
22725
|
+
return job.completed_at ?? job.ended_at ?? job.captured_at ?? job.created_at ?? new Date(0).toISOString();
|
|
22726
|
+
}
|
|
22727
|
+
function laterTimestamp2(current, candidate) {
|
|
22728
|
+
if (current === null)
|
|
22729
|
+
return candidate;
|
|
22730
|
+
if (candidate === null)
|
|
22731
|
+
return current;
|
|
22732
|
+
const currentMillis = Date.parse(current);
|
|
22733
|
+
const candidateMillis = Date.parse(candidate);
|
|
22734
|
+
if (Number.isFinite(currentMillis) && Number.isFinite(candidateMillis)) {
|
|
22735
|
+
return candidateMillis > currentMillis ? candidate : current;
|
|
22736
|
+
}
|
|
22737
|
+
return candidate > current ? candidate : current;
|
|
22738
|
+
}
|
|
22739
|
+
function isCompletionBoundary2(job, columns) {
|
|
22740
|
+
return columns.has("trigger") && job.trigger === "session_end" || columns.has("boundary_reason") && COMPLETION_BOUNDARY_REASONS2.has(job.boundary_reason ?? "");
|
|
22741
|
+
}
|
|
22742
|
+
function mergeTranscriptContent2(current, next) {
|
|
22743
|
+
if (current.length === 0)
|
|
22744
|
+
return next;
|
|
22745
|
+
if (next.length === 0 || current === next || current.includes(next))
|
|
22746
|
+
return current;
|
|
22747
|
+
if (next.includes(current))
|
|
22748
|
+
return next;
|
|
22749
|
+
return `${current}
|
|
22750
|
+
${next}`;
|
|
22751
|
+
}
|
|
22752
|
+
function backfillTranscriptsFromSummaryJobs2(db) {
|
|
22753
|
+
if (!hasTable42(db, "summary_jobs"))
|
|
22754
|
+
return;
|
|
22755
|
+
const summaryColumns = tableColumns2(db, "summary_jobs");
|
|
22756
|
+
if (!summaryColumns.has("transcript"))
|
|
22757
|
+
return;
|
|
22758
|
+
const select = (name) => summaryColumns.has(name) ? `"${name}" AS "${name}"` : `NULL AS "${name}"`;
|
|
22759
|
+
const jobs = db.prepare(`SELECT ${[
|
|
22760
|
+
"id",
|
|
22761
|
+
"session_key",
|
|
22762
|
+
"transcript",
|
|
22763
|
+
"harness",
|
|
22764
|
+
"project",
|
|
22765
|
+
"agent_id",
|
|
22766
|
+
"trigger",
|
|
22767
|
+
"boundary_reason",
|
|
22768
|
+
"captured_at",
|
|
22769
|
+
"ended_at",
|
|
22770
|
+
"completed_at",
|
|
22771
|
+
"created_at"
|
|
22772
|
+
].map(select).join(", ")} FROM summary_jobs`).all();
|
|
22773
|
+
const candidates = new Map;
|
|
22774
|
+
for (const job of jobs) {
|
|
22775
|
+
if (typeof job.transcript !== "string" || job.transcript.trim().length === 0)
|
|
22776
|
+
continue;
|
|
22777
|
+
const agentId = typeof job.agent_id === "string" && job.agent_id.length > 0 ? job.agent_id : "default";
|
|
22778
|
+
const sessionKey = typeof job.session_key === "string" && job.session_key.trim().length > 0 ? job.session_key : `legacy-summary-job:${job.id ?? hashTranscript2(`${summaryJobTimestamp2(job)}\x00${job.transcript}`)}`;
|
|
22779
|
+
const key = `${agentId}\x00${sessionKey}`;
|
|
22780
|
+
const current = candidates.get(key);
|
|
22781
|
+
const timestamp = summaryJobTimestamp2(job);
|
|
22782
|
+
const boundary = isCompletionBoundary2(job, summaryColumns);
|
|
22783
|
+
const createdAt = job.captured_at ?? job.created_at ?? job.ended_at ?? timestamp;
|
|
22784
|
+
if (!current) {
|
|
22785
|
+
candidates.set(key, {
|
|
22786
|
+
sessionKey,
|
|
22787
|
+
job: { ...job, agent_id: agentId },
|
|
22788
|
+
content: job.transcript,
|
|
22789
|
+
createdAt,
|
|
22790
|
+
completedAt: boundary ? timestamp : null
|
|
22791
|
+
});
|
|
22792
|
+
continue;
|
|
22793
|
+
}
|
|
22794
|
+
const currentTimestamp = summaryJobTimestamp2(current.job);
|
|
22795
|
+
const preferred = timestamp > currentTimestamp || timestamp === currentTimestamp && job.transcript.length > current.content.length ? { ...job, agent_id: agentId } : current.job;
|
|
22796
|
+
candidates.set(key, {
|
|
22797
|
+
sessionKey,
|
|
22798
|
+
job: preferred,
|
|
22799
|
+
content: mergeTranscriptContent2(current.content, job.transcript),
|
|
22800
|
+
createdAt: current.createdAt < createdAt ? current.createdAt : createdAt,
|
|
22801
|
+
completedAt: laterTimestamp2(current.completedAt, boundary ? timestamp : null)
|
|
22802
|
+
});
|
|
22803
|
+
}
|
|
22804
|
+
const transcriptColumns = tableColumns2(db, "session_transcripts");
|
|
22805
|
+
const hasUpdated = transcriptColumns.has("updated_at");
|
|
22806
|
+
const hasCompleted = transcriptColumns.has("completed_at");
|
|
22807
|
+
const hasHash = transcriptColumns.has("content_hash");
|
|
22808
|
+
const insertColumns = ["session_key", "content", "harness", "project", "agent_id", "created_at"];
|
|
22809
|
+
if (hasUpdated)
|
|
22810
|
+
insertColumns.push("updated_at");
|
|
22811
|
+
if (hasCompleted)
|
|
22812
|
+
insertColumns.push("completed_at");
|
|
22813
|
+
if (hasHash)
|
|
22814
|
+
insertColumns.push("content_hash");
|
|
22815
|
+
const insert = db.prepare(`INSERT OR IGNORE INTO session_transcripts (${insertColumns.join(", ")}) VALUES (${insertColumns.map(() => "?").join(", ")})`);
|
|
22816
|
+
const existing = db.prepare("SELECT content, completed_at FROM session_transcripts WHERE agent_id = ? AND session_key = ?");
|
|
22817
|
+
for (const candidate of candidates.values()) {
|
|
22818
|
+
const job = candidate.job;
|
|
22819
|
+
const agentId = job.agent_id ?? "default";
|
|
22820
|
+
const existingRow = existing.get(agentId, candidate.sessionKey);
|
|
22821
|
+
if (existingRow != null) {
|
|
22822
|
+
const previousContent = typeof existingRow.content === "string" ? existingRow.content : "";
|
|
22823
|
+
const mergedContent = mergeTranscriptContent2(previousContent, candidate.content);
|
|
22824
|
+
const completedAt = typeof existingRow.completed_at === "string" && existingRow.completed_at.length > 0 ? existingRow.completed_at : candidate.completedAt;
|
|
22825
|
+
const assignments = ["content = ?"];
|
|
22826
|
+
const values2 = [mergedContent];
|
|
22827
|
+
if (hasUpdated && mergedContent !== previousContent) {
|
|
22828
|
+
assignments.push("updated_at = ?");
|
|
22829
|
+
values2.push(candidate.createdAt);
|
|
22830
|
+
}
|
|
22831
|
+
if (hasCompleted && completedAt && !existingRow.completed_at) {
|
|
22832
|
+
assignments.push("completed_at = ?");
|
|
22833
|
+
values2.push(completedAt);
|
|
22834
|
+
}
|
|
22835
|
+
if (hasHash) {
|
|
22836
|
+
assignments.push("content_hash = ?");
|
|
22837
|
+
values2.push(hashTranscript2(mergedContent));
|
|
22838
|
+
}
|
|
22839
|
+
values2.push(agentId, candidate.sessionKey);
|
|
22840
|
+
db.prepare(`UPDATE session_transcripts SET ${assignments.join(", ")} WHERE agent_id = ? AND session_key = ?`).run(...values2);
|
|
22841
|
+
continue;
|
|
22842
|
+
}
|
|
22843
|
+
const values = [
|
|
22844
|
+
candidate.sessionKey,
|
|
22845
|
+
candidate.content,
|
|
22846
|
+
job.harness ?? null,
|
|
22847
|
+
job.project ?? null,
|
|
22848
|
+
agentId,
|
|
22849
|
+
candidate.createdAt
|
|
22850
|
+
];
|
|
22851
|
+
if (hasUpdated)
|
|
22852
|
+
values.push(candidate.createdAt);
|
|
22853
|
+
if (hasCompleted)
|
|
22854
|
+
values.push(candidate.completedAt);
|
|
22855
|
+
if (hasHash)
|
|
22856
|
+
values.push(hashTranscript2(candidate.content));
|
|
22857
|
+
insert.run(...values);
|
|
22858
|
+
}
|
|
22859
|
+
}
|
|
22860
|
+
function up1172(db) {
|
|
22861
|
+
if (!hasTable42(db, "session_transcripts"))
|
|
22862
|
+
return;
|
|
22863
|
+
addColumnIfMissing252(db, "session_transcripts", "completed_at", "TEXT");
|
|
22864
|
+
addColumnIfMissing252(db, "session_transcripts", "content_hash", "TEXT");
|
|
22865
|
+
backfillTranscriptHashes2(db);
|
|
22866
|
+
if (hasTable42(db, "transcript_capture_jobs")) {
|
|
22867
|
+
const captureColumns = db.prepare("PRAGMA table_info(transcript_capture_jobs)").all();
|
|
22868
|
+
if (captureColumns.some((row) => row.name === "summary_status")) {
|
|
22869
|
+
db.exec("UPDATE transcript_capture_jobs SET summary_status = 'not_requested' WHERE summary_status IN ('pending', 'failed', 'skipped')");
|
|
22870
|
+
}
|
|
22871
|
+
}
|
|
22872
|
+
if (hasTable42(db, "summary_jobs")) {
|
|
22873
|
+
backfillTranscriptsFromSummaryJobs2(db);
|
|
22874
|
+
backfillTranscriptHashes2(db);
|
|
22875
|
+
const summaryColumns = tableColumns2(db, "summary_jobs");
|
|
22876
|
+
const timestampParts = ["completed_at", "ended_at", "captured_at", "created_at"].filter((column) => summaryColumns.has(column)).map((column) => `sj.${column}`);
|
|
22877
|
+
const timestampValue = timestampParts.length === 1 ? timestampParts[0] : `COALESCE(${timestampParts.join(", ")})`;
|
|
22878
|
+
const completionTimestamp = timestampValue ? `MAX(${timestampValue})` : "NULL";
|
|
22879
|
+
const boundaryParts = [
|
|
22880
|
+
summaryColumns.has("trigger") ? "sj.trigger = 'session_end'" : null,
|
|
22881
|
+
summaryColumns.has("boundary_reason") ? "sj.boundary_reason IN ('session_closed', 'session_clear', 'stale_session', 'ttl_expired')" : null
|
|
22882
|
+
].filter((part) => part !== null);
|
|
22883
|
+
const boundaryPredicate = boundaryParts.length > 0 ? `(${boundaryParts.join(" OR ")})` : "1=1";
|
|
22884
|
+
const agentPredicate = summaryColumns.has("agent_id") ? "sj.agent_id = session_transcripts.agent_id" : "session_transcripts.agent_id = 'default'";
|
|
22885
|
+
if (completionTimestamp !== "NULL") {
|
|
22886
|
+
db.exec(`
|
|
22887
|
+
UPDATE session_transcripts
|
|
22888
|
+
SET completed_at = COALESCE(
|
|
22889
|
+
completed_at,
|
|
22890
|
+
(
|
|
22891
|
+
SELECT ${completionTimestamp}
|
|
22892
|
+
FROM summary_jobs AS sj
|
|
22893
|
+
WHERE ${agentPredicate}
|
|
22894
|
+
AND sj.session_key = session_transcripts.session_key
|
|
22895
|
+
AND ${boundaryPredicate}
|
|
22896
|
+
)
|
|
22897
|
+
)
|
|
22898
|
+
WHERE completed_at IS NULL;
|
|
22899
|
+
`);
|
|
22900
|
+
}
|
|
22901
|
+
db.exec("DELETE FROM summary_jobs");
|
|
22902
|
+
}
|
|
22903
|
+
const completionIndexColumns = ["agent_id", "completed_at"];
|
|
22904
|
+
if (tableColumns2(db, "session_transcripts").has("updated_at"))
|
|
22905
|
+
completionIndexColumns.push("updated_at");
|
|
22906
|
+
db.exec(`
|
|
22907
|
+
CREATE INDEX IF NOT EXISTS idx_st_agent_completed
|
|
22908
|
+
ON session_transcripts(${completionIndexColumns.join(", ")});
|
|
22909
|
+
CREATE INDEX IF NOT EXISTS idx_st_agent_hash
|
|
22910
|
+
ON session_transcripts(agent_id, content_hash);
|
|
22911
|
+
`);
|
|
22912
|
+
}
|
|
22913
|
+
function up1182(db) {
|
|
22914
|
+
db.exec(`
|
|
22915
|
+
CREATE INDEX IF NOT EXISTS idx_memory_jobs_pressure_status
|
|
22916
|
+
ON memory_jobs(status)
|
|
22917
|
+
WHERE status IN ('pending', 'leased') AND job_type <> 'extract';
|
|
22918
|
+
CREATE INDEX IF NOT EXISTS idx_memory_jobs_pressure_created_at
|
|
22919
|
+
ON memory_jobs(created_at)
|
|
22920
|
+
WHERE status IN ('pending', 'leased') AND job_type <> 'extract';
|
|
22921
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_pressure_status
|
|
22922
|
+
ON summary_jobs(status)
|
|
22923
|
+
WHERE status IN ('pending', 'leased');
|
|
22924
|
+
CREATE INDEX IF NOT EXISTS idx_summary_jobs_pressure_created_at
|
|
22925
|
+
ON summary_jobs(created_at)
|
|
22926
|
+
WHERE status IN ('pending', 'leased');
|
|
22927
|
+
`);
|
|
22928
|
+
}
|
|
22443
22929
|
var MIGRATIONS2 = [
|
|
22444
22930
|
{
|
|
22445
22931
|
version: 1,
|
|
22446
22932
|
name: "baseline",
|
|
22447
|
-
up:
|
|
22933
|
+
up: up119,
|
|
22448
22934
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
22449
22935
|
},
|
|
22450
22936
|
{
|
|
@@ -22510,7 +22996,7 @@ var MIGRATIONS2 = [
|
|
|
22510
22996
|
{
|
|
22511
22997
|
version: 11,
|
|
22512
22998
|
name: "session-scores",
|
|
22513
|
-
up:
|
|
22999
|
+
up: up1110,
|
|
22514
23000
|
artifacts: { tables: ["session_scores"] }
|
|
22515
23001
|
},
|
|
22516
23002
|
{
|
|
@@ -23379,6 +23865,22 @@ var MIGRATIONS2 = [
|
|
|
23379
23865
|
{ table: "cross_agent_messages", column: "acp_target_agent_name" }
|
|
23380
23866
|
]
|
|
23381
23867
|
}
|
|
23868
|
+
},
|
|
23869
|
+
{
|
|
23870
|
+
version: 117,
|
|
23871
|
+
name: "retire-summary-worker",
|
|
23872
|
+
up: up1172,
|
|
23873
|
+
artifacts: {
|
|
23874
|
+
columns: [
|
|
23875
|
+
{ table: "session_transcripts", column: "completed_at" },
|
|
23876
|
+
{ table: "session_transcripts", column: "content_hash" }
|
|
23877
|
+
]
|
|
23878
|
+
}
|
|
23879
|
+
},
|
|
23880
|
+
{
|
|
23881
|
+
version: 118,
|
|
23882
|
+
name: "queue-pressure-indices",
|
|
23883
|
+
up: up1182
|
|
23382
23884
|
}
|
|
23383
23885
|
];
|
|
23384
23886
|
var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
|
|
@@ -24001,7 +24503,7 @@ function codexHookHash(eventName, handler) {
|
|
|
24001
24503
|
}
|
|
24002
24504
|
]
|
|
24003
24505
|
};
|
|
24004
|
-
return `sha256:${
|
|
24506
|
+
return `sha256:${createHash3("sha256").update(JSON.stringify(canonicalJson(identity))).digest("hex")}`;
|
|
24005
24507
|
}
|
|
24006
24508
|
function buildHookTrustEntries(hooksPath, file) {
|
|
24007
24509
|
const entries = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signetai/connector-codex",
|
|
3
|
-
"version": "0.185.
|
|
3
|
+
"version": "0.185.6",
|
|
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.185.
|
|
28
|
-
"@signetai/core": "0.185.
|
|
27
|
+
"@signetai/connector-base": "0.185.6",
|
|
28
|
+
"@signetai/core": "0.185.6"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.0.0",
|