@novalabai/adk 2.15.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -33
- package/dist/client.d.ts +19 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +27 -8
- package/dist/client.js.map +1 -1
- package/dist/core/errors.d.ts +57 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +76 -2
- package/dist/core/errors.js.map +1 -1
- package/dist/core/http.d.ts +20 -0
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +105 -42
- package/dist/core/http.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/dist/resources/billing.d.ts +16 -0
- package/dist/resources/billing.d.ts.map +1 -1
- package/dist/resources/billing.js +30 -0
- package/dist/resources/billing.js.map +1 -1
- package/dist/resources/chat.d.ts +7 -0
- package/dist/resources/chat.d.ts.map +1 -1
- package/dist/resources/chat.js +10 -1
- package/dist/resources/chat.js.map +1 -1
- package/dist/resources/creative.d.ts +2 -3
- package/dist/resources/creative.d.ts.map +1 -1
- package/dist/resources/creative.js.map +1 -1
- package/dist/resources/files.d.ts +12 -1
- package/dist/resources/files.d.ts.map +1 -1
- package/dist/resources/files.js +12 -1
- package/dist/resources/files.js.map +1 -1
- package/dist/resources/messages.d.ts +34 -0
- package/dist/resources/messages.d.ts.map +1 -0
- package/dist/resources/messages.js +54 -0
- package/dist/resources/messages.js.map +1 -0
- package/dist/resources/models-list.d.ts +9 -0
- package/dist/resources/models-list.d.ts.map +1 -0
- package/dist/resources/models-list.js +15 -0
- package/dist/resources/models-list.js.map +1 -0
- package/dist/resources/subscription.d.ts +0 -2
- package/dist/resources/subscription.d.ts.map +1 -1
- package/dist/resources/subscription.js +0 -4
- package/dist/resources/subscription.js.map +1 -1
- package/dist/types/account.d.ts +137 -0
- package/dist/types/account.d.ts.map +1 -0
- package/dist/types/account.js +4 -0
- package/dist/types/account.js.map +1 -0
- package/dist/types/files.d.ts +10 -0
- package/dist/types/files.d.ts.map +1 -1
- package/dist/types/messages.d.ts +159 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +68 -0
- package/dist/types/messages.js.map +1 -0
- package/package.json +1 -1
- package/dist/resources/terminal.d.ts +0 -84
- package/dist/resources/terminal.d.ts.map +0 -1
- package/dist/resources/terminal.js +0 -81
- package/dist/resources/terminal.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,37 +12,105 @@ npm install @novalabai/adk
|
|
|
12
12
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
|
+
1. API keys come with every paid plan, from Pro (a Free plan's key gets
|
|
16
|
+
`PlanRequired`). Pick a plan at https://app.novalab.build/plans.
|
|
17
|
+
2. Create a key in Nova under Settings, Developer, and set it as `NOVA_API_KEY`.
|
|
18
|
+
3. First call (Node 18+, ESM or CommonJS):
|
|
19
|
+
|
|
15
20
|
```typescript
|
|
16
|
-
import { NovaClient } from '@novalabai/adk';
|
|
21
|
+
import { NovaClient, messageText } from '@novalabai/adk';
|
|
22
|
+
|
|
23
|
+
const nova = new NovaClient(); // reads NOVA_API_KEY (or new NovaClient({ apiKey: 'nova_...' }))
|
|
17
24
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
const msg = await nova.messages.create({
|
|
26
|
+
model: 'nova-flagship',
|
|
27
|
+
max_tokens: 512,
|
|
28
|
+
messages: [{ role: 'user', content: 'Write one sentence about the fjords.' }],
|
|
22
29
|
});
|
|
30
|
+
console.log(messageText(msg));
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Nova models: `nova-max`, `nova-flagship`, `nova-reasoning`, `nova-fast`. The
|
|
34
|
+
model you name in `messages.create` is the model that runs. Hosted in the EU.
|
|
35
|
+
|
|
36
|
+
## Chat, streaming, tools, images
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { eventText, imageBlock, messageText, toolResultBlock, toolUses } from '@novalabai/adk';
|
|
40
|
+
|
|
41
|
+
// Nova's full chat: model 'auto' picks the model; send session_id back to continue
|
|
42
|
+
const reply = await nova.chat.send({ message: 'Summarise the latest sales report' });
|
|
43
|
+
await nova.chat.send({ message: 'Shorter, please.', session_id: reply.session_id });
|
|
44
|
+
|
|
45
|
+
// Streaming
|
|
46
|
+
for await (const ev of nova.messages.stream({ model: 'nova-fast', messages: [{ role: 'user', content: 'Hello' }] })) {
|
|
47
|
+
process.stdout.write(eventText(ev));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Your own tools: run them when the answer stops with 'tool_use', send the result back
|
|
51
|
+
const tools = [{ name: 'get_weather', input_schema: { type: 'object', properties: { city: { type: 'string' } } } }];
|
|
52
|
+
const messages: any[] = [{ role: 'user', content: 'Weather in Oslo?' }];
|
|
53
|
+
let msg = await nova.messages.create({ tools, messages });
|
|
54
|
+
while (msg.stop_reason === 'tool_use') {
|
|
55
|
+
const results = toolUses(msg).map((c) => toolResultBlock(c.id, myWeather(c.input))); // myWeather: your code
|
|
56
|
+
messages.push({ role: 'assistant', content: msg.content }, { role: 'user', content: results });
|
|
57
|
+
msg = await nova.messages.create({ tools, messages });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Images (PNG, JPEG, GIF, WebP)
|
|
61
|
+
await nova.messages.create({ messages: [{ role: 'user', content: [imageBlock(pngBytes), { type: 'text', text: 'What is this?' }] }] });
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## JSON answers, files, thinking (2.17)
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { documentBlock, jsonSchemaFormat, messageJson, messageText, messageThinking } from '@novalabai/adk';
|
|
68
|
+
|
|
69
|
+
// JSON that matches your schema (InvalidJsonOutput when it cannot)
|
|
70
|
+
const schema = { type: 'object', properties: { vendor: { type: 'string' }, total: { type: 'number' } }, required: ['vendor', 'total'] };
|
|
71
|
+
const inv = await nova.messages.create({ messages: [{ role: 'user', content: 'Invoice: ACME, total 12 EUR' }], response_format: jsonSchemaFormat(schema) });
|
|
72
|
+
console.log(messageJson<{ total: number }>(inv).total);
|
|
23
73
|
|
|
24
|
-
//
|
|
74
|
+
// Answer from a file, with page numbers
|
|
75
|
+
const f = await nova.files.upload({ content: await readFile('contract.pdf'), filename: 'contract.pdf' });
|
|
76
|
+
const ans = await nova.messages.create({ messages: [{ role: 'user', content: [documentBlock(f.file_id), { type: 'text', text: 'Notice period?' }] }] });
|
|
77
|
+
console.log(messageText(ans), ans.citations?.map((c) => c.page));
|
|
78
|
+
|
|
79
|
+
// Think longer (Pro plan and higher)
|
|
80
|
+
const careful = await nova.messages.create({ thinking: { effort: 'high' }, messages: [{ role: 'user', content: 'Check this spec ...' }] });
|
|
81
|
+
console.log(messageThinking(careful), messageText(careful));
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Try them first in the API Playground: https://app.novalab.build/playground
|
|
85
|
+
|
|
86
|
+
## Plan features and credits
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const plan = await nova.planFeatures(); // GET /v1/plan/features
|
|
90
|
+
console.log(plan.plan, plan.features.helpers?.allowed, plan.limits.monthly_credits);
|
|
91
|
+
|
|
92
|
+
const credits = await nova.billing.credits(); // balance, used_pct, at_zero, topup_url
|
|
93
|
+
const packs = await nova.billing.topupPacks();
|
|
94
|
+
const { checkout_url } = await nova.billing.topupCheckout(packs[0].credits); // open to pay
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Also: `nova.models.list()`, `nova.billing.usageHistory(days)`,
|
|
98
|
+
`nova.billing.operationCosts()`, `nova.billing.catalog()`,
|
|
99
|
+
`nova.billing.invoices()`, `nova.billing.portal()`, and
|
|
100
|
+
`nova.chat.completions({ messages })` for the common chat completions format.
|
|
101
|
+
|
|
102
|
+
## Agents
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
25
105
|
const agent = await nova.agents.create({
|
|
26
106
|
name: 'my-assistant',
|
|
27
107
|
description: 'A helpful coding assistant',
|
|
28
108
|
model: 'auto',
|
|
29
109
|
systemPrompt: 'You are a helpful assistant.',
|
|
30
|
-
temperature: 0.7,
|
|
31
|
-
maxTokens: 2048,
|
|
32
110
|
});
|
|
33
|
-
|
|
34
|
-
// Deploy it
|
|
35
111
|
await nova.agents.deploy(agent.agentId);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const result = await nova.agents.run(agent.agentId, {
|
|
39
|
-
task: 'Explain the security risks of storing JWT tokens in localStorage',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
console.log(result.output); // AI response
|
|
43
|
-
console.log(result.confidence); // 0-100 confidence score
|
|
44
|
-
console.log(result.trust); // Trust evaluation (accuracy, safety, relevance, completeness)
|
|
45
|
-
console.log(result.autonomyLevel); // AUTONOMOUS | NOTIFY | APPROVAL_REQUIRED | BLOCKED
|
|
112
|
+
const result = await nova.agents.run(agent.agentId, { task: 'Explain the risks of storing JWT tokens in localStorage' });
|
|
113
|
+
console.log(result.output, result.confidence);
|
|
46
114
|
```
|
|
47
115
|
|
|
48
116
|
## Features
|
|
@@ -81,7 +149,6 @@ nova.conversations // Stored conversations and their artifacts
|
|
|
81
149
|
nova.team // Your team and its members
|
|
82
150
|
nova.agent // Chat-agent settings and tool-call approvals
|
|
83
151
|
nova.files // Chat attachments
|
|
84
|
-
nova.terminal // Admin only (see below)
|
|
85
152
|
```
|
|
86
153
|
|
|
87
154
|
## Streaming Chat and Agent Mode
|
|
@@ -135,21 +202,25 @@ await nova.team.remove('user_123');
|
|
|
135
202
|
await nova.agent.updateSettings({ agent_mode: true, company_name: 'Acme' });
|
|
136
203
|
```
|
|
137
204
|
|
|
138
|
-
##
|
|
205
|
+
## Running code
|
|
139
206
|
|
|
140
|
-
`nova.terminal
|
|
141
|
-
|
|
142
|
-
`code === 'admin_required'`.
|
|
207
|
+
`nova.terminal` was removed (the `/v1/terminal` API is gone). Ask Nova to
|
|
208
|
+
run code in chat instead; it runs in the chat's private EU code sandbox.
|
|
143
209
|
|
|
144
210
|
## Errors
|
|
145
211
|
|
|
146
|
-
| Error | When |
|
|
147
|
-
|
|
148
|
-
| `NovaAuthError` | 401
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
| `
|
|
152
|
-
| `
|
|
212
|
+
| Error | When | What to do |
|
|
213
|
+
|---|---|---|
|
|
214
|
+
| `NovaAuthError` | 401 `auth_error` | Check the key |
|
|
215
|
+
| `CreditsExhausted` | 402 `insufficient_credits` (also a stream ending with `quota_exceeded`). Nothing ran. | `topupUrl` (credit pack, works at once) or `upgradeUrl` |
|
|
216
|
+
| `PlanRequired` | 403 `api_requires_paid_plan`: the key belongs to a Free plan | `upgradeUrl` |
|
|
217
|
+
| `FeatureNotInPlan` | 403 `feature_not_in_plan` | `requiredPlan`, `upgradeUrl` |
|
|
218
|
+
| `NovaPermissionError` | other 403, e.g. team role `forbidden` | |
|
|
219
|
+
| `RateLimited` | 429 (the SDK already waited `Retry-After` and retried short waits) | wait `retryAfter` seconds |
|
|
220
|
+
| `NovaAPIError` | anything else; `.code` and `.body` hold the server's error | |
|
|
221
|
+
|
|
222
|
+
The 2.16 errors extend the 2.15 ones and keep their `name`, so older checks
|
|
223
|
+
keep working; use `instanceof CreditsExhausted` and so on in new code.
|
|
153
224
|
|
|
154
225
|
## Trust Evaluation
|
|
155
226
|
|
|
@@ -197,7 +268,10 @@ for await (const chunk of stream) {
|
|
|
197
268
|
## Requirements
|
|
198
269
|
|
|
199
270
|
- Node.js >= 18
|
|
200
|
-
- A
|
|
271
|
+
- A Nova API key on a paid plan (Settings, Developer in https://app.novalab.build)
|
|
272
|
+
|
|
273
|
+
Docs and API reference: https://app.novalab.build/docs. OpenAPI 3.1:
|
|
274
|
+
https://app.novalab.build/openapi.json
|
|
201
275
|
|
|
202
276
|
## License
|
|
203
277
|
|
package/dist/client.d.ts
CHANGED
|
@@ -49,7 +49,6 @@ import { OilGasResource } from './resources/oilgas.js';
|
|
|
49
49
|
import { CreativeResource } from './resources/creative.js';
|
|
50
50
|
import { DesignResource } from './resources/design.js';
|
|
51
51
|
import { CybersecurityResource } from './resources/cybersecurity.js';
|
|
52
|
-
import { TerminalResource } from './resources/terminal.js';
|
|
53
52
|
import { ToolBuilderResource } from './resources/toolbuilder.js';
|
|
54
53
|
import { BrowserResource } from './resources/browser.js';
|
|
55
54
|
import { IntegrationsResource } from './resources/integrations.js';
|
|
@@ -57,11 +56,18 @@ import { AccountingResource } from './resources/accounting.js';
|
|
|
57
56
|
import { HealthResource } from './resources/health.js';
|
|
58
57
|
import { MarketingResource } from './resources/marketing.js';
|
|
59
58
|
import { MemoryResource } from './resources/memory.js';
|
|
59
|
+
import { MessagesResource } from './resources/messages.js';
|
|
60
|
+
import { ModelsResource } from './resources/models-list.js';
|
|
61
|
+
import type { PlanFeaturesInfo } from './types/account.js';
|
|
60
62
|
export interface NovaClientOptions {
|
|
61
|
-
|
|
63
|
+
/** Your Nova API key. Default: the NOVA_API_KEY environment variable. */
|
|
64
|
+
apiKey?: string;
|
|
62
65
|
region?: string;
|
|
66
|
+
/** Default: NOVA_BASE_URL, else https://api.novalab.build/v1 */
|
|
63
67
|
baseUrl?: string;
|
|
64
68
|
timeout?: number;
|
|
69
|
+
/** Retries for 429 / 5xx / timeouts (default 3). */
|
|
70
|
+
maxRetries?: number;
|
|
65
71
|
}
|
|
66
72
|
export declare class NovaClient {
|
|
67
73
|
readonly agents: AgentsResource;
|
|
@@ -132,8 +138,6 @@ export declare class NovaClient {
|
|
|
132
138
|
readonly design: DesignResource;
|
|
133
139
|
/** Cybersecurity AI — vulnerability scanning, compliance, threat intel, incident response */
|
|
134
140
|
readonly cybersecurity: CybersecurityResource;
|
|
135
|
-
/** Terminal AI — command execution, code running, package management, git, files */
|
|
136
|
-
readonly terminal: TerminalResource;
|
|
137
141
|
/** Tool Builder AI — generate custom tools from natural language prompts */
|
|
138
142
|
readonly toolbuilder: ToolBuilderResource;
|
|
139
143
|
/** Browser AI — browsing, screenshots, scraping, and automated testing */
|
|
@@ -157,7 +161,17 @@ export declare class NovaClient {
|
|
|
157
161
|
* → pipeline(steps) — compose route → parallel → verify
|
|
158
162
|
*/
|
|
159
163
|
readonly orchestrate: OrchestrationResource;
|
|
164
|
+
/** v2.16 — POST /v1/messages: create(...) and stream(...), with content blocks, your own tools and images. */
|
|
165
|
+
readonly messages: MessagesResource;
|
|
166
|
+
/** v2.16 — GET /v1/models */
|
|
167
|
+
readonly models: ModelsResource;
|
|
160
168
|
private readonly http;
|
|
161
|
-
constructor(options
|
|
169
|
+
constructor(options?: NovaClientOptions);
|
|
170
|
+
/**
|
|
171
|
+
* What your plan includes (GET /v1/plan/features). Check
|
|
172
|
+
* `features.helpers.allowed` before calling a feature to avoid a
|
|
173
|
+
* `FeatureNotInPlan` error.
|
|
174
|
+
*/
|
|
175
|
+
planFeatures(): Promise<PlanFeaturesInfo>;
|
|
162
176
|
}
|
|
163
177
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OA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AC;IAEtC,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;IAE5C,8GAA8G;IAC9G,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,OAAO,GAAE,iBAAsB;IA6E3C;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAGhD"}
|
package/dist/client.js
CHANGED
|
@@ -53,7 +53,6 @@ const oilgas_js_1 = require("./resources/oilgas.js");
|
|
|
53
53
|
const creative_js_1 = require("./resources/creative.js");
|
|
54
54
|
const design_js_1 = require("./resources/design.js");
|
|
55
55
|
const cybersecurity_js_1 = require("./resources/cybersecurity.js");
|
|
56
|
-
const terminal_js_1 = require("./resources/terminal.js");
|
|
57
56
|
const toolbuilder_js_1 = require("./resources/toolbuilder.js");
|
|
58
57
|
const browser_js_1 = require("./resources/browser.js");
|
|
59
58
|
const integrations_js_1 = require("./resources/integrations.js");
|
|
@@ -61,6 +60,12 @@ const accounting_js_1 = require("./resources/accounting.js");
|
|
|
61
60
|
const health_js_1 = require("./resources/health.js");
|
|
62
61
|
const marketing_js_1 = require("./resources/marketing.js");
|
|
63
62
|
const memory_js_1 = require("./resources/memory.js");
|
|
63
|
+
const messages_js_1 = require("./resources/messages.js");
|
|
64
|
+
const models_list_js_1 = require("./resources/models-list.js");
|
|
65
|
+
function env(name) {
|
|
66
|
+
const p = globalThis.process;
|
|
67
|
+
return p?.env?.[name] || undefined;
|
|
68
|
+
}
|
|
64
69
|
const DEFAULT_REGION = 'eu-west-1';
|
|
65
70
|
const DEFAULT_BASE_URL = 'https://api.novalab.build/v1';
|
|
66
71
|
class NovaClient {
|
|
@@ -132,8 +137,6 @@ class NovaClient {
|
|
|
132
137
|
design;
|
|
133
138
|
/** Cybersecurity AI — vulnerability scanning, compliance, threat intel, incident response */
|
|
134
139
|
cybersecurity;
|
|
135
|
-
/** Terminal AI — command execution, code running, package management, git, files */
|
|
136
|
-
terminal;
|
|
137
140
|
/** Tool Builder AI — generate custom tools from natural language prompts */
|
|
138
141
|
toolbuilder;
|
|
139
142
|
/** Browser AI — browsing, screenshots, scraping, and automated testing */
|
|
@@ -157,16 +160,25 @@ class NovaClient {
|
|
|
157
160
|
* → pipeline(steps) — compose route → parallel → verify
|
|
158
161
|
*/
|
|
159
162
|
orchestrate;
|
|
163
|
+
/** v2.16 — POST /v1/messages: create(...) and stream(...), with content blocks, your own tools and images. */
|
|
164
|
+
messages;
|
|
165
|
+
/** v2.16 — GET /v1/models */
|
|
166
|
+
models;
|
|
160
167
|
http;
|
|
161
|
-
constructor(options) {
|
|
168
|
+
constructor(options = {}) {
|
|
162
169
|
const region = options.region ?? DEFAULT_REGION;
|
|
163
|
-
const baseURL = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
170
|
+
const baseURL = options.baseUrl ?? env('NOVA_BASE_URL') ?? DEFAULT_BASE_URL;
|
|
171
|
+
// Without a key every call gets 401 auth_error (NovaAuthError).
|
|
172
|
+
const apiKey = options.apiKey ?? env('NOVA_API_KEY') ?? '';
|
|
164
173
|
this.http = new http_js_1.HttpClient({
|
|
165
174
|
baseURL,
|
|
166
|
-
apiKey
|
|
175
|
+
apiKey,
|
|
167
176
|
region,
|
|
168
177
|
timeout: options.timeout,
|
|
178
|
+
maxRetries: options.maxRetries,
|
|
169
179
|
});
|
|
180
|
+
this.messages = new messages_js_1.MessagesResource(this.http);
|
|
181
|
+
this.models = new models_list_js_1.ModelsResource(this.http);
|
|
170
182
|
this.agents = new agents_js_1.AgentsResource(this.http);
|
|
171
183
|
this.workflows = new workflows_js_1.WorkflowsResource(this.http);
|
|
172
184
|
this.signals = new signals_js_1.SignalsResource(this.http);
|
|
@@ -194,7 +206,7 @@ class NovaClient {
|
|
|
194
206
|
this.multiModal = new multimodal_js_1.MultiModalResource(this.http);
|
|
195
207
|
this.costOpt = new costopt_js_1.CostOptResource(this.http);
|
|
196
208
|
this.templates = new templates_js_1.TemplatesResource(this.http);
|
|
197
|
-
this.websocket = new websocket_js_1.WebSocketResource(this.http, baseURL,
|
|
209
|
+
this.websocket = new websocket_js_1.WebSocketResource(this.http, baseURL, apiKey);
|
|
198
210
|
this.marketplace = new marketplace_js_1.MarketplaceResource(this.http);
|
|
199
211
|
this.observability = new observability_js_1.ObservabilityResource(this.http);
|
|
200
212
|
this.chat = new chat_js_1.ChatResource(this.http);
|
|
@@ -218,7 +230,6 @@ class NovaClient {
|
|
|
218
230
|
this.creative = new creative_js_1.CreativeResource(this.http);
|
|
219
231
|
this.design = new design_js_1.DesignResource(this.http);
|
|
220
232
|
this.cybersecurity = new cybersecurity_js_1.CybersecurityResource(this.http);
|
|
221
|
-
this.terminal = new terminal_js_1.TerminalResource(this.http);
|
|
222
233
|
this.toolbuilder = new toolbuilder_js_1.ToolBuilderResource(this.http);
|
|
223
234
|
this.browser = new browser_js_1.BrowserResource(this.http);
|
|
224
235
|
this.integrations = new integrations_js_1.IntegrationsResource(this.http);
|
|
@@ -227,6 +238,14 @@ class NovaClient {
|
|
|
227
238
|
this.marketing = new marketing_js_1.MarketingResource(this.http);
|
|
228
239
|
this.memory = new memory_js_1.MemoryResource(this.http);
|
|
229
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* What your plan includes (GET /v1/plan/features). Check
|
|
243
|
+
* `features.helpers.allowed` before calling a feature to avoid a
|
|
244
|
+
* `FeatureNotInPlan` error.
|
|
245
|
+
*/
|
|
246
|
+
async planFeatures() {
|
|
247
|
+
return this.http.get('/plan/features');
|
|
248
|
+
}
|
|
230
249
|
}
|
|
231
250
|
exports.NovaClient = NovaClient;
|
|
232
251
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,qDAAuD;AACvD,2DAA6D;AAC7D,uDAAyD;AACzD,+DAAiE;AACjE,+DAAiE;AACjE,iDAAmD;AACnD,uDAAyD;AACzD,mDAAqD;AACrD,yDAA2D;AAC3D,uDAAiE;AACjE,yDAA2D;AAC3D,+CAAiD;AACjD,+DAAuE;AACvE,yDAA2D;AAC3D,qDAAuD;AACvD,mDAAqD;AACrD,uDAAyD,CAAE,SAAS;AACpE,+CAAiD;AACjD,iDAAmD;AACnD,+DAAiE;AACjE,mDAAqD;AACrD,6DAA+D;AAC/D,6DAA+D;AAC/D,iDAAmD;AACnD,6DAA+D;AAC/D,uDAAyD;AACzD,2DAA6D;AAC7D,2DAA6D;AAC7D,+DAAiE;AACjE,mEAAqE;AACrE,2DAA6D;AAC7D,qDAAuD;AACvD,2DAA6D;AAC7D,yDAA2D;AAC3D,iEAAmE;AACnE,iDAAmD;AACnD,6DAA8D;AAC9D,qDAAuD;AACvD,uDAAyD;AACzD,mDAAqD;AACrD,mDAAqD;AACrD,mEAAqE;AACrE,iDAAmD;AACnD,mDAAqD;AACrD,2DAA6D;AAC7D,qDAAuD;AACvD,uDAAyD;AACzD,qDAAuD;AACvD,yDAA2D;AAC3D,qDAAuD;AACvD,mEAAqE;AACrE
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,qDAAuD;AACvD,2DAA6D;AAC7D,uDAAyD;AACzD,+DAAiE;AACjE,+DAAiE;AACjE,iDAAmD;AACnD,uDAAyD;AACzD,mDAAqD;AACrD,yDAA2D;AAC3D,uDAAiE;AACjE,yDAA2D;AAC3D,+CAAiD;AACjD,+DAAuE;AACvE,yDAA2D;AAC3D,qDAAuD;AACvD,mDAAqD;AACrD,uDAAyD,CAAE,SAAS;AACpE,+CAAiD;AACjD,iDAAmD;AACnD,+DAA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AAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,IAAI,sCAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,IAAI,kCAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,GAAG,IAAI,0BAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,gCAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,IAAI,0BAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAmB,gBAAgB,CAAC,CAAC;IAC3D,CAAC;CACF;AA3MD,gCA2MC"}
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ export declare class NovaError extends Error {
|
|
|
3
3
|
}
|
|
4
4
|
export declare class NovaAPIError extends NovaError {
|
|
5
5
|
readonly status: number;
|
|
6
|
-
|
|
6
|
+
code: string;
|
|
7
7
|
readonly requestId: string | undefined;
|
|
8
|
+
/** The server's error object (the fields next to `code` and `message`). */
|
|
9
|
+
body: Record<string, unknown>;
|
|
8
10
|
constructor(status: number, code: string, message: string, requestId?: string);
|
|
9
11
|
}
|
|
10
12
|
export declare class NovaAuthError extends NovaAPIError {
|
|
@@ -12,7 +14,7 @@ export declare class NovaAuthError extends NovaAPIError {
|
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* HTTP 403: the key is valid but not allowed to do this. `code` carries the
|
|
15
|
-
* server's reason, e.g. `admin_required` (admin-only
|
|
17
|
+
* server's reason, e.g. `admin_required` (admin-only endpoints) or
|
|
16
18
|
* `forbidden` (team actions that need the owner/admin role).
|
|
17
19
|
*/
|
|
18
20
|
export declare class NovaPermissionError extends NovaAPIError {
|
|
@@ -40,6 +42,59 @@ export declare class NovaInsufficientCreditsError extends NovaAPIError {
|
|
|
40
42
|
readonly topupUrl: string;
|
|
41
43
|
constructor(detail: InsufficientCreditsDetail, requestId?: string);
|
|
42
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* HTTP 402: out of credits. Nothing was run. Buy a credit pack at `topupUrl`
|
|
47
|
+
* (works at once) or upgrade at `upgradeUrl`. A request that had already
|
|
48
|
+
* started finishes. Extends `NovaInsufficientCreditsError`, so 2.15 code
|
|
49
|
+
* that checks for that still works.
|
|
50
|
+
*/
|
|
51
|
+
export declare class CreditsExhausted extends NovaInsufficientCreditsError {
|
|
52
|
+
constructor(detail: InsufficientCreditsDetail, requestId?: string);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* HTTP 403 `api_requires_paid_plan`: API keys need a paid plan (from Pro).
|
|
56
|
+
* This key belongs to a Free plan. Upgrade at `upgradeUrl`.
|
|
57
|
+
*/
|
|
58
|
+
export declare class PlanRequired extends NovaPermissionError {
|
|
59
|
+
readonly plan: string;
|
|
60
|
+
readonly upgradeUrl: string;
|
|
61
|
+
constructor(message: string, plan?: string, upgradeUrl?: string, requestId?: string);
|
|
62
|
+
}
|
|
63
|
+
export interface FeatureNotInPlanDetail {
|
|
64
|
+
message: string;
|
|
65
|
+
feature?: string;
|
|
66
|
+
plan?: string;
|
|
67
|
+
requiredPlan?: string;
|
|
68
|
+
upgradeUrl?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* HTTP 403 `feature_not_in_plan`: your plan does not include `feature`.
|
|
72
|
+
* `requiredPlan` is the first plan with it. Check `nova.planFeatures()`
|
|
73
|
+
* first to avoid it.
|
|
74
|
+
*/
|
|
75
|
+
export declare class FeatureNotInPlan extends NovaPermissionError {
|
|
76
|
+
readonly feature: string;
|
|
77
|
+
readonly plan: string;
|
|
78
|
+
readonly requiredPlan: string;
|
|
79
|
+
readonly upgradeUrl: string;
|
|
80
|
+
constructor(detail: FeatureNotInPlanDetail, requestId?: string);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* HTTP 422 `invalid_json_output` (2.17): you asked for a JSON answer
|
|
84
|
+
* (`response_format`) and the answer did not match your schema after two
|
|
85
|
+
* tries. The message says where it failed. Nothing was charged.
|
|
86
|
+
*/
|
|
87
|
+
export declare class InvalidJsonOutput extends NovaAPIError {
|
|
88
|
+
constructor(message?: string, requestId?: string);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* HTTP 429: too many requests. Wait `retryAfter` seconds. The SDK already
|
|
92
|
+
* waited and retried (when the wait was short) before throwing this.
|
|
93
|
+
* `code` is `rate_limited` (per minute) or `plan_limit_reached`.
|
|
94
|
+
*/
|
|
95
|
+
export declare class RateLimited extends NovaRateLimitError {
|
|
96
|
+
constructor(retryAfter: number, message?: string, requestId?: string, code?: string);
|
|
97
|
+
}
|
|
43
98
|
export declare class NovaValidationError extends NovaError {
|
|
44
99
|
constructor(message: string);
|
|
45
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,YAAa,SAAQ,SAAS;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,YAAa,SAAQ,SAAS;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,2EAA2E;IAC3E,IAAI,EAAE,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CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAKjD"}
|
package/dist/core/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NovaConfidenceError = exports.NovaTimeoutError = exports.NovaValidationError = exports.NovaInsufficientCreditsError = exports.NovaRateLimitError = exports.NovaPermissionError = exports.NovaAuthError = exports.NovaAPIError = exports.NovaError = void 0;
|
|
3
|
+
exports.NovaConfidenceError = exports.NovaTimeoutError = exports.NovaValidationError = exports.RateLimited = exports.InvalidJsonOutput = exports.FeatureNotInPlan = exports.PlanRequired = exports.CreditsExhausted = exports.NovaInsufficientCreditsError = exports.NovaRateLimitError = exports.NovaPermissionError = exports.NovaAuthError = exports.NovaAPIError = exports.NovaError = void 0;
|
|
4
4
|
class NovaError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -13,6 +13,8 @@ class NovaAPIError extends NovaError {
|
|
|
13
13
|
status;
|
|
14
14
|
code;
|
|
15
15
|
requestId;
|
|
16
|
+
/** The server's error object (the fields next to `code` and `message`). */
|
|
17
|
+
body = {};
|
|
16
18
|
constructor(status, code, message, requestId) {
|
|
17
19
|
super(message);
|
|
18
20
|
this.name = 'NovaAPIError';
|
|
@@ -31,7 +33,7 @@ class NovaAuthError extends NovaAPIError {
|
|
|
31
33
|
exports.NovaAuthError = NovaAuthError;
|
|
32
34
|
/**
|
|
33
35
|
* HTTP 403: the key is valid but not allowed to do this. `code` carries the
|
|
34
|
-
* server's reason, e.g. `admin_required` (admin-only
|
|
36
|
+
* server's reason, e.g. `admin_required` (admin-only endpoints) or
|
|
35
37
|
* `forbidden` (team actions that need the owner/admin role).
|
|
36
38
|
*/
|
|
37
39
|
class NovaPermissionError extends NovaAPIError {
|
|
@@ -70,6 +72,78 @@ class NovaInsufficientCreditsError extends NovaAPIError {
|
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
exports.NovaInsufficientCreditsError = NovaInsufficientCreditsError;
|
|
75
|
+
// The four v2.16 classes below keep their parent's `name`
|
|
76
|
+
// (NovaInsufficientCreditsError, NovaPermissionError, NovaRateLimitError), so
|
|
77
|
+
// 2.15 code that checks `err.name` keeps working. Use `instanceof`.
|
|
78
|
+
/**
|
|
79
|
+
* HTTP 402: out of credits. Nothing was run. Buy a credit pack at `topupUrl`
|
|
80
|
+
* (works at once) or upgrade at `upgradeUrl`. A request that had already
|
|
81
|
+
* started finishes. Extends `NovaInsufficientCreditsError`, so 2.15 code
|
|
82
|
+
* that checks for that still works.
|
|
83
|
+
*/
|
|
84
|
+
class CreditsExhausted extends NovaInsufficientCreditsError {
|
|
85
|
+
constructor(detail, requestId) {
|
|
86
|
+
super(detail, requestId);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.CreditsExhausted = CreditsExhausted;
|
|
90
|
+
/**
|
|
91
|
+
* HTTP 403 `api_requires_paid_plan`: API keys need a paid plan (from Pro).
|
|
92
|
+
* This key belongs to a Free plan. Upgrade at `upgradeUrl`.
|
|
93
|
+
*/
|
|
94
|
+
class PlanRequired extends NovaPermissionError {
|
|
95
|
+
plan;
|
|
96
|
+
upgradeUrl;
|
|
97
|
+
constructor(message, plan = '', upgradeUrl = '', requestId) {
|
|
98
|
+
super('api_requires_paid_plan', message, requestId);
|
|
99
|
+
this.plan = plan;
|
|
100
|
+
this.upgradeUrl = upgradeUrl;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.PlanRequired = PlanRequired;
|
|
104
|
+
/**
|
|
105
|
+
* HTTP 403 `feature_not_in_plan`: your plan does not include `feature`.
|
|
106
|
+
* `requiredPlan` is the first plan with it. Check `nova.planFeatures()`
|
|
107
|
+
* first to avoid it.
|
|
108
|
+
*/
|
|
109
|
+
class FeatureNotInPlan extends NovaPermissionError {
|
|
110
|
+
feature;
|
|
111
|
+
plan;
|
|
112
|
+
requiredPlan;
|
|
113
|
+
upgradeUrl;
|
|
114
|
+
constructor(detail, requestId) {
|
|
115
|
+
super('feature_not_in_plan', detail.message, requestId);
|
|
116
|
+
this.feature = detail.feature ?? '';
|
|
117
|
+
this.plan = detail.plan ?? '';
|
|
118
|
+
this.requiredPlan = detail.requiredPlan ?? '';
|
|
119
|
+
this.upgradeUrl = detail.upgradeUrl ?? '';
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.FeatureNotInPlan = FeatureNotInPlan;
|
|
123
|
+
/**
|
|
124
|
+
* HTTP 422 `invalid_json_output` (2.17): you asked for a JSON answer
|
|
125
|
+
* (`response_format`) and the answer did not match your schema after two
|
|
126
|
+
* tries. The message says where it failed. Nothing was charged.
|
|
127
|
+
*/
|
|
128
|
+
class InvalidJsonOutput extends NovaAPIError {
|
|
129
|
+
constructor(message = 'The answer did not match your JSON schema.', requestId) {
|
|
130
|
+
super(422, 'invalid_json_output', message, requestId);
|
|
131
|
+
this.name = 'InvalidJsonOutput';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.InvalidJsonOutput = InvalidJsonOutput;
|
|
135
|
+
/**
|
|
136
|
+
* HTTP 429: too many requests. Wait `retryAfter` seconds. The SDK already
|
|
137
|
+
* waited and retried (when the wait was short) before throwing this.
|
|
138
|
+
* `code` is `rate_limited` (per minute) or `plan_limit_reached`.
|
|
139
|
+
*/
|
|
140
|
+
class RateLimited extends NovaRateLimitError {
|
|
141
|
+
constructor(retryAfter, message = 'Rate limit exceeded', requestId, code = 'rate_limited') {
|
|
142
|
+
super(retryAfter, message, requestId);
|
|
143
|
+
this.code = code;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.RateLimited = RateLimited;
|
|
73
147
|
class NovaValidationError extends NovaError {
|
|
74
148
|
constructor(message) {
|
|
75
149
|
super(message);
|
package/dist/core/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAND,8BAMC;AAED,MAAa,YAAa,SAAQ,SAAS;IAChC,MAAM,CAAS;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAND,8BAMC;AAED,MAAa,YAAa,SAAQ,SAAS;IAChC,MAAM,CAAS;IACxB,IAAI,CAAS;IACJ,SAAS,CAAqB;IACvC,2EAA2E;IAC3E,IAAI,GAA4B,EAAE,CAAC;IAEnC,YAAY,MAAc,EAAE,IAAY,EAAE,OAAe,EAAE,SAAkB;QAC3E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAdD,oCAcC;AAED,MAAa,aAAc,SAAQ,YAAY;IAC7C,YAAY,UAAkB,uBAAuB,EAAE,SAAkB;QACvE,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,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2
|
+
export declare const SDK_VERSION = "2.17.0";
|
|
3
|
+
/** A 429 asking for a longer wait (seconds) is thrown at once instead of waited out. */
|
|
4
|
+
export declare const MAX_RETRY_AFTER = 30;
|
|
5
|
+
/**
|
|
6
|
+
* The error object of any Nova error body: flat `{code, message, ...}`,
|
|
7
|
+
* FastAPI's `{detail: {...}}` or the Messages `{type: 'error', error: {...}}`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function errorFields(body: unknown): Record<string, any>;
|
|
10
|
+
/** Seconds to wait after a 429: Retry-After, then `retry_after` in the body, then X-RateLimit-Reset; 1 otherwise. */
|
|
11
|
+
export declare function retryAfterSeconds(headers: {
|
|
12
|
+
get(name: string): string | null;
|
|
13
|
+
} | undefined, body?: Record<string, any>, now?: number): number;
|
|
14
|
+
/** Build the typed error for an error response (status + parsed body). */
|
|
15
|
+
export declare function errorFromBody(status: number, body: unknown, headers?: {
|
|
16
|
+
get(name: string): string | null;
|
|
17
|
+
}, requestId?: string, statusText?: string): NovaAPIError;
|
|
1
18
|
export type RequestInterceptor = (config: RequestConfig) => RequestConfig | Promise<RequestConfig>;
|
|
2
19
|
export type ResponseInterceptor = (response: HttpResponse<unknown>) => HttpResponse<unknown> | Promise<HttpResponse<unknown>>;
|
|
3
20
|
export interface HttpClientOptions {
|
|
@@ -5,6 +22,8 @@ export interface HttpClientOptions {
|
|
|
5
22
|
apiKey: string;
|
|
6
23
|
region: string;
|
|
7
24
|
timeout?: number;
|
|
25
|
+
/** Retries for 429 / 5xx / timeouts (default 3). */
|
|
26
|
+
maxRetries?: number;
|
|
8
27
|
}
|
|
9
28
|
export interface RequestConfig {
|
|
10
29
|
method: string;
|
|
@@ -23,6 +42,7 @@ export declare class HttpClient {
|
|
|
23
42
|
private readonly baseURL;
|
|
24
43
|
private readonly apiKey;
|
|
25
44
|
private readonly timeout;
|
|
45
|
+
private readonly maxRetries;
|
|
26
46
|
private readonly requestInterceptors;
|
|
27
47
|
private readonly responseInterceptors;
|
|
28
48
|
constructor(options: HttpClientOptions);
|