@opengeni/documents 0.2.72 → 0.3.2
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/index.d.ts +36 -7
- package/dist/index.js +224 -59
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +326 -86
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Settings } from "@opengeni/config";
|
|
2
|
-
import type { AddDocumentRequest, CreateDocumentBaseRequest, Document, DocumentBase, DocumentCurationStatus, DocumentSearchMode, DocumentSearchResult, DocumentStatus, FileAsset, KnowledgeSourceKind } from "@opengeni/contracts";
|
|
2
|
+
import type { AddDocumentRequest, CreateDocumentBaseRequest, Document, DocumentAuthorityKind, DocumentBase, DocumentCurationStatus, DocumentSearchMode, DocumentSearchResult, DocumentStatus, DocumentVisibility, FileAsset, KnowledgeSourceKind } from "@opengeni/contracts";
|
|
3
3
|
import { type Database } from "@opengeni/db";
|
|
4
4
|
import type { ObjectStorage } from "@opengeni/storage";
|
|
5
5
|
export declare const DEFAULT_DOCUMENT_PARSER = "liteparse";
|
|
@@ -9,6 +9,7 @@ export declare const DEFAULT_DOCUMENT_CHUNK_SIZE = 1200;
|
|
|
9
9
|
export declare const DEFAULT_DOCUMENT_CHUNK_OVERLAP = 160;
|
|
10
10
|
export declare const DEFAULT_DOCUMENT_CURATION_MODEL = "gpt-4o-mini";
|
|
11
11
|
export declare const DOCUMENT_CURATION_MAX_INPUT_CHARS = 24000;
|
|
12
|
+
export declare const DOCUMENT_AUTHORITY_SUBJECT_MAX_BYTES = 1024;
|
|
12
13
|
export declare const DOCUMENT_CURATION_AUTO_FILE_CONFIDENCE = 0.75;
|
|
13
14
|
export declare const DEFAULT_BASE_NAME = "Default";
|
|
14
15
|
export declare const DEFAULT_BASE_DESCRIPTION = "Default base for dropped files and notes.";
|
|
@@ -82,6 +83,11 @@ export type DocumentAccessFilter = {
|
|
|
82
83
|
*/
|
|
83
84
|
agentOnly?: boolean | undefined;
|
|
84
85
|
};
|
|
86
|
+
export type DocumentAuthority = {
|
|
87
|
+
kind: DocumentAuthorityKind;
|
|
88
|
+
workspaceId: string | null;
|
|
89
|
+
subjectId: string | null;
|
|
90
|
+
};
|
|
85
91
|
export type DocumentInventoryStatusCounts = Record<DocumentStatus, number>;
|
|
86
92
|
export type DocumentInventorySourceKindCounts = Record<KnowledgeSourceKind, number>;
|
|
87
93
|
export type DocumentInventory = {
|
|
@@ -110,6 +116,7 @@ export type DocumentInventoryInput = {
|
|
|
110
116
|
access?: DocumentAccessFilter | undefined;
|
|
111
117
|
};
|
|
112
118
|
export type DocumentSearchInput = {
|
|
119
|
+
accountId: string;
|
|
113
120
|
workspaceId: string;
|
|
114
121
|
query: string;
|
|
115
122
|
baseIds?: string[] | undefined;
|
|
@@ -119,6 +126,12 @@ export type DocumentSearchInput = {
|
|
|
119
126
|
aclTags?: string[] | undefined;
|
|
120
127
|
access?: DocumentAccessFilter | undefined;
|
|
121
128
|
};
|
|
129
|
+
export type EffectiveDocumentSearchInput = Omit<DocumentSearchInput, "access"> & {
|
|
130
|
+
/** Immutable human subject accepted for the logical request/turn. */
|
|
131
|
+
initiatingSubjectId: string;
|
|
132
|
+
/** Agent retrieval additionally enforces documents.agent_access. */
|
|
133
|
+
surface: "human" | "agent";
|
|
134
|
+
};
|
|
122
135
|
export type DocumentIndexHooks = {
|
|
123
136
|
beforeEmbed?: (input: {
|
|
124
137
|
accountId: string;
|
|
@@ -243,6 +256,8 @@ export declare function addDocumentToBase(db: Database, input: AddDocumentReques
|
|
|
243
256
|
workspaceId: string;
|
|
244
257
|
baseId: string;
|
|
245
258
|
createdBy?: string | null | undefined;
|
|
259
|
+
initiatingSubjectId?: string | null | undefined;
|
|
260
|
+
organizationAuthorityGranted?: boolean | undefined;
|
|
246
261
|
curationStatus?: DocumentCurationStatus | undefined;
|
|
247
262
|
access?: DocumentAccessFilter | undefined;
|
|
248
263
|
}): Promise<Document>;
|
|
@@ -256,6 +271,7 @@ export declare function moveDocumentToBase(db: Database, input: {
|
|
|
256
271
|
workspaceId: string;
|
|
257
272
|
documentId: string;
|
|
258
273
|
targetBaseId?: string | null | undefined;
|
|
274
|
+
organizationAuthorityGranted?: boolean | undefined;
|
|
259
275
|
access?: DocumentAccessFilter | undefined;
|
|
260
276
|
}): Promise<Document>;
|
|
261
277
|
export declare function deleteDocumentFromBase(db: Database, input: {
|
|
@@ -263,19 +279,32 @@ export declare function deleteDocumentFromBase(db: Database, input: {
|
|
|
263
279
|
workspaceId: string;
|
|
264
280
|
baseId: string;
|
|
265
281
|
documentId: string;
|
|
282
|
+
organizationAuthorityGranted?: boolean | undefined;
|
|
266
283
|
access?: DocumentAccessFilter | undefined;
|
|
267
284
|
}): Promise<void>;
|
|
268
285
|
export declare function listDocuments(db: Database, workspaceId: string, baseId: string, access?: DocumentAccessFilter): Promise<Document[]>;
|
|
269
286
|
export declare function getDocument(db: Database, workspaceId: string, documentId: string, access?: DocumentAccessFilter): Promise<Document | null>;
|
|
270
|
-
export declare function queueDocumentForReindex(db: Database, workspaceId: string, documentId: string, access?: DocumentAccessFilter): Promise<Document>;
|
|
271
|
-
export declare function indexDocumentNow(db: Database, objectStorage: ObjectStorage, workspaceId: string, documentId: string, services?: DocumentServices, hooks?: DocumentIndexHooks): Promise<Document>;
|
|
287
|
+
export declare function queueDocumentForReindex(db: Database, workspaceId: string, documentId: string, access?: DocumentAccessFilter, organizationAuthorityGranted?: boolean): Promise<Document>;
|
|
288
|
+
export declare function indexDocumentNow(db: Database, objectStorage: ObjectStorage, workspaceId: string, documentId: string, services?: DocumentServices, hooks?: DocumentIndexHooks, access?: DocumentAccessFilter): Promise<Document>;
|
|
272
289
|
export declare function searchDocuments(db: Database, input: DocumentSearchInput, services?: Pick<DocumentServices, "embedder">): Promise<DocumentSearchResult[]>;
|
|
273
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Canonical effective retrieval composition for API, SDK, and MCP surfaces.
|
|
292
|
+
* Callers supply the already-authorized immutable initiating subject; no
|
|
293
|
+
* request/tool input can replace it with another user's personal authority.
|
|
294
|
+
*/
|
|
295
|
+
export declare function searchEffectiveDocuments(db: Database, input: EffectiveDocumentSearchInput, services?: Pick<DocumentServices, "embedder">): Promise<DocumentSearchResult[]>;
|
|
296
|
+
export declare function getDocumentChunk(db: Database, accountId: string, workspaceId: string, chunkId: string, access?: DocumentAccessFilter): Promise<DocumentSearchResult | null>;
|
|
297
|
+
export declare function resolveDocumentAuthority(input: {
|
|
298
|
+
kind?: DocumentAuthorityKind | undefined;
|
|
299
|
+
legacyVisibility?: DocumentVisibility | undefined;
|
|
300
|
+
workspaceId: string;
|
|
301
|
+
initiatingSubjectId?: string | null | undefined;
|
|
302
|
+
}): DocumentAuthority;
|
|
274
303
|
/** Whether a single already-fetched document is readable by this human viewer. */
|
|
275
|
-
export declare function canViewDocument(document: Pick<DocumentAccessRecord, "
|
|
304
|
+
export declare function canViewDocument(document: Pick<DocumentAccessRecord, "authorityKind" | "authoritySubjectId">, viewerSubjectId: string | null | undefined): boolean;
|
|
276
305
|
type DocumentAccessRecord = {
|
|
277
|
-
|
|
278
|
-
|
|
306
|
+
authorityKind: string;
|
|
307
|
+
authoritySubjectId: string | null;
|
|
279
308
|
agentAccess: boolean;
|
|
280
309
|
};
|
|
281
310
|
export declare function parseDocumentBytes(bytes: Uint8Array, file: FileAsset, parser?: DocumentParser): Promise<ParsedDocument>;
|