@axiom-lattice/pg-stores 3.1.0 → 3.1.2

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.
Files changed (47) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/CHANGELOG.md +18 -0
  3. package/dist/index.d.mts +283 -23
  4. package/dist/index.d.ts +283 -23
  5. package/dist/index.js +1867 -224
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +1854 -217
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +3 -3
  10. package/src/__tests__/ChannelBindingStore.test.ts +122 -0
  11. package/src/__tests__/PostgreSQLCapabilityBundleStore.migrations.test.ts +67 -0
  12. package/src/__tests__/PostgreSQLCapabilityBundleStore.test.ts +383 -0
  13. package/src/__tests__/PostgreSQLChannelInstallationStore.test.ts +16 -0
  14. package/src/__tests__/PostgreSQLProjectBotMembershipStore.test.ts +117 -0
  15. package/src/__tests__/PostgreSQLProjectMembershipStore.test.ts +235 -0
  16. package/src/__tests__/PostgreSQLProjectRoomMessageStore.test.ts +103 -0
  17. package/src/__tests__/PostgreSQLProjectRoomStore.migrations.test.ts +114 -0
  18. package/src/__tests__/PostgreSQLProjectRoomStore.test.ts +48 -0
  19. package/src/__tests__/PostgreSQLTaskStore.integration.test.ts +27 -0
  20. package/src/__tests__/PostgreSQLTaskStore.test.ts +57 -0
  21. package/src/__tests__/PostgreSQLTaskWorkItemStore.integration.test.ts +107 -0
  22. package/src/__tests__/PostgreSQLTaskWorkItemStore.migrations.test.ts +62 -0
  23. package/src/__tests__/PostgreSQLTaskWorkItemStore.test.ts +162 -1
  24. package/src/__tests__/ThreadMessageQueueStore.migrations.test.ts +63 -0
  25. package/src/__tests__/ThreadMessageQueueStore.test.ts +209 -4
  26. package/src/__tests__/add_workspace_project_to_queue.test.ts +15 -0
  27. package/src/__tests__/migration-name-version-compatibility.test.ts +67 -0
  28. package/src/__tests__/task-files.test.ts +4 -3
  29. package/src/createPgStoreConfig.ts +25 -1
  30. package/src/index.ts +13 -0
  31. package/src/migrations/add_trusted_run_context_column.ts +18 -0
  32. package/src/migrations/capability_bundle_migration.ts +20 -0
  33. package/src/migrations/migration.ts +2 -1
  34. package/src/migrations/project_room_migration.ts +128 -0
  35. package/src/migrations/task_migration.ts +15 -0
  36. package/src/migrations/task_work_items_migration.ts +45 -1
  37. package/src/stores/ChannelBindingStore.ts +99 -59
  38. package/src/stores/PostgreSQLCapabilityBundleStore.ts +306 -0
  39. package/src/stores/PostgreSQLChannelInstallationStore.ts +12 -30
  40. package/src/stores/PostgreSQLProjectBotMembershipStore.ts +199 -0
  41. package/src/stores/PostgreSQLProjectMembershipStore.ts +140 -0
  42. package/src/stores/PostgreSQLProjectRoomMessageStore.ts +177 -0
  43. package/src/stores/PostgreSQLProjectRoomStore.ts +57 -0
  44. package/src/stores/PostgreSQLProjectStore.ts +230 -50
  45. package/src/stores/PostgreSQLTaskStore.ts +89 -3
  46. package/src/stores/PostgreSQLTaskWorkItemStore.ts +198 -8
  47. package/src/stores/ThreadMessageQueueStore.ts +130 -32
@@ -1,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/pg-stores@3.1.0 build /home/runner/work/agentic/agentic/packages/pg-stores
2
+ > @axiom-lattice/pg-stores@3.1.2 build /home/runner/work/agentic/agentic/packages/pg-stores
3
3
  > tsup src/index.ts --format cjs,esm --dts --sourcemap
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,13 +8,13 @@
8
8
  CLI Target: es2020
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 307.76 KB
12
- CJS dist/index.js.map 570.33 KB
13
- CJS ⚡️ Build success in 696ms
14
- ESM dist/index.mjs 300.95 KB
15
- ESM dist/index.mjs.map 570.04 KB
16
- ESM ⚡️ Build success in 717ms
11
+ ESM dist/index.mjs 372.32 KB
12
+ ESM dist/index.mjs.map 692.52 KB
13
+ ESM ⚡️ Build success in 1081ms
14
+ CJS dist/index.js 380.26 KB
15
+ CJS dist/index.js.map 692.90 KB
16
+ CJS ⚡️ Build success in 1137ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 16916ms
19
- DTS dist/index.d.ts 65.28 KB
20
- DTS dist/index.d.mts 65.28 KB
18
+ DTS ⚡️ Build success in 18304ms
19
+ DTS dist/index.d.ts 78.61 KB
20
+ DTS dist/index.d.mts 78.61 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @axiom-lattice/pg-stores
2
2
 
3
+ ## 3.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 08bf26a: update metric builder
8
+ - Updated dependencies [08bf26a]
9
+ - @axiom-lattice/core@4.2.2
10
+ - @axiom-lattice/protocols@4.1.2
11
+
12
+ ## 3.1.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 8db9937: huge enhance
17
+ - Updated dependencies [8db9937]
18
+ - @axiom-lattice/core@4.2.1
19
+ - @axiom-lattice/protocols@4.1.1
20
+
3
21
  ## 3.1.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Pool, PoolConfig, PoolClient } from 'pg';
2
2
  export { Pool, PoolConfig } from 'pg';
3
- import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, DatabaseConfigStore, DatabaseConfigEntry, CreateDatabaseConfigRequest, UpdateDatabaseConfigRequest, ConnectionStore, ConnectionEntry, MetricsServerConfigStore, MetricsServerConfigEntry, CreateMetricsServerConfigRequest, UpdateMetricsServerConfigRequest, McpServerConfigStore, McpServerConfigEntry, CreateMcpServerConfigRequest, UpdateMcpServerConfigRequest, WorkspaceStore, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, ProjectStore, ProjectFilter, Project, CreateProjectRequest, UpdateProjectRequest, UserStore, User, CreateUserRequest, UpdateUserRequest, TenantStore, Tenant, CreateTenantRequest, UpdateTenantRequest, UserTenantLinkStore, UserTenantLink, CreateUserTenantLinkRequest, UpdateUserTenantLinkRequest, WorkflowTrackingStore, CreateWorkflowRunRequest, WorkflowRun, UpdateWorkflowRunRequest, QueryWorkflowRunsOptions, QueryWorkflowRunsResult, CreateRunStepRequest, RunStep, UpdateRunStepRequest, StepType, EvalStore, EvalProject, CreateEvalProjectRequest, EvalSuite, CreateEvalSuiteRequest, EvalCase, CreateEvalCaseRequest, EvalRun, CreateEvalRunRequest, EvalRunResult, EvalProjectReport, BindingRegistry, Binding, CreateBindingInput, ChannelInstallationStore, ChannelInstallation, ChannelInstallationType, CreateChannelInstallationRequest, UpdateChannelInstallationRequest, A2AApiKeyStore, A2AApiKeyRecord, CreateA2AApiKeyInput, A2AApiKeyEntry, AgentWebAppStore, AgentWebApp, CreateAgentWebAppInput, AgentWebAppStorePatch, AgentWebAppUpdateOptions, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType, TaskStore, CreateTaskRequest, TaskItem, TaskListFilter, UpdateTaskRequest, TaskWorkItemStore, CreateWorkItemRequest, TaskWorkItem, CreateWorkItemIfAbsentRequest, TaskWorkItemListFilter, MenuRegistry, MenuItem, CreateMenuItemInput, UpdateMenuItemInput, SharedResourceStore, ShareRecord, CollectionStore, Collection, CreateCollectionRequest, UpdateCollectionRequest, VectorStoreProvider, VectorStoreCreateParams, SkillStore, Skill, CreateSkillRequest } from '@axiom-lattice/protocols';
4
- export { AgentWebApp, AgentWebAppAppearance, AgentWebAppFeatures, AgentWebAppScope, AgentWebAppStatus, AgentWebAppStore, Assistant, AssistantStore, Binding, BindingRegistry, ChannelInstallation, ChannelInstallationStore, ConnectionEntry, ConnectionStore, CreateAgentWebAppInput, CreateAssistantRequest, CreateBindingInput, CreateChannelInstallationRequest, CreateDatabaseConfigRequest, CreateEvalCaseRequest, CreateEvalProjectRequest, CreateEvalRunRequest, CreateEvalSuiteRequest, CreateMcpServerConfigRequest, CreateMenuItemInput, CreateMetricsServerConfigRequest, CreateProjectRequest, CreateRunStepRequest, CreateShareRequest, CreateSkillRequest, CreateTenantRequest, CreateThreadRequest, CreateUserRequest, CreateUserTenantLinkRequest, CreateWorkflowRunRequest, CreateWorkspaceRequest, DatabaseConfig, DatabaseConfigEntry, DatabaseConfigStore, DatabaseType, EvalCase, EvalProject, EvalProjectReport, EvalRun, EvalRunResult, EvalStore, EvalSuite, LarkChannelInstallationConfig, McpServerConfigEntry, McpServerConfigStore, MenuItem, MenuRegistry, MetricsServerConfig, MetricsServerConfigEntry, MetricsServerConfigStore, Project, ProjectStore, ResourceAddress, RunStep, ScheduleExecutionType, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ShareRecord, ShareResult, ShareVisibility, SharedResourceStore, Skill, SkillStore, StorageType, Tenant, TenantStatus, TenantStore, Thread, ThreadStore, UpdateAgentWebAppInput, UpdateChannelInstallationRequest, UpdateDatabaseConfigRequest, UpdateMcpServerConfigRequest, UpdateMetricsServerConfigRequest, UpdateProjectRequest, UpdateRunStepRequest, UpdateTenantRequest, UpdateUserRequest, UpdateUserTenantLinkRequest, UpdateWorkflowRunRequest, UpdateWorkspaceRequest, User, UserStore, UserTenantLink, UserTenantLinkStore, UserTenantRole, WorkflowRun, WorkflowTrackingStore, Workspace, WorkspaceStore } from '@axiom-lattice/protocols';
5
- import { IMessageQueueStore, AddMessageParams, PendingMessage, ThreadInfo } from '@axiom-lattice/core';
3
+ import { ThreadStore, Thread, CreateThreadRequest, AssistantStore, Assistant, CreateAssistantRequest, DatabaseConfigStore, DatabaseConfigEntry, CreateDatabaseConfigRequest, UpdateDatabaseConfigRequest, ConnectionStore, ConnectionEntry, MetricsServerConfigStore, MetricsServerConfigEntry, CreateMetricsServerConfigRequest, UpdateMetricsServerConfigRequest, McpServerConfigStore, McpServerConfigEntry, CreateMcpServerConfigRequest, UpdateMcpServerConfigRequest, WorkspaceStore, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, ProjectStore, ProjectFilter, Project, CreateProjectRequest, UpdateProjectRequest, UpdateProjectCapabilityBundlesResult, UserStore, User, CreateUserRequest, UpdateUserRequest, TenantStore, Tenant, CreateTenantRequest, UpdateTenantRequest, UserTenantLinkStore, UserTenantLink, CreateUserTenantLinkRequest, UpdateUserTenantLinkRequest, WorkflowTrackingStore, CreateWorkflowRunRequest, WorkflowRun, UpdateWorkflowRunRequest, QueryWorkflowRunsOptions, QueryWorkflowRunsResult, CreateRunStepRequest, RunStep, UpdateRunStepRequest, StepType, EvalStore, EvalProject, CreateEvalProjectRequest, EvalSuite, CreateEvalSuiteRequest, EvalCase, CreateEvalCaseRequest, EvalRun, CreateEvalRunRequest, EvalRunResult, EvalProjectReport, BindingRegistry, Binding, CreateBindingInput, BindingMutablePatch, BindingListParams, ChannelInstallationStore, ChannelInstallation, ChannelInstallationType, CreateChannelInstallationInput, UpdateChannelInstallationRequest, A2AApiKeyStore, A2AApiKeyRecord, CreateA2AApiKeyInput, A2AApiKeyEntry, AgentWebAppStore, AgentWebApp, CreateAgentWebAppInput, AgentWebAppStorePatch, AgentWebAppUpdateOptions, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ScheduleExecutionType, TaskStore, CreateTaskRequest, TaskItem, TaskListFilter, TaskDependentListQuery, UpdateTaskRequest, TaskMutationSnapshot, TaskWorkItemStore, CreateWorkItemRequest, TaskWorkItem, CreateWorkItemIfAbsentRequest, TaskWorkItemListFilter, ProjectLifecycleEventQuery, MenuRegistry, MenuItem, CreateMenuItemInput, UpdateMenuItemInput, SharedResourceStore, ShareRecord, CollectionStore, Collection, CreateCollectionRequest, UpdateCollectionRequest, VectorStoreProvider, VectorStoreCreateParams, CapabilityBundleStore, CapabilityBundle, InternalCreateCapabilityBundleInput, InternalUpdateCapabilityBundleInput, CapabilityBundleDeleteResult, ProjectRoomStore, ProjectRoom, ProjectMembershipStore, ProjectMembership, ProjectHumanRole, ProjectMembershipMutationResult, ProjectBotMembershipStore, ProjectBotMembership, ProjectRoomMessageStore, ProjectRoomMessage, SkillStore, Skill, CreateSkillRequest } from '@axiom-lattice/protocols';
4
+ export { AgentWebApp, AgentWebAppAppearance, AgentWebAppFeatures, AgentWebAppScope, AgentWebAppStatus, AgentWebAppStore, Assistant, AssistantStore, Binding, BindingRegistry, CapabilityBundle, CapabilityBundleStore, ChannelInstallation, ChannelInstallationStore, ConnectionEntry, ConnectionStore, CreateAgentWebAppInput, CreateAssistantRequest, CreateBindingInput, CreateCapabilityBundleInput, CreateChannelInstallationInput, CreateChannelInstallationRequest, CreateDatabaseConfigRequest, CreateEvalCaseRequest, CreateEvalProjectRequest, CreateEvalRunRequest, CreateEvalSuiteRequest, CreateMcpServerConfigRequest, CreateMenuItemInput, CreateMetricsServerConfigRequest, CreateProjectRequest, CreateRunStepRequest, CreateShareRequest, CreateSkillRequest, CreateTenantRequest, CreateThreadRequest, CreateUserRequest, CreateUserTenantLinkRequest, CreateWorkflowRunRequest, CreateWorkspaceRequest, DatabaseConfig, DatabaseConfigEntry, DatabaseConfigStore, DatabaseType, EvalCase, EvalProject, EvalProjectReport, EvalRun, EvalRunResult, EvalStore, EvalSuite, LarkChannelInstallationConfig, McpServerConfigEntry, McpServerConfigStore, MenuItem, MenuRegistry, MetricsServerConfig, MetricsServerConfigEntry, MetricsServerConfigStore, Project, ProjectStore, ResourceAddress, RunStep, ScheduleExecutionType, ScheduleStorage, ScheduledTaskDefinition, ScheduledTaskStatus, ShareRecord, ShareResult, ShareVisibility, SharedResourceStore, Skill, SkillStore, StorageType, Tenant, TenantStatus, TenantStore, Thread, ThreadStore, UpdateAgentWebAppInput, UpdateCapabilityBundleInput, UpdateChannelInstallationRequest, UpdateDatabaseConfigRequest, UpdateMcpServerConfigRequest, UpdateMetricsServerConfigRequest, UpdateProjectRequest, UpdateRunStepRequest, UpdateTenantRequest, UpdateUserRequest, UpdateUserTenantLinkRequest, UpdateWorkflowRunRequest, UpdateWorkspaceRequest, User, UserStore, UserTenantLink, UserTenantLinkStore, UserTenantRole, WorkflowRun, WorkflowTrackingStore, Workspace, WorkspaceStore } from '@axiom-lattice/protocols';
5
+ import { IMessageQueueStore, AddMessageParams, PendingMessage, QueueScope, ThreadInfo } from '@axiom-lattice/core';
6
6
  export { AddMessageParams, PendingMessage, ThreadInfo } from '@axiom-lattice/core';
7
7
  import { PostgresSaver } from '@langchain/langgraph-checkpoint-postgres';
8
8
  import { DocumentInterface } from '@langchain/core/documents';
@@ -620,6 +620,8 @@ declare class PostgreSQLProjectStore implements ProjectStore {
620
620
  * Delete a project by ID
621
621
  */
622
622
  deleteProject(tenantId: string, id: string): Promise<boolean>;
623
+ updateCapabilityBundleIds(tenantId: string, projectId: string, bundleIds: string[], expectedRevisions?: Record<string, string>): Promise<UpdateProjectCapabilityBundlesResult>;
624
+ isCapabilityBundleReferenced(tenantId: string, bundleId: string): Promise<boolean>;
623
625
  }
624
626
 
625
627
  interface PostgreSQLUserStoreOptions {
@@ -913,6 +915,7 @@ declare class ThreadMessageQueueStore implements IMessageQueueStore {
913
915
  * Add message to queue
914
916
  */
915
917
  addMessage(params: AddMessageParams): Promise<PendingMessage>;
918
+ addMessageIfCapacity(params: AddMessageParams, maxSize: number): Promise<boolean>;
916
919
  /**
917
920
  * Add message at head of queue (high priority, e.g., STEER/Command messages)
918
921
  * Uses priority=100 to ensure message is processed first
@@ -921,15 +924,15 @@ declare class ThreadMessageQueueStore implements IMessageQueueStore {
921
924
  /**
922
925
  * Get pending messages for thread
923
926
  */
924
- getPendingMessages(threadId: string): Promise<PendingMessage[]>;
927
+ getPendingMessages(threadId: string, scope?: QueueScope): Promise<PendingMessage[]>;
925
928
  /**
926
929
  * Get processing messages for a thread
927
930
  */
928
- getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
931
+ getProcessingMessages(threadId: string, scope?: QueueScope): Promise<PendingMessage[]>;
929
932
  /**
930
933
  * Get queue size
931
934
  */
932
- getQueueSize(threadId: string): Promise<number>;
935
+ getQueueSize(threadId: string, scope?: QueueScope): Promise<number>;
933
936
  /**
934
937
  * Get all threads with pending or processing messages
935
938
  */
@@ -937,20 +940,20 @@ declare class ThreadMessageQueueStore implements IMessageQueueStore {
937
940
  /**
938
941
  * Remove message
939
942
  */
940
- removeMessage(messageId: string): Promise<boolean>;
943
+ removeMessage(messageId: string, scope?: QueueScope): Promise<boolean>;
941
944
  /**
942
945
  * Clear all messages for thread
943
946
  */
944
- clearMessages(threadId: string): Promise<void>;
947
+ clearMessages(threadId: string, scope?: QueueScope): Promise<void>;
945
948
  /**
946
949
  * Mark message as processing
947
950
  */
948
- markProcessing(messageId: string): Promise<void>;
951
+ markProcessing(messageId: string, customRunConfig?: unknown, scope?: QueueScope): Promise<void>;
949
952
  /**
950
953
  * Reset all processing messages to pending state for a thread
951
954
  * Returns the number of messages reset
952
955
  */
953
- resetProcessingToPending(threadId: string): Promise<number>;
956
+ resetProcessingToPending(threadId: string, scope?: QueueScope): Promise<number>;
954
957
  private rowToMessage;
955
958
  }
956
959
 
@@ -974,18 +977,18 @@ declare class ChannelBindingStore implements BindingRegistry {
974
977
  channelInstallationId: string;
975
978
  tenantId: string;
976
979
  }): Promise<Binding | null>;
977
- create(input: CreateBindingInput): Promise<Binding>;
978
- update(id: string, patch: Partial<Binding>): Promise<Binding>;
979
- delete(id: string): Promise<void>;
980
- list(params: {
981
- channel?: string;
982
- agentId?: string;
980
+ findById(tenantId: string, id: string): Promise<Binding | null>;
981
+ findBySubject(params: {
983
982
  tenantId: string;
984
- channelInstallationId?: string;
985
- limit?: number;
986
- offset?: number;
987
- }): Promise<Binding[]>;
988
- import(bindings: CreateBindingInput[]): Promise<Binding[]>;
983
+ channel: string;
984
+ channelInstallationId: string;
985
+ senderId: string;
986
+ }): Promise<Binding | null>;
987
+ create(input: CreateBindingInput): Promise<Binding>;
988
+ update(tenantId: string, id: string, patch: BindingMutablePatch): Promise<Binding>;
989
+ delete(tenantId: string, id: string): Promise<void>;
990
+ list(params: BindingListParams): Promise<Binding[]>;
991
+ import(tenantId: string, bindings: CreateBindingInput[]): Promise<Binding[]>;
989
992
  export(params: {
990
993
  tenantId: string;
991
994
  }): Promise<Binding[]>;
@@ -1010,7 +1013,7 @@ declare class PostgreSQLChannelInstallationStore implements ChannelInstallationS
1010
1013
  getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
1011
1014
  getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
1012
1015
  getAllInstallations(channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
1013
- createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
1016
+ createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationInput): Promise<ChannelInstallation>;
1014
1017
  updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
1015
1018
  deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
1016
1019
  private ensureInitialized;
@@ -1219,6 +1222,8 @@ declare class PostgreSQLTaskStore implements TaskStore {
1219
1222
  }): Promise<TaskItem>;
1220
1223
  getById(tenantId: string, id: string): Promise<TaskItem | null>;
1221
1224
  list(filter: TaskListFilter): Promise<TaskItem[]>;
1225
+ /** Lists exact project tasks containing a JSON string dependency. */
1226
+ listDependents(query: TaskDependentListQuery): Promise<TaskItem[]>;
1222
1227
  update(tenantId: string, id: string, updates: UpdateTaskRequest): Promise<TaskItem | null>;
1223
1228
  /**
1224
1229
  * Atomically update a task unless its current status is blocked.
@@ -1234,22 +1239,58 @@ declare class PostgreSQLTaskStore implements TaskStore {
1234
1239
  updateIfStatusIn(tenantId: string, id: string, updates: UpdateTaskRequest, expectedStatuses: TaskItem["status"][]): Promise<TaskItem | null>;
1235
1240
  /** Atomically update a task only when status and updatedAt match a read snapshot. */
1236
1241
  updateIfStatusAndUpdatedAt(tenantId: string, id: string, updates: UpdateTaskRequest, expectedStatuses: TaskItem["status"][], expectedUpdatedAt: Date | string): Promise<TaskItem | null>;
1242
+ /** Atomically update only while status, timestamp, owner, and Project scope match. */
1243
+ updateIfSnapshot(tenantId: string, id: string, updates: UpdateTaskRequest, snapshot: TaskMutationSnapshot): Promise<TaskItem | null>;
1237
1244
  /** Atomically update a child only when both child and parent snapshots match. */
1238
1245
  updateIfStatusUpdatedAtAndParentUpdatedAt(tenantId: string, id: string, updates: UpdateTaskRequest, expectedStatuses: TaskItem["status"][], expectedUpdatedAt: Date | string, parentId: string, expectedParentUpdatedAt: Date | string): Promise<TaskItem | null>;
1239
1246
  delete(tenantId: string, id: string): Promise<boolean>;
1247
+ /** Atomically delete only while status, timestamp, owner, and Project scope match. */
1248
+ deleteIfSnapshot(tenantId: string, id: string, snapshot: TaskMutationSnapshot): Promise<boolean>;
1240
1249
  dispose(): Promise<void>;
1241
1250
  private ensureInitialized;
1242
1251
  }
1243
1252
 
1253
+ /** PostgreSQL TaskWorkItem store connection and migration options. */
1254
+ interface PostgreSQLTaskWorkItemStoreOptions {
1255
+ /** External caller-owned pool; central migrations must already be applied. */
1256
+ pool?: Pool;
1257
+ /** Connection configuration for a standalone, store-owned pool. */
1258
+ poolConfig?: string | PoolConfig;
1259
+ /** Whether a standalone store eagerly applies migrations. Defaults to true. */
1260
+ autoMigrate?: boolean;
1261
+ }
1262
+ /** PostgreSQL TaskWorkItem persistence with optional standalone migrations. */
1244
1263
  declare class PostgreSQLTaskWorkItemStore implements TaskWorkItemStore {
1245
1264
  private pool;
1265
+ private migrationManager;
1266
+ private initialized;
1267
+ private ownsPool;
1268
+ private initPromise;
1246
1269
  constructor(pool: Pool);
1270
+ constructor(options: PostgreSQLTaskWorkItemStoreOptions);
1271
+ /** Applies the complete standalone TaskWorkItem migration chain once. */
1272
+ initialize(): Promise<void>;
1273
+ /** Closes the pool only when this store created it from connection configuration. */
1274
+ dispose(): Promise<void>;
1275
+ private startInitialization;
1276
+ private ensureInitialized;
1247
1277
  create(params: CreateWorkItemRequest): Promise<TaskWorkItem>;
1278
+ /** Atomically inserts a work item by selecting one exact task snapshot. */
1279
+ createIfTaskSnapshot(params: CreateWorkItemRequest, snapshot: TaskMutationSnapshot): Promise<TaskWorkItem | null>;
1248
1280
  /** Find an event by its tenant- and task-scoped key without pagination. */
1249
1281
  findByEventKey(tenantId: string, taskId: string, eventKey: string): Promise<TaskWorkItem | null>;
1250
1282
  /** Atomically return an existing event or create it once. */
1251
1283
  createIfAbsentByEventKey(params: CreateWorkItemIfAbsentRequest): Promise<TaskWorkItem>;
1252
1284
  list(filter: TaskWorkItemListFilter): Promise<TaskWorkItem[]>;
1285
+ /** List pending execution results using one bounded PostgreSQL anti-join query. */
1286
+ listPendingExecutionResults(params: {
1287
+ tenantId: string;
1288
+ taskId: string;
1289
+ limit: number;
1290
+ }): Promise<TaskWorkItem[]>;
1291
+ /** Lists canonical project lifecycle events with an exclusive cursor. */
1292
+ listProjectLifecycleEvents(query: ProjectLifecycleEventQuery): Promise<TaskWorkItem[]>;
1293
+ private assertProjectLifecycleEvent;
1253
1294
  private rowToItem;
1254
1295
  }
1255
1296
 
@@ -1360,6 +1401,214 @@ declare function createPGVectorStoreProvider(connectionString: string): {
1360
1401
  pool: Pool;
1361
1402
  };
1362
1403
 
1404
+ /**
1405
+ * Configures PostgreSQL connectivity and migration behavior for capability bundles.
1406
+ *
1407
+ * @remarks
1408
+ * An injected `pool` is externally managed and assumed to have migrations applied.
1409
+ * When `poolConfig` is used, the store owns the pool and runs migrations eagerly
1410
+ * unless `autoMigrate` is false. Call `initialize()` before use in that case.
1411
+ */
1412
+ interface PostgreSQLCapabilityBundleStoreOptions {
1413
+ /** Externally managed PostgreSQL pool. */
1414
+ pool?: Pool;
1415
+ /** Connection string or pool configuration used to create an owned pool. */
1416
+ poolConfig?: string | PoolConfig;
1417
+ /** Whether an owned pool should run migrations during construction. @default true */
1418
+ autoMigrate?: boolean;
1419
+ }
1420
+ /**
1421
+ * Persists tenant-scoped capability bundles in PostgreSQL.
1422
+ *
1423
+ * @example
1424
+ * ```ts
1425
+ * const store = new PostgreSQLCapabilityBundleStore({ poolConfig: connectionString });
1426
+ * await store.initialize();
1427
+ * const bundles = await store.listByTenant("tenant-1");
1428
+ * await store.dispose();
1429
+ * ```
1430
+ *
1431
+ * @remarks
1432
+ * Stores created from `poolConfig` own their pool and must be disposed. Stores
1433
+ * created with an injected pool neither migrate nor close that pool.
1434
+ */
1435
+ declare class PostgreSQLCapabilityBundleStore implements CapabilityBundleStore {
1436
+ private readonly pool;
1437
+ private migrationManager;
1438
+ private initialized;
1439
+ private ownsPool;
1440
+ private initPromise;
1441
+ /**
1442
+ * Creates a PostgreSQL capability bundle store.
1443
+ *
1444
+ * @param options - Pool ownership, connection, and migration options.
1445
+ */
1446
+ constructor(options: PostgreSQLCapabilityBundleStoreOptions);
1447
+ /**
1448
+ * Applies pending migrations for an internally managed pool.
1449
+ *
1450
+ * @returns A shared promise that resolves when initialization completes.
1451
+ */
1452
+ initialize(): Promise<void>;
1453
+ private startInitialization;
1454
+ /**
1455
+ * Closes the pool when it was created by this store.
1456
+ *
1457
+ * @returns A promise that resolves after owned resources are released.
1458
+ */
1459
+ dispose(): Promise<void>;
1460
+ private ready;
1461
+ listByTenant(tenantId: string): Promise<CapabilityBundle[]>;
1462
+ getById(tenantId: string, id: string): Promise<CapabilityBundle | null>;
1463
+ getManyByIds(tenantId: string, ids: string[]): Promise<CapabilityBundle[]>;
1464
+ create(tenantId: string, input: InternalCreateCapabilityBundleInput): Promise<CapabilityBundle>;
1465
+ update(tenantId: string, id: string, input: InternalUpdateCapabilityBundleInput): Promise<CapabilityBundle | {
1466
+ status: "conflict";
1467
+ } | null>;
1468
+ deleteIfUnreferenced(tenantId: string, id: string): Promise<CapabilityBundleDeleteResult>;
1469
+ }
1470
+
1471
+ /** Persists tenant-isolated canonical project main rooms in PostgreSQL. */
1472
+ declare class PostgreSQLProjectRoomStore implements ProjectRoomStore {
1473
+ /** Creates a store using an externally managed pool; the pool is not migrated or closed. */
1474
+ constructor(options: {
1475
+ pool: Pool;
1476
+ });
1477
+ private readonly pool;
1478
+ /** Creates or returns the single persisted main room for a project. */
1479
+ ensureMainRoom(input: {
1480
+ id: string;
1481
+ tenantId: string;
1482
+ workspaceId: string;
1483
+ projectId: string;
1484
+ name: string;
1485
+ }): Promise<ProjectRoom>;
1486
+ /** Finds a tenant-scoped project's main room, or returns null. */
1487
+ getMainRoom(tenantId: string, projectId: string): Promise<ProjectRoom | null>;
1488
+ }
1489
+
1490
+ /** Indicates that a tenant/project/user membership already exists. */
1491
+ declare class DuplicateProjectMembershipError extends Error {
1492
+ constructor();
1493
+ }
1494
+ /** Indicates that a membership ID already exists in the tenant. */
1495
+ declare class ProjectMembershipIdConflictError extends Error {
1496
+ constructor();
1497
+ }
1498
+ /** Persists tenant-isolated human project memberships in PostgreSQL. */
1499
+ declare class PostgreSQLProjectMembershipStore implements ProjectMembershipStore {
1500
+ /** Creates a store using an externally managed pool; the pool is not migrated or closed. */
1501
+ constructor(options: {
1502
+ pool: Pool;
1503
+ });
1504
+ private readonly pool;
1505
+ /** Lists memberships in stable joined-time and ID order. */
1506
+ list(tenantId: string, projectId: string): Promise<ProjectMembership[]>;
1507
+ /** Finds a membership by exact tenant, project, and user identity. */
1508
+ findByUser(tenantId: string, projectId: string, userId: string): Promise<ProjectMembership | null>;
1509
+ /** Inserts a membership and maps database uniqueness errors to stable typed errors. */
1510
+ create(input: Omit<ProjectMembership, "joinedAt" | "updatedAt">): Promise<ProjectMembership>;
1511
+ /** Atomically creates the first active owner while serializing the project scope. */
1512
+ createInitialOwner(input: Omit<ProjectMembership, "role" | "status" | "joinedAt" | "updatedAt">): Promise<{
1513
+ kind: "created" | "existing";
1514
+ membership: ProjectMembership;
1515
+ } | {
1516
+ kind: "already_initialized";
1517
+ }>;
1518
+ /** Updates a role under a project lock with exact timestamp and owner safeguards. */
1519
+ updateRole(input: {
1520
+ tenantId: string;
1521
+ id: string;
1522
+ role: ProjectHumanRole;
1523
+ expectedUpdatedAt: Date;
1524
+ }): Promise<ProjectMembershipMutationResult>;
1525
+ /** Marks a membership removed under a project lock with exact timestamp and owner safeguards. */
1526
+ remove(input: {
1527
+ tenantId: string;
1528
+ id: string;
1529
+ expectedUpdatedAt: Date;
1530
+ }): Promise<ProjectMembershipMutationResult>;
1531
+ private mutate;
1532
+ }
1533
+
1534
+ type ConstraintConflict = "coordinator_conflict" | "mention_conflict";
1535
+ /** Indicates that a new bot membership ID already exists in the tenant. */
1536
+ declare class ProjectBotMembershipIdConflictError extends Error {
1537
+ /** Creates an accurate tenant-scoped membership ID collision error. */
1538
+ constructor(tenantId: string, id: string);
1539
+ }
1540
+ /** Persists tenant-isolated project bot roster memberships in PostgreSQL. */
1541
+ declare class PostgreSQLProjectBotMembershipStore implements ProjectBotMembershipStore {
1542
+ /** Creates a store using an externally managed shared pool. */
1543
+ constructor(options: {
1544
+ pool: Pool;
1545
+ });
1546
+ private readonly pool;
1547
+ /** Lists retained memberships in stable join order. */
1548
+ list(tenantId: string, projectId: string): Promise<ProjectBotMembership[]>;
1549
+ /** Finds a membership by tenant-scoped ID. */
1550
+ findById(tenantId: string, id: string): Promise<ProjectBotMembership | null>;
1551
+ /** Finds an assistant's durable membership in a tenant-scoped project. */
1552
+ findByAssistant(tenantId: string, projectId: string, assistantId: string): Promise<ProjectBotMembership | null>;
1553
+ /** Inserts a new membership or reactivates the assistant's durable membership atomically. */
1554
+ save(input: Omit<ProjectBotMembership, "joinedAt" | "updatedAt">): Promise<{
1555
+ kind: "created" | "updated" | "reactivated";
1556
+ membership: ProjectBotMembership;
1557
+ } | {
1558
+ kind: ConstraintConflict;
1559
+ }>;
1560
+ /** Applies a mutable-field patch with project serialization and millisecond-safe optimistic concurrency. */
1561
+ update(input: {
1562
+ tenantId: string;
1563
+ id: string;
1564
+ patch: Partial<Pick<ProjectBotMembership, "role" | "title" | "responsibility" | "mentionName" | "status">>;
1565
+ expectedUpdatedAt: Date;
1566
+ }): Promise<{
1567
+ kind: "updated";
1568
+ membership: ProjectBotMembership;
1569
+ } | {
1570
+ kind: "not_found" | "conflict" | ConstraintConflict;
1571
+ }>;
1572
+ }
1573
+
1574
+ /** Indicates that a tenant-scoped room message ID already exists. */
1575
+ declare class ProjectRoomMessageIdConflictError extends Error {
1576
+ /** Creates an accurate tenant-scoped message ID collision error. */
1577
+ constructor(tenantId: string, id: string);
1578
+ }
1579
+ /** Indicates that ordinary creation reused a room-scoped idempotency key. */
1580
+ declare class DuplicateProjectRoomMessageIdempotencyKeyError extends Error {
1581
+ /** Creates an accurate tenant and room-scoped idempotency collision error. */
1582
+ constructor(tenantId: string, roomId: string, idempotencyKey: string);
1583
+ }
1584
+ /** Persists tenant-isolated project room messages in PostgreSQL. */
1585
+ declare class PostgreSQLProjectRoomMessageStore implements ProjectRoomMessageStore {
1586
+ /** Creates a store using an externally managed shared pool. */
1587
+ constructor(options: {
1588
+ pool: Pool;
1589
+ });
1590
+ private readonly pool;
1591
+ /** Creates a room message and maps known uniqueness failures to typed errors. */
1592
+ create(input: Omit<ProjectRoomMessage, "createdAt">): Promise<ProjectRoomMessage>;
1593
+ /** Atomically creates or returns the canonical message for a room-scoped idempotency key. */
1594
+ createIdempotent(input: Omit<ProjectRoomMessage, "createdAt"> & {
1595
+ idempotencyKey: string;
1596
+ }): Promise<ProjectRoomMessage>;
1597
+ /** Lists messages newest first using an exclusive stable cursor and a clamped limit. */
1598
+ list(input: {
1599
+ tenantId: string;
1600
+ roomId: string;
1601
+ before?: {
1602
+ createdAt: Date;
1603
+ id: string;
1604
+ };
1605
+ limit: number;
1606
+ }): Promise<ProjectRoomMessage[]>;
1607
+ /** Finds a message by tenant-scoped ID. */
1608
+ findById(tenantId: string, id: string): Promise<ProjectRoomMessage | null>;
1609
+ private parameters;
1610
+ }
1611
+
1363
1612
  declare function createPgStoreConfig(connectionString: string): Promise<{
1364
1613
  workspace: PostgreSQLWorkspaceStore;
1365
1614
  project: PostgreSQLProjectStore;
@@ -1381,10 +1630,15 @@ declare function createPgStoreConfig(connectionString: string): Promise<{
1381
1630
  taskWorkItem: PostgreSQLTaskWorkItemStore;
1382
1631
  a2aApiKey: PostgreSQLA2AApiKeyStore;
1383
1632
  agentWebApp: PostgreSQLAgentWebAppStore;
1633
+ capabilityBundle: PostgreSQLCapabilityBundleStore;
1384
1634
  schedule: PostgreSQLScheduleStorage;
1385
1635
  menu: MenuStore;
1386
1636
  sharedResource: PostgresSharedResourceStore;
1387
1637
  collection: PostgreSQLCollectionStore;
1638
+ projectRoom: PostgreSQLProjectRoomStore;
1639
+ projectMembership: PostgreSQLProjectMembershipStore;
1640
+ projectBotMembership: PostgreSQLProjectBotMembershipStore;
1641
+ projectRoomMessage: PostgreSQLProjectRoomMessageStore;
1388
1642
  vectorStoreProvider: PGVectorStoreProvider;
1389
1643
  checkpoint: PostgresSaver;
1390
1644
  }>;
@@ -1828,6 +2082,9 @@ declare class ChannelIdentityMappingStore {
1828
2082
  private ensureInitialized;
1829
2083
  }
1830
2084
 
2085
+ /** Creates the tenant-scoped capability bundle table. */
2086
+ declare const createCapabilityBundlesTable: Migration;
2087
+
1831
2088
  /**
1832
2089
  * Eval table migrations
1833
2090
  */
@@ -1867,4 +2124,7 @@ declare const addFileContentType: Migration;
1867
2124
 
1868
2125
  declare const createCollectionsTable: Migration;
1869
2126
 
1870
- export { ChannelBindingStore, type ChannelBindingStoreOptions, type ChannelIdentityMapping, ChannelIdentityMappingStore, type ChannelIdentityMappingStoreOptions, type CreateChannelIdentityMappingInput, MenuStore, type MenuStoreOptions, type Migration, MigrationManager, PGVectorStoreProvider, PostgreSQLA2AApiKeyStore, type PostgreSQLA2AApiKeyStoreOptions, PostgreSQLAgentWebAppStore, type PostgreSQLAgentWebAppStoreOptions, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLChannelInstallationStore, type PostgreSQLChannelInstallationStoreOptions, PostgreSQLCollectionStore, type PostgreSQLCollectionStoreOptions, PostgreSQLConnectionStore, PostgreSQLDatabaseConfigStore, type PostgreSQLDatabaseConfigStoreOptions, PostgreSQLEvalStore, type PostgreSQLEvalStoreOptions, PostgreSQLMcpServerConfigStore, type PostgreSQLMcpServerConfigStoreOptions, PostgreSQLMetricsServerConfigStore, type PostgreSQLMetricsServerConfigStoreOptions, PostgreSQLProjectStore, type PostgreSQLProjectStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLSkillStore, type PostgreSQLSkillStoreOptions, PostgreSQLTenantStore, type PostgreSQLTenantStoreOptions, type PostgreSQLThreadMessageQueueStoreOptions, PostgreSQLThreadStore, type PostgreSQLThreadStoreOptions, PostgreSQLUserStore, type PostgreSQLUserStoreOptions, PostgreSQLUserTenantLinkStore, type PostgreSQLUserTenantLinkStoreOptions, PostgreSQLWorkflowTrackingStore, type PostgreSQLWorkflowTrackingStoreOptions, PostgreSQLWorkspaceStore, type PostgreSQLWorkspaceStoreOptions, PostgresSharedResourceStore, type PostgresSharedResourceStoreOptions, ThreadMessageQueueStore, addAssistantTenantId, addEnvToEvalRuns, addFileContentType, addHoldoutToEvalRuns, addInterruptColumnsToEval, addInterruptPolicyToEvalCases, addProjectConfigColumn, addScheduleTenantId, addSkillTenantId, addStepThreadId, addTaskIdToEvalRuns, addThreadTenantId, addWorkflowRunsTenantStatusUpdatedIndex, alterChannelInstallationsTable, changeAssistantPrimaryKey, changeSkillPrimaryKey, changeThreadPrimaryKey, createA2AApiKeysTable, createAgentWebAppsTable, createAssistantsTable, createChannelBindingsTable, createChannelIdentityMappingTables, createChannelInstallationsTable, createCollectionsTable, createDatabaseConfigsTable, createEvalCasesTable, createEvalProjectsTable, createEvalRunResultsTable, createEvalRunsTable, createEvalSuitesTable, createMcpServerConfigsTable, createMenuItemsTable, createMetricsConfigsTable, createPGVectorStoreProvider, createPgStoreConfig, createProjectsTable, createScheduledTasksTable, createSharedResourcesTable, createSkillsTable, createTenantsTable, createThreadMessageQueueTable, createThreadsTable, createUsersTable, createWorkflowTrackingTables, createWorkspacesTable, enforceUniqueEvalProjectName, evalMigrations, mapRowToRunStep, mapRowToWorkflowRun, safeParse };
2127
+ /** Creates the tenant-scoped project room, roster, and message tables. */
2128
+ declare const createProjectRoomTables: Migration;
2129
+
2130
+ export { ChannelBindingStore, type ChannelBindingStoreOptions, type ChannelIdentityMapping, ChannelIdentityMappingStore, type ChannelIdentityMappingStoreOptions, type CreateChannelIdentityMappingInput, DuplicateProjectMembershipError, DuplicateProjectRoomMessageIdempotencyKeyError, MenuStore, type MenuStoreOptions, type Migration, MigrationManager, PGVectorStoreProvider, PostgreSQLA2AApiKeyStore, type PostgreSQLA2AApiKeyStoreOptions, PostgreSQLAgentWebAppStore, type PostgreSQLAgentWebAppStoreOptions, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLCapabilityBundleStore, type PostgreSQLCapabilityBundleStoreOptions, PostgreSQLChannelInstallationStore, type PostgreSQLChannelInstallationStoreOptions, PostgreSQLCollectionStore, type PostgreSQLCollectionStoreOptions, PostgreSQLConnectionStore, PostgreSQLDatabaseConfigStore, type PostgreSQLDatabaseConfigStoreOptions, PostgreSQLEvalStore, type PostgreSQLEvalStoreOptions, PostgreSQLMcpServerConfigStore, type PostgreSQLMcpServerConfigStoreOptions, PostgreSQLMetricsServerConfigStore, type PostgreSQLMetricsServerConfigStoreOptions, PostgreSQLProjectBotMembershipStore, PostgreSQLProjectMembershipStore, PostgreSQLProjectRoomMessageStore, PostgreSQLProjectRoomStore, PostgreSQLProjectStore, type PostgreSQLProjectStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLSkillStore, type PostgreSQLSkillStoreOptions, PostgreSQLTaskWorkItemStore, type PostgreSQLTaskWorkItemStoreOptions, PostgreSQLTenantStore, type PostgreSQLTenantStoreOptions, type PostgreSQLThreadMessageQueueStoreOptions, PostgreSQLThreadStore, type PostgreSQLThreadStoreOptions, PostgreSQLUserStore, type PostgreSQLUserStoreOptions, PostgreSQLUserTenantLinkStore, type PostgreSQLUserTenantLinkStoreOptions, PostgreSQLWorkflowTrackingStore, type PostgreSQLWorkflowTrackingStoreOptions, PostgreSQLWorkspaceStore, type PostgreSQLWorkspaceStoreOptions, PostgresSharedResourceStore, type PostgresSharedResourceStoreOptions, ProjectBotMembershipIdConflictError, ProjectMembershipIdConflictError, ProjectRoomMessageIdConflictError, ThreadMessageQueueStore, addAssistantTenantId, addEnvToEvalRuns, addFileContentType, addHoldoutToEvalRuns, addInterruptColumnsToEval, addInterruptPolicyToEvalCases, addProjectConfigColumn, addScheduleTenantId, addSkillTenantId, addStepThreadId, addTaskIdToEvalRuns, addThreadTenantId, addWorkflowRunsTenantStatusUpdatedIndex, alterChannelInstallationsTable, changeAssistantPrimaryKey, changeSkillPrimaryKey, changeThreadPrimaryKey, createA2AApiKeysTable, createAgentWebAppsTable, createAssistantsTable, createCapabilityBundlesTable, createChannelBindingsTable, createChannelIdentityMappingTables, createChannelInstallationsTable, createCollectionsTable, createDatabaseConfigsTable, createEvalCasesTable, createEvalProjectsTable, createEvalRunResultsTable, createEvalRunsTable, createEvalSuitesTable, createMcpServerConfigsTable, createMenuItemsTable, createMetricsConfigsTable, createPGVectorStoreProvider, createPgStoreConfig, createProjectRoomTables, createProjectsTable, createScheduledTasksTable, createSharedResourcesTable, createSkillsTable, createTenantsTable, createThreadMessageQueueTable, createThreadsTable, createUsersTable, createWorkflowTrackingTables, createWorkspacesTable, enforceUniqueEvalProjectName, evalMigrations, mapRowToRunStep, mapRowToWorkflowRun, safeParse };