@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/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/pg-stores@3.
|
|
2
|
+
> @axiom-lattice/pg-stores@3.4.0 build /home/runner/work/agentic/agentic/packages/pg-stores
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2020
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
12
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
15
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m516.90 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m957.25 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 704ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m526.27 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m957.52 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 709ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 9826ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m110.40 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m110.40 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,192 @@
|
|
|
1
1
|
# @axiom-lattice/pg-stores
|
|
2
2
|
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d5dc506: Agent run history retention
|
|
8
|
+
|
|
9
|
+
- Add `IAgentRunLedger.deleteTerminalBefore(cutoffMs, limit)` for bounded,
|
|
10
|
+
oldest-first deletion of terminal runs; pending and running rows are never
|
|
11
|
+
deleted.
|
|
12
|
+
- Implement the method for the in-memory and PostgreSQL ledgers, including a
|
|
13
|
+
partial terminal-`finished_at` index (migration v201).
|
|
14
|
+
- Add a gateway retention job controlled by `AGENT_RUN_RETENTION_DAYS` (default
|
|
15
|
+
30 days; `0`/invalid disables) and stop it during graceful shutdown.
|
|
16
|
+
|
|
17
|
+
- f1f8840: Durable cross-replica public-channel replies (Phase B)
|
|
18
|
+
|
|
19
|
+
- Add a durable `ChannelReplyJob` protocol, in-memory/PostgreSQL stores, and a
|
|
20
|
+
`lattice_channel_reply_jobs` migration (v200) with lease-based claim, bounded
|
|
21
|
+
reschedule, and terminal delivery state.
|
|
22
|
+
- Route non-Room public ingress for adapters declaring `durableReply: true`
|
|
23
|
+
through a reply job plus a pending `source='run_api'` run (job written first,
|
|
24
|
+
with compensation on run-create failure). Lark opts in; WeCom/WeChat/Room stay
|
|
25
|
+
legacy because their reply transport is connection-bound/process-local.
|
|
26
|
+
- Add `ChannelReplyDispatcher`, which polls due jobs on any replica, waits for
|
|
27
|
+
the run ledger to become terminal, reads the final assistant text from the
|
|
28
|
+
thread checkpoint, sends it through the adapter, and marks the job delivered.
|
|
29
|
+
Empty output and loader/send failures retry with capped exponential backoff;
|
|
30
|
+
sends have a 15s deadline; missing runs converge after a 30s grace window;
|
|
31
|
+
cancelled runs do not send a waiting notice. Terminal jobs are pruned after
|
|
32
|
+
24h.
|
|
33
|
+
- Keep Room/trusted dispatch and `ChannelConnectionLeader` unchanged. Durable
|
|
34
|
+
replies are at-least-once; outbound metadata carries `inputMessageId` for
|
|
35
|
+
channel-side deduplication. Ingress falls back to legacy when the dispatcher
|
|
36
|
+
runtime is not registered. Opt out with `CHANNEL_DURABLE_RUNS=false`.
|
|
37
|
+
|
|
38
|
+
- 8285b9a: Execution substrate: durable agent-run ledger and opt-in fleet worker
|
|
39
|
+
|
|
40
|
+
- Add `IAgentRunLedger` + PostgreSQL implementation (migration v193, one running run per thread).
|
|
41
|
+
- Record agent runs observationally (fire-and-forget begin/heartbeat/settle); lease remains the execution authority.
|
|
42
|
+
- Add opt-in `ThreadExecutionSupervisor` worker discovery with fair rotating scan, cooldowns, orphan recovery via the existing resume path, and readiness guidance.
|
|
43
|
+
- Add `probeThreadRunOwner` (owner/free/unknown) and `hasPending` discovery metadata.
|
|
44
|
+
|
|
45
|
+
- ea90717: `keep_latest` checkpoint pruning (M2-B2b)
|
|
46
|
+
|
|
47
|
+
- Add `CheckpointMaintenance.pruneThread` and transactional per-namespace latest-N checkpoint retention with blob retention derived from `channel_versions`.
|
|
48
|
+
- Add `POST .../prune { strategy: "keep_latest", keep?: 1..100 }`; `delete` is unchanged.
|
|
49
|
+
- Reuse strict ownership, thread-run lease, and empty-inbox guards; keep the thread row and chunk stream.
|
|
50
|
+
|
|
51
|
+
- 1fde314: Pending run task queue (Phase 1)
|
|
52
|
+
|
|
53
|
+
- Make `lattice_agent_runs` the durable task queue for the new single-run API: create writes `pending`, a worker claims/executes through `Agent.executeRun`, and recovery reclaims expired rows in place and completes durable rollback work.
|
|
54
|
+
- Add run lifecycle `join` (bounded terminal wait), `cancel?action=interrupt|rollback`, and HITL command runs; Web App runtime mirrors the same handlers.
|
|
55
|
+
- Add `client.runs.join` / cancel `action` / create `command`, and single-run HITL with `ThreadStream.openRun`. `RunCreateResult` is now `{ runId, messageId?, status: "pending" }`: the old queue-first `status: "queued"` / `queued: true` shape and the required `messageId` are gone (command runs have no user message).
|
|
56
|
+
- Keep the legacy message queue, Room, Project Task, A2A, and legacy HITL on `source='legacy'`; the two executors share the `thread-run` lease.
|
|
57
|
+
|
|
58
|
+
- 1236db0: feat(run-queue): add a per-tenant execution concurrency cap
|
|
59
|
+
|
|
60
|
+
`RUN_TASK_MAX_RUNNING_PER_TENANT` bounds concurrently `running`
|
|
61
|
+
`source='run_api'` rows per tenant, independently of the admission quota
|
|
62
|
+
(`RUN_TASK_MAX_ACTIVE_PER_TENANT`, which counts pending + running and rejects
|
|
63
|
+
creates). Pending rows stay queued; scans skip tenants at their cap so other
|
|
64
|
+
tenants remain listable. InMemory enforces on list/claim, PostgreSQL adds a
|
|
65
|
+
per-candidate count predicate and serializes capped claims with a
|
|
66
|
+
transaction-scoped tenant advisory lock. The global `N_JOBS_PER_WORKER` pool and
|
|
67
|
+
existing claim ordering are unchanged; this is best-effort cross-tenant
|
|
68
|
+
visibility, not strict round-robin fairness.
|
|
69
|
+
|
|
70
|
+
- 5c5550b: Per-tenant run queue admission quota
|
|
71
|
+
|
|
72
|
+
- Add optional `maxActiveRunsForTenant` to `CreatePendingAgentRunInput` and
|
|
73
|
+
`AgentRunTenantQuotaExceededError` (`RUN_TENANT_QUOTA_EXCEEDED`); both stores
|
|
74
|
+
reject before insert when the tenant already has that many active
|
|
75
|
+
(`pending`/`running`) `source='run_api'` runs.
|
|
76
|
+
- PostgreSQL serializes tenant creates with
|
|
77
|
+
`pg_advisory_xact_lock(hashtext($tenantId))` before counting; no migration.
|
|
78
|
+
- Gateway reads `RUN_TASK_MAX_ACTIVE_PER_TENANT` (positive safe integer else
|
|
79
|
+
unlimited) for run-lifecycle, legacy `/api/runs` background/streaming, and A2A
|
|
80
|
+
creation; HTTP creates return 429 before SSE hijack.
|
|
81
|
+
- Admission control only: pending rows count, worker claim order is unchanged,
|
|
82
|
+
and this is not fair scheduling or per-tenant execution concurrency.
|
|
83
|
+
|
|
84
|
+
- e732b92: Execute Project Task on the durable AgentRun queue while preserving TaskItem lifecycle, roster authority, HITL, and Room projection.
|
|
85
|
+
|
|
86
|
+
Project Task now creates `source="project_task"` runs with a canonical `taskId`; the worker rebuilds trusted Project/roster context from persisted rows, and a terminal hook settles error/interrupted/cancelled outcomes. Production composition no longer requires `threadMessageQueue`. Adds the active-run-by-task ledger query and PG migrations v203 (task identity) / v204 (one running row across `run_api` and `project_task`). A2A remains `source="run_api"` with unchanged semantics; run success is not task completion.
|
|
87
|
+
|
|
88
|
+
- da5294d: Tenant-scoped namespaced KV store (M2-C)
|
|
89
|
+
|
|
90
|
+
- Add `StoreProtocol` (put/get/delete/search/listNamespaces/deleteExpired) with deep JSONB filters, substring query, and TTL.
|
|
91
|
+
- Add InMemory, Local SQLite, and PostgreSQL implementations (PG migration v195 with GIN and partial expiry indexes).
|
|
92
|
+
- Add `/api/store/*` routes and a single-flight store TTL sweeper.
|
|
93
|
+
- `index` hints are accepted but vector indexing and semantic search remain deferred.
|
|
94
|
+
|
|
95
|
+
- 2609f3b: Thread copy and prune-delete (M2-B1)
|
|
96
|
+
|
|
97
|
+
- Add `CheckpointMaintenance` and transactional `copyThread` / `deleteThread` to `PostgreSQLCheckpointStorage`, with a typed `CHECKPOINT_TARGET_NOT_EMPTY` conflict and metadata `thread_id` rewrite.
|
|
98
|
+
- Add owner-scoped, busy-guarded copy and prune-delete routes; prune clears the thread's chunk stream best-effort and retains run-ledger rows.
|
|
99
|
+
- Share the thread ownership resolver between read and maintenance controllers.
|
|
100
|
+
|
|
101
|
+
- 12ce057: Thread read model (M2-A)
|
|
102
|
+
|
|
103
|
+
- Add `Agent.getStateHistory` / `Agent.getStateAtCheckpoint` (bounded to 50 checkpoints).
|
|
104
|
+
- Add `CheckpointStorage` / `ThreadCheckpointStorage` protocols and a read-only `PostgreSQLCheckpointStorage` over the built-in `PostgresSaver` tables.
|
|
105
|
+
- Add tenant/assistant-scoped read-only routes for thread status, checkpoint history, checkpoint state, and checkpoint storage usage; missing checkpoints and foreign threads return 404 and unexpected errors are sanitized.
|
|
106
|
+
|
|
107
|
+
- 23902af: Per-thread TTL and expiry sweeper (M2-B2a)
|
|
108
|
+
|
|
109
|
+
- Add optional `expiresAt` to `Thread`/`CreateThreadRequest` and `listExpiredThreads` to `ThreadStore`.
|
|
110
|
+
- Persist `expires_at` in InMemory, Local SQLite, and PostgreSQL stores (PG migration v194 + partial index).
|
|
111
|
+
- Accept `ttlSeconds`/`expiresAt` when creating a thread (invalid values return 400).
|
|
112
|
+
- Add a lease/inbox/maintenance-guarded TTL sweeper with `THREAD_TTL_SWEEP_*` configuration.
|
|
113
|
+
- Copy does not inherit TTL; run-ledger rows are retained on sweep.
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- c1f4f54: fix: do not let stale legacy running rows block run_api claims
|
|
118
|
+
|
|
119
|
+
Legacy message-queue ledger rows and durable `run_api` rows share
|
|
120
|
+
`lattice_agent_runs`. A crashed legacy owner could leave a `running` row behind
|
|
121
|
+
and the `(tenant, thread) WHERE status='running'` unique index made every later
|
|
122
|
+
`run_api` pending row unclaimable after the thread-run lease expired.
|
|
123
|
+
|
|
124
|
+
Pending scans/claims now ignore legacy running rows, and migration v202 scopes
|
|
125
|
+
the one-running-row partial unique index to `source='run_api'`. Actual execution
|
|
126
|
+
exclusion remains the shared `thread-run` lease.
|
|
127
|
+
|
|
128
|
+
- 5f0aeff: feat(run-task): interleave pending scans fairly across tenants
|
|
129
|
+
|
|
130
|
+
`ListPendingRunsOptions.fairTenants` (default `false`) returns each tenant's
|
|
131
|
+
oldest claimable pending run first, then each tenant's second-oldest, and so on,
|
|
132
|
+
with `(availableAt, createdAt, runId, tenantId)` tie-breakers. Existing due,
|
|
133
|
+
active-thread, rollback and `maxRunningPerTenant` filters still apply before
|
|
134
|
+
ranking. InMemory and PostgreSQL use the same ordering; PostgreSQL ranks with a
|
|
135
|
+
tenant-partitioned `row_number()` window. Fair mode rejects the global keyset
|
|
136
|
+
`after` cursor with `RangeError`, and the run-task worker now always scans fair
|
|
137
|
+
without a cursor. This is best-effort interleaving at scan time, not strict
|
|
138
|
+
global round-robin scheduling.
|
|
139
|
+
|
|
140
|
+
- Updated dependencies [1fde314]
|
|
141
|
+
- Updated dependencies [9a6579c]
|
|
142
|
+
- Updated dependencies [c1f4f54]
|
|
143
|
+
- Updated dependencies [d5dc506]
|
|
144
|
+
- Updated dependencies [f1f8840]
|
|
145
|
+
- Updated dependencies [8285b9a]
|
|
146
|
+
- Updated dependencies [5f0aeff]
|
|
147
|
+
- Updated dependencies [dcbe47b]
|
|
148
|
+
- Updated dependencies [235b4a4]
|
|
149
|
+
- Updated dependencies [c07db86]
|
|
150
|
+
- Updated dependencies [ea90717]
|
|
151
|
+
- Updated dependencies [e33c7c3]
|
|
152
|
+
- Updated dependencies [2d61ef6]
|
|
153
|
+
- Updated dependencies [351b0e9]
|
|
154
|
+
- Updated dependencies [1fde314]
|
|
155
|
+
- Updated dependencies [1236db0]
|
|
156
|
+
- Updated dependencies [5c5550b]
|
|
157
|
+
- Updated dependencies [e732b92]
|
|
158
|
+
- Updated dependencies [2422cdd]
|
|
159
|
+
- Updated dependencies [bfb7c42]
|
|
160
|
+
- Updated dependencies [ced17aa]
|
|
161
|
+
- Updated dependencies [8f9dd0d]
|
|
162
|
+
- Updated dependencies [da5294d]
|
|
163
|
+
- Updated dependencies [03e9984]
|
|
164
|
+
- Updated dependencies [2609f3b]
|
|
165
|
+
- Updated dependencies [4a74c70]
|
|
166
|
+
- Updated dependencies [12ce057]
|
|
167
|
+
- Updated dependencies [66daf89]
|
|
168
|
+
- Updated dependencies [23902af]
|
|
169
|
+
- Updated dependencies [fad0bd0]
|
|
170
|
+
- @axiom-lattice/core@9.0.0
|
|
171
|
+
- @axiom-lattice/protocols@5.0.0
|
|
172
|
+
|
|
173
|
+
## 3.3.13
|
|
174
|
+
|
|
175
|
+
### Patch Changes
|
|
176
|
+
|
|
177
|
+
- b0d43d4: Tenant model providers can now offer chat, embedding and speech-to-text models from one catalog, and every model-provider or collection change takes effect without a gateway restart.
|
|
178
|
+
|
|
179
|
+
`ModelKind` (`chat` / `embedding` / `asr`) is stored on the model row rather than the provider, because one provider is one credential and one base URL and a single OpenAI-compatible endpoint commonly serves all three. Each kind keeps its own runtime lattice and lazily materialises its client from the shared store, so a tenant model resolves on every replica without replica-to-replica synchronisation. A loader guard keeps a chat consumer from ever resolving an embedding or ASR row, and the tenant default model remains chat-only.
|
|
180
|
+
|
|
181
|
+
The provider panel exposes the kind per model, offers a per-model thinking toggle (stored as `extra.disableThinking`, translated to the upstream kwargs by core), and can run one embedding inference to prove a model works and report its vector dimension. Collection and voice pickers now read the tenant catalog and fall back to the deployment's boot-registered models.
|
|
182
|
+
|
|
183
|
+
Invalidation is now uniform across kinds: a provider change evicts chat, embedding and ASR clients on every replica, and a collection change — including a new `embeddingKey` — drops the cached vector stores it invalidated, locally and across replicas through the outbox.
|
|
184
|
+
|
|
185
|
+
- Updated dependencies [b0d43d4]
|
|
186
|
+
- Updated dependencies [c57f417]
|
|
187
|
+
- @axiom-lattice/protocols@4.11.0
|
|
188
|
+
- @axiom-lattice/core@8.1.0
|
|
189
|
+
|
|
3
190
|
## 3.3.12
|
|
4
191
|
|
|
5
192
|
### Patch 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, 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 };
|