@qverisai/sdk 0.1.2 → 0.3.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +1 -1
  3. package/README.md +129 -216
  4. package/dist/client.d.ts +116 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +334 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/errors.d.ts +25 -0
  9. package/dist/errors.d.ts.map +1 -0
  10. package/dist/errors.js +34 -0
  11. package/dist/errors.js.map +1 -0
  12. package/dist/index.d.ts +14 -20
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +12 -260
  15. package/dist/index.js.map +1 -1
  16. package/dist/integrations/ai.d.ts +768 -0
  17. package/dist/integrations/ai.d.ts.map +1 -0
  18. package/dist/integrations/ai.js +87 -0
  19. package/dist/integrations/ai.js.map +1 -0
  20. package/dist/retry.d.ts +42 -0
  21. package/dist/retry.d.ts.map +1 -0
  22. package/dist/retry.js +63 -0
  23. package/dist/retry.js.map +1 -0
  24. package/dist/types.d.ts +266 -62
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/types.js +3 -2
  27. package/dist/types.js.map +1 -1
  28. package/package.json +72 -55
  29. package/dist/api/client.d.ts +0 -147
  30. package/dist/api/client.d.ts.map +0 -1
  31. package/dist/api/client.js +0 -201
  32. package/dist/api/client.js.map +0 -1
  33. package/dist/tools/execute.d.ts +0 -89
  34. package/dist/tools/execute.d.ts.map +0 -1
  35. package/dist/tools/execute.js +0 -73
  36. package/dist/tools/execute.js.map +0 -1
  37. package/dist/tools/get-by-ids.d.ts +0 -69
  38. package/dist/tools/get-by-ids.d.ts.map +0 -1
  39. package/dist/tools/get-by-ids.js +0 -55
  40. package/dist/tools/get-by-ids.js.map +0 -1
  41. package/dist/tools/search.d.ts +0 -71
  42. package/dist/tools/search.d.ts.map +0 -1
  43. package/dist/tools/search.js +0 -53
  44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1,87 @@
1
+ /**
2
+ * Vercel AI SDK adapter for QVeris.
3
+ *
4
+ * Exposes the QVeris discover / inspect / call workflow as Vercel AI SDK tools,
5
+ * so an agent built with the `ai` package can find and invoke thousands of
6
+ * external capabilities through one QVeris API key.
7
+ *
8
+ * `ai` and `zod` are peer dependencies — install them alongside `@qverisai/sdk`.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { generateText } from 'ai';
13
+ * import { openai } from '@ai-sdk/openai';
14
+ * import { Qveris } from '@qverisai/sdk';
15
+ * import { getQverisTools } from '@qverisai/sdk/ai';
16
+ *
17
+ * const qveris = new Qveris({ apiKey: process.env.QVERIS_API_KEY! });
18
+ * const { text } = await generateText({
19
+ * model: openai('gpt-4o'),
20
+ * tools: getQverisTools(qveris),
21
+ * maxSteps: 6,
22
+ * prompt: 'Find a stock quote capability and quote AAPL.',
23
+ * });
24
+ * ```
25
+ *
26
+ * @module @qverisai/sdk/ai
27
+ */
28
+ import { tool } from 'ai';
29
+ import { z } from 'zod';
30
+ /**
31
+ * Build Vercel AI SDK tools for the QVeris discover/inspect/call workflow.
32
+ *
33
+ * @param qveris - The Qveris client to route calls through.
34
+ * @param options - Optional `sessionId` for correlation/pricing context.
35
+ * @returns A tools object keyed by `qveris_discover` / `qveris_inspect` /
36
+ * `qveris_call`, ready to pass to `generateText`/`streamText`.
37
+ */
38
+ export function getQverisTools(qveris, options = {}) {
39
+ if (!qveris ||
40
+ typeof qveris.discover !== 'function' ||
41
+ typeof qveris.inspect !== 'function' ||
42
+ typeof qveris.call !== 'function') {
43
+ throw new TypeError('getQverisTools requires a valid Qveris client instance.');
44
+ }
45
+ const { sessionId } = options;
46
+ return {
47
+ qveris_discover: tool({
48
+ description: 'Discover QVeris capabilities from a natural-language query. Free; returns candidates and a search_id.',
49
+ inputSchema: z.object({
50
+ query: z.string().describe("Capability query, e.g. 'weather forecast API'."),
51
+ limit: z.number().int().min(1).max(100).optional().describe('Number of results (1-100).'),
52
+ }),
53
+ execute: async ({ query, limit }) => qveris.discover(query, { ...(limit !== undefined && { limit }), ...(sessionId && { sessionId }) }),
54
+ }),
55
+ qveris_inspect: tool({
56
+ description: 'Inspect one or more QVeris capabilities by tool_id before calling them. Free.',
57
+ inputSchema: z.object({
58
+ tool_ids: z.array(z.string()).describe('Tool IDs returned by discover.'),
59
+ search_id: z.string().optional().describe('The search_id from the discover response, if available.'),
60
+ }),
61
+ execute: async ({ tool_ids, search_id }) => qveris.inspect(tool_ids, { ...(search_id && { searchId: search_id }), ...(sessionId && { sessionId }) }),
62
+ }),
63
+ qveris_call: tool({
64
+ description: 'Call a selected QVeris capability with parameters. May consume credits.',
65
+ inputSchema: z.object({
66
+ tool_id: z.string().describe('The capability tool_id, from discover or inspect.'),
67
+ params_to_tool: z
68
+ .record(z.string(), z.unknown())
69
+ .optional()
70
+ .describe('Parameters to pass to the capability.'),
71
+ search_id: z.string().optional().describe('The search_id from the discover response, if available.'),
72
+ max_response_size: z
73
+ .number()
74
+ .int()
75
+ .optional()
76
+ .describe('Max response size in bytes; -1 means unlimited.'),
77
+ }),
78
+ execute: async ({ tool_id, search_id, params_to_tool = {}, max_response_size }) => qveris.call(tool_id, {
79
+ parameters: params_to_tool,
80
+ ...(search_id && { searchId: search_id }),
81
+ ...(max_response_size !== undefined && { maxResponseSize: max_response_size }),
82
+ ...(sessionId && { sessionId }),
83
+ }),
84
+ }),
85
+ };
86
+ }
87
+ //# sourceMappingURL=ai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/integrations/ai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,UAAkC,EAAE;IACjF,IACE,CAAC,MAAM;QACP,OAA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@@
1
+ /**
2
+ * Rate-limit aware retry helpers for the QVeris client.
3
+ *
4
+ * Pure functions the client uses to decide whether and how long to wait before
5
+ * retrying a rate-limited (`429`) or transient (`503`) response — honoring the
6
+ * `Retry-After` header when present, otherwise exponential backoff with full
7
+ * jitter. Kept separate from the client so the delay math is unit-testable.
8
+ *
9
+ * @module @qverisai/sdk/retry
10
+ */
11
+ export declare const DEFAULT_MAX_RETRIES = 3;
12
+ export declare const DEFAULT_BASE_DELAY_MS = 500;
13
+ export declare const DEFAULT_MAX_DELAY_MS = 60000;
14
+ /** HTTP statuses worth retrying: rate limiting + transient unavailability. */
15
+ export declare const RETRYABLE_STATUS: Set<number>;
16
+ /**
17
+ * Parse a `Retry-After` header into milliseconds.
18
+ *
19
+ * Accepts both RFC 9110 forms — a delta in seconds (`"12"`) or an HTTP-date.
20
+ * Returns `null` when absent/unparseable, and never a negative value.
21
+ */
22
+ export declare function parseRetryAfterMs(value: string | null | undefined, now?: number): number | null;
23
+ export interface RetryDelayOptions {
24
+ /** Parsed `Retry-After` in ms, or null to use backoff. */
25
+ retryAfterMs: number | null;
26
+ /** Zero-based attempt index (0 = first retry). */
27
+ attempt: number;
28
+ baseDelayMs: number;
29
+ maxDelayMs: number;
30
+ /** Jitter source in [0, 1); defaults to `Math.random`. */
31
+ random?: () => number;
32
+ }
33
+ /**
34
+ * Compute how long to wait before the next attempt, in milliseconds.
35
+ *
36
+ * Honors `retryAfterMs` (capped at `maxDelayMs`); otherwise exponential backoff
37
+ * `baseDelayMs * 2**attempt` with full jitter, capped at `maxDelayMs`.
38
+ */
39
+ export declare function computeRetryDelayMs(options: RetryDelayOptions): number;
40
+ /** Resolve a caller-supplied `maxRetries` to a safe non-negative integer. */
41
+ export declare function resolveMaxRetries(maxRetries: number | undefined): number;
42
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAG3C,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,aAAsB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM,GAAG,IAAI,CAgB3G;AAED,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAQtE;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGxE"}
package/dist/retry.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Rate-limit aware retry helpers for the QVeris client.
3
+ *
4
+ * Pure functions the client uses to decide whether and how long to wait before
5
+ * retrying a rate-limited (`429`) or transient (`503`) response — honoring the
6
+ * `Retry-After` header when present, otherwise exponential backoff with full
7
+ * jitter. Kept separate from the client so the delay math is unit-testable.
8
+ *
9
+ * @module @qverisai/sdk/retry
10
+ */
11
+ export const DEFAULT_MAX_RETRIES = 3;
12
+ export const DEFAULT_BASE_DELAY_MS = 500;
13
+ export const DEFAULT_MAX_DELAY_MS = 60_000;
14
+ const MAX_BACKOFF_EXPONENT = 30; // guards 2**attempt against overflow
15
+ /** HTTP statuses worth retrying: rate limiting + transient unavailability. */
16
+ export const RETRYABLE_STATUS = new Set([429, 503]);
17
+ /**
18
+ * Parse a `Retry-After` header into milliseconds.
19
+ *
20
+ * Accepts both RFC 9110 forms — a delta in seconds (`"12"`) or an HTTP-date.
21
+ * Returns `null` when absent/unparseable, and never a negative value.
22
+ */
23
+ export function parseRetryAfterMs(value, now = Date.now()) {
24
+ if (value == null)
25
+ return null;
26
+ const trimmed = value.trim();
27
+ if (trimmed === '')
28
+ return null;
29
+ // Delta-seconds form: a non-negative integer.
30
+ if (/^\d+$/.test(trimmed)) {
31
+ return Number(trimmed) * 1000;
32
+ }
33
+ // HTTP-date form. Require a letter (month name / "GMT") so Date.parse's
34
+ // leniency doesn't turn junk like "-5" into a spurious date.
35
+ if (!/[a-zA-Z]/.test(trimmed))
36
+ return null;
37
+ const dateMs = Date.parse(trimmed);
38
+ if (Number.isNaN(dateMs))
39
+ return null;
40
+ return Math.max(0, dateMs - now);
41
+ }
42
+ /**
43
+ * Compute how long to wait before the next attempt, in milliseconds.
44
+ *
45
+ * Honors `retryAfterMs` (capped at `maxDelayMs`); otherwise exponential backoff
46
+ * `baseDelayMs * 2**attempt` with full jitter, capped at `maxDelayMs`.
47
+ */
48
+ export function computeRetryDelayMs(options) {
49
+ const { retryAfterMs, attempt, baseDelayMs, maxDelayMs } = options;
50
+ if (retryAfterMs != null) {
51
+ return Math.min(retryAfterMs, maxDelayMs);
52
+ }
53
+ const random = options.random ?? Math.random;
54
+ const capped = Math.min(baseDelayMs * 2 ** Math.min(attempt, MAX_BACKOFF_EXPONENT), maxDelayMs);
55
+ return capped * (0.5 + 0.5 * random());
56
+ }
57
+ /** Resolve a caller-supplied `maxRetries` to a safe non-negative integer. */
58
+ export function resolveMaxRetries(maxRetries) {
59
+ if (maxRetries == null || !Number.isFinite(maxRetries))
60
+ return DEFAULT_MAX_RETRIES;
61
+ return Math.max(0, Math.floor(maxRetries));
62
+ }
63
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":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AAE,GAAG,OAAO,CAAC;IACnE,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,oBAAoB,CAAC,EAAE,UAAU,CAAC,CAAC;IAChG,OAAO,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,MAAM,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,iBAAiB,CAAC,UAA8B;IAC9D,IAAI,UAAU,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,mBAAmB,CAAC;IACnF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7C,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,30 +1,18 @@
1
1
  /**
2
2
  * Qveris API Type Definitions
3
3
  *
4
- * This module contains TypeScript types that match the Qveris API v0.1.6 schema.
5
- * All types are fully documented for IDE autocompletion and developer experience.
4
+ * This module contains TypeScript types that match the Qveris API schema.
5
+ * Aligned with backend ToolInfo, SearchResponse, ToolCallResponse, and
6
+ * the REST API documentation at docs/en-US/rest-api.md.
6
7
  *
7
8
  * @module types
8
9
  * @see {@link https://qveris.ai/api/v1} Qveris API Base URL
9
10
  */
10
11
  /**
11
12
  * Request body for the Search Tools API.
12
- *
13
- * @example
14
- * ```typescript
15
- * const request: SearchRequest = {
16
- * query: "weather forecast API",
17
- * limit: 10,
18
- * session_id: "abcd1234-ab12-ab12-ab12-abcdef123456"
19
- * };
20
- * ```
21
13
  */
22
14
  export interface SearchRequest {
23
- /**
24
- * Natural language search query describing the tool capability you need.
25
- * @example "weather forecast API"
26
- * @example "send email notification"
27
- */
15
+ /** Natural language search query describing the tool capability you need. */
28
16
  query: string;
29
17
  /**
30
18
  * Maximum number of results to return.
@@ -33,15 +21,11 @@ export interface SearchRequest {
33
21
  * @maximum 100
34
22
  */
35
23
  limit?: number;
36
- /**
37
- * Session identifier for tracking user sessions.
38
- * Same ID corresponds to the same user session.
39
- */
24
+ /** Session identifier for tracking user sessions. */
40
25
  session_id?: string;
41
26
  }
42
27
  /**
43
28
  * Parameter definition for a tool.
44
- * Describes a single input parameter that a tool accepts.
45
29
  */
46
30
  export interface ToolParameter {
47
31
  /** Parameter name (used as key in the parameters object) */
@@ -62,41 +46,146 @@ export interface ToolExamples {
62
46
  /** Sample parameter values demonstrating typical usage */
63
47
  sample_parameters?: Record<string, unknown>;
64
48
  }
49
+ /**
50
+ * Historical execution performance statistics for a tool.
51
+ */
52
+ export interface ToolStats {
53
+ /** Historical average execution time in milliseconds */
54
+ avg_execution_time_ms?: number;
55
+ /** Historical success rate (0.0 - 1.0) */
56
+ success_rate?: number;
57
+ /** Legacy fallback estimate in credits per call */
58
+ cost?: number;
59
+ }
60
+ export interface BillingPrice {
61
+ amount_credits: number;
62
+ per?: number | null;
63
+ unit?: string | null;
64
+ unit_label?: string | null;
65
+ }
66
+ export interface BillingChargeLine {
67
+ component_key: string;
68
+ quantity?: number | null;
69
+ unit?: string | null;
70
+ unit_label?: string | null;
71
+ price?: BillingPrice | null;
72
+ amount_credits?: number | null;
73
+ description?: string | null;
74
+ is_adjustment?: boolean | null;
75
+ }
76
+ export interface BillingRule {
77
+ metering_mode?: string;
78
+ billing_unit?: string;
79
+ billing_unit_label?: string;
80
+ price?: BillingPrice | null;
81
+ price_breakdown?: Record<string, unknown>[] | null;
82
+ pricing_dimensions?: Record<string, unknown>[] | null;
83
+ minimum_charge_credits?: number | null;
84
+ snapshot_id?: number | null;
85
+ snapshot_version?: string | null;
86
+ runtime_pricing_version?: string | null;
87
+ pricing_source_system?: string | null;
88
+ description?: string;
89
+ }
90
+ export interface CompactBillingStatement {
91
+ price?: BillingPrice | null;
92
+ quantity?: number | null;
93
+ charge_lines?: BillingChargeLine[] | null;
94
+ minimum_charge_credits?: number | null;
95
+ list_amount_credits?: number | null;
96
+ requested_amount_credits?: number | null;
97
+ summary?: string | null;
98
+ }
99
+ /**
100
+ * Category/tag attached to a tool.
101
+ * Current API responses return category objects; legacy responses returned
102
+ * plain strings, so `ToolInfo.categories` accepts both.
103
+ */
104
+ export interface ToolCategory {
105
+ slug?: string;
106
+ name?: string;
107
+ description?: string;
108
+ }
109
+ /**
110
+ * Coverage tag attached to a capability (e.g. market coverage).
111
+ */
112
+ export interface ToolCapabilityTag {
113
+ id?: string;
114
+ name?: string;
115
+ type?: string;
116
+ description?: string;
117
+ }
118
+ /**
119
+ * Standardized capability descriptor attached to a tool
120
+ * (e.g. "MKT.BARS.ADJUSTED" with market coverage tags).
121
+ */
122
+ export interface ToolCapability {
123
+ id?: string;
124
+ tag?: ToolCapabilityTag[];
125
+ }
65
126
  /**
66
127
  * Information about a tool returned from search results.
67
128
  * Contains everything needed to understand and execute the tool.
68
129
  */
69
130
  export interface ToolInfo {
70
- /** Unique identifier for the tool (used in execute_tool) */
131
+ /** Unique identifier for the tool (used in call) */
71
132
  tool_id: string;
72
133
  /** Human-readable display name */
73
134
  name: string;
74
135
  /** Detailed description of what the tool does */
75
136
  description: string;
137
+ /** Tool categories/tags: category objects, or plain strings in legacy responses */
138
+ categories?: Array<string | ToolCategory>;
139
+ /** Standardized capability descriptors with coverage tags */
140
+ capabilities?: ToolCapability[];
141
+ /** Provider identifier */
142
+ provider_id?: string;
76
143
  /** Name of the organization/service providing this tool */
77
144
  provider_name?: string;
78
145
  /** Description of the provider */
79
146
  provider_description?: string;
147
+ /** Provider website URL */
148
+ provider_website_url?: string;
80
149
  /**
81
150
  * Geographic availability of the tool.
82
151
  * - "global" - Available worldwide
83
152
  * - "US|CA" - Whitelist: only available in US and Canada
84
- * - "!CN|RU" - Blacklist: not available in China and Russia
153
+ * - "-CN|RU" - Blacklist: not available in China and Russia
85
154
  */
86
155
  region?: string;
87
- /** Average response latency in milliseconds */
88
- avg_latency_ms?: number;
89
156
  /** List of parameters the tool accepts */
90
157
  params?: ToolParameter[];
91
158
  /** Usage examples with sample parameters */
92
159
  examples?: ToolExamples;
160
+ /** Historical execution performance statistics */
161
+ stats?: ToolStats;
162
+ /** Structured rule-level billing metadata when available */
163
+ billing_rule?: BillingRule;
164
+ /** Pre-call cost estimate in credits, when available */
165
+ expected_cost?: string | number;
166
+ /** Relevance score for the search query (0.0 - 1.0, higher = better match) */
167
+ final_score?: number;
168
+ /** Human-readable explanation of why this tool was recommended (Discover results only) */
169
+ why_recommended?: string;
170
+ /** Whether this tool has been executed before (verified in production) */
171
+ has_last_execution?: boolean;
172
+ /** Most recent execution record, if available */
173
+ last_execution_record?: Record<string, unknown>;
174
+ /** Documentation URL for the tool */
175
+ docs_url?: string;
176
+ /** Protocol type */
177
+ protocol?: string;
93
178
  }
94
179
  /**
95
180
  * Performance statistics for a search operation.
96
181
  */
97
182
  export interface SearchStats {
98
183
  /** Total time to complete the search in milliseconds */
99
- search_time_ms: number;
184
+ search_time_ms?: number;
185
+ /** Vector recall count */
186
+ vector_recall_count?: number;
187
+ /** Fulltext recall count */
188
+ fulltext_recall_count?: number;
100
189
  }
101
190
  /**
102
191
  * Response from the Search Tools API.
@@ -106,7 +195,7 @@ export interface SearchResponse {
106
195
  query?: string;
107
196
  /**
108
197
  * Unique identifier for this search.
109
- * Required when calling execute_tool for any tool from these results.
198
+ * Required when calling call for any tool from these results.
110
199
  */
111
200
  search_id: string;
112
201
  /** Total number of results returned */
@@ -115,58 +204,32 @@ export interface SearchResponse {
115
204
  results: ToolInfo[];
116
205
  /** Search performance statistics */
117
206
  stats?: SearchStats;
207
+ /** User's remaining credits after this operation */
208
+ remaining_credits?: number;
209
+ /** Total elapsed time in milliseconds */
210
+ elapsed_time_ms?: number;
118
211
  }
119
212
  /**
120
213
  * Request body for the Get Tools by IDs API.
121
- *
122
- * @example
123
- * ```typescript
124
- * const request: GetToolsByIdsRequest = {
125
- * tool_ids: ["tool-1", "tool-2"],
126
- * search_id: "search-123",
127
- * session_id: "abcd1234-ab12-ab12-ab12-abcdef123456"
128
- * };
129
- * ```
130
214
  */
131
215
  export interface GetToolsByIdsRequest {
132
- /**
133
- * Array of tool IDs to retrieve information for.
134
- */
216
+ /** Array of tool IDs to retrieve information for. */
135
217
  tool_ids: string[];
136
- /**
137
- * The search_id from the search that returned the tool(s).
138
- * Optional but recommended for analytics and billing.
139
- */
218
+ /** The search_id from the search that returned the tool(s). */
140
219
  search_id?: string;
141
- /**
142
- * Session identifier for tracking user sessions.
143
- * Same ID corresponds to the same user session.
144
- */
220
+ /** Session identifier for tracking user sessions. */
145
221
  session_id?: string;
146
222
  }
147
223
  /**
148
224
  * Request body for the Execute Tool API.
149
- *
150
- * @example
151
- * ```typescript
152
- * const request: ExecuteRequest = {
153
- * search_id: "abcd1234-ab12-ab12-ab12-abcdef123456",
154
- * session_id: "abcd1234-ab12-ab12-ab12-abcdef123456",
155
- * parameters: { city: "London", units: "metric" },
156
- * max_response_size: 20480
157
- * };
158
- * ```
159
225
  */
160
226
  export interface ExecuteRequest {
161
227
  /**
162
228
  * The search_id from the search that returned this tool.
163
- * Links the execution to the original search for analytics.
229
+ * Links the execution to the original search for analytics and billing.
164
230
  */
165
231
  search_id: string;
166
- /**
167
- * Session identifier for tracking user sessions.
168
- * Same ID corresponds to the same user session.
169
- */
232
+ /** Session identifier for tracking user sessions. */
170
233
  session_id?: string;
171
234
  /**
172
235
  * Key-value pairs of parameters to pass to the tool.
@@ -206,6 +269,11 @@ export interface ExecuteResultTruncated {
206
269
  * Useful for previewing the data structure.
207
270
  */
208
271
  truncated_content: string;
272
+ /**
273
+ * JSON Schema describing the structure of the full content.
274
+ * Helps the agent understand the data shape without downloading.
275
+ */
276
+ content_schema?: Record<string, unknown>;
209
277
  }
210
278
  /**
211
279
  * Union type for execution results (either full data or truncated).
@@ -235,9 +303,119 @@ export interface ExecuteResponse {
235
303
  error_message?: string | null;
236
304
  /** Execution duration in seconds */
237
305
  execution_time?: number;
306
+ /** Execution duration in milliseconds (alternative field) */
307
+ elapsed_time_ms?: number;
308
+ /** Legacy fallback estimate; use usage audit or credits ledger for final charge */
309
+ cost?: number;
310
+ /** Structured pre-settlement billing statement when available */
311
+ billing?: CompactBillingStatement;
312
+ /** Legacy/full pre-settlement bill snapshot when returned directly */
313
+ pre_settlement_bill?: Record<string, unknown>;
314
+ /** User's remaining credits after this execution */
315
+ remaining_credits?: number;
238
316
  /** Timestamp of execution (ISO 8601 format) */
317
+ created_at?: string;
318
+ }
319
+ export interface ApiEnvelope<T> {
320
+ status: string;
321
+ message?: string;
322
+ status_code?: number;
323
+ data: T;
324
+ }
325
+ export interface CreditsResponse {
326
+ remaining_credits: number;
327
+ daily_free?: Record<string, unknown>;
328
+ invite_reward?: Record<string, unknown>;
329
+ welcome_bonus?: Record<string, unknown>;
330
+ purchased?: Record<string, unknown>;
331
+ }
332
+ export interface UsageHistoryRequest {
333
+ start_date?: string;
334
+ end_date?: string;
335
+ summary?: boolean;
336
+ bucket?: string;
337
+ event_type?: string;
338
+ kind?: string;
339
+ success?: boolean;
340
+ charge_outcome?: string;
341
+ search_id?: string;
342
+ execution_id?: string;
343
+ min_credits?: number;
344
+ max_credits?: number;
345
+ limit?: number;
346
+ page?: number;
347
+ page_size?: number;
348
+ }
349
+ export interface UsageEventItem {
350
+ id: string;
351
+ event_type: string;
352
+ kind?: string | null;
353
+ source_system: string;
354
+ source_ref_type?: string | null;
355
+ source_ref_id?: string | null;
356
+ session_id?: string | null;
357
+ search_id?: string | null;
358
+ execution_id?: string | null;
359
+ tool_id?: string | null;
360
+ model?: string | null;
361
+ query?: string | null;
362
+ success: boolean;
363
+ charge_outcome?: string | null;
364
+ error_message?: string | null;
365
+ billing_snapshot_status?: string | null;
366
+ pre_settlement_bill?: Record<string, unknown> | null;
367
+ settlement_result?: Record<string, unknown> | null;
368
+ requested_amount_credits?: number | null;
369
+ actual_amount_credits?: number | null;
370
+ credits_ledger_entry_id?: string | null;
371
+ display_target?: string | null;
372
+ billing_summary?: string | null;
373
+ pre_settlement_amount_credits?: number | null;
374
+ settled_amount_credits?: number | null;
375
+ created_at: string;
376
+ }
377
+ export interface UsageEventsResponse {
378
+ items: UsageEventItem[];
379
+ total: number;
380
+ page: number;
381
+ page_size: number;
382
+ summary?: Record<string, unknown> | null;
383
+ }
384
+ export interface CreditsLedgerRequest {
385
+ start_date?: string;
386
+ end_date?: string;
387
+ summary?: boolean;
388
+ bucket?: string;
389
+ entry_type?: string;
390
+ direction?: string;
391
+ min_credits?: number;
392
+ max_credits?: number;
393
+ limit?: number;
394
+ page?: number;
395
+ page_size?: number;
396
+ }
397
+ export interface CreditsLedgerItem {
398
+ id: string;
399
+ entry_type: string;
400
+ amount_credits: number;
401
+ source_system: string;
402
+ source_ref_type?: string | null;
403
+ source_ref_id?: string | null;
404
+ pre_settlement_bill?: Record<string, unknown> | null;
405
+ settlement_result?: Record<string, unknown> | null;
406
+ balance_before?: Record<string, unknown> | null;
407
+ balance_after?: Record<string, unknown> | null;
408
+ ledger_metadata?: Record<string, unknown> | null;
409
+ description?: string | null;
239
410
  created_at: string;
240
411
  }
412
+ export interface CreditsLedgerResponse {
413
+ items: CreditsLedgerItem[];
414
+ total: number;
415
+ page: number;
416
+ page_size: number;
417
+ summary?: Record<string, unknown> | null;
418
+ }
241
419
  /**
242
420
  * Configuration options for the Qveris API client.
243
421
  */
@@ -246,10 +424,32 @@ export interface QverisClientConfig {
246
424
  apiKey: string;
247
425
  /** Base URL for the API (defaults to production) */
248
426
  baseUrl?: string;
427
+ /** Default request timeout in milliseconds */
428
+ timeoutMs?: number;
429
+ /**
430
+ * Max automatic retries for rate-limited (429) / transient (503) responses.
431
+ * Honors `Retry-After`, otherwise backs off exponentially with jitter.
432
+ * Defaults to 3; set to 0 to disable.
433
+ */
434
+ maxRetries?: number;
249
435
  }
250
436
  /**
251
437
  * Error response from the Qveris API.
252
438
  */
439
+ export type ApiOperation = 'discover' | 'inspect' | 'call' | 'credits' | 'usage_history' | 'credits_ledger';
440
+ export type ApiErrorType = 'http_error' | 'invalid_json' | 'timeout' | 'network_error';
441
+ export interface ApiObservability {
442
+ source: 'qveris_api';
443
+ operation: ApiOperation;
444
+ method: 'GET' | 'POST';
445
+ endpoint: string;
446
+ url: string;
447
+ query_params?: Record<string, string>;
448
+ timeout_ms: number;
449
+ http_status?: number;
450
+ request_id?: string;
451
+ error_type?: ApiErrorType;
452
+ }
253
453
  export interface ApiError {
254
454
  /** HTTP status code */
255
455
  status: number;
@@ -257,5 +457,9 @@ export interface ApiError {
257
457
  message: string;
258
458
  /** Original error details if available */
259
459
  details?: unknown;
460
+ /** Request metadata for diagnosing API/provider/tool-chain failures. */
461
+ observability?: ApiObservability;
462
+ /** Lower-level transport or runtime cause when available. */
463
+ cause?: string;
260
464
  }
261
465
  //# sourceMappingURL=types.d.ts.map