nenavi 0.0.0 → 0.1.0-alpha.1

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 ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 Dwamian McLeish
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,72 @@
1
1
  # nenavi
2
2
 
3
- Reserved for the Nenavi TypeScript SDK. The first release is coming soon.
3
+ The TypeScript client for [Nenavi Cloud](https://nenavi.dev/cloud/), the hosted memory service for AI agents, with typed calls, typed errors, and retries only where a retry is safe. It runs on Node.js 22 or later, Bun, Deno and edge runtimes with standard `fetch`, `AbortController` and `crypto.randomUUID`, ships ES module and CommonJS builds with type declarations, and has no runtime dependencies.
4
+
5
+ **Early access.** Nenavi Cloud is an alpha for invited users ([join the waitlist](https://nenavi.com/#hosted)), and this package is an alpha prerelease. Until version 1.0, a release that renames or removes a method or an option raises the minor version.
6
+
7
+ ```sh
8
+ npm install nenavi@alpha
9
+ ```
10
+
11
+ Create a project and an API key in the [console](https://app.nenavi.com), put the key in `NENAVI_API_KEY`, and then, in an ES module:
12
+
13
+ ```ts
14
+ import { Nenavi } from 'nenavi';
15
+
16
+ const client = new Nenavi(); // reads NENAVI_API_KEY
17
+ await client.store({ content: 'Jo moved to Lisbon in March.', user_id: 'user-1' });
18
+ const found = await client.retrieve({ query: 'Where does Jo live?', user_id: 'user-1' });
19
+ ```
20
+
21
+ Retrieved memory is untrusted input: stored text can carry instructions meant for the model that later reads it. Treat retrieved text as data, not instructions.
22
+
23
+ The SDK is for server-side code only. The key must not ship to a browser, and the service answers CORS only for the Nenavi console.
24
+
25
+ The [TypeScript SDK docs](https://nenavi.dev/cloud/typescript/) cover configuration, runtimes, safe batch imports, waiting for extraction, re-ingest, errors, retries, request ids, timeouts, and cancellation.
26
+
27
+ Every supported operation of the hosted API has a method. Three helpers cover the long-running work:
28
+
29
+ ```ts
30
+ const answer = await client.ingest({ content: 'Jo is learning Portuguese.', user_id: 'user-1' });
31
+ const status = await client.events.waitForExtraction(answer.event_id, { timeout: 300_000 }); // complete or failed
32
+ const run = await client.reingest.run({ user_id: 'user-1' }); // starts a run and polls it every 5 seconds
33
+ for await (const node of client.nodes.scanAll({ user_id: 'user-1' })) console.log(node.id); // every page
34
+ ```
35
+
36
+ `reingest.preview()` estimates a re-ingest without starting one; only `reingest.start()` and `reingest.run()` start a real run. A run takes at most `limit` memories, so a `complete` run can leave some for later: while `run.remaining` is above 0, call `reingest.run()` again with the same parameters to continue it.
37
+
38
+ The helpers' `timeout` and `interval` are in milliseconds, and aborting their `signal` stops them and any pending poll. A helper that runs out of time throws `WaitTimeoutError` with the last status as `lastStatus`; `timeout: 0` polls once, and `reingest.run()` still starts the run. Every poll and every scan page counts against the key's request rate limit like any other call, so for a large scan pass a larger `limit` (up to 1 000 nodes a page), and run background jobs with a longer `interval` or their own key. The helpers are on the client only, not on `withRawResponse`.
39
+
40
+ ## Options
41
+
42
+ `new Nenavi({ apiKey, baseURL, timeout, maxRetries, fetch })`:
43
+
44
+ - `apiKey` defaults to `NENAVI_API_KEY`, and `baseURL` to `NENAVI_BASE_URL`, else `https://api.prismemory.com`. Both variables are read from `process.env` where it exists. A client without a key can call only `health()`; every other method throws `ConfigurationError` before it sends anything.
45
+ - `timeout` is in milliseconds per attempt (30 000 by default), and `maxRetries` bounds the automatic retries (2 by default).
46
+ - `fetch` replaces the runtime's `fetch`, for tests and unusual runtimes.
47
+
48
+ Every method takes a final options argument `{ signal, timeout, maxRetries }`. Aborting `signal` stops the request and any pending retry, and the call rejects with the signal's reason, as `fetch` does. `ingestFast()` and the node `PUT` methods also take `idempotencyKey`. That reason carries no `Idempotency-Key`, so when you pass a `signal` to `ingestFast()`, pass your own `idempotencyKey` too and reuse it to retry an aborted call; a new key is a new batch, stored and metered again.
49
+
50
+ On Deno, reading the two variables needs `--allow-env=NENAVI_API_KEY,NENAVI_BASE_URL`. Without it, an interactive Deno asks for the permission, and a non-interactive one treats both as unset.
51
+
52
+ Request and response fields keep the API's snake_case names (`user_id`, `event_id`), and the types are generated from `sdks/openapi.json`. `client.withRawResponse` has the same methods and returns `{ status, headers, requestId, data }`.
53
+
54
+ ## Errors and retries
55
+
56
+ Every error the SDK throws is a `NenaviError`, and every class works with `instanceof`: `APIError` and its subclasses (`AuthenticationError`, `NotFoundError`, `RateLimitError`, `QuotaExceededError`, `ServiceUnavailableError` and the others) carry `status`, `reasonCode`, `detail` and `requestId`. `APIConnectionError` and `APITimeoutError` mean no response arrived. `ResponseValidationError` means a `2xx` answer had a body the SDK could not read as the operation's type: the call may have taken effect, so read its `body` (for example the `event_id` of a `store()`) and `requestId` before calling again. `body` can hold stored memory text, and `console.error(error)` or `JSON.stringify(error)` prints it: log the message and `requestId` instead.
57
+
58
+ Only `GET` methods and `ingestFast()` retry by themselves, on a `429 rate_limited` (after `Retry-After`), a `503 database_unavailable` or `lease_unavailable`, or a connection error. `store()`, `ingest()` and `retrieve()` never retry: a retried store stores the text again and counts twice against the monthly limits. `ingestFast()` sends one `Idempotency-Key` on every retry of a call; to retry it by hand, pass the error's `idempotencyKey`.
59
+
60
+ ## Development
61
+
62
+ ```sh
63
+ pnpm --filter nenavi test # builds dist/, then runs the tests
64
+ pnpm --filter nenavi lint
65
+ pnpm --filter nenavi type-check
66
+ pnpm --filter nenavi build
67
+ ```
68
+
69
+ - `src/generated/` holds the types generated from `sdks/openapi.json` by `openapi-typescript`, with `SPEC_VERSION` and `SPEC_SHA256`. After the snapshot changes, run `pnpm --filter nenavi generate`; `test/generated.test.ts` fails until you do.
70
+ - `test/conformance.test.ts` runs every scenario in `sdks/conformance/` with a mock `fetch`.
71
+ - `test/package.test.ts` loads the built package with `import` and with `require`.
72
+ - `examples/quickstart.ts` stores and retrieves one memory with the key from `NENAVI_API_KEY` (and `NENAVI_BASE_URL` for a local service): `pnpm exec tsx examples/quickstart.ts`.
@@ -0,0 +1,318 @@
1
+ import { Core, type Call, type ClientOptions, type IdempotentRequestOptions, type RawResponse, type RequestOptions } from './core.js';
2
+ import type { AliasProposalReviewResponse, AliasProposalsListParams, AliasProposalsListResponse, AliasProposalsReviewParams, AnswerCitationResponse, AnswerCitationsGetParams, AnswerCitationsListParams, AnswerCitationsListResponse, AnswerCitationsRecordParams, AssertionAggregationResponse, AssertionStateResponse, AssertionsAggregateParams, AssertionsStateParams, ClaimsMarkContradictionParams, ClaimsResolveContradictionParams, ClaimsResponse, ClaimsSupersedeParams, EventNodesResponse, EventRecord, EventsRetryExtractionParams, ExtractionResponse, ExtractionStatusResponse, ExtractionsProcessParams, ExtractionsProcessResponse, FullRetrievalEvaluationResponse, GraphParams, GraphResponse, HealthResponse, IngestFastParams, IngestFastResponse, IngestParams, IngestResponse, LearningEvaluateFullRetrievalParams, LearningEvaluateParams, LearningEvaluationResponse, LearningProfilesActivateParams, LearningProfilesActiveParams, LearningProfilesCreateParams, LearningProfilesDeactivateParams, LearningProfilesGetParams, LearningProfilesHistoryParams, LearningProfilesListParams, LearningProfilesRollbackParams, MaterializationsProcessParams, MaterializationsProcessResponse, NodeChainResponse, NodeListResponse, NodeNeighborhoodResponse, NodePageResponse, NodeResponse, NodesChainParams, NodesEvaluateConditionParams, NodesListParams, NodesNeighborhoodParams, NodesProvenanceParams, NodesReinforceParams, NodesScanParams, OrganizeParams, OrganizeResponse, PlannedQuantityAggregationResponse, ProcessingStatusResponse, ProvenanceResponse, QuantitiesAggregateParams, QuantitiesAggregateTextParams, QuantityAggregationResponse, RankingProfileActiveResponse, RankingProfileDeactivateResponse, RankingProfileHistoryResponse, RankingProfileListResponse, RankingProfileResponse, RankingProfileStateResponse, RankingProfileStatusResponse, ReingestParams, ReingestPreview, ReingestRunStatus, RelevanceGetParams, RelevanceListParams, RelevanceListResponse, RelevanceRecordParams, RelevanceRecordResponse, RetrievalReceiptResponse, RetrievalsGetParams, RetrieveParams, RetrieveResponse, StatsParams, StatsResponse, StoreParams, StoreResponse, UsageResponse } from './types.js';
3
+ /** What a method returns: the parsed body, or in the raw view its RawResponse. */
4
+ export type APIPromise<Raw extends boolean, T> = Promise<Raw extends true ? RawResponse<T> : T>;
5
+ declare class Resource<Raw extends boolean> {
6
+ protected readonly _core: Core;
7
+ protected readonly _raw: Raw;
8
+ constructor(core: Core, raw: Raw);
9
+ /** Build the call and send it; an error while building it rejects the promise too. */
10
+ protected _request<T>(build: () => Call): APIPromise<Raw, T>;
11
+ }
12
+ /** A helper's options (sdks/CONTRACT.md, Helpers). */
13
+ export interface HelperOptions {
14
+ /**
15
+ * Milliseconds after which the helper stops waiting: it polls no more once they run
16
+ * out. A poll already sent finishes first, with its own per-attempt timeout and retries.
17
+ * 0 polls once (`run()` still starts the run); `Infinity` waits without a limit.
18
+ */
19
+ timeout?: number;
20
+ /** Milliseconds between polls. */
21
+ interval?: number;
22
+ /** Aborting it stops the helper and any pending poll or retry. */
23
+ signal?: AbortSignal | null;
24
+ }
25
+ /** The `/v1/events` routes. */
26
+ export declare class Events<Raw extends boolean = false> extends Resource<Raw> {
27
+ /** `GET /v1/events/{event_id}`: the stored event, as the JSON object it is. */
28
+ get(eventId: string, options?: RequestOptions): APIPromise<Raw, EventRecord>;
29
+ /** `GET /v1/events/{event_id}/nodes`: the nodes derived from the event. */
30
+ nodes(eventId: string, options?: RequestOptions): APIPromise<Raw, EventNodesResponse>;
31
+ /** `GET /v1/events/{event_id}/processing-status`. */
32
+ processingStatus(eventId: string, options?: RequestOptions): APIPromise<Raw, ProcessingStatusResponse>;
33
+ /** `GET /v1/events/{event_id}/extraction`: the record, or its protected view. */
34
+ extraction(eventId: string, options?: RequestOptions): APIPromise<Raw, ExtractionResponse>;
35
+ /** `GET /v1/events/{event_id}/extraction-status`. */
36
+ extractionStatus(eventId: string, options?: RequestOptions): APIPromise<Raw, ExtractionStatusResponse>;
37
+ /** `POST /v1/events/{event_id}/retry-extraction`. Not retried automatically. */
38
+ retryExtraction(eventId: string, params?: EventsRetryExtractionParams, options?: RequestOptions): APIPromise<Raw, ExtractionStatusResponse>;
39
+ }
40
+ /** The `/v1/nodes` routes. */
41
+ export declare class Nodes<Raw extends boolean = false> extends Resource<Raw> {
42
+ /** `GET /v1/nodes/{node_id}`. */
43
+ get(nodeId: string, options?: RequestOptions): APIPromise<Raw, NodeResponse>;
44
+ /** `GET /v1/nodes`: list nodes. */
45
+ list(params?: NodesListParams, options?: RequestOptions): APIPromise<Raw, NodeListResponse>;
46
+ /**
47
+ * `GET /v1/nodes/scan`: one page of nodes, in id order.
48
+ *
49
+ * While the page's `has_more` is true, pass its `next_cursor` as `after_id` to read the
50
+ * next page.
51
+ */
52
+ scan(params?: NodesScanParams, options?: RequestOptions): APIPromise<Raw, NodePageResponse>;
53
+ /** `GET /v1/nodes/{node_id}/provenance`: the provenance, or its protected view. */
54
+ provenance(nodeId: string, params?: NodesProvenanceParams, options?: RequestOptions): APIPromise<Raw, ProvenanceResponse>;
55
+ /** `PUT /v1/nodes/{node_id}/promote`. Not retried automatically. */
56
+ promote(nodeId: string, options?: IdempotentRequestOptions): APIPromise<Raw, NodeResponse>;
57
+ /** `PUT /v1/nodes/{node_id}/archive`. Not retried automatically. */
58
+ archive(nodeId: string, options?: IdempotentRequestOptions): APIPromise<Raw, NodeResponse>;
59
+ /**
60
+ * `PUT /v1/nodes/{node_id}/reinforce`. Not retried automatically.
61
+ *
62
+ * Sends a body only when `params` has a field.
63
+ */
64
+ reinforce(nodeId: string, params?: NodesReinforceParams, options?: IdempotentRequestOptions): APIPromise<Raw, NodeResponse>;
65
+ /** `PUT /v1/nodes/{node_id}/condition`: record a conditional claim's state. Not retried automatically. */
66
+ evaluateCondition(nodeId: string, params: NodesEvaluateConditionParams, options?: IdempotentRequestOptions): APIPromise<Raw, NodeResponse>;
67
+ /** `GET /v1/nodes/{node_id}/neighborhood`: the nodes within `max_hops` edges. */
68
+ neighborhood(nodeId: string, params?: NodesNeighborhoodParams, options?: RequestOptions): APIPromise<Raw, NodeNeighborhoodResponse>;
69
+ /** `GET /v1/nodes/{node_id}/chain`: the node's supersedence chain. */
70
+ chain(nodeId: string, params?: NodesChainParams, options?: RequestOptions): APIPromise<Raw, NodeChainResponse>;
71
+ }
72
+ /** The `/v1/reingest` routes: re-derive one end user's stored memories. */
73
+ export declare class Reingest<Raw extends boolean = false> extends Resource<Raw> {
74
+ /**
75
+ * `POST /v1/reingest` with `dry_run: true`: count and estimate a run.
76
+ *
77
+ * Always sends `dry_run: true`, so a preview never starts a run. Not retried
78
+ * automatically.
79
+ */
80
+ preview(params: ReingestParams, options?: RequestOptions): APIPromise<Raw, ReingestPreview>;
81
+ /**
82
+ * `POST /v1/reingest` with `dry_run: false`: start a background run.
83
+ *
84
+ * The service answers `202` with the run's `run_id`, or `200` with `run_id: null` when
85
+ * nothing needs re-deriving. Each memory the run takes counts as one ingest call. A run
86
+ * takes at most `limit` memories, so a `complete` run can leave some for later
87
+ * (`remaining` above 0): sending the same request again continues it. Not retried
88
+ * automatically; a `409` `reingest_running` throws `ConflictError`.
89
+ */
90
+ start(params: ReingestParams, options?: RequestOptions): APIPromise<Raw, ReingestRunStatus>;
91
+ /** `GET /v1/reingest/{run_id}`: the run's state, counts and usage. */
92
+ get(runId: string, options?: RequestOptions): APIPromise<Raw, ReingestRunStatus>;
93
+ }
94
+ /** The claim routes: supersedences and contradictions. Not retried automatically. */
95
+ export declare class Claims<Raw extends boolean = false> extends Resource<Raw> {
96
+ /** `POST /v1/supersedences`: record that one claim replaces another. */
97
+ supersede(params: ClaimsSupersedeParams, options?: RequestOptions): APIPromise<Raw, ClaimsResponse>;
98
+ /** `POST /v1/contradictions`: mark two claims as contradicting each other. */
99
+ markContradiction(params: ClaimsMarkContradictionParams, options?: RequestOptions): APIPromise<Raw, ClaimsResponse>;
100
+ /** `POST /v1/contradictions/resolve`: resolve a contradiction in favor of one claim. */
101
+ resolveContradiction(params: ClaimsResolveContradictionParams, options?: RequestOptions): APIPromise<Raw, ClaimsResponse>;
102
+ }
103
+ /** The `/v1/alias-proposals` routes: identity review. */
104
+ export declare class AliasProposals<Raw extends boolean = false> extends Resource<Raw> {
105
+ /** `GET /v1/alias-proposals`: the alias proposals waiting for review. */
106
+ list(params?: AliasProposalsListParams, options?: RequestOptions): APIPromise<Raw, AliasProposalsListResponse>;
107
+ /** `POST /v1/alias-proposals/{proposal_operation_id}/review`. Not retried automatically. */
108
+ review(proposalOperationId: string, params: AliasProposalsReviewParams, options?: RequestOptions): APIPromise<Raw, AliasProposalReviewResponse>;
109
+ }
110
+ /** The `/v1/materializations` routes. */
111
+ export declare class Materializations<Raw extends boolean = false> extends Resource<Raw> {
112
+ /** `POST /v1/materializations/process`: run the due materializations. Not retried automatically. */
113
+ process(params: MaterializationsProcessParams, options?: RequestOptions): APIPromise<Raw, MaterializationsProcessResponse>;
114
+ }
115
+ /** The `/v1/extractions` routes. */
116
+ export declare class Extractions<Raw extends boolean = false> extends Resource<Raw> {
117
+ /** `POST /v1/extractions/process`: run the due extraction jobs. Not retried automatically. */
118
+ process(params: ExtractionsProcessParams, options?: RequestOptions): APIPromise<Raw, ExtractionsProcessResponse>;
119
+ }
120
+ /** The `/v1/assertions` routes: exact queries over assertions. Not retried automatically. */
121
+ export declare class Assertions<Raw extends boolean = false> extends Resource<Raw> {
122
+ /** `POST /v1/assertions/aggregate`. */
123
+ aggregate(params: AssertionsAggregateParams, options?: RequestOptions): APIPromise<Raw, AssertionAggregationResponse>;
124
+ /** `POST /v1/assertions/state`. */
125
+ state(params: AssertionsStateParams, options?: RequestOptions): APIPromise<Raw, AssertionStateResponse>;
126
+ }
127
+ /** The `/v1/quantities` routes: exact queries over quantities. Not retried automatically. */
128
+ export declare class Quantities<Raw extends boolean = false> extends Resource<Raw> {
129
+ /** `POST /v1/quantities/aggregate`. */
130
+ aggregate(params: QuantitiesAggregateParams, options?: RequestOptions): APIPromise<Raw, QuantityAggregationResponse>;
131
+ /** `POST /v1/quantities/aggregate-text`: plan and run an aggregation from a question. */
132
+ aggregateText(params: QuantitiesAggregateTextParams, options?: RequestOptions): APIPromise<Raw, PlannedQuantityAggregationResponse>;
133
+ }
134
+ /** The `/v1/retrievals` routes: retrieval receipts. */
135
+ export declare class Retrievals<Raw extends boolean = false> extends Resource<Raw> {
136
+ /** `GET /v1/retrievals/{request_id}`: the receipt, or one of its protected views. */
137
+ get(requestId: string, params?: RetrievalsGetParams, options?: RequestOptions): APIPromise<Raw, RetrievalReceiptResponse>;
138
+ }
139
+ /** The `/v1/relevance` routes: relevance feedback. */
140
+ export declare class Relevance<Raw extends boolean = false> extends Resource<Raw> {
141
+ /** `POST /v1/relevance`: record feedback on a retrieved memory. Not retried automatically. */
142
+ record(params: RelevanceRecordParams, options?: RequestOptions): APIPromise<Raw, RelevanceRecordResponse>;
143
+ /** `GET /v1/relevance`: the recorded feedback. */
144
+ list(params?: RelevanceListParams, options?: RequestOptions): APIPromise<Raw, RelevanceListResponse>;
145
+ /** `GET /v1/relevance/{feedback_id}`. */
146
+ get(feedbackId: string, params?: RelevanceGetParams, options?: RequestOptions): APIPromise<Raw, RelevanceRecordResponse>;
147
+ }
148
+ /** The `/v1/answer-citations` routes: which memories an answer cited. */
149
+ export declare class AnswerCitations<Raw extends boolean = false> extends Resource<Raw> {
150
+ /** `POST /v1/answer-citations`: record an answer's citations. Not retried automatically. */
151
+ record(params: AnswerCitationsRecordParams, options?: RequestOptions): APIPromise<Raw, AnswerCitationResponse>;
152
+ /** `GET /v1/answer-citations`: the recorded citations, each a record or its protected view. */
153
+ list(params?: AnswerCitationsListParams, options?: RequestOptions): APIPromise<Raw, AnswerCitationsListResponse>;
154
+ /** `GET /v1/answer-citations/{citation_id}`: the record, or its protected view. */
155
+ get(citationId: string, params?: AnswerCitationsGetParams, options?: RequestOptions): APIPromise<Raw, AnswerCitationResponse>;
156
+ }
157
+ /** The `/v1/learning/profiles` routes: ranking profiles. */
158
+ export declare class LearningProfiles<Raw extends boolean = false> extends Resource<Raw> {
159
+ /** `GET /v1/learning/profiles`. */
160
+ list(params?: LearningProfilesListParams, options?: RequestOptions): APIPromise<Raw, RankingProfileListResponse>;
161
+ /** `POST /v1/learning/profiles`: create a profile. Not retried automatically. */
162
+ create(params: LearningProfilesCreateParams, options?: RequestOptions): APIPromise<Raw, RankingProfileResponse>;
163
+ /** `GET /v1/learning/profiles/{profile_id}`: the profile and its status. */
164
+ get(profileId: string, params?: LearningProfilesGetParams, options?: RequestOptions): APIPromise<Raw, RankingProfileStatusResponse>;
165
+ /** `GET /v1/learning/profiles/active`: the active profile, or null when none is. */
166
+ active(params?: LearningProfilesActiveParams, options?: RequestOptions): APIPromise<Raw, RankingProfileActiveResponse>;
167
+ /** `GET /v1/learning/profiles/history`: the activation history. */
168
+ history(params?: LearningProfilesHistoryParams, options?: RequestOptions): APIPromise<Raw, RankingProfileHistoryResponse>;
169
+ /** `POST /v1/learning/profiles/{profile_id}/activate`. Not retried automatically. */
170
+ activate(profileId: string, params: LearningProfilesActivateParams, options?: RequestOptions): APIPromise<Raw, RankingProfileStateResponse>;
171
+ /** `POST /v1/learning/profiles/deactivate`: null when no profile was active. Not retried automatically. */
172
+ deactivate(params: LearningProfilesDeactivateParams, options?: RequestOptions): APIPromise<Raw, RankingProfileDeactivateResponse>;
173
+ /** `POST /v1/learning/profiles/rollback`. Not retried automatically. */
174
+ rollback(params: LearningProfilesRollbackParams, options?: RequestOptions): APIPromise<Raw, RankingProfileStateResponse>;
175
+ }
176
+ /** The `/v1/learning` routes: offline evaluation and ranking profiles. */
177
+ export declare class Learning<Raw extends boolean = false> extends Resource<Raw> {
178
+ readonly profiles: LearningProfiles<Raw>;
179
+ constructor(core: Core, raw: Raw);
180
+ /** `POST /v1/learning/evaluate`. Not retried automatically. */
181
+ evaluate(params: LearningEvaluateParams, options?: RequestOptions): APIPromise<Raw, LearningEvaluationResponse>;
182
+ /** `POST /v1/learning/evaluate-full-retrieval`. Not retried automatically. */
183
+ evaluateFullRetrieval(params: LearningEvaluateFullRetrievalParams, options?: RequestOptions): APIPromise<Raw, FullRetrievalEvaluationResponse>;
184
+ }
185
+ /** `client.events`: the event routes and `waitForExtraction()`. */
186
+ export declare class EventsWithHelpers extends Events<false> {
187
+ /**
188
+ * Poll the event's extraction status until it is `complete` or `failed`.
189
+ *
190
+ * Polls `GET /v1/events/{event_id}/extraction-status` at once and then every
191
+ * `interval` milliseconds (2 000), and returns the last status; a `failed` status is
192
+ * returned, not thrown. When `timeout` milliseconds (300 000) run out first, throws
193
+ * `WaitTimeoutError` with the last status as `lastStatus`. Aborting `signal` stops
194
+ * the helper and any pending poll or retry. Each poll is an ordinary call, with the
195
+ * client's retries and errors, and counts against the key's request rate limit like any
196
+ * other call, so many waits at once can slow the key's other calls. A job can stay
197
+ * `pending` until the next batch flush; `extractions.process()` runs the due jobs.
198
+ */
199
+ waitForExtraction(eventId: string, options?: HelperOptions): Promise<ExtractionStatusResponse>;
200
+ }
201
+ /** `client.nodes`: the node routes and `scanAll()`. */
202
+ export declare class NodesWithHelpers extends Nodes<false> {
203
+ /**
204
+ * Yield every node `scan()` reaches, one page after another.
205
+ *
206
+ * While a page's `has_more` is true, sends its `next_cursor` as the next `after_id`,
207
+ * with the other parameters unchanged; `limit` is the page size. Each page is an
208
+ * ordinary `scan()` call with `options`, sent as soon as the previous page is read, and
209
+ * counts against the key's request rate limit: a large `limit` (up to 1 000) needs fewer
210
+ * pages. A page whose `has_more` is true without a new `next_cursor` throws
211
+ * `NenaviError`, so a scan never ends early without saying so.
212
+ *
213
+ * @example
214
+ * for await (const node of client.nodes.scanAll({ user_id: 'user-1' })) console.log(node.id);
215
+ */
216
+ scanAll(params?: NodesScanParams, options?: RequestOptions): AsyncGenerator<NodeResponse, void, undefined>;
217
+ }
218
+ /** `client.reingest`: the re-ingest routes and `run()`. */
219
+ export declare class ReingestWithHelpers extends Reingest<false> {
220
+ /**
221
+ * Start a re-ingest run and poll it until its `state` is `complete` or `failed`.
222
+ *
223
+ * Sends `start()` (`dry_run: false`), then polls `get()` every `interval` milliseconds
224
+ * (5 000) and returns the last status; a `failed` run is returned, not thrown. When
225
+ * nothing needs re-deriving, the service's `200` answer is returned as it is. A `409`
226
+ * `reingest_running` throws `ConflictError`. When `timeout` milliseconds (3 600 000)
227
+ * run out first, throws `WaitTimeoutError` with the last status as `lastStatus`; the
228
+ * run itself goes on. The timeout never prevents the start. Aborting `signal` stops the
229
+ * helper and any pending poll, not the run. A failed poll throws that call's error while
230
+ * the run goes on; to keep the run's id across such failures, call `start()` and poll
231
+ * `get()` yourself.
232
+ *
233
+ * A run takes at most `limit` memories, so a `complete` run can leave some for later
234
+ * (`remaining` above 0): calling `run()` again with the same parameters continues it.
235
+ */
236
+ run(params: ReingestParams, options?: HelperOptions): Promise<ReingestRunStatus>;
237
+ }
238
+ /** The operations, in the parsed form (`Nenavi`) or the raw form (`withRawResponse`). */
239
+ export declare class NenaviMethods<Raw extends boolean = false> extends Resource<Raw> {
240
+ readonly events: Events<Raw>;
241
+ readonly nodes: Nodes<Raw>;
242
+ readonly reingest: Reingest<Raw>;
243
+ readonly claims: Claims<Raw>;
244
+ readonly aliasProposals: AliasProposals<Raw>;
245
+ readonly materializations: Materializations<Raw>;
246
+ readonly extractions: Extractions<Raw>;
247
+ readonly assertions: Assertions<Raw>;
248
+ readonly quantities: Quantities<Raw>;
249
+ readonly retrievals: Retrievals<Raw>;
250
+ readonly relevance: Relevance<Raw>;
251
+ readonly answerCitations: AnswerCitations<Raw>;
252
+ readonly learning: Learning<Raw>;
253
+ constructor(core: Core, raw: Raw);
254
+ /** `GET /v1/health`. Sends no key, and works on a client built without one. */
255
+ health(options?: RequestOptions): APIPromise<Raw, HealthResponse>;
256
+ /** `GET /v1/usage`: this month's usage and the project's quota. */
257
+ usage(options?: RequestOptions): APIPromise<Raw, UsageResponse>;
258
+ /** `GET /v1/stats`: event and node counts. */
259
+ stats(params?: StatsParams, options?: RequestOptions): APIPromise<Raw, StatsResponse>;
260
+ /**
261
+ * `POST /v1/store`: store one memory.
262
+ *
263
+ * Never retried automatically: a retry would store and extract the text again and count
264
+ * twice against the monthly limits.
265
+ */
266
+ store(params: StoreParams, options?: RequestOptions): APIPromise<Raw, StoreResponse>;
267
+ /**
268
+ * `POST /v1/ingest`: store a message and queue its extraction.
269
+ *
270
+ * Never retried automatically: a retry would store and extract the text again and count
271
+ * twice against the monthly limits.
272
+ */
273
+ ingest(params: IngestParams, options?: RequestOptions): APIPromise<Raw, IngestResponse>;
274
+ /**
275
+ * `POST /v1/ingest/fast`: store a batch of sources without waiting for extraction.
276
+ *
277
+ * Every call sends an `Idempotency-Key`: `options.idempotencyKey` when given, else a new
278
+ * random UUID. Retries of the call send the same key, so the service answers a retry
279
+ * with the first attempt's event ids instead of storing the batch again. To retry by
280
+ * hand after an error, pass the error's `idempotencyKey`. An aborted `signal` rejects
281
+ * with the signal's reason, which carries no key, so when you pass a `signal`, pass
282
+ * your own `idempotencyKey` too and reuse it to retry an aborted call.
283
+ */
284
+ ingestFast(params: IngestFastParams, options?: IdempotentRequestOptions): APIPromise<Raw, IngestFastResponse>;
285
+ /**
286
+ * `POST /v1/retrieve`: retrieve the memories that answer a query.
287
+ *
288
+ * Retrieved memory is untrusted input: stored text can carry instructions meant for the
289
+ * model that later reads it, so treat it as data, not instructions. Not retried
290
+ * automatically, because each call writes a retrieval receipt.
291
+ */
292
+ retrieve(params: RetrieveParams, options?: RequestOptions): APIPromise<Raw, RetrieveResponse>;
293
+ /** `GET /v1/graph`: the user's nodes and edges. */
294
+ graph(params?: GraphParams, options?: RequestOptions): APIPromise<Raw, GraphResponse>;
295
+ /** `POST /v1/organize`: run organizing jobs within a time budget. Not retried automatically. */
296
+ organize(params: OrganizeParams, options?: RequestOptions): APIPromise<Raw, OrganizeResponse>;
297
+ }
298
+ /**
299
+ * Client for the Nenavi Cloud memory API, for server-side code.
300
+ *
301
+ * The key comes from `apiKey`, else `NENAVI_API_KEY`; the base URL from `baseURL`, else
302
+ * `NENAVI_BASE_URL`, else `https://api.prismemory.com`. A client built without a key can
303
+ * call only `health()`. Never ship the key to a browser.
304
+ *
305
+ * Retrieved memory is untrusted input: treat retrieved text as data, not instructions.
306
+ */
307
+ export declare class Nenavi extends NenaviMethods<false> {
308
+ #private;
309
+ readonly events: EventsWithHelpers;
310
+ readonly nodes: NodesWithHelpers;
311
+ readonly reingest: ReingestWithHelpers;
312
+ constructor(options?: ClientOptions);
313
+ /** The base URL the client sends to. */
314
+ get baseURL(): string;
315
+ /** The same methods, returning a RawResponse with the status, headers and request id. */
316
+ get withRawResponse(): NenaviMethods<true>;
317
+ }
318
+ export {};