@opengeni/db 0.13.4 → 0.14.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.
@@ -933,6 +933,9 @@ var sessions = pgTable2(
933
933
  // Non-default first-party MCP token permissions (manager-style sessions);
934
934
  // null means the fixed worker default set in @opengeni/runtime.
935
935
  firstPartyMcpPermissions: jsonb("first_party_mcp_permissions").$type(),
936
+ // Exact model-visible first-party tool selection. NULL resolves to the
937
+ // fixed minimal default; [] intentionally selects no broad-server tools.
938
+ firstPartyMcpTools: jsonb("first_party_mcp_tools").$type(),
936
939
  // Durable tool-policy origin. NULL is retained for pre-migration rows;
937
940
  // mapSession exposes those rows as `legacy` instead of guessing omitted vs
938
941
  // explicit [].
@@ -1865,14 +1868,15 @@ var sessionSystemUpdates = pgTable2(
1865
1868
  summary: text2("summary").notNull(),
1866
1869
  payload: jsonb("payload").$type().notNull().default({}),
1867
1870
  lineage: jsonb("lineage").$type().notNull().default({}),
1868
- // pending: eligible to start/attach to an inference; deferred: preserved
1869
- // after a failed internal-only inference but dormant until a real prompt or
1870
- // a genuinely new pending update arrives; delivered/cancelled/failed are
1871
- // terminal for that delivery attempt.
1871
+ // pending is visible queue truth; delivered means its exact model-memory
1872
+ // batch was durably claimed. Terminal cancellation/supersession is explicit.
1872
1873
  state: text2("state").notNull().default("pending"),
1873
1874
  deliveredTurnId: uuid2("delivered_turn_id").references(() => sessionTurns.id, {
1874
1875
  onDelete: "set null"
1875
1876
  }),
1877
+ // Migration owns the forward FK to session_history_items, declared later.
1878
+ // Every member of one claimed batch points at the exact model-memory row.
1879
+ deliveredHistoryItemId: uuid2("delivered_history_item_id"),
1876
1880
  deliveredAt: timestamp2("delivered_at", { withTimezone: true }),
1877
1881
  createdAt: timestamp2("created_at", { withTimezone: true }).notNull().defaultNow()
1878
1882
  },
@@ -1887,7 +1891,7 @@ var sessionSystemUpdates = pgTable2(
1887
1891
  ),
1888
1892
  stateValid: check2(
1889
1893
  "system_updates_state_check",
1890
- sql2`${table.state} in ('pending', 'deferred', 'delivered', 'cancelled', 'superseded', 'failed')`
1894
+ sql2`${table.state} in ('pending', 'delivered', 'cancelled', 'superseded', 'failed')`
1891
1895
  ),
1892
1896
  dedupe: uniqueIndex2("session_system_updates_dedupe_uq").on(
1893
1897
  table.workspaceId,
@@ -1899,6 +1903,15 @@ var sessionSystemUpdates = pgTable2(
1899
1903
  table.sessionId,
1900
1904
  table.state,
1901
1905
  table.createdAt
1906
+ ),
1907
+ onePendingSteer: uniqueIndex2("session_system_updates_one_pending_steer_idx").on(table.workspaceId, table.sessionId).where(sql2`${table.kind} = 'agent_steer_instruction' and ${table.state} = 'pending'`),
1908
+ deliveryHistoryValid: check2(
1909
+ "session_system_updates_delivery_history_check",
1910
+ sql2`(
1911
+ (${table.state} = 'delivered' and ${table.deliveredHistoryItemId} is not null)
1912
+ or
1913
+ (${table.state} <> 'delivered' and ${table.deliveredHistoryItemId} is null)
1914
+ )`
1902
1915
  )
1903
1916
  })
1904
1917
  );
@@ -4031,4 +4044,4 @@ export {
4031
4044
  rigChanges,
4032
4045
  schema_exports
4033
4046
  };
4034
- //# sourceMappingURL=chunk-IQOXTFKA.js.map
4047
+ //# sourceMappingURL=chunk-PQKVUWQW.js.map