@veroq/sdk 1.0.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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +108 -0
  3. package/dist/cjs/agent.d.ts +144 -0
  4. package/dist/cjs/agent.d.ts.map +1 -0
  5. package/dist/cjs/agent.js +143 -0
  6. package/dist/cjs/agent.js.map +1 -0
  7. package/dist/cjs/cli.d.ts +3 -0
  8. package/dist/cjs/cli.d.ts.map +1 -0
  9. package/dist/cjs/cli.js +206 -0
  10. package/dist/cjs/cli.js.map +1 -0
  11. package/dist/cjs/client.d.ts +153 -0
  12. package/dist/cjs/client.d.ts.map +1 -0
  13. package/dist/cjs/client.js +800 -0
  14. package/dist/cjs/client.js.map +1 -0
  15. package/dist/cjs/errors.d.ts +21 -0
  16. package/dist/cjs/errors.d.ts.map +1 -0
  17. package/dist/cjs/errors.js +44 -0
  18. package/dist/cjs/errors.js.map +1 -0
  19. package/dist/cjs/index.d.ts +6 -0
  20. package/dist/cjs/index.d.ts.map +1 -0
  21. package/dist/cjs/index.js +16 -0
  22. package/dist/cjs/index.js.map +1 -0
  23. package/dist/cjs/types.d.ts +779 -0
  24. package/dist/cjs/types.d.ts.map +1 -0
  25. package/dist/cjs/types.js +3 -0
  26. package/dist/cjs/types.js.map +1 -0
  27. package/dist/esm/agent.d.ts +144 -0
  28. package/dist/esm/agent.d.ts.map +1 -0
  29. package/dist/esm/agent.js +139 -0
  30. package/dist/esm/agent.js.map +1 -0
  31. package/dist/esm/cli.d.ts +3 -0
  32. package/dist/esm/cli.d.ts.map +1 -0
  33. package/dist/esm/cli.js +204 -0
  34. package/dist/esm/cli.js.map +1 -0
  35. package/dist/esm/client.d.ts +153 -0
  36. package/dist/esm/client.d.ts.map +1 -0
  37. package/dist/esm/client.js +796 -0
  38. package/dist/esm/client.js.map +1 -0
  39. package/dist/esm/errors.d.ts +21 -0
  40. package/dist/esm/errors.d.ts.map +1 -0
  41. package/dist/esm/errors.js +36 -0
  42. package/dist/esm/errors.js.map +1 -0
  43. package/dist/esm/index.d.ts +6 -0
  44. package/dist/esm/index.d.ts.map +1 -0
  45. package/dist/esm/index.js +4 -0
  46. package/dist/esm/index.js.map +1 -0
  47. package/dist/esm/types.d.ts +779 -0
  48. package/dist/esm/types.d.ts.map +1 -0
  49. package/dist/esm/types.js +2 -0
  50. package/dist/esm/types.js.map +1 -0
  51. package/package.json +74 -0
@@ -0,0 +1,800 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PolarisClient = exports.VeroqClient = void 0;
4
+ const fs_1 = require("fs");
5
+ const os_1 = require("os");
6
+ const path_1 = require("path");
7
+ const errors_js_1 = require("./errors.js");
8
+ function readCredentials() {
9
+ // Check VEROQ_API_KEY first, then fall back to POLARIS_API_KEY
10
+ const envKey = process.env.VEROQ_API_KEY || process.env.POLARIS_API_KEY;
11
+ if (envKey)
12
+ return envKey;
13
+ // Check ~/.veroq/credentials first, then fall back to ~/.polaris/credentials
14
+ try {
15
+ const key = (0, fs_1.readFileSync)((0, path_1.join)((0, os_1.homedir)(), ".veroq", "credentials"), "utf-8").trim();
16
+ if (key)
17
+ return key;
18
+ }
19
+ catch { /* ignore */ }
20
+ try {
21
+ const key = (0, fs_1.readFileSync)((0, path_1.join)((0, os_1.homedir)(), ".polaris", "credentials"), "utf-8").trim();
22
+ return key || undefined;
23
+ }
24
+ catch {
25
+ return undefined;
26
+ }
27
+ }
28
+ const DEFAULT_BASE_URL = "https://api.thepolarisreport.com";
29
+ function toSnakeCase(str) {
30
+ return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
31
+ }
32
+ function toSnakeParams(params) {
33
+ const result = {};
34
+ for (const [key, value] of Object.entries(params)) {
35
+ if (value !== undefined && value !== null) {
36
+ result[toSnakeCase(key)] = String(value);
37
+ }
38
+ }
39
+ return result;
40
+ }
41
+ /* -- Parsers: snake_case API -> camelCase SDK -- */
42
+ function parseSource(raw) {
43
+ return {
44
+ name: (raw.name || ""),
45
+ url: (raw.url || ""),
46
+ trustLevel: raw.trust_level,
47
+ verified: raw.verified,
48
+ };
49
+ }
50
+ function parseEntity(raw) {
51
+ return {
52
+ name: (raw.name || ""),
53
+ type: raw.type,
54
+ sentiment: raw.sentiment,
55
+ mentionCount: (raw.mention_count ?? raw.mentions_24h),
56
+ ticker: raw.ticker,
57
+ role: raw.role,
58
+ };
59
+ }
60
+ function parseProvenance(raw) {
61
+ return {
62
+ reviewStatus: raw.review_status,
63
+ aiContributionPct: raw.ai_contribution_pct,
64
+ humanContributionPct: raw.human_contribution_pct,
65
+ confidenceScore: raw.confidence_score,
66
+ biasScore: raw.bias_score,
67
+ agentsInvolved: raw.agents_involved,
68
+ };
69
+ }
70
+ function parseBrief(raw) {
71
+ const prov = raw.provenance
72
+ ? parseProvenance(raw.provenance)
73
+ : undefined;
74
+ return {
75
+ id: raw.id,
76
+ headline: (raw.headline || ""),
77
+ summary: raw.summary,
78
+ body: raw.body,
79
+ confidence: raw.confidence ?? prov?.confidenceScore,
80
+ biasScore: raw.bias_score ?? prov?.biasScore,
81
+ sentiment: raw.sentiment,
82
+ counterArgument: raw.counter_argument,
83
+ category: raw.category,
84
+ tags: raw.tags,
85
+ sources: raw.sources
86
+ ? raw.sources.map(parseSource)
87
+ : undefined,
88
+ entitiesEnriched: raw.entities_enriched
89
+ ? raw.entities_enriched.map(parseEntity)
90
+ : undefined,
91
+ structuredData: raw.structured_data,
92
+ publishedAt: raw.published_at,
93
+ reviewStatus: raw.review_status,
94
+ provenance: prov,
95
+ briefType: raw.brief_type,
96
+ trending: raw.trending,
97
+ topics: raw.topics,
98
+ entities: raw.entities,
99
+ impactScore: raw.impact_score,
100
+ readTimeSeconds: raw.read_time_seconds,
101
+ sourceCount: raw.source_count,
102
+ correctionsCount: raw.corrections_count,
103
+ biasAnalysis: raw.bias_analysis,
104
+ fullSources: raw.full_sources,
105
+ };
106
+ }
107
+ function parseSourceAnalysis(raw) {
108
+ return {
109
+ outlet: raw.outlet,
110
+ headline: raw.headline,
111
+ framing: raw.framing,
112
+ politicalLean: raw.political_lean,
113
+ loadedLanguage: raw.loaded_language,
114
+ emphasis: raw.emphasis,
115
+ omissions: raw.omissions,
116
+ sentiment: raw.sentiment,
117
+ rawExcerpt: raw.raw_excerpt,
118
+ };
119
+ }
120
+ class VeroqClient {
121
+ constructor(options = {}) {
122
+ this.apiKey = options.apiKey ?? readCredentials();
123
+ this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, "");
124
+ }
125
+ async request(method, path, params, body) {
126
+ let url = `${this.baseUrl}${path}`;
127
+ if (params) {
128
+ const snaked = toSnakeParams(params);
129
+ const qs = new URLSearchParams(snaked).toString();
130
+ if (qs)
131
+ url += `?${qs}`;
132
+ }
133
+ const headers = { "Content-Type": "application/json" };
134
+ if (this.apiKey) {
135
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
136
+ }
137
+ const init = { method, headers };
138
+ if (body !== undefined) {
139
+ init.body = JSON.stringify(body);
140
+ }
141
+ const resp = await fetch(url, init);
142
+ if (!resp.ok) {
143
+ await this.throwError(resp);
144
+ }
145
+ return resp.json();
146
+ }
147
+ async throwError(resp) {
148
+ let body;
149
+ try {
150
+ body = await resp.json();
151
+ }
152
+ catch {
153
+ body = await resp.text();
154
+ }
155
+ const msg = (body && typeof body === "object" && "error" in body)
156
+ ? String(body.error)
157
+ : String(body);
158
+ if (resp.status === 401) {
159
+ throw new errors_js_1.AuthenticationError(msg, body);
160
+ }
161
+ if (resp.status === 404) {
162
+ throw new errors_js_1.NotFoundError(msg, body);
163
+ }
164
+ if (resp.status === 429) {
165
+ const retryAfter = resp.headers.get("Retry-After") || resp.headers.get("RateLimit-Reset");
166
+ const parsed = retryAfter ? (isNaN(Number(retryAfter)) ? retryAfter : Number(retryAfter)) : null;
167
+ throw new errors_js_1.RateLimitError(msg, body, parsed);
168
+ }
169
+ throw new errors_js_1.APIError(msg, resp.status, body);
170
+ }
171
+ async feed(options = {}) {
172
+ const params = { ...options };
173
+ if (params.limit !== undefined) {
174
+ params.perPage = params.limit;
175
+ delete params.limit;
176
+ }
177
+ const data = await this.request("GET", "/api/v1/feed", params);
178
+ const meta = (data.meta || {});
179
+ return {
180
+ briefs: (data.briefs || []).map(parseBrief),
181
+ total: (meta.total || data.total || 0),
182
+ page: (meta.page || data.page || 1),
183
+ perPage: (meta.per_page || data.per_page || 20),
184
+ generatedAt: data.generated_at,
185
+ agentVersion: data.agent_version,
186
+ sourcesScanned24h: (meta.sources_scanned_24h || data.sources_scanned_24h),
187
+ };
188
+ }
189
+ async brief(id, options = {}) {
190
+ const params = {};
191
+ if (options.includeFullText !== undefined) {
192
+ params.includeFullText = options.includeFullText;
193
+ }
194
+ const data = await this.request("GET", `/api/v1/brief/${id}`, params);
195
+ return parseBrief((data.brief || data));
196
+ }
197
+ async timeline(id) {
198
+ return this.request("GET", `/api/v1/brief/${id}/timeline`);
199
+ }
200
+ async search(query, options = {}) {
201
+ const params = { q: query, ...options };
202
+ const data = await this.request("GET", "/api/v1/search", params);
203
+ const dm = data.depth_metadata;
204
+ return {
205
+ briefs: (data.briefs || []).map(parseBrief),
206
+ total: (data.total || 0),
207
+ facets: data.facets,
208
+ relatedQueries: data.related_queries,
209
+ didYouMean: data.did_you_mean,
210
+ tookMs: data.took_ms,
211
+ meta: data.meta,
212
+ depthMetadata: dm ? {
213
+ depth: dm.depth,
214
+ searchMs: dm.search_ms,
215
+ crossRefMs: dm.cross_ref_ms,
216
+ verificationMs: dm.verification_ms,
217
+ totalMs: dm.total_ms,
218
+ } : undefined,
219
+ };
220
+ }
221
+ /** Get search autocomplete suggestions. */
222
+ async searchSuggest(q) {
223
+ const params = { q };
224
+ return this.request("GET", "/api/v1/search/suggest", params);
225
+ }
226
+ async generate(topic, category) {
227
+ const body = { topic };
228
+ if (category)
229
+ body.category = category;
230
+ const data = await this.request("POST", "/api/v1/generate/brief", undefined, body);
231
+ return parseBrief((data.brief || data));
232
+ }
233
+ async entities(options = {}) {
234
+ const data = await this.request("GET", "/api/v1/entities", options);
235
+ return {
236
+ entities: (data.entities || []).map(parseEntity),
237
+ };
238
+ }
239
+ async entityBriefs(name, options = {}) {
240
+ const data = await this.request("GET", `/api/v1/entities/${encodeURIComponent(name)}/briefs`, options);
241
+ return (data.briefs || []).map(parseBrief);
242
+ }
243
+ async trendingEntities(limit) {
244
+ const params = {};
245
+ if (limit !== undefined)
246
+ params.limit = limit;
247
+ const data = await this.request("GET", "/api/v1/entities/trending", params);
248
+ return {
249
+ entities: (data.entities || []).map(parseEntity),
250
+ };
251
+ }
252
+ async similar(id, options = {}) {
253
+ const data = await this.request("GET", `/api/v1/similar/${id}`, options);
254
+ return (data.briefs || []).map(parseBrief);
255
+ }
256
+ async clusters(options = {}) {
257
+ const data = await this.request("GET", "/api/v1/clusters", options);
258
+ return {
259
+ clusters: (data.clusters || []),
260
+ period: data.period,
261
+ };
262
+ }
263
+ async data(options = {}) {
264
+ const data = await this.request("GET", "/api/v1/data", options);
265
+ return { data: (data.data || []) };
266
+ }
267
+ async agentFeed(options = {}) {
268
+ const data = await this.request("GET", "/api/v1/agent-feed", options);
269
+ return {
270
+ briefs: (data.briefs || []).map(parseBrief),
271
+ total: (data.total || 0),
272
+ page: (data.page || 1),
273
+ perPage: (data.per_page || 20),
274
+ generatedAt: data.generated_at,
275
+ agentVersion: data.agent_version,
276
+ sourcesScanned24h: data.sources_scanned_24h,
277
+ };
278
+ }
279
+ async compareSources(briefId) {
280
+ const data = await this.request("GET", "/api/v1/compare/sources", { briefId });
281
+ const rawBrief = data.polaris_brief;
282
+ const rawAnalyses = data.source_analyses;
283
+ return {
284
+ topic: data.topic,
285
+ shareId: data.share_id,
286
+ polarisBrief: rawBrief ? parseBrief(rawBrief) : undefined,
287
+ sourceAnalyses: rawAnalyses ? rawAnalyses.map(parseSourceAnalysis) : undefined,
288
+ polarisAnalysis: data.polaris_analysis,
289
+ generatedAt: data.generated_at,
290
+ };
291
+ }
292
+ async research(query, options = {}) {
293
+ const body = { query };
294
+ if (options.maxSources !== undefined)
295
+ body.max_sources = options.maxSources;
296
+ if (options.depth !== undefined)
297
+ body.depth = options.depth;
298
+ if (options.category !== undefined)
299
+ body.category = options.category;
300
+ if (options.includeSources !== undefined)
301
+ body.include_sources = options.includeSources;
302
+ if (options.excludeSources !== undefined)
303
+ body.exclude_sources = options.excludeSources;
304
+ if (options.outputSchema !== undefined)
305
+ body.output_schema = options.outputSchema;
306
+ const data = await this.request("POST", "/api/v1/research", undefined, body);
307
+ const sourcesUsed = (data.sources_used || []).map((s) => ({
308
+ briefId: s.brief_id,
309
+ headline: s.headline,
310
+ confidence: s.confidence,
311
+ category: s.category,
312
+ }));
313
+ const entityMap = (data.entity_map || []).map((e) => ({
314
+ name: e.name,
315
+ type: e.type,
316
+ mentions: e.mentions,
317
+ coOccursWith: (e.co_occurs_with || []).map((c) => ({
318
+ entity: c.entity,
319
+ count: c.count,
320
+ })),
321
+ }));
322
+ const meta = data.metadata;
323
+ return {
324
+ query: data.query,
325
+ report: data.report,
326
+ sourcesUsed,
327
+ entityMap,
328
+ subQueries: data.sub_queries,
329
+ metadata: meta ? {
330
+ briefsAnalyzed: (meta.briefs_analyzed || 0),
331
+ uniqueSources: (meta.unique_sources || 0),
332
+ processingTimeMs: meta.processing_time_ms,
333
+ modelsUsed: meta.models_used,
334
+ } : undefined,
335
+ structuredOutput: data.structured_output,
336
+ structuredOutputError: data.structured_output_error,
337
+ };
338
+ }
339
+ async extract(urls, includeMetadata) {
340
+ const body = { urls };
341
+ if (includeMetadata !== undefined)
342
+ body.include_metadata = includeMetadata;
343
+ const data = await this.request("POST", "/api/v1/extract", undefined, body);
344
+ return {
345
+ results: (data.results || []).map((r) => ({
346
+ url: r.url,
347
+ title: r.title,
348
+ text: r.text,
349
+ wordCount: r.word_count,
350
+ language: r.language,
351
+ publishedDate: r.published_date,
352
+ domain: r.domain,
353
+ success: r.success,
354
+ error: r.error,
355
+ })),
356
+ creditsUsed: (data.credits_used || 0),
357
+ };
358
+ }
359
+ async verify(claim, options = {}) {
360
+ const body = { claim };
361
+ if (options.context !== undefined)
362
+ body.context = options.context;
363
+ const data = await this.request("POST", "/api/v1/verify", undefined, body);
364
+ const mapBrief = (b) => ({
365
+ id: b.id,
366
+ headline: b.headline,
367
+ confidence: b.confidence,
368
+ relevance: (b.relevance ?? null),
369
+ });
370
+ return {
371
+ claim: data.claim,
372
+ verdict: data.verdict,
373
+ confidence: (data.confidence || 0),
374
+ summary: (data.summary || ""),
375
+ supportingBriefs: (data.supporting_briefs || []).map(mapBrief),
376
+ contradictingBriefs: (data.contradicting_briefs || []).map(mapBrief),
377
+ nuances: (data.nuances ?? null),
378
+ sourcesAnalyzed: (data.sources_analyzed || 0),
379
+ briefsMatched: (data.briefs_matched || 0),
380
+ creditsUsed: (data.credits_used || 0),
381
+ cached: (data.cached || false),
382
+ processingTimeMs: (data.processing_time_ms || 0),
383
+ modelUsed: (data.model_used ?? null),
384
+ };
385
+ }
386
+ async trending(options = {}) {
387
+ const data = await this.request("GET", "/api/v1/trending", options);
388
+ return (data.briefs || []).map(parseBrief);
389
+ }
390
+ async forecast(topic, options = {}) {
391
+ const body = {
392
+ topic,
393
+ depth: options.depth ?? "standard",
394
+ period: options.period ?? "30d",
395
+ timeframe: options.timeframe ?? "30d",
396
+ };
397
+ return this.request("POST", "/api/v1/forecast", undefined, body);
398
+ }
399
+ async diff(id, since) {
400
+ const params = {};
401
+ if (since !== undefined)
402
+ params.since = since;
403
+ return this.request("GET", `/api/v1/brief/${id}/diff`, params);
404
+ }
405
+ async contradictions(options = {}) {
406
+ const params = { limit: options.limit ?? 20 };
407
+ if (options.severity !== undefined)
408
+ params.severity = options.severity;
409
+ if (options.category !== undefined)
410
+ params.category = options.category;
411
+ return this.request("GET", "/api/v1/contradictions", params);
412
+ }
413
+ async events(options = {}) {
414
+ const params = {
415
+ period: options.period ?? "30d",
416
+ limit: options.limit ?? 30,
417
+ };
418
+ if (options.type !== undefined)
419
+ params.type = options.type;
420
+ if (options.subject !== undefined)
421
+ params.subject = options.subject;
422
+ if (options.category !== undefined)
423
+ params.category = options.category;
424
+ return this.request("GET", "/api/v1/events", params);
425
+ }
426
+ async subscribeBrief(id) {
427
+ return this.request("POST", `/api/v1/brief/${id}/subscribe`, undefined, {});
428
+ }
429
+ async unsubscribeBrief(id) {
430
+ return this.request("DELETE", `/api/v1/brief/${id}/subscribe`);
431
+ }
432
+ async watchlists() {
433
+ return this.request("GET", "/api/v1/watchlists");
434
+ }
435
+ async createWatchlist(name, options = {}) {
436
+ const body = { name, ...options };
437
+ return this.request("POST", "/api/v1/watchlists", undefined, body);
438
+ }
439
+ async addWatchItem(watchlistId, type, options = {}) {
440
+ const body = { type, ...options };
441
+ return this.request("POST", `/api/v1/watchlists/${watchlistId}/items`, undefined, body);
442
+ }
443
+ /** Get matches for a watchlist. */
444
+ async watchlistMatches(watchlistId) {
445
+ return this.request("GET", `/api/v1/watchlists/${encodeURIComponent(watchlistId)}/matches`);
446
+ }
447
+ async createMonitor(options) {
448
+ return this.request("POST", "/api/v1/monitor", undefined, options);
449
+ }
450
+ async monitors() {
451
+ return this.request("GET", "/api/v1/monitors");
452
+ }
453
+ async createSession(name, metadata) {
454
+ const body = { name: name ?? "default" };
455
+ if (metadata !== undefined)
456
+ body.metadata = metadata;
457
+ return this.request("POST", "/api/v1/agent/session", undefined, body);
458
+ }
459
+ async sessions() {
460
+ return this.request("GET", "/api/v1/agent/sessions");
461
+ }
462
+ async markRead(sessionName, briefIds) {
463
+ const body = { brief_ids: briefIds };
464
+ return this.request("POST", `/api/v1/agent/session/${sessionName}/read`, undefined, body);
465
+ }
466
+ async agentFeedFiltered(options = {}) {
467
+ const params = {
468
+ session: options.session ?? "default",
469
+ limit: options.limit ?? 20,
470
+ };
471
+ if (options.category !== undefined)
472
+ params.category = options.category;
473
+ return this.request("GET", "/api/v1/agent/feed", params);
474
+ }
475
+ async webSearch(q, options) {
476
+ const params = { q, ...options };
477
+ return this.request("GET", "/api/v1/web-search", params);
478
+ }
479
+ async crawl(url, options) {
480
+ const body = { url, ...options };
481
+ return this.request("POST", "/api/v1/crawl", undefined, body);
482
+ }
483
+ // -- Trading --
484
+ async tickerResolve(symbols) {
485
+ const params = { q: symbols.join(",") };
486
+ return this.request("GET", "/api/v1/ticker/resolve", params);
487
+ }
488
+ async ticker(symbol) {
489
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}`);
490
+ }
491
+ async tickerHistory(symbol, options = {}) {
492
+ const params = { ...options };
493
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/history`, params);
494
+ }
495
+ async tickerSignals(symbol, options = {}) {
496
+ const params = { ...options };
497
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/signals`, params);
498
+ }
499
+ async tickerCorrelations(symbol, options = {}) {
500
+ const params = { ...options };
501
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/correlations`, params);
502
+ }
503
+ async tickerScore(symbol) {
504
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/score`);
505
+ }
506
+ /** Get live prices for one or more ticker symbols. */
507
+ async tickerPrices(symbols, paid) {
508
+ const params = { symbols: symbols.join(",") };
509
+ if (paid !== undefined)
510
+ params.paid = paid;
511
+ return this.request("GET", "/api/v1/ticker/prices", params);
512
+ }
513
+ /** Get sentiment analysis for a ticker symbol. */
514
+ async tickerSentiment(symbol, period) {
515
+ const params = {};
516
+ if (period !== undefined)
517
+ params.period = period;
518
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/sentiment`, params);
519
+ }
520
+ /** Get full analysis for a ticker symbol. */
521
+ async tickerAnalysis(symbol) {
522
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/analysis`);
523
+ }
524
+ /** Get recent news for a ticker symbol. */
525
+ async tickerNews(symbol, limit) {
526
+ const params = {};
527
+ if (limit !== undefined)
528
+ params.limit = limit;
529
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/news`, params);
530
+ }
531
+ async sectors(options = {}) {
532
+ const params = { ...options };
533
+ return this.request("GET", "/api/v1/sectors", params);
534
+ }
535
+ async sectorTickers(sector, options = {}) {
536
+ const params = { ...options };
537
+ return this.request("GET", `/api/v1/sectors/${encodeURIComponent(sector)}/tickers`, params);
538
+ }
539
+ async eventsCalendar(options = {}) {
540
+ const params = { ...options };
541
+ return this.request("GET", "/api/v1/events/calendar", params);
542
+ }
543
+ /** Get IPO calendar, optionally filtered by status. */
544
+ async ipoCalendar(status) {
545
+ const params = {};
546
+ if (status !== undefined)
547
+ params.status = status;
548
+ return this.request("GET", "/api/v1/ipo/calendar", params);
549
+ }
550
+ async portfolioFeed(holdings, options = {}) {
551
+ const body = { holdings, ...options };
552
+ return this.request("POST", "/api/v1/portfolio/feed", undefined, body);
553
+ }
554
+ // -- AV Parity --
555
+ async candles(symbol, options = {}) {
556
+ const params = { ...options };
557
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/candles`, params);
558
+ }
559
+ async financials(symbol) {
560
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/financials`);
561
+ }
562
+ async earnings(symbol) {
563
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/earnings`);
564
+ }
565
+ async indicators(symbol, type, options = {}) {
566
+ const params = { type, ...options };
567
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/indicators`, params);
568
+ }
569
+ async technicals(symbol, options = {}) {
570
+ const params = { ...options };
571
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/technicals`, params);
572
+ }
573
+ async marketMovers() {
574
+ return this.request("GET", "/api/v1/market/movers");
575
+ }
576
+ async marketSummary() {
577
+ return this.request("GET", "/api/v1/market/summary");
578
+ }
579
+ async marketEarnings(options = {}) {
580
+ const params = { ...options };
581
+ return this.request("GET", "/api/v1/market/earnings", params);
582
+ }
583
+ async forex(pair) {
584
+ if (pair) {
585
+ return this.request("GET", `/api/v1/forex/${encodeURIComponent(pair)}`);
586
+ }
587
+ return this.request("GET", "/api/v1/forex");
588
+ }
589
+ async forexCandles(pair, options = {}) {
590
+ const params = { ...options };
591
+ return this.request("GET", `/api/v1/forex/${encodeURIComponent(pair)}/candles`, params);
592
+ }
593
+ async commodities(symbol) {
594
+ if (symbol) {
595
+ return this.request("GET", `/api/v1/commodities/${encodeURIComponent(symbol)}`);
596
+ }
597
+ return this.request("GET", "/api/v1/commodities");
598
+ }
599
+ async commodityCandles(symbol, options = {}) {
600
+ const params = { ...options };
601
+ return this.request("GET", `/api/v1/commodities/${encodeURIComponent(symbol)}/candles`, params);
602
+ }
603
+ async economy(indicator, options = {}) {
604
+ if (indicator) {
605
+ const params = { ...options };
606
+ return this.request("GET", `/api/v1/economy/${encodeURIComponent(indicator)}`, params);
607
+ }
608
+ return this.request("GET", "/api/v1/economy");
609
+ }
610
+ async economyYields() {
611
+ return this.request("GET", "/api/v1/economy/yields");
612
+ }
613
+ /** Get a specific economic indicator by name. */
614
+ async economyIndicator(indicator) {
615
+ return this.request("GET", `/api/v1/economy/${encodeURIComponent(indicator)}`);
616
+ }
617
+ // -- Crypto --
618
+ async crypto(symbol) {
619
+ if (symbol) {
620
+ return this.request("GET", `/api/v1/crypto/${encodeURIComponent(symbol)}`);
621
+ }
622
+ return this.request("GET", "/api/v1/crypto");
623
+ }
624
+ async cryptoTop(options = {}) {
625
+ const params = { ...options };
626
+ return this.request("GET", "/api/v1/crypto/top", params);
627
+ }
628
+ async cryptoChart(symbol, options = {}) {
629
+ const params = { ...options };
630
+ return this.request("GET", `/api/v1/crypto/${encodeURIComponent(symbol)}/chart`, params);
631
+ }
632
+ async cryptoDefi(protocol) {
633
+ if (protocol) {
634
+ return this.request("GET", `/api/v1/crypto/defi/${encodeURIComponent(protocol)}`);
635
+ }
636
+ return this.request("GET", "/api/v1/crypto/defi");
637
+ }
638
+ /** Get details for a specific DeFi protocol. */
639
+ async defiProtocol(protocol) {
640
+ return this.request("GET", `/api/v1/crypto/defi/${encodeURIComponent(protocol)}`);
641
+ }
642
+ // -- Screener --
643
+ async screener(filters) {
644
+ return this.request("POST", "/api/v1/screener", undefined, filters);
645
+ }
646
+ async screenerNatural(query, options = {}) {
647
+ const body = { query };
648
+ if (options.limit !== undefined)
649
+ body.limit = options.limit;
650
+ return this.request("POST", "/api/v1/screener/natural", undefined, body);
651
+ }
652
+ async screenerPresets() {
653
+ return this.request("GET", "/api/v1/screener/presets");
654
+ }
655
+ async screenerPreset(id, options = {}) {
656
+ const params = { ...options };
657
+ return this.request("GET", `/api/v1/screener/presets/${encodeURIComponent(id)}`, params);
658
+ }
659
+ // -- Alerts --
660
+ async createAlert(ticker, alertType, threshold, options = {}) {
661
+ const body = { ticker, alert_type: alertType, threshold };
662
+ if (options.callbackUrl !== undefined)
663
+ body.callback_url = options.callbackUrl;
664
+ return this.request("POST", "/api/v1/alerts", undefined, body);
665
+ }
666
+ async listAlerts(status) {
667
+ const params = {};
668
+ if (status !== undefined)
669
+ params.status = status;
670
+ return this.request("GET", "/api/v1/alerts", params);
671
+ }
672
+ async deleteAlert(id) {
673
+ return this.request("DELETE", `/api/v1/alerts/${encodeURIComponent(id)}`);
674
+ }
675
+ async triggeredAlerts(options = {}) {
676
+ const params = { ...options };
677
+ return this.request("GET", "/api/v1/alerts/triggered", params);
678
+ }
679
+ // -- Backtest --
680
+ async backtest(strategy, options = {}) {
681
+ const body = { strategy, period: options.period ?? "1y", ...options };
682
+ delete body.period;
683
+ body.period = options.period ?? "1y";
684
+ return this.request("POST", "/api/v1/backtest", undefined, body);
685
+ }
686
+ // -- Correlation --
687
+ async correlation(tickers, options = {}) {
688
+ const body = { tickers, days: options.days ?? 30 };
689
+ return this.request("POST", "/api/v1/correlation", undefined, body);
690
+ }
691
+ // -- Ticker Intelligence --
692
+ async newsImpact(symbol) {
693
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/impact`);
694
+ }
695
+ async competitors(symbol) {
696
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/competitors`);
697
+ }
698
+ async transcripts(symbol, options = {}) {
699
+ const params = { ...options };
700
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/transcripts`, params);
701
+ }
702
+ // -- Social --
703
+ /** Get social media sentiment for a ticker symbol. */
704
+ async socialSentiment(symbol) {
705
+ return this.request("GET", `/api/v1/ticker/${encodeURIComponent(symbol)}/social`);
706
+ }
707
+ /** Get trending topics across social media. */
708
+ async socialTrending() {
709
+ return this.request("GET", "/api/v1/social/trending");
710
+ }
711
+ /** Get social sentiment for a named entity. */
712
+ async socialEntity(entity) {
713
+ return this.request("GET", `/api/v1/social/sentiment/${encodeURIComponent(entity)}`);
714
+ }
715
+ // -- Reports --
716
+ /** Generate an AI report for a ticker. */
717
+ async generateReport(ticker, tier) {
718
+ const body = { ticker, tier: tier || "quick" };
719
+ return this.request("POST", "/api/v1/reports/generate", undefined, body);
720
+ }
721
+ /** Get a previously generated report by ID. */
722
+ async getReport(reportId) {
723
+ return this.request("GET", `/api/v1/reports/${encodeURIComponent(reportId)}`);
724
+ }
725
+ /** List recent reports. */
726
+ async listReports(limit) {
727
+ const params = { limit: limit ?? 20 };
728
+ return this.request("GET", "/api/v1/reports", params);
729
+ }
730
+ /** Upload a CLI-generated report. */
731
+ async uploadReport(ticker, markdown, tier) {
732
+ const body = { ticker, markdown, tier: tier || "cli" };
733
+ return this.request("POST", "/api/v1/reports/upload", undefined, body);
734
+ }
735
+ stream(options = {}) {
736
+ let controller = null;
737
+ return {
738
+ start: (onBrief, onError) => {
739
+ controller = new AbortController();
740
+ const params = {};
741
+ if (options.categories)
742
+ params.categories = options.categories;
743
+ let url = `${this.baseUrl}/api/v1/stream`;
744
+ const snaked = toSnakeParams(params);
745
+ const qs = new URLSearchParams(snaked).toString();
746
+ if (qs)
747
+ url += `?${qs}`;
748
+ const headers = { Accept: "text/event-stream" };
749
+ if (this.apiKey)
750
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
751
+ fetch(url, { headers, signal: controller.signal })
752
+ .then(async (resp) => {
753
+ if (!resp.ok) {
754
+ await this.throwError(resp);
755
+ }
756
+ const reader = resp.body?.getReader();
757
+ if (!reader)
758
+ return;
759
+ const decoder = new TextDecoder();
760
+ let buffer = "";
761
+ while (true) {
762
+ const { done, value } = await reader.read();
763
+ if (done)
764
+ break;
765
+ buffer += decoder.decode(value, { stream: true });
766
+ const lines = buffer.split("\n");
767
+ buffer = lines.pop() || "";
768
+ for (const line of lines) {
769
+ if (line.startsWith("data:")) {
770
+ const payload = line.slice(5).trim();
771
+ if (payload && payload !== "[DONE]") {
772
+ try {
773
+ const data = JSON.parse(payload);
774
+ onBrief(parseBrief(data));
775
+ }
776
+ catch {
777
+ // skip malformed JSON
778
+ }
779
+ }
780
+ }
781
+ }
782
+ }
783
+ })
784
+ .catch((err) => {
785
+ if (err.name !== "AbortError") {
786
+ onError?.(err);
787
+ }
788
+ });
789
+ },
790
+ stop: () => {
791
+ controller?.abort();
792
+ controller = null;
793
+ },
794
+ };
795
+ }
796
+ }
797
+ exports.VeroqClient = VeroqClient;
798
+ /** @deprecated Use VeroqClient instead */
799
+ exports.PolarisClient = VeroqClient;
800
+ //# sourceMappingURL=client.js.map