@pageindex/sdk 0.3.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/README.md +133 -0
- package/dist/index.cjs +326 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +347 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +347 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +323 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
//#region src/api/types.d.ts
|
|
2
|
+
interface SubmitDocumentOptions {
|
|
3
|
+
mode?: string;
|
|
4
|
+
folderId?: string;
|
|
5
|
+
}
|
|
6
|
+
interface SubmitDocumentResponse {
|
|
7
|
+
doc_id: string;
|
|
8
|
+
}
|
|
9
|
+
interface GetDocumentMetadataResponse {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
status: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
pageNum?: number;
|
|
16
|
+
folderId?: string | null;
|
|
17
|
+
}
|
|
18
|
+
interface GetTreeOptions {
|
|
19
|
+
summary?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface TreeNodeContent {
|
|
22
|
+
title: string;
|
|
23
|
+
node_id: string;
|
|
24
|
+
page_index: number;
|
|
25
|
+
text?: string;
|
|
26
|
+
nodes?: TreeNodeContent[];
|
|
27
|
+
}
|
|
28
|
+
interface GetTreeResponse {
|
|
29
|
+
doc_id: string;
|
|
30
|
+
status: string;
|
|
31
|
+
retrieval_ready: boolean;
|
|
32
|
+
result: TreeNodeContent[];
|
|
33
|
+
}
|
|
34
|
+
interface GetOcrOptions {
|
|
35
|
+
format?: "page" | "node" | "raw";
|
|
36
|
+
}
|
|
37
|
+
interface OcrPageContent {
|
|
38
|
+
images: string[];
|
|
39
|
+
markdown: string;
|
|
40
|
+
page_index: number;
|
|
41
|
+
extended_node_candidates?: unknown[];
|
|
42
|
+
}
|
|
43
|
+
interface GetOcrResponse {
|
|
44
|
+
doc_id: string;
|
|
45
|
+
status: string;
|
|
46
|
+
retrieval_ready: boolean;
|
|
47
|
+
result: OcrPageContent[];
|
|
48
|
+
}
|
|
49
|
+
interface ListDocumentsOptions {
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
folderId?: string;
|
|
53
|
+
}
|
|
54
|
+
interface DocumentItem {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description: string | null;
|
|
58
|
+
status: string;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
pageNum?: number;
|
|
61
|
+
folderId?: string | null;
|
|
62
|
+
}
|
|
63
|
+
interface ListDocumentsResponse {
|
|
64
|
+
documents: DocumentItem[];
|
|
65
|
+
total: number;
|
|
66
|
+
limit: number;
|
|
67
|
+
offset: number;
|
|
68
|
+
}
|
|
69
|
+
interface DeleteDocumentResponse {
|
|
70
|
+
message: string;
|
|
71
|
+
}
|
|
72
|
+
interface ChatCompletionsParams {
|
|
73
|
+
messages: Array<{
|
|
74
|
+
role: "system" | "user" | "assistant";
|
|
75
|
+
content: string;
|
|
76
|
+
}>;
|
|
77
|
+
doc_id?: string;
|
|
78
|
+
doc_ids?: string[];
|
|
79
|
+
model?: string;
|
|
80
|
+
stream?: boolean;
|
|
81
|
+
temperature?: number;
|
|
82
|
+
enable_citations?: boolean;
|
|
83
|
+
stream_metadata?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface ChatCompletionsResponse {
|
|
86
|
+
id: string;
|
|
87
|
+
choices: Array<{
|
|
88
|
+
index: number;
|
|
89
|
+
message: {
|
|
90
|
+
role: string;
|
|
91
|
+
content: string;
|
|
92
|
+
};
|
|
93
|
+
finish_reason: string;
|
|
94
|
+
}>;
|
|
95
|
+
usage?: {
|
|
96
|
+
prompt_tokens: number;
|
|
97
|
+
completion_tokens: number;
|
|
98
|
+
total_tokens: number;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/api/client.d.ts
|
|
103
|
+
interface PageIndexApiConfig {
|
|
104
|
+
apiUrl: string;
|
|
105
|
+
apiKey: string;
|
|
106
|
+
folderScope?: string;
|
|
107
|
+
}
|
|
108
|
+
declare class PageIndexApi {
|
|
109
|
+
private readonly baseUrl;
|
|
110
|
+
private readonly apiKey;
|
|
111
|
+
private readonly folderScope?;
|
|
112
|
+
constructor(config: PageIndexApiConfig);
|
|
113
|
+
submitDocument(file: Blob | Buffer | ArrayBuffer, fileName: string, options?: SubmitDocumentOptions): Promise<SubmitDocumentResponse>;
|
|
114
|
+
getDocument(docId: string): Promise<GetDocumentMetadataResponse>;
|
|
115
|
+
getTree(docId: string, options?: GetTreeOptions): Promise<GetTreeResponse>;
|
|
116
|
+
getOcr(docId: string, options?: GetOcrOptions): Promise<GetOcrResponse>;
|
|
117
|
+
listDocuments(options?: ListDocumentsOptions): Promise<ListDocumentsResponse>;
|
|
118
|
+
deleteDocument(docId: string): Promise<DeleteDocumentResponse>;
|
|
119
|
+
chatCompletions(params: ChatCompletionsParams): Promise<ChatCompletionsResponse>;
|
|
120
|
+
private request;
|
|
121
|
+
private requestMultipart;
|
|
122
|
+
private handleResponse;
|
|
123
|
+
private mapStatusToErrorCode;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/transport.d.ts
|
|
127
|
+
declare class McpTransport {
|
|
128
|
+
private config;
|
|
129
|
+
private client;
|
|
130
|
+
private transport;
|
|
131
|
+
private connected;
|
|
132
|
+
private folderScope;
|
|
133
|
+
private idleTimeout;
|
|
134
|
+
private idleTimer;
|
|
135
|
+
constructor(config: {
|
|
136
|
+
apiUrl: string;
|
|
137
|
+
apiKey: string;
|
|
138
|
+
folderScope?: string;
|
|
139
|
+
idleTimeout?: number;
|
|
140
|
+
});
|
|
141
|
+
private resetIdleTimer;
|
|
142
|
+
private clearIdleTimer;
|
|
143
|
+
setFolderScope(scope: string | undefined): Promise<void>;
|
|
144
|
+
isConnected: () => boolean;
|
|
145
|
+
connect(): Promise<void>;
|
|
146
|
+
callTool<T = unknown>(name: string, args: Record<string, unknown>): Promise<T>;
|
|
147
|
+
close(): Promise<void>;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/tools/types.d.ts
|
|
151
|
+
interface NextSteps {
|
|
152
|
+
summary: string;
|
|
153
|
+
options: string[];
|
|
154
|
+
auto_retry?: string;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/tools/create-folder.d.ts
|
|
158
|
+
interface CreateFolderParams {
|
|
159
|
+
name: string;
|
|
160
|
+
description?: string;
|
|
161
|
+
parentFolderId?: string;
|
|
162
|
+
}
|
|
163
|
+
interface FolderItem {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
description: string | null;
|
|
167
|
+
parent_folder_id: string | null;
|
|
168
|
+
created_at: string;
|
|
169
|
+
file_count: number;
|
|
170
|
+
children_count: number;
|
|
171
|
+
}
|
|
172
|
+
interface CreateFolderResult {
|
|
173
|
+
folder: FolderItem;
|
|
174
|
+
next_steps: NextSteps;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/tools/find-relevant-documents.d.ts
|
|
178
|
+
interface FindRelevantDocumentsParams {
|
|
179
|
+
nameOrDescriptionFilter?: string;
|
|
180
|
+
cursor?: string;
|
|
181
|
+
limit?: number;
|
|
182
|
+
}
|
|
183
|
+
interface SearchDocumentItem {
|
|
184
|
+
id: string;
|
|
185
|
+
name: string;
|
|
186
|
+
description: string;
|
|
187
|
+
status: string;
|
|
188
|
+
pageNum: number;
|
|
189
|
+
createdAt: string;
|
|
190
|
+
folderId: string | null;
|
|
191
|
+
}
|
|
192
|
+
interface FindRelevantDocumentsResult {
|
|
193
|
+
docs: SearchDocumentItem[];
|
|
194
|
+
cursor?: string;
|
|
195
|
+
has_more: boolean;
|
|
196
|
+
next_steps: NextSteps;
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/tools/get-document-structure.d.ts
|
|
200
|
+
interface GetDocumentStructureParams {
|
|
201
|
+
docName: string;
|
|
202
|
+
part?: number;
|
|
203
|
+
waitForCompletion?: boolean;
|
|
204
|
+
}
|
|
205
|
+
interface GetDocumentStructureResult {
|
|
206
|
+
doc_name: string;
|
|
207
|
+
structure: unknown;
|
|
208
|
+
total_parts?: number;
|
|
209
|
+
next_steps: NextSteps;
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/tools/get-document.d.ts
|
|
213
|
+
interface GetDocumentParams {
|
|
214
|
+
docName: string;
|
|
215
|
+
waitForCompletion?: boolean;
|
|
216
|
+
}
|
|
217
|
+
interface GetDocumentResult {
|
|
218
|
+
id: string;
|
|
219
|
+
name: string;
|
|
220
|
+
description: string;
|
|
221
|
+
status: string;
|
|
222
|
+
createdAt: string;
|
|
223
|
+
pageNum?: number;
|
|
224
|
+
wait_info?: {
|
|
225
|
+
waited: boolean;
|
|
226
|
+
elapsed_seconds?: number;
|
|
227
|
+
final_status?: string;
|
|
228
|
+
};
|
|
229
|
+
next_steps: NextSteps;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/tools/get-page-content.d.ts
|
|
233
|
+
interface GetPageContentParams {
|
|
234
|
+
docName: string;
|
|
235
|
+
pages: string;
|
|
236
|
+
waitForCompletion?: boolean;
|
|
237
|
+
}
|
|
238
|
+
interface PageContentItem {
|
|
239
|
+
page: number;
|
|
240
|
+
text: string;
|
|
241
|
+
block_id?: string;
|
|
242
|
+
image_count?: number;
|
|
243
|
+
image_annotations?: string[];
|
|
244
|
+
}
|
|
245
|
+
interface GetPageContentResult {
|
|
246
|
+
doc_name: string;
|
|
247
|
+
total_pages: number;
|
|
248
|
+
requested_pages: string;
|
|
249
|
+
returned_pages: string;
|
|
250
|
+
content: PageContentItem[];
|
|
251
|
+
next_steps: NextSteps;
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/tools/list-folders.d.ts
|
|
255
|
+
interface ListFoldersParams {
|
|
256
|
+
/**
|
|
257
|
+
* Use "root" for root-level folders only, a folder ID for subfolders, or omit for all folders
|
|
258
|
+
*/
|
|
259
|
+
parentFolderId?: string;
|
|
260
|
+
}
|
|
261
|
+
interface ListFoldersResult {
|
|
262
|
+
folders: FolderItem[];
|
|
263
|
+
next_steps: NextSteps;
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/tools/recent-documents.d.ts
|
|
267
|
+
interface RecentDocumentItem {
|
|
268
|
+
id: string;
|
|
269
|
+
name: string;
|
|
270
|
+
description: string;
|
|
271
|
+
status: string;
|
|
272
|
+
createdAt: string;
|
|
273
|
+
pageNum?: number;
|
|
274
|
+
}
|
|
275
|
+
interface RecentDocumentsResult {
|
|
276
|
+
docs: RecentDocumentItem[];
|
|
277
|
+
total_shown: number;
|
|
278
|
+
processing_count: number;
|
|
279
|
+
ready_count: number;
|
|
280
|
+
failed_count: number;
|
|
281
|
+
next_steps: NextSteps;
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/tools/remove-document.d.ts
|
|
285
|
+
interface RemoveDocumentParams {
|
|
286
|
+
docNames: string[];
|
|
287
|
+
}
|
|
288
|
+
interface RemoveDocumentResult {
|
|
289
|
+
results: {
|
|
290
|
+
successful: number;
|
|
291
|
+
failed: number;
|
|
292
|
+
details: Array<{
|
|
293
|
+
doc_name: string;
|
|
294
|
+
success: boolean;
|
|
295
|
+
error?: string;
|
|
296
|
+
}>;
|
|
297
|
+
};
|
|
298
|
+
next_steps: NextSteps;
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/tools/index.d.ts
|
|
302
|
+
declare class PageIndexTools {
|
|
303
|
+
private transport;
|
|
304
|
+
constructor(transport: McpTransport);
|
|
305
|
+
recentDocuments: () => Promise<RecentDocumentsResult>;
|
|
306
|
+
findRelevantDocuments: (params?: FindRelevantDocumentsParams) => Promise<FindRelevantDocumentsResult>;
|
|
307
|
+
createFolder: (params: CreateFolderParams) => Promise<CreateFolderResult>;
|
|
308
|
+
listFolders: (params?: ListFoldersParams) => Promise<ListFoldersResult>;
|
|
309
|
+
getDocument: (params: GetDocumentParams) => Promise<GetDocumentResult>;
|
|
310
|
+
getDocumentStructure: (params: GetDocumentStructureParams) => Promise<GetDocumentStructureResult>;
|
|
311
|
+
getPageContent: (params: GetPageContentParams) => Promise<GetPageContentResult>;
|
|
312
|
+
removeDocument: (params: RemoveDocumentParams) => Promise<RemoveDocumentResult>;
|
|
313
|
+
}
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/client.d.ts
|
|
316
|
+
interface PageIndexClientConfig {
|
|
317
|
+
apiKey: string;
|
|
318
|
+
apiUrl?: string;
|
|
319
|
+
folderScope?: string;
|
|
320
|
+
/** MCP connection idle timeout in ms. Set 0 to disable. Default: 60000 (60s) */
|
|
321
|
+
idleTimeout?: number;
|
|
322
|
+
}
|
|
323
|
+
declare class PageIndexClient {
|
|
324
|
+
private transport;
|
|
325
|
+
private _api;
|
|
326
|
+
private _tools;
|
|
327
|
+
constructor(config: PageIndexClientConfig);
|
|
328
|
+
get api(): PageIndexApi;
|
|
329
|
+
get tools(): PageIndexTools;
|
|
330
|
+
setFolderScope(scope: string | undefined): Promise<void>;
|
|
331
|
+
connect: () => Promise<void>;
|
|
332
|
+
isConnected: () => boolean;
|
|
333
|
+
close: () => Promise<void>;
|
|
334
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/errors.d.ts
|
|
338
|
+
type PageIndexErrorCode = "USAGE_LIMIT_REACHED" | "INVALID_INPUT" | "NOT_FOUND" | "UNAUTHORIZED" | "RATE_LIMITED" | "SERVICE_UNAVAILABLE" | "INTERNAL_ERROR";
|
|
339
|
+
declare class PageIndexError extends Error {
|
|
340
|
+
readonly code?: PageIndexErrorCode | undefined;
|
|
341
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
342
|
+
readonly statusCode?: number | undefined;
|
|
343
|
+
constructor(message: string, code?: PageIndexErrorCode | undefined, details?: Record<string, unknown> | undefined, statusCode?: number | undefined);
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
export { ChatCompletionsParams, ChatCompletionsResponse, type CreateFolderParams, type CreateFolderResult, DeleteDocumentResponse, DocumentItem, type FindRelevantDocumentsParams, type FindRelevantDocumentsResult, type FolderItem, GetDocumentMetadataResponse, type GetDocumentParams, type GetDocumentResult, type GetDocumentStructureParams, type GetDocumentStructureResult, GetOcrOptions, GetOcrResponse, type GetPageContentParams, type GetPageContentResult, GetTreeOptions, GetTreeResponse, ListDocumentsOptions, ListDocumentsResponse, type ListFoldersParams, type ListFoldersResult, type NextSteps, OcrPageContent, type PageContentItem, PageIndexApi, type PageIndexApiConfig, PageIndexClient, type PageIndexClientConfig, PageIndexError, type PageIndexErrorCode, PageIndexTools, type RecentDocumentItem, type RecentDocumentsResult, type RemoveDocumentParams, type RemoveDocumentResult, type SearchDocumentItem, SubmitDocumentOptions, SubmitDocumentResponse, TreeNodeContent };
|
|
347
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/api/types.ts","../src/api/client.ts","../src/transport.ts","../src/tools/types.ts","../src/tools/create-folder.ts","../src/tools/find-relevant-documents.ts","../src/tools/get-document-structure.ts","../src/tools/get-document.ts","../src/tools/get-page-content.ts","../src/tools/list-folders.ts","../src/tools/recent-documents.ts","../src/tools/remove-document.ts","../src/tools/index.ts","../src/client.ts","../src/errors.ts"],"mappings":";UAEiB,qBAAA;EAAA,IAAA;EAAA,QAAA;AAAA;AAAA,UAKA,sBAAA;EAAA,MAAA;AAAA;AAAA,UAIA,2BAAA;EAAA,EAAA;EAAA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,OAAA;AAAA;;;KCvDrB,kBAAA;AAAA,cASC,cAAA,SAAuB,KAAA;EAAA,SAAA,IAAA,GAGT,kBAAA;EAAA,SAAA,OAAA,GACG,MAAA;EAAA,SAAA,UAAA;EAAA,YAAA,OAAA,UAAA,IAAA,GADH,kBAAA,cAAA,OAAA,GACG,MAAA,+BAAA,UAAA;AAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
//#region src/api/types.d.ts
|
|
2
|
+
interface SubmitDocumentOptions {
|
|
3
|
+
mode?: string;
|
|
4
|
+
folderId?: string;
|
|
5
|
+
}
|
|
6
|
+
interface SubmitDocumentResponse {
|
|
7
|
+
doc_id: string;
|
|
8
|
+
}
|
|
9
|
+
interface GetDocumentMetadataResponse {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
status: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
pageNum?: number;
|
|
16
|
+
folderId?: string | null;
|
|
17
|
+
}
|
|
18
|
+
interface GetTreeOptions {
|
|
19
|
+
summary?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface TreeNodeContent {
|
|
22
|
+
title: string;
|
|
23
|
+
node_id: string;
|
|
24
|
+
page_index: number;
|
|
25
|
+
text?: string;
|
|
26
|
+
nodes?: TreeNodeContent[];
|
|
27
|
+
}
|
|
28
|
+
interface GetTreeResponse {
|
|
29
|
+
doc_id: string;
|
|
30
|
+
status: string;
|
|
31
|
+
retrieval_ready: boolean;
|
|
32
|
+
result: TreeNodeContent[];
|
|
33
|
+
}
|
|
34
|
+
interface GetOcrOptions {
|
|
35
|
+
format?: "page" | "node" | "raw";
|
|
36
|
+
}
|
|
37
|
+
interface OcrPageContent {
|
|
38
|
+
images: string[];
|
|
39
|
+
markdown: string;
|
|
40
|
+
page_index: number;
|
|
41
|
+
extended_node_candidates?: unknown[];
|
|
42
|
+
}
|
|
43
|
+
interface GetOcrResponse {
|
|
44
|
+
doc_id: string;
|
|
45
|
+
status: string;
|
|
46
|
+
retrieval_ready: boolean;
|
|
47
|
+
result: OcrPageContent[];
|
|
48
|
+
}
|
|
49
|
+
interface ListDocumentsOptions {
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
folderId?: string;
|
|
53
|
+
}
|
|
54
|
+
interface DocumentItem {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description: string | null;
|
|
58
|
+
status: string;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
pageNum?: number;
|
|
61
|
+
folderId?: string | null;
|
|
62
|
+
}
|
|
63
|
+
interface ListDocumentsResponse {
|
|
64
|
+
documents: DocumentItem[];
|
|
65
|
+
total: number;
|
|
66
|
+
limit: number;
|
|
67
|
+
offset: number;
|
|
68
|
+
}
|
|
69
|
+
interface DeleteDocumentResponse {
|
|
70
|
+
message: string;
|
|
71
|
+
}
|
|
72
|
+
interface ChatCompletionsParams {
|
|
73
|
+
messages: Array<{
|
|
74
|
+
role: "system" | "user" | "assistant";
|
|
75
|
+
content: string;
|
|
76
|
+
}>;
|
|
77
|
+
doc_id?: string;
|
|
78
|
+
doc_ids?: string[];
|
|
79
|
+
model?: string;
|
|
80
|
+
stream?: boolean;
|
|
81
|
+
temperature?: number;
|
|
82
|
+
enable_citations?: boolean;
|
|
83
|
+
stream_metadata?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface ChatCompletionsResponse {
|
|
86
|
+
id: string;
|
|
87
|
+
choices: Array<{
|
|
88
|
+
index: number;
|
|
89
|
+
message: {
|
|
90
|
+
role: string;
|
|
91
|
+
content: string;
|
|
92
|
+
};
|
|
93
|
+
finish_reason: string;
|
|
94
|
+
}>;
|
|
95
|
+
usage?: {
|
|
96
|
+
prompt_tokens: number;
|
|
97
|
+
completion_tokens: number;
|
|
98
|
+
total_tokens: number;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/api/client.d.ts
|
|
103
|
+
interface PageIndexApiConfig {
|
|
104
|
+
apiUrl: string;
|
|
105
|
+
apiKey: string;
|
|
106
|
+
folderScope?: string;
|
|
107
|
+
}
|
|
108
|
+
declare class PageIndexApi {
|
|
109
|
+
private readonly baseUrl;
|
|
110
|
+
private readonly apiKey;
|
|
111
|
+
private readonly folderScope?;
|
|
112
|
+
constructor(config: PageIndexApiConfig);
|
|
113
|
+
submitDocument(file: Blob | Buffer | ArrayBuffer, fileName: string, options?: SubmitDocumentOptions): Promise<SubmitDocumentResponse>;
|
|
114
|
+
getDocument(docId: string): Promise<GetDocumentMetadataResponse>;
|
|
115
|
+
getTree(docId: string, options?: GetTreeOptions): Promise<GetTreeResponse>;
|
|
116
|
+
getOcr(docId: string, options?: GetOcrOptions): Promise<GetOcrResponse>;
|
|
117
|
+
listDocuments(options?: ListDocumentsOptions): Promise<ListDocumentsResponse>;
|
|
118
|
+
deleteDocument(docId: string): Promise<DeleteDocumentResponse>;
|
|
119
|
+
chatCompletions(params: ChatCompletionsParams): Promise<ChatCompletionsResponse>;
|
|
120
|
+
private request;
|
|
121
|
+
private requestMultipart;
|
|
122
|
+
private handleResponse;
|
|
123
|
+
private mapStatusToErrorCode;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/transport.d.ts
|
|
127
|
+
declare class McpTransport {
|
|
128
|
+
private config;
|
|
129
|
+
private client;
|
|
130
|
+
private transport;
|
|
131
|
+
private connected;
|
|
132
|
+
private folderScope;
|
|
133
|
+
private idleTimeout;
|
|
134
|
+
private idleTimer;
|
|
135
|
+
constructor(config: {
|
|
136
|
+
apiUrl: string;
|
|
137
|
+
apiKey: string;
|
|
138
|
+
folderScope?: string;
|
|
139
|
+
idleTimeout?: number;
|
|
140
|
+
});
|
|
141
|
+
private resetIdleTimer;
|
|
142
|
+
private clearIdleTimer;
|
|
143
|
+
setFolderScope(scope: string | undefined): Promise<void>;
|
|
144
|
+
isConnected: () => boolean;
|
|
145
|
+
connect(): Promise<void>;
|
|
146
|
+
callTool<T = unknown>(name: string, args: Record<string, unknown>): Promise<T>;
|
|
147
|
+
close(): Promise<void>;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/tools/types.d.ts
|
|
151
|
+
interface NextSteps {
|
|
152
|
+
summary: string;
|
|
153
|
+
options: string[];
|
|
154
|
+
auto_retry?: string;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/tools/create-folder.d.ts
|
|
158
|
+
interface CreateFolderParams {
|
|
159
|
+
name: string;
|
|
160
|
+
description?: string;
|
|
161
|
+
parentFolderId?: string;
|
|
162
|
+
}
|
|
163
|
+
interface FolderItem {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
description: string | null;
|
|
167
|
+
parent_folder_id: string | null;
|
|
168
|
+
created_at: string;
|
|
169
|
+
file_count: number;
|
|
170
|
+
children_count: number;
|
|
171
|
+
}
|
|
172
|
+
interface CreateFolderResult {
|
|
173
|
+
folder: FolderItem;
|
|
174
|
+
next_steps: NextSteps;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/tools/find-relevant-documents.d.ts
|
|
178
|
+
interface FindRelevantDocumentsParams {
|
|
179
|
+
nameOrDescriptionFilter?: string;
|
|
180
|
+
cursor?: string;
|
|
181
|
+
limit?: number;
|
|
182
|
+
}
|
|
183
|
+
interface SearchDocumentItem {
|
|
184
|
+
id: string;
|
|
185
|
+
name: string;
|
|
186
|
+
description: string;
|
|
187
|
+
status: string;
|
|
188
|
+
pageNum: number;
|
|
189
|
+
createdAt: string;
|
|
190
|
+
folderId: string | null;
|
|
191
|
+
}
|
|
192
|
+
interface FindRelevantDocumentsResult {
|
|
193
|
+
docs: SearchDocumentItem[];
|
|
194
|
+
cursor?: string;
|
|
195
|
+
has_more: boolean;
|
|
196
|
+
next_steps: NextSteps;
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/tools/get-document-structure.d.ts
|
|
200
|
+
interface GetDocumentStructureParams {
|
|
201
|
+
docName: string;
|
|
202
|
+
part?: number;
|
|
203
|
+
waitForCompletion?: boolean;
|
|
204
|
+
}
|
|
205
|
+
interface GetDocumentStructureResult {
|
|
206
|
+
doc_name: string;
|
|
207
|
+
structure: unknown;
|
|
208
|
+
total_parts?: number;
|
|
209
|
+
next_steps: NextSteps;
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/tools/get-document.d.ts
|
|
213
|
+
interface GetDocumentParams {
|
|
214
|
+
docName: string;
|
|
215
|
+
waitForCompletion?: boolean;
|
|
216
|
+
}
|
|
217
|
+
interface GetDocumentResult {
|
|
218
|
+
id: string;
|
|
219
|
+
name: string;
|
|
220
|
+
description: string;
|
|
221
|
+
status: string;
|
|
222
|
+
createdAt: string;
|
|
223
|
+
pageNum?: number;
|
|
224
|
+
wait_info?: {
|
|
225
|
+
waited: boolean;
|
|
226
|
+
elapsed_seconds?: number;
|
|
227
|
+
final_status?: string;
|
|
228
|
+
};
|
|
229
|
+
next_steps: NextSteps;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/tools/get-page-content.d.ts
|
|
233
|
+
interface GetPageContentParams {
|
|
234
|
+
docName: string;
|
|
235
|
+
pages: string;
|
|
236
|
+
waitForCompletion?: boolean;
|
|
237
|
+
}
|
|
238
|
+
interface PageContentItem {
|
|
239
|
+
page: number;
|
|
240
|
+
text: string;
|
|
241
|
+
block_id?: string;
|
|
242
|
+
image_count?: number;
|
|
243
|
+
image_annotations?: string[];
|
|
244
|
+
}
|
|
245
|
+
interface GetPageContentResult {
|
|
246
|
+
doc_name: string;
|
|
247
|
+
total_pages: number;
|
|
248
|
+
requested_pages: string;
|
|
249
|
+
returned_pages: string;
|
|
250
|
+
content: PageContentItem[];
|
|
251
|
+
next_steps: NextSteps;
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/tools/list-folders.d.ts
|
|
255
|
+
interface ListFoldersParams {
|
|
256
|
+
/**
|
|
257
|
+
* Use "root" for root-level folders only, a folder ID for subfolders, or omit for all folders
|
|
258
|
+
*/
|
|
259
|
+
parentFolderId?: string;
|
|
260
|
+
}
|
|
261
|
+
interface ListFoldersResult {
|
|
262
|
+
folders: FolderItem[];
|
|
263
|
+
next_steps: NextSteps;
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/tools/recent-documents.d.ts
|
|
267
|
+
interface RecentDocumentItem {
|
|
268
|
+
id: string;
|
|
269
|
+
name: string;
|
|
270
|
+
description: string;
|
|
271
|
+
status: string;
|
|
272
|
+
createdAt: string;
|
|
273
|
+
pageNum?: number;
|
|
274
|
+
}
|
|
275
|
+
interface RecentDocumentsResult {
|
|
276
|
+
docs: RecentDocumentItem[];
|
|
277
|
+
total_shown: number;
|
|
278
|
+
processing_count: number;
|
|
279
|
+
ready_count: number;
|
|
280
|
+
failed_count: number;
|
|
281
|
+
next_steps: NextSteps;
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/tools/remove-document.d.ts
|
|
285
|
+
interface RemoveDocumentParams {
|
|
286
|
+
docNames: string[];
|
|
287
|
+
}
|
|
288
|
+
interface RemoveDocumentResult {
|
|
289
|
+
results: {
|
|
290
|
+
successful: number;
|
|
291
|
+
failed: number;
|
|
292
|
+
details: Array<{
|
|
293
|
+
doc_name: string;
|
|
294
|
+
success: boolean;
|
|
295
|
+
error?: string;
|
|
296
|
+
}>;
|
|
297
|
+
};
|
|
298
|
+
next_steps: NextSteps;
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/tools/index.d.ts
|
|
302
|
+
declare class PageIndexTools {
|
|
303
|
+
private transport;
|
|
304
|
+
constructor(transport: McpTransport);
|
|
305
|
+
recentDocuments: () => Promise<RecentDocumentsResult>;
|
|
306
|
+
findRelevantDocuments: (params?: FindRelevantDocumentsParams) => Promise<FindRelevantDocumentsResult>;
|
|
307
|
+
createFolder: (params: CreateFolderParams) => Promise<CreateFolderResult>;
|
|
308
|
+
listFolders: (params?: ListFoldersParams) => Promise<ListFoldersResult>;
|
|
309
|
+
getDocument: (params: GetDocumentParams) => Promise<GetDocumentResult>;
|
|
310
|
+
getDocumentStructure: (params: GetDocumentStructureParams) => Promise<GetDocumentStructureResult>;
|
|
311
|
+
getPageContent: (params: GetPageContentParams) => Promise<GetPageContentResult>;
|
|
312
|
+
removeDocument: (params: RemoveDocumentParams) => Promise<RemoveDocumentResult>;
|
|
313
|
+
}
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/client.d.ts
|
|
316
|
+
interface PageIndexClientConfig {
|
|
317
|
+
apiKey: string;
|
|
318
|
+
apiUrl?: string;
|
|
319
|
+
folderScope?: string;
|
|
320
|
+
/** MCP connection idle timeout in ms. Set 0 to disable. Default: 60000 (60s) */
|
|
321
|
+
idleTimeout?: number;
|
|
322
|
+
}
|
|
323
|
+
declare class PageIndexClient {
|
|
324
|
+
private transport;
|
|
325
|
+
private _api;
|
|
326
|
+
private _tools;
|
|
327
|
+
constructor(config: PageIndexClientConfig);
|
|
328
|
+
get api(): PageIndexApi;
|
|
329
|
+
get tools(): PageIndexTools;
|
|
330
|
+
setFolderScope(scope: string | undefined): Promise<void>;
|
|
331
|
+
connect: () => Promise<void>;
|
|
332
|
+
isConnected: () => boolean;
|
|
333
|
+
close: () => Promise<void>;
|
|
334
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/errors.d.ts
|
|
338
|
+
type PageIndexErrorCode = "USAGE_LIMIT_REACHED" | "INVALID_INPUT" | "NOT_FOUND" | "UNAUTHORIZED" | "RATE_LIMITED" | "SERVICE_UNAVAILABLE" | "INTERNAL_ERROR";
|
|
339
|
+
declare class PageIndexError extends Error {
|
|
340
|
+
readonly code?: PageIndexErrorCode | undefined;
|
|
341
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
342
|
+
readonly statusCode?: number | undefined;
|
|
343
|
+
constructor(message: string, code?: PageIndexErrorCode | undefined, details?: Record<string, unknown> | undefined, statusCode?: number | undefined);
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
export { ChatCompletionsParams, ChatCompletionsResponse, type CreateFolderParams, type CreateFolderResult, DeleteDocumentResponse, DocumentItem, type FindRelevantDocumentsParams, type FindRelevantDocumentsResult, type FolderItem, GetDocumentMetadataResponse, type GetDocumentParams, type GetDocumentResult, type GetDocumentStructureParams, type GetDocumentStructureResult, GetOcrOptions, GetOcrResponse, type GetPageContentParams, type GetPageContentResult, GetTreeOptions, GetTreeResponse, ListDocumentsOptions, ListDocumentsResponse, type ListFoldersParams, type ListFoldersResult, type NextSteps, OcrPageContent, type PageContentItem, PageIndexApi, type PageIndexApiConfig, PageIndexClient, type PageIndexClientConfig, PageIndexError, type PageIndexErrorCode, PageIndexTools, type RecentDocumentItem, type RecentDocumentsResult, type RemoveDocumentParams, type RemoveDocumentResult, type SearchDocumentItem, SubmitDocumentOptions, SubmitDocumentResponse, TreeNodeContent };
|
|
347
|
+
//# sourceMappingURL=index.d.mts.map
|