@signetai/connector-base 0.238.1 → 0.239.1

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/agent-dir.js CHANGED
@@ -15927,6 +15927,185 @@ function up170(db) {
15927
15927
  INSERT OR IGNORE INTO dependency_history_compaction_state (id) VALUES (1);
15928
15928
  `);
15929
15929
  }
15930
+ function up171(db) {
15931
+ db.exec(`
15932
+ CREATE TABLE IF NOT EXISTS cross_agent_message_wakes (
15933
+ message_id TEXT PRIMARY KEY,
15934
+ agent_id TEXT NOT NULL,
15935
+ session_key TEXT NOT NULL,
15936
+ harness TEXT NOT NULL,
15937
+ woken_at TEXT NOT NULL
15938
+ );
15939
+ CREATE INDEX IF NOT EXISTS idx_cross_agent_message_wakes_session
15940
+ ON cross_agent_message_wakes(session_key, woken_at);
15941
+
15942
+ CREATE TABLE IF NOT EXISTS board_topics (
15943
+ slug TEXT PRIMARY KEY,
15944
+ title TEXT,
15945
+ description TEXT,
15946
+ created_by_agent_id TEXT NOT NULL,
15947
+ created_at TEXT NOT NULL,
15948
+ updated_at TEXT NOT NULL
15949
+ );
15950
+
15951
+ CREATE TABLE IF NOT EXISTS board_threads (
15952
+ id TEXT PRIMARY KEY,
15953
+ topic_slug TEXT NOT NULL,
15954
+ title TEXT NOT NULL,
15955
+ author_agent_id TEXT NOT NULL,
15956
+ author_session_key TEXT,
15957
+ author_harness TEXT,
15958
+ status TEXT NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'resolved', 'archived')),
15959
+ pinned INTEGER NOT NULL DEFAULT 0 CHECK (pinned IN (0, 1)),
15960
+ source_message_id TEXT,
15961
+ post_count INTEGER NOT NULL DEFAULT 0 CHECK (post_count >= 0),
15962
+ created_at TEXT NOT NULL,
15963
+ updated_at TEXT NOT NULL,
15964
+ last_post_at TEXT NOT NULL
15965
+ );
15966
+ CREATE INDEX IF NOT EXISTS idx_board_threads_topic_activity
15967
+ ON board_threads(topic_slug, last_post_at DESC, id);
15968
+ CREATE INDEX IF NOT EXISTS idx_board_threads_activity
15969
+ ON board_threads(last_post_at DESC, id);
15970
+ DROP INDEX IF EXISTS idx_board_threads_author;
15971
+ CREATE INDEX idx_board_threads_author
15972
+ ON board_threads(author_agent_id, author_session_key);
15973
+
15974
+ CREATE TABLE IF NOT EXISTS board_thread_tags (
15975
+ thread_id TEXT NOT NULL,
15976
+ tag TEXT NOT NULL,
15977
+ PRIMARY KEY (thread_id, tag)
15978
+ );
15979
+ CREATE INDEX IF NOT EXISTS idx_board_thread_tags_tag
15980
+ ON board_thread_tags(tag, thread_id);
15981
+
15982
+ CREATE TABLE IF NOT EXISTS board_posts (
15983
+ id TEXT PRIMARY KEY,
15984
+ seq INTEGER NOT NULL,
15985
+ thread_id TEXT NOT NULL,
15986
+ author_agent_id TEXT NOT NULL,
15987
+ author_session_key TEXT,
15988
+ author_harness TEXT,
15989
+ body TEXT NOT NULL,
15990
+ reply_to_post_id TEXT,
15991
+ created_at TEXT NOT NULL,
15992
+ projected_at TEXT
15993
+ );
15994
+ `);
15995
+ repairBoardPosts(db);
15996
+ db.exec(`
15997
+ CREATE TABLE IF NOT EXISTS board_reads (
15998
+ agent_id TEXT NOT NULL,
15999
+ thread_id TEXT NOT NULL,
16000
+ last_read_at TEXT NOT NULL,
16001
+ last_read_post_seq INTEGER NOT NULL DEFAULT 0,
16002
+ PRIMARY KEY (agent_id, thread_id)
16003
+ );
16004
+ CREATE INDEX IF NOT EXISTS idx_board_reads_thread
16005
+ ON board_reads(thread_id);
16006
+
16007
+ `);
16008
+ repairBoardReads(db);
16009
+ repairBoardNotices(db);
16010
+ db.exec(`
16011
+ CREATE TABLE IF NOT EXISTS board_notices (
16012
+ agent_id TEXT NOT NULL,
16013
+ session_key TEXT NOT NULL,
16014
+ thread_id TEXT NOT NULL,
16015
+ notified_post_seq INTEGER NOT NULL DEFAULT 0,
16016
+ PRIMARY KEY (agent_id, session_key, thread_id)
16017
+ );
16018
+ DROP INDEX IF EXISTS idx_board_posts_thread;
16019
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_board_posts_seq
16020
+ ON board_posts(seq);
16021
+ CREATE INDEX IF NOT EXISTS idx_board_posts_thread
16022
+ ON board_posts(thread_id, seq);
16023
+ CREATE INDEX IF NOT EXISTS idx_board_posts_author
16024
+ ON board_posts(author_agent_id, author_session_key, thread_id);
16025
+ CREATE INDEX IF NOT EXISTS idx_board_posts_unprojected
16026
+ ON board_posts(created_at, id) WHERE projected_at IS NULL;
16027
+
16028
+ CREATE INDEX IF NOT EXISTS idx_board_reads_thread
16029
+ ON board_reads(thread_id);
16030
+ CREATE INDEX IF NOT EXISTS idx_board_notices_thread
16031
+ ON board_notices(thread_id);
16032
+ `);
16033
+ }
16034
+ function columnNames(db, table) {
16035
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
16036
+ return new Set(rows.map((row) => String(row.name)));
16037
+ }
16038
+ function repairBoardPosts(db) {
16039
+ if (!columnNames(db, "board_posts").has("seq")) {
16040
+ db.exec("ALTER TABLE board_posts ADD COLUMN seq INTEGER");
16041
+ }
16042
+ const rows = db.prepare("SELECT rowid AS rid, seq FROM board_posts ORDER BY rowid ASC").all();
16043
+ const used = new Set;
16044
+ let max = 0;
16045
+ for (const row of rows) {
16046
+ const seq = typeof row.seq === "number" ? row.seq : Number.NaN;
16047
+ if (Number.isInteger(seq) && seq > 0 && !used.has(seq)) {
16048
+ used.add(seq);
16049
+ max = Math.max(max, seq);
16050
+ }
16051
+ }
16052
+ const seen = new Set;
16053
+ const update = db.prepare("UPDATE board_posts SET seq = ? WHERE rowid = ?");
16054
+ for (const row of rows) {
16055
+ const seq = typeof row.seq === "number" ? row.seq : Number.NaN;
16056
+ if (Number.isInteger(seq) && seq > 0 && !seen.has(seq)) {
16057
+ seen.add(seq);
16058
+ continue;
16059
+ }
16060
+ max += 1;
16061
+ update.run(max, row.rid);
16062
+ }
16063
+ }
16064
+ function repairBoardReads(db) {
16065
+ if (columnNames(db, "board_reads").has("last_read_post_seq"))
16066
+ return;
16067
+ db.exec("ALTER TABLE board_reads ADD COLUMN last_read_post_seq INTEGER NOT NULL DEFAULT 0");
16068
+ db.exec(`
16069
+ UPDATE board_reads SET last_read_post_seq = COALESCE((
16070
+ SELECT MAX(p.seq) FROM board_posts p
16071
+ WHERE p.thread_id = board_reads.thread_id AND p.created_at <= board_reads.last_read_at
16072
+ ), 0)
16073
+ `);
16074
+ }
16075
+ function repairBoardNotices(db) {
16076
+ const columns = columnNames(db, "board_notices");
16077
+ if (columns.size === 0)
16078
+ return;
16079
+ if (columns.has("notified_post_seq") && !columns.has("notified_at"))
16080
+ return;
16081
+ db.exec("SAVEPOINT repair_board_notices");
16082
+ try {
16083
+ db.exec("DROP TABLE IF EXISTS board_notices_repair");
16084
+ db.exec(`
16085
+ CREATE TABLE board_notices_repair (
16086
+ agent_id TEXT NOT NULL,
16087
+ session_key TEXT NOT NULL,
16088
+ thread_id TEXT NOT NULL,
16089
+ notified_post_seq INTEGER NOT NULL DEFAULT 0,
16090
+ PRIMARY KEY (agent_id, session_key, thread_id)
16091
+ )
16092
+ `);
16093
+ const seqExpr = columns.has("notified_post_seq") ? "COALESCE(n.notified_post_seq, 0)" : "0";
16094
+ const atExpr = columns.has("notified_at") ? `COALESCE((SELECT MAX(p.seq) FROM board_posts p WHERE p.thread_id = n.thread_id AND p.created_at <= n.notified_at), 0)` : "0";
16095
+ db.exec(`
16096
+ INSERT INTO board_notices_repair (agent_id, session_key, thread_id, notified_post_seq)
16097
+ SELECT n.agent_id, n.session_key, n.thread_id, MAX(${seqExpr}, ${atExpr})
16098
+ FROM board_notices n
16099
+ `);
16100
+ db.exec("DROP TABLE board_notices");
16101
+ db.exec("ALTER TABLE board_notices_repair RENAME TO board_notices");
16102
+ db.exec("RELEASE repair_board_notices");
16103
+ } catch (error) {
16104
+ db.exec("ROLLBACK TO repair_board_notices");
16105
+ db.exec("RELEASE repair_board_notices");
16106
+ throw error;
16107
+ }
16108
+ }
15930
16109
  var MIGRATIONS = [
15931
16110
  {
15932
16111
  version: 1,
@@ -17299,6 +17478,30 @@ var MIGRATIONS = [
17299
17478
  artifacts: {
17300
17479
  tables: ["dependency_history_compaction_state"]
17301
17480
  }
17481
+ },
17482
+ {
17483
+ version: 171,
17484
+ name: "agent-wake-and-message-board",
17485
+ up: up171,
17486
+ artifacts: {
17487
+ columns: [
17488
+ { table: "cross_agent_message_wakes", column: "session_key" },
17489
+ { table: "board_threads", column: "last_post_at" },
17490
+ { table: "board_posts", column: "projected_at" },
17491
+ { table: "board_posts", column: "seq" },
17492
+ { table: "board_reads", column: "last_read_post_seq" },
17493
+ { table: "board_notices", column: "notified_post_seq" }
17494
+ ],
17495
+ tables: [
17496
+ "cross_agent_message_wakes",
17497
+ "board_topics",
17498
+ "board_threads",
17499
+ "board_thread_tags",
17500
+ "board_posts",
17501
+ "board_reads",
17502
+ "board_notices"
17503
+ ]
17504
+ }
17302
17505
  }
17303
17506
  ];
17304
17507
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
package/dist/index.js CHANGED
@@ -15928,6 +15928,185 @@ function up170(db) {
15928
15928
  INSERT OR IGNORE INTO dependency_history_compaction_state (id) VALUES (1);
15929
15929
  `);
15930
15930
  }
15931
+ function up171(db) {
15932
+ db.exec(`
15933
+ CREATE TABLE IF NOT EXISTS cross_agent_message_wakes (
15934
+ message_id TEXT PRIMARY KEY,
15935
+ agent_id TEXT NOT NULL,
15936
+ session_key TEXT NOT NULL,
15937
+ harness TEXT NOT NULL,
15938
+ woken_at TEXT NOT NULL
15939
+ );
15940
+ CREATE INDEX IF NOT EXISTS idx_cross_agent_message_wakes_session
15941
+ ON cross_agent_message_wakes(session_key, woken_at);
15942
+
15943
+ CREATE TABLE IF NOT EXISTS board_topics (
15944
+ slug TEXT PRIMARY KEY,
15945
+ title TEXT,
15946
+ description TEXT,
15947
+ created_by_agent_id TEXT NOT NULL,
15948
+ created_at TEXT NOT NULL,
15949
+ updated_at TEXT NOT NULL
15950
+ );
15951
+
15952
+ CREATE TABLE IF NOT EXISTS board_threads (
15953
+ id TEXT PRIMARY KEY,
15954
+ topic_slug TEXT NOT NULL,
15955
+ title TEXT NOT NULL,
15956
+ author_agent_id TEXT NOT NULL,
15957
+ author_session_key TEXT,
15958
+ author_harness TEXT,
15959
+ status TEXT NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'resolved', 'archived')),
15960
+ pinned INTEGER NOT NULL DEFAULT 0 CHECK (pinned IN (0, 1)),
15961
+ source_message_id TEXT,
15962
+ post_count INTEGER NOT NULL DEFAULT 0 CHECK (post_count >= 0),
15963
+ created_at TEXT NOT NULL,
15964
+ updated_at TEXT NOT NULL,
15965
+ last_post_at TEXT NOT NULL
15966
+ );
15967
+ CREATE INDEX IF NOT EXISTS idx_board_threads_topic_activity
15968
+ ON board_threads(topic_slug, last_post_at DESC, id);
15969
+ CREATE INDEX IF NOT EXISTS idx_board_threads_activity
15970
+ ON board_threads(last_post_at DESC, id);
15971
+ DROP INDEX IF EXISTS idx_board_threads_author;
15972
+ CREATE INDEX idx_board_threads_author
15973
+ ON board_threads(author_agent_id, author_session_key);
15974
+
15975
+ CREATE TABLE IF NOT EXISTS board_thread_tags (
15976
+ thread_id TEXT NOT NULL,
15977
+ tag TEXT NOT NULL,
15978
+ PRIMARY KEY (thread_id, tag)
15979
+ );
15980
+ CREATE INDEX IF NOT EXISTS idx_board_thread_tags_tag
15981
+ ON board_thread_tags(tag, thread_id);
15982
+
15983
+ CREATE TABLE IF NOT EXISTS board_posts (
15984
+ id TEXT PRIMARY KEY,
15985
+ seq INTEGER NOT NULL,
15986
+ thread_id TEXT NOT NULL,
15987
+ author_agent_id TEXT NOT NULL,
15988
+ author_session_key TEXT,
15989
+ author_harness TEXT,
15990
+ body TEXT NOT NULL,
15991
+ reply_to_post_id TEXT,
15992
+ created_at TEXT NOT NULL,
15993
+ projected_at TEXT
15994
+ );
15995
+ `);
15996
+ repairBoardPosts(db);
15997
+ db.exec(`
15998
+ CREATE TABLE IF NOT EXISTS board_reads (
15999
+ agent_id TEXT NOT NULL,
16000
+ thread_id TEXT NOT NULL,
16001
+ last_read_at TEXT NOT NULL,
16002
+ last_read_post_seq INTEGER NOT NULL DEFAULT 0,
16003
+ PRIMARY KEY (agent_id, thread_id)
16004
+ );
16005
+ CREATE INDEX IF NOT EXISTS idx_board_reads_thread
16006
+ ON board_reads(thread_id);
16007
+
16008
+ `);
16009
+ repairBoardReads(db);
16010
+ repairBoardNotices(db);
16011
+ db.exec(`
16012
+ CREATE TABLE IF NOT EXISTS board_notices (
16013
+ agent_id TEXT NOT NULL,
16014
+ session_key TEXT NOT NULL,
16015
+ thread_id TEXT NOT NULL,
16016
+ notified_post_seq INTEGER NOT NULL DEFAULT 0,
16017
+ PRIMARY KEY (agent_id, session_key, thread_id)
16018
+ );
16019
+ DROP INDEX IF EXISTS idx_board_posts_thread;
16020
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_board_posts_seq
16021
+ ON board_posts(seq);
16022
+ CREATE INDEX IF NOT EXISTS idx_board_posts_thread
16023
+ ON board_posts(thread_id, seq);
16024
+ CREATE INDEX IF NOT EXISTS idx_board_posts_author
16025
+ ON board_posts(author_agent_id, author_session_key, thread_id);
16026
+ CREATE INDEX IF NOT EXISTS idx_board_posts_unprojected
16027
+ ON board_posts(created_at, id) WHERE projected_at IS NULL;
16028
+
16029
+ CREATE INDEX IF NOT EXISTS idx_board_reads_thread
16030
+ ON board_reads(thread_id);
16031
+ CREATE INDEX IF NOT EXISTS idx_board_notices_thread
16032
+ ON board_notices(thread_id);
16033
+ `);
16034
+ }
16035
+ function columnNames(db, table) {
16036
+ const rows = db.prepare(`PRAGMA table_info(${table})`).all();
16037
+ return new Set(rows.map((row) => String(row.name)));
16038
+ }
16039
+ function repairBoardPosts(db) {
16040
+ if (!columnNames(db, "board_posts").has("seq")) {
16041
+ db.exec("ALTER TABLE board_posts ADD COLUMN seq INTEGER");
16042
+ }
16043
+ const rows = db.prepare("SELECT rowid AS rid, seq FROM board_posts ORDER BY rowid ASC").all();
16044
+ const used = new Set;
16045
+ let max = 0;
16046
+ for (const row of rows) {
16047
+ const seq = typeof row.seq === "number" ? row.seq : Number.NaN;
16048
+ if (Number.isInteger(seq) && seq > 0 && !used.has(seq)) {
16049
+ used.add(seq);
16050
+ max = Math.max(max, seq);
16051
+ }
16052
+ }
16053
+ const seen = new Set;
16054
+ const update = db.prepare("UPDATE board_posts SET seq = ? WHERE rowid = ?");
16055
+ for (const row of rows) {
16056
+ const seq = typeof row.seq === "number" ? row.seq : Number.NaN;
16057
+ if (Number.isInteger(seq) && seq > 0 && !seen.has(seq)) {
16058
+ seen.add(seq);
16059
+ continue;
16060
+ }
16061
+ max += 1;
16062
+ update.run(max, row.rid);
16063
+ }
16064
+ }
16065
+ function repairBoardReads(db) {
16066
+ if (columnNames(db, "board_reads").has("last_read_post_seq"))
16067
+ return;
16068
+ db.exec("ALTER TABLE board_reads ADD COLUMN last_read_post_seq INTEGER NOT NULL DEFAULT 0");
16069
+ db.exec(`
16070
+ UPDATE board_reads SET last_read_post_seq = COALESCE((
16071
+ SELECT MAX(p.seq) FROM board_posts p
16072
+ WHERE p.thread_id = board_reads.thread_id AND p.created_at <= board_reads.last_read_at
16073
+ ), 0)
16074
+ `);
16075
+ }
16076
+ function repairBoardNotices(db) {
16077
+ const columns = columnNames(db, "board_notices");
16078
+ if (columns.size === 0)
16079
+ return;
16080
+ if (columns.has("notified_post_seq") && !columns.has("notified_at"))
16081
+ return;
16082
+ db.exec("SAVEPOINT repair_board_notices");
16083
+ try {
16084
+ db.exec("DROP TABLE IF EXISTS board_notices_repair");
16085
+ db.exec(`
16086
+ CREATE TABLE board_notices_repair (
16087
+ agent_id TEXT NOT NULL,
16088
+ session_key TEXT NOT NULL,
16089
+ thread_id TEXT NOT NULL,
16090
+ notified_post_seq INTEGER NOT NULL DEFAULT 0,
16091
+ PRIMARY KEY (agent_id, session_key, thread_id)
16092
+ )
16093
+ `);
16094
+ const seqExpr = columns.has("notified_post_seq") ? "COALESCE(n.notified_post_seq, 0)" : "0";
16095
+ const atExpr = columns.has("notified_at") ? `COALESCE((SELECT MAX(p.seq) FROM board_posts p WHERE p.thread_id = n.thread_id AND p.created_at <= n.notified_at), 0)` : "0";
16096
+ db.exec(`
16097
+ INSERT INTO board_notices_repair (agent_id, session_key, thread_id, notified_post_seq)
16098
+ SELECT n.agent_id, n.session_key, n.thread_id, MAX(${seqExpr}, ${atExpr})
16099
+ FROM board_notices n
16100
+ `);
16101
+ db.exec("DROP TABLE board_notices");
16102
+ db.exec("ALTER TABLE board_notices_repair RENAME TO board_notices");
16103
+ db.exec("RELEASE repair_board_notices");
16104
+ } catch (error) {
16105
+ db.exec("ROLLBACK TO repair_board_notices");
16106
+ db.exec("RELEASE repair_board_notices");
16107
+ throw error;
16108
+ }
16109
+ }
15931
16110
  var MIGRATIONS = [
15932
16111
  {
15933
16112
  version: 1,
@@ -17300,6 +17479,30 @@ var MIGRATIONS = [
17300
17479
  artifacts: {
17301
17480
  tables: ["dependency_history_compaction_state"]
17302
17481
  }
17482
+ },
17483
+ {
17484
+ version: 171,
17485
+ name: "agent-wake-and-message-board",
17486
+ up: up171,
17487
+ artifacts: {
17488
+ columns: [
17489
+ { table: "cross_agent_message_wakes", column: "session_key" },
17490
+ { table: "board_threads", column: "last_post_at" },
17491
+ { table: "board_posts", column: "projected_at" },
17492
+ { table: "board_posts", column: "seq" },
17493
+ { table: "board_reads", column: "last_read_post_seq" },
17494
+ { table: "board_notices", column: "notified_post_seq" }
17495
+ ],
17496
+ tables: [
17497
+ "cross_agent_message_wakes",
17498
+ "board_topics",
17499
+ "board_threads",
17500
+ "board_thread_tags",
17501
+ "board_posts",
17502
+ "board_reads",
17503
+ "board_notices"
17504
+ ]
17505
+ }
17303
17506
  }
17304
17507
  ];
17305
17508
  var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-base",
3
- "version": "0.238.1",
3
+ "version": "0.239.1",
4
4
  "description": "Base class for Signet harness connectors",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "typecheck": "tsc --noEmit"
31
31
  },
32
32
  "dependencies": {
33
- "@signetai/core": "0.238.1",
33
+ "@signetai/core": "0.239.1",
34
34
  "json5": "^2.2.3",
35
35
  "jsonc-parser": "3.3.1"
36
36
  },