@opengeni/db 0.18.1 → 0.21.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 (35) hide show
  1. package/dist/chunk-NK2A36KP.js +5822 -0
  2. package/dist/chunk-NK2A36KP.js.map +1 -0
  3. package/dist/{chunk-T6RSJT6C.js → chunk-OTJHD33E.js} +109 -1
  4. package/dist/chunk-OTJHD33E.js.map +1 -0
  5. package/dist/index.d.ts +25 -1
  6. package/dist/index.js +5761 -2827
  7. package/dist/index.js.map +1 -1
  8. package/dist/memory-domain.d.ts +110 -1
  9. package/dist/memory-governance-schema.d.ts +562 -0
  10. package/dist/memory-governance.d.ts +41 -0
  11. package/dist/provision-roles.js +1 -1
  12. package/dist/runtime-posture.d.ts +3 -3
  13. package/dist/schema.d.ts +425 -0
  14. package/dist/schema.js +37 -1
  15. package/dist/scoped-knowledge-schema.d.ts +5341 -0
  16. package/dist/scoped-knowledge.d.ts +208 -0
  17. package/dist/session-queue-commands.d.ts +2 -1
  18. package/drizzle/0152_hierarchical_memory_foundation.sql +1589 -0
  19. package/drizzle/0153_mcp_personal_connection_delegations.sql +181 -0
  20. package/drizzle/0154_scoped_knowledge_foundation.sql +2292 -0
  21. package/package.json +3 -3
  22. package/src/connection-token-resolver.ts +3 -0
  23. package/src/index.ts +351 -12
  24. package/src/memory-domain.ts +360 -1
  25. package/src/memory-governance-schema.ts +162 -0
  26. package/src/memory-governance.ts +317 -0
  27. package/src/provision-roles.ts +72 -0
  28. package/src/runtime-posture.ts +36 -0
  29. package/src/schema.ts +87 -4
  30. package/src/scoped-knowledge-schema.ts +603 -0
  31. package/src/scoped-knowledge.ts +2891 -0
  32. package/src/session-queue-commands.ts +48 -0
  33. package/dist/chunk-T6RSJT6C.js.map +0 -1
  34. package/dist/chunk-YKWJ7QJ2.js +0 -5000
  35. package/dist/chunk-YKWJ7QJ2.js.map +0 -1
@@ -0,0 +1,208 @@
1
+ import type { EligibleKnowledgeClaim, KnowledgeChangeProposalRecord, KnowledgeClaimEvidencePolarity, KnowledgeClaimOrigin, KnowledgeClaimRecord, KnowledgeClaimRelationType, KnowledgeClaimReviewState, KnowledgeDocumentVersionRecord, KnowledgeFactObjectKind, KnowledgeFactRecord, KnowledgeLifecycleEventType, KnowledgeLifecycleState, KnowledgeProviderRecord, KnowledgeSourceAclVersionRecord, KnowledgeSourceObjectRecord, KnowledgeSourceRecord, KnowledgeSyncRunRecord, ScopedKnowledgeActor, ScopedKnowledgeScope } from "@opengeni/contracts";
2
+ import type { Database } from "./index";
3
+ type KnowledgeWriteContext = {
4
+ accountId: string;
5
+ workspaceId: string;
6
+ scope: ScopedKnowledgeScope;
7
+ operationId: string;
8
+ actor: ScopedKnowledgeActor;
9
+ };
10
+ type KnowledgeReadContext = {
11
+ accountId: string;
12
+ workspaceId: string;
13
+ initiatingSubjectId: string;
14
+ surface: "human" | "agent";
15
+ };
16
+ export declare class ScopedKnowledgeConflictError extends Error {
17
+ readonly name = "ScopedKnowledgeConflictError";
18
+ readonly code = "SCOPED_KNOWLEDGE_CONFLICT";
19
+ }
20
+ export declare class ScopedKnowledgeGenerationConflictError extends Error {
21
+ readonly name = "ScopedKnowledgeGenerationConflictError";
22
+ readonly code = "SCOPED_KNOWLEDGE_GENERATION_CONFLICT";
23
+ }
24
+ export declare class ScopedKnowledgeNotFoundError extends Error {
25
+ readonly name = "ScopedKnowledgeNotFoundError";
26
+ }
27
+ export declare class ScopedKnowledgeInvalidOperationError extends Error {
28
+ readonly name = "ScopedKnowledgeInvalidOperationError";
29
+ }
30
+ export declare class ScopedKnowledgeAuthorityError extends Error {
31
+ readonly name = "ScopedKnowledgeAuthorityError";
32
+ }
33
+ export declare function scopedKnowledgeInputHash(value: unknown): string;
34
+ export declare function normalizeScopedKnowledgeKey(value: string): string;
35
+ export declare function scopedKnowledgeScopeKey(scope: ScopedKnowledgeScope): string;
36
+ export declare function upsertKnowledgeProvider(db: Database, input: KnowledgeWriteContext & {
37
+ providerKey: string;
38
+ externalTenantId: string;
39
+ }): Promise<KnowledgeProviderRecord>;
40
+ export declare function upsertKnowledgeSource(db: Database, input: KnowledgeWriteContext & {
41
+ providerId: string;
42
+ externalSourceId: string;
43
+ sourceKind: string;
44
+ sourceUri?: string | null;
45
+ }): Promise<KnowledgeSourceRecord>;
46
+ export declare function appendKnowledgeSourceAclVersion(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
47
+ sourceId: string;
48
+ audience: ScopedKnowledgeScope;
49
+ expectedSourceLifecycleGeneration: number;
50
+ expectedAclGeneration: number;
51
+ aclVersion?: string | null;
52
+ agentAccess: boolean;
53
+ reasonCode: string;
54
+ }): Promise<KnowledgeSourceAclVersionRecord>;
55
+ export declare function beginKnowledgeSyncRun(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
56
+ sourceId: string;
57
+ expectedSourceLifecycleGeneration: number;
58
+ expectedSyncGeneration: number;
59
+ inputCursor: string | null;
60
+ }): Promise<KnowledgeSyncRunRecord>;
61
+ export declare function completeKnowledgeSyncRun(db: Database, input: {
62
+ accountId: string;
63
+ workspaceId: string;
64
+ initiatingSubjectId: string | null;
65
+ runId: string;
66
+ state: "succeeded" | "failed";
67
+ outputCursor?: string | null;
68
+ watermark?: string | null;
69
+ metadata?: Record<string, unknown> | undefined;
70
+ errorCode?: string | null;
71
+ reasonCode: string;
72
+ }): Promise<KnowledgeSyncRunRecord>;
73
+ export declare function upsertKnowledgeSourceObject(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
74
+ sourceId: string;
75
+ externalObjectId: string;
76
+ documentId?: string | null;
77
+ }): Promise<KnowledgeSourceObjectRecord>;
78
+ export declare function appendKnowledgeDocumentVersion(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
79
+ objectId: string;
80
+ expectedObjectLifecycleGeneration: number;
81
+ expectedVersionGeneration: number;
82
+ externalVersionId: string;
83
+ contentSha256: string;
84
+ ingestionKey: string;
85
+ sourceCursor?: string | null;
86
+ sourceMetadata?: Record<string, unknown> | undefined;
87
+ sourceCreatedAt?: string | null;
88
+ sourceUpdatedAt?: string | null;
89
+ aclVersionId: string;
90
+ aclGeneration: number;
91
+ documentId?: string | null;
92
+ fileId?: string | null;
93
+ locationMetadata?: Record<string, unknown> | undefined;
94
+ reasonCode: string;
95
+ }): Promise<KnowledgeDocumentVersionRecord>;
96
+ export declare function recordKnowledgeLifecycleEvent(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
97
+ targetKind: "provider" | "source" | "object";
98
+ targetId: string;
99
+ eventType: Extract<KnowledgeLifecycleEventType, "deleted" | "revoked" | "restored">;
100
+ expectedGeneration: number;
101
+ reasonCode: string;
102
+ }): Promise<{
103
+ targetId: string;
104
+ lifecycleState: KnowledgeLifecycleState;
105
+ lifecycleGeneration: number;
106
+ replayed: boolean;
107
+ }>;
108
+ export declare function restoreKnowledgeSourceObject(db: Database, input: Omit<Parameters<typeof recordKnowledgeLifecycleEvent>[1], "targetKind" | "eventType">): Promise<{
109
+ targetId: string;
110
+ lifecycleState: KnowledgeLifecycleState;
111
+ lifecycleGeneration: number;
112
+ replayed: boolean;
113
+ }>;
114
+ export declare function upsertKnowledgeEntity(db: Database, input: KnowledgeWriteContext & {
115
+ entityType: string;
116
+ normalizedKey: string;
117
+ displayName: string;
118
+ }): Promise<{
119
+ id: string;
120
+ accountId: string;
121
+ scope: ScopedKnowledgeScope;
122
+ entityType: string;
123
+ normalizedKey: string;
124
+ displayName: string;
125
+ createdAt: string;
126
+ }>;
127
+ export declare function attachKnowledgeEntityAlias(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
128
+ entityId: string;
129
+ alias: string;
130
+ }): Promise<{
131
+ id: string;
132
+ entityId: string;
133
+ alias: string;
134
+ normalizedAlias: string;
135
+ }>;
136
+ export declare function upsertKnowledgeFact(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
137
+ subjectEntityId: string;
138
+ predicateKey: string;
139
+ object: {
140
+ kind: "entity";
141
+ entityId: string;
142
+ } | {
143
+ kind: Exclude<KnowledgeFactObjectKind, "entity">;
144
+ value: unknown;
145
+ };
146
+ }): Promise<KnowledgeFactRecord>;
147
+ export declare function appendKnowledgeClaim(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
148
+ factId: string;
149
+ origin: KnowledgeClaimOrigin;
150
+ confidenceBps: number;
151
+ effectiveAt: string;
152
+ expiresAt?: string | null;
153
+ extractionMethod: string;
154
+ extractionMetadata?: Record<string, unknown> | undefined;
155
+ modelProvider?: string | null;
156
+ modelName?: string | null;
157
+ modelVersion?: string | null;
158
+ }): Promise<KnowledgeClaimRecord>;
159
+ export declare function linkKnowledgeClaims(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
160
+ relationType: KnowledgeClaimRelationType;
161
+ fromClaimId: string;
162
+ toClaimId: string;
163
+ }): Promise<{
164
+ id: string;
165
+ relationType: KnowledgeClaimRelationType;
166
+ fromClaimId: string;
167
+ toClaimId: string;
168
+ }>;
169
+ export declare function appendKnowledgeClaimEvidence(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
170
+ claimId: string;
171
+ documentVersionId: string;
172
+ polarity: KnowledgeClaimEvidencePolarity;
173
+ documentChunkId?: string | null;
174
+ chunkIndex?: number | null;
175
+ locator?: string | null;
176
+ quoteHash?: string | null;
177
+ contentHash: string;
178
+ }): Promise<{
179
+ id: string;
180
+ claimId: string;
181
+ documentVersionId: string;
182
+ polarity: KnowledgeClaimEvidencePolarity;
183
+ }>;
184
+ export declare function appendKnowledgeClaimReview(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
185
+ claimId: string;
186
+ state: KnowledgeClaimReviewState;
187
+ reason: string;
188
+ }): Promise<{
189
+ id: string;
190
+ claimId: string;
191
+ state: KnowledgeClaimReviewState;
192
+ reviewRevision: number;
193
+ }>;
194
+ export declare function createKnowledgeChangeProposal(db: Database, input: Omit<KnowledgeWriteContext, "scope"> & {
195
+ claimId: string;
196
+ evidenceId: string;
197
+ targetKind: "instruction_policy" | "preference";
198
+ targetScope: string;
199
+ targetKey?: string | null;
200
+ content: string;
201
+ }): Promise<KnowledgeChangeProposalRecord>;
202
+ export declare function listEligibleKnowledgeClaims(db: Database, input: KnowledgeReadContext & {
203
+ limit?: number | undefined;
204
+ }): Promise<EligibleKnowledgeClaim[]>;
205
+ export declare function getEligibleKnowledgeClaim(db: Database, input: KnowledgeReadContext & {
206
+ claimId: string;
207
+ }): Promise<EligibleKnowledgeClaim | null>;
208
+ export {};
@@ -1,4 +1,4 @@
1
- import { ResourceRef, type LatencyMode, type ReasoningEffort, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
1
+ import { ResourceRef, type McpPersonalConnectionDelegation, type LatencyMode, type ReasoningEffort, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
2
2
  import type { Database } from "./index";
3
3
  import { type SessionCommandActor, type SessionCommandReceiptRow } from "./session-control";
4
4
  import * as schema from "./schema";
@@ -158,6 +158,7 @@ export declare function submitHumanPromptInTransaction(db: Database, input: {
158
158
  /** Trusted API/core admission snapshot. Omitted only by legacy low-level callers. */
159
159
  turnExecutionPolicy?: TurnExecutionPolicyV1;
160
160
  source: "user" | "api";
161
+ personalConnectionDelegations?: McpPersonalConnectionDelegation[];
161
162
  mcpCredentialUpdates?: Array<{
162
163
  id: string;
163
164
  headersEncrypted: Record<string, string>;