@stackfactor/client-api 1.20.1 → 1.20.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/cjs/lib/knowledgeBaseAgent.d.ts +77 -2
- package/dist/cjs/lib/knowledgeBaseAgent.d.ts.map +1 -1
- package/dist/cjs/lib/knowledgeBaseAgent.js +54 -6
- package/dist/cjs/lib/knowledgeBaseAgent.js.map +1 -1
- package/dist/esm/lib/knowledgeBaseAgent.d.ts +77 -2
- package/dist/esm/lib/knowledgeBaseAgent.d.ts.map +1 -1
- package/dist/esm/lib/knowledgeBaseAgent.js +50 -5
- package/dist/esm/lib/knowledgeBaseAgent.js.map +1 -1
- package/package.json +1 -1
|
@@ -66,6 +66,16 @@ export interface SyncOutcome {
|
|
|
66
66
|
/** How many documents the source holds, when the run counted them. */
|
|
67
67
|
count?: number;
|
|
68
68
|
lastError?: string | null;
|
|
69
|
+
/**
|
|
70
|
+
* True when the run listed the whole source, so the backend may remove what
|
|
71
|
+
* the source no longer holds. A run that registered can say so even if it was
|
|
72
|
+
* cancelled or failed while processing.
|
|
73
|
+
*/
|
|
74
|
+
exhaustive?: boolean;
|
|
75
|
+
/** Listed ids the run did not ingest; ignored by the backend for a run that registered. */
|
|
76
|
+
notIngested?: string[];
|
|
77
|
+
/** True when the run registered its listing (the two-phase flow). */
|
|
78
|
+
registered?: boolean;
|
|
69
79
|
}
|
|
70
80
|
/** Which page of the source to list. */
|
|
71
81
|
export interface DocumentPage {
|
|
@@ -89,10 +99,33 @@ export interface ListedDocument {
|
|
|
89
99
|
mimeType?: string;
|
|
90
100
|
[field: string]: unknown;
|
|
91
101
|
}
|
|
102
|
+
/** What registering one page of the listing came to: counts of the entries it held. */
|
|
103
|
+
export interface RegisteredDocuments {
|
|
104
|
+
/** Every entry accepted: `toProcess + unchanged + blocked + inProgress + repeated`. */
|
|
105
|
+
registered: number;
|
|
106
|
+
/** New, changed since its last ingest, not settled, or listed without a version: to be ingested in full. */
|
|
107
|
+
toProcess: number;
|
|
108
|
+
/** Settled and unchanged: only their ACL is read. */
|
|
109
|
+
unchanged: number;
|
|
110
|
+
/** Left as they are: held by a reviewer. */
|
|
111
|
+
blocked: number;
|
|
112
|
+
/** Left as they are: being ingested by another request. */
|
|
113
|
+
inProgress: number;
|
|
114
|
+
/** An id this run had already registered, so counted once. */
|
|
115
|
+
repeated: number;
|
|
116
|
+
}
|
|
117
|
+
/** A registered document handed out for ingestion. */
|
|
118
|
+
export interface QueuedDocument {
|
|
119
|
+
/** The document's id in the knowledge base, to ingest by. */
|
|
120
|
+
documentId: string;
|
|
121
|
+
/** The source's own id for it. */
|
|
122
|
+
externalId: string;
|
|
123
|
+
name: string | null;
|
|
124
|
+
}
|
|
92
125
|
/** What ingesting one document came to. */
|
|
93
126
|
export interface IngestOutcome {
|
|
94
127
|
documentId: string | null;
|
|
95
|
-
/** created · updated · unchanged_bytes · unchanged_content · failed · in_progress */
|
|
128
|
+
/** created · updated · unchanged_bytes · unchanged_content · unchanged_version · failed · quarantined · blocked · in_progress */
|
|
96
129
|
outcome: string;
|
|
97
130
|
/** Why it failed, for a failed outcome. */
|
|
98
131
|
error?: string;
|
|
@@ -137,7 +170,7 @@ export declare const startSync: (knowledgeBaseId: string, sourceId: string, corr
|
|
|
137
170
|
* POST /api/v1/knowledge-base/:id/sources/:sourceId/sync/finish
|
|
138
171
|
* @param {String} knowledgeBaseId The knowledge base
|
|
139
172
|
* @param {String} sourceId The source subdocument
|
|
140
|
-
* @param {SyncOutcome} outcome `completed`, and `count`, `lastError`, `correlationId` when there are any
|
|
173
|
+
* @param {SyncOutcome} outcome `completed`, and `count`, `lastError`, `correlationId`, `exhaustive`, `notIngested`, `registered` when there are any
|
|
141
174
|
* @param {String} token The run's AGENT token
|
|
142
175
|
* @returns {Promise<{ok: true}>}
|
|
143
176
|
*/
|
|
@@ -198,4 +231,46 @@ export declare const listSourceDocuments: (knowledgeBaseId: string, sourceId: st
|
|
|
198
231
|
* @returns {Promise<IngestOutcome>}
|
|
199
232
|
*/
|
|
200
233
|
export declare const ingestDocument: (knowledgeBaseId: string, sourceId: string, document: ListedDocument, correlationId: string | null, token: string) => Promise<IngestOutcome>;
|
|
234
|
+
/**
|
|
235
|
+
* Registers one listed page: the backend stores each entry, tells which
|
|
236
|
+
* documents changed since their last ingest, and marks them for this run. The
|
|
237
|
+
* run calls it once per page and ingests nothing until the listing has ended.
|
|
238
|
+
* An id listed twice in the run is counted once (`repeated`).
|
|
239
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents/register
|
|
240
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
241
|
+
* @param {String} sourceId The source subdocument
|
|
242
|
+
* @param {String} correlationId The run's own correlation id; the backend refuses any other
|
|
243
|
+
* @param {ListedDocument[]} documents One page of entries, as the connector listed them
|
|
244
|
+
* @param {String} token The run's AGENT token
|
|
245
|
+
* @returns {Promise<RegisteredDocuments>}
|
|
246
|
+
*/
|
|
247
|
+
export declare const registerSourceDocuments: (knowledgeBaseId: string, sourceId: string, correlationId: string, documents: ListedDocument[], token: string) => Promise<RegisteredDocuments>;
|
|
248
|
+
/**
|
|
249
|
+
* Pulls the next documents this run is to process. Each document is handed out
|
|
250
|
+
* once, so concurrent pullers never get the same one; an empty list means
|
|
251
|
+
* nothing is left.
|
|
252
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents/next
|
|
253
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
254
|
+
* @param {String} sourceId The source subdocument
|
|
255
|
+
* @param {String} correlationId The run's correlation id; the backend refuses any other
|
|
256
|
+
* @param {Number} limit How many at most, 1–50; the backend refuses any other
|
|
257
|
+
* @param {String} token The run's AGENT token
|
|
258
|
+
* @returns {Promise<{documents: QueuedDocument[]}>}
|
|
259
|
+
*/
|
|
260
|
+
export declare const nextSourceDocuments: (knowledgeBaseId: string, sourceId: string, correlationId: string, limit: number, token: string) => Promise<{
|
|
261
|
+
documents: QueuedDocument[];
|
|
262
|
+
}>;
|
|
263
|
+
/**
|
|
264
|
+
* Ingests a document the run registered, by its id: the backend already holds
|
|
265
|
+
* the listed entry. Answers as `ingestDocument` does; a document that could not
|
|
266
|
+
* be ingested is an outcome, not a rejection.
|
|
267
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents
|
|
268
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
269
|
+
* @param {String} sourceId The source subdocument
|
|
270
|
+
* @param {String} documentId The `documentId` of a `QueuedDocument`
|
|
271
|
+
* @param {String} correlationId The run's correlation id
|
|
272
|
+
* @param {String} token The run's AGENT token
|
|
273
|
+
* @returns {Promise<IngestOutcome>}
|
|
274
|
+
*/
|
|
275
|
+
export declare const ingestRegisteredDocument: (knowledgeBaseId: string, sourceId: string, documentId: string, correlationId: string, token: string) => Promise<IngestOutcome>;
|
|
201
276
|
//# sourceMappingURL=knowledgeBaseAgent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledgeBaseAgent.d.ts","sourceRoot":"","sources":["../../../src/lib/knowledgeBaseAgent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knowledgeBaseAgent.d.ts","sourceRoot":"","sources":["../../../src/lib/knowledgeBaseAgent.ts"],"names":[],"mappings":"AA6CA,yGAAyG;AACzG,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,2DAA2D;IAC3D,WAAW,EAAE,MAAM,EAAE,CAAC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
3
|
-
exports.ingestDocument = exports.listSourceDocuments = exports.reportAccounts = exports.finishSync = exports.startSync = exports.search = void 0;
|
|
3
|
+
exports.ingestRegisteredDocument = exports.nextSourceDocuments = exports.registerSourceDocuments = exports.ingestDocument = exports.listSourceDocuments = exports.reportAccounts = exports.finishSync = exports.startSync = exports.search = void 0;
|
|
4
4
|
const axiosClient_js_1 = require("./axiosClient.js");
|
|
5
5
|
//
|
|
6
6
|
// The knowledge-base calls an agent run makes.
|
|
@@ -13,10 +13,15 @@ const axiosClient_js_1 = require("./axiosClient.js");
|
|
|
13
13
|
// to synchronise (and to report a source's accounts). There is no user-facing
|
|
14
14
|
// search: retrieval is internal to the agents by design.
|
|
15
15
|
//
|
|
16
|
-
// The sync agent is data-blind. It orchestrates
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// and
|
|
16
|
+
// The sync agent is data-blind. It orchestrates and the backend does the work:
|
|
17
|
+
// fetching, parsing, chunking and embedding happen there, and the answers carry
|
|
18
|
+
// outcomes and counts, never the content. A run lists, registers, then pulls:
|
|
19
|
+
// it lists the source page by page and registers each page
|
|
20
|
+
// (`registerSourceDocuments`), so the whole source is known before any
|
|
21
|
+
// document is ingested; it then asks for the documents to process in batches
|
|
22
|
+
// (`nextSourceDocuments`) and ingests each by id
|
|
23
|
+
// (`ingestRegisteredDocument`). `ingestDocument`, which takes the listed entry
|
|
24
|
+
// itself, stays for agents still running the page-by-page flow.
|
|
20
25
|
//
|
|
21
26
|
const BASE = "/api/v1/knowledge-base";
|
|
22
27
|
const sourceOf = (knowledgeBaseId, sourceId) => `${BASE}/${encodeURIComponent(knowledgeBaseId)}/sources/${encodeURIComponent(sourceId)}`;
|
|
@@ -60,7 +65,7 @@ exports.startSync = startSync;
|
|
|
60
65
|
* POST /api/v1/knowledge-base/:id/sources/:sourceId/sync/finish
|
|
61
66
|
* @param {String} knowledgeBaseId The knowledge base
|
|
62
67
|
* @param {String} sourceId The source subdocument
|
|
63
|
-
* @param {SyncOutcome} outcome `completed`, and `count`, `lastError`, `correlationId` when there are any
|
|
68
|
+
* @param {SyncOutcome} outcome `completed`, and `count`, `lastError`, `correlationId`, `exhaustive`, `notIngested`, `registered` when there are any
|
|
64
69
|
* @param {String} token The run's AGENT token
|
|
65
70
|
* @returns {Promise<{ok: true}>}
|
|
66
71
|
*/
|
|
@@ -110,4 +115,47 @@ exports.listSourceDocuments = listSourceDocuments;
|
|
|
110
115
|
*/
|
|
111
116
|
const ingestDocument = (knowledgeBaseId, sourceId, document, correlationId, token) => answer(axiosClient_js_1.client.post(`${sourceOf(knowledgeBaseId, sourceId)}/documents`, { document, ...(correlationId ? { correlationId } : {}) }, headers(token)));
|
|
112
117
|
exports.ingestDocument = ingestDocument;
|
|
118
|
+
/**
|
|
119
|
+
* Registers one listed page: the backend stores each entry, tells which
|
|
120
|
+
* documents changed since their last ingest, and marks them for this run. The
|
|
121
|
+
* run calls it once per page and ingests nothing until the listing has ended.
|
|
122
|
+
* An id listed twice in the run is counted once (`repeated`).
|
|
123
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents/register
|
|
124
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
125
|
+
* @param {String} sourceId The source subdocument
|
|
126
|
+
* @param {String} correlationId The run's own correlation id; the backend refuses any other
|
|
127
|
+
* @param {ListedDocument[]} documents One page of entries, as the connector listed them
|
|
128
|
+
* @param {String} token The run's AGENT token
|
|
129
|
+
* @returns {Promise<RegisteredDocuments>}
|
|
130
|
+
*/
|
|
131
|
+
const registerSourceDocuments = (knowledgeBaseId, sourceId, correlationId, documents, token) => answer(axiosClient_js_1.client.post(`${sourceOf(knowledgeBaseId, sourceId)}/documents/register`, { correlationId, documents }, headers(token)));
|
|
132
|
+
exports.registerSourceDocuments = registerSourceDocuments;
|
|
133
|
+
/**
|
|
134
|
+
* Pulls the next documents this run is to process. Each document is handed out
|
|
135
|
+
* once, so concurrent pullers never get the same one; an empty list means
|
|
136
|
+
* nothing is left.
|
|
137
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents/next
|
|
138
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
139
|
+
* @param {String} sourceId The source subdocument
|
|
140
|
+
* @param {String} correlationId The run's correlation id; the backend refuses any other
|
|
141
|
+
* @param {Number} limit How many at most, 1–50; the backend refuses any other
|
|
142
|
+
* @param {String} token The run's AGENT token
|
|
143
|
+
* @returns {Promise<{documents: QueuedDocument[]}>}
|
|
144
|
+
*/
|
|
145
|
+
const nextSourceDocuments = (knowledgeBaseId, sourceId, correlationId, limit, token) => answer(axiosClient_js_1.client.post(`${sourceOf(knowledgeBaseId, sourceId)}/documents/next`, { correlationId, limit }, headers(token)));
|
|
146
|
+
exports.nextSourceDocuments = nextSourceDocuments;
|
|
147
|
+
/**
|
|
148
|
+
* Ingests a document the run registered, by its id: the backend already holds
|
|
149
|
+
* the listed entry. Answers as `ingestDocument` does; a document that could not
|
|
150
|
+
* be ingested is an outcome, not a rejection.
|
|
151
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents
|
|
152
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
153
|
+
* @param {String} sourceId The source subdocument
|
|
154
|
+
* @param {String} documentId The `documentId` of a `QueuedDocument`
|
|
155
|
+
* @param {String} correlationId The run's correlation id
|
|
156
|
+
* @param {String} token The run's AGENT token
|
|
157
|
+
* @returns {Promise<IngestOutcome>}
|
|
158
|
+
*/
|
|
159
|
+
const ingestRegisteredDocument = (knowledgeBaseId, sourceId, documentId, correlationId, token) => answer(axiosClient_js_1.client.post(`${sourceOf(knowledgeBaseId, sourceId)}/documents`, { documentId, correlationId }, headers(token)));
|
|
160
|
+
exports.ingestRegisteredDocument = ingestRegisteredDocument;
|
|
113
161
|
//# sourceMappingURL=knowledgeBaseAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledgeBaseAgent.js","sourceRoot":"","sources":["../../../src/lib/knowledgeBaseAgent.ts"],"names":[],"mappings":";;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,EAAE,QAAQ,CAAC,qBAAqB,EAC3D,EAAE,aAAa,EAAE,SAAS,EAAE,EAC5B,OAAO,CAAC,KAAK,CAAC,CACf,CACF,CAAC;AAbS,QAAA,uBAAuB,2BAahC;AAEJ;;;;;;;;;;;GAWG;AACI,MAAM,mBAAmB,GAAG,CACjC,eAAuB,EACvB,QAAgB,EAChB,aAAqB,EACrB,KAAa,EACb,KAAa,EAC6B,EAAE,CAC5C,MAAM,CACJ,uBAAM,CAAC,IAAI,CACT,GAAG,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC,iBAAiB,EACvD,EAAE,aAAa,EAAE,KAAK,EAAE,EACxB,OAAO,CAAC,KAAK,CAAC,CACf,CACF,CAAC;AAbS,QAAA,mBAAmB,uBAa5B;AAEJ;;;;;;;;;;;GAWG;AACI,MAAM,wBAAwB,GAAG,CACtC,eAAuB,EACvB,QAAgB,EAChB,UAAkB,EAClB,aAAqB,EACrB,KAAa,EACW,EAAE,CAC1B,MAAM,CACJ,uBAAM,CAAC,IAAI,CACT,GAAG,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC,YAAY,EAClD,EAAE,UAAU,EAAE,aAAa,EAAE,EAC7B,OAAO,CAAC,KAAK,CAAC,CACf,CACF,CAAC;AAbS,QAAA,wBAAwB,4BAajC"}
|
|
@@ -66,6 +66,16 @@ export interface SyncOutcome {
|
|
|
66
66
|
/** How many documents the source holds, when the run counted them. */
|
|
67
67
|
count?: number;
|
|
68
68
|
lastError?: string | null;
|
|
69
|
+
/**
|
|
70
|
+
* True when the run listed the whole source, so the backend may remove what
|
|
71
|
+
* the source no longer holds. A run that registered can say so even if it was
|
|
72
|
+
* cancelled or failed while processing.
|
|
73
|
+
*/
|
|
74
|
+
exhaustive?: boolean;
|
|
75
|
+
/** Listed ids the run did not ingest; ignored by the backend for a run that registered. */
|
|
76
|
+
notIngested?: string[];
|
|
77
|
+
/** True when the run registered its listing (the two-phase flow). */
|
|
78
|
+
registered?: boolean;
|
|
69
79
|
}
|
|
70
80
|
/** Which page of the source to list. */
|
|
71
81
|
export interface DocumentPage {
|
|
@@ -89,10 +99,33 @@ export interface ListedDocument {
|
|
|
89
99
|
mimeType?: string;
|
|
90
100
|
[field: string]: unknown;
|
|
91
101
|
}
|
|
102
|
+
/** What registering one page of the listing came to: counts of the entries it held. */
|
|
103
|
+
export interface RegisteredDocuments {
|
|
104
|
+
/** Every entry accepted: `toProcess + unchanged + blocked + inProgress + repeated`. */
|
|
105
|
+
registered: number;
|
|
106
|
+
/** New, changed since its last ingest, not settled, or listed without a version: to be ingested in full. */
|
|
107
|
+
toProcess: number;
|
|
108
|
+
/** Settled and unchanged: only their ACL is read. */
|
|
109
|
+
unchanged: number;
|
|
110
|
+
/** Left as they are: held by a reviewer. */
|
|
111
|
+
blocked: number;
|
|
112
|
+
/** Left as they are: being ingested by another request. */
|
|
113
|
+
inProgress: number;
|
|
114
|
+
/** An id this run had already registered, so counted once. */
|
|
115
|
+
repeated: number;
|
|
116
|
+
}
|
|
117
|
+
/** A registered document handed out for ingestion. */
|
|
118
|
+
export interface QueuedDocument {
|
|
119
|
+
/** The document's id in the knowledge base, to ingest by. */
|
|
120
|
+
documentId: string;
|
|
121
|
+
/** The source's own id for it. */
|
|
122
|
+
externalId: string;
|
|
123
|
+
name: string | null;
|
|
124
|
+
}
|
|
92
125
|
/** What ingesting one document came to. */
|
|
93
126
|
export interface IngestOutcome {
|
|
94
127
|
documentId: string | null;
|
|
95
|
-
/** created · updated · unchanged_bytes · unchanged_content · failed · in_progress */
|
|
128
|
+
/** created · updated · unchanged_bytes · unchanged_content · unchanged_version · failed · quarantined · blocked · in_progress */
|
|
96
129
|
outcome: string;
|
|
97
130
|
/** Why it failed, for a failed outcome. */
|
|
98
131
|
error?: string;
|
|
@@ -137,7 +170,7 @@ export declare const startSync: (knowledgeBaseId: string, sourceId: string, corr
|
|
|
137
170
|
* POST /api/v1/knowledge-base/:id/sources/:sourceId/sync/finish
|
|
138
171
|
* @param {String} knowledgeBaseId The knowledge base
|
|
139
172
|
* @param {String} sourceId The source subdocument
|
|
140
|
-
* @param {SyncOutcome} outcome `completed`, and `count`, `lastError`, `correlationId` when there are any
|
|
173
|
+
* @param {SyncOutcome} outcome `completed`, and `count`, `lastError`, `correlationId`, `exhaustive`, `notIngested`, `registered` when there are any
|
|
141
174
|
* @param {String} token The run's AGENT token
|
|
142
175
|
* @returns {Promise<{ok: true}>}
|
|
143
176
|
*/
|
|
@@ -198,4 +231,46 @@ export declare const listSourceDocuments: (knowledgeBaseId: string, sourceId: st
|
|
|
198
231
|
* @returns {Promise<IngestOutcome>}
|
|
199
232
|
*/
|
|
200
233
|
export declare const ingestDocument: (knowledgeBaseId: string, sourceId: string, document: ListedDocument, correlationId: string | null, token: string) => Promise<IngestOutcome>;
|
|
234
|
+
/**
|
|
235
|
+
* Registers one listed page: the backend stores each entry, tells which
|
|
236
|
+
* documents changed since their last ingest, and marks them for this run. The
|
|
237
|
+
* run calls it once per page and ingests nothing until the listing has ended.
|
|
238
|
+
* An id listed twice in the run is counted once (`repeated`).
|
|
239
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents/register
|
|
240
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
241
|
+
* @param {String} sourceId The source subdocument
|
|
242
|
+
* @param {String} correlationId The run's own correlation id; the backend refuses any other
|
|
243
|
+
* @param {ListedDocument[]} documents One page of entries, as the connector listed them
|
|
244
|
+
* @param {String} token The run's AGENT token
|
|
245
|
+
* @returns {Promise<RegisteredDocuments>}
|
|
246
|
+
*/
|
|
247
|
+
export declare const registerSourceDocuments: (knowledgeBaseId: string, sourceId: string, correlationId: string, documents: ListedDocument[], token: string) => Promise<RegisteredDocuments>;
|
|
248
|
+
/**
|
|
249
|
+
* Pulls the next documents this run is to process. Each document is handed out
|
|
250
|
+
* once, so concurrent pullers never get the same one; an empty list means
|
|
251
|
+
* nothing is left.
|
|
252
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents/next
|
|
253
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
254
|
+
* @param {String} sourceId The source subdocument
|
|
255
|
+
* @param {String} correlationId The run's correlation id; the backend refuses any other
|
|
256
|
+
* @param {Number} limit How many at most, 1–50; the backend refuses any other
|
|
257
|
+
* @param {String} token The run's AGENT token
|
|
258
|
+
* @returns {Promise<{documents: QueuedDocument[]}>}
|
|
259
|
+
*/
|
|
260
|
+
export declare const nextSourceDocuments: (knowledgeBaseId: string, sourceId: string, correlationId: string, limit: number, token: string) => Promise<{
|
|
261
|
+
documents: QueuedDocument[];
|
|
262
|
+
}>;
|
|
263
|
+
/**
|
|
264
|
+
* Ingests a document the run registered, by its id: the backend already holds
|
|
265
|
+
* the listed entry. Answers as `ingestDocument` does; a document that could not
|
|
266
|
+
* be ingested is an outcome, not a rejection.
|
|
267
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents
|
|
268
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
269
|
+
* @param {String} sourceId The source subdocument
|
|
270
|
+
* @param {String} documentId The `documentId` of a `QueuedDocument`
|
|
271
|
+
* @param {String} correlationId The run's correlation id
|
|
272
|
+
* @param {String} token The run's AGENT token
|
|
273
|
+
* @returns {Promise<IngestOutcome>}
|
|
274
|
+
*/
|
|
275
|
+
export declare const ingestRegisteredDocument: (knowledgeBaseId: string, sourceId: string, documentId: string, correlationId: string, token: string) => Promise<IngestOutcome>;
|
|
201
276
|
//# sourceMappingURL=knowledgeBaseAgent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledgeBaseAgent.d.ts","sourceRoot":"","sources":["../../../src/lib/knowledgeBaseAgent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knowledgeBaseAgent.d.ts","sourceRoot":"","sources":["../../../src/lib/knowledgeBaseAgent.ts"],"names":[],"mappings":"AA6CA,yGAAyG;AACzG,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,iBAAiB,CAAC,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O,MAAM,KACZ,OAAO,CAAC;IAAE,SAAS,EAAE,cAAc,EAAE,CAAA;CAAE,CAOvC,CAAC;AAEJ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,iBAAiB,MAAM,EACvB,UAAU,MAAM,EAChB,YAAY,MAAM,EAClB,eAAe,MAAM,EACrB,OAAO,MAAM,KACZ,OAAO,CAAC,aAAa,CAOrB,CAAC"}
|
|
@@ -10,10 +10,15 @@ import { client } from "./axiosClient.js";
|
|
|
10
10
|
// to synchronise (and to report a source's accounts). There is no user-facing
|
|
11
11
|
// search: retrieval is internal to the agents by design.
|
|
12
12
|
//
|
|
13
|
-
// The sync agent is data-blind. It orchestrates
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// and
|
|
13
|
+
// The sync agent is data-blind. It orchestrates and the backend does the work:
|
|
14
|
+
// fetching, parsing, chunking and embedding happen there, and the answers carry
|
|
15
|
+
// outcomes and counts, never the content. A run lists, registers, then pulls:
|
|
16
|
+
// it lists the source page by page and registers each page
|
|
17
|
+
// (`registerSourceDocuments`), so the whole source is known before any
|
|
18
|
+
// document is ingested; it then asks for the documents to process in batches
|
|
19
|
+
// (`nextSourceDocuments`) and ingests each by id
|
|
20
|
+
// (`ingestRegisteredDocument`). `ingestDocument`, which takes the listed entry
|
|
21
|
+
// itself, stays for agents still running the page-by-page flow.
|
|
17
22
|
//
|
|
18
23
|
const BASE = "/api/v1/knowledge-base";
|
|
19
24
|
const sourceOf = (knowledgeBaseId, sourceId) => `${BASE}/${encodeURIComponent(knowledgeBaseId)}/sources/${encodeURIComponent(sourceId)}`;
|
|
@@ -55,7 +60,7 @@ export const startSync = (knowledgeBaseId, sourceId, correlationId, token) => an
|
|
|
55
60
|
* POST /api/v1/knowledge-base/:id/sources/:sourceId/sync/finish
|
|
56
61
|
* @param {String} knowledgeBaseId The knowledge base
|
|
57
62
|
* @param {String} sourceId The source subdocument
|
|
58
|
-
* @param {SyncOutcome} outcome `completed`, and `count`, `lastError`, `correlationId` when there are any
|
|
63
|
+
* @param {SyncOutcome} outcome `completed`, and `count`, `lastError`, `correlationId`, `exhaustive`, `notIngested`, `registered` when there are any
|
|
59
64
|
* @param {String} token The run's AGENT token
|
|
60
65
|
* @returns {Promise<{ok: true}>}
|
|
61
66
|
*/
|
|
@@ -101,4 +106,44 @@ export const listSourceDocuments = (knowledgeBaseId, sourceId, page, token) => a
|
|
|
101
106
|
* @returns {Promise<IngestOutcome>}
|
|
102
107
|
*/
|
|
103
108
|
export const ingestDocument = (knowledgeBaseId, sourceId, document, correlationId, token) => answer(client.post(`${sourceOf(knowledgeBaseId, sourceId)}/documents`, { document, ...(correlationId ? { correlationId } : {}) }, headers(token)));
|
|
109
|
+
/**
|
|
110
|
+
* Registers one listed page: the backend stores each entry, tells which
|
|
111
|
+
* documents changed since their last ingest, and marks them for this run. The
|
|
112
|
+
* run calls it once per page and ingests nothing until the listing has ended.
|
|
113
|
+
* An id listed twice in the run is counted once (`repeated`).
|
|
114
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents/register
|
|
115
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
116
|
+
* @param {String} sourceId The source subdocument
|
|
117
|
+
* @param {String} correlationId The run's own correlation id; the backend refuses any other
|
|
118
|
+
* @param {ListedDocument[]} documents One page of entries, as the connector listed them
|
|
119
|
+
* @param {String} token The run's AGENT token
|
|
120
|
+
* @returns {Promise<RegisteredDocuments>}
|
|
121
|
+
*/
|
|
122
|
+
export const registerSourceDocuments = (knowledgeBaseId, sourceId, correlationId, documents, token) => answer(client.post(`${sourceOf(knowledgeBaseId, sourceId)}/documents/register`, { correlationId, documents }, headers(token)));
|
|
123
|
+
/**
|
|
124
|
+
* Pulls the next documents this run is to process. Each document is handed out
|
|
125
|
+
* once, so concurrent pullers never get the same one; an empty list means
|
|
126
|
+
* nothing is left.
|
|
127
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents/next
|
|
128
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
129
|
+
* @param {String} sourceId The source subdocument
|
|
130
|
+
* @param {String} correlationId The run's correlation id; the backend refuses any other
|
|
131
|
+
* @param {Number} limit How many at most, 1–50; the backend refuses any other
|
|
132
|
+
* @param {String} token The run's AGENT token
|
|
133
|
+
* @returns {Promise<{documents: QueuedDocument[]}>}
|
|
134
|
+
*/
|
|
135
|
+
export const nextSourceDocuments = (knowledgeBaseId, sourceId, correlationId, limit, token) => answer(client.post(`${sourceOf(knowledgeBaseId, sourceId)}/documents/next`, { correlationId, limit }, headers(token)));
|
|
136
|
+
/**
|
|
137
|
+
* Ingests a document the run registered, by its id: the backend already holds
|
|
138
|
+
* the listed entry. Answers as `ingestDocument` does; a document that could not
|
|
139
|
+
* be ingested is an outcome, not a rejection.
|
|
140
|
+
* POST /api/v1/knowledge-base/:id/sources/:sourceId/documents
|
|
141
|
+
* @param {String} knowledgeBaseId The knowledge base
|
|
142
|
+
* @param {String} sourceId The source subdocument
|
|
143
|
+
* @param {String} documentId The `documentId` of a `QueuedDocument`
|
|
144
|
+
* @param {String} correlationId The run's correlation id
|
|
145
|
+
* @param {String} token The run's AGENT token
|
|
146
|
+
* @returns {Promise<IngestOutcome>}
|
|
147
|
+
*/
|
|
148
|
+
export const ingestRegisteredDocument = (knowledgeBaseId, sourceId, documentId, correlationId, token) => answer(client.post(`${sourceOf(knowledgeBaseId, sourceId)}/documents`, { documentId, correlationId }, headers(token)));
|
|
104
149
|
//# sourceMappingURL=knowledgeBaseAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledgeBaseAgent.js","sourceRoot":"","sources":["../../../src/lib/knowledgeBaseAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,sEAAsE;AACtE,0EAA0E;AAC1E,6EAA6E;AAC7E,8EA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