@sixb/pg 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/agent-storage.d.ts +4 -0
- package/dist/agents/agent-storage.d.ts.map +1 -1
- package/dist/agents/approvals.d.ts +2 -1
- package/dist/agents/approvals.d.ts.map +1 -1
- package/dist/agents/checkpoints.d.ts +2 -1
- package/dist/agents/checkpoints.d.ts.map +1 -1
- package/dist/agents/inbox.d.ts +23 -0
- package/dist/agents/inbox.d.ts.map +1 -0
- package/dist/agents/messages.d.ts +2 -1
- package/dist/agents/messages.d.ts.map +1 -1
- package/dist/agents/reads.d.ts +9 -0
- package/dist/agents/reads.d.ts.map +1 -0
- package/dist/agents/runs.d.ts +2 -1
- package/dist/agents/runs.d.ts.map +1 -1
- package/dist/agents/threads.d.ts.map +1 -1
- package/dist/index.js +1212 -87
- package/dist/index.js.map +17 -15
- package/dist/latest-run-query.d.ts +3 -1
- package/dist/latest-run-query.d.ts.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/ontology-storage/replacement-plans.d.ts.map +1 -1
- package/dist/pg-ai-cost-storage.d.ts.map +1 -1
- package/dist/pg-artifact-storage.d.ts +4 -1
- package/dist/pg-artifact-storage.d.ts.map +1 -1
- package/dist/pg-sync-run-storage.d.ts +2 -1
- package/dist/pg-sync-run-storage.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/agents/agent-storage.ts +6 -0
- package/src/agents/approvals.ts +44 -0
- package/src/agents/checkpoints.ts +26 -0
- package/src/agents/inbox.ts +421 -0
- package/src/agents/messages.ts +81 -2
- package/src/agents/reads.ts +160 -0
- package/src/agents/runs.ts +25 -0
- package/src/agents/threads.ts +95 -11
- package/src/latest-run-query.ts +8 -1
- package/src/migrations/103-script-executions.sql +145 -0
- package/src/migrations/104-artifact-pdfs.sql +18 -0
- package/src/migrations/105-guest-comment-links.sql +17 -0
- package/src/migrations/106-agent-thread-inbox.sql +36 -0
- package/src/migrations/107-agent-inbox-edits.sql +3 -0
- package/src/migrations/108-agent-thread-reads.sql +73 -0
- package/src/migrations/109-sync-run-connections.sql +6 -0
- package/src/migrations.ts +14 -0
- package/src/ontology-storage/replacement-plans.ts +51 -1
- package/src/pg-ai-cost-storage.ts +35 -20
- package/src/pg-artifact-storage.ts +67 -9
- package/src/pg-sync-run-storage.ts +69 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SQLClient } from "./pg-client";
|
|
1
|
+
import type { SQLClient, SqlParameter } from "./pg-client";
|
|
2
2
|
type PgLatestRunTarget = {
|
|
3
3
|
readonly tableName: "pipeline_runs";
|
|
4
4
|
readonly ownerColumn: "pipeline_id";
|
|
@@ -21,6 +21,8 @@ export declare function queryLatestRunsByOwnerId<TRow>(input: {
|
|
|
21
21
|
readonly selectList?: PgLatestRunSelectList;
|
|
22
22
|
/** A status that never counts as the latest run, such as a run made stale by a newer one. */
|
|
23
23
|
readonly excludedStatus?: string;
|
|
24
|
+
/** One more condition a row must meet to count. `bind` adds a parameter, named as it returns. */
|
|
25
|
+
readonly filter?: (bind: (value: SqlParameter) => string) => string;
|
|
24
26
|
} & PgLatestRunTarget): Promise<readonly TRow[]>;
|
|
25
27
|
export {};
|
|
26
28
|
//# sourceMappingURL=latest-run-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latest-run-query.d.ts","sourceRoot":"","sources":["../src/latest-run-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"latest-run-query.d.ts","sourceRoot":"","sources":["../src/latest-run-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,KAAK,iBAAiB,GAClB;IAAE,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAA;CAAE,GAC5E;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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replacement-plans.d.ts","sourceRoot":"","sources":["../../src/ontology-storage/replacement-plans.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAM3B,MAAM,qCAAqC,CAAA;AAY5C,OAAO,KAAK,EAEV,mBAAmB,EACnB,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAc7C,eAAO,MAAM,kBAAkB,mCAAmC,CAAA;AAclE,mGAAmG;AACnG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,cAAc,EAAE,QAAQ,GAAG,MAAM,CAAA;CAC3C;
|
|
1
|
+
{"version":3,"file":"replacement-plans.d.ts","sourceRoot":"","sources":["../../src/ontology-storage/replacement-plans.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAM3B,MAAM,qCAAqC,CAAA;AAY5C,OAAO,KAAK,EAEV,mBAAmB,EACnB,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAc7C,eAAO,MAAM,kBAAkB,mCAAmC,CAAA;AAclE,mGAAmG;AACnG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,cAAc,EAAE,QAAQ,GAAG,MAAM,CAAA;CAC3C;AA0ID,qBAAa,gCAAiC,YAAW,8BAA8B;IACzE,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,IAAI,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAqFpE,WAAW,CAChB,KAAK,EAAE,+BAA+B,GACrC,aAAa,CAAC,wBAAwB,CAAC;IAoEpC,KAAK,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwFtD,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA0ClE,KAAK,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,MAAM,CAAC;CAkChE;AAED,gFAAgF;AAChF,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,SAAS,EACd,MAAM,EAAE;IACN,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAA;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACd,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;SAAE,CAAA;QAClD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;KACnC,CAAA;CACF,GACA,OAAO,CAAC,iBAAiB,CAAC,CA2B5B;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,qEAAqE;AACrE,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAyBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-ai-cost-storage.d.ts","sourceRoot":"","sources":["../src/pg-ai-cost-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pg-ai-cost-storage.d.ts","sourceRoot":"","sources":["../src/pg-ai-cost-storage.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAElB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAE1B,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACpC,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAGnD,8EAA8E;AAC9E,qBAAa,eAAgB,YAAW,aAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,mBAAmB,CACvB,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,2BAA2B,CAAC;IAIjC,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BhE,mBAAmB,CACvB,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC;IAsB9B,oBAAoB,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA2L1F,cAAc,CAClB,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,+BAA+B,CAAC;CA6I5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArtifactBoardPreviewRecord, ArtifactCommentKey, ArtifactCommentRecord, ArtifactFrameGrantRecord, ArtifactRecord, ArtifactRestorePointRecord, ArtifactStateEntry, ArtifactStateKeyInput, ArtifactStateScope, ArtifactStorage, ArtifactTurnInput, ArtifactTurnWriteRecord, ArtifactVersionRecord, CopyArtifactInput, CreateArtifactCommentInput, CreateArtifactInput, DeleteArtifactInput, DeleteExpiredArtifactFrameGrantsInput, FindArtifactFrameGrantInput, FreezeArtifactVersionInput, GetArtifactInput, GetArtifactRestorePointInput, GetArtifactVersionInput, ListArtifactBoardPreviewsInput, ListArtifactsInput, ListArtifactsResult, ListArtifactVersionsInput, ListArtifactVersionsResult, ListReferencingVersionsInput, PublishArtifactVersionInput, PublishedArtifactVersion, PutArtifactBoardPreviewsInput, ResolveArtifactCommentInput, RestoreArtifactInput, SetArtifactStateInput, UndoArtifactTurnInput, UndoneArtifactTurn } from "@sixb/core/storage";
|
|
1
|
+
import type { ArtifactBoardPreviewRecord, ArtifactCommentKey, ArtifactCommentRecord, ArtifactFrameGrantRecord, ArtifactPdfKeyInput, ArtifactPdfRecord, ArtifactRecord, ArtifactRestorePointRecord, ArtifactStateEntry, ArtifactStateKeyInput, ArtifactStateScope, ArtifactStorage, ArtifactTurnInput, ArtifactTurnWriteRecord, ArtifactVersionRecord, CopyArtifactInput, CreateArtifactCommentInput, CreateArtifactInput, DeleteArtifactInput, DeleteExpiredArtifactFrameGrantsInput, FindArtifactFrameGrantInput, FreezeArtifactVersionInput, GetArtifactInput, GetArtifactRestorePointInput, GetArtifactVersionInput, ListArtifactBoardPreviewsInput, ListArtifactsInput, ListArtifactsResult, ListArtifactVersionsInput, ListArtifactVersionsResult, ListReferencingVersionsInput, PublishArtifactVersionInput, PublishedArtifactVersion, PutArtifactBoardPreviewsInput, ResolveArtifactCommentInput, RestoreArtifactInput, SetArtifactStateInput, UndoArtifactTurnInput, UndoneArtifactTurn } from "@sixb/core/storage";
|
|
2
2
|
import { type PgStoreClient } from "./transactions";
|
|
3
3
|
export declare class PgArtifactStorage implements ArtifactStorage {
|
|
4
4
|
private readonly sql;
|
|
@@ -28,6 +28,9 @@ export declare class PgArtifactStorage implements ArtifactStorage {
|
|
|
28
28
|
clearState(input: ArtifactStateScope): Promise<number>;
|
|
29
29
|
listBoardPreviews(input: ListArtifactBoardPreviewsInput): Promise<ArtifactBoardPreviewRecord[]>;
|
|
30
30
|
putBoardPreviews(input: PutArtifactBoardPreviewsInput): Promise<void>;
|
|
31
|
+
getPdf(input: ArtifactPdfKeyInput): Promise<ArtifactPdfRecord | null>;
|
|
32
|
+
putPdf(input: ArtifactPdfRecord): Promise<void>;
|
|
33
|
+
clearPdfFailure(input: ArtifactPdfKeyInput): Promise<void>;
|
|
31
34
|
createComment(input: CreateArtifactCommentInput): Promise<ArtifactCommentRecord>;
|
|
32
35
|
getComment(input: ArtifactCommentKey): Promise<ArtifactCommentRecord | null>;
|
|
33
36
|
listComments(input: GetArtifactInput): Promise<ArtifactCommentRecord[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-artifact-storage.d.ts","sourceRoot":"","sources":["../src/pg-artifact-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pg-artifact-storage.d.ts","sourceRoot":"","sources":["../src/pg-artifact-storage.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,0BAA0B,EAE1B,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EAEd,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EAEvB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,qCAAqC,EACrC,2BAA2B,EAC3B,0BAA0B,EAC1B,gBAAgB,EAChB,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,wBAAwB,EACxB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AA+DrE,qBAAa,iBAAkB,YAAW,eAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;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CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAW1D,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;CAS3D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClaimRunInput, ConfirmRunExecutionInput, ExecutionStorage, FinishSyncRunInput, ListLatestSyncRunsInput, ListLatestSyncRunsResult, ListLostRunsInput, ListSyncRunsInput, ListSyncRunsResult, PrepareSyncRunCommitInput, QueueSyncRunInput, ReleaseRunExecutionInput, RunClaim, SyncRunRecord, SyncRunStorage } from "@sixb/core/storage";
|
|
1
|
+
import type { ClaimRunInput, ConfirmRunExecutionInput, ExecutionStorage, FinishSyncRunInput, ListLatestSyncConnectionRunsInput, ListLatestSyncRunsInput, ListLatestSyncRunsResult, ListLostRunsInput, ListSyncRunsInput, ListSyncRunsResult, PrepareSyncRunCommitInput, QueueSyncRunInput, ReleaseRunExecutionInput, RunClaim, SyncRunRecord, SyncRunStorage } from "@sixb/core/storage";
|
|
2
2
|
import { type PgStoreClient } from "./transactions";
|
|
3
3
|
export declare class PgSyncRunStorage implements SyncRunStorage {
|
|
4
4
|
private readonly sql;
|
|
@@ -18,5 +18,6 @@ export declare class PgSyncRunStorage implements SyncRunStorage {
|
|
|
18
18
|
}): Promise<SyncRunRecord | null>;
|
|
19
19
|
list(input: ListSyncRunsInput): Promise<ListSyncRunsResult>;
|
|
20
20
|
listLatestBySyncIds(input: ListLatestSyncRunsInput): Promise<ListLatestSyncRunsResult>;
|
|
21
|
+
listLatestByConnection(input: ListLatestSyncConnectionRunsInput): Promise<ListLatestSyncRunsResult>;
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=pg-sync-run-storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-sync-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-sync-run-storage.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,a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AAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAiBtE,yBAAyB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC;IAIlF,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC;IAIrE,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhE,aAAa,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAC;IAgBvE,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IA4DzD,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IASjF,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwE3D,mBAAmB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAoBtF,sBAAsB,CAC1B,KAAK,EAAE,iCAAiC,GACvC,OAAO,CAAC,wBAAwB,CAAC;CA8BrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/pg",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "PostgreSQL storage provider for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"postgres": "^3.4.5"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@sixb/core": "0.2.
|
|
43
|
+
"@sixb/core": "0.2.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@sixb/core": "0.2.
|
|
46
|
+
"@sixb/core": "0.2.6",
|
|
47
47
|
"@types/bun": "latest",
|
|
48
48
|
"typescript": "^5.7.0"
|
|
49
49
|
},
|
|
@@ -3,8 +3,10 @@ import type { PgStoreClient } from "../transactions"
|
|
|
3
3
|
import { PgAgentApprovalStore } from "./approvals"
|
|
4
4
|
import { PgAgentContextCheckpointStore } from "./checkpoints"
|
|
5
5
|
import { PgAgentComputerSessionStore } from "./computers"
|
|
6
|
+
import { PgAgentInboxStore } from "./inbox"
|
|
6
7
|
import { PgAgentMemoryStore } from "./memory"
|
|
7
8
|
import { PgAgentMessageStore } from "./messages"
|
|
9
|
+
import { PgAgentThreadReadStore } from "./reads"
|
|
8
10
|
import { PgAgentRunStore } from "./runs"
|
|
9
11
|
import { PgAgentApprovalModeStore } from "./settings"
|
|
10
12
|
import { PgAgentThreadStore } from "./threads"
|
|
@@ -23,6 +25,7 @@ export interface PgAgentStorageOptions {
|
|
|
23
25
|
*/
|
|
24
26
|
export class PgAgentStorage implements AgentStorage {
|
|
25
27
|
readonly threads: PgAgentThreadStore
|
|
28
|
+
readonly reads: PgAgentThreadReadStore
|
|
26
29
|
readonly runs: PgAgentRunStore
|
|
27
30
|
readonly messages: PgAgentMessageStore
|
|
28
31
|
readonly checkpoints: PgAgentContextCheckpointStore
|
|
@@ -31,9 +34,11 @@ export class PgAgentStorage implements AgentStorage {
|
|
|
31
34
|
readonly approvalModes: PgAgentApprovalModeStore
|
|
32
35
|
readonly computers: PgAgentComputerSessionStore
|
|
33
36
|
readonly tokenRates: PgAgentTokenRateStore
|
|
37
|
+
readonly inbox: PgAgentInboxStore
|
|
34
38
|
|
|
35
39
|
constructor(options: PgAgentStorageOptions) {
|
|
36
40
|
this.threads = new PgAgentThreadStore(options.sql)
|
|
41
|
+
this.reads = new PgAgentThreadReadStore(options.sql)
|
|
37
42
|
this.runs = new PgAgentRunStore(options.sql, options.executions)
|
|
38
43
|
this.messages = new PgAgentMessageStore(options.sql)
|
|
39
44
|
this.checkpoints = new PgAgentContextCheckpointStore(options.sql)
|
|
@@ -42,5 +47,6 @@ export class PgAgentStorage implements AgentStorage {
|
|
|
42
47
|
this.approvalModes = new PgAgentApprovalModeStore(options.sql)
|
|
43
48
|
this.computers = new PgAgentComputerSessionStore(options.sql)
|
|
44
49
|
this.tokenRates = new PgAgentTokenRateStore(options.sql)
|
|
50
|
+
this.inbox = new PgAgentInboxStore(options.sql)
|
|
45
51
|
}
|
|
46
52
|
}
|
package/src/agents/approvals.ts
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
type MarkAgentApprovalsReportedInput,
|
|
21
21
|
type RequestAgentApprovalInput,
|
|
22
22
|
type RequestAgentApprovalResult,
|
|
23
|
+
type RewindAgentApprovalsInput,
|
|
24
|
+
type RewindAgentApprovalsResult,
|
|
23
25
|
type SettleAgentApprovalsInput,
|
|
24
26
|
type StopAgentApprovalsInput,
|
|
25
27
|
type StopAgentApprovalsResult,
|
|
@@ -187,6 +189,48 @@ export class PgAgentApprovalStore implements AgentApprovalStore {
|
|
|
187
189
|
return { cancelled: cancelled.sort(compareApprovals), stopped }
|
|
188
190
|
}
|
|
189
191
|
|
|
192
|
+
async rewind(input: RewindAgentApprovalsInput): Promise<RewindAgentApprovalsResult> {
|
|
193
|
+
const runIds = [...new Set(input.runIds)]
|
|
194
|
+
const clearedIds = [...new Set(input.clearedMessageIds ?? [])]
|
|
195
|
+
const cancelledAt = new Date(input.cancelledAt ?? new Date())
|
|
196
|
+
|
|
197
|
+
return runPgTransaction(this.sql, async (tx) => {
|
|
198
|
+
if (clearedIds.length > 0) {
|
|
199
|
+
await tx`
|
|
200
|
+
UPDATE agent_approvals
|
|
201
|
+
SET reported_in_message_id = NULL
|
|
202
|
+
WHERE project_id = ${input.projectId}
|
|
203
|
+
AND thread_id = ${input.threadId}
|
|
204
|
+
AND reported_in_message_id = ANY(${tx.array(clearedIds)}::text[])
|
|
205
|
+
`
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (runIds.length === 0) return { cancelled: [], deleted: 0 }
|
|
209
|
+
|
|
210
|
+
const removed = await tx<AgentApprovalRow[]>`
|
|
211
|
+
DELETE FROM agent_approvals
|
|
212
|
+
WHERE project_id = ${input.projectId}
|
|
213
|
+
AND thread_id = ${input.threadId}
|
|
214
|
+
AND run_id = ANY(${tx.array(runIds)}::text[])
|
|
215
|
+
RETURNING *
|
|
216
|
+
`
|
|
217
|
+
|
|
218
|
+
const cancelled = removed
|
|
219
|
+
.filter((row) => row.status === "pending")
|
|
220
|
+
.map((row): AgentApprovalRecord => {
|
|
221
|
+
const parsed = rowToApproval(row)
|
|
222
|
+
return {
|
|
223
|
+
...parsed,
|
|
224
|
+
status: "cancelled",
|
|
225
|
+
turnStoppedAt: parsed.turnStoppedAt ?? cancelledAt,
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
.sort(compareApprovals)
|
|
229
|
+
|
|
230
|
+
return { cancelled, deleted: removed.length }
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
|
|
190
234
|
async holdsRun(input: { readonly projectId: string; readonly runId: string }): Promise<boolean> {
|
|
191
235
|
return pgHoldsRun(this.sql, input.projectId, input.runId)
|
|
192
236
|
}
|
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
assertAgentContextCheckpointAuthority,
|
|
5
5
|
assertAgentContextCheckpointReplayState,
|
|
6
6
|
assertCreateAgentContextCheckpointInput,
|
|
7
|
+
assertDeleteAgentContextCheckpointsAfterSeqInput,
|
|
7
8
|
} from "@sixb/core/internal/agent-run-storage-provider"
|
|
8
9
|
import {
|
|
9
10
|
type AgentContextCheckpointRecord,
|
|
10
11
|
type AgentContextCheckpointStore,
|
|
11
12
|
AgentStorageError,
|
|
12
13
|
type CreateAgentContextCheckpointInput,
|
|
14
|
+
type DeleteAgentContextCheckpointsAfterSeqInput,
|
|
13
15
|
} from "@sixb/core/storage"
|
|
14
16
|
import { isUniqueViolation } from "../storage-errors"
|
|
15
17
|
import { type PgStoreClient, runPgTransaction } from "../transactions"
|
|
@@ -178,6 +180,30 @@ export class PgAgentContextCheckpointStore implements AgentContextCheckpointStor
|
|
|
178
180
|
return row ? rowToContextCheckpointRecord(row) : null
|
|
179
181
|
}
|
|
180
182
|
|
|
183
|
+
async deleteAfterSeq(input: DeleteAgentContextCheckpointsAfterSeqInput): Promise<number> {
|
|
184
|
+
assertDeleteAgentContextCheckpointsAfterSeqInput(input, "SixbPg")
|
|
185
|
+
|
|
186
|
+
return runPgTransaction(this.sql, async (tx) => {
|
|
187
|
+
const rows = await tx<{ id: string }[]>`
|
|
188
|
+
SELECT id FROM agent_context_checkpoints
|
|
189
|
+
WHERE project_id = ${input.projectId}
|
|
190
|
+
AND thread_id = ${input.threadId}
|
|
191
|
+
AND observed_head_seq > ${input.afterSeq}
|
|
192
|
+
ORDER BY summarized_through_seq DESC, created_at DESC, id DESC
|
|
193
|
+
FOR UPDATE
|
|
194
|
+
`
|
|
195
|
+
if (rows.length === 0) return 0
|
|
196
|
+
|
|
197
|
+
for (const row of rows) {
|
|
198
|
+
await tx`
|
|
199
|
+
DELETE FROM agent_context_checkpoints
|
|
200
|
+
WHERE project_id = ${input.projectId} AND id = ${row.id}
|
|
201
|
+
`
|
|
202
|
+
}
|
|
203
|
+
return rows.length
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
|
|
181
207
|
async getByRunIds(input: {
|
|
182
208
|
readonly projectId: string
|
|
183
209
|
readonly threadId: string
|