@intentface/latch-drizzle 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/schema.d.ts CHANGED
@@ -593,6 +593,23 @@ export declare const runs: import("drizzle-orm/sqlite-core").SQLiteTableWithColu
593
593
  }, {}, {
594
594
  length: number | undefined;
595
595
  }>;
596
+ agentVersion: import("drizzle-orm/sqlite-core").SQLiteColumn<{
597
+ name: "agent_version";
598
+ tableName: "latch_runs";
599
+ dataType: "number";
600
+ columnType: "SQLiteInteger";
601
+ data: number;
602
+ driverParam: number;
603
+ notNull: false;
604
+ hasDefault: false;
605
+ isPrimaryKey: false;
606
+ isAutoincrement: false;
607
+ hasRuntimeDefault: false;
608
+ enumValues: undefined;
609
+ baseColumn: never;
610
+ identity: undefined;
611
+ generated: undefined;
612
+ }, {}, {}>;
596
613
  error: import("drizzle-orm/sqlite-core").SQLiteColumn<{
597
614
  name: "error";
598
615
  tableName: "latch_runs";
@@ -1272,6 +1289,23 @@ export declare const agents: import("drizzle-orm/sqlite-core").SQLiteTableWithCo
1272
1289
  }, {}, {
1273
1290
  length: number | undefined;
1274
1291
  }>;
1292
+ publishedVersion: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1293
+ name: "published_version";
1294
+ tableName: "latch_agents";
1295
+ dataType: "number";
1296
+ columnType: "SQLiteInteger";
1297
+ data: number;
1298
+ driverParam: number;
1299
+ notNull: false;
1300
+ hasDefault: false;
1301
+ isPrimaryKey: false;
1302
+ isAutoincrement: false;
1303
+ hasRuntimeDefault: false;
1304
+ enumValues: undefined;
1305
+ baseColumn: never;
1306
+ identity: undefined;
1307
+ generated: undefined;
1308
+ }, {}, {}>;
1275
1309
  createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1276
1310
  name: "created_at";
1277
1311
  tableName: "latch_agents";
@@ -1309,6 +1343,478 @@ export declare const agents: import("drizzle-orm/sqlite-core").SQLiteTableWithCo
1309
1343
  };
1310
1344
  dialect: "sqlite";
1311
1345
  }>;
1346
+ /**
1347
+ * Append-only history of published agent records — the set of distinct
1348
+ * CONFIGURATIONS this agent has had. One row per publish, and none for a
1349
+ * publish whose content is unchanged, so history stays a list of real changes
1350
+ * rather than of save events.
1351
+ *
1352
+ * The `latch_agents` row is always a copy of the version its `published_version`
1353
+ * names. Rolling back (`activateVersion`) moves that pointer and appends NO
1354
+ * version, so flipping between two configurations cannot inflate history —
1355
+ * which is why WHEN each version was live is recorded separately, in
1356
+ * `latch_agent_activations`.
1357
+ *
1358
+ * Deleting an agent deletes its versions (the store's `remove` cascades).
1359
+ */
1360
+ export declare const agentVersions: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
1361
+ name: "latch_agent_versions";
1362
+ schema: undefined;
1363
+ columns: {
1364
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1365
+ name: "id";
1366
+ tableName: "latch_agent_versions";
1367
+ dataType: "string";
1368
+ columnType: "SQLiteText";
1369
+ data: string;
1370
+ driverParam: string;
1371
+ notNull: true;
1372
+ hasDefault: false;
1373
+ isPrimaryKey: true;
1374
+ isAutoincrement: false;
1375
+ hasRuntimeDefault: false;
1376
+ enumValues: [string, ...string[]];
1377
+ baseColumn: never;
1378
+ identity: undefined;
1379
+ generated: undefined;
1380
+ }, {}, {
1381
+ length: number | undefined;
1382
+ }>;
1383
+ owner: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1384
+ name: "owner";
1385
+ tableName: "latch_agent_versions";
1386
+ dataType: "string";
1387
+ columnType: "SQLiteText";
1388
+ data: string;
1389
+ driverParam: string;
1390
+ notNull: true;
1391
+ hasDefault: false;
1392
+ isPrimaryKey: false;
1393
+ isAutoincrement: false;
1394
+ hasRuntimeDefault: false;
1395
+ enumValues: [string, ...string[]];
1396
+ baseColumn: never;
1397
+ identity: undefined;
1398
+ generated: undefined;
1399
+ }, {}, {
1400
+ length: number | undefined;
1401
+ }>;
1402
+ name: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1403
+ name: "name";
1404
+ tableName: "latch_agent_versions";
1405
+ dataType: "string";
1406
+ columnType: "SQLiteText";
1407
+ data: string;
1408
+ driverParam: string;
1409
+ notNull: true;
1410
+ hasDefault: false;
1411
+ isPrimaryKey: false;
1412
+ isAutoincrement: false;
1413
+ hasRuntimeDefault: false;
1414
+ enumValues: [string, ...string[]];
1415
+ baseColumn: never;
1416
+ identity: undefined;
1417
+ generated: undefined;
1418
+ }, {}, {
1419
+ length: number | undefined;
1420
+ }>;
1421
+ version: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1422
+ name: "version";
1423
+ tableName: "latch_agent_versions";
1424
+ dataType: "number";
1425
+ columnType: "SQLiteInteger";
1426
+ data: number;
1427
+ driverParam: number;
1428
+ notNull: true;
1429
+ hasDefault: false;
1430
+ isPrimaryKey: false;
1431
+ isAutoincrement: false;
1432
+ hasRuntimeDefault: false;
1433
+ enumValues: undefined;
1434
+ baseColumn: never;
1435
+ identity: undefined;
1436
+ generated: undefined;
1437
+ }, {}, {}>;
1438
+ record: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1439
+ name: "record";
1440
+ tableName: "latch_agent_versions";
1441
+ dataType: "json";
1442
+ columnType: "SQLiteTextJson";
1443
+ data: unknown;
1444
+ driverParam: string;
1445
+ notNull: true;
1446
+ hasDefault: false;
1447
+ isPrimaryKey: false;
1448
+ isAutoincrement: false;
1449
+ hasRuntimeDefault: false;
1450
+ enumValues: undefined;
1451
+ baseColumn: never;
1452
+ identity: undefined;
1453
+ generated: undefined;
1454
+ }, {}, {}>;
1455
+ author: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1456
+ name: "author";
1457
+ tableName: "latch_agent_versions";
1458
+ dataType: "string";
1459
+ columnType: "SQLiteText";
1460
+ data: string;
1461
+ driverParam: string;
1462
+ notNull: false;
1463
+ hasDefault: false;
1464
+ isPrimaryKey: false;
1465
+ isAutoincrement: false;
1466
+ hasRuntimeDefault: false;
1467
+ enumValues: [string, ...string[]];
1468
+ baseColumn: never;
1469
+ identity: undefined;
1470
+ generated: undefined;
1471
+ }, {}, {
1472
+ length: number | undefined;
1473
+ }>;
1474
+ source: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1475
+ name: "source";
1476
+ tableName: "latch_agent_versions";
1477
+ dataType: "string";
1478
+ columnType: "SQLiteText";
1479
+ data: string;
1480
+ driverParam: string;
1481
+ notNull: false;
1482
+ hasDefault: false;
1483
+ isPrimaryKey: false;
1484
+ isAutoincrement: false;
1485
+ hasRuntimeDefault: false;
1486
+ enumValues: [string, ...string[]];
1487
+ baseColumn: never;
1488
+ identity: undefined;
1489
+ generated: undefined;
1490
+ }, {}, {
1491
+ length: number | undefined;
1492
+ }>;
1493
+ changedFields: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1494
+ name: "changed_fields";
1495
+ tableName: "latch_agent_versions";
1496
+ dataType: "json";
1497
+ columnType: "SQLiteTextJson";
1498
+ data: unknown;
1499
+ driverParam: string;
1500
+ notNull: false;
1501
+ hasDefault: false;
1502
+ isPrimaryKey: false;
1503
+ isAutoincrement: false;
1504
+ hasRuntimeDefault: false;
1505
+ enumValues: undefined;
1506
+ baseColumn: never;
1507
+ identity: undefined;
1508
+ generated: undefined;
1509
+ }, {}, {}>;
1510
+ changeMessage: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1511
+ name: "change_message";
1512
+ tableName: "latch_agent_versions";
1513
+ dataType: "string";
1514
+ columnType: "SQLiteText";
1515
+ data: string;
1516
+ driverParam: string;
1517
+ notNull: false;
1518
+ hasDefault: false;
1519
+ isPrimaryKey: false;
1520
+ isAutoincrement: false;
1521
+ hasRuntimeDefault: false;
1522
+ enumValues: [string, ...string[]];
1523
+ baseColumn: never;
1524
+ identity: undefined;
1525
+ generated: undefined;
1526
+ }, {}, {
1527
+ length: number | undefined;
1528
+ }>;
1529
+ createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1530
+ name: "created_at";
1531
+ tableName: "latch_agent_versions";
1532
+ dataType: "number";
1533
+ columnType: "SQLiteInteger";
1534
+ data: number;
1535
+ driverParam: number;
1536
+ notNull: true;
1537
+ hasDefault: false;
1538
+ isPrimaryKey: false;
1539
+ isAutoincrement: false;
1540
+ hasRuntimeDefault: false;
1541
+ enumValues: undefined;
1542
+ baseColumn: never;
1543
+ identity: undefined;
1544
+ generated: undefined;
1545
+ }, {}, {}>;
1546
+ };
1547
+ dialect: "sqlite";
1548
+ }>;
1549
+ /**
1550
+ * Who made which version live, and when — the publish timeline.
1551
+ *
1552
+ * `latch_agent_versions` is the set of distinct CONFIGURATIONS; activating an
1553
+ * existing version moves a pointer and appends no version, so without this table
1554
+ * a rollback would leave no trace of itself. One row per publish AND per
1555
+ * activation, so the two together answer both "what did this agent look like"
1556
+ * and "what was it running on Tuesday".
1557
+ */
1558
+ export declare const agentActivations: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
1559
+ name: "latch_agent_activations";
1560
+ schema: undefined;
1561
+ columns: {
1562
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1563
+ name: "id";
1564
+ tableName: "latch_agent_activations";
1565
+ dataType: "string";
1566
+ columnType: "SQLiteText";
1567
+ data: string;
1568
+ driverParam: string;
1569
+ notNull: true;
1570
+ hasDefault: false;
1571
+ isPrimaryKey: true;
1572
+ isAutoincrement: false;
1573
+ hasRuntimeDefault: false;
1574
+ enumValues: [string, ...string[]];
1575
+ baseColumn: never;
1576
+ identity: undefined;
1577
+ generated: undefined;
1578
+ }, {}, {
1579
+ length: number | undefined;
1580
+ }>;
1581
+ owner: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1582
+ name: "owner";
1583
+ tableName: "latch_agent_activations";
1584
+ dataType: "string";
1585
+ columnType: "SQLiteText";
1586
+ data: string;
1587
+ driverParam: string;
1588
+ notNull: true;
1589
+ hasDefault: false;
1590
+ isPrimaryKey: false;
1591
+ isAutoincrement: false;
1592
+ hasRuntimeDefault: false;
1593
+ enumValues: [string, ...string[]];
1594
+ baseColumn: never;
1595
+ identity: undefined;
1596
+ generated: undefined;
1597
+ }, {}, {
1598
+ length: number | undefined;
1599
+ }>;
1600
+ name: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1601
+ name: "name";
1602
+ tableName: "latch_agent_activations";
1603
+ dataType: "string";
1604
+ columnType: "SQLiteText";
1605
+ data: string;
1606
+ driverParam: string;
1607
+ notNull: true;
1608
+ hasDefault: false;
1609
+ isPrimaryKey: false;
1610
+ isAutoincrement: false;
1611
+ hasRuntimeDefault: false;
1612
+ enumValues: [string, ...string[]];
1613
+ baseColumn: never;
1614
+ identity: undefined;
1615
+ generated: undefined;
1616
+ }, {}, {
1617
+ length: number | undefined;
1618
+ }>;
1619
+ version: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1620
+ name: "version";
1621
+ tableName: "latch_agent_activations";
1622
+ dataType: "number";
1623
+ columnType: "SQLiteInteger";
1624
+ data: number;
1625
+ driverParam: number;
1626
+ notNull: true;
1627
+ hasDefault: false;
1628
+ isPrimaryKey: false;
1629
+ isAutoincrement: false;
1630
+ hasRuntimeDefault: false;
1631
+ enumValues: undefined;
1632
+ baseColumn: never;
1633
+ identity: undefined;
1634
+ generated: undefined;
1635
+ }, {}, {}>;
1636
+ actor: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1637
+ name: "actor";
1638
+ tableName: "latch_agent_activations";
1639
+ dataType: "string";
1640
+ columnType: "SQLiteText";
1641
+ data: string;
1642
+ driverParam: string;
1643
+ notNull: false;
1644
+ hasDefault: false;
1645
+ isPrimaryKey: false;
1646
+ isAutoincrement: false;
1647
+ hasRuntimeDefault: false;
1648
+ enumValues: [string, ...string[]];
1649
+ baseColumn: never;
1650
+ identity: undefined;
1651
+ generated: undefined;
1652
+ }, {}, {
1653
+ length: number | undefined;
1654
+ }>;
1655
+ source: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1656
+ name: "source";
1657
+ tableName: "latch_agent_activations";
1658
+ dataType: "string";
1659
+ columnType: "SQLiteText";
1660
+ data: string;
1661
+ driverParam: string;
1662
+ notNull: false;
1663
+ hasDefault: false;
1664
+ isPrimaryKey: false;
1665
+ isAutoincrement: false;
1666
+ hasRuntimeDefault: false;
1667
+ enumValues: [string, ...string[]];
1668
+ baseColumn: never;
1669
+ identity: undefined;
1670
+ generated: undefined;
1671
+ }, {}, {
1672
+ length: number | undefined;
1673
+ }>;
1674
+ createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1675
+ name: "created_at";
1676
+ tableName: "latch_agent_activations";
1677
+ dataType: "number";
1678
+ columnType: "SQLiteInteger";
1679
+ data: number;
1680
+ driverParam: number;
1681
+ notNull: true;
1682
+ hasDefault: false;
1683
+ isPrimaryKey: false;
1684
+ isAutoincrement: false;
1685
+ hasRuntimeDefault: false;
1686
+ enumValues: undefined;
1687
+ baseColumn: never;
1688
+ identity: undefined;
1689
+ generated: undefined;
1690
+ }, {}, {}>;
1691
+ };
1692
+ dialect: "sqlite";
1693
+ }>;
1694
+ /**
1695
+ * One unpublished working copy per (agent, editor).
1696
+ *
1697
+ * Deliberately PER EDITOR, not per agent: `owner` is an isolation boundary a
1698
+ * whole org shares, so a single draft would let two admins silently overwrite
1699
+ * each other's half-written prompt. Drafts never affect a running agent — the
1700
+ * live record is `latch_agents`, and a draft becomes live only by being
1701
+ * published, which is what `base_version` guards.
1702
+ */
1703
+ export declare const agentDrafts: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
1704
+ name: "latch_agent_drafts";
1705
+ schema: undefined;
1706
+ columns: {
1707
+ owner: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1708
+ name: "owner";
1709
+ tableName: "latch_agent_drafts";
1710
+ dataType: "string";
1711
+ columnType: "SQLiteText";
1712
+ data: string;
1713
+ driverParam: string;
1714
+ notNull: true;
1715
+ hasDefault: false;
1716
+ isPrimaryKey: false;
1717
+ isAutoincrement: false;
1718
+ hasRuntimeDefault: false;
1719
+ enumValues: [string, ...string[]];
1720
+ baseColumn: never;
1721
+ identity: undefined;
1722
+ generated: undefined;
1723
+ }, {}, {
1724
+ length: number | undefined;
1725
+ }>;
1726
+ name: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1727
+ name: "name";
1728
+ tableName: "latch_agent_drafts";
1729
+ dataType: "string";
1730
+ columnType: "SQLiteText";
1731
+ data: string;
1732
+ driverParam: string;
1733
+ notNull: true;
1734
+ hasDefault: false;
1735
+ isPrimaryKey: false;
1736
+ isAutoincrement: false;
1737
+ hasRuntimeDefault: false;
1738
+ enumValues: [string, ...string[]];
1739
+ baseColumn: never;
1740
+ identity: undefined;
1741
+ generated: undefined;
1742
+ }, {}, {
1743
+ length: number | undefined;
1744
+ }>;
1745
+ editor: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1746
+ name: "editor";
1747
+ tableName: "latch_agent_drafts";
1748
+ dataType: "string";
1749
+ columnType: "SQLiteText";
1750
+ data: string;
1751
+ driverParam: string;
1752
+ notNull: true;
1753
+ hasDefault: false;
1754
+ isPrimaryKey: false;
1755
+ isAutoincrement: false;
1756
+ hasRuntimeDefault: false;
1757
+ enumValues: [string, ...string[]];
1758
+ baseColumn: never;
1759
+ identity: undefined;
1760
+ generated: undefined;
1761
+ }, {}, {
1762
+ length: number | undefined;
1763
+ }>;
1764
+ record: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1765
+ name: "record";
1766
+ tableName: "latch_agent_drafts";
1767
+ dataType: "json";
1768
+ columnType: "SQLiteTextJson";
1769
+ data: unknown;
1770
+ driverParam: string;
1771
+ notNull: true;
1772
+ hasDefault: false;
1773
+ isPrimaryKey: false;
1774
+ isAutoincrement: false;
1775
+ hasRuntimeDefault: false;
1776
+ enumValues: undefined;
1777
+ baseColumn: never;
1778
+ identity: undefined;
1779
+ generated: undefined;
1780
+ }, {}, {}>;
1781
+ baseVersion: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1782
+ name: "base_version";
1783
+ tableName: "latch_agent_drafts";
1784
+ dataType: "number";
1785
+ columnType: "SQLiteInteger";
1786
+ data: number;
1787
+ driverParam: number;
1788
+ notNull: false;
1789
+ hasDefault: false;
1790
+ isPrimaryKey: false;
1791
+ isAutoincrement: false;
1792
+ hasRuntimeDefault: false;
1793
+ enumValues: undefined;
1794
+ baseColumn: never;
1795
+ identity: undefined;
1796
+ generated: undefined;
1797
+ }, {}, {}>;
1798
+ updatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1799
+ name: "updated_at";
1800
+ tableName: "latch_agent_drafts";
1801
+ dataType: "number";
1802
+ columnType: "SQLiteInteger";
1803
+ data: number;
1804
+ driverParam: number;
1805
+ notNull: true;
1806
+ hasDefault: false;
1807
+ isPrimaryKey: false;
1808
+ isAutoincrement: false;
1809
+ hasRuntimeDefault: false;
1810
+ enumValues: undefined;
1811
+ baseColumn: never;
1812
+ identity: undefined;
1813
+ generated: undefined;
1814
+ }, {}, {}>;
1815
+ };
1816
+ dialect: "sqlite";
1817
+ }>;
1312
1818
  /**
1313
1819
  * Memory-sweep state, per chat: which messages have been extracted into
1314
1820
  * episodic memory. Lease columns mirror `latch_schedules` (claim/complete,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAWA,mFAAmF;AAEnF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBjB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBpB,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;;;;;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;;;;;;;;;;;;;;EAuB5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWvB,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAczB,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BrB,CAAC"}
package/dist/schema.js CHANGED
@@ -58,6 +58,9 @@ export const runs = sqliteTable("latch_runs", {
58
58
  /** Opaque fingerprint of the sorted tool names this turn sent (see
59
59
  * `toolsetHash`) — detects toolset churn. */
60
60
  toolsHash: text("tools_hash"),
61
+ /** The agent-record version (`latch_agent_versions.version`) this turn ran.
62
+ * NULL for code-declared agents, which have no stored record. */
63
+ agentVersion: integer("agent_version"),
61
64
  error: text("error"),
62
65
  startedAt: integer("started_at").notNull(),
63
66
  endedAt: integer("ended_at"),
@@ -121,9 +124,103 @@ export const agents = sqliteTable("latch_agents", {
121
124
  /** NULL=default, 0=unlimited, N=cap (AgentRecord["maxSteps"]). */
122
125
  maxSteps: integer("max_steps"),
123
126
  scope: text("scope").notNull(),
127
+ /** Which `latch_agent_versions.version` this live row is a copy of. */
128
+ publishedVersion: integer("published_version"),
124
129
  createdAt: integer("created_at").notNull(),
125
130
  updatedAt: integer("updated_at").notNull(),
126
131
  }, (t) => [uniqueIndex("latch_agents_owner_name").on(t.owner, t.name)]);
132
+ /**
133
+ * Append-only history of published agent records — the set of distinct
134
+ * CONFIGURATIONS this agent has had. One row per publish, and none for a
135
+ * publish whose content is unchanged, so history stays a list of real changes
136
+ * rather than of save events.
137
+ *
138
+ * The `latch_agents` row is always a copy of the version its `published_version`
139
+ * names. Rolling back (`activateVersion`) moves that pointer and appends NO
140
+ * version, so flipping between two configurations cannot inflate history —
141
+ * which is why WHEN each version was live is recorded separately, in
142
+ * `latch_agent_activations`.
143
+ *
144
+ * Deleting an agent deletes its versions (the store's `remove` cascades).
145
+ */
146
+ export const agentVersions = sqliteTable("latch_agent_versions", {
147
+ id: text("id").primaryKey(),
148
+ /** Same opaque ownership key as `latch_agents.owner`. */
149
+ owner: text("owner").notNull(),
150
+ name: text("name").notNull(),
151
+ /** Monotonic per (owner, name), from 1. */
152
+ version: integer("version").notNull(),
153
+ /** The full normalized `AgentRecord` as published. */
154
+ record: text("record", { mode: "json" }).notNull(),
155
+ /** Host-supplied publisher id; NULL for the migration backfill. */
156
+ author: text("author"),
157
+ /** 'editor' | 'builder-agent' | 'api' | 'backfill'. */
158
+ source: text("source"),
159
+ /**
160
+ * string[] — top-level record fields that differ from the PREVIOUS version,
161
+ * computed at write time. NULL for v1 (nothing to differ from). Denormalized
162
+ * so a history list can say "instructions, model" without loading two
163
+ * snapshots and diffing them.
164
+ */
165
+ changedFields: text("changed_fields", { mode: "json" }),
166
+ /** Optional one-line note from whoever published. */
167
+ changeMessage: text("change_message"),
168
+ createdAt: integer("created_at").notNull(),
169
+ }, (t) => [
170
+ // Backstops the max(version)+1 race: a losing concurrent publish retries.
171
+ uniqueIndex("latch_agent_versions_owner_name_version").on(t.owner, t.name, t.version),
172
+ index("latch_agent_versions_owner_name_idx").on(t.owner, t.name),
173
+ ]);
174
+ /**
175
+ * Who made which version live, and when — the publish timeline.
176
+ *
177
+ * `latch_agent_versions` is the set of distinct CONFIGURATIONS; activating an
178
+ * existing version moves a pointer and appends no version, so without this table
179
+ * a rollback would leave no trace of itself. One row per publish AND per
180
+ * activation, so the two together answer both "what did this agent look like"
181
+ * and "what was it running on Tuesday".
182
+ */
183
+ export const agentActivations = sqliteTable("latch_agent_activations", {
184
+ id: text("id").primaryKey(),
185
+ /** Same opaque ownership key as `latch_agents.owner`. */
186
+ owner: text("owner").notNull(),
187
+ name: text("name").notNull(),
188
+ /** The version that became live. */
189
+ version: integer("version").notNull(),
190
+ /** Host-supplied actor id; NULL for the migration backfill. */
191
+ actor: text("actor"),
192
+ /** 'publish' (new content) | 'activate' (rollback) | 'backfill'. */
193
+ source: text("source"),
194
+ createdAt: integer("created_at").notNull(),
195
+ }, (t) => [index("latch_agent_activations_owner_name_idx").on(t.owner, t.name, t.createdAt)]);
196
+ /**
197
+ * One unpublished working copy per (agent, editor).
198
+ *
199
+ * Deliberately PER EDITOR, not per agent: `owner` is an isolation boundary a
200
+ * whole org shares, so a single draft would let two admins silently overwrite
201
+ * each other's half-written prompt. Drafts never affect a running agent — the
202
+ * live record is `latch_agents`, and a draft becomes live only by being
203
+ * published, which is what `base_version` guards.
204
+ */
205
+ export const agentDrafts = sqliteTable("latch_agent_drafts", {
206
+ /** Same opaque ownership key as `latch_agents.owner`. */
207
+ owner: text("owner").notNull(),
208
+ name: text("name").notNull(),
209
+ /** The PERSON editing (see `AgentStoreOptions.editorKey`). */
210
+ editor: text("editor").notNull(),
211
+ /** The full in-progress `AgentRecord`. */
212
+ record: text("record", { mode: "json" }).notNull(),
213
+ /**
214
+ * The version this draft was started from. Compared against the live
215
+ * `published_version` at publish time: if they differ, someone else has
216
+ * published since, and publishing blind would silently revert them.
217
+ */
218
+ baseVersion: integer("base_version"),
219
+ updatedAt: integer("updated_at").notNull(),
220
+ }, (t) => [
221
+ primaryKey({ columns: [t.owner, t.name, t.editor] }),
222
+ index("latch_agent_drafts_owner_idx").on(t.owner),
223
+ ]);
127
224
  /**
128
225
  * Memory-sweep state, per chat: which messages have been extracted into
129
226
  * episodic memory. Lease columns mirror `latch_schedules` (claim/complete,