nenavi 0.0.0 → 0.1.0-alpha.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/LICENSE +191 -0
- package/README.md +72 -1
- package/dist/cjs/client.d.ts +328 -0
- package/dist/cjs/client.js +918 -0
- package/dist/cjs/core.d.ts +80 -0
- package/dist/cjs/core.js +426 -0
- package/dist/cjs/errors.d.ts +129 -0
- package/dist/cjs/errors.js +305 -0
- package/dist/cjs/generated/openapi.d.ts +8109 -0
- package/dist/cjs/generated/openapi.js +4 -0
- package/dist/cjs/generated/spec.d.ts +4 -0
- package/dist/cjs/generated/spec.js +9 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.d.ts +115 -0
- package/dist/cjs/types.js +7 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +5 -0
- package/dist/esm/client.d.ts +328 -0
- package/dist/esm/client.js +896 -0
- package/dist/esm/core.d.ts +80 -0
- package/dist/esm/core.js +416 -0
- package/dist/esm/errors.d.ts +129 -0
- package/dist/esm/errors.js +282 -0
- package/dist/esm/generated/openapi.d.ts +8109 -0
- package/dist/esm/generated/openapi.js +3 -0
- package/dist/esm/generated/spec.d.ts +4 -0
- package/dist/esm/generated/spec.js +6 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.d.ts +115 -0
- package/dist/esm/types.js +6 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +2 -0
- package/package.json +45 -3
|
@@ -0,0 +1,918 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The client, `Nenavi`, and its resource groups (sdks/CONTRACT.md, Operations).
|
|
3
|
+
//
|
|
4
|
+
// Each method describes one call: its HTTP method and path, where its fields go, and
|
|
5
|
+
// whether the SDK may retry it by itself. Core in core.ts sends it.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Nenavi = exports.NenaviMethods = exports.ReingestWithHelpers = exports.NodesWithHelpers = exports.EventsWithHelpers = exports.Learning = exports.LearningProfiles = exports.AnswerCitations = exports.Relevance = exports.Retrievals = exports.Quantities = exports.Assertions = exports.Extractions = exports.Materializations = exports.AliasProposals = exports.Claims = exports.Reingest = exports.Nodes = exports.Events = void 0;
|
|
8
|
+
const errors_js_1 = require("./errors.js");
|
|
9
|
+
const core_js_1 = require("./core.js");
|
|
10
|
+
class Resource {
|
|
11
|
+
_core;
|
|
12
|
+
_raw;
|
|
13
|
+
constructor(core, raw) {
|
|
14
|
+
this._core = core;
|
|
15
|
+
this._raw = raw;
|
|
16
|
+
}
|
|
17
|
+
/** Build the call and send it; an error while building it rejects the promise too. */
|
|
18
|
+
_request(build) {
|
|
19
|
+
let call;
|
|
20
|
+
try {
|
|
21
|
+
call = build();
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return Promise.reject(error);
|
|
25
|
+
}
|
|
26
|
+
return this._core.request(call, this._raw);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The states a helper keeps polling through. Any other state, one the service adds later
|
|
31
|
+
* included, is final and returned.
|
|
32
|
+
*/
|
|
33
|
+
const WORKING = new Set(['pending', 'running']);
|
|
34
|
+
/** `GET /v1/events/{event_id}/extraction-status`, for the method and its helper. */
|
|
35
|
+
function extractionStatusCall(eventId, options) {
|
|
36
|
+
return {
|
|
37
|
+
method: 'GET',
|
|
38
|
+
path: `/v1/events/${(0, core_js_1.pathParam)(eventId)}/extraction-status`,
|
|
39
|
+
retrySafe: true,
|
|
40
|
+
options,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** `GET /v1/reingest/{run_id}`, for the method and its helper. */
|
|
44
|
+
function reingestGetCall(runId, options) {
|
|
45
|
+
return { method: 'GET', path: `/v1/reingest/${(0, core_js_1.pathParam)(runId)}`, retrySafe: true, options };
|
|
46
|
+
}
|
|
47
|
+
/** A caller's `Idempotency-Key`, or null; an empty value counts as not given. */
|
|
48
|
+
function callerKey(options) {
|
|
49
|
+
const key = (0, core_js_1.ownProperties)(options).idempotencyKey;
|
|
50
|
+
return key ? String(key) : null;
|
|
51
|
+
}
|
|
52
|
+
/** The `/v1/events` routes. */
|
|
53
|
+
class Events extends Resource {
|
|
54
|
+
/** `GET /v1/events/{event_id}`: the stored event, as the JSON object it is. */
|
|
55
|
+
get(eventId, options) {
|
|
56
|
+
return this._request(() => ({
|
|
57
|
+
method: 'GET',
|
|
58
|
+
path: `/v1/events/${(0, core_js_1.pathParam)(eventId)}`,
|
|
59
|
+
retrySafe: true,
|
|
60
|
+
options,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
/** `GET /v1/events/{event_id}/nodes`: the nodes derived from the event. */
|
|
64
|
+
nodes(eventId, options) {
|
|
65
|
+
return this._request(() => ({
|
|
66
|
+
method: 'GET',
|
|
67
|
+
path: `/v1/events/${(0, core_js_1.pathParam)(eventId)}/nodes`,
|
|
68
|
+
retrySafe: true,
|
|
69
|
+
options,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
/** `GET /v1/events/{event_id}/processing-status`. */
|
|
73
|
+
processingStatus(eventId, options) {
|
|
74
|
+
return this._request(() => ({
|
|
75
|
+
method: 'GET',
|
|
76
|
+
path: `/v1/events/${(0, core_js_1.pathParam)(eventId)}/processing-status`,
|
|
77
|
+
retrySafe: true,
|
|
78
|
+
options,
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
/** `GET /v1/events/{event_id}/extraction`: the record, or its protected view. */
|
|
82
|
+
extraction(eventId, options) {
|
|
83
|
+
return this._request(() => ({
|
|
84
|
+
method: 'GET',
|
|
85
|
+
path: `/v1/events/${(0, core_js_1.pathParam)(eventId)}/extraction`,
|
|
86
|
+
retrySafe: true,
|
|
87
|
+
options,
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
/** `GET /v1/events/{event_id}/extraction-status`. */
|
|
91
|
+
extractionStatus(eventId, options) {
|
|
92
|
+
return this._request(() => extractionStatusCall(eventId, options));
|
|
93
|
+
}
|
|
94
|
+
/** `POST /v1/events/{event_id}/retry-extraction`. Not retried automatically. */
|
|
95
|
+
retryExtraction(eventId, params, options) {
|
|
96
|
+
return this._request(() => ({
|
|
97
|
+
method: 'POST',
|
|
98
|
+
path: `/v1/events/${(0, core_js_1.pathParam)(eventId)}/retry-extraction`,
|
|
99
|
+
retrySafe: false,
|
|
100
|
+
query: params,
|
|
101
|
+
options,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.Events = Events;
|
|
106
|
+
/** The `/v1/nodes` routes. */
|
|
107
|
+
class Nodes extends Resource {
|
|
108
|
+
/** `GET /v1/nodes/{node_id}`. */
|
|
109
|
+
get(nodeId, options) {
|
|
110
|
+
return this._request(() => ({
|
|
111
|
+
method: 'GET',
|
|
112
|
+
path: `/v1/nodes/${(0, core_js_1.pathParam)(nodeId)}`,
|
|
113
|
+
retrySafe: true,
|
|
114
|
+
options,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
/** `GET /v1/nodes`: list nodes. */
|
|
118
|
+
list(params, options) {
|
|
119
|
+
return this._request(() => ({
|
|
120
|
+
method: 'GET',
|
|
121
|
+
path: '/v1/nodes',
|
|
122
|
+
retrySafe: true,
|
|
123
|
+
query: params,
|
|
124
|
+
options,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* `GET /v1/nodes/scan`: one page of nodes, in id order.
|
|
129
|
+
*
|
|
130
|
+
* While the page's `has_more` is true, pass its `next_cursor` as `after_id` to read the
|
|
131
|
+
* next page.
|
|
132
|
+
*/
|
|
133
|
+
scan(params, options) {
|
|
134
|
+
return this._request(() => ({
|
|
135
|
+
method: 'GET',
|
|
136
|
+
path: '/v1/nodes/scan',
|
|
137
|
+
retrySafe: true,
|
|
138
|
+
query: params,
|
|
139
|
+
options,
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
/** `GET /v1/nodes/{node_id}/provenance`: the provenance, or its protected view. */
|
|
143
|
+
provenance(nodeId, params, options) {
|
|
144
|
+
return this._request(() => ({
|
|
145
|
+
method: 'GET',
|
|
146
|
+
path: `/v1/nodes/${(0, core_js_1.pathParam)(nodeId)}/provenance`,
|
|
147
|
+
retrySafe: true,
|
|
148
|
+
query: params,
|
|
149
|
+
options,
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
/** `PUT /v1/nodes/{node_id}/promote`. Not retried automatically. */
|
|
153
|
+
promote(nodeId, options) {
|
|
154
|
+
return this._request(() => ({
|
|
155
|
+
method: 'PUT',
|
|
156
|
+
path: `/v1/nodes/${(0, core_js_1.pathParam)(nodeId)}/promote`,
|
|
157
|
+
retrySafe: false,
|
|
158
|
+
idempotencyKey: callerKey(options),
|
|
159
|
+
options,
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
/** `PUT /v1/nodes/{node_id}/archive`. Not retried automatically. */
|
|
163
|
+
archive(nodeId, options) {
|
|
164
|
+
return this._request(() => ({
|
|
165
|
+
method: 'PUT',
|
|
166
|
+
path: `/v1/nodes/${(0, core_js_1.pathParam)(nodeId)}/archive`,
|
|
167
|
+
retrySafe: false,
|
|
168
|
+
idempotencyKey: callerKey(options),
|
|
169
|
+
options,
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* `PUT /v1/nodes/{node_id}/reinforce`. Not retried automatically.
|
|
174
|
+
*
|
|
175
|
+
* Sends a body only when `params` has a field.
|
|
176
|
+
*/
|
|
177
|
+
reinforce(nodeId, params, options) {
|
|
178
|
+
const given = Object.values(params ?? {}).some((value) => value !== undefined);
|
|
179
|
+
return this._request(() => ({
|
|
180
|
+
method: 'PUT',
|
|
181
|
+
path: `/v1/nodes/${(0, core_js_1.pathParam)(nodeId)}/reinforce`,
|
|
182
|
+
retrySafe: false,
|
|
183
|
+
body: given ? params : undefined,
|
|
184
|
+
idempotencyKey: callerKey(options),
|
|
185
|
+
options,
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
/** `PUT /v1/nodes/{node_id}/condition`: record a conditional claim's state. Not retried automatically. */
|
|
189
|
+
evaluateCondition(nodeId, params, options) {
|
|
190
|
+
return this._request(() => ({
|
|
191
|
+
method: 'PUT',
|
|
192
|
+
path: `/v1/nodes/${(0, core_js_1.pathParam)(nodeId)}/condition`,
|
|
193
|
+
retrySafe: false,
|
|
194
|
+
body: params ?? {},
|
|
195
|
+
idempotencyKey: callerKey(options),
|
|
196
|
+
options,
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
/** `GET /v1/nodes/{node_id}/neighborhood`: the nodes within `max_hops` edges. */
|
|
200
|
+
neighborhood(nodeId, params, options) {
|
|
201
|
+
return this._request(() => ({
|
|
202
|
+
method: 'GET',
|
|
203
|
+
path: `/v1/nodes/${(0, core_js_1.pathParam)(nodeId)}/neighborhood`,
|
|
204
|
+
retrySafe: true,
|
|
205
|
+
query: params,
|
|
206
|
+
options,
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
/** `GET /v1/nodes/{node_id}/chain`: the node's supersedence chain. */
|
|
210
|
+
chain(nodeId, params, options) {
|
|
211
|
+
return this._request(() => ({
|
|
212
|
+
method: 'GET',
|
|
213
|
+
path: `/v1/nodes/${(0, core_js_1.pathParam)(nodeId)}/chain`,
|
|
214
|
+
retrySafe: true,
|
|
215
|
+
query: params,
|
|
216
|
+
options,
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.Nodes = Nodes;
|
|
221
|
+
/** The `/v1/reingest` routes: re-derive one end user's stored memories. */
|
|
222
|
+
class Reingest extends Resource {
|
|
223
|
+
/**
|
|
224
|
+
* `POST /v1/reingest` with `dry_run: true`: count and estimate a run.
|
|
225
|
+
*
|
|
226
|
+
* Always sends `dry_run: true`, so a preview never starts a run. Not retried
|
|
227
|
+
* automatically.
|
|
228
|
+
*/
|
|
229
|
+
preview(params, options) {
|
|
230
|
+
return this._request(() => ({
|
|
231
|
+
method: 'POST',
|
|
232
|
+
path: '/v1/reingest',
|
|
233
|
+
retrySafe: false,
|
|
234
|
+
body: { ...(0, core_js_1.ownProperties)(params), dry_run: true },
|
|
235
|
+
options,
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* `POST /v1/reingest` with `dry_run: false`: start a background run.
|
|
240
|
+
*
|
|
241
|
+
* The service answers `202` with the run's `run_id`, or `200` with `run_id: null` when
|
|
242
|
+
* nothing needs re-deriving. Each memory the run takes counts as one ingest call. A run
|
|
243
|
+
* takes at most `limit` memories, so a `complete` run can leave some for later
|
|
244
|
+
* (`remaining` above 0): sending the same request again continues it. Not retried
|
|
245
|
+
* automatically; a `409` `reingest_running` throws `ConflictError`.
|
|
246
|
+
*/
|
|
247
|
+
start(params, options) {
|
|
248
|
+
return this._request(() => ({
|
|
249
|
+
method: 'POST',
|
|
250
|
+
path: '/v1/reingest',
|
|
251
|
+
retrySafe: false,
|
|
252
|
+
body: { ...(0, core_js_1.ownProperties)(params), dry_run: false },
|
|
253
|
+
options,
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
/** `GET /v1/reingest/{run_id}`: the run's state, counts and usage. */
|
|
257
|
+
get(runId, options) {
|
|
258
|
+
return this._request(() => reingestGetCall(runId, options));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.Reingest = Reingest;
|
|
262
|
+
/** The claim routes: supersedences and contradictions. Not retried automatically. */
|
|
263
|
+
class Claims extends Resource {
|
|
264
|
+
/** `POST /v1/supersedences`: record that one claim replaces another. */
|
|
265
|
+
supersede(params, options) {
|
|
266
|
+
return this._request(() => ({
|
|
267
|
+
method: 'POST',
|
|
268
|
+
path: '/v1/supersedences',
|
|
269
|
+
retrySafe: false,
|
|
270
|
+
body: params ?? {},
|
|
271
|
+
options,
|
|
272
|
+
}));
|
|
273
|
+
}
|
|
274
|
+
/** `POST /v1/contradictions`: mark two claims as contradicting each other. */
|
|
275
|
+
markContradiction(params, options) {
|
|
276
|
+
return this._request(() => ({
|
|
277
|
+
method: 'POST',
|
|
278
|
+
path: '/v1/contradictions',
|
|
279
|
+
retrySafe: false,
|
|
280
|
+
body: params ?? {},
|
|
281
|
+
options,
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
/** `POST /v1/contradictions/resolve`: resolve a contradiction in favor of one claim. */
|
|
285
|
+
resolveContradiction(params, options) {
|
|
286
|
+
return this._request(() => ({
|
|
287
|
+
method: 'POST',
|
|
288
|
+
path: '/v1/contradictions/resolve',
|
|
289
|
+
retrySafe: false,
|
|
290
|
+
body: params ?? {},
|
|
291
|
+
options,
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
exports.Claims = Claims;
|
|
296
|
+
/** The `/v1/alias-proposals` routes: identity review. */
|
|
297
|
+
class AliasProposals extends Resource {
|
|
298
|
+
/** `GET /v1/alias-proposals`: the alias proposals waiting for review. */
|
|
299
|
+
list(params, options) {
|
|
300
|
+
return this._request(() => ({
|
|
301
|
+
method: 'GET',
|
|
302
|
+
path: '/v1/alias-proposals',
|
|
303
|
+
retrySafe: true,
|
|
304
|
+
query: params,
|
|
305
|
+
answer: 'array',
|
|
306
|
+
options,
|
|
307
|
+
}));
|
|
308
|
+
}
|
|
309
|
+
/** `POST /v1/alias-proposals/{proposal_operation_id}/review`. Not retried automatically. */
|
|
310
|
+
review(proposalOperationId, params, options) {
|
|
311
|
+
return this._request(() => ({
|
|
312
|
+
method: 'POST',
|
|
313
|
+
path: `/v1/alias-proposals/${(0, core_js_1.pathParam)(proposalOperationId)}/review`,
|
|
314
|
+
retrySafe: false,
|
|
315
|
+
body: params ?? {},
|
|
316
|
+
options,
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
exports.AliasProposals = AliasProposals;
|
|
321
|
+
/** The `/v1/materializations` routes. */
|
|
322
|
+
class Materializations extends Resource {
|
|
323
|
+
/** `POST /v1/materializations/process`: run the due materializations. Not retried automatically. */
|
|
324
|
+
process(params, options) {
|
|
325
|
+
return this._request(() => ({
|
|
326
|
+
method: 'POST',
|
|
327
|
+
path: '/v1/materializations/process',
|
|
328
|
+
retrySafe: false,
|
|
329
|
+
body: params ?? {},
|
|
330
|
+
options,
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
exports.Materializations = Materializations;
|
|
335
|
+
/** The `/v1/extractions` routes. */
|
|
336
|
+
class Extractions extends Resource {
|
|
337
|
+
/** `POST /v1/extractions/process`: run the due extraction jobs. Not retried automatically. */
|
|
338
|
+
process(params, options) {
|
|
339
|
+
return this._request(() => ({
|
|
340
|
+
method: 'POST',
|
|
341
|
+
path: '/v1/extractions/process',
|
|
342
|
+
retrySafe: false,
|
|
343
|
+
body: params ?? {},
|
|
344
|
+
options,
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
exports.Extractions = Extractions;
|
|
349
|
+
/** The `/v1/assertions` routes: exact queries over assertions. Not retried automatically. */
|
|
350
|
+
class Assertions extends Resource {
|
|
351
|
+
/** `POST /v1/assertions/aggregate`. */
|
|
352
|
+
aggregate(params, options) {
|
|
353
|
+
return this._request(() => ({
|
|
354
|
+
method: 'POST',
|
|
355
|
+
path: '/v1/assertions/aggregate',
|
|
356
|
+
retrySafe: false,
|
|
357
|
+
body: params ?? {},
|
|
358
|
+
options,
|
|
359
|
+
}));
|
|
360
|
+
}
|
|
361
|
+
/** `POST /v1/assertions/state`. */
|
|
362
|
+
state(params, options) {
|
|
363
|
+
return this._request(() => ({
|
|
364
|
+
method: 'POST',
|
|
365
|
+
path: '/v1/assertions/state',
|
|
366
|
+
retrySafe: false,
|
|
367
|
+
body: params ?? {},
|
|
368
|
+
options,
|
|
369
|
+
}));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
exports.Assertions = Assertions;
|
|
373
|
+
/** The `/v1/quantities` routes: exact queries over quantities. Not retried automatically. */
|
|
374
|
+
class Quantities extends Resource {
|
|
375
|
+
/** `POST /v1/quantities/aggregate`. */
|
|
376
|
+
aggregate(params, options) {
|
|
377
|
+
return this._request(() => ({
|
|
378
|
+
method: 'POST',
|
|
379
|
+
path: '/v1/quantities/aggregate',
|
|
380
|
+
retrySafe: false,
|
|
381
|
+
body: params ?? {},
|
|
382
|
+
options,
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
385
|
+
/** `POST /v1/quantities/aggregate-text`: plan and run an aggregation from a question. */
|
|
386
|
+
aggregateText(params, options) {
|
|
387
|
+
return this._request(() => ({
|
|
388
|
+
method: 'POST',
|
|
389
|
+
path: '/v1/quantities/aggregate-text',
|
|
390
|
+
retrySafe: false,
|
|
391
|
+
body: params ?? {},
|
|
392
|
+
options,
|
|
393
|
+
}));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
exports.Quantities = Quantities;
|
|
397
|
+
/** The `/v1/retrievals` routes: retrieval receipts. */
|
|
398
|
+
class Retrievals extends Resource {
|
|
399
|
+
/** `GET /v1/retrievals/{request_id}`: the receipt, or one of its protected views. */
|
|
400
|
+
get(requestId, params, options) {
|
|
401
|
+
return this._request(() => ({
|
|
402
|
+
method: 'GET',
|
|
403
|
+
path: `/v1/retrievals/${(0, core_js_1.pathParam)(requestId)}`,
|
|
404
|
+
retrySafe: true,
|
|
405
|
+
query: params,
|
|
406
|
+
options,
|
|
407
|
+
}));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
exports.Retrievals = Retrievals;
|
|
411
|
+
/** The `/v1/relevance` routes: relevance feedback. */
|
|
412
|
+
class Relevance extends Resource {
|
|
413
|
+
/** `POST /v1/relevance`: record feedback on a retrieved memory. Not retried automatically. */
|
|
414
|
+
record(params, options) {
|
|
415
|
+
return this._request(() => ({
|
|
416
|
+
method: 'POST',
|
|
417
|
+
path: '/v1/relevance',
|
|
418
|
+
retrySafe: false,
|
|
419
|
+
body: params ?? {},
|
|
420
|
+
options,
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
/** `GET /v1/relevance`: the recorded feedback. */
|
|
424
|
+
list(params, options) {
|
|
425
|
+
return this._request(() => ({
|
|
426
|
+
method: 'GET',
|
|
427
|
+
path: '/v1/relevance',
|
|
428
|
+
retrySafe: true,
|
|
429
|
+
query: params,
|
|
430
|
+
answer: 'array',
|
|
431
|
+
options,
|
|
432
|
+
}));
|
|
433
|
+
}
|
|
434
|
+
/** `GET /v1/relevance/{feedback_id}`. */
|
|
435
|
+
get(feedbackId, params, options) {
|
|
436
|
+
return this._request(() => ({
|
|
437
|
+
method: 'GET',
|
|
438
|
+
path: `/v1/relevance/${(0, core_js_1.pathParam)(feedbackId)}`,
|
|
439
|
+
retrySafe: true,
|
|
440
|
+
query: params,
|
|
441
|
+
options,
|
|
442
|
+
}));
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
exports.Relevance = Relevance;
|
|
446
|
+
/** The `/v1/answer-citations` routes: which memories an answer cited. */
|
|
447
|
+
class AnswerCitations extends Resource {
|
|
448
|
+
/** `POST /v1/answer-citations`: record an answer's citations. Not retried automatically. */
|
|
449
|
+
record(params, options) {
|
|
450
|
+
return this._request(() => ({
|
|
451
|
+
method: 'POST',
|
|
452
|
+
path: '/v1/answer-citations',
|
|
453
|
+
retrySafe: false,
|
|
454
|
+
body: params ?? {},
|
|
455
|
+
options,
|
|
456
|
+
}));
|
|
457
|
+
}
|
|
458
|
+
/** `GET /v1/answer-citations`: the recorded citations, each a record or its protected view. */
|
|
459
|
+
list(params, options) {
|
|
460
|
+
return this._request(() => ({
|
|
461
|
+
method: 'GET',
|
|
462
|
+
path: '/v1/answer-citations',
|
|
463
|
+
retrySafe: true,
|
|
464
|
+
query: params,
|
|
465
|
+
answer: 'array',
|
|
466
|
+
options,
|
|
467
|
+
}));
|
|
468
|
+
}
|
|
469
|
+
/** `GET /v1/answer-citations/{citation_id}`: the record, or its protected view. */
|
|
470
|
+
get(citationId, params, options) {
|
|
471
|
+
return this._request(() => ({
|
|
472
|
+
method: 'GET',
|
|
473
|
+
path: `/v1/answer-citations/${(0, core_js_1.pathParam)(citationId)}`,
|
|
474
|
+
retrySafe: true,
|
|
475
|
+
query: params,
|
|
476
|
+
options,
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
exports.AnswerCitations = AnswerCitations;
|
|
481
|
+
/** The `/v1/learning/profiles` routes: ranking profiles. */
|
|
482
|
+
class LearningProfiles extends Resource {
|
|
483
|
+
/** `GET /v1/learning/profiles`. */
|
|
484
|
+
list(params, options) {
|
|
485
|
+
return this._request(() => ({
|
|
486
|
+
method: 'GET',
|
|
487
|
+
path: '/v1/learning/profiles',
|
|
488
|
+
retrySafe: true,
|
|
489
|
+
query: params,
|
|
490
|
+
answer: 'array',
|
|
491
|
+
options,
|
|
492
|
+
}));
|
|
493
|
+
}
|
|
494
|
+
/** `POST /v1/learning/profiles`: create a profile. Not retried automatically. */
|
|
495
|
+
create(params, options) {
|
|
496
|
+
return this._request(() => ({
|
|
497
|
+
method: 'POST',
|
|
498
|
+
path: '/v1/learning/profiles',
|
|
499
|
+
retrySafe: false,
|
|
500
|
+
body: params ?? {},
|
|
501
|
+
options,
|
|
502
|
+
}));
|
|
503
|
+
}
|
|
504
|
+
/** `GET /v1/learning/profiles/{profile_id}`: the profile and its status. */
|
|
505
|
+
get(profileId, params, options) {
|
|
506
|
+
return this._request(() => ({
|
|
507
|
+
method: 'GET',
|
|
508
|
+
path: `/v1/learning/profiles/${(0, core_js_1.pathParam)(profileId)}`,
|
|
509
|
+
retrySafe: true,
|
|
510
|
+
query: params,
|
|
511
|
+
options,
|
|
512
|
+
}));
|
|
513
|
+
}
|
|
514
|
+
/** `GET /v1/learning/profiles/active`: the active profile, or null when none is. */
|
|
515
|
+
active(params, options) {
|
|
516
|
+
return this._request(() => ({
|
|
517
|
+
method: 'GET',
|
|
518
|
+
path: '/v1/learning/profiles/active',
|
|
519
|
+
retrySafe: true,
|
|
520
|
+
query: params,
|
|
521
|
+
answer: 'nullable',
|
|
522
|
+
options,
|
|
523
|
+
}));
|
|
524
|
+
}
|
|
525
|
+
/** `GET /v1/learning/profiles/history`: the activation history. */
|
|
526
|
+
history(params, options) {
|
|
527
|
+
return this._request(() => ({
|
|
528
|
+
method: 'GET',
|
|
529
|
+
path: '/v1/learning/profiles/history',
|
|
530
|
+
retrySafe: true,
|
|
531
|
+
query: params,
|
|
532
|
+
answer: 'array',
|
|
533
|
+
options,
|
|
534
|
+
}));
|
|
535
|
+
}
|
|
536
|
+
/** `POST /v1/learning/profiles/{profile_id}/activate`. Not retried automatically. */
|
|
537
|
+
activate(profileId, params, options) {
|
|
538
|
+
return this._request(() => ({
|
|
539
|
+
method: 'POST',
|
|
540
|
+
path: `/v1/learning/profiles/${(0, core_js_1.pathParam)(profileId)}/activate`,
|
|
541
|
+
retrySafe: false,
|
|
542
|
+
body: params ?? {},
|
|
543
|
+
options,
|
|
544
|
+
}));
|
|
545
|
+
}
|
|
546
|
+
/** `POST /v1/learning/profiles/deactivate`: null when no profile was active. Not retried automatically. */
|
|
547
|
+
deactivate(params, options) {
|
|
548
|
+
return this._request(() => ({
|
|
549
|
+
method: 'POST',
|
|
550
|
+
path: '/v1/learning/profiles/deactivate',
|
|
551
|
+
retrySafe: false,
|
|
552
|
+
body: params ?? {},
|
|
553
|
+
answer: 'nullable',
|
|
554
|
+
options,
|
|
555
|
+
}));
|
|
556
|
+
}
|
|
557
|
+
/** `POST /v1/learning/profiles/rollback`. Not retried automatically. */
|
|
558
|
+
rollback(params, options) {
|
|
559
|
+
return this._request(() => ({
|
|
560
|
+
method: 'POST',
|
|
561
|
+
path: '/v1/learning/profiles/rollback',
|
|
562
|
+
retrySafe: false,
|
|
563
|
+
body: params ?? {},
|
|
564
|
+
options,
|
|
565
|
+
}));
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
exports.LearningProfiles = LearningProfiles;
|
|
569
|
+
/** The `/v1/learning` routes: offline evaluation and ranking profiles. */
|
|
570
|
+
class Learning extends Resource {
|
|
571
|
+
profiles;
|
|
572
|
+
constructor(core, raw) {
|
|
573
|
+
super(core, raw);
|
|
574
|
+
this.profiles = new LearningProfiles(core, raw);
|
|
575
|
+
}
|
|
576
|
+
/** `POST /v1/learning/evaluate`. Not retried automatically. */
|
|
577
|
+
evaluate(params, options) {
|
|
578
|
+
return this._request(() => ({
|
|
579
|
+
method: 'POST',
|
|
580
|
+
path: '/v1/learning/evaluate',
|
|
581
|
+
retrySafe: false,
|
|
582
|
+
body: params ?? {},
|
|
583
|
+
options,
|
|
584
|
+
}));
|
|
585
|
+
}
|
|
586
|
+
/** `POST /v1/learning/evaluate-full-retrieval`. Not retried automatically. */
|
|
587
|
+
evaluateFullRetrieval(params, options) {
|
|
588
|
+
return this._request(() => ({
|
|
589
|
+
method: 'POST',
|
|
590
|
+
path: '/v1/learning/evaluate-full-retrieval',
|
|
591
|
+
retrySafe: false,
|
|
592
|
+
body: params ?? {},
|
|
593
|
+
options,
|
|
594
|
+
}));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
exports.Learning = Learning;
|
|
598
|
+
// The helpers (sdks/CONTRACT.md, Helpers) live on the parsed form only: the raw view has
|
|
599
|
+
// every operation and no helpers. Each poll is an ordinary call, with its retries and errors.
|
|
600
|
+
/** `client.events`: the event routes and `waitForExtraction()`. */
|
|
601
|
+
class EventsWithHelpers extends Events {
|
|
602
|
+
/**
|
|
603
|
+
* Poll the event's extraction status until it is no longer `pending` or `running`.
|
|
604
|
+
*
|
|
605
|
+
* Polls `GET /v1/events/{event_id}/extraction-status` at once and then every
|
|
606
|
+
* `interval` milliseconds (2 000), and returns the first status that is not `pending`
|
|
607
|
+
* or `running`: `complete`, `failed` (returned, not thrown), or a status this SDK does
|
|
608
|
+
* not know yet. When `timeout` milliseconds (300 000) run out first, throws
|
|
609
|
+
* `WaitTimeoutError` with the last status as `lastStatus`; `timeout` is a deadline that
|
|
610
|
+
* also bounds each poll and its retries (see `HelperOptions`). Aborting `signal` stops
|
|
611
|
+
* the helper and any pending poll or retry. Each poll is an ordinary call, with the
|
|
612
|
+
* client's retries and errors, and counts against the key's request rate limit like any
|
|
613
|
+
* other call, so many waits at once can slow the key's other calls. A job can stay
|
|
614
|
+
* `pending` until the next batch flush; `extractions.process()` runs the due jobs.
|
|
615
|
+
*/
|
|
616
|
+
async waitForExtraction(eventId, options) {
|
|
617
|
+
const { timeout = 300_000, interval = 2_000, signal = null } = (0, core_js_1.ownProperties)(options);
|
|
618
|
+
const core = this._core;
|
|
619
|
+
const deadline = (0, core_js_1.helperDeadline)(core.now(), timeout, interval);
|
|
620
|
+
let lastStatus = null;
|
|
621
|
+
for (;;) {
|
|
622
|
+
let status;
|
|
623
|
+
try {
|
|
624
|
+
status = await this._request(() => ({
|
|
625
|
+
...extractionStatusCall(eventId, { signal }),
|
|
626
|
+
deadline,
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
629
|
+
catch (error) {
|
|
630
|
+
// Only a poll the deadline stopped throws WaitTimeoutError; its own error is the cause.
|
|
631
|
+
if (!(error instanceof errors_js_1.WaitTimeoutError))
|
|
632
|
+
throw error;
|
|
633
|
+
const last = lastStatus === null ? 'none' : JSON.stringify(lastStatus.status);
|
|
634
|
+
throw (0, core_js_1.withCause)(new errors_js_1.WaitTimeoutError(`The extraction did not finish within ${timeout} ms: ${error.message}. The last ` +
|
|
635
|
+
`status read was ${last}.`, { lastStatus }), error.cause);
|
|
636
|
+
}
|
|
637
|
+
if (!WORKING.has(status.status))
|
|
638
|
+
return status;
|
|
639
|
+
lastStatus = status;
|
|
640
|
+
const wait = (0, core_js_1.helperWait)(core.now(), deadline, interval);
|
|
641
|
+
if (wait === null) {
|
|
642
|
+
throw new errors_js_1.WaitTimeoutError(`The extraction did not finish within ${timeout} ms; its last status was ` +
|
|
643
|
+
`${JSON.stringify(status.status)}.`, { lastStatus: status });
|
|
644
|
+
}
|
|
645
|
+
await core.sleep(wait, signal);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
exports.EventsWithHelpers = EventsWithHelpers;
|
|
650
|
+
/** `client.nodes`: the node routes and `scanAll()`. */
|
|
651
|
+
class NodesWithHelpers extends Nodes {
|
|
652
|
+
/**
|
|
653
|
+
* Yield every node `scan()` reaches, one page after another.
|
|
654
|
+
*
|
|
655
|
+
* While a page's `has_more` is true, sends its `next_cursor` as the next `after_id`,
|
|
656
|
+
* with the other parameters unchanged; `limit` is the page size. Each page is an
|
|
657
|
+
* ordinary `scan()` call with `options`, sent as soon as the previous page is read, and
|
|
658
|
+
* counts against the key's request rate limit: a large `limit` (up to 1 000) needs fewer
|
|
659
|
+
* pages. A page whose `has_more` is true without a new `next_cursor` throws
|
|
660
|
+
* `NenaviError`, so a scan never ends early without saying so.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* for await (const node of client.nodes.scanAll({ user_id: 'user-1', limit: 1000 })) {
|
|
664
|
+
* console.log(node.id);
|
|
665
|
+
* }
|
|
666
|
+
*/
|
|
667
|
+
async *scanAll(params, options) {
|
|
668
|
+
const given = (0, core_js_1.ownProperties)(params);
|
|
669
|
+
let cursor = given.after_id;
|
|
670
|
+
for (;;) {
|
|
671
|
+
const page = await this.scan({ ...given, after_id: cursor }, options);
|
|
672
|
+
for (const node of page.nodes ?? [])
|
|
673
|
+
yield node;
|
|
674
|
+
if (!page.has_more)
|
|
675
|
+
return;
|
|
676
|
+
if (page.next_cursor === undefined ||
|
|
677
|
+
page.next_cursor === null ||
|
|
678
|
+
String(page.next_cursor) === String(cursor)) {
|
|
679
|
+
// Following it would read the same page forever; stopping quietly would hide the
|
|
680
|
+
// nodes the scan did not reach.
|
|
681
|
+
throw new errors_js_1.NenaviError('The scan page says there are more nodes but gives no new next_cursor, so the ' +
|
|
682
|
+
'scan cannot continue.');
|
|
683
|
+
}
|
|
684
|
+
cursor = page.next_cursor;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
exports.NodesWithHelpers = NodesWithHelpers;
|
|
689
|
+
/** `client.reingest`: the re-ingest routes and `run()`. */
|
|
690
|
+
class ReingestWithHelpers extends Reingest {
|
|
691
|
+
/**
|
|
692
|
+
* Start a re-ingest run and poll it until its `state` is final.
|
|
693
|
+
*
|
|
694
|
+
* Sends `start()` (`dry_run: false`), then polls `get()` every `interval` milliseconds
|
|
695
|
+
* (5 000) and returns the first status whose `state` is not `pending` or `running`:
|
|
696
|
+
* `complete`, `failed` (returned, not thrown), or a state this SDK does not know yet.
|
|
697
|
+
* When nothing needs re-deriving, the service's `200` answer is returned as it is. A
|
|
698
|
+
* `409` `reingest_running` throws `ConflictError`. When `timeout` milliseconds
|
|
699
|
+
* (3 600 000) run out first, throws `WaitTimeoutError` with the last status as
|
|
700
|
+
* `lastStatus`; the run itself goes on. `timeout` is a deadline that also bounds each
|
|
701
|
+
* poll and its retries (see `HelperOptions`); it never prevents or cuts short the start,
|
|
702
|
+
* which has the client's own timeout. Aborting `signal` stops the helper and any pending
|
|
703
|
+
* poll, not the run. A poll that fails throws that call's error while the run goes on,
|
|
704
|
+
* with the last status read before it as `lastStatus`: its `run_id` lets the caller go
|
|
705
|
+
* on polling with `get()` instead of calling `run()` again, which throws `ConflictError`
|
|
706
|
+
* (`reingest_running`) until the run ends.
|
|
707
|
+
*
|
|
708
|
+
* A run takes at most `limit` memories, so a `complete` run can leave some for later
|
|
709
|
+
* (`remaining` above 0): calling `run()` again with the same parameters continues it.
|
|
710
|
+
*/
|
|
711
|
+
async run(params, options) {
|
|
712
|
+
const { timeout = 3_600_000, interval = 5_000, signal = null } = (0, core_js_1.ownProperties)(options);
|
|
713
|
+
const core = this._core;
|
|
714
|
+
const deadline = (0, core_js_1.helperDeadline)(core.now(), timeout, interval);
|
|
715
|
+
let status = await this.start(params, { signal });
|
|
716
|
+
while (status.run_id !== null && status.run_id !== undefined && WORKING.has(status.state)) {
|
|
717
|
+
const wait = (0, core_js_1.helperWait)(core.now(), deadline, interval);
|
|
718
|
+
if (wait === null) {
|
|
719
|
+
throw new errors_js_1.WaitTimeoutError(`The re-ingest run ${status.run_id} did not finish within ${timeout} ms; its ` +
|
|
720
|
+
`last state was ${JSON.stringify(status.state)}.`, { lastStatus: status });
|
|
721
|
+
}
|
|
722
|
+
await core.sleep(wait, signal);
|
|
723
|
+
const runId = status.run_id;
|
|
724
|
+
try {
|
|
725
|
+
status = await this._request(() => ({
|
|
726
|
+
...reingestGetCall(runId, { signal }),
|
|
727
|
+
deadline,
|
|
728
|
+
}));
|
|
729
|
+
}
|
|
730
|
+
catch (error) {
|
|
731
|
+
// A poll the deadline stopped throws WaitTimeoutError; its own error is the cause.
|
|
732
|
+
if (error instanceof errors_js_1.WaitTimeoutError) {
|
|
733
|
+
throw (0, core_js_1.withCause)(new errors_js_1.WaitTimeoutError(`The re-ingest run ${runId} did not finish within ${timeout} ms: ` +
|
|
734
|
+
`${error.message}. Its last state was ${JSON.stringify(status.state)}.`, { lastStatus: status }), error.cause);
|
|
735
|
+
}
|
|
736
|
+
// The run goes on; without its id the caller could only call run() again, which
|
|
737
|
+
// the service refuses with 409 until the run ends. An abort keeps its own reason.
|
|
738
|
+
if (error instanceof errors_js_1.NenaviError && !signal?.aborted)
|
|
739
|
+
error.lastStatus = status;
|
|
740
|
+
throw error;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return status;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
exports.ReingestWithHelpers = ReingestWithHelpers;
|
|
747
|
+
/** The operations, in the parsed form (`Nenavi`) or the raw form (`withRawResponse`). */
|
|
748
|
+
class NenaviMethods extends Resource {
|
|
749
|
+
events;
|
|
750
|
+
nodes;
|
|
751
|
+
reingest;
|
|
752
|
+
claims;
|
|
753
|
+
aliasProposals;
|
|
754
|
+
materializations;
|
|
755
|
+
extractions;
|
|
756
|
+
assertions;
|
|
757
|
+
quantities;
|
|
758
|
+
retrievals;
|
|
759
|
+
relevance;
|
|
760
|
+
answerCitations;
|
|
761
|
+
learning;
|
|
762
|
+
constructor(core, raw) {
|
|
763
|
+
super(core, raw);
|
|
764
|
+
this.events = new Events(core, raw);
|
|
765
|
+
this.nodes = new Nodes(core, raw);
|
|
766
|
+
this.reingest = new Reingest(core, raw);
|
|
767
|
+
this.claims = new Claims(core, raw);
|
|
768
|
+
this.aliasProposals = new AliasProposals(core, raw);
|
|
769
|
+
this.materializations = new Materializations(core, raw);
|
|
770
|
+
this.extractions = new Extractions(core, raw);
|
|
771
|
+
this.assertions = new Assertions(core, raw);
|
|
772
|
+
this.quantities = new Quantities(core, raw);
|
|
773
|
+
this.retrievals = new Retrievals(core, raw);
|
|
774
|
+
this.relevance = new Relevance(core, raw);
|
|
775
|
+
this.answerCitations = new AnswerCitations(core, raw);
|
|
776
|
+
this.learning = new Learning(core, raw);
|
|
777
|
+
}
|
|
778
|
+
/** `GET /v1/health`. Sends no key, and works on a client built without one. */
|
|
779
|
+
health(options) {
|
|
780
|
+
return this._request(() => ({
|
|
781
|
+
method: 'GET',
|
|
782
|
+
path: '/v1/health',
|
|
783
|
+
retrySafe: true,
|
|
784
|
+
auth: false,
|
|
785
|
+
options,
|
|
786
|
+
}));
|
|
787
|
+
}
|
|
788
|
+
/** `GET /v1/usage`: this month's usage and the project's quota. */
|
|
789
|
+
usage(options) {
|
|
790
|
+
return this._request(() => ({ method: 'GET', path: '/v1/usage', retrySafe: true, options }));
|
|
791
|
+
}
|
|
792
|
+
/** `GET /v1/stats`: event and node counts. */
|
|
793
|
+
stats(params, options) {
|
|
794
|
+
return this._request(() => ({
|
|
795
|
+
method: 'GET',
|
|
796
|
+
path: '/v1/stats',
|
|
797
|
+
retrySafe: true,
|
|
798
|
+
query: params,
|
|
799
|
+
options,
|
|
800
|
+
}));
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* `POST /v1/store`: store one memory.
|
|
804
|
+
*
|
|
805
|
+
* Never retried automatically: a retry would store and extract the text again and count
|
|
806
|
+
* twice against the monthly limits.
|
|
807
|
+
*/
|
|
808
|
+
store(params, options) {
|
|
809
|
+
return this._request(() => ({
|
|
810
|
+
method: 'POST',
|
|
811
|
+
path: '/v1/store',
|
|
812
|
+
retrySafe: false,
|
|
813
|
+
body: params ?? {},
|
|
814
|
+
options,
|
|
815
|
+
}));
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* `POST /v1/ingest`: store a message and queue its extraction.
|
|
819
|
+
*
|
|
820
|
+
* Never retried automatically: a retry would store and extract the text again and count
|
|
821
|
+
* twice against the monthly limits.
|
|
822
|
+
*/
|
|
823
|
+
ingest(params, options) {
|
|
824
|
+
return this._request(() => ({
|
|
825
|
+
method: 'POST',
|
|
826
|
+
path: '/v1/ingest',
|
|
827
|
+
retrySafe: false,
|
|
828
|
+
body: params ?? {},
|
|
829
|
+
options,
|
|
830
|
+
}));
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* `POST /v1/ingest/fast`: store a batch of sources without waiting for extraction.
|
|
834
|
+
*
|
|
835
|
+
* Every call sends an `Idempotency-Key`: `options.idempotencyKey` when given, else a new
|
|
836
|
+
* random UUID. Retries of the call send the same key, so the service answers a retry
|
|
837
|
+
* with the first attempt's event ids instead of storing the batch again. To retry by
|
|
838
|
+
* hand after an error, pass the error's `idempotencyKey`. An aborted `signal` rejects
|
|
839
|
+
* with the signal's reason, which carries no key, so when you pass a `signal`, pass
|
|
840
|
+
* your own `idempotencyKey` too and reuse it to retry an aborted call.
|
|
841
|
+
*/
|
|
842
|
+
ingestFast(params, options) {
|
|
843
|
+
return this._request(() => ({
|
|
844
|
+
method: 'POST',
|
|
845
|
+
path: '/v1/ingest/fast',
|
|
846
|
+
retrySafe: true,
|
|
847
|
+
body: params ?? {},
|
|
848
|
+
idempotencyKey: callerKey(options) ?? crypto.randomUUID(),
|
|
849
|
+
options,
|
|
850
|
+
}));
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* `POST /v1/retrieve`: retrieve the memories that answer a query.
|
|
854
|
+
*
|
|
855
|
+
* Retrieved memory is untrusted input: stored text can carry instructions meant for the
|
|
856
|
+
* model that later reads it, so treat it as data, not instructions. Not retried
|
|
857
|
+
* automatically, because each call writes a retrieval receipt.
|
|
858
|
+
*/
|
|
859
|
+
retrieve(params, options) {
|
|
860
|
+
return this._request(() => ({
|
|
861
|
+
method: 'POST',
|
|
862
|
+
path: '/v1/retrieve',
|
|
863
|
+
retrySafe: false,
|
|
864
|
+
body: params ?? {},
|
|
865
|
+
options,
|
|
866
|
+
}));
|
|
867
|
+
}
|
|
868
|
+
/** `GET /v1/graph`: the user's nodes and edges. */
|
|
869
|
+
graph(params, options) {
|
|
870
|
+
return this._request(() => ({
|
|
871
|
+
method: 'GET',
|
|
872
|
+
path: '/v1/graph',
|
|
873
|
+
retrySafe: true,
|
|
874
|
+
query: params,
|
|
875
|
+
options,
|
|
876
|
+
}));
|
|
877
|
+
}
|
|
878
|
+
/** `POST /v1/organize`: run organizing jobs within a time budget. Not retried automatically. */
|
|
879
|
+
organize(params, options) {
|
|
880
|
+
return this._request(() => ({
|
|
881
|
+
method: 'POST',
|
|
882
|
+
path: '/v1/organize',
|
|
883
|
+
retrySafe: false,
|
|
884
|
+
body: params ?? {},
|
|
885
|
+
options,
|
|
886
|
+
}));
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
exports.NenaviMethods = NenaviMethods;
|
|
890
|
+
/**
|
|
891
|
+
* Client for the Nenavi Cloud memory API, for server-side code.
|
|
892
|
+
*
|
|
893
|
+
* The key comes from `apiKey`, else `NENAVI_API_KEY`; the base URL from `baseURL`, else
|
|
894
|
+
* `NENAVI_BASE_URL`, else `https://api.prismemory.com`. A client built without a key can
|
|
895
|
+
* call only `health()`. Never ship the key to a browser.
|
|
896
|
+
*
|
|
897
|
+
* Retrieved memory is untrusted input: treat retrieved text as data, not instructions.
|
|
898
|
+
*/
|
|
899
|
+
class Nenavi extends NenaviMethods {
|
|
900
|
+
#raw;
|
|
901
|
+
constructor(options = {}) {
|
|
902
|
+
const core = new core_js_1.Core(options);
|
|
903
|
+
super(core, false);
|
|
904
|
+
this.events = new EventsWithHelpers(core, false);
|
|
905
|
+
this.nodes = new NodesWithHelpers(core, false);
|
|
906
|
+
this.reingest = new ReingestWithHelpers(core, false);
|
|
907
|
+
}
|
|
908
|
+
/** The base URL the client sends to. */
|
|
909
|
+
get baseURL() {
|
|
910
|
+
return this._core.baseURL;
|
|
911
|
+
}
|
|
912
|
+
/** The same methods, returning a RawResponse with the status, headers and request id. */
|
|
913
|
+
get withRawResponse() {
|
|
914
|
+
this.#raw ??= new NenaviMethods(this._core, true);
|
|
915
|
+
return this.#raw;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
exports.Nenavi = Nenavi;
|