@intellara/trovegen-sdk 0.0.0-stage → 0.1.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 +202 -0
- package/NOTICE +27 -0
- package/README.md +69 -2
- package/dist/index.d.ts +347 -0
- package/dist/index.js +202 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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 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 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 those 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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
troveGEN TypeScript SDK
|
|
2
|
+
Copyright 2026 Intellara Technologies Private Limited
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (the
|
|
5
|
+
"License"). You may obtain a copy of the License in the LICENSE file
|
|
6
|
+
distributed with this package, or at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
TRADEMARKS
|
|
11
|
+
----------
|
|
12
|
+
"troveGEN", "TROVE-Z", "troveGEN-Z", "Intellara" and the associated logos are
|
|
13
|
+
trademarks of Intellara Technologies Private Limited. The Apache License does
|
|
14
|
+
not grant permission to use these marks (see section 6 of the License).
|
|
15
|
+
|
|
16
|
+
You may state that your product works with, connects to, or is built on
|
|
17
|
+
troveGEN. You may not use these marks in a way that suggests endorsement,
|
|
18
|
+
affiliation, or that your product is an official Intellara distribution, and
|
|
19
|
+
you may not use them as the name of a fork or derivative work.
|
|
20
|
+
|
|
21
|
+
SCOPE OF THIS LICENCE
|
|
22
|
+
---------------------
|
|
23
|
+
This Apache-2.0 licence applies ONLY to this client package. It does not apply
|
|
24
|
+
to the troveGEN platform (the ingestion pipeline, retrieval engine, API server
|
|
25
|
+
and console), which is proprietary software licensed separately under a
|
|
26
|
+
commercial agreement. Access to a running troveGEN deployment is governed by
|
|
27
|
+
that agreement, not by this file.
|
package/README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @intellara/trovegen-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Typed, dependency-free TypeScript client for [troveGEN](https://trovegen.com) — a RAG Pipeline
|
|
4
|
+
& Search API you point at your own vector database. Works in Node ≥18 and browsers.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @intellara/trovegen-sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Quickstart
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { TroveGenClient } from '@intellara/trovegen-sdk';
|
|
14
|
+
|
|
15
|
+
const trovegen = new TroveGenClient({ apiKey: process.env.TROVEGEN_KEY });
|
|
16
|
+
|
|
17
|
+
const project = await trovegen.projects.create({ name: 'Docs' });
|
|
18
|
+
|
|
19
|
+
await trovegen.documents.ingestText(project.id, {
|
|
20
|
+
title: 'Refunds',
|
|
21
|
+
text: 'Refunds are processed within 5 business days.',
|
|
22
|
+
metadata: { region: 'eu', year: 2026 },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const res = await trovegen.search(project.id, {
|
|
26
|
+
query: 'When do customers get their money back?',
|
|
27
|
+
mode: 'hybrid',
|
|
28
|
+
topK: 8,
|
|
29
|
+
});
|
|
30
|
+
// res.results[0] → { content, score, documentId, chunkIndex, metadata }
|
|
31
|
+
// feed res.results into your own LLM, agent, or UI
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## What this SDK is for
|
|
35
|
+
|
|
36
|
+
troveGEN's core product is **search**: hybrid retrieval (dense vectors fused with BM25),
|
|
37
|
+
reranking, metadata filters, and permission-aware results — returned as scored, ranked
|
|
38
|
+
chunks for your own application to consume. This SDK wraps that API with typed
|
|
39
|
+
requests/responses, automatic retry with `Retry-After` honored on `429`s, and errors you
|
|
40
|
+
can actually branch on (`TroveGenError` carries `code` + `requestId`).
|
|
41
|
+
|
|
42
|
+
An optional generation API (`trovegen.ask()` / `trovegen.askStream()`) is also available for
|
|
43
|
+
teams that want built-in citations, hallucination scoring, or agentic multi-step
|
|
44
|
+
retrieval — it's off by default per tenant and returns `GENERATION_DISABLED` until a
|
|
45
|
+
workspace admin turns it on. Not required to use the SDK.
|
|
46
|
+
|
|
47
|
+
## API key scopes
|
|
48
|
+
|
|
49
|
+
Every call is checked against the key's scopes: `search:read` (search, ask, conversations), `pipeline:read` (read documents, jobs, sources), `pipeline:write` (ingest, delete, jobs), `projects:write` (create, edit, delete projects), `connections:write` (connections). A call the key may not make throws a `TroveGenError` with code `KEY_SCOPE_FORBIDDEN`. The workspace plan's limits apply on top of the scopes.
|
|
50
|
+
|
|
51
|
+
## Pointing at a deployment
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
new TroveGenClient({ apiKey: 'trv_...', baseUrl: 'https://api.your-deployment.example' });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Defaults to `http://localhost:4000` for local development. Point `baseUrl` at any
|
|
58
|
+
troveGEN deployment — the managed service, your own self-hosted install, or a fully
|
|
59
|
+
air-gapped one. The client is identical in every case: it holds no hardcoded host and
|
|
60
|
+
sends no telemetry.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
Apache License 2.0 — Copyright 2026 Intellara Technologies Private Limited.
|
|
65
|
+
See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
|
66
|
+
|
|
67
|
+
This licence covers **this client package only**. The troveGEN platform it
|
|
68
|
+
connects to is proprietary and licensed separately; using this client does not
|
|
69
|
+
grant any right to the platform. "troveGEN" and "Intellara" are trademarks —
|
|
70
|
+
Apache-2.0 grants no rights to them (section 6).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* troveGEN SDK — a thin, dependency-free, typed client for the troveGEN API.
|
|
3
|
+
*
|
|
4
|
+
* Works in Node ≥18 and modern browsers (global fetch / FormData / streams).
|
|
5
|
+
* Auth: a `trv_` API key (server-to-server) or a dashboard JWT.
|
|
6
|
+
* Point `baseUrl` at any troveGEN deployment — cloud, self-hosted, or air-gapped.
|
|
7
|
+
*
|
|
8
|
+
* const trovegen = new TroveGenClient({ apiKey: 'trv_…', baseUrl: 'http://localhost:4000' });
|
|
9
|
+
* const project = await trovegen.projects.create({ name: 'Docs' });
|
|
10
|
+
* await trovegen.documents.ingestText(project.id, { title: 'Refunds', text: '…' });
|
|
11
|
+
* for await (const ev of trovegen.askStream(project.id, { query: 'refund policy?' })) {
|
|
12
|
+
* if (ev.event === 'delta') process.stdout.write(ev.data.text);
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export interface TroveGenClientOptions {
|
|
16
|
+
/** API key (`trv_…`) or dashboard access token. */
|
|
17
|
+
apiKey: string;
|
|
18
|
+
/** Deployment origin, e.g. https://api.trovegen.example — default local dev. */
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
/** Retries for 429/5xx/network failures (default 2, exponential + jitter). */
|
|
21
|
+
maxRetries?: number;
|
|
22
|
+
/** Per-request timeout in ms (default 60s; streaming requests are exempt). */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
fetch?: typeof fetch;
|
|
25
|
+
}
|
|
26
|
+
export declare class TroveGenError extends Error {
|
|
27
|
+
readonly code: string;
|
|
28
|
+
readonly status: number;
|
|
29
|
+
readonly requestId?: string | undefined;
|
|
30
|
+
readonly details?: unknown | undefined;
|
|
31
|
+
constructor(code: string, message: string, status: number, requestId?: string | undefined, details?: unknown | undefined);
|
|
32
|
+
}
|
|
33
|
+
export interface Project {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
slug: string;
|
|
37
|
+
namespace: string;
|
|
38
|
+
mode: 'managed' | 'byo';
|
|
39
|
+
embeddingModel: string;
|
|
40
|
+
embeddingDimensions: number;
|
|
41
|
+
retrievalConfig: Record<string, unknown>;
|
|
42
|
+
status: string;
|
|
43
|
+
}
|
|
44
|
+
export interface IngestResult {
|
|
45
|
+
id: string;
|
|
46
|
+
title: string | null;
|
|
47
|
+
status: string;
|
|
48
|
+
chunkCount: number;
|
|
49
|
+
tokenCount: number;
|
|
50
|
+
warnings?: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface SearchResult {
|
|
53
|
+
content: string;
|
|
54
|
+
documentId: string;
|
|
55
|
+
chunkIndex: number;
|
|
56
|
+
score: number;
|
|
57
|
+
metadata: Record<string, unknown>;
|
|
58
|
+
vectorScore?: number;
|
|
59
|
+
keywordScore?: number;
|
|
60
|
+
rankScore?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface SearchResponse {
|
|
63
|
+
results: SearchResult[];
|
|
64
|
+
pipeline: {
|
|
65
|
+
mode: string;
|
|
66
|
+
topK: number;
|
|
67
|
+
candidateCount: number;
|
|
68
|
+
rerankApplied: boolean;
|
|
69
|
+
reranker: string | null;
|
|
70
|
+
mmr: boolean;
|
|
71
|
+
minScore: number;
|
|
72
|
+
/** Related-chunk expansion actually applied, if any (gap 12). */
|
|
73
|
+
expand?: string;
|
|
74
|
+
expandWindow?: number;
|
|
75
|
+
expandedResults?: number;
|
|
76
|
+
/** Recency bias, if this request or the project turned it on. */
|
|
77
|
+
recencyBias?: boolean;
|
|
78
|
+
recencyHalfLifeDays?: number;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export interface DeletionRemoved {
|
|
82
|
+
chunks: number;
|
|
83
|
+
vectors: number;
|
|
84
|
+
tables: number;
|
|
85
|
+
figures: number;
|
|
86
|
+
processingEvents: number;
|
|
87
|
+
qualityFlags: number;
|
|
88
|
+
maskedValues: number;
|
|
89
|
+
graph: {
|
|
90
|
+
entities: number;
|
|
91
|
+
relations: number;
|
|
92
|
+
communities: number;
|
|
93
|
+
};
|
|
94
|
+
evalQuestions: number;
|
|
95
|
+
chatCitations: number;
|
|
96
|
+
}
|
|
97
|
+
export interface DeletionImpact {
|
|
98
|
+
document: {
|
|
99
|
+
id: string;
|
|
100
|
+
title: string | null;
|
|
101
|
+
sourceType: string;
|
|
102
|
+
status: string;
|
|
103
|
+
fromConnector: {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
kind: string;
|
|
107
|
+
} | null;
|
|
108
|
+
};
|
|
109
|
+
/** Versions erased together (1 unless the project keeps version history). */
|
|
110
|
+
versions: number;
|
|
111
|
+
removes: DeletionRemoved;
|
|
112
|
+
/** What stays, stated plainly. */
|
|
113
|
+
keeps: string[];
|
|
114
|
+
}
|
|
115
|
+
export interface DeletionReceipt {
|
|
116
|
+
id: string;
|
|
117
|
+
deleted: true;
|
|
118
|
+
versionsPurged: number;
|
|
119
|
+
removed: DeletionRemoved;
|
|
120
|
+
keeps: string[];
|
|
121
|
+
/** Things to do now, e.g. rebuild graph communities or remove the file at its connected source. */
|
|
122
|
+
followUps: string[];
|
|
123
|
+
}
|
|
124
|
+
export interface MultiProjectSearchResponse {
|
|
125
|
+
results: Array<SearchResult & {
|
|
126
|
+
projectId: string;
|
|
127
|
+
projectName: string;
|
|
128
|
+
projectSlug: string;
|
|
129
|
+
/** Score bands for this project's model — read `score` against these. */
|
|
130
|
+
relevance: {
|
|
131
|
+
strong: number;
|
|
132
|
+
moderate: number;
|
|
133
|
+
};
|
|
134
|
+
/** Present when several projects were merged by rank. */
|
|
135
|
+
fusedScore?: number;
|
|
136
|
+
}>;
|
|
137
|
+
projects: Array<{
|
|
138
|
+
id: string;
|
|
139
|
+
name: string;
|
|
140
|
+
slug: string;
|
|
141
|
+
resultCount: number;
|
|
142
|
+
/** Set when this project could not be searched; the others still return. */
|
|
143
|
+
error?: {
|
|
144
|
+
code: string;
|
|
145
|
+
message: string;
|
|
146
|
+
};
|
|
147
|
+
}>;
|
|
148
|
+
pipeline: {
|
|
149
|
+
mode: string;
|
|
150
|
+
topK: number;
|
|
151
|
+
fusion: 'none' | 'rrf';
|
|
152
|
+
projectCount: number;
|
|
153
|
+
failedProjects?: number;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** Canonical metadata filter: bare equality, $-operators, $and/$or groups. */
|
|
157
|
+
export type Filter = Record<string, unknown>;
|
|
158
|
+
/** Related-chunk expansion (gap 12): stitches associated chunks into one window. */
|
|
159
|
+
export type Expand = 'none' | 'neighbors' | 'section' | 'parent' | 'entity' | 'graph';
|
|
160
|
+
export interface SearchParams {
|
|
161
|
+
query: string;
|
|
162
|
+
topK?: number;
|
|
163
|
+
mode?: 'vector' | 'keyword' | 'hybrid';
|
|
164
|
+
minScore?: number;
|
|
165
|
+
rerank?: 'none' | 'llm' | 'cohere' | 'tei';
|
|
166
|
+
filter?: Filter;
|
|
167
|
+
trace?: boolean;
|
|
168
|
+
/** Related-chunk expansion — 'none' preserves independent top-k. */
|
|
169
|
+
expand?: Expand;
|
|
170
|
+
/** Neighbours per side when expand='neighbors' (0 disables). */
|
|
171
|
+
expandWindow?: number;
|
|
172
|
+
/** Query-side HyDE: embed a generated hypothetical answer alongside the query. */
|
|
173
|
+
hyde?: boolean;
|
|
174
|
+
/** Edge hops for expand='graph' (1 = direct neighbours). */
|
|
175
|
+
graphHops?: number;
|
|
176
|
+
/** Opt-in exponential-decay re-ranking by document age. */
|
|
177
|
+
recencyBias?: boolean;
|
|
178
|
+
/** Half-life in days for recencyBias (a document this old = half weight). */
|
|
179
|
+
recencyHalfLifeDays?: number;
|
|
180
|
+
}
|
|
181
|
+
export interface AskParams {
|
|
182
|
+
query: string;
|
|
183
|
+
topK?: number;
|
|
184
|
+
mode?: 'auto' | 'table' | 'search' | 'retrieve' | 'agentic';
|
|
185
|
+
filter?: Filter;
|
|
186
|
+
style?: 'concise' | 'detailed';
|
|
187
|
+
/** The underlying hybrid-search strategy (vector-only/keyword-only/hybrid). */
|
|
188
|
+
retrievalMode?: 'vector' | 'keyword' | 'hybrid';
|
|
189
|
+
rerank?: 'none' | 'llm' | 'cohere' | 'tei';
|
|
190
|
+
minScore?: number;
|
|
191
|
+
expand?: Expand;
|
|
192
|
+
expandWindow?: number;
|
|
193
|
+
hyde?: boolean;
|
|
194
|
+
graphHops?: number;
|
|
195
|
+
recencyBias?: boolean;
|
|
196
|
+
recencyHalfLifeDays?: number;
|
|
197
|
+
}
|
|
198
|
+
export interface Citation {
|
|
199
|
+
marker: number;
|
|
200
|
+
documentId: string;
|
|
201
|
+
chunkIndex: number;
|
|
202
|
+
page?: number;
|
|
203
|
+
score: number;
|
|
204
|
+
text: string;
|
|
205
|
+
}
|
|
206
|
+
export interface AskResponse {
|
|
207
|
+
mode: string;
|
|
208
|
+
engine: 'deterministic' | 'llm-sql' | 'generated' | 'retrieve' | 'none';
|
|
209
|
+
answer?: string | null;
|
|
210
|
+
refused?: boolean;
|
|
211
|
+
citations?: Citation[];
|
|
212
|
+
usage?: {
|
|
213
|
+
inputTokens: number;
|
|
214
|
+
outputTokens: number;
|
|
215
|
+
};
|
|
216
|
+
results?: SearchResult[];
|
|
217
|
+
value?: number;
|
|
218
|
+
sql?: string;
|
|
219
|
+
note?: string;
|
|
220
|
+
}
|
|
221
|
+
export type AskStreamEvent = {
|
|
222
|
+
event: 'meta';
|
|
223
|
+
data: {
|
|
224
|
+
engine: string;
|
|
225
|
+
retrieved: number;
|
|
226
|
+
topScore: number;
|
|
227
|
+
};
|
|
228
|
+
} | {
|
|
229
|
+
event: 'delta';
|
|
230
|
+
data: {
|
|
231
|
+
text: string;
|
|
232
|
+
};
|
|
233
|
+
} | {
|
|
234
|
+
event: 'citations';
|
|
235
|
+
data: {
|
|
236
|
+
refused: boolean;
|
|
237
|
+
answer: string | null;
|
|
238
|
+
citations: Citation[];
|
|
239
|
+
usage?: AskResponse['usage'];
|
|
240
|
+
};
|
|
241
|
+
} | {
|
|
242
|
+
event: 'result';
|
|
243
|
+
data: AskResponse;
|
|
244
|
+
} | {
|
|
245
|
+
event: 'error';
|
|
246
|
+
data: {
|
|
247
|
+
message: string;
|
|
248
|
+
};
|
|
249
|
+
} | {
|
|
250
|
+
event: 'done';
|
|
251
|
+
data: Record<string, never>;
|
|
252
|
+
};
|
|
253
|
+
export interface TroveGenDocument {
|
|
254
|
+
id: string;
|
|
255
|
+
title: string | null;
|
|
256
|
+
sourceType: string;
|
|
257
|
+
status: string;
|
|
258
|
+
chunkCount: number;
|
|
259
|
+
createdAt: string;
|
|
260
|
+
}
|
|
261
|
+
export interface MetadataKeyInfo {
|
|
262
|
+
key: string;
|
|
263
|
+
type: string;
|
|
264
|
+
occurrences: number;
|
|
265
|
+
samples: string[];
|
|
266
|
+
}
|
|
267
|
+
/** An extracted entity (gap 11): heuristic entities are typed 'unknown'; the
|
|
268
|
+
* LLM lane distinguishes person/org/product/location/event/concept. */
|
|
269
|
+
export interface EntityInfo {
|
|
270
|
+
id: string;
|
|
271
|
+
name: string;
|
|
272
|
+
type: string;
|
|
273
|
+
mentionCount: number;
|
|
274
|
+
}
|
|
275
|
+
export declare class TroveGenClient {
|
|
276
|
+
private readonly base;
|
|
277
|
+
private readonly key;
|
|
278
|
+
private readonly retries;
|
|
279
|
+
private readonly timeoutMs;
|
|
280
|
+
private readonly fetchImpl;
|
|
281
|
+
constructor(opts: TroveGenClientOptions);
|
|
282
|
+
private request;
|
|
283
|
+
private json;
|
|
284
|
+
readonly projects: {
|
|
285
|
+
create: (input: {
|
|
286
|
+
name: string;
|
|
287
|
+
[k: string]: unknown;
|
|
288
|
+
}) => Promise<Project>;
|
|
289
|
+
list: () => Promise<Project[]>;
|
|
290
|
+
get: (id: string) => Promise<Project>;
|
|
291
|
+
update: (id: string, patch: Record<string, unknown>) => Promise<Project>;
|
|
292
|
+
delete: (id: string) => Promise<{
|
|
293
|
+
id: string;
|
|
294
|
+
}>;
|
|
295
|
+
metadataKeys: (id: string) => Promise<MetadataKeyInfo[]>;
|
|
296
|
+
};
|
|
297
|
+
/** Entity graph (gap 11): entities extracted at ingest (chunkingConfig.graphMode). */
|
|
298
|
+
readonly entities: {
|
|
299
|
+
list: (projectId: string, limit?: number) => Promise<EntityInfo[]>;
|
|
300
|
+
};
|
|
301
|
+
readonly documents: {
|
|
302
|
+
ingestText: (projectId: string, input: {
|
|
303
|
+
title?: string;
|
|
304
|
+
text: string;
|
|
305
|
+
metadata?: Record<string, unknown>;
|
|
306
|
+
documentType?: string;
|
|
307
|
+
}) => Promise<IngestResult>;
|
|
308
|
+
ingestUrl: (projectId: string, input: {
|
|
309
|
+
url: string;
|
|
310
|
+
metadata?: Record<string, unknown>;
|
|
311
|
+
}) => Promise<IngestResult>;
|
|
312
|
+
ingestFile: (projectId: string, file: {
|
|
313
|
+
data: Uint8Array | Blob;
|
|
314
|
+
filename: string;
|
|
315
|
+
contentType?: string;
|
|
316
|
+
}, metadata?: Record<string, unknown>) => Promise<IngestResult>;
|
|
317
|
+
list: (projectId: string) => Promise<TroveGenDocument[]>;
|
|
318
|
+
/** What deleting this document would remove — read-only; use it to confirm with the user first. */
|
|
319
|
+
deletionImpact: (projectId: string, documentId: string) => Promise<DeletionImpact>;
|
|
320
|
+
/** Permanently deletes the document AND everything derived from it; returns a receipt of what was removed. */
|
|
321
|
+
delete: (projectId: string, documentId: string) => Promise<DeletionReceipt>;
|
|
322
|
+
};
|
|
323
|
+
search(projectId: string, params: SearchParams): Promise<SearchResponse>;
|
|
324
|
+
/**
|
|
325
|
+
* Search the projects you choose (ids or slugs); omit `projectIds` to search
|
|
326
|
+
* every project in the workspace. Several projects are merged by rank, and
|
|
327
|
+
* each result names the project it came from.
|
|
328
|
+
*/
|
|
329
|
+
searchProjects(params: SearchParams & {
|
|
330
|
+
projectIds?: string[];
|
|
331
|
+
}): Promise<MultiProjectSearchResponse>;
|
|
332
|
+
/** Routed ask: exact table computation, grounded generation, or retrieval. */
|
|
333
|
+
ask(projectId: string, params: AskParams): Promise<AskResponse>;
|
|
334
|
+
/**
|
|
335
|
+
* Streaming ask (SSE). Yields typed events; the terminal `citations` event
|
|
336
|
+
* carries the validated answer — replace accumulated deltas with it.
|
|
337
|
+
*/
|
|
338
|
+
askStream(projectId: string, params: AskParams): AsyncGenerator<AskStreamEvent>;
|
|
339
|
+
readonly usage: {
|
|
340
|
+
get: () => Promise<{
|
|
341
|
+
usage: Record<string, number>;
|
|
342
|
+
entitlements: Record<string, number | boolean>;
|
|
343
|
+
}>;
|
|
344
|
+
};
|
|
345
|
+
/** Liveness of the target deployment (no auth required server-side). */
|
|
346
|
+
health(): Promise<boolean>;
|
|
347
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* troveGEN SDK — a thin, dependency-free, typed client for the troveGEN API.
|
|
4
|
+
*
|
|
5
|
+
* Works in Node ≥18 and modern browsers (global fetch / FormData / streams).
|
|
6
|
+
* Auth: a `trv_` API key (server-to-server) or a dashboard JWT.
|
|
7
|
+
* Point `baseUrl` at any troveGEN deployment — cloud, self-hosted, or air-gapped.
|
|
8
|
+
*
|
|
9
|
+
* const trovegen = new TroveGenClient({ apiKey: 'trv_…', baseUrl: 'http://localhost:4000' });
|
|
10
|
+
* const project = await trovegen.projects.create({ name: 'Docs' });
|
|
11
|
+
* await trovegen.documents.ingestText(project.id, { title: 'Refunds', text: '…' });
|
|
12
|
+
* for await (const ev of trovegen.askStream(project.id, { query: 'refund policy?' })) {
|
|
13
|
+
* if (ev.event === 'delta') process.stdout.write(ev.data.text);
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TroveGenClient = exports.TroveGenError = void 0;
|
|
18
|
+
class TroveGenError extends Error {
|
|
19
|
+
constructor(code, message, status, requestId, details) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.code = code;
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.requestId = requestId;
|
|
24
|
+
this.details = details;
|
|
25
|
+
this.name = 'TroveGenError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.TroveGenError = TroveGenError;
|
|
29
|
+
class TroveGenClient {
|
|
30
|
+
constructor(opts) {
|
|
31
|
+
// ---- resources -----------------------------------------------------------
|
|
32
|
+
this.projects = {
|
|
33
|
+
create: (input) => this.json('POST', '/projects', input),
|
|
34
|
+
list: () => this.json('GET', '/projects'),
|
|
35
|
+
get: (id) => this.json('GET', `/projects/${id}`),
|
|
36
|
+
update: (id, patch) => this.json('PATCH', `/projects/${id}`, patch),
|
|
37
|
+
delete: (id) => this.json('DELETE', `/projects/${id}`),
|
|
38
|
+
metadataKeys: (id) => this.json('GET', `/projects/${id}/metadata-keys`),
|
|
39
|
+
};
|
|
40
|
+
/** Entity graph (gap 11): entities extracted at ingest (chunkingConfig.graphMode). */
|
|
41
|
+
this.entities = {
|
|
42
|
+
list: (projectId, limit) => this.json('GET', `/projects/${projectId}/entities${limit ? `?limit=${limit}` : ''}`),
|
|
43
|
+
};
|
|
44
|
+
this.documents = {
|
|
45
|
+
ingestText: (projectId, input) => this.json('POST', `/projects/${projectId}/documents/text`, input),
|
|
46
|
+
ingestUrl: (projectId, input) => this.json('POST', `/projects/${projectId}/documents/url`, input),
|
|
47
|
+
ingestFile: (projectId, file, metadata) => {
|
|
48
|
+
const form = new FormData();
|
|
49
|
+
const blob = file.data instanceof Blob
|
|
50
|
+
? file.data
|
|
51
|
+
: new Blob([file.data.buffer.slice(file.data.byteOffset, file.data.byteOffset + file.data.byteLength)], {
|
|
52
|
+
type: file.contentType ?? 'application/octet-stream',
|
|
53
|
+
});
|
|
54
|
+
form.append('file', blob, file.filename);
|
|
55
|
+
if (metadata)
|
|
56
|
+
form.append('metadata', JSON.stringify(metadata));
|
|
57
|
+
return this.json('POST', `/projects/${projectId}/documents/file`, undefined, form);
|
|
58
|
+
},
|
|
59
|
+
list: (projectId) => this.json('GET', `/projects/${projectId}/documents`),
|
|
60
|
+
/** What deleting this document would remove — read-only; use it to confirm with the user first. */
|
|
61
|
+
deletionImpact: (projectId, documentId) => this.json('GET', `/projects/${projectId}/documents/${documentId}/deletion-impact`),
|
|
62
|
+
/** Permanently deletes the document AND everything derived from it; returns a receipt of what was removed. */
|
|
63
|
+
delete: (projectId, documentId) => this.json('DELETE', `/projects/${projectId}/documents/${documentId}`),
|
|
64
|
+
};
|
|
65
|
+
this.usage = {
|
|
66
|
+
get: () => this.json('GET', '/usage'),
|
|
67
|
+
};
|
|
68
|
+
if (!opts.apiKey)
|
|
69
|
+
throw new Error('TroveGenClient: apiKey is required');
|
|
70
|
+
this.key = opts.apiKey;
|
|
71
|
+
this.base = (opts.baseUrl ?? 'http://localhost:4000').replace(/\/+$/, '') + '/api/v1';
|
|
72
|
+
this.retries = opts.maxRetries ?? 2;
|
|
73
|
+
this.timeoutMs = opts.timeoutMs ?? 60_000;
|
|
74
|
+
this.fetchImpl = opts.fetch ?? fetch;
|
|
75
|
+
}
|
|
76
|
+
// ---- transport -----------------------------------------------------------
|
|
77
|
+
async request(method, path, body, init) {
|
|
78
|
+
let lastError;
|
|
79
|
+
for (let attempt = 0; attempt <= this.retries; attempt++) {
|
|
80
|
+
const controller = new AbortController();
|
|
81
|
+
const timer = init?.stream
|
|
82
|
+
? null
|
|
83
|
+
: setTimeout(() => controller.abort(new Error('request timed out')), this.timeoutMs);
|
|
84
|
+
try {
|
|
85
|
+
const res = await this.fetchImpl(`${this.base}${path}`, {
|
|
86
|
+
method,
|
|
87
|
+
headers: {
|
|
88
|
+
Authorization: `Bearer ${this.key}`,
|
|
89
|
+
...(init?.form ? {} : body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
90
|
+
...(init?.stream ? { Accept: 'text/event-stream' } : {}),
|
|
91
|
+
},
|
|
92
|
+
body: init?.form ?? (body !== undefined ? JSON.stringify(body) : undefined),
|
|
93
|
+
signal: controller.signal,
|
|
94
|
+
});
|
|
95
|
+
// Retry the transient tier; surface everything else immediately.
|
|
96
|
+
if ((res.status === 429 || res.status >= 500) && attempt < this.retries) {
|
|
97
|
+
const retryAfter = Number(res.headers.get('retry-after')) * 1000;
|
|
98
|
+
await sleep(retryAfter > 0 ? retryAfter : backoff(attempt));
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
return res;
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
lastError = err;
|
|
105
|
+
if (attempt < this.retries) {
|
|
106
|
+
await sleep(backoff(attempt));
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
if (timer)
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
throw lastError instanceof Error ? lastError : new Error('request failed');
|
|
117
|
+
}
|
|
118
|
+
async json(method, path, body, form) {
|
|
119
|
+
const res = await this.request(method, path, body, form ? { form } : undefined);
|
|
120
|
+
const requestId = res.headers.get('x-request-id') ?? undefined;
|
|
121
|
+
const parsed = (await res.json().catch(() => null));
|
|
122
|
+
if (!res.ok || !parsed || parsed.success === false) {
|
|
123
|
+
const err = parsed?.error;
|
|
124
|
+
throw new TroveGenError(err?.code ?? `HTTP_${res.status}`, err?.message ?? `Request failed with status ${res.status}`, res.status, requestId, err?.details);
|
|
125
|
+
}
|
|
126
|
+
return parsed.data;
|
|
127
|
+
}
|
|
128
|
+
search(projectId, params) {
|
|
129
|
+
return this.json('POST', `/projects/${projectId}/search`, params);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Search the projects you choose (ids or slugs); omit `projectIds` to search
|
|
133
|
+
* every project in the workspace. Several projects are merged by rank, and
|
|
134
|
+
* each result names the project it came from.
|
|
135
|
+
*/
|
|
136
|
+
searchProjects(params) {
|
|
137
|
+
return this.json('POST', '/search', params);
|
|
138
|
+
}
|
|
139
|
+
/** Routed ask: exact table computation, grounded generation, or retrieval. */
|
|
140
|
+
ask(projectId, params) {
|
|
141
|
+
return this.json('POST', `/projects/${projectId}/ask`, params);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Streaming ask (SSE). Yields typed events; the terminal `citations` event
|
|
145
|
+
* carries the validated answer — replace accumulated deltas with it.
|
|
146
|
+
*/
|
|
147
|
+
async *askStream(projectId, params) {
|
|
148
|
+
const res = await this.request('POST', `/projects/${projectId}/ask`, { ...params, stream: true }, { stream: true });
|
|
149
|
+
if (!res.ok || !res.body) {
|
|
150
|
+
const parsed = (await res.json().catch(() => null));
|
|
151
|
+
throw new TroveGenError(parsed?.error?.code ?? `HTTP_${res.status}`, parsed?.error?.message ?? `Stream request failed (${res.status})`, res.status, res.headers.get('x-request-id') ?? undefined, parsed?.error?.details);
|
|
152
|
+
}
|
|
153
|
+
const reader = res.body.getReader();
|
|
154
|
+
const decoder = new TextDecoder();
|
|
155
|
+
let buffer = '';
|
|
156
|
+
for (;;) {
|
|
157
|
+
const { done, value } = await reader.read();
|
|
158
|
+
if (done)
|
|
159
|
+
break;
|
|
160
|
+
buffer += decoder.decode(value, { stream: true });
|
|
161
|
+
let idx;
|
|
162
|
+
while ((idx = buffer.indexOf('\n\n')) !== -1) {
|
|
163
|
+
const block = buffer.slice(0, idx);
|
|
164
|
+
buffer = buffer.slice(idx + 2);
|
|
165
|
+
let event = 'message';
|
|
166
|
+
let data = '';
|
|
167
|
+
for (const line of block.split('\n')) {
|
|
168
|
+
if (line.startsWith('event: '))
|
|
169
|
+
event = line.slice(7).trim();
|
|
170
|
+
else if (line.startsWith('data: '))
|
|
171
|
+
data += line.slice(6);
|
|
172
|
+
}
|
|
173
|
+
if (!data)
|
|
174
|
+
continue;
|
|
175
|
+
try {
|
|
176
|
+
yield { event, data: JSON.parse(data) };
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
/* skip malformed frame */
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** Liveness of the target deployment (no auth required server-side). */
|
|
185
|
+
async health() {
|
|
186
|
+
try {
|
|
187
|
+
const res = await this.fetchImpl(`${this.base.replace(/\/api\/v1$/, '')}/health`);
|
|
188
|
+
return res.ok;
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.TroveGenClient = TroveGenClient;
|
|
196
|
+
function sleep(ms) {
|
|
197
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
198
|
+
}
|
|
199
|
+
function backoff(attempt) {
|
|
200
|
+
return Math.min(4000, 400 * 2 ** attempt) + Math.random() * 200;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAcH,MAAa,aAAc,SAAQ,KAAK;IACtC,YACkB,IAAY,EAC5B,OAAe,EACC,MAAc,EACd,SAAkB,EAClB,OAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QANC,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAS;QAClB,YAAO,GAAP,OAAO,CAAU;QAGjC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAXD,sCAWC;AA4ND,MAAa,cAAc;IAOzB,YAAY,IAA2B;QAwEvC,6EAA6E;QAEpE,aAAQ,GAAG;YAClB,MAAM,EAAE,CAAC,KAA6C,EAAE,EAAE,CACxD,IAAI,CAAC,IAAI,CAAU,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC;YAChD,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAY,KAAK,EAAE,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AAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AA7MD,wCA6MC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC;AACD,SAAS,OAAO,CAAC,OAAe;IAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;AAClE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intellara/trovegen-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "TypeScript SDK for the troveGEN RAG platform — ingestion, hybrid search, and grounded, cited answers (with streaming).",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://trovegen.com",
|
|
7
|
+
"author": "Intellara Technologies Private Limited",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"rag",
|
|
10
|
+
"retrieval-augmented-generation",
|
|
11
|
+
"vector-search",
|
|
12
|
+
"hybrid-search",
|
|
13
|
+
"trovegen"
|
|
14
|
+
],
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"NOTICE"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^24.19.1",
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"type-check": "tsc --noEmit"
|
|
36
|
+
}
|
|
6
37
|
}
|