@sixb/pg 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/agents/threads.d.ts +4 -0
  2. package/dist/agents/threads.d.ts.map +1 -1
  3. package/dist/auth-storage/sessions.d.ts +2 -1
  4. package/dist/auth-storage/sessions.d.ts.map +1 -1
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +959 -7
  8. package/dist/index.js.map +15 -13
  9. package/dist/migrations.d.ts.map +1 -1
  10. package/dist/ontology-storage/replacement-plans.d.ts.map +1 -1
  11. package/dist/ontology-storage/sources.d.ts +2 -1
  12. package/dist/ontology-storage/sources.d.ts.map +1 -1
  13. package/dist/pg-action-run-storage.d.ts +4 -0
  14. package/dist/pg-action-run-storage.d.ts.map +1 -1
  15. package/dist/pg-activity-storage.d.ts +22 -0
  16. package/dist/pg-activity-storage.d.ts.map +1 -0
  17. package/dist/pg-artifact-storage.d.ts +19 -0
  18. package/dist/pg-artifact-storage.d.ts.map +1 -0
  19. package/dist/pg-execution-storage.d.ts +2 -1
  20. package/dist/pg-execution-storage.d.ts.map +1 -1
  21. package/dist/pg-workflow-run-storage.d.ts +4 -0
  22. package/dist/pg-workflow-run-storage.d.ts.map +1 -1
  23. package/dist/share-grant-storage.d.ts +2 -1
  24. package/dist/share-grant-storage.d.ts.map +1 -1
  25. package/package.json +3 -3
  26. package/src/agents/threads.ts +23 -0
  27. package/src/auth-storage/sessions.ts +20 -0
  28. package/src/index.ts +10 -0
  29. package/src/migrations/063-artifacts.sql +67 -0
  30. package/src/migrations/064-drop-output-diagnostics.sql +14 -0
  31. package/src/migrations/065-plan-work-payload-statistics.sql +5 -0
  32. package/src/migrations/066-activity.sql +61 -0
  33. package/src/migrations/067-activity-timeline.sql +15 -0
  34. package/src/migrations/068-activity-interactions.sql +20 -0
  35. package/src/migrations.ts +18 -0
  36. package/src/ontology-storage/replacement-plans.ts +25 -7
  37. package/src/ontology-storage/sources.ts +37 -0
  38. package/src/pg-action-run-storage.ts +23 -0
  39. package/src/pg-activity-storage.ts +486 -0
  40. package/src/pg-artifact-storage.ts +325 -0
  41. package/src/pg-execution-storage.ts +52 -0
  42. package/src/pg-workflow-run-storage.ts +23 -0
  43. package/src/share-grant-storage.ts +21 -0
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAqH3B,OAAO,KAAK,EAAe,GAAG,EAAa,MAAM,aAAa,CAAA;AAG9D,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC;AAED,eAAO,MAAM,2BAA2B,wBAAwB,CAAA;AAEhE,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,wBAAwB,CAAC,CAE1F;AAED,wBAAgB,MAAM,CACpB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/D,OAAO,GAAE,oBAAyB,GACjC,aAAa,CAAC,wBAAwB,CAAC,CAEzC;AAED,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,MAAM,GACjB,SAAS,eAAe,EAAE,CAQ5B;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IACjB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,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G,OAAO,CAAC,qBAAqB,CAAC;IA6EpE,WAAW,CAChB,KAAK,EAAE,+BAA+B,GACrC,aAAa,CAAC,wBAAwB,CAAC;IAmEpC,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
+ {"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,EA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qBAAqB,CACzC,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAyBhC"}
@@ -1,4 +1,4 @@
1
- import type { AbandonRunSourceMaterializationInput, AbandonSourceMaterializationCandidateInput, AdoptedSourceMaterialization, AdoptSourceMaterializationInput, BeginSourceMaterializationInput, CleanupTerminalSourceMaterializationsInput, CleanupTerminalSourceMaterializationsResult, GetActiveOntologySourceInput, MarkSourceMaterializationReadyInput, OntologySourceRecord, OntologySourceStorage, PurgeAbandonedSourceMaterializationsInput, StageSourceRowsInput, StageSourceRowsResult } from "@sixb/core/storage";
1
+ import type { AbandonRunSourceMaterializationInput, AbandonSourceMaterializationCandidateInput, ActiveOntologySource, AdoptedSourceMaterialization, AdoptSourceMaterializationInput, BeginSourceMaterializationInput, CleanupTerminalSourceMaterializationsInput, CleanupTerminalSourceMaterializationsResult, GetActiveOntologySourceInput, ListActiveOntologySourcesInput, MarkSourceMaterializationReadyInput, OntologySourceRecord, OntologySourceStorage, PurgeAbandonedSourceMaterializationsInput, StageSourceRowsInput, StageSourceRowsResult } from "@sixb/core/storage";
2
2
  import { type PgRootOperation } from "./shared";
3
3
  export declare class PgOntologySourceStorage implements OntologySourceStorage {
4
4
  private readonly runRootOperation;
@@ -7,6 +7,7 @@ export declare class PgOntologySourceStorage implements OntologySourceStorage {
7
7
  stageRows(input: StageSourceRowsInput): Promise<StageSourceRowsResult>;
8
8
  markReady(input: MarkSourceMaterializationReadyInput): Promise<OntologySourceRecord>;
9
9
  getActive(input: GetActiveOntologySourceInput): Promise<OntologySourceRecord | null>;
10
+ listActive(input: ListActiveOntologySourcesInput): Promise<readonly ActiveOntologySource[]>;
10
11
  adopt(input: AdoptSourceMaterializationInput): Promise<AdoptedSourceMaterialization | null>;
11
12
  abandon(input: AbandonSourceMaterializationCandidateInput): Promise<OntologySourceRecord>;
12
13
  abandon(input: AbandonRunSourceMaterializationInput): Promise<OntologySourceRecord | null>;
@@ -1 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,CAAC;IACzF,OAAO,CAAC,KAAK,EAAE,oCAAoC,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAa1F,eAAe,CACnB,KAAK,EAAE,0CAA0C,GAChD,OAAO,CAAC,2CAA2C,CAAC;IASjD,cAAc,CAClB,KAAK,EAAE,yCAAyC,GAC/C,OAAO,CAAC,2CAA2C,CAAC;YAQzC,gBAAgB;IA2B9B,uFAAuF;YACzE,gBAAgB;YAwBhB,iBAAiB;YAQjB,qBAAqB;YAgCrB,gBAAgB;IA2F9B,0EAA0E;YAC5D,aAAa;YAsBb,eAAe;IA0C7B,OAAO,CAAC,eAAe;YAkBT,eAAe;YAef,WAAW;YAkBX,eAAe;CAW9B"}
@@ -10,6 +10,10 @@ export declare class PgActionRunStorage implements ActionRunStorage {
10
10
  projectId: string;
11
11
  id: string;
12
12
  }): Promise<ActionRunRecord | null>;
13
+ getByExecutionIds(params: {
14
+ readonly projectId: string;
15
+ readonly executionIds: readonly string[];
16
+ }): Promise<readonly ActionRunRecord[]>;
13
17
  list(input: ListActionRunsInput): Promise<ListActionRunsResult>;
14
18
  }
15
19
  //# sourceMappingURL=pg-action-run-storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pg-action-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-action-run-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAIV,eAAe,EAEf,gBAAgB,EAEhB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAErE,qBAAa,kBAAmB,YAAW,gBAAgB;IAEvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,gBAAgB;IAGzC,MAAM,CAAC,KAAK,EAAE,oBA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AE,CAAC;IAoBjC,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAiHtE"}
@@ -0,0 +1,22 @@
1
+ import type { ActivityCalendarInput, ActivityDay, ActivityPeriodInput, ActivitySessionVisits, ActivityStorage, ActivitySummary, ActivityUsersPage, ActivityVisitsPage, AppendActivityInput, AppendActivityResult, ListActivitySessionVisitsInput, ListActivityUsersInput, ListActivityVisitsInput, ReadActivityVisitInput, StoredActivityVisitPage } from "@sixb/core/storage";
2
+ import { type PgStoreClient } from "./transactions";
3
+ /** PostgreSQL activity. An advisory lock per session serializes its batches across replicas. */
4
+ export declare class PgActivityStorage implements ActivityStorage {
5
+ private readonly sql;
6
+ constructor(sql: PgStoreClient);
7
+ append(input: AppendActivityInput): Promise<AppendActivityResult>;
8
+ list(input: ListActivityVisitsInput): Promise<ActivityVisitsPage>;
9
+ users(input: ListActivityUsersInput): Promise<ActivityUsersPage>;
10
+ summarize(input: ActivityPeriodInput): Promise<ActivitySummary>;
11
+ calendar(input: ActivityCalendarInput): Promise<readonly ActivityDay[]>;
12
+ read(input: ReadActivityVisitInput): Promise<StoredActivityVisitPage | null>;
13
+ sessionVisits(input: ListActivitySessionVisitsInput): Promise<readonly ActivitySessionVisits[]>;
14
+ /**
15
+ * The visits `v` active in the period, and only the account's when one is asked for. A visit
16
+ * lasts less than a day, so it started at most a day before the period: that bounds the index
17
+ * range.
18
+ */
19
+ private overlapping;
20
+ private visitColumns;
21
+ }
22
+ //# sourceMappingURL=pg-activity-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-activity-storage.d.ts","sourceRoot":"","sources":["../src/pg-activity-storage.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,qBAAqB,EAErB,WAAW,EAGX,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,iBAAiB,EAEjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAoB,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAKvF,gGAAgG;AAChG,qBAAa,iBAAkB,YAAW,eAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA4FjE,IAAI,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoBjE,KAAK,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiChE,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAwB/D,QAAQ,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC;IA4BvE,IAAI,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IA4C5E,aAAa,CACjB,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,SAAS,qBAAqB,EAAE,CAAC;IAoC5C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,YAAY;CAMrB"}
@@ -0,0 +1,19 @@
1
+ import type { ArtifactFrameGrantRecord, ArtifactRecord, ArtifactStorage, ArtifactVersionRecord, CreateArtifactInput, DeleteArtifactInput, DeleteArtifactVersionsByOriginInput, DeleteExpiredArtifactFrameGrantsInput, FindArtifactFrameGrantInput, GetArtifactInput, GetArtifactVersionInput, ListArtifactsInput, ListArtifactsResult, ListArtifactVersionsInput, ListArtifactVersionsResult, ListReferencingVersionsInput, PublishArtifactVersionInput, PublishedArtifactVersion } from "@sixb/core/storage";
2
+ import { type PgStoreClient } from "./transactions";
3
+ export declare class PgArtifactStorage implements ArtifactStorage {
4
+ private readonly sql;
5
+ constructor(sql: PgStoreClient);
6
+ create(input: CreateArtifactInput): Promise<PublishedArtifactVersion>;
7
+ publish(input: PublishArtifactVersionInput): Promise<PublishedArtifactVersion>;
8
+ get(input: GetArtifactInput): Promise<ArtifactRecord | null>;
9
+ list(input: ListArtifactsInput): Promise<ListArtifactsResult>;
10
+ getVersion(input: GetArtifactVersionInput): Promise<ArtifactVersionRecord | null>;
11
+ listVersions(input: ListArtifactVersionsInput): Promise<ListArtifactVersionsResult>;
12
+ listReferencingVersions(input: ListReferencingVersionsInput): Promise<ArtifactVersionRecord[]>;
13
+ createFrameGrant(record: ArtifactFrameGrantRecord): Promise<void>;
14
+ findFrameGrant(input: FindArtifactFrameGrantInput): Promise<ArtifactFrameGrantRecord | null>;
15
+ deleteExpiredFrameGrants(input: DeleteExpiredArtifactFrameGrantsInput): Promise<number>;
16
+ delete(input: DeleteArtifactInput): Promise<boolean>;
17
+ deleteVersionsByOrigin(input: DeleteArtifactVersionsByOriginInput): Promise<number>;
18
+ }
19
+ //# sourceMappingURL=pg-artifact-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-artifact-storage.d.ts","sourceRoot":"","sources":["../src/pg-artifact-storage.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,wBAAwB,EACxB,cAAc,EACd,eAAe,EAEf,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,mCAAmC,EACnC,qCAAqC,EACrC,2BAA2B,EAC3B,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,wBAAwB,EACzB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAyBrE,qBAAa,iBAAkB,YAAW,eAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAsBrE,OAAO,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA+B9E,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAQ5D,IAAI,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuC7D,UAAU,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IASjF,YAAY,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAoBnF,uBAAuB,CAC3B,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAkB7B,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAejE,cAAc,CAClB,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;IAQrC,wBAAwB,CAAC,KAAK,EAAE,qCAAqC,GAAG,OAAO,CAAC,MAAM,CAAC;IAavF,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD,sBAAsB,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,MAAM,CAAC;CAgD1F"}
@@ -1,5 +1,5 @@
1
1
  import { type ExecutionStorageRow } from "@sixb/core/internal/execution-storage";
2
- import type { CreateExecutionInput, ExecutionRecord, ExecutionStorage, ShareSessionStorage } from "@sixb/core/storage";
2
+ import type { CreateExecutionInput, ExecutionRecord, ExecutionStorage, ListSessionExecutionsInput, SessionExecutions, ShareSessionStorage } from "@sixb/core/storage";
3
3
  import type { PgAuthStorage } from "./auth-storage";
4
4
  import type { PgStoreClient } from "./transactions";
5
5
  export declare class PgExecutionStorage implements ExecutionStorage {
@@ -12,6 +12,7 @@ export declare class PgExecutionStorage implements ExecutionStorage {
12
12
  readonly projectId: string;
13
13
  readonly id: string;
14
14
  }): Promise<ExecutionRecord | null>;
15
+ listBySession(input: ListSessionExecutionsInput): Promise<SessionExecutions>;
15
16
  }
16
17
  /** An `executions` row as its record, for any store that reads executions alongside its own rows. */
17
18
  export declare function pgExecutionRecord(row: PgExecutionRow): ExecutionRecord;
@@ -1 +1 @@
1
- {"version":3,"file":"pg-execution-storage.d.ts","sourceRoot":"","sources":["../src/pg-execution-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,qBAAa,kBAAmB,YAAW,gBAAgB;IAEvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAFb,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,aAAa,EACnB,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC;IAGhE,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IA8E7D,OAAO,CAAC,MAAM,EAAE;QACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KACpB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;CAQpC;AAED,qGAAqG;AACrG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,G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AQ,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM,CAAA;CACnC"}
@@ -17,6 +17,10 @@ export declare class PgWorkflowRunStorage implements WorkflowRunStorage {
17
17
  projectId: string;
18
18
  id: string;
19
19
  }): Promise<WorkflowRunRecord | null>;
20
+ getByExecutionIds(params: {
21
+ readonly projectId: string;
22
+ readonly executionIds: readonly string[];
23
+ }): Promise<readonly WorkflowRunRecord[]>;
20
24
  list(input: ListWorkflowRunsInput): Promise<ListWorkflowRunsResult>;
21
25
  listLatestByWorkflowIds(input: ListLatestWorkflowRunsInput): Promise<ListLatestWorkflowRunsResult>;
22
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pg-workflow-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-workflow-run-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,+BAA+B,EAC/B,kDAAkD,EAClD,yCAAyC,EACzC,+BAA+B,EAC/B,gBAAgB,EAChB,+BAA+B,EAC/B,0BAA0B,EAC1B,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,gCAAgC,EAChC,uBAAuB,EACvB,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAU3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAErE,qBAAa,oBAAqB,YAAW,kBAAkB;IAK3D,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAL7B,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAA;IACxC,QAAQ,CAA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I,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,+BAA+B,CAAC;CAsB5F;AAED,qBAAa,wBAAyB,YAAW,sBAAsB;IACzD,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,KAAK,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAwEvE,MAAM,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgDzE,IAAI,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAoCrE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IASzF,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;CA0DlF"}
@@ -1,10 +1,11 @@
1
- import type { CreateShareGrantInput, GetShareGrantByIdInput, ListShareGrantsInput, ListShareGrantsResult, RevokeShareGrantInput, ShareGrantRecord, ShareGrantStorage } from "@sixb/core/storage";
1
+ import type { CreateShareGrantInput, GetShareGrantByIdInput, GetShareGrantsByIdsInput, ListShareGrantsInput, ListShareGrantsResult, RevokeShareGrantInput, ShareGrantRecord, ShareGrantStorage } from "@sixb/core/storage";
2
2
  import type { PgStoreClient } from "./transactions";
3
3
  export declare class PgShareGrantStorage implements ShareGrantStorage {
4
4
  private readonly sql;
5
5
  constructor(sql: PgStoreClient);
6
6
  create(input: CreateShareGrantInput): Promise<ShareGrantRecord>;
7
7
  getById(input: GetShareGrantByIdInput): Promise<ShareGrantRecord | null>;
8
+ getByIds(input: GetShareGrantsByIdsInput): Promise<readonly ShareGrantRecord[]>;
8
9
  list(input: ListShareGrantsInput): Promise<ListShareGrantsResult>;
9
10
  revoke(input: RevokeShareGrantInput): Promise<ShareGrantRecord | null>;
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"share-grant-storage.d.ts","sourceRoot":"","sources":["../src/share-grant-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,qBAAa,mBAAoB,YAAW,iBAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqD/D,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUxE,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA8CjE,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAqB7E"}
1
+ {"version":3,"file":"share-grant-storage.d.ts","sourceRoot":"","sources":["../src/share-grant-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,qBAAa,mBAAoB,YAAW,iBAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqD/D,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUxE,QAAQ,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC;IAoB/E,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA8CjE,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAqB7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/pg",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
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.1.20"
43
+ "@sixb/core": "0.1.21"
44
44
  },
45
45
  "devDependencies": {
46
- "@sixb/core": "0.1.20",
46
+ "@sixb/core": "0.1.21",
47
47
  "@types/bun": "latest",
48
48
  "typescript": "^5.7.0"
49
49
  },
@@ -108,6 +108,29 @@ export class PgAgentThreadStore implements AgentThreadStore {
108
108
  return row ? rowToThreadRecord(row) : null
109
109
  }
110
110
 
111
+ async getByIds(params: {
112
+ readonly projectId: string
113
+ readonly ids: readonly string[]
114
+ }): Promise<readonly AgentThreadRecord[]> {
115
+ const ids = [...new Set(params.ids)]
116
+ if (ids.length === 0) {
117
+ return []
118
+ }
119
+
120
+ const rows = await this.sql<AgentThreadRow[]>`
121
+ SELECT *
122
+ FROM agent_threads
123
+ WHERE project_id = ${params.projectId}
124
+ AND id = ANY(${this.sql.array(ids)}::text[])
125
+ `
126
+
127
+ const byId = new Map(rows.map((row) => [row.id, row]))
128
+ return ids.flatMap((id) => {
129
+ const row = byId.get(id)
130
+ return row ? [rowToThreadRecord(row)] : []
131
+ })
132
+ }
133
+
111
134
  async list(input: ListAgentThreadsInput): Promise<ListAgentThreadsResult> {
112
135
  if (input.statuses !== undefined && input.statuses.length === 0) {
113
136
  return { threads: [], hasMore: false, total: 0 }
@@ -1,6 +1,8 @@
1
1
  import type {
2
2
  AuthSessionStore,
3
3
  CreateAuthSessionInput,
4
+ ListAuthSessionsInput,
5
+ ListAuthSessionsResult,
4
6
  RotateSessionRefreshTokenResult,
5
7
  SessionRecord,
6
8
  } from "@sixb/core/storage"
@@ -56,6 +58,24 @@ export class PgAuthSessionStore implements AuthSessionStore {
56
58
  return rows.map(rowToSessionRecord)
57
59
  }
58
60
 
61
+ async listByUserId(params: ListAuthSessionsInput): Promise<ListAuthSessionsResult> {
62
+ const rows = (await this.sql`
63
+ SELECT *
64
+ FROM auth_sessions
65
+ WHERE project_id = ${params.projectId}
66
+ AND user_id = ${params.userId}
67
+ ${params.before ? this.sql`AND created_at <= ${params.before.createdAt}` : this.sql``}
68
+ ORDER BY created_at DESC, id DESC
69
+ LIMIT ${params.limit + 1}
70
+ OFFSET ${params.before?.skip ?? 0}
71
+ `) as PgAuthSessionRow[]
72
+
73
+ return {
74
+ sessions: rows.slice(0, params.limit).map(rowToSessionRecord),
75
+ hasMore: rows.length > params.limit,
76
+ }
77
+ }
78
+
59
79
  async findValidByTokenHash(params: {
60
80
  readonly projectId: string
61
81
  readonly id: string
package/src/index.ts CHANGED
@@ -49,9 +49,11 @@ export type { PgObjectTextCountIndex } from "./objects/text-count-index"
49
49
 
50
50
  import { PgOntologyStorage, type PgOntologyTransactionContext } from "./ontology-storage"
51
51
  import { PgActionRunStorage } from "./pg-action-run-storage"
52
+ import { PgActivityStorage } from "./pg-activity-storage"
52
53
  import { PgAiCostStorage } from "./pg-ai-cost-storage"
53
54
  import { PgAiLimitStorage } from "./pg-ai-limit-storage"
54
55
  import { PgAiUsageStorage } from "./pg-ai-usage-storage"
56
+ import { PgArtifactStorage } from "./pg-artifact-storage"
55
57
  import { createPgClient, type SQL, type SQLClient } from "./pg-client"
56
58
  import { PgExecutionStorage } from "./pg-execution-storage"
57
59
  import { PgFileDownloadGrantStorage } from "./pg-file-download-grant-storage"
@@ -166,6 +168,7 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
166
168
  readonly auth: PgAuthStorage
167
169
  readonly executions: PgExecutionStorage
168
170
  readonly agents: PgAgentStorage
171
+ readonly artifacts: PgArtifactStorage
169
172
  readonly aiUsage: AiUsageStorage
170
173
  readonly aiCosts: AiCostStorage
171
174
  readonly aiLimits: AiLimitStorage
@@ -183,6 +186,7 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
183
186
  readonly shareSessions: PgShareSessionStorage
184
187
  readonly fileUploadSessions: PgFileUploadSessionStorage
185
188
  readonly fileDownloadGrants: PgFileDownloadGrantStorage
189
+ readonly activity: PgActivityStorage
186
190
  readonly migrators: readonly StorageMigrator[]
187
191
 
188
192
  private readonly sql: SQL
@@ -252,6 +256,7 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
252
256
  this.auth = createAuthOperationScope(stores.auth, scope)
253
257
  this.executions = createOperationScopedFacade(stores.executions, scope)
254
258
  this.agents = createAgentOperationScope(stores.agents, scope)
259
+ this.artifacts = createOperationScopedFacade(stores.artifacts, scope)
255
260
  this.aiUsage = createOperationScopedFacade(stores.aiUsage, scope)
256
261
  this.aiCosts = createOperationScopedFacade(stores.aiCosts, scope)
257
262
  this.aiLimits = createOperationScopedFacade(stores.aiLimits, scope)
@@ -269,6 +274,7 @@ export class PostgresStorage implements MigrationCapableStorage, QueryPreparatio
269
274
  this.shareSessions = createOperationScopedFacade(stores.shareSessions, scope)
270
275
  this.fileUploadSessions = createOperationScopedFacade(stores.fileUploadSessions, scope)
271
276
  this.fileDownloadGrants = createOperationScopedFacade(stores.fileDownloadGrants, scope)
277
+ this.activity = createOperationScopedFacade(stores.activity, scope)
272
278
  registerPostgresStorageTestingAdapter(this, (durationMs) =>
273
279
  stores.connectorConnections.advanceTimeForTesting(durationMs)
274
280
  )
@@ -414,6 +420,7 @@ function createPostgresStores(
414
420
  auth,
415
421
  executions,
416
422
  agents: new PgAgentStorage({ sql, executions }),
423
+ artifacts: new PgArtifactStorage(sql),
417
424
  aiUsage: new PgAiUsageStorage(sql),
418
425
  aiCosts: new PgAiCostStorage(sql),
419
426
  aiLimits: new PgAiLimitStorage(sql),
@@ -431,6 +438,7 @@ function createPostgresStores(
431
438
  shareSessions,
432
439
  fileUploadSessions: new PgFileUploadSessionStorage(sql),
433
440
  fileDownloadGrants: new PgFileDownloadGrantStorage(sql),
441
+ activity: new PgActivityStorage(sql),
434
442
  }
435
443
  }
436
444
 
@@ -440,6 +448,7 @@ interface PostgresStoreSet {
440
448
  readonly auth: PgAuthStorage
441
449
  readonly executions: PgExecutionStorage
442
450
  readonly agents: PgAgentStorage
451
+ readonly artifacts: PgArtifactStorage
443
452
  readonly aiUsage: PgAiUsageStorage
444
453
  readonly aiCosts: PgAiCostStorage
445
454
  readonly aiLimits: PgAiLimitStorage
@@ -457,6 +466,7 @@ interface PostgresStoreSet {
457
466
  readonly shareSessions: PgShareSessionStorage
458
467
  readonly fileUploadSessions: PgFileUploadSessionStorage
459
468
  readonly fileDownloadGrants: PgFileDownloadGrantStorage
469
+ readonly activity: PgActivityStorage
460
470
  }
461
471
 
462
472
  function resolveTimeoutMillis(value: number | undefined, label: string): number | undefined {
@@ -0,0 +1,67 @@
1
+ -- Artifacts: versioned documents, sheets, decks, and files. An artifact's kind never
2
+ -- changes. Versions take `next_version`, which only grows, so a number is never reused after its
3
+ -- version is deleted.
4
+ CREATE TABLE artifacts (
5
+ project_id TEXT NOT NULL CHECK (length(trim(project_id)) > 0),
6
+ id TEXT NOT NULL CHECK (length(trim(id)) > 0),
7
+ kind TEXT NOT NULL CHECK (kind IN ('document', 'sheet', 'slides', 'file')),
8
+ title TEXT NOT NULL CHECK (length(trim(title)) > 0),
9
+ owner_principal_type TEXT NOT NULL
10
+ CHECK (owner_principal_type IN ('user', 'serviceAccount', 'system')),
11
+ owner_principal_id TEXT NOT NULL CHECK (length(owner_principal_id) > 0),
12
+ latest_version INTEGER NOT NULL CHECK (latest_version > 0),
13
+ next_version INTEGER NOT NULL CHECK (next_version > latest_version),
14
+ created_at TIMESTAMPTZ NOT NULL,
15
+ updated_at TIMESTAMPTZ NOT NULL,
16
+ PRIMARY KEY (project_id, id)
17
+ );
18
+
19
+ CREATE INDEX idx_artifacts_project_updated ON artifacts (project_id, updated_at DESC, id);
20
+ CREATE INDEX idx_artifacts_owner_updated
21
+ ON artifacts (project_id, owner_principal_type, owner_principal_id, updated_at DESC, id);
22
+
23
+ -- `refs`, not `references`: that word is reserved in SQL.
24
+ CREATE TABLE artifact_versions (
25
+ project_id TEXT NOT NULL,
26
+ artifact_id TEXT NOT NULL,
27
+ version INTEGER NOT NULL CHECK (version > 0),
28
+ title TEXT NOT NULL CHECK (length(trim(title)) > 0),
29
+ entry TEXT NOT NULL CHECK (length(entry) > 0),
30
+ files JSONB NOT NULL CHECK (jsonb_typeof(files) = 'array'),
31
+ outline JSONB NOT NULL CHECK (jsonb_typeof(outline) = 'object'),
32
+ refs JSONB NOT NULL CHECK (jsonb_typeof(refs) = 'array'),
33
+ author_principal_type TEXT NOT NULL
34
+ CHECK (author_principal_type IN ('user', 'serviceAccount', 'system')),
35
+ author_principal_id TEXT NOT NULL CHECK (length(author_principal_id) > 0),
36
+ origin_thread_id TEXT,
37
+ origin_run_id TEXT,
38
+ created_at TIMESTAMPTZ NOT NULL,
39
+ PRIMARY KEY (project_id, artifact_id, version),
40
+ FOREIGN KEY (project_id, artifact_id) REFERENCES artifacts (project_id, id) ON DELETE CASCADE,
41
+ CHECK ((origin_thread_id IS NULL) = (origin_run_id IS NULL))
42
+ );
43
+
44
+ CREATE INDEX idx_artifact_versions_origin_run
45
+ ON artifact_versions (project_id, origin_run_id) WHERE origin_run_id IS NOT NULL;
46
+ CREATE INDEX idx_artifact_versions_origin_thread
47
+ ON artifact_versions (project_id, origin_thread_id, artifact_id) WHERE origin_thread_id IS NOT NULL;
48
+
49
+ -- Short-lived links that a sandboxed frame loads a deck's files through. Only the SHA-256 of each
50
+ -- link's token is stored. `targets` is what the frame may show from other artifacts, decided for
51
+ -- its reader when the link was issued: a JSON array of { address, artifactId, version }.
52
+ CREATE TABLE artifact_frame_grants (
53
+ project_id TEXT NOT NULL,
54
+ token_hash TEXT NOT NULL CHECK (token_hash ~ '^[0-9a-f]{64}$'),
55
+ artifact_id TEXT NOT NULL,
56
+ version INTEGER NOT NULL CHECK (version > 0),
57
+ targets JSONB NOT NULL CHECK (jsonb_typeof(targets) = 'array'),
58
+ created_at TIMESTAMPTZ NOT NULL,
59
+ expires_at TIMESTAMPTZ NOT NULL,
60
+ PRIMARY KEY (project_id, token_hash),
61
+ FOREIGN KEY (project_id, artifact_id) REFERENCES artifacts (project_id, id) ON DELETE CASCADE,
62
+ CHECK (expires_at > created_at)
63
+ );
64
+
65
+ CREATE INDEX idx_artifact_frame_grants_expiry ON artifact_frame_grants (project_id, expires_at);
66
+ -- Deleting an artifact cascades here, and Postgres does not index a foreign key by itself.
67
+ CREATE INDEX idx_artifact_frame_grants_artifact ON artifact_frame_grants (project_id, artifact_id);
@@ -0,0 +1,14 @@
1
+ -- The Agent delivers files by publishing artifacts, so a run no longer collects an output
2
+ -- directory or reports on it. Stored `output_*` diagnostics go; a run left with none stores none.
3
+ UPDATE agent_runs
4
+ SET diagnostics = (
5
+ SELECT jsonb_agg(item.value ORDER BY item.position)
6
+ FROM jsonb_array_elements(agent_runs.diagnostics) WITH ORDINALITY AS item(value, position)
7
+ WHERE item.value->>'code' NOT LIKE 'output\_%'
8
+ )
9
+ WHERE jsonb_typeof(diagnostics) = 'array'
10
+ AND EXISTS (
11
+ SELECT 1
12
+ FROM jsonb_array_elements(agent_runs.diagnostics) AS item(value)
13
+ WHERE item.value->>'code' LIKE 'output\_%'
14
+ );
@@ -0,0 +1,5 @@
1
+ -- A plan's work is analyzed whenever a stream has staged enough of it, and most of that ANALYZE
2
+ -- went into the statistics of `payload`, which no query reads: the plan queries filter on the
3
+ -- typed columns and only extract values from `payload`, and an extracted value has no statistics.
4
+ -- A query that filters `payload` itself (`@>`, `?`) would need them back.
5
+ ALTER TABLE ontology_replacement_plan_work ALTER COLUMN payload SET STATISTICS 0;
@@ -0,0 +1,61 @@
1
+ -- App activity: one source per verified session, the visits it opened, and their page views.
2
+ -- Foreground activity moves a visit's `last_seen_at` and stores no row, unless it opens a visit.
3
+ -- A session id names an `auth_sessions` row for a user and a `share_sessions` row for a share; it
4
+ -- is not a secret, and no foreign key holds it, so history outlives its sessions. Ids compare
5
+ -- byte by byte, as the other providers sort them.
6
+ CREATE TABLE activity_sources (
7
+ project_id TEXT NOT NULL,
8
+ actor_type TEXT NOT NULL CHECK (actor_type IN ('user', 'share')),
9
+ session_id TEXT NOT NULL CHECK (length(session_id) > 0),
10
+ visit_id TEXT NOT NULL,
11
+ last_seen_at TIMESTAMPTZ NOT NULL,
12
+ sequence INTEGER NOT NULL CHECK (sequence >= 0),
13
+ window_start TIMESTAMPTZ NOT NULL,
14
+ window_count INTEGER NOT NULL CHECK (window_count >= 0),
15
+ PRIMARY KEY (project_id, actor_type, session_id)
16
+ );
17
+
18
+ CREATE TABLE activity_visits (
19
+ project_id TEXT NOT NULL,
20
+ id TEXT COLLATE "C" NOT NULL,
21
+ actor_type TEXT NOT NULL CHECK (actor_type IN ('user', 'share')),
22
+ user_id TEXT COLLATE "C",
23
+ grant_id TEXT,
24
+ session_id TEXT NOT NULL CHECK (length(session_id) > 0),
25
+ started_at TIMESTAMPTZ NOT NULL,
26
+ last_seen_at TIMESTAMPTZ NOT NULL CHECK (last_seen_at >= started_at),
27
+ page_views INTEGER NOT NULL CHECK (page_views >= 0),
28
+ attribution JSONB CHECK (attribution IS NULL OR jsonb_typeof(attribution) = 'object'),
29
+ PRIMARY KEY (project_id, id),
30
+ CHECK (
31
+ (actor_type = 'user' AND user_id IS NOT NULL AND grant_id IS NULL)
32
+ OR (actor_type = 'share' AND user_id IS NULL AND grant_id IS NOT NULL)
33
+ )
34
+ );
35
+
36
+ -- A period reads the visits it overlaps. A visit lasts less than a day, so they started in
37
+ -- `[from - 1 day, to)`: both period indexes bound `started_at` on both sides. `last_seen_at` is
38
+ -- left out of every index, so the update each batch makes touches none of them. The user index
39
+ -- also serves deleting one user's history.
40
+ CREATE INDEX idx_activity_visits_started
41
+ ON activity_visits (project_id, started_at, id);
42
+ CREATE INDEX idx_activity_visits_user
43
+ ON activity_visits (project_id, user_id, started_at, id);
44
+ -- A session's visits, to join them with the session and the executions it authorized.
45
+ CREATE INDEX idx_activity_visits_session
46
+ ON activity_visits (project_id, actor_type, session_id);
47
+
48
+ CREATE TABLE activity_page_views (
49
+ project_id TEXT NOT NULL,
50
+ visit_id TEXT COLLATE "C" NOT NULL,
51
+ sequence INTEGER NOT NULL CHECK (sequence > 0),
52
+ id TEXT NOT NULL,
53
+ route TEXT NOT NULL,
54
+ received_at TIMESTAMPTZ NOT NULL,
55
+ attribution JSONB CHECK (attribution IS NULL OR jsonb_typeof(attribution) = 'object'),
56
+ PRIMARY KEY (project_id, visit_id, sequence),
57
+ FOREIGN KEY (project_id, visit_id) REFERENCES activity_visits (project_id, id) ON DELETE CASCADE
58
+ );
59
+
60
+ -- Finds a retried page view by the id its browser chose.
61
+ CREATE INDEX idx_activity_page_views_id ON activity_page_views (project_id, id);
@@ -0,0 +1,15 @@
1
+ -- A visit's timeline reads what its session started: the roots it authorized in a window, then
2
+ -- everything they caused. A signed-in session is the credential of its roots, a shared link's
3
+ -- session their delegation; a child names its parent. Agent executions copy their parent's
4
+ -- session: the root indexes hold only executions without a parent, so they never see those, and
5
+ -- end with `id` so the root read's order needs no sort. A user's connection history reads
6
+ -- `idx_auth_sessions_user_created`, which already exists.
7
+ CREATE INDEX idx_executions_session_roots
8
+ ON executions (project_id, authority_session_id, created_at, id)
9
+ WHERE authority_session_id IS NOT NULL AND parent_execution_id IS NULL;
10
+ CREATE INDEX idx_executions_delegation_roots
11
+ ON executions (project_id, authority_delegation_session_id, created_at, id)
12
+ WHERE authority_delegation_session_id IS NOT NULL AND parent_execution_id IS NULL;
13
+ CREATE INDEX idx_executions_parent
14
+ ON executions (project_id, parent_execution_id)
15
+ WHERE parent_execution_id IS NOT NULL;
@@ -0,0 +1,20 @@
1
+ -- Interactions an app marks, such as a button: their name and route, never a value. They share
2
+ -- the visit's sequence with its page views, so a visit reads both in the order they happened, and
3
+ -- cascade with the visit, which counts them as it counts its page views.
4
+ ALTER TABLE activity_visits
5
+ ADD COLUMN interactions INTEGER NOT NULL DEFAULT 0 CHECK (interactions >= 0);
6
+
7
+ CREATE TABLE activity_interactions (
8
+ project_id TEXT NOT NULL,
9
+ visit_id TEXT COLLATE "C" NOT NULL,
10
+ sequence INTEGER NOT NULL CHECK (sequence > 0),
11
+ id TEXT NOT NULL,
12
+ name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 100),
13
+ route TEXT NOT NULL,
14
+ received_at TIMESTAMPTZ NOT NULL,
15
+ PRIMARY KEY (project_id, visit_id, sequence),
16
+ FOREIGN KEY (project_id, visit_id) REFERENCES activity_visits (project_id, id) ON DELETE CASCADE
17
+ );
18
+
19
+ -- Finds a retried interaction by the id its browser chose.
20
+ CREATE INDEX idx_activity_interactions_id ON activity_interactions (project_id, id);
package/src/migrations.ts CHANGED
@@ -433,6 +433,12 @@ export const postgresStorageMigrations = defineMigrations<PostgresMigrationConte
433
433
  pgSql("060-drained-source-versions", drainedSourceVersionsSql),
434
434
  pgSql("061-terminal-action-runs", terminalActionRunsSql),
435
435
  pgSql("062-drop-auth-audience", dropAuthAudienceSql),
436
+ pgSql("063-artifacts", artifactsSql),
437
+ pgSql("064-drop-output-diagnostics", dropOutputDiagnosticsSql),
438
+ pgSql("065-plan-work-payload-statistics", planWorkPayloadStatisticsSql),
439
+ pgSql("066-activity", activitySql),
440
+ pgSql("067-activity-timeline", activityTimelineSql),
441
+ pgSql("068-activity-interactions", activityInteractionsSql),
436
442
  ],
437
443
  })
438
444
 
@@ -463,3 +469,15 @@ import drainedSourceVersionsSql from "./migrations/060-drained-source-versions.s
463
469
  }
464
470
  import terminalActionRunsSql from "./migrations/061-terminal-action-runs.sql" with { type: "text" }
465
471
  import dropAuthAudienceSql from "./migrations/062-drop-auth-audience.sql" with { type: "text" }
472
+ import artifactsSql from "./migrations/063-artifacts.sql" with { type: "text" }
473
+ import dropOutputDiagnosticsSql from "./migrations/064-drop-output-diagnostics.sql" with {
474
+ type: "text",
475
+ }
476
+ import planWorkPayloadStatisticsSql from "./migrations/065-plan-work-payload-statistics.sql" with {
477
+ type: "text",
478
+ }
479
+ import activitySql from "./migrations/066-activity.sql" with { type: "text" }
480
+ import activityTimelineSql from "./migrations/067-activity-timeline.sql" with { type: "text" }
481
+ import activityInteractionsSql from "./migrations/068-activity-interactions.sql" with {
482
+ type: "text",
483
+ }