@opengeni/db 0.22.2 → 0.23.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.
Files changed (48) hide show
  1. package/dist/{chunk-CYGFLLMN.js → chunk-3UCHDMKG.js} +656 -282
  2. package/dist/chunk-3UCHDMKG.js.map +1 -0
  3. package/dist/{chunk-BNGEN5QZ.js → chunk-L6ADMZHE.js} +24 -2
  4. package/dist/chunk-L6ADMZHE.js.map +1 -0
  5. package/dist/index.d.ts +39 -3
  6. package/dist/index.js +7009 -3882
  7. package/dist/index.js.map +1 -1
  8. package/dist/provision-roles.js +1 -1
  9. package/dist/runtime-posture.d.ts +3 -3
  10. package/dist/schema.d.ts +1416 -92
  11. package/dist/schema.js +11 -1
  12. package/dist/session-control.d.ts +7 -1
  13. package/dist/session-queue-commands.d.ts +8 -0
  14. package/dist/session-realtime-context.d.ts +56 -0
  15. package/dist/session-realtime-ledger.d.ts +188 -0
  16. package/dist/session-realtime-mirror.d.ts +30 -0
  17. package/dist/session-realtime-state.d.ts +2 -0
  18. package/dist/session-realtime-terminal.d.ts +40 -0
  19. package/dist/session-realtime.d.ts +59 -0
  20. package/dist/workspace-instruction-policies-schema.d.ts +239 -0
  21. package/dist/workspace-instruction-policies.d.ts +44 -0
  22. package/drizzle/0156_slack_reaction_trigger.sql +49 -0
  23. package/drizzle/0157_session_policy_role_snapshots.sql +1146 -0
  24. package/drizzle/0158_session_realtime_mode.sql +88 -0
  25. package/drizzle/0159_session_realtime_ledger.sql +198 -0
  26. package/drizzle/0160_session_realtime_delegation_terminal.sql +38 -0
  27. package/drizzle/0161_session_realtime_context_projection.sql +82 -0
  28. package/drizzle/0162_session_realtime_connection_promotion.sql +53 -0
  29. package/drizzle/0163_session_realtime_delegation_progress.sql +35 -0
  30. package/drizzle/0164_session_realtime_models.sql +28 -0
  31. package/package.json +4 -4
  32. package/src/index.ts +614 -78
  33. package/src/preference-registry.ts +11 -6
  34. package/src/provision-roles.ts +12 -0
  35. package/src/runtime-posture.ts +10 -0
  36. package/src/schema.ts +400 -43
  37. package/src/session-control.ts +596 -21
  38. package/src/session-queue-commands.ts +76 -7
  39. package/src/session-realtime-context.ts +393 -0
  40. package/src/session-realtime-ledger.ts +1790 -0
  41. package/src/session-realtime-mirror.ts +160 -0
  42. package/src/session-realtime-state.ts +25 -0
  43. package/src/session-realtime-terminal.ts +306 -0
  44. package/src/session-realtime.ts +611 -0
  45. package/src/workspace-instruction-policies-schema.ts +41 -0
  46. package/src/workspace-instruction-policies.ts +131 -2
  47. package/dist/chunk-BNGEN5QZ.js.map +0 -1
  48. package/dist/chunk-CYGFLLMN.js.map +0 -1
@@ -733,3 +733,242 @@ export declare const workspaceInstructionPolicyActivationEvents: import("drizzle
733
733
  };
734
734
  dialect: 'pg';
735
735
  }>;
736
+ export declare const workspaceInstructionPolicySnapshots: import("drizzle-orm/pg-core").PgTableWithColumns<{
737
+ name: "workspace_instruction_policy_snapshots";
738
+ schema: undefined;
739
+ columns: {
740
+ id: import("drizzle-orm/pg-core").PgColumn<{
741
+ name: "id";
742
+ tableName: "workspace_instruction_policy_snapshots";
743
+ dataType: "string";
744
+ columnType: "PgUUID";
745
+ data: string;
746
+ driverParam: string;
747
+ notNull: true;
748
+ hasDefault: true;
749
+ isPrimaryKey: true;
750
+ isAutoincrement: false;
751
+ hasRuntimeDefault: false;
752
+ enumValues: undefined;
753
+ baseColumn: never;
754
+ identity: undefined;
755
+ generated: undefined;
756
+ }, {}, {}>;
757
+ accountId: import("drizzle-orm/pg-core").PgColumn<{
758
+ name: "account_id";
759
+ tableName: "workspace_instruction_policy_snapshots";
760
+ dataType: "string";
761
+ columnType: "PgUUID";
762
+ data: string;
763
+ driverParam: string;
764
+ notNull: true;
765
+ hasDefault: false;
766
+ isPrimaryKey: false;
767
+ isAutoincrement: false;
768
+ hasRuntimeDefault: false;
769
+ enumValues: undefined;
770
+ baseColumn: never;
771
+ identity: undefined;
772
+ generated: undefined;
773
+ }, {}, {}>;
774
+ workspaceId: import("drizzle-orm/pg-core").PgColumn<{
775
+ name: "workspace_id";
776
+ tableName: "workspace_instruction_policy_snapshots";
777
+ dataType: "string";
778
+ columnType: "PgUUID";
779
+ data: string;
780
+ driverParam: string;
781
+ notNull: true;
782
+ hasDefault: false;
783
+ isPrimaryKey: false;
784
+ isAutoincrement: false;
785
+ hasRuntimeDefault: false;
786
+ enumValues: undefined;
787
+ baseColumn: never;
788
+ identity: undefined;
789
+ generated: undefined;
790
+ }, {}, {}>;
791
+ sessionId: import("drizzle-orm/pg-core").PgColumn<{
792
+ name: "session_id";
793
+ tableName: "workspace_instruction_policy_snapshots";
794
+ dataType: "string";
795
+ columnType: "PgUUID";
796
+ data: string;
797
+ driverParam: string;
798
+ notNull: true;
799
+ hasDefault: false;
800
+ isPrimaryKey: false;
801
+ isAutoincrement: false;
802
+ hasRuntimeDefault: false;
803
+ enumValues: undefined;
804
+ baseColumn: never;
805
+ identity: undefined;
806
+ generated: undefined;
807
+ }, {}, {}>;
808
+ turnId: import("drizzle-orm/pg-core").PgColumn<{
809
+ name: "turn_id";
810
+ tableName: "workspace_instruction_policy_snapshots";
811
+ dataType: "string";
812
+ columnType: "PgUUID";
813
+ data: string;
814
+ driverParam: string;
815
+ notNull: true;
816
+ hasDefault: false;
817
+ isPrimaryKey: false;
818
+ isAutoincrement: false;
819
+ hasRuntimeDefault: false;
820
+ enumValues: undefined;
821
+ baseColumn: never;
822
+ identity: undefined;
823
+ generated: undefined;
824
+ }, {}, {}>;
825
+ attemptId: import("drizzle-orm/pg-core").PgColumn<{
826
+ name: "attempt_id";
827
+ tableName: "workspace_instruction_policy_snapshots";
828
+ dataType: "string";
829
+ columnType: "PgUUID";
830
+ data: string;
831
+ driverParam: string;
832
+ notNull: true;
833
+ hasDefault: false;
834
+ isPrimaryKey: false;
835
+ isAutoincrement: false;
836
+ hasRuntimeDefault: false;
837
+ enumValues: undefined;
838
+ baseColumn: never;
839
+ identity: undefined;
840
+ generated: undefined;
841
+ }, {}, {}>;
842
+ executionGeneration: import("drizzle-orm/pg-core").PgColumn<{
843
+ name: "execution_generation";
844
+ tableName: "workspace_instruction_policy_snapshots";
845
+ dataType: "number";
846
+ columnType: "PgInteger";
847
+ data: number;
848
+ driverParam: string | number;
849
+ notNull: true;
850
+ hasDefault: false;
851
+ isPrimaryKey: false;
852
+ isAutoincrement: false;
853
+ hasRuntimeDefault: false;
854
+ enumValues: undefined;
855
+ baseColumn: never;
856
+ identity: undefined;
857
+ generated: undefined;
858
+ }, {}, {}>;
859
+ policyRole: import("drizzle-orm/pg-core").PgColumn<{
860
+ name: "policy_role";
861
+ tableName: "workspace_instruction_policy_snapshots";
862
+ dataType: "string";
863
+ columnType: "PgText";
864
+ data: string;
865
+ driverParam: string;
866
+ notNull: false;
867
+ hasDefault: false;
868
+ isPrimaryKey: false;
869
+ isAutoincrement: false;
870
+ hasRuntimeDefault: false;
871
+ enumValues: [string, ...string[]];
872
+ baseColumn: never;
873
+ identity: undefined;
874
+ generated: undefined;
875
+ }, {}, {}>;
876
+ roleSource: import("drizzle-orm/pg-core").PgColumn<{
877
+ name: "role_source";
878
+ tableName: "workspace_instruction_policy_snapshots";
879
+ dataType: "string";
880
+ columnType: "PgText";
881
+ data: string;
882
+ driverParam: string;
883
+ notNull: true;
884
+ hasDefault: false;
885
+ isPrimaryKey: false;
886
+ isAutoincrement: false;
887
+ hasRuntimeDefault: false;
888
+ enumValues: [string, ...string[]];
889
+ baseColumn: never;
890
+ identity: undefined;
891
+ generated: undefined;
892
+ }, {}, {}>;
893
+ entries: import("drizzle-orm/pg-core").PgColumn<{
894
+ name: "entries";
895
+ tableName: "workspace_instruction_policy_snapshots";
896
+ dataType: "json";
897
+ columnType: "PgJsonb";
898
+ data: {
899
+ kind: "charter" | "policy";
900
+ scope: "global" | "role";
901
+ roleKey: string | null;
902
+ revisionId: string;
903
+ revision: number;
904
+ contentHash: string;
905
+ activationVersion: number;
906
+ activatedAt: string;
907
+ provenance: {
908
+ source: "human" | "knowledge_proposal" | "legacy_import" | "onboarding";
909
+ sourceIdHash: string | null;
910
+ };
911
+ }[];
912
+ driverParam: unknown;
913
+ notNull: true;
914
+ hasDefault: false;
915
+ isPrimaryKey: false;
916
+ isAutoincrement: false;
917
+ hasRuntimeDefault: false;
918
+ enumValues: undefined;
919
+ baseColumn: never;
920
+ identity: undefined;
921
+ generated: undefined;
922
+ }, {}, {
923
+ $type: {
924
+ kind: "charter" | "policy";
925
+ scope: "global" | "role";
926
+ roleKey: string | null;
927
+ revisionId: string;
928
+ revision: number;
929
+ contentHash: string;
930
+ activationVersion: number;
931
+ activatedAt: string;
932
+ provenance: {
933
+ source: "human" | "knowledge_proposal" | "legacy_import" | "onboarding";
934
+ sourceIdHash: string | null;
935
+ };
936
+ }[];
937
+ }>;
938
+ entryHash: import("drizzle-orm/pg-core").PgColumn<{
939
+ name: "entry_hash";
940
+ tableName: "workspace_instruction_policy_snapshots";
941
+ dataType: "string";
942
+ columnType: "PgText";
943
+ data: string;
944
+ driverParam: string;
945
+ notNull: true;
946
+ hasDefault: false;
947
+ isPrimaryKey: false;
948
+ isAutoincrement: false;
949
+ hasRuntimeDefault: false;
950
+ enumValues: [string, ...string[]];
951
+ baseColumn: never;
952
+ identity: undefined;
953
+ generated: undefined;
954
+ }, {}, {}>;
955
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
956
+ name: "created_at";
957
+ tableName: "workspace_instruction_policy_snapshots";
958
+ dataType: "date";
959
+ columnType: "PgTimestamp";
960
+ data: Date;
961
+ driverParam: string;
962
+ notNull: true;
963
+ hasDefault: true;
964
+ isPrimaryKey: false;
965
+ isAutoincrement: false;
966
+ hasRuntimeDefault: false;
967
+ enumValues: undefined;
968
+ baseColumn: never;
969
+ identity: undefined;
970
+ generated: undefined;
971
+ }, {}, {}>;
972
+ };
973
+ dialect: 'pg';
974
+ }>;
@@ -29,6 +29,17 @@ export declare class WorkspaceInstructionPolicyLegacyUnavailableError extends Er
29
29
  readonly name = "WorkspaceInstructionPolicyLegacyUnavailableError";
30
30
  constructor();
31
31
  }
32
+ export declare class WorkspaceInstructionPolicySnapshotAuthorityError extends Error {
33
+ readonly name = "WorkspaceInstructionPolicySnapshotAuthorityError";
34
+ }
35
+ export type WorkspaceInstructionPolicyAttemptClaims = {
36
+ accountId: string;
37
+ workspaceId: string;
38
+ sessionId: string;
39
+ turnId: string;
40
+ attemptId: string;
41
+ executionGeneration: number;
42
+ };
32
43
  export declare function createWorkspaceInstructionPolicyDraft(db: Database, input: CallerDraftInput): Promise<WorkspaceInstructionPolicyRevision>;
33
44
  /** Import only the stored legacy override; never materialize a deployment default or activate it. */
34
45
  export declare function importLegacyWorkspaceInstructionPolicyDraft(db: Database, input: {
@@ -61,4 +72,37 @@ export declare function rollbackWorkspaceInstructionPolicyRevision(db: Database,
61
72
  actorSubjectId: string;
62
73
  reason: string;
63
74
  }): Promise<WorkspaceInstructionPolicyActivationResponse>;
75
+ /**
76
+ * Freeze (or replay) the exact active charter/global/role policy set for one
77
+ * accepted attempt, then resolve only those immutable revisions. The snapshot
78
+ * stores bounded descriptors/hashes; full policy text remains in the revision
79
+ * table and cannot be widened by a later head activation.
80
+ */
81
+ export declare function getOrCreateWorkspaceInstructionPolicySnapshot(db: Database, claims: WorkspaceInstructionPolicyAttemptClaims): Promise<{
82
+ id: string;
83
+ workspaceId: string;
84
+ sessionId: string;
85
+ turnId: string;
86
+ attemptId: string;
87
+ executionGeneration: number;
88
+ policyRole: string | null;
89
+ roleSource: "invalid_metadata_fallback" | "metadata_fallback" | "none" | "session_binding";
90
+ entryHash: string;
91
+ createdAt: string;
92
+ entries: {
93
+ kind: "charter" | "policy";
94
+ scope: "global" | "role";
95
+ roleKey: string | null;
96
+ revisionId: string;
97
+ revision: number;
98
+ contentHash: string;
99
+ activationVersion: number;
100
+ activatedAt: string;
101
+ provenance: {
102
+ source: "human" | "knowledge_proposal" | "legacy_import" | "onboarding";
103
+ sourceIdHash: string | null;
104
+ };
105
+ content: string;
106
+ }[];
107
+ }>;
64
108
  export {};
@@ -0,0 +1,49 @@
1
+ -- deployment-mode: rolling
2
+ -- Admit the optional Slack emoji-reaction summon source into the existing
3
+ -- durable interaction inbox. Older writers use only the existing subset, so
4
+ -- this CHECK expansion is mixed-version compatible.
5
+
6
+ SET LOCAL lock_timeout = '5s';
7
+ SET LOCAL statement_timeout = '10min';
8
+
9
+ ALTER TABLE "slack_interaction_inbox"
10
+ DROP CONSTRAINT "slack_interaction_inbox_trigger_check";
11
+
12
+ ALTER TABLE "slack_interaction_inbox"
13
+ ADD CONSTRAINT "slack_interaction_inbox_trigger_check"
14
+ CHECK (
15
+ "trigger_kind" IN (
16
+ 'app_mention',
17
+ 'dm',
18
+ 'reaction',
19
+ 'slash_command',
20
+ 'message_shortcut',
21
+ 'thread_reply'
22
+ )
23
+ ) NOT VALID;
24
+
25
+ ALTER TABLE "slack_interaction_inbox"
26
+ VALIDATE CONSTRAINT "slack_interaction_inbox_trigger_check";
27
+
28
+ -- A rate-limited conversations.replies traversal must resume at the exact next
29
+ -- cursor instead of consuming the next one-request-per-minute allowance by
30
+ -- refetching page one. The payload is application-authenticated and bounded;
31
+ -- this database constraint additionally prevents terminal/non-reaction rows
32
+ -- from retaining checkpoint material.
33
+ ALTER TABLE "slack_interaction_inbox"
34
+ ADD COLUMN "reaction_context_checkpoint" jsonb;
35
+
36
+ ALTER TABLE "slack_interaction_inbox"
37
+ ADD CONSTRAINT "slack_interaction_inbox_reaction_checkpoint_check"
38
+ CHECK (
39
+ "reaction_context_checkpoint" IS NULL
40
+ OR (
41
+ "trigger_kind" = 'reaction'
42
+ AND "status" IN ('pending', 'processing')
43
+ AND jsonb_typeof("reaction_context_checkpoint") = 'object'
44
+ AND octet_length("reaction_context_checkpoint"::text) <= 131072
45
+ )
46
+ ) NOT VALID;
47
+
48
+ ALTER TABLE "slack_interaction_inbox"
49
+ VALIDATE CONSTRAINT "slack_interaction_inbox_reaction_checkpoint_check";