@opengeni/contracts 0.27.0 → 0.30.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/dist/{chunk-S4F2GZPD.js → chunk-YWKPXSLB.js} +2578 -2422
- package/dist/chunk-YWKPXSLB.js.map +1 -0
- package/dist/google-drive.js +1 -1
- package/dist/index.d.ts +197 -7
- package/dist/index.js +39 -1
- package/dist/scoped-knowledge.d.ts +233 -0
- package/package.json +1 -1
- package/src/index.ts +182 -8
- package/src/scoped-knowledge.ts +216 -0
- package/dist/chunk-S4F2GZPD.js.map +0 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/** Tenant scope for normalized knowledge and source provenance. */
|
|
4
|
+
export const ScopedKnowledgeScopeKind = z.enum(["organization", "workspace", "personal"]);
|
|
5
|
+
export type ScopedKnowledgeScopeKind = z.infer<typeof ScopedKnowledgeScopeKind>;
|
|
6
|
+
|
|
7
|
+
export type ScopedKnowledgeScope =
|
|
8
|
+
| { kind: "organization"; workspaceId: null; subjectId: null }
|
|
9
|
+
| { kind: "workspace"; workspaceId: string; subjectId: null }
|
|
10
|
+
| { kind: "personal"; workspaceId: string | null; subjectId: string };
|
|
11
|
+
|
|
12
|
+
export const ScopedKnowledgeActorKind = z.enum(["human", "service"]);
|
|
13
|
+
export type ScopedKnowledgeActorKind = z.infer<typeof ScopedKnowledgeActorKind>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Immutable write provenance. A service actor may retain a causal human, but
|
|
17
|
+
* the service identity never substitutes for that human on personal reads.
|
|
18
|
+
*/
|
|
19
|
+
export type ScopedKnowledgeActor = {
|
|
20
|
+
kind: ScopedKnowledgeActorKind;
|
|
21
|
+
subjectId: string;
|
|
22
|
+
initiatingHumanSubjectId: string | null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const KnowledgeLifecycleState = z.enum(["active", "deleted", "revoked"]);
|
|
26
|
+
export type KnowledgeLifecycleState = z.infer<typeof KnowledgeLifecycleState>;
|
|
27
|
+
|
|
28
|
+
export const KnowledgeLifecycleEventType = z.enum([
|
|
29
|
+
"deleted",
|
|
30
|
+
"revoked",
|
|
31
|
+
"restored",
|
|
32
|
+
"acl_changed",
|
|
33
|
+
"sync_succeeded",
|
|
34
|
+
"sync_failed",
|
|
35
|
+
"object_version_added",
|
|
36
|
+
]);
|
|
37
|
+
export type KnowledgeLifecycleEventType = z.infer<typeof KnowledgeLifecycleEventType>;
|
|
38
|
+
|
|
39
|
+
export const KnowledgeSyncRunState = z.enum(["started", "succeeded", "failed"]);
|
|
40
|
+
export type KnowledgeSyncRunState = z.infer<typeof KnowledgeSyncRunState>;
|
|
41
|
+
|
|
42
|
+
export const KnowledgeClaimOrigin = z.enum(["explicit", "inferred"]);
|
|
43
|
+
export type KnowledgeClaimOrigin = z.infer<typeof KnowledgeClaimOrigin>;
|
|
44
|
+
|
|
45
|
+
export const KnowledgeClaimRelationType = z.enum(["supersedes", "conflicts_with"]);
|
|
46
|
+
export type KnowledgeClaimRelationType = z.infer<typeof KnowledgeClaimRelationType>;
|
|
47
|
+
|
|
48
|
+
export const KnowledgeClaimEvidencePolarity = z.enum(["supports", "contradicts"]);
|
|
49
|
+
export type KnowledgeClaimEvidencePolarity = z.infer<typeof KnowledgeClaimEvidencePolarity>;
|
|
50
|
+
|
|
51
|
+
export const KnowledgeClaimReviewState = z.enum(["proposed", "approved", "rejected", "revoked"]);
|
|
52
|
+
export type KnowledgeClaimReviewState = z.infer<typeof KnowledgeClaimReviewState>;
|
|
53
|
+
|
|
54
|
+
export const KnowledgeFactObjectKind = z.enum([
|
|
55
|
+
"entity",
|
|
56
|
+
"text",
|
|
57
|
+
"number",
|
|
58
|
+
"boolean",
|
|
59
|
+
"json",
|
|
60
|
+
"timestamp",
|
|
61
|
+
]);
|
|
62
|
+
export type KnowledgeFactObjectKind = z.infer<typeof KnowledgeFactObjectKind>;
|
|
63
|
+
|
|
64
|
+
export const KnowledgeChangeProposalTargetKind = z.enum(["instruction_policy", "preference"]);
|
|
65
|
+
export type KnowledgeChangeProposalTargetKind = z.infer<typeof KnowledgeChangeProposalTargetKind>;
|
|
66
|
+
|
|
67
|
+
export type KnowledgeProviderRecord = {
|
|
68
|
+
id: string;
|
|
69
|
+
accountId: string;
|
|
70
|
+
scope: ScopedKnowledgeScope;
|
|
71
|
+
providerKey: string;
|
|
72
|
+
externalTenantId: string;
|
|
73
|
+
lifecycleState: KnowledgeLifecycleState;
|
|
74
|
+
lifecycleGeneration: number;
|
|
75
|
+
createdAt: string;
|
|
76
|
+
updatedAt: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type KnowledgeSourceRecord = {
|
|
80
|
+
id: string;
|
|
81
|
+
accountId: string;
|
|
82
|
+
providerId: string;
|
|
83
|
+
scope: ScopedKnowledgeScope;
|
|
84
|
+
externalSourceId: string;
|
|
85
|
+
sourceKind: string;
|
|
86
|
+
sourceUri: string | null;
|
|
87
|
+
currentAclGeneration: number | null;
|
|
88
|
+
syncGeneration: number;
|
|
89
|
+
syncCursor: string | null;
|
|
90
|
+
lifecycleState: KnowledgeLifecycleState;
|
|
91
|
+
lifecycleGeneration: number;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
updatedAt: string;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export type KnowledgeSourceAclVersionRecord = {
|
|
97
|
+
id: string;
|
|
98
|
+
accountId: string;
|
|
99
|
+
sourceId: string;
|
|
100
|
+
generation: number;
|
|
101
|
+
aclVersion: string | null;
|
|
102
|
+
aclHash: string;
|
|
103
|
+
audience: ScopedKnowledgeScope;
|
|
104
|
+
agentAccess: boolean;
|
|
105
|
+
createdAt: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type KnowledgeSyncRunRecord = {
|
|
109
|
+
id: string;
|
|
110
|
+
accountId: string;
|
|
111
|
+
sourceId: string;
|
|
112
|
+
operationId: string;
|
|
113
|
+
state: KnowledgeSyncRunState;
|
|
114
|
+
inputSyncGeneration: number;
|
|
115
|
+
inputLifecycleGeneration: number;
|
|
116
|
+
inputCursor: string | null;
|
|
117
|
+
outputCursor: string | null;
|
|
118
|
+
watermark: string | null;
|
|
119
|
+
metadata: Record<string, unknown>;
|
|
120
|
+
errorCode: string | null;
|
|
121
|
+
startedAt: string;
|
|
122
|
+
completedAt: string | null;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type KnowledgeSourceObjectRecord = {
|
|
126
|
+
id: string;
|
|
127
|
+
accountId: string;
|
|
128
|
+
sourceId: string;
|
|
129
|
+
scope: ScopedKnowledgeScope;
|
|
130
|
+
externalObjectId: string;
|
|
131
|
+
documentId: string | null;
|
|
132
|
+
lifecycleState: KnowledgeLifecycleState;
|
|
133
|
+
lifecycleGeneration: number;
|
|
134
|
+
versionGeneration: number;
|
|
135
|
+
currentVersionId: string | null;
|
|
136
|
+
createdAt: string;
|
|
137
|
+
updatedAt: string;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type KnowledgeDocumentVersionRecord = {
|
|
141
|
+
id: string;
|
|
142
|
+
accountId: string;
|
|
143
|
+
sourceId: string;
|
|
144
|
+
objectId: string;
|
|
145
|
+
scope: ScopedKnowledgeScope;
|
|
146
|
+
versionGeneration: number;
|
|
147
|
+
externalVersionId: string;
|
|
148
|
+
contentSha256: string;
|
|
149
|
+
ingestionKey: string;
|
|
150
|
+
aclVersionId: string;
|
|
151
|
+
aclGeneration: number;
|
|
152
|
+
documentId: string | null;
|
|
153
|
+
fileId: string | null;
|
|
154
|
+
createdAt: string;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type KnowledgeEntityRecord = {
|
|
158
|
+
id: string;
|
|
159
|
+
accountId: string;
|
|
160
|
+
scope: ScopedKnowledgeScope;
|
|
161
|
+
entityType: string;
|
|
162
|
+
normalizedKey: string;
|
|
163
|
+
displayName: string;
|
|
164
|
+
createdAt: string;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export type KnowledgeFactRecord = {
|
|
168
|
+
id: string;
|
|
169
|
+
accountId: string;
|
|
170
|
+
scope: ScopedKnowledgeScope;
|
|
171
|
+
subjectEntityId: string;
|
|
172
|
+
predicateKey: string;
|
|
173
|
+
objectKind: KnowledgeFactObjectKind;
|
|
174
|
+
objectEntityId: string | null;
|
|
175
|
+
objectValue: unknown | null;
|
|
176
|
+
objectHash: string;
|
|
177
|
+
createdAt: string;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type KnowledgeClaimRecord = {
|
|
181
|
+
id: string;
|
|
182
|
+
accountId: string;
|
|
183
|
+
scope: ScopedKnowledgeScope;
|
|
184
|
+
factId: string;
|
|
185
|
+
origin: KnowledgeClaimOrigin;
|
|
186
|
+
confidenceBps: number;
|
|
187
|
+
effectiveAt: string;
|
|
188
|
+
expiresAt: string | null;
|
|
189
|
+
extractionMethod: string;
|
|
190
|
+
modelProvider: string | null;
|
|
191
|
+
modelName: string | null;
|
|
192
|
+
modelVersion: string | null;
|
|
193
|
+
createdAt: string;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export type EligibleKnowledgeClaim = {
|
|
197
|
+
claim: KnowledgeClaimRecord;
|
|
198
|
+
fact: KnowledgeFactRecord;
|
|
199
|
+
reviewState: "approved";
|
|
200
|
+
supportingEvidenceCount: number;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export type KnowledgeChangeProposalRecord = {
|
|
204
|
+
id: string;
|
|
205
|
+
accountId: string;
|
|
206
|
+
scope: ScopedKnowledgeScope;
|
|
207
|
+
targetKind: KnowledgeChangeProposalTargetKind;
|
|
208
|
+
targetScope: string;
|
|
209
|
+
targetKey: string | null;
|
|
210
|
+
content: string;
|
|
211
|
+
contentHash: string;
|
|
212
|
+
claimId: string;
|
|
213
|
+
evidenceId: string;
|
|
214
|
+
status: "proposed";
|
|
215
|
+
createdAt: string;
|
|
216
|
+
};
|