@axiom-lattice/pg-stores 3.3.12 → 3.4.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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +187 -0
- package/dist/index.d.mts +353 -3
- package/dist/index.d.ts +353 -3
- package/dist/index.js +2323 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2329 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/PGVectorStoreProvider.ts +19 -13
- package/src/__tests__/AgentRunRetention.migrations.test.ts +41 -0
- package/src/__tests__/PostgreSQLAgentRunLedger.test.ts +305 -0
- package/src/__tests__/PostgreSQLAgentRunRetention.test.ts +126 -0
- package/src/__tests__/PostgreSQLAgentRunTaskQueue.test.ts +1375 -0
- package/src/__tests__/PostgreSQLChannelReplyJobStore.test.ts +333 -0
- package/src/__tests__/PostgreSQLCheckpointStorage.deleteAfter.test.ts +473 -0
- package/src/__tests__/PostgreSQLCheckpointStorage.test.ts +538 -0
- package/src/__tests__/PostgreSQLStore.test.ts +173 -0
- package/src/__tests__/PostgreSQLThreadStore.test.ts +80 -0
- package/src/__tests__/ThreadMessageQueueStore.integration.test.ts +21 -0
- package/src/__tests__/ThreadMessageQueueStore.test.ts +8 -3
- package/src/__tests__/createPgStoreConfig.test.ts +38 -0
- package/src/createPgStoreConfig.ts +36 -1
- package/src/index.ts +7 -0
- package/src/migrations/agent_run_base_checkpoint_captured_migration.ts +34 -0
- package/src/migrations/agent_run_capability_revision_migration.ts +24 -0
- package/src/migrations/agent_run_ledger_migration.ts +51 -0
- package/src/migrations/agent_run_project_task_migration.ts +34 -0
- package/src/migrations/agent_run_project_task_running_index_migration.ts +33 -0
- package/src/migrations/agent_run_retention_migration.ts +25 -0
- package/src/migrations/agent_run_rollback_failure_migration.ts +28 -0
- package/src/migrations/agent_run_running_index_source_migration.ts +31 -0
- package/src/migrations/agent_run_task_queue_migration.ts +65 -0
- package/src/migrations/channel_reply_job_migration.ts +55 -0
- package/src/migrations/model_provider_migrations.ts +27 -0
- package/src/migrations/store_migrations.ts +50 -0
- package/src/migrations/thread_migrations.ts +25 -0
- package/src/stores/PostgreSQLAgentRunLedger.ts +1210 -0
- package/src/stores/PostgreSQLChannelReplyJobStore.ts +373 -0
- package/src/stores/PostgreSQLCheckpointStorage.ts +548 -0
- package/src/stores/PostgreSQLModelProviderStore.ts +25 -7
- package/src/stores/PostgreSQLStore.ts +167 -0
- package/src/stores/PostgreSQLThreadStore.ts +49 -10
- package/src/stores/ThreadMessageQueueStore.ts +10 -5
package/dist/index.d.ts
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, 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, UpdateA2AApiKeyInput, A2AApiKeyEntry, OpenAuditStore, OpenAuditQuery, OpenAuditRecord, OpenAuditAppendInput, 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, ProjectRoomReadStateStore, ProjectRoomReadState, UserPushSubscriptionStore, UserPushSubscription, ModelProviderStore, ModelProviderEntry, CreateModelProviderRequest, UpdateModelProviderRequest, ModelProviderStatus, ModelProviderModelEntry, ProviderModelInput, LeaseStore, LeaseRecord, OutboxStore, OutboxEvent, PluginDeploymentStore, PluginDeployment, SkillStore, Skill, CreateSkillRequest } from '@axiom-lattice/protocols';
|
|
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, UpdateA2AApiKeyInput, A2AApiKeyEntry, OpenAuditStore, OpenAuditQuery, OpenAuditRecord, OpenAuditAppendInput, 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, ProjectRoomReadStateStore, ProjectRoomReadState, UserPushSubscriptionStore, UserPushSubscription, ModelProviderStore, ModelProviderEntry, CreateModelProviderRequest, UpdateModelProviderRequest, ModelProviderStatus, ModelProviderModelEntry, ProviderModelInput, LeaseStore, LeaseRecord, OutboxStore, OutboxEvent, PluginDeploymentStore, PluginDeployment, ChannelReplyJobStore, CreateChannelReplyJobInput, ChannelReplyJob, CheckpointStorage, CheckpointMaintenance, ThreadCheckpointStorage, StoreProtocol, StorePutInput, StoreItem, StoreSearchInput, SkillStore, Skill, CreateSkillRequest } from '@axiom-lattice/protocols';
|
|
4
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, ClaimMessagesOptions, ThreadInfo } from '@axiom-lattice/core';
|
|
5
|
+
import { IMessageQueueStore, AddMessageParams, PendingMessage, QueueScope, ClaimMessagesOptions, ThreadInfo, IAgentRunLedger, BeginAgentRunInput, AgentRunRecord, CreatePendingAgentRunInput, ListPendingRunsOptions, ClaimAgentRunInput, DeleteAgentRunExpected, AgentRunStatus, RollbackFailureResult, AgentRunRollbackResult, AgentRunExpiredOutcome, SettleExpiredRunOptions, AgentRunCounts, AgentRunSource, ReapedAgentRun } 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';
|
|
@@ -78,6 +78,10 @@ declare class PostgreSQLThreadStore implements ThreadStore {
|
|
|
78
78
|
* Check if thread exists
|
|
79
79
|
*/
|
|
80
80
|
hasThread(tenantId: string, threadId: string): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* List expired threads across all tenants, oldest expiry first.
|
|
83
|
+
*/
|
|
84
|
+
listExpiredThreads(now: Date, limit: number): Promise<Thread[]>;
|
|
81
85
|
/**
|
|
82
86
|
* Ensure store is initialized
|
|
83
87
|
*/
|
|
@@ -943,6 +947,9 @@ declare class ThreadMessageQueueStore implements IMessageQueueStore {
|
|
|
943
947
|
getQueueSize(threadId: string, scope?: QueueScope): Promise<number>;
|
|
944
948
|
/**
|
|
945
949
|
* Get all threads with pending or processing messages
|
|
950
|
+
*
|
|
951
|
+
* @returns One entry per full scope, with `hasPending` distinguishing
|
|
952
|
+
* processing-only threads (no pending row) from threads with work to drain.
|
|
946
953
|
*/
|
|
947
954
|
getThreadsWithPendingMessages(): Promise<ThreadInfo[]>;
|
|
948
955
|
/**
|
|
@@ -1937,6 +1944,309 @@ declare class PostgreSQLPluginDeploymentStore implements PluginDeploymentStore {
|
|
|
1937
1944
|
delete(tenantId: string, pluginType: string): Promise<boolean>;
|
|
1938
1945
|
}
|
|
1939
1946
|
|
|
1947
|
+
/**
|
|
1948
|
+
* PostgreSQL Agent Run Ledger
|
|
1949
|
+
*
|
|
1950
|
+
* Durable run lifecycle and task queue. `source='run_api'` rows are claimed by
|
|
1951
|
+
* the run-task worker; `source='legacy'` rows preserve the existing
|
|
1952
|
+
* observational ledger/message-queue behavior.
|
|
1953
|
+
*/
|
|
1954
|
+
|
|
1955
|
+
/** Options accepted by {@link PostgreSQLAgentRunLedger}. */
|
|
1956
|
+
interface PostgreSQLAgentRunLedgerOptions {
|
|
1957
|
+
/** Externally managed pool. When supplied, migrations are not run here. */
|
|
1958
|
+
pool?: Pool;
|
|
1959
|
+
/** Connection string or pool config used to create a pool. */
|
|
1960
|
+
poolConfig?: string | PoolConfig;
|
|
1961
|
+
/** Set to `false` to skip running this store's migration automatically. */
|
|
1962
|
+
autoMigrate?: boolean;
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* PostgreSQL implementation of {@link IAgentRunLedger}.
|
|
1966
|
+
*
|
|
1967
|
+
* @remarks
|
|
1968
|
+
* - Run rows are the durable queue for `run_api` and `project_task` work.
|
|
1969
|
+
* Claim is an atomic CAS guarded by the same-thread running rule.
|
|
1970
|
+
* - Legacy `beginRun` keeps the historical reconcile-then-insert behavior and
|
|
1971
|
+
* writes `source='legacy'`.
|
|
1972
|
+
* - `reapExpired` reports expired run-queue rows without mutating them;
|
|
1973
|
+
* `reapLegacyExpired` preserves the supervisor's legacy settle behavior.
|
|
1974
|
+
*/
|
|
1975
|
+
declare class PostgreSQLAgentRunLedger implements IAgentRunLedger {
|
|
1976
|
+
private pool;
|
|
1977
|
+
private ownsPool;
|
|
1978
|
+
private initialized;
|
|
1979
|
+
private initPromise;
|
|
1980
|
+
private migrationManager;
|
|
1981
|
+
/**
|
|
1982
|
+
* @param options An externally managed pool, or a pool config/connection URL.
|
|
1983
|
+
*/
|
|
1984
|
+
constructor(options: PostgreSQLAgentRunLedgerOptions);
|
|
1985
|
+
/** Runs pending migrations once. */
|
|
1986
|
+
initialize(): Promise<void>;
|
|
1987
|
+
/** Ends the pool when this store owns it. */
|
|
1988
|
+
dispose(): Promise<void>;
|
|
1989
|
+
/**
|
|
1990
|
+
* Creates a running legacy run, reconciling any existing running row first.
|
|
1991
|
+
*
|
|
1992
|
+
* @remarks The caller holds the `thread-run` lease, so a surviving `running`
|
|
1993
|
+
* row is stale (its owner can no longer hold the lease) even when its ledger
|
|
1994
|
+
* lease has not expired yet.
|
|
1995
|
+
*/
|
|
1996
|
+
beginRun(input: BeginAgentRunInput): Promise<AgentRunRecord>;
|
|
1997
|
+
/** Creates an unowned pending run-queue row. */
|
|
1998
|
+
createPendingRun(input: CreatePendingAgentRunInput): Promise<AgentRunRecord>;
|
|
1999
|
+
/** Lists claimable run-queue rows, oldest available first. */
|
|
2000
|
+
listPendingRuns(options?: ListPendingRunsOptions): Promise<AgentRunRecord[]>;
|
|
2001
|
+
/** Atomically claims a pending run-queue row. */
|
|
2002
|
+
claimRun(input: ClaimAgentRunInput): Promise<AgentRunRecord | undefined>;
|
|
2003
|
+
/**
|
|
2004
|
+
* Claims under a per-tenant running cap.
|
|
2005
|
+
*
|
|
2006
|
+
* @remarks Serializes claims for one tenant with a transaction-scoped
|
|
2007
|
+
* advisory lock, counts running rows, then runs the same claim statement.
|
|
2008
|
+
* The lock is shared with admission creates so cap checks cannot race.
|
|
2009
|
+
*/
|
|
2010
|
+
private claimRunWithTenantCap;
|
|
2011
|
+
/** Captures the checkpoint a running run-queue row started from. */
|
|
2012
|
+
setBaseCheckpoint(tenantId: string, runId: string, owner: string, baseCheckpointId: string | null): Promise<boolean>;
|
|
2013
|
+
/** Records the resolved capability runtime revision for a running run. */
|
|
2014
|
+
setCapabilityRevision(tenantId: string, runId: string, owner: string, revision: string | null): Promise<boolean>;
|
|
2015
|
+
/** Deletes a run row immediately, optionally guarded by status/owner. */
|
|
2016
|
+
deleteRun(tenantId: string, runId: string, expected?: DeleteAgentRunExpected): Promise<boolean>;
|
|
2017
|
+
/** Deletes terminal rows finished before `cutoffMs`, oldest first. */
|
|
2018
|
+
deleteTerminalBefore(cutoffMs: number, limit: number): Promise<number>;
|
|
2019
|
+
/** Extends a running run's lease when `owner` still holds it. */
|
|
2020
|
+
heartbeatRun(runId: string, owner: string, leaseMs: number): Promise<boolean>;
|
|
2021
|
+
/** Settles a running run when `owner` still holds it. */
|
|
2022
|
+
settleRun(runId: string, owner: string, status: Exclude<AgentRunStatus, "pending" | "running">, error?: string): Promise<boolean>;
|
|
2023
|
+
/** Settles a running run only when no rollback is pending. */
|
|
2024
|
+
settleRunUnlessRollbackRequested(runId: string, owner: string, status: Exclude<AgentRunStatus, "pending" | "running">, error?: string): Promise<boolean>;
|
|
2025
|
+
/** Terminates an uncaptured rollback run with a repair signal. */
|
|
2026
|
+
settleRollbackFailure(tenantId: string, runId: string, error: string): Promise<boolean>;
|
|
2027
|
+
/** Records one bounded rollback failure and optionally converges. */
|
|
2028
|
+
recordRollbackFailure(tenantId: string, runId: string, error: string, maxAttempts: number): Promise<RollbackFailureResult | undefined>;
|
|
2029
|
+
/** Reads a run within a tenant. */
|
|
2030
|
+
getRun(tenantId: string, runId: string): Promise<AgentRunRecord | undefined>;
|
|
2031
|
+
/** Finds the active (pending/running) run for a ProjectTask. */
|
|
2032
|
+
getActiveRunForTask(tenantId: string, taskId: string): Promise<AgentRunRecord | undefined>;
|
|
2033
|
+
/** Lists a thread's runs, newest first (including pending rows). */
|
|
2034
|
+
listRuns(tenantId: string, threadId: string, options?: {
|
|
2035
|
+
limit?: number;
|
|
2036
|
+
offset?: number;
|
|
2037
|
+
}): Promise<AgentRunRecord[]>;
|
|
2038
|
+
/** Finds the thread's running run, if any. */
|
|
2039
|
+
findRunning(tenantId: string, threadId: string): Promise<AgentRunRecord | undefined>;
|
|
2040
|
+
/** Requests cancellation, settling pending/expired rows interrupted. */
|
|
2041
|
+
requestCancel(tenantId: string, runId: string): Promise<"cancelled" | "requested" | "not_found" | "terminal">;
|
|
2042
|
+
/** Deletes a pending run or flags a running run for rollback. */
|
|
2043
|
+
requestRollback(tenantId: string, runId: string): Promise<AgentRunRollbackResult>;
|
|
2044
|
+
/** Atomically reclaims an expired running row without requeueing it. */
|
|
2045
|
+
recoverExpiredRun(runId: string, owner: string, leaseMs: number): Promise<AgentRunRecord | undefined>;
|
|
2046
|
+
/** Atomically requeues or interrupts an expired run-queue row. */
|
|
2047
|
+
settleExpiredRun(runId: string, outcome: AgentRunExpiredOutcome, options?: SettleExpiredRunOptions): Promise<boolean>;
|
|
2048
|
+
/** Counts runs grouped by lifecycle status. */
|
|
2049
|
+
counts(): Promise<AgentRunCounts>;
|
|
2050
|
+
/** Reports expired run-queue rows for the requested sources. */
|
|
2051
|
+
reapExpired(sources?: readonly AgentRunSource[]): Promise<ReapedAgentRun[]>;
|
|
2052
|
+
/** Lists rollback work that still needs a checkpoint rewind. */
|
|
2053
|
+
listRollbackRuns(): Promise<ReapedAgentRun[]>;
|
|
2054
|
+
/** Settles expired legacy rows, preserving the historical supervisor behavior. */
|
|
2055
|
+
reapLegacyExpired(): Promise<ReapedAgentRun[]>;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
/** Options accepted by {@link PostgreSQLChannelReplyJobStore}. */
|
|
2059
|
+
interface PostgreSQLChannelReplyJobStoreOptions {
|
|
2060
|
+
/** Externally managed pool. When supplied, migrations are not run here. */
|
|
2061
|
+
pool?: Pool;
|
|
2062
|
+
/** Connection string or pool config used to create a pool. */
|
|
2063
|
+
poolConfig?: string | PoolConfig;
|
|
2064
|
+
/** Set to `false` to skip running this store's migration automatically. */
|
|
2065
|
+
autoMigrate?: boolean;
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* PostgreSQL {@link ChannelReplyJobStore}.
|
|
2069
|
+
*
|
|
2070
|
+
* @remarks Claims are a single conditional `UPDATE` (CAS) guarded by status,
|
|
2071
|
+
* `available_at`, and lease expiry, so competing replicas cannot both win.
|
|
2072
|
+
* Lease/created/updated/delivered timestamps use the database clock; only the
|
|
2073
|
+
* caller-supplied `availableAt` epoch is stored as-is.
|
|
2074
|
+
*/
|
|
2075
|
+
declare class PostgreSQLChannelReplyJobStore implements ChannelReplyJobStore {
|
|
2076
|
+
private pool;
|
|
2077
|
+
private ownsPool;
|
|
2078
|
+
private initialized;
|
|
2079
|
+
private initPromise;
|
|
2080
|
+
private migrationManager;
|
|
2081
|
+
/** @param options An externally managed pool, or a pool config/connection URL. */
|
|
2082
|
+
constructor(options: PostgreSQLChannelReplyJobStoreOptions);
|
|
2083
|
+
/** Runs pending migrations once. */
|
|
2084
|
+
initialize(): Promise<void>;
|
|
2085
|
+
/** Ends the pool when this store owns it. */
|
|
2086
|
+
dispose(): Promise<void>;
|
|
2087
|
+
/** Creates a pending job with database-clock created/updated timestamps. */
|
|
2088
|
+
create(input: CreateChannelReplyJobInput): Promise<ChannelReplyJob>;
|
|
2089
|
+
/** Reads one job within a tenant scope. */
|
|
2090
|
+
get(tenantId: string, runId: string): Promise<ChannelReplyJob | null>;
|
|
2091
|
+
/** Lists claimable pending jobs that are due at `now`, oldest first. */
|
|
2092
|
+
listPending(now: number, limit?: number): Promise<ChannelReplyJob[]>;
|
|
2093
|
+
/**
|
|
2094
|
+
* Atomically leases a claimable job.
|
|
2095
|
+
*
|
|
2096
|
+
* @param now Accepted for interface symmetry; PostgreSQL uses the database clock.
|
|
2097
|
+
*/
|
|
2098
|
+
claim(tenantId: string, runId: string, owner: string, leaseMs: number, now?: number): Promise<ChannelReplyJob | null>;
|
|
2099
|
+
/**
|
|
2100
|
+
* Marks a job delivered when `owner` still holds the lease.
|
|
2101
|
+
*
|
|
2102
|
+
* @param now Accepted for interface symmetry; PostgreSQL uses the database clock.
|
|
2103
|
+
*/
|
|
2104
|
+
markDelivered(tenantId: string, runId: string, owner: string, outputMessageId?: string | null, now?: number): Promise<ChannelReplyJob | null>;
|
|
2105
|
+
/**
|
|
2106
|
+
* Returns a job to pending with an incremented attempt count.
|
|
2107
|
+
*
|
|
2108
|
+
* @param now Accepted for interface symmetry; PostgreSQL uses the database clock.
|
|
2109
|
+
*/
|
|
2110
|
+
reschedule(tenantId: string, runId: string, owner: string, error: string, availableAt: number, now?: number): Promise<ChannelReplyJob | null>;
|
|
2111
|
+
/**
|
|
2112
|
+
* Marks a job terminally failed when `owner` still holds the lease.
|
|
2113
|
+
*
|
|
2114
|
+
* @param now Accepted for interface symmetry; PostgreSQL uses the database clock.
|
|
2115
|
+
*/
|
|
2116
|
+
markFailed(tenantId: string, runId: string, owner: string, error: string, now?: number): Promise<ChannelReplyJob | null>;
|
|
2117
|
+
/** Deletes one job. Returns whether a row was removed. */
|
|
2118
|
+
delete(tenantId: string, runId: string): Promise<boolean>;
|
|
2119
|
+
/** Deletes terminal jobs whose last update is older than `before`. */
|
|
2120
|
+
deleteTerminalBefore(before: number, limit?: number): Promise<number>;
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
/**
|
|
2124
|
+
* Raised when a checkpoint copy targets a thread that already owns rows.
|
|
2125
|
+
*/
|
|
2126
|
+
declare class CheckpointTargetNotEmptyError extends Error {
|
|
2127
|
+
/** Machine-readable conflict code. */
|
|
2128
|
+
readonly code: "CHECKPOINT_TARGET_NOT_EMPTY";
|
|
2129
|
+
/**
|
|
2130
|
+
* @param threadId - Non-empty target thread id.
|
|
2131
|
+
*/
|
|
2132
|
+
constructor(threadId: string);
|
|
2133
|
+
}
|
|
2134
|
+
/**
|
|
2135
|
+
* Raised when a checkpoint rewind targets a base checkpoint that does not exist.
|
|
2136
|
+
*/
|
|
2137
|
+
declare class CheckpointBaseNotFoundError extends Error {
|
|
2138
|
+
/** Machine-readable failure code. */
|
|
2139
|
+
readonly code: "CHECKPOINT_BASE_NOT_FOUND";
|
|
2140
|
+
/** Thread owning the missing base checkpoint. */
|
|
2141
|
+
readonly threadId: string;
|
|
2142
|
+
/** Base checkpoint id that was not found. */
|
|
2143
|
+
readonly baseCheckpointId: string;
|
|
2144
|
+
/**
|
|
2145
|
+
* @param threadId - Thread owning the missing base checkpoint.
|
|
2146
|
+
* @param baseCheckpointId - Base checkpoint id that was not found.
|
|
2147
|
+
*/
|
|
2148
|
+
constructor(threadId: string, baseCheckpointId: string);
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2151
|
+
* Checkpoint accounting and maintenance over LangGraph's built-in
|
|
2152
|
+
* `PostgresSaver` tables.
|
|
2153
|
+
*
|
|
2154
|
+
* `get` is a read-only aggregate. `copyThread`, `deleteThread`, `deleteAfter`,
|
|
2155
|
+
* and `pruneThread` are the explicit maintenance operations; each runs in one
|
|
2156
|
+
* transaction and touches only the `checkpoints`, `checkpoint_blobs`, and
|
|
2157
|
+
* `checkpoint_writes` tables created by `PostgresSaver.setup()`. No migration
|
|
2158
|
+
* is added.
|
|
2159
|
+
*/
|
|
2160
|
+
declare class PostgreSQLCheckpointStorage implements CheckpointStorage, CheckpointMaintenance {
|
|
2161
|
+
private readonly pool;
|
|
2162
|
+
/**
|
|
2163
|
+
* @param pool - PostgreSQL pool shared with the rest of the store config.
|
|
2164
|
+
*/
|
|
2165
|
+
constructor(pool: Pool);
|
|
2166
|
+
/**
|
|
2167
|
+
* Measure the checkpoint storage used by one thread.
|
|
2168
|
+
*
|
|
2169
|
+
* @param threadId - Thread id whose checkpoint rows should be measured.
|
|
2170
|
+
* @returns Counts and byte sizes grouped by checkpoint storage category.
|
|
2171
|
+
*/
|
|
2172
|
+
get(threadId: string): Promise<ThreadCheckpointStorage>;
|
|
2173
|
+
/**
|
|
2174
|
+
* Copy every checkpoint row from a source thread to an empty target thread.
|
|
2175
|
+
*
|
|
2176
|
+
* @param sourceThreadId - Thread whose rows are copied.
|
|
2177
|
+
* @param targetThreadId - Empty thread that receives the rows.
|
|
2178
|
+
* @returns Resolves when the copy commits; an empty source is a no-op.
|
|
2179
|
+
* @throws {CheckpointTargetNotEmptyError} When the target already owns rows.
|
|
2180
|
+
*/
|
|
2181
|
+
copyThread(sourceThreadId: string, targetThreadId: string): Promise<void>;
|
|
2182
|
+
/**
|
|
2183
|
+
* Retain only the latest N checkpoints per checkpoint namespace.
|
|
2184
|
+
*
|
|
2185
|
+
* @param threadId - Thread whose checkpoint history is pruned.
|
|
2186
|
+
* @param options - Retention options.
|
|
2187
|
+
* @param options.keepLatest - Number of latest checkpoints to retain per namespace.
|
|
2188
|
+
* @returns Counts of deleted checkpoint, blob, and write rows.
|
|
2189
|
+
*/
|
|
2190
|
+
pruneThread(threadId: string, options: {
|
|
2191
|
+
keepLatest: number;
|
|
2192
|
+
}): Promise<{
|
|
2193
|
+
checkpoints: number;
|
|
2194
|
+
blobs: number;
|
|
2195
|
+
writes: number;
|
|
2196
|
+
}>;
|
|
2197
|
+
/**
|
|
2198
|
+
* Delete the checkpoints that descend from a base checkpoint.
|
|
2199
|
+
*
|
|
2200
|
+
* Descendants are discovered by following both same-namespace
|
|
2201
|
+
* `parent_checkpoint_id` edges and cross-namespace `metadata.parents` edges
|
|
2202
|
+
* (LangGraph's `{ "<parent checkpoint_ns>": "<parent checkpoint id>" }` map on
|
|
2203
|
+
* subgraph checkpoints), recursively across every namespace. Out-of-order or
|
|
2204
|
+
* clock-skewed ids do not affect the result. Writes keyed to the base
|
|
2205
|
+
* checkpoint belong to the rolled-back run's first superstep and are deleted
|
|
2206
|
+
* too. Blobs referenced only by deleted checkpoints are removed.
|
|
2207
|
+
*
|
|
2208
|
+
* @param threadId - Thread whose later checkpoint history is deleted.
|
|
2209
|
+
* @param baseCheckpointId - Checkpoint to retain as the new tip, or `null` to
|
|
2210
|
+
* delete every checkpoint for the thread.
|
|
2211
|
+
* @returns Resolves when the deletion commits; no descendants is a no-op.
|
|
2212
|
+
* @throws {RangeError} When `baseCheckpointId` is an empty string.
|
|
2213
|
+
* @throws {CheckpointBaseNotFoundError} When the base checkpoint does not
|
|
2214
|
+
* exist on the thread.
|
|
2215
|
+
*/
|
|
2216
|
+
deleteAfter(threadId: string, baseCheckpointId: string | null): Promise<void>;
|
|
2217
|
+
/**
|
|
2218
|
+
* Delete every checkpoint row for a thread.
|
|
2219
|
+
*
|
|
2220
|
+
* @param threadId - Thread whose checkpoint rows are deleted.
|
|
2221
|
+
* @returns Resolves when the deletion commits.
|
|
2222
|
+
*/
|
|
2223
|
+
deleteThread(threadId: string): Promise<void>;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
/**
|
|
2227
|
+
* PostgreSQL tenant-scoped namespaced key-value store.
|
|
2228
|
+
*
|
|
2229
|
+
* @remarks
|
|
2230
|
+
* - `namespace` is a `TEXT[]`; prefix search compares `namespace[1:n]`.
|
|
2231
|
+
* - `filter` uses JSONB containment (`value @> $filter`).
|
|
2232
|
+
* - `query` is a case-insensitive substring over `value::text`.
|
|
2233
|
+
* - Expired items are excluded from reads/searches and hard-deleted by
|
|
2234
|
+
* {@link deleteExpired}.
|
|
2235
|
+
*/
|
|
2236
|
+
declare class PostgreSQLStore implements StoreProtocol {
|
|
2237
|
+
private readonly pool;
|
|
2238
|
+
/**
|
|
2239
|
+
* @param pool - Pool shared with the rest of the store config.
|
|
2240
|
+
*/
|
|
2241
|
+
constructor(pool: Pool);
|
|
2242
|
+
put(tenantId: string, input: StorePutInput): Promise<StoreItem>;
|
|
2243
|
+
get(tenantId: string, namespace: string[], key: string): Promise<StoreItem | null>;
|
|
2244
|
+
delete(tenantId: string, namespace: string[], key: string): Promise<boolean>;
|
|
2245
|
+
search(tenantId: string, input: StoreSearchInput): Promise<StoreItem[]>;
|
|
2246
|
+
listNamespaces(tenantId: string, prefix?: string[], limit?: number): Promise<string[][]>;
|
|
2247
|
+
deleteExpired(now: Date, limit: number): Promise<number>;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
1940
2250
|
declare function createPgStoreConfig(connectionString: string): Promise<{
|
|
1941
2251
|
workspace: PostgreSQLWorkspaceStore;
|
|
1942
2252
|
project: PostgreSQLProjectStore;
|
|
@@ -1974,8 +2284,12 @@ declare function createPgStoreConfig(connectionString: string): Promise<{
|
|
|
1974
2284
|
lease: PostgreSQLLeaseStore;
|
|
1975
2285
|
outbox: PostgreSQLOutboxStore;
|
|
1976
2286
|
pluginDeployment: PostgreSQLPluginDeploymentStore;
|
|
2287
|
+
agentRun: PostgreSQLAgentRunLedger;
|
|
2288
|
+
channelReplyJob: PostgreSQLChannelReplyJobStore;
|
|
1977
2289
|
vectorStoreProvider: PGVectorStoreProvider;
|
|
1978
2290
|
checkpoint: PostgresSaver;
|
|
2291
|
+
checkpointStorage: PostgreSQLCheckpointStorage;
|
|
2292
|
+
store: PostgreSQLStore;
|
|
1979
2293
|
}>;
|
|
1980
2294
|
|
|
1981
2295
|
/**
|
|
@@ -2136,6 +2450,12 @@ declare class MigrationManager {
|
|
|
2136
2450
|
* Initial migration: Create threads table
|
|
2137
2451
|
*/
|
|
2138
2452
|
declare const createThreadsTable: Migration;
|
|
2453
|
+
/**
|
|
2454
|
+
* Migration: Add per-thread expiry (`expires_at`) for the TTL sweeper.
|
|
2455
|
+
*
|
|
2456
|
+
* A partial index keeps expiry scans cheap while leaving non-TTL threads out.
|
|
2457
|
+
*/
|
|
2458
|
+
declare const addThreadExpiresAt: Migration;
|
|
2139
2459
|
|
|
2140
2460
|
/**
|
|
2141
2461
|
* Thread table tenant isolation migration
|
|
@@ -2481,4 +2801,34 @@ declare const createPluginDeployments: Migration;
|
|
|
2481
2801
|
*/
|
|
2482
2802
|
declare const dropPluginDeploymentAuthToken: Migration;
|
|
2483
2803
|
|
|
2484
|
-
|
|
2804
|
+
/**
|
|
2805
|
+
* Creates the durable agent run ledger.
|
|
2806
|
+
*
|
|
2807
|
+
* @remarks
|
|
2808
|
+
* The partial unique index enforces the ledger invariant: at most one
|
|
2809
|
+
* `running` row per `(tenant_id, thread_id)`.
|
|
2810
|
+
*/
|
|
2811
|
+
declare const createAgentRunLedgerTable: Migration;
|
|
2812
|
+
|
|
2813
|
+
/**
|
|
2814
|
+
* Durable channel reply jobs used by the cross-replica reply dispatcher.
|
|
2815
|
+
*
|
|
2816
|
+
* @remarks Lease-based claims make the row the single source of truth for
|
|
2817
|
+
* "which replica is delivering this run's channel reply". Timestamps are epoch
|
|
2818
|
+
* milliseconds from the database clock.
|
|
2819
|
+
*/
|
|
2820
|
+
declare const createChannelReplyJobsTable: Migration;
|
|
2821
|
+
|
|
2822
|
+
/**
|
|
2823
|
+
* Namespaced KV store migrations.
|
|
2824
|
+
*/
|
|
2825
|
+
|
|
2826
|
+
/**
|
|
2827
|
+
* Migration: create the tenant-scoped namespaced KV store table.
|
|
2828
|
+
*
|
|
2829
|
+
* GIN indexes support namespace prefix and JSONB containment filters; the
|
|
2830
|
+
* partial expiry index supports the TTL sweeper.
|
|
2831
|
+
*/
|
|
2832
|
+
declare const createStoreItemsTable: Migration;
|
|
2833
|
+
|
|
2834
|
+
export { ChannelBindingStore, type ChannelBindingStoreOptions, type ChannelIdentityMapping, ChannelIdentityMappingStore, type ChannelIdentityMappingStoreOptions, CheckpointBaseNotFoundError, CheckpointTargetNotEmptyError, type CreateChannelIdentityMappingInput, DuplicateProjectMembershipError, DuplicateProjectRoomMessageIdempotencyKeyError, MenuStore, type MenuStoreOptions, type Migration, MigrationManager, PGVectorStoreProvider, PostgreSQLA2AApiKeyStore, type PostgreSQLA2AApiKeyStoreOptions, PostgreSQLAgentRunLedger, type PostgreSQLAgentRunLedgerOptions, PostgreSQLAgentWebAppStore, type PostgreSQLAgentWebAppStoreOptions, PostgreSQLAssistantStore, type PostgreSQLAssistantStoreOptions, PostgreSQLCapabilityBundleStore, type PostgreSQLCapabilityBundleStoreOptions, PostgreSQLChannelInstallationStore, type PostgreSQLChannelInstallationStoreOptions, PostgreSQLChannelReplyJobStore, type PostgreSQLChannelReplyJobStoreOptions, PostgreSQLCheckpointStorage, PostgreSQLCollectionStore, type PostgreSQLCollectionStoreOptions, PostgreSQLConnectionStore, PostgreSQLDatabaseConfigStore, type PostgreSQLDatabaseConfigStoreOptions, PostgreSQLEvalStore, type PostgreSQLEvalStoreOptions, PostgreSQLMcpServerConfigStore, type PostgreSQLMcpServerConfigStoreOptions, PostgreSQLMetricsServerConfigStore, type PostgreSQLMetricsServerConfigStoreOptions, PostgreSQLModelProviderStore, type PostgreSQLModelProviderStoreOptions, PostgreSQLOpenAuditStore, type PostgreSQLOpenAuditStoreOptions, PostgreSQLPluginDeploymentStore, PostgreSQLProjectBotMembershipStore, PostgreSQLProjectMembershipStore, PostgreSQLProjectRoomMessageStore, PostgreSQLProjectRoomReadStateStore, PostgreSQLProjectRoomStore, PostgreSQLProjectStore, type PostgreSQLProjectStoreOptions, PostgreSQLScheduleStorage, type PostgreSQLScheduleStorageOptions, PostgreSQLSkillStore, type PostgreSQLSkillStoreOptions, PostgreSQLStore, 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, addMcpAppContentType, addProjectConfigColumn, addScheduleTenantId, addSkillTenantId, addStepThreadId, addTaskIdToEvalRuns, addThreadExpiresAt, addThreadTenantId, addWorkflowRunsTenantStatusUpdatedIndex, alterChannelInstallationsTable, changeAssistantPrimaryKey, changeSkillPrimaryKey, changeThreadPrimaryKey, createA2AApiKeysTable, createAgentRunLedgerTable, createAgentWebAppsTable, createAssistantsTable, createCapabilityBundlesTable, createChannelBindingsTable, createChannelIdentityMappingTables, createChannelInstallationsTable, createChannelReplyJobsTable, createCollectionsTable, createDatabaseConfigsTable, createEvalCasesTable, createEvalProjectsTable, createEvalRunResultsTable, createEvalRunsTable, createEvalSuitesTable, createMcpServerConfigsTable, createMenuItemsTable, createMetricsConfigsTable, createPGVectorStoreProvider, createPgStoreConfig, createPluginDeployments, createProjectRoomReadStates, createProjectRoomTables, createProjectsTable, createScheduledTasksTable, createSharedResourcesTable, createSkillsTable, createStoreItemsTable, createTenantsTable, createThreadMessageQueueTable, createThreadsTable, createUsersTable, createWorkflowTrackingTables, createWorkspacesTable, dropPluginDeploymentAuthToken, enforceUniqueEvalProjectName, evalMigrations, mapRowToRunStep, mapRowToWorkflowRun, safeParse };
|