kloakd-sdk 0.1.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/dist/index.d.mts +526 -0
- package/dist/index.d.ts +526 -0
- package/dist/index.js +876 -0
- package/dist/index.mjs +843 -0
- package/package.json +53 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KLOAKD SDK — Shared HTTP transport layer (TypeScript).
|
|
3
|
+
*
|
|
4
|
+
* Uses the native `fetch` API (Node 18+, all modern browsers).
|
|
5
|
+
* Retry policy:
|
|
6
|
+
* - Retryable: 429, 500, 502, 503, 504
|
|
7
|
+
* - Non-retryable: 400, 401, 403, 404
|
|
8
|
+
* - Strategy: exponential backoff (1s * 2^attempt), cap 60s
|
|
9
|
+
* - 429 respects Retry-After header
|
|
10
|
+
* - Max attempts: configurable, default 3
|
|
11
|
+
*/
|
|
12
|
+
interface TransportOptions {
|
|
13
|
+
apiKey: string;
|
|
14
|
+
organizationId: string;
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
timeout: number;
|
|
17
|
+
maxRetries: number;
|
|
18
|
+
/** Injected fetch implementation — used in tests to mock responses. */
|
|
19
|
+
fetchImpl?: typeof fetch;
|
|
20
|
+
}
|
|
21
|
+
declare class HttpTransport {
|
|
22
|
+
readonly _apiKey: string;
|
|
23
|
+
readonly _organizationId: string;
|
|
24
|
+
readonly _baseUrl: string;
|
|
25
|
+
readonly _timeout: number;
|
|
26
|
+
readonly _maxRetries: number;
|
|
27
|
+
private readonly _fetch;
|
|
28
|
+
constructor(opts: TransportOptions);
|
|
29
|
+
authHeaders(): Record<string, string>;
|
|
30
|
+
orgPrefix(): string;
|
|
31
|
+
url(path: string): string;
|
|
32
|
+
request<T = Record<string, unknown>>(method: string, path: string, body?: Record<string, unknown>, params?: Record<string, string>): Promise<T>;
|
|
33
|
+
get<T = Record<string, unknown>>(path: string, params?: Record<string, string>): Promise<T>;
|
|
34
|
+
post<T = Record<string, unknown>>(path: string, body: Record<string, unknown>): Promise<T>;
|
|
35
|
+
delete(path: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Open an SSE stream and return an AsyncIterable over raw `data:` payloads.
|
|
38
|
+
* Caller is responsible for parsing each chunk.
|
|
39
|
+
*/
|
|
40
|
+
stream(path: string, body: Record<string, unknown>): AsyncIterable<Record<string, unknown>>;
|
|
41
|
+
/**
|
|
42
|
+
* SSE stream that also surfaces `event:` field alongside `data:`.
|
|
43
|
+
* Used by Parlyr.chatStream().
|
|
44
|
+
*/
|
|
45
|
+
streamWithEvents(path: string, body: Record<string, unknown>): AsyncIterable<{
|
|
46
|
+
event: string;
|
|
47
|
+
data: Record<string, unknown>;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* KLOAKD SDK — TypeScript interfaces for all result models.
|
|
53
|
+
*
|
|
54
|
+
* All field names use camelCase per §4 of the API design doc.
|
|
55
|
+
* Nullable fields use `T | null` (not undefined) for JSON compatibility.
|
|
56
|
+
*/
|
|
57
|
+
/** Pagination envelope included in all list-returning responses. */
|
|
58
|
+
interface Paginated {
|
|
59
|
+
hasMore: boolean;
|
|
60
|
+
total: number;
|
|
61
|
+
}
|
|
62
|
+
interface FetchResult {
|
|
63
|
+
success: boolean;
|
|
64
|
+
url: string;
|
|
65
|
+
statusCode: number;
|
|
66
|
+
tierUsed: number;
|
|
67
|
+
html: string | null;
|
|
68
|
+
vendorDetected: string | null;
|
|
69
|
+
antiBotBypassed: boolean;
|
|
70
|
+
artifactId: string | null;
|
|
71
|
+
error: string | null;
|
|
72
|
+
/** True if success is true and error is null. */
|
|
73
|
+
readonly ok: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface FetchEvent {
|
|
76
|
+
type: string;
|
|
77
|
+
tier: number | null;
|
|
78
|
+
vendor: string | null;
|
|
79
|
+
metadata: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
interface AnalyzeResult {
|
|
82
|
+
blocked: boolean;
|
|
83
|
+
vendor: string | null;
|
|
84
|
+
confidence: number;
|
|
85
|
+
recommendedActions: string[];
|
|
86
|
+
}
|
|
87
|
+
interface PageNode {
|
|
88
|
+
url: string;
|
|
89
|
+
depth: number;
|
|
90
|
+
title: string | null;
|
|
91
|
+
statusCode: number | null;
|
|
92
|
+
children: string[];
|
|
93
|
+
}
|
|
94
|
+
interface CrawlResult extends Paginated {
|
|
95
|
+
success: boolean;
|
|
96
|
+
crawlId: string;
|
|
97
|
+
url: string;
|
|
98
|
+
totalPages: number;
|
|
99
|
+
maxDepthReached: number;
|
|
100
|
+
pages: PageNode[];
|
|
101
|
+
artifactId: string | null;
|
|
102
|
+
error: string | null;
|
|
103
|
+
readonly ok: boolean;
|
|
104
|
+
}
|
|
105
|
+
interface CrawlEvent {
|
|
106
|
+
type: string;
|
|
107
|
+
url: string | null;
|
|
108
|
+
depth: number | null;
|
|
109
|
+
pagesFound: number | null;
|
|
110
|
+
metadata: Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
interface ApiEndpoint {
|
|
113
|
+
url: string;
|
|
114
|
+
method: string;
|
|
115
|
+
apiType: string;
|
|
116
|
+
confidence: number;
|
|
117
|
+
parameters: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
interface DiscoverResult extends Paginated {
|
|
120
|
+
success: boolean;
|
|
121
|
+
discoveryId: string;
|
|
122
|
+
url: string;
|
|
123
|
+
totalEndpoints: number;
|
|
124
|
+
endpoints: ApiEndpoint[];
|
|
125
|
+
artifactId: string | null;
|
|
126
|
+
error: string | null;
|
|
127
|
+
readonly ok: boolean;
|
|
128
|
+
}
|
|
129
|
+
interface DiscoverEvent {
|
|
130
|
+
type: string;
|
|
131
|
+
endpointUrl: string | null;
|
|
132
|
+
apiType: string | null;
|
|
133
|
+
metadata: Record<string, unknown>;
|
|
134
|
+
}
|
|
135
|
+
interface NexusAnalyzeResult {
|
|
136
|
+
perceptionId: string;
|
|
137
|
+
strategy: Record<string, unknown>;
|
|
138
|
+
pageType: string;
|
|
139
|
+
complexityLevel: string;
|
|
140
|
+
artifactId: string | null;
|
|
141
|
+
durationMs: number;
|
|
142
|
+
error: string | null;
|
|
143
|
+
readonly ok: boolean;
|
|
144
|
+
}
|
|
145
|
+
interface NexusSynthesisResult {
|
|
146
|
+
strategyId: string;
|
|
147
|
+
strategyName: string;
|
|
148
|
+
generatedCode: string;
|
|
149
|
+
artifactId: string | null;
|
|
150
|
+
synthesisTimeMs: number;
|
|
151
|
+
error: string | null;
|
|
152
|
+
readonly ok: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface NexusVerifyResult {
|
|
155
|
+
verificationResultId: string;
|
|
156
|
+
isSafe: boolean;
|
|
157
|
+
riskScore: number;
|
|
158
|
+
safetyScore: number;
|
|
159
|
+
violations: string[];
|
|
160
|
+
durationMs: number;
|
|
161
|
+
error: string | null;
|
|
162
|
+
readonly ok: boolean;
|
|
163
|
+
}
|
|
164
|
+
interface NexusExecuteResult {
|
|
165
|
+
executionResultId: string;
|
|
166
|
+
success: boolean;
|
|
167
|
+
records: Record<string, unknown>[];
|
|
168
|
+
artifactId: string | null;
|
|
169
|
+
durationMs: number;
|
|
170
|
+
error: string | null;
|
|
171
|
+
readonly ok: boolean;
|
|
172
|
+
}
|
|
173
|
+
interface NexusKnowledgeResult extends Paginated {
|
|
174
|
+
learnedConcepts: Record<string, unknown>[];
|
|
175
|
+
learnedPatterns: Record<string, unknown>[];
|
|
176
|
+
durationMs: number;
|
|
177
|
+
error: string | null;
|
|
178
|
+
readonly ok: boolean;
|
|
179
|
+
}
|
|
180
|
+
interface ParseResult {
|
|
181
|
+
intent: string;
|
|
182
|
+
confidence: number;
|
|
183
|
+
tier: number;
|
|
184
|
+
source: string;
|
|
185
|
+
entities: Record<string, unknown>;
|
|
186
|
+
requiresAction: boolean;
|
|
187
|
+
clarificationNeeded: string | null;
|
|
188
|
+
reasoning: string | null;
|
|
189
|
+
detectedUrl: string | null;
|
|
190
|
+
readonly ok: boolean;
|
|
191
|
+
}
|
|
192
|
+
interface ChatTurn {
|
|
193
|
+
sessionId: string;
|
|
194
|
+
intent: string;
|
|
195
|
+
confidence: number;
|
|
196
|
+
tier: number;
|
|
197
|
+
response: string;
|
|
198
|
+
entities: Record<string, unknown>;
|
|
199
|
+
requiresAction: boolean;
|
|
200
|
+
clarificationNeeded: string | null;
|
|
201
|
+
}
|
|
202
|
+
interface ChatEvent {
|
|
203
|
+
event: string;
|
|
204
|
+
data: Record<string, unknown>;
|
|
205
|
+
}
|
|
206
|
+
interface SessionResult {
|
|
207
|
+
success: boolean;
|
|
208
|
+
sessionId: string;
|
|
209
|
+
url: string;
|
|
210
|
+
artifactId: string | null;
|
|
211
|
+
screenshotUrl: string | null;
|
|
212
|
+
error: string | null;
|
|
213
|
+
readonly ok: boolean;
|
|
214
|
+
}
|
|
215
|
+
interface FetchyrResult {
|
|
216
|
+
success: boolean;
|
|
217
|
+
url: string;
|
|
218
|
+
statusCode: number;
|
|
219
|
+
html: string | null;
|
|
220
|
+
artifactId: string | null;
|
|
221
|
+
sessionArtifactId: string;
|
|
222
|
+
error: string | null;
|
|
223
|
+
readonly ok: boolean;
|
|
224
|
+
}
|
|
225
|
+
interface WorkflowResult {
|
|
226
|
+
workflowId: string;
|
|
227
|
+
name: string;
|
|
228
|
+
steps: Record<string, unknown>[];
|
|
229
|
+
url: string | null;
|
|
230
|
+
createdAt: string;
|
|
231
|
+
error: string | null;
|
|
232
|
+
readonly ok: boolean;
|
|
233
|
+
}
|
|
234
|
+
interface WorkflowExecutionResult {
|
|
235
|
+
executionId: string;
|
|
236
|
+
workflowId: string;
|
|
237
|
+
status: string;
|
|
238
|
+
startedAt: string | null;
|
|
239
|
+
completedAt: string | null;
|
|
240
|
+
records: Record<string, unknown>[];
|
|
241
|
+
error: string | null;
|
|
242
|
+
readonly ok: boolean;
|
|
243
|
+
}
|
|
244
|
+
interface FormDetectionResult {
|
|
245
|
+
forms: Record<string, unknown>[];
|
|
246
|
+
totalForms: number;
|
|
247
|
+
error: string | null;
|
|
248
|
+
}
|
|
249
|
+
interface MfaDetectionResult {
|
|
250
|
+
mfaDetected: boolean;
|
|
251
|
+
challengeId: string | null;
|
|
252
|
+
mfaType: string | null;
|
|
253
|
+
error: string | null;
|
|
254
|
+
}
|
|
255
|
+
interface MfaResult {
|
|
256
|
+
success: boolean;
|
|
257
|
+
sessionArtifactId: string | null;
|
|
258
|
+
error: string | null;
|
|
259
|
+
}
|
|
260
|
+
interface DeduplicationResult {
|
|
261
|
+
uniqueRecords: Record<string, unknown>[];
|
|
262
|
+
duplicateCount: number;
|
|
263
|
+
totalInput: number;
|
|
264
|
+
error: string | null;
|
|
265
|
+
readonly ok: boolean;
|
|
266
|
+
}
|
|
267
|
+
interface ExtractionResult extends Paginated {
|
|
268
|
+
success: boolean;
|
|
269
|
+
url: string;
|
|
270
|
+
method: string;
|
|
271
|
+
records: Record<string, unknown>[];
|
|
272
|
+
totalRecords: number;
|
|
273
|
+
pagesScraped: number;
|
|
274
|
+
artifactId: string | null;
|
|
275
|
+
jobId: string | null;
|
|
276
|
+
error: string | null;
|
|
277
|
+
readonly ok: boolean;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
interface FetchOptions {
|
|
281
|
+
forceBrowser?: boolean;
|
|
282
|
+
useProxy?: boolean;
|
|
283
|
+
sessionArtifactId?: string;
|
|
284
|
+
}
|
|
285
|
+
interface FetchAsyncOptions extends FetchOptions {
|
|
286
|
+
webhookUrl?: string;
|
|
287
|
+
}
|
|
288
|
+
declare class EvadrNamespace {
|
|
289
|
+
private readonly _t;
|
|
290
|
+
constructor(_t: HttpTransport);
|
|
291
|
+
fetch(url: string, opts?: FetchOptions): Promise<FetchResult>;
|
|
292
|
+
fetchAsync(url: string, opts?: FetchAsyncOptions): Promise<string>;
|
|
293
|
+
fetchStream(url: string, opts?: {
|
|
294
|
+
forceBrowser?: boolean;
|
|
295
|
+
}): AsyncIterable<FetchEvent>;
|
|
296
|
+
analyze(url: string, opts?: {
|
|
297
|
+
statusCode?: number;
|
|
298
|
+
headers?: Record<string, string>;
|
|
299
|
+
bodySnippet?: string;
|
|
300
|
+
}): Promise<AnalyzeResult>;
|
|
301
|
+
storeProxy(name: string, proxyUrl: string): Promise<void>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
interface LoginOptions {
|
|
305
|
+
submitSelector?: string;
|
|
306
|
+
successUrlContains?: string;
|
|
307
|
+
}
|
|
308
|
+
interface FetchyrFetchOptions {
|
|
309
|
+
waitForSelector?: string;
|
|
310
|
+
extractHtml?: boolean;
|
|
311
|
+
}
|
|
312
|
+
declare class FetchyrNamespace {
|
|
313
|
+
private readonly _t;
|
|
314
|
+
constructor(_t: HttpTransport);
|
|
315
|
+
login(url: string, usernameSelector: string, passwordSelector: string, username: string, password: string, opts?: LoginOptions): Promise<SessionResult>;
|
|
316
|
+
fetch(url: string, sessionArtifactId: string, opts?: FetchyrFetchOptions): Promise<FetchyrResult>;
|
|
317
|
+
getSession(artifactId: string): Promise<Record<string, unknown>>;
|
|
318
|
+
invalidateSession(artifactId: string): Promise<void>;
|
|
319
|
+
createWorkflow(name: string, steps: Record<string, unknown>[], url?: string): Promise<WorkflowResult>;
|
|
320
|
+
executeWorkflow(workflowId: string): Promise<WorkflowExecutionResult>;
|
|
321
|
+
getExecution(workflowId: string, executionId: string): Promise<WorkflowExecutionResult>;
|
|
322
|
+
detectForms(url: string, opts?: {
|
|
323
|
+
sessionArtifactId?: string;
|
|
324
|
+
}): Promise<FormDetectionResult>;
|
|
325
|
+
detectMfa(url: string, opts?: {
|
|
326
|
+
sessionArtifactId?: string;
|
|
327
|
+
}): Promise<MfaDetectionResult>;
|
|
328
|
+
submitMfa(challengeId: string, code: string): Promise<MfaResult>;
|
|
329
|
+
checkDuplicates(records: Record<string, unknown>[], opts?: {
|
|
330
|
+
domain?: string;
|
|
331
|
+
}): Promise<DeduplicationResult>;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
interface PageOptions {
|
|
335
|
+
schema?: Record<string, string>;
|
|
336
|
+
fetchArtifactId?: string;
|
|
337
|
+
sessionArtifactId?: string;
|
|
338
|
+
apiMapArtifactId?: string;
|
|
339
|
+
options?: Record<string, unknown>;
|
|
340
|
+
limit?: number;
|
|
341
|
+
offset?: number;
|
|
342
|
+
}
|
|
343
|
+
declare class KolektrNamespace {
|
|
344
|
+
private readonly _t;
|
|
345
|
+
constructor(_t: HttpTransport);
|
|
346
|
+
page(url: string, opts?: PageOptions): Promise<ExtractionResult>;
|
|
347
|
+
pageAll(url: string, opts?: Omit<PageOptions, 'limit' | 'offset'>): Promise<Record<string, unknown>[]>;
|
|
348
|
+
extractHtml(html: string, url: string, opts?: {
|
|
349
|
+
schema?: Record<string, string>;
|
|
350
|
+
}): Promise<ExtractionResult>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
declare class NexusNamespace {
|
|
354
|
+
private readonly _t;
|
|
355
|
+
constructor(_t: HttpTransport);
|
|
356
|
+
analyze(url: string, opts?: {
|
|
357
|
+
html?: string;
|
|
358
|
+
constraints?: Record<string, unknown>;
|
|
359
|
+
}): Promise<NexusAnalyzeResult>;
|
|
360
|
+
synthesize(perceptionId: string, opts?: {
|
|
361
|
+
strategy?: Record<string, unknown>;
|
|
362
|
+
timeout?: number;
|
|
363
|
+
}): Promise<NexusSynthesisResult>;
|
|
364
|
+
verify(strategyId: string): Promise<NexusVerifyResult>;
|
|
365
|
+
execute(strategyId: string, url: string): Promise<NexusExecuteResult>;
|
|
366
|
+
knowledge(executionResultId: string, opts?: {
|
|
367
|
+
limit?: number;
|
|
368
|
+
offset?: number;
|
|
369
|
+
}): Promise<NexusKnowledgeResult>;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
declare class ParlyrNamespace {
|
|
373
|
+
private readonly _t;
|
|
374
|
+
constructor(_t: HttpTransport);
|
|
375
|
+
parse(message: string, opts?: {
|
|
376
|
+
sessionId?: string;
|
|
377
|
+
}): Promise<ParseResult>;
|
|
378
|
+
/**
|
|
379
|
+
* Send one chat turn and collect all SSE events into a ChatTurn.
|
|
380
|
+
* Blocks until the `done` event is received.
|
|
381
|
+
*/
|
|
382
|
+
chat(sessionId: string, message: string): Promise<ChatTurn>;
|
|
383
|
+
/**
|
|
384
|
+
* Async iterable SSE stream for one chat turn.
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* for await (const event of client.parlyr.chatStream('sess-1', 'Scrape linkedin.com')) {
|
|
389
|
+
* console.log(event.event, event.data);
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
chatStream(sessionId: string, message: string): AsyncIterable<ChatEvent>;
|
|
394
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
interface DiscoverOptions {
|
|
398
|
+
siteHierarchyArtifactId?: string;
|
|
399
|
+
maxRequests?: number;
|
|
400
|
+
sessionArtifactId?: string;
|
|
401
|
+
limit?: number;
|
|
402
|
+
offset?: number;
|
|
403
|
+
}
|
|
404
|
+
declare class SkanyrNamespace {
|
|
405
|
+
private readonly _t;
|
|
406
|
+
constructor(_t: HttpTransport);
|
|
407
|
+
discover(url: string, opts?: DiscoverOptions): Promise<DiscoverResult>;
|
|
408
|
+
discoverAll(url: string, opts?: Omit<DiscoverOptions, 'limit' | 'offset'>): Promise<ApiEndpoint[]>;
|
|
409
|
+
discoverStream(url: string, opts?: {
|
|
410
|
+
siteHierarchyArtifactId?: string;
|
|
411
|
+
maxRequests?: number;
|
|
412
|
+
}): AsyncIterable<DiscoverEvent>;
|
|
413
|
+
getApiMap(artifactId: string): Promise<Record<string, unknown>>;
|
|
414
|
+
getJob(jobId: string): Promise<Record<string, unknown>>;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
interface CrawlOptions {
|
|
418
|
+
maxDepth?: number;
|
|
419
|
+
maxPages?: number;
|
|
420
|
+
includeExternalLinks?: boolean;
|
|
421
|
+
sessionArtifactId?: string;
|
|
422
|
+
limit?: number;
|
|
423
|
+
offset?: number;
|
|
424
|
+
}
|
|
425
|
+
declare class WebgrphNamespace {
|
|
426
|
+
private readonly _t;
|
|
427
|
+
constructor(_t: HttpTransport);
|
|
428
|
+
crawl(url: string, opts?: CrawlOptions): Promise<CrawlResult>;
|
|
429
|
+
crawlAll(url: string, opts?: Omit<CrawlOptions, 'limit' | 'offset'>): Promise<PageNode[]>;
|
|
430
|
+
crawlStream(url: string, opts?: {
|
|
431
|
+
maxDepth?: number;
|
|
432
|
+
maxPages?: number;
|
|
433
|
+
}): AsyncIterable<CrawlEvent>;
|
|
434
|
+
getHierarchy(artifactId: string): Promise<Record<string, unknown>>;
|
|
435
|
+
getJob(jobId: string): Promise<Record<string, unknown>>;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* KLOAKD TypeScript SDK — Main client class.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* import { Kloakd } from 'kloakd-sdk';
|
|
444
|
+
*
|
|
445
|
+
* const client = new Kloakd({
|
|
446
|
+
* apiKey: 'sk-live-abc123',
|
|
447
|
+
* organizationId: 'your-org-id',
|
|
448
|
+
* });
|
|
449
|
+
*
|
|
450
|
+
* const fetch = await client.evadr.fetch('https://books.toscrape.com');
|
|
451
|
+
* const data = await client.kolektr.page('https://books.toscrape.com', {
|
|
452
|
+
* schema: { title: 'css:h3 a', price: 'css:p.price_color' },
|
|
453
|
+
* fetchArtifactId: fetch.artifactId ?? undefined,
|
|
454
|
+
* });
|
|
455
|
+
* console.log(data.records.slice(0, 3));
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
|
|
459
|
+
interface KloakdOptions {
|
|
460
|
+
apiKey: string;
|
|
461
|
+
organizationId: string;
|
|
462
|
+
baseUrl?: string;
|
|
463
|
+
timeout?: number;
|
|
464
|
+
maxRetries?: number;
|
|
465
|
+
/** Injected fetch — for testing only. */
|
|
466
|
+
fetchImpl?: typeof fetch;
|
|
467
|
+
}
|
|
468
|
+
declare class Kloakd {
|
|
469
|
+
readonly evadr: EvadrNamespace;
|
|
470
|
+
readonly webgrph: WebgrphNamespace;
|
|
471
|
+
readonly skanyr: SkanyrNamespace;
|
|
472
|
+
readonly nexus: NexusNamespace;
|
|
473
|
+
readonly parlyr: ParlyrNamespace;
|
|
474
|
+
readonly fetchyr: FetchyrNamespace;
|
|
475
|
+
readonly kolektr: KolektrNamespace;
|
|
476
|
+
private readonly _transport;
|
|
477
|
+
constructor(opts: KloakdOptions);
|
|
478
|
+
toString(): string;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* KLOAKD SDK — Error hierarchy.
|
|
483
|
+
*
|
|
484
|
+
* All errors extend KloakdError, which extends the native Error class.
|
|
485
|
+
* Every error carries statusCode and message.
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* ```typescript
|
|
489
|
+
* import { RateLimitError, KloakdError } from 'kloakd-sdk';
|
|
490
|
+
*
|
|
491
|
+
* try {
|
|
492
|
+
* const result = await client.evadr.fetch('https://example.com');
|
|
493
|
+
* } catch (e) {
|
|
494
|
+
* if (e instanceof RateLimitError) {
|
|
495
|
+
* await sleep(e.retryAfter * 1000);
|
|
496
|
+
* } else if (e instanceof KloakdError) {
|
|
497
|
+
* console.error(e.statusCode, e.message);
|
|
498
|
+
* }
|
|
499
|
+
* }
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
declare class KloakdError extends Error {
|
|
503
|
+
readonly statusCode: number;
|
|
504
|
+
constructor(message: string, statusCode: number);
|
|
505
|
+
}
|
|
506
|
+
declare class AuthenticationError extends KloakdError {
|
|
507
|
+
constructor(message: string);
|
|
508
|
+
}
|
|
509
|
+
declare class NotEntitledError extends KloakdError {
|
|
510
|
+
readonly module: string;
|
|
511
|
+
readonly upgradeUrl: string;
|
|
512
|
+
constructor(message: string, module: string, upgradeUrl?: string);
|
|
513
|
+
}
|
|
514
|
+
declare class RateLimitError extends KloakdError {
|
|
515
|
+
readonly retryAfter: number;
|
|
516
|
+
readonly resetAt: string;
|
|
517
|
+
constructor(message: string, retryAfter: number, resetAt?: string);
|
|
518
|
+
}
|
|
519
|
+
declare class UpstreamError extends KloakdError {
|
|
520
|
+
constructor(message: string);
|
|
521
|
+
}
|
|
522
|
+
declare class ApiError extends KloakdError {
|
|
523
|
+
constructor(message: string, statusCode: number);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export { type AnalyzeResult, type ApiEndpoint, ApiError, AuthenticationError, type ChatEvent, type ChatTurn, type CrawlEvent, type CrawlResult, type DeduplicationResult, type DiscoverEvent, type DiscoverResult, type ExtractionResult, type FetchEvent, type FetchResult, type FetchyrResult, type FormDetectionResult, Kloakd, KloakdError, type KloakdOptions, type MfaDetectionResult, type MfaResult, type NexusAnalyzeResult, type NexusExecuteResult, type NexusKnowledgeResult, type NexusSynthesisResult, type NexusVerifyResult, NotEntitledError, type PageNode, type ParseResult, RateLimitError, type SessionResult, UpstreamError, type WorkflowExecutionResult, type WorkflowResult };
|