@signetai/connector-gemini 0.185.3 → 0.185.5
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 +485 -25
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { dirname as dirname5, isAbsolute, join as join3, relative, sep } from "n
|
|
|
21
21
|
import { createRequire } from "node:module";
|
|
22
22
|
import { dirname, join } from "node:path";
|
|
23
23
|
import { fileURLToPath } from "node:url";
|
|
24
|
+
import { createHash } from "node:crypto";
|
|
24
25
|
import { homedir as homedir2 } from "os";
|
|
25
26
|
import { join as join2 } from "path";
|
|
26
27
|
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, statSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
@@ -10557,6 +10558,224 @@ function up116(db) {
|
|
|
10557
10558
|
ON cross_agent_messages(delivery_path, delivery_state, delivery_lease_expires_at, delivery_updated_at);
|
|
10558
10559
|
`);
|
|
10559
10560
|
}
|
|
10561
|
+
function hasTable4(db, table) {
|
|
10562
|
+
return db.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
|
|
10563
|
+
}
|
|
10564
|
+
function addColumnIfMissing25(db, table, column, definition) {
|
|
10565
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
10566
|
+
if (columns.some((row) => row.name === column))
|
|
10567
|
+
return;
|
|
10568
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
10569
|
+
}
|
|
10570
|
+
function tableColumns(db, table) {
|
|
10571
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
10572
|
+
return new Set(rows.map((row) => typeof row.name === "string" ? row.name : ""));
|
|
10573
|
+
}
|
|
10574
|
+
function hashTranscript(content) {
|
|
10575
|
+
return createHash("sha256").update(content, "utf8").digest("hex");
|
|
10576
|
+
}
|
|
10577
|
+
function backfillTranscriptHashes(db) {
|
|
10578
|
+
const columns = tableColumns(db, "session_transcripts");
|
|
10579
|
+
if (!columns.has("content_hash") || !columns.has("content"))
|
|
10580
|
+
return;
|
|
10581
|
+
const rows = db.prepare("SELECT session_key, agent_id, content FROM session_transcripts WHERE content_hash IS NULL").all();
|
|
10582
|
+
const update = db.prepare("UPDATE session_transcripts SET content_hash = ? WHERE agent_id = ? AND session_key = ? AND content_hash IS NULL");
|
|
10583
|
+
for (const row of rows) {
|
|
10584
|
+
if (typeof row.content !== "string" || typeof row.session_key !== "string")
|
|
10585
|
+
continue;
|
|
10586
|
+
update.run(hashTranscript(row.content), typeof row.agent_id === "string" ? row.agent_id : "default", row.session_key);
|
|
10587
|
+
}
|
|
10588
|
+
}
|
|
10589
|
+
var COMPLETION_BOUNDARY_REASONS = new Set(["session_closed", "session_clear", "stale_session", "ttl_expired"]);
|
|
10590
|
+
function summaryJobTimestamp(job) {
|
|
10591
|
+
return job.completed_at ?? job.ended_at ?? job.captured_at ?? job.created_at ?? new Date(0).toISOString();
|
|
10592
|
+
}
|
|
10593
|
+
function laterTimestamp(current, candidate) {
|
|
10594
|
+
if (current === null)
|
|
10595
|
+
return candidate;
|
|
10596
|
+
if (candidate === null)
|
|
10597
|
+
return current;
|
|
10598
|
+
const currentMillis = Date.parse(current);
|
|
10599
|
+
const candidateMillis = Date.parse(candidate);
|
|
10600
|
+
if (Number.isFinite(currentMillis) && Number.isFinite(candidateMillis)) {
|
|
10601
|
+
return candidateMillis > currentMillis ? candidate : current;
|
|
10602
|
+
}
|
|
10603
|
+
return candidate > current ? candidate : current;
|
|
10604
|
+
}
|
|
10605
|
+
function isCompletionBoundary(job, columns) {
|
|
10606
|
+
return columns.has("trigger") && job.trigger === "session_end" || columns.has("boundary_reason") && COMPLETION_BOUNDARY_REASONS.has(job.boundary_reason ?? "");
|
|
10607
|
+
}
|
|
10608
|
+
function mergeTranscriptContent(current, next) {
|
|
10609
|
+
if (current.length === 0)
|
|
10610
|
+
return next;
|
|
10611
|
+
if (next.length === 0 || current === next || current.includes(next))
|
|
10612
|
+
return current;
|
|
10613
|
+
if (next.includes(current))
|
|
10614
|
+
return next;
|
|
10615
|
+
return `${current}
|
|
10616
|
+
${next}`;
|
|
10617
|
+
}
|
|
10618
|
+
function backfillTranscriptsFromSummaryJobs(db) {
|
|
10619
|
+
if (!hasTable4(db, "summary_jobs"))
|
|
10620
|
+
return;
|
|
10621
|
+
const summaryColumns = tableColumns(db, "summary_jobs");
|
|
10622
|
+
if (!summaryColumns.has("transcript"))
|
|
10623
|
+
return;
|
|
10624
|
+
const select = (name) => summaryColumns.has(name) ? `"${name}" AS "${name}"` : `NULL AS "${name}"`;
|
|
10625
|
+
const jobs = db.prepare(`SELECT ${[
|
|
10626
|
+
"id",
|
|
10627
|
+
"session_key",
|
|
10628
|
+
"transcript",
|
|
10629
|
+
"harness",
|
|
10630
|
+
"project",
|
|
10631
|
+
"agent_id",
|
|
10632
|
+
"trigger",
|
|
10633
|
+
"boundary_reason",
|
|
10634
|
+
"captured_at",
|
|
10635
|
+
"ended_at",
|
|
10636
|
+
"completed_at",
|
|
10637
|
+
"created_at"
|
|
10638
|
+
].map(select).join(", ")} FROM summary_jobs`).all();
|
|
10639
|
+
const candidates = new Map;
|
|
10640
|
+
for (const job of jobs) {
|
|
10641
|
+
if (typeof job.transcript !== "string" || job.transcript.trim().length === 0)
|
|
10642
|
+
continue;
|
|
10643
|
+
const agentId = typeof job.agent_id === "string" && job.agent_id.length > 0 ? job.agent_id : "default";
|
|
10644
|
+
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}`)}`;
|
|
10645
|
+
const key = `${agentId}\x00${sessionKey}`;
|
|
10646
|
+
const current = candidates.get(key);
|
|
10647
|
+
const timestamp = summaryJobTimestamp(job);
|
|
10648
|
+
const boundary = isCompletionBoundary(job, summaryColumns);
|
|
10649
|
+
const createdAt = job.captured_at ?? job.created_at ?? job.ended_at ?? timestamp;
|
|
10650
|
+
if (!current) {
|
|
10651
|
+
candidates.set(key, {
|
|
10652
|
+
sessionKey,
|
|
10653
|
+
job: { ...job, agent_id: agentId },
|
|
10654
|
+
content: job.transcript,
|
|
10655
|
+
createdAt,
|
|
10656
|
+
completedAt: boundary ? timestamp : null
|
|
10657
|
+
});
|
|
10658
|
+
continue;
|
|
10659
|
+
}
|
|
10660
|
+
const currentTimestamp = summaryJobTimestamp(current.job);
|
|
10661
|
+
const preferred = timestamp > currentTimestamp || timestamp === currentTimestamp && job.transcript.length > current.content.length ? { ...job, agent_id: agentId } : current.job;
|
|
10662
|
+
candidates.set(key, {
|
|
10663
|
+
sessionKey,
|
|
10664
|
+
job: preferred,
|
|
10665
|
+
content: mergeTranscriptContent(current.content, job.transcript),
|
|
10666
|
+
createdAt: current.createdAt < createdAt ? current.createdAt : createdAt,
|
|
10667
|
+
completedAt: laterTimestamp(current.completedAt, boundary ? timestamp : null)
|
|
10668
|
+
});
|
|
10669
|
+
}
|
|
10670
|
+
const transcriptColumns = tableColumns(db, "session_transcripts");
|
|
10671
|
+
const hasUpdated = transcriptColumns.has("updated_at");
|
|
10672
|
+
const hasCompleted = transcriptColumns.has("completed_at");
|
|
10673
|
+
const hasHash = transcriptColumns.has("content_hash");
|
|
10674
|
+
const insertColumns = ["session_key", "content", "harness", "project", "agent_id", "created_at"];
|
|
10675
|
+
if (hasUpdated)
|
|
10676
|
+
insertColumns.push("updated_at");
|
|
10677
|
+
if (hasCompleted)
|
|
10678
|
+
insertColumns.push("completed_at");
|
|
10679
|
+
if (hasHash)
|
|
10680
|
+
insertColumns.push("content_hash");
|
|
10681
|
+
const insert = db.prepare(`INSERT OR IGNORE INTO session_transcripts (${insertColumns.join(", ")}) VALUES (${insertColumns.map(() => "?").join(", ")})`);
|
|
10682
|
+
const existing = db.prepare("SELECT content, completed_at FROM session_transcripts WHERE agent_id = ? AND session_key = ?");
|
|
10683
|
+
for (const candidate of candidates.values()) {
|
|
10684
|
+
const job = candidate.job;
|
|
10685
|
+
const agentId = job.agent_id ?? "default";
|
|
10686
|
+
const existingRow = existing.get(agentId, candidate.sessionKey);
|
|
10687
|
+
if (existingRow != null) {
|
|
10688
|
+
const previousContent = typeof existingRow.content === "string" ? existingRow.content : "";
|
|
10689
|
+
const mergedContent = mergeTranscriptContent(previousContent, candidate.content);
|
|
10690
|
+
const completedAt = typeof existingRow.completed_at === "string" && existingRow.completed_at.length > 0 ? existingRow.completed_at : candidate.completedAt;
|
|
10691
|
+
const assignments = ["content = ?"];
|
|
10692
|
+
const values2 = [mergedContent];
|
|
10693
|
+
if (hasUpdated && mergedContent !== previousContent) {
|
|
10694
|
+
assignments.push("updated_at = ?");
|
|
10695
|
+
values2.push(candidate.createdAt);
|
|
10696
|
+
}
|
|
10697
|
+
if (hasCompleted && completedAt && !existingRow.completed_at) {
|
|
10698
|
+
assignments.push("completed_at = ?");
|
|
10699
|
+
values2.push(completedAt);
|
|
10700
|
+
}
|
|
10701
|
+
if (hasHash) {
|
|
10702
|
+
assignments.push("content_hash = ?");
|
|
10703
|
+
values2.push(hashTranscript(mergedContent));
|
|
10704
|
+
}
|
|
10705
|
+
values2.push(agentId, candidate.sessionKey);
|
|
10706
|
+
db.prepare(`UPDATE session_transcripts SET ${assignments.join(", ")} WHERE agent_id = ? AND session_key = ?`).run(...values2);
|
|
10707
|
+
continue;
|
|
10708
|
+
}
|
|
10709
|
+
const values = [
|
|
10710
|
+
candidate.sessionKey,
|
|
10711
|
+
candidate.content,
|
|
10712
|
+
job.harness ?? null,
|
|
10713
|
+
job.project ?? null,
|
|
10714
|
+
agentId,
|
|
10715
|
+
candidate.createdAt
|
|
10716
|
+
];
|
|
10717
|
+
if (hasUpdated)
|
|
10718
|
+
values.push(candidate.createdAt);
|
|
10719
|
+
if (hasCompleted)
|
|
10720
|
+
values.push(candidate.completedAt);
|
|
10721
|
+
if (hasHash)
|
|
10722
|
+
values.push(hashTranscript(candidate.content));
|
|
10723
|
+
insert.run(...values);
|
|
10724
|
+
}
|
|
10725
|
+
}
|
|
10726
|
+
function up117(db) {
|
|
10727
|
+
if (!hasTable4(db, "session_transcripts"))
|
|
10728
|
+
return;
|
|
10729
|
+
addColumnIfMissing25(db, "session_transcripts", "completed_at", "TEXT");
|
|
10730
|
+
addColumnIfMissing25(db, "session_transcripts", "content_hash", "TEXT");
|
|
10731
|
+
backfillTranscriptHashes(db);
|
|
10732
|
+
if (hasTable4(db, "transcript_capture_jobs")) {
|
|
10733
|
+
const captureColumns = db.prepare("PRAGMA table_info(transcript_capture_jobs)").all();
|
|
10734
|
+
if (captureColumns.some((row) => row.name === "summary_status")) {
|
|
10735
|
+
db.exec("UPDATE transcript_capture_jobs SET summary_status = 'not_requested' WHERE summary_status IN ('pending', 'failed', 'skipped')");
|
|
10736
|
+
}
|
|
10737
|
+
}
|
|
10738
|
+
if (hasTable4(db, "summary_jobs")) {
|
|
10739
|
+
backfillTranscriptsFromSummaryJobs(db);
|
|
10740
|
+
backfillTranscriptHashes(db);
|
|
10741
|
+
const summaryColumns = tableColumns(db, "summary_jobs");
|
|
10742
|
+
const timestampParts = ["completed_at", "ended_at", "captured_at", "created_at"].filter((column) => summaryColumns.has(column)).map((column) => `sj.${column}`);
|
|
10743
|
+
const timestampValue = timestampParts.length === 1 ? timestampParts[0] : `COALESCE(${timestampParts.join(", ")})`;
|
|
10744
|
+
const completionTimestamp = timestampValue ? `MAX(${timestampValue})` : "NULL";
|
|
10745
|
+
const boundaryParts = [
|
|
10746
|
+
summaryColumns.has("trigger") ? "sj.trigger = 'session_end'" : null,
|
|
10747
|
+
summaryColumns.has("boundary_reason") ? "sj.boundary_reason IN ('session_closed', 'session_clear', 'stale_session', 'ttl_expired')" : null
|
|
10748
|
+
].filter((part) => part !== null);
|
|
10749
|
+
const boundaryPredicate = boundaryParts.length > 0 ? `(${boundaryParts.join(" OR ")})` : "1=1";
|
|
10750
|
+
const agentPredicate = summaryColumns.has("agent_id") ? "sj.agent_id = session_transcripts.agent_id" : "session_transcripts.agent_id = 'default'";
|
|
10751
|
+
if (completionTimestamp !== "NULL") {
|
|
10752
|
+
db.exec(`
|
|
10753
|
+
UPDATE session_transcripts
|
|
10754
|
+
SET completed_at = COALESCE(
|
|
10755
|
+
completed_at,
|
|
10756
|
+
(
|
|
10757
|
+
SELECT ${completionTimestamp}
|
|
10758
|
+
FROM summary_jobs AS sj
|
|
10759
|
+
WHERE ${agentPredicate}
|
|
10760
|
+
AND sj.session_key = session_transcripts.session_key
|
|
10761
|
+
AND ${boundaryPredicate}
|
|
10762
|
+
)
|
|
10763
|
+
)
|
|
10764
|
+
WHERE completed_at IS NULL;
|
|
10765
|
+
`);
|
|
10766
|
+
}
|
|
10767
|
+
db.exec("DELETE FROM summary_jobs");
|
|
10768
|
+
}
|
|
10769
|
+
const completionIndexColumns = ["agent_id", "completed_at"];
|
|
10770
|
+
if (tableColumns(db, "session_transcripts").has("updated_at"))
|
|
10771
|
+
completionIndexColumns.push("updated_at");
|
|
10772
|
+
db.exec(`
|
|
10773
|
+
CREATE INDEX IF NOT EXISTS idx_st_agent_completed
|
|
10774
|
+
ON session_transcripts(${completionIndexColumns.join(", ")});
|
|
10775
|
+
CREATE INDEX IF NOT EXISTS idx_st_agent_hash
|
|
10776
|
+
ON session_transcripts(agent_id, content_hash);
|
|
10777
|
+
`);
|
|
10778
|
+
}
|
|
10560
10779
|
var MIGRATIONS = [
|
|
10561
10780
|
{
|
|
10562
10781
|
version: 1,
|
|
@@ -11496,6 +11715,17 @@ var MIGRATIONS = [
|
|
|
11496
11715
|
{ table: "cross_agent_messages", column: "acp_target_agent_name" }
|
|
11497
11716
|
]
|
|
11498
11717
|
}
|
|
11718
|
+
},
|
|
11719
|
+
{
|
|
11720
|
+
version: 117,
|
|
11721
|
+
name: "retire-summary-worker",
|
|
11722
|
+
up: up117,
|
|
11723
|
+
artifacts: {
|
|
11724
|
+
columns: [
|
|
11725
|
+
{ table: "session_transcripts", column: "completed_at" },
|
|
11726
|
+
{ table: "session_transcripts", column: "content_hash" }
|
|
11727
|
+
]
|
|
11728
|
+
}
|
|
11499
11729
|
}
|
|
11500
11730
|
];
|
|
11501
11731
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -11938,6 +12168,7 @@ function resolveSignetWorkspacePath(home2 = homedir()) {
|
|
|
11938
12168
|
import { createRequire as createRequire3 } from "node:module";
|
|
11939
12169
|
import { dirname as dirname6, join as join4 } from "node:path";
|
|
11940
12170
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
12171
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
11941
12172
|
import { homedir as homedir22 } from "os";
|
|
11942
12173
|
import { join as join22 } from "path";
|
|
11943
12174
|
import { createRequire as createRequire22 } from "node:module";
|
|
@@ -18895,7 +19126,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
18895
19126
|
return true;
|
|
18896
19127
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
18897
19128
|
}
|
|
18898
|
-
function
|
|
19129
|
+
function up118(db) {
|
|
18899
19130
|
db.exec(`
|
|
18900
19131
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
18901
19132
|
version INTEGER PRIMARY KEY,
|
|
@@ -18988,27 +19219,27 @@ function hasColumn22(db, table, column) {
|
|
|
18988
19219
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
18989
19220
|
return rows.some((r) => r.name === column);
|
|
18990
19221
|
}
|
|
18991
|
-
function
|
|
19222
|
+
function addColumnIfMissing26(db, table, column, definition) {
|
|
18992
19223
|
if (!hasColumn22(db, table, column)) {
|
|
18993
19224
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
18994
19225
|
}
|
|
18995
19226
|
}
|
|
18996
19227
|
function up210(db) {
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
|
|
19005
|
-
|
|
19006
|
-
|
|
19007
|
-
|
|
19008
|
-
|
|
19009
|
-
|
|
19010
|
-
|
|
19011
|
-
|
|
19228
|
+
addColumnIfMissing26(db, "memories", "content_hash", "TEXT");
|
|
19229
|
+
addColumnIfMissing26(db, "memories", "normalized_content", "TEXT");
|
|
19230
|
+
addColumnIfMissing26(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
19231
|
+
addColumnIfMissing26(db, "memories", "deleted_at", "TEXT");
|
|
19232
|
+
addColumnIfMissing26(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
19233
|
+
addColumnIfMissing26(db, "memories", "embedding_model", "TEXT");
|
|
19234
|
+
addColumnIfMissing26(db, "memories", "extraction_model", "TEXT");
|
|
19235
|
+
addColumnIfMissing26(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
19236
|
+
addColumnIfMissing26(db, "memories", "who", "TEXT");
|
|
19237
|
+
addColumnIfMissing26(db, "memories", "why", "TEXT");
|
|
19238
|
+
addColumnIfMissing26(db, "memories", "project", "TEXT");
|
|
19239
|
+
addColumnIfMissing26(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
19240
|
+
addColumnIfMissing26(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
19241
|
+
addColumnIfMissing26(db, "memories", "last_accessed", "TEXT");
|
|
19242
|
+
addColumnIfMissing26(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
19012
19243
|
db.exec(`
|
|
19013
19244
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
19014
19245
|
id TEXT PRIMARY KEY,
|
|
@@ -19104,7 +19335,7 @@ function up210(db) {
|
|
|
19104
19335
|
ON memory_entity_mentions(entity_id);
|
|
19105
19336
|
`);
|
|
19106
19337
|
}
|
|
19107
|
-
function
|
|
19338
|
+
function addColumnIfMissing27(db, table, column, definition) {
|
|
19108
19339
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
19109
19340
|
if (rows.some((r) => r.name === column))
|
|
19110
19341
|
return false;
|
|
@@ -19112,8 +19343,8 @@ function addColumnIfMissing26(db, table, column, definition) {
|
|
|
19112
19343
|
return true;
|
|
19113
19344
|
}
|
|
19114
19345
|
function up310(db) {
|
|
19115
|
-
|
|
19116
|
-
|
|
19346
|
+
addColumnIfMissing27(db, "memories", "why", "TEXT");
|
|
19347
|
+
addColumnIfMissing27(db, "memories", "project", "TEXT");
|
|
19117
19348
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
19118
19349
|
db.exec(`
|
|
19119
19350
|
UPDATE memories
|
|
@@ -19318,7 +19549,7 @@ function up1010(db) {
|
|
|
19318
19549
|
)
|
|
19319
19550
|
`);
|
|
19320
19551
|
}
|
|
19321
|
-
function
|
|
19552
|
+
function up119(db) {
|
|
19322
19553
|
db.exec(`
|
|
19323
19554
|
CREATE TABLE IF NOT EXISTS session_scores (
|
|
19324
19555
|
id TEXT PRIMARY KEY,
|
|
@@ -20539,7 +20770,7 @@ function up492(db) {
|
|
|
20539
20770
|
);
|
|
20540
20771
|
`);
|
|
20541
20772
|
}
|
|
20542
|
-
function
|
|
20773
|
+
function hasTable5(db, name) {
|
|
20543
20774
|
return db.prepare(`SELECT name
|
|
20544
20775
|
FROM sqlite_master
|
|
20545
20776
|
WHERE type = 'table' AND name = ?
|
|
@@ -20569,7 +20800,7 @@ function up502(db) {
|
|
|
20569
20800
|
CREATE INDEX IF NOT EXISTS idx_entity_dependency_history_created
|
|
20570
20801
|
ON entity_dependency_history(created_at DESC);
|
|
20571
20802
|
`);
|
|
20572
|
-
if (!
|
|
20803
|
+
if (!hasTable5(db, "entity_dependencies"))
|
|
20573
20804
|
return;
|
|
20574
20805
|
db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_insert");
|
|
20575
20806
|
db.exec("DROP TRIGGER IF EXISTS trg_entity_dependencies_related_to_reason_update");
|
|
@@ -22471,11 +22702,229 @@ function up1162(db) {
|
|
|
22471
22702
|
ON cross_agent_messages(delivery_path, delivery_state, delivery_lease_expires_at, delivery_updated_at);
|
|
22472
22703
|
`);
|
|
22473
22704
|
}
|
|
22705
|
+
function hasTable42(db, table) {
|
|
22706
|
+
return db.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) != null;
|
|
22707
|
+
}
|
|
22708
|
+
function addColumnIfMissing252(db, table, column, definition) {
|
|
22709
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
22710
|
+
if (columns.some((row) => row.name === column))
|
|
22711
|
+
return;
|
|
22712
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
22713
|
+
}
|
|
22714
|
+
function tableColumns2(db, table) {
|
|
22715
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
22716
|
+
return new Set(rows.map((row) => typeof row.name === "string" ? row.name : ""));
|
|
22717
|
+
}
|
|
22718
|
+
function hashTranscript2(content) {
|
|
22719
|
+
return createHash2("sha256").update(content, "utf8").digest("hex");
|
|
22720
|
+
}
|
|
22721
|
+
function backfillTranscriptHashes2(db) {
|
|
22722
|
+
const columns = tableColumns2(db, "session_transcripts");
|
|
22723
|
+
if (!columns.has("content_hash") || !columns.has("content"))
|
|
22724
|
+
return;
|
|
22725
|
+
const rows = db.prepare("SELECT session_key, agent_id, content FROM session_transcripts WHERE content_hash IS NULL").all();
|
|
22726
|
+
const update = db.prepare("UPDATE session_transcripts SET content_hash = ? WHERE agent_id = ? AND session_key = ? AND content_hash IS NULL");
|
|
22727
|
+
for (const row of rows) {
|
|
22728
|
+
if (typeof row.content !== "string" || typeof row.session_key !== "string")
|
|
22729
|
+
continue;
|
|
22730
|
+
update.run(hashTranscript2(row.content), typeof row.agent_id === "string" ? row.agent_id : "default", row.session_key);
|
|
22731
|
+
}
|
|
22732
|
+
}
|
|
22733
|
+
var COMPLETION_BOUNDARY_REASONS2 = new Set(["session_closed", "session_clear", "stale_session", "ttl_expired"]);
|
|
22734
|
+
function summaryJobTimestamp2(job) {
|
|
22735
|
+
return job.completed_at ?? job.ended_at ?? job.captured_at ?? job.created_at ?? new Date(0).toISOString();
|
|
22736
|
+
}
|
|
22737
|
+
function laterTimestamp2(current, candidate) {
|
|
22738
|
+
if (current === null)
|
|
22739
|
+
return candidate;
|
|
22740
|
+
if (candidate === null)
|
|
22741
|
+
return current;
|
|
22742
|
+
const currentMillis = Date.parse(current);
|
|
22743
|
+
const candidateMillis = Date.parse(candidate);
|
|
22744
|
+
if (Number.isFinite(currentMillis) && Number.isFinite(candidateMillis)) {
|
|
22745
|
+
return candidateMillis > currentMillis ? candidate : current;
|
|
22746
|
+
}
|
|
22747
|
+
return candidate > current ? candidate : current;
|
|
22748
|
+
}
|
|
22749
|
+
function isCompletionBoundary2(job, columns) {
|
|
22750
|
+
return columns.has("trigger") && job.trigger === "session_end" || columns.has("boundary_reason") && COMPLETION_BOUNDARY_REASONS2.has(job.boundary_reason ?? "");
|
|
22751
|
+
}
|
|
22752
|
+
function mergeTranscriptContent2(current, next) {
|
|
22753
|
+
if (current.length === 0)
|
|
22754
|
+
return next;
|
|
22755
|
+
if (next.length === 0 || current === next || current.includes(next))
|
|
22756
|
+
return current;
|
|
22757
|
+
if (next.includes(current))
|
|
22758
|
+
return next;
|
|
22759
|
+
return `${current}
|
|
22760
|
+
${next}`;
|
|
22761
|
+
}
|
|
22762
|
+
function backfillTranscriptsFromSummaryJobs2(db) {
|
|
22763
|
+
if (!hasTable42(db, "summary_jobs"))
|
|
22764
|
+
return;
|
|
22765
|
+
const summaryColumns = tableColumns2(db, "summary_jobs");
|
|
22766
|
+
if (!summaryColumns.has("transcript"))
|
|
22767
|
+
return;
|
|
22768
|
+
const select = (name) => summaryColumns.has(name) ? `"${name}" AS "${name}"` : `NULL AS "${name}"`;
|
|
22769
|
+
const jobs = db.prepare(`SELECT ${[
|
|
22770
|
+
"id",
|
|
22771
|
+
"session_key",
|
|
22772
|
+
"transcript",
|
|
22773
|
+
"harness",
|
|
22774
|
+
"project",
|
|
22775
|
+
"agent_id",
|
|
22776
|
+
"trigger",
|
|
22777
|
+
"boundary_reason",
|
|
22778
|
+
"captured_at",
|
|
22779
|
+
"ended_at",
|
|
22780
|
+
"completed_at",
|
|
22781
|
+
"created_at"
|
|
22782
|
+
].map(select).join(", ")} FROM summary_jobs`).all();
|
|
22783
|
+
const candidates = new Map;
|
|
22784
|
+
for (const job of jobs) {
|
|
22785
|
+
if (typeof job.transcript !== "string" || job.transcript.trim().length === 0)
|
|
22786
|
+
continue;
|
|
22787
|
+
const agentId = typeof job.agent_id === "string" && job.agent_id.length > 0 ? job.agent_id : "default";
|
|
22788
|
+
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}`)}`;
|
|
22789
|
+
const key = `${agentId}\x00${sessionKey}`;
|
|
22790
|
+
const current = candidates.get(key);
|
|
22791
|
+
const timestamp = summaryJobTimestamp2(job);
|
|
22792
|
+
const boundary = isCompletionBoundary2(job, summaryColumns);
|
|
22793
|
+
const createdAt = job.captured_at ?? job.created_at ?? job.ended_at ?? timestamp;
|
|
22794
|
+
if (!current) {
|
|
22795
|
+
candidates.set(key, {
|
|
22796
|
+
sessionKey,
|
|
22797
|
+
job: { ...job, agent_id: agentId },
|
|
22798
|
+
content: job.transcript,
|
|
22799
|
+
createdAt,
|
|
22800
|
+
completedAt: boundary ? timestamp : null
|
|
22801
|
+
});
|
|
22802
|
+
continue;
|
|
22803
|
+
}
|
|
22804
|
+
const currentTimestamp = summaryJobTimestamp2(current.job);
|
|
22805
|
+
const preferred = timestamp > currentTimestamp || timestamp === currentTimestamp && job.transcript.length > current.content.length ? { ...job, agent_id: agentId } : current.job;
|
|
22806
|
+
candidates.set(key, {
|
|
22807
|
+
sessionKey,
|
|
22808
|
+
job: preferred,
|
|
22809
|
+
content: mergeTranscriptContent2(current.content, job.transcript),
|
|
22810
|
+
createdAt: current.createdAt < createdAt ? current.createdAt : createdAt,
|
|
22811
|
+
completedAt: laterTimestamp2(current.completedAt, boundary ? timestamp : null)
|
|
22812
|
+
});
|
|
22813
|
+
}
|
|
22814
|
+
const transcriptColumns = tableColumns2(db, "session_transcripts");
|
|
22815
|
+
const hasUpdated = transcriptColumns.has("updated_at");
|
|
22816
|
+
const hasCompleted = transcriptColumns.has("completed_at");
|
|
22817
|
+
const hasHash = transcriptColumns.has("content_hash");
|
|
22818
|
+
const insertColumns = ["session_key", "content", "harness", "project", "agent_id", "created_at"];
|
|
22819
|
+
if (hasUpdated)
|
|
22820
|
+
insertColumns.push("updated_at");
|
|
22821
|
+
if (hasCompleted)
|
|
22822
|
+
insertColumns.push("completed_at");
|
|
22823
|
+
if (hasHash)
|
|
22824
|
+
insertColumns.push("content_hash");
|
|
22825
|
+
const insert = db.prepare(`INSERT OR IGNORE INTO session_transcripts (${insertColumns.join(", ")}) VALUES (${insertColumns.map(() => "?").join(", ")})`);
|
|
22826
|
+
const existing = db.prepare("SELECT content, completed_at FROM session_transcripts WHERE agent_id = ? AND session_key = ?");
|
|
22827
|
+
for (const candidate of candidates.values()) {
|
|
22828
|
+
const job = candidate.job;
|
|
22829
|
+
const agentId = job.agent_id ?? "default";
|
|
22830
|
+
const existingRow = existing.get(agentId, candidate.sessionKey);
|
|
22831
|
+
if (existingRow != null) {
|
|
22832
|
+
const previousContent = typeof existingRow.content === "string" ? existingRow.content : "";
|
|
22833
|
+
const mergedContent = mergeTranscriptContent2(previousContent, candidate.content);
|
|
22834
|
+
const completedAt = typeof existingRow.completed_at === "string" && existingRow.completed_at.length > 0 ? existingRow.completed_at : candidate.completedAt;
|
|
22835
|
+
const assignments = ["content = ?"];
|
|
22836
|
+
const values2 = [mergedContent];
|
|
22837
|
+
if (hasUpdated && mergedContent !== previousContent) {
|
|
22838
|
+
assignments.push("updated_at = ?");
|
|
22839
|
+
values2.push(candidate.createdAt);
|
|
22840
|
+
}
|
|
22841
|
+
if (hasCompleted && completedAt && !existingRow.completed_at) {
|
|
22842
|
+
assignments.push("completed_at = ?");
|
|
22843
|
+
values2.push(completedAt);
|
|
22844
|
+
}
|
|
22845
|
+
if (hasHash) {
|
|
22846
|
+
assignments.push("content_hash = ?");
|
|
22847
|
+
values2.push(hashTranscript2(mergedContent));
|
|
22848
|
+
}
|
|
22849
|
+
values2.push(agentId, candidate.sessionKey);
|
|
22850
|
+
db.prepare(`UPDATE session_transcripts SET ${assignments.join(", ")} WHERE agent_id = ? AND session_key = ?`).run(...values2);
|
|
22851
|
+
continue;
|
|
22852
|
+
}
|
|
22853
|
+
const values = [
|
|
22854
|
+
candidate.sessionKey,
|
|
22855
|
+
candidate.content,
|
|
22856
|
+
job.harness ?? null,
|
|
22857
|
+
job.project ?? null,
|
|
22858
|
+
agentId,
|
|
22859
|
+
candidate.createdAt
|
|
22860
|
+
];
|
|
22861
|
+
if (hasUpdated)
|
|
22862
|
+
values.push(candidate.createdAt);
|
|
22863
|
+
if (hasCompleted)
|
|
22864
|
+
values.push(candidate.completedAt);
|
|
22865
|
+
if (hasHash)
|
|
22866
|
+
values.push(hashTranscript2(candidate.content));
|
|
22867
|
+
insert.run(...values);
|
|
22868
|
+
}
|
|
22869
|
+
}
|
|
22870
|
+
function up1172(db) {
|
|
22871
|
+
if (!hasTable42(db, "session_transcripts"))
|
|
22872
|
+
return;
|
|
22873
|
+
addColumnIfMissing252(db, "session_transcripts", "completed_at", "TEXT");
|
|
22874
|
+
addColumnIfMissing252(db, "session_transcripts", "content_hash", "TEXT");
|
|
22875
|
+
backfillTranscriptHashes2(db);
|
|
22876
|
+
if (hasTable42(db, "transcript_capture_jobs")) {
|
|
22877
|
+
const captureColumns = db.prepare("PRAGMA table_info(transcript_capture_jobs)").all();
|
|
22878
|
+
if (captureColumns.some((row) => row.name === "summary_status")) {
|
|
22879
|
+
db.exec("UPDATE transcript_capture_jobs SET summary_status = 'not_requested' WHERE summary_status IN ('pending', 'failed', 'skipped')");
|
|
22880
|
+
}
|
|
22881
|
+
}
|
|
22882
|
+
if (hasTable42(db, "summary_jobs")) {
|
|
22883
|
+
backfillTranscriptsFromSummaryJobs2(db);
|
|
22884
|
+
backfillTranscriptHashes2(db);
|
|
22885
|
+
const summaryColumns = tableColumns2(db, "summary_jobs");
|
|
22886
|
+
const timestampParts = ["completed_at", "ended_at", "captured_at", "created_at"].filter((column) => summaryColumns.has(column)).map((column) => `sj.${column}`);
|
|
22887
|
+
const timestampValue = timestampParts.length === 1 ? timestampParts[0] : `COALESCE(${timestampParts.join(", ")})`;
|
|
22888
|
+
const completionTimestamp = timestampValue ? `MAX(${timestampValue})` : "NULL";
|
|
22889
|
+
const boundaryParts = [
|
|
22890
|
+
summaryColumns.has("trigger") ? "sj.trigger = 'session_end'" : null,
|
|
22891
|
+
summaryColumns.has("boundary_reason") ? "sj.boundary_reason IN ('session_closed', 'session_clear', 'stale_session', 'ttl_expired')" : null
|
|
22892
|
+
].filter((part) => part !== null);
|
|
22893
|
+
const boundaryPredicate = boundaryParts.length > 0 ? `(${boundaryParts.join(" OR ")})` : "1=1";
|
|
22894
|
+
const agentPredicate = summaryColumns.has("agent_id") ? "sj.agent_id = session_transcripts.agent_id" : "session_transcripts.agent_id = 'default'";
|
|
22895
|
+
if (completionTimestamp !== "NULL") {
|
|
22896
|
+
db.exec(`
|
|
22897
|
+
UPDATE session_transcripts
|
|
22898
|
+
SET completed_at = COALESCE(
|
|
22899
|
+
completed_at,
|
|
22900
|
+
(
|
|
22901
|
+
SELECT ${completionTimestamp}
|
|
22902
|
+
FROM summary_jobs AS sj
|
|
22903
|
+
WHERE ${agentPredicate}
|
|
22904
|
+
AND sj.session_key = session_transcripts.session_key
|
|
22905
|
+
AND ${boundaryPredicate}
|
|
22906
|
+
)
|
|
22907
|
+
)
|
|
22908
|
+
WHERE completed_at IS NULL;
|
|
22909
|
+
`);
|
|
22910
|
+
}
|
|
22911
|
+
db.exec("DELETE FROM summary_jobs");
|
|
22912
|
+
}
|
|
22913
|
+
const completionIndexColumns = ["agent_id", "completed_at"];
|
|
22914
|
+
if (tableColumns2(db, "session_transcripts").has("updated_at"))
|
|
22915
|
+
completionIndexColumns.push("updated_at");
|
|
22916
|
+
db.exec(`
|
|
22917
|
+
CREATE INDEX IF NOT EXISTS idx_st_agent_completed
|
|
22918
|
+
ON session_transcripts(${completionIndexColumns.join(", ")});
|
|
22919
|
+
CREATE INDEX IF NOT EXISTS idx_st_agent_hash
|
|
22920
|
+
ON session_transcripts(agent_id, content_hash);
|
|
22921
|
+
`);
|
|
22922
|
+
}
|
|
22474
22923
|
var MIGRATIONS2 = [
|
|
22475
22924
|
{
|
|
22476
22925
|
version: 1,
|
|
22477
22926
|
name: "baseline",
|
|
22478
|
-
up:
|
|
22927
|
+
up: up118,
|
|
22479
22928
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
22480
22929
|
},
|
|
22481
22930
|
{
|
|
@@ -22541,7 +22990,7 @@ var MIGRATIONS2 = [
|
|
|
22541
22990
|
{
|
|
22542
22991
|
version: 11,
|
|
22543
22992
|
name: "session-scores",
|
|
22544
|
-
up:
|
|
22993
|
+
up: up119,
|
|
22545
22994
|
artifacts: { tables: ["session_scores"] }
|
|
22546
22995
|
},
|
|
22547
22996
|
{
|
|
@@ -23410,6 +23859,17 @@ var MIGRATIONS2 = [
|
|
|
23410
23859
|
{ table: "cross_agent_messages", column: "acp_target_agent_name" }
|
|
23411
23860
|
]
|
|
23412
23861
|
}
|
|
23862
|
+
},
|
|
23863
|
+
{
|
|
23864
|
+
version: 117,
|
|
23865
|
+
name: "retire-summary-worker",
|
|
23866
|
+
up: up1172,
|
|
23867
|
+
artifacts: {
|
|
23868
|
+
columns: [
|
|
23869
|
+
{ table: "session_transcripts", column: "completed_at" },
|
|
23870
|
+
{ table: "session_transcripts", column: "content_hash" }
|
|
23871
|
+
]
|
|
23872
|
+
}
|
|
23413
23873
|
}
|
|
23414
23874
|
];
|
|
23415
23875
|
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-gemini",
|
|
3
|
-
"version": "0.185.
|
|
3
|
+
"version": "0.185.5",
|
|
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.185.
|
|
28
|
-
"@signetai/core": "0.185.
|
|
27
|
+
"@signetai/connector-base": "0.185.5",
|
|
28
|
+
"@signetai/core": "0.185.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.0.0",
|