@uvrn/farm 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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/dist/connectors/CoinGeckoFarm.d.ts +8 -0
  4. package/dist/connectors/CoinGeckoFarm.d.ts.map +1 -0
  5. package/dist/connectors/CoinGeckoFarm.js +34 -0
  6. package/dist/connectors/CoinGeckoFarm.js.map +1 -0
  7. package/dist/connectors/CoinbaseFarm.d.ts +8 -0
  8. package/dist/connectors/CoinbaseFarm.d.ts.map +1 -0
  9. package/dist/connectors/CoinbaseFarm.js +41 -0
  10. package/dist/connectors/CoinbaseFarm.js.map +1 -0
  11. package/dist/connectors/NewsApiFarm.d.ts +8 -0
  12. package/dist/connectors/NewsApiFarm.d.ts.map +1 -0
  13. package/dist/connectors/NewsApiFarm.js +33 -0
  14. package/dist/connectors/NewsApiFarm.js.map +1 -0
  15. package/dist/connectors/PerplexityFarm.d.ts +8 -0
  16. package/dist/connectors/PerplexityFarm.d.ts.map +1 -0
  17. package/dist/connectors/PerplexityFarm.js +52 -0
  18. package/dist/connectors/PerplexityFarm.js.map +1 -0
  19. package/dist/connectors/base/BaseConnector.d.ts +16 -0
  20. package/dist/connectors/base/BaseConnector.d.ts.map +1 -0
  21. package/dist/connectors/base/BaseConnector.js +79 -0
  22. package/dist/connectors/base/BaseConnector.js.map +1 -0
  23. package/dist/connectors/index.d.ts +6 -0
  24. package/dist/connectors/index.d.ts.map +1 -0
  25. package/dist/connectors/index.js +14 -0
  26. package/dist/connectors/index.js.map +1 -0
  27. package/dist/index.d.ts +9 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +34 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/internal/defaultClaimRegistration.d.ts +3 -0
  32. package/dist/internal/defaultClaimRegistration.d.ts.map +1 -0
  33. package/dist/internal/defaultClaimRegistration.js +19 -0
  34. package/dist/internal/defaultClaimRegistration.js.map +1 -0
  35. package/dist/multi/MultiFarm.d.ts +18 -0
  36. package/dist/multi/MultiFarm.d.ts.map +1 -0
  37. package/dist/multi/MultiFarm.js +84 -0
  38. package/dist/multi/MultiFarm.js.map +1 -0
  39. package/dist/registry/ConnectorRegistry.d.ts +13 -0
  40. package/dist/registry/ConnectorRegistry.d.ts.map +1 -0
  41. package/dist/registry/ConnectorRegistry.js +27 -0
  42. package/dist/registry/ConnectorRegistry.js.map +1 -0
  43. package/dist/types/index.d.ts +17 -0
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/dist/types/index.js +15 -0
  46. package/dist/types/index.js.map +1 -0
  47. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Suttle Media LLC / UVRN-org
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # @uvrn/farm
2
+
3
+ `@uvrn/farm` is the UVRN protocol's provider-agnostic ingestion layer. It defines the connector contract used by `@uvrn/agent`, gives you a reusable base class for retry and timeout handling, and includes a few reference connectors that demonstrate the pattern without locking you to any specific third-party service.
4
+
5
+ ## Minimal install
6
+
7
+ ```bash
8
+ npm install @uvrn/farm @uvrn/core @uvrn/agent
9
+ ```
10
+
11
+ `@uvrn/core` and `@uvrn/agent` are peer dependencies. No other UVRN package is required to implement your own connector.
12
+
13
+ ## Bring Your Own Provider
14
+
15
+ `FarmConnector` is the contract. `BaseConnector` is the reusable scaffold. This is the primary use case.
16
+
17
+ ```ts
18
+ import { BaseConnector } from '@uvrn/farm';
19
+ import type { ClaimRegistration, FarmResult } from '@uvrn/farm';
20
+
21
+ class MyConnector extends BaseConnector {
22
+ readonly name = 'MyConnector';
23
+
24
+ async fetch(claim: ClaimRegistration): Promise<FarmResult> {
25
+ return {
26
+ claimId: claim.id,
27
+ sources: [
28
+ {
29
+ url: 'https://example.com/data',
30
+ title: `${claim.label} evidence`,
31
+ snippet: 'Your custom provider result goes here.',
32
+ publishedAt: new Date().toISOString(),
33
+ credibility: 0.8,
34
+ },
35
+ ],
36
+ fetchedAt: new Date().toISOString(),
37
+ durationMs: 10,
38
+ };
39
+ }
40
+ }
41
+ ```
42
+
43
+ Concrete connectors may also expose a convenience `fetch(claim: string)` overload for standalone use.
44
+
45
+ ## Reference Implementations
46
+
47
+ These classes are examples, not requirements:
48
+
49
+ - `CoinGeckoFarm`: public crypto search metadata, no API key required
50
+ - `CoinbaseFarm`: public currency catalog data, no API key required
51
+ - `PerplexityFarm`: research synthesis via Perplexity, API key required
52
+ - `NewsApiFarm`: news article search via NewsAPI, API key required
53
+
54
+ You can import them from the package root or from `@uvrn/farm/connectors`.
55
+
56
+ ```ts
57
+ import { MultiFarm } from '@uvrn/farm';
58
+ import { CoinGeckoFarm, CoinbaseFarm } from '@uvrn/farm/connectors';
59
+
60
+ const farm = new MultiFarm([
61
+ new CoinGeckoFarm(),
62
+ new CoinbaseFarm(),
63
+ ]);
64
+ ```
65
+
66
+ ## MultiFarm
67
+
68
+ `MultiFarm` runs multiple connectors in parallel with `Promise.allSettled()`, merges successful sources, and returns partial results if one connector fails. Set `failFast: true` if you want the first connector error to abort the run.
69
+
70
+ ## Connector Registry
71
+
72
+ `ConnectorRegistry` stores named connectors and can assemble a `MultiFarm` instance from all registered connectors or a named subset.
73
+
74
+ ## Public API
75
+
76
+ - `BaseConnector`
77
+ - `CoinGeckoFarm`
78
+ - `CoinbaseFarm`
79
+ - `PerplexityFarm`
80
+ - `NewsApiFarm`
81
+ - `MultiFarm`
82
+ - `ConnectorRegistry`
83
+ - `registry`
84
+ - `FarmConnector`
85
+ - `FarmResult`
86
+ - `FarmSource`
87
+ - `ClaimRegistration`
88
+ - `ConnectorConfig`
89
+ - `MultiFarmOptions`
90
+ - `FarmConnectorError`
91
+
92
+ ## Dependencies
93
+
94
+ - Peer dependencies: `@uvrn/core`, `@uvrn/agent`
95
+ - Runtime dependencies: none
@@ -0,0 +1,8 @@
1
+ import type { ClaimRegistration, FarmResult } from '../types';
2
+ import { BaseConnector } from './base/BaseConnector';
3
+ export declare class CoinGeckoFarm extends BaseConnector {
4
+ readonly name = "CoinGeckoFarm";
5
+ fetch(claim: ClaimRegistration): Promise<FarmResult>;
6
+ fetch(claim: string): Promise<FarmResult>;
7
+ }
8
+ //# sourceMappingURL=CoinGeckoFarm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoinGeckoFarm.d.ts","sourceRoot":"","sources":["../../src/connectors/CoinGeckoFarm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAWrD,qBAAa,aAAc,SAAQ,aAAa;IAC9C,QAAQ,CAAC,IAAI,mBAAmB;IAE1B,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IACpD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CA8BhD"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoinGeckoFarm = void 0;
4
+ const types_1 = require("../types");
5
+ const BaseConnector_1 = require("./base/BaseConnector");
6
+ class CoinGeckoFarm extends BaseConnector_1.BaseConnector {
7
+ name = 'CoinGeckoFarm';
8
+ async fetch(claim) {
9
+ const registration = typeof claim === 'string' ? this.claimFromString(claim) : claim;
10
+ const startedAt = Date.now();
11
+ try {
12
+ const query = encodeURIComponent(registration.query);
13
+ const payload = await this.requestJson(`https://api.coingecko.com/api/v3/search?query=${query}`);
14
+ const sources = (payload.coins ?? []).slice(0, 5).map((coin) => ({
15
+ url: `https://www.coingecko.com/en/coins/${coin.id}`,
16
+ title: `${coin.name} (${coin.symbol.toUpperCase()})`,
17
+ snippet: coin.market_cap_rank != null
18
+ ? `CoinGecko search match ranked #${coin.market_cap_rank}.`
19
+ : 'CoinGecko search match with market metadata.',
20
+ publishedAt: new Date().toISOString(),
21
+ credibility: 0.85,
22
+ }));
23
+ return this.buildResult(registration, sources, startedAt);
24
+ }
25
+ catch (error) {
26
+ if (error instanceof types_1.FarmConnectorError) {
27
+ throw error;
28
+ }
29
+ throw new types_1.FarmConnectorError(this.name, 'Failed to fetch CoinGecko search results', error);
30
+ }
31
+ }
32
+ }
33
+ exports.CoinGeckoFarm = CoinGeckoFarm;
34
+ //# sourceMappingURL=CoinGeckoFarm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoinGeckoFarm.js","sourceRoot":"","sources":["../../src/connectors/CoinGeckoFarm.ts"],"names":[],"mappings":";;;AACA,oCAA8C;AAE9C,wDAAqD;AAWrD,MAAa,aAAc,SAAQ,6BAAa;IACrC,IAAI,GAAG,eAAe,CAAC;IAIhC,KAAK,CAAC,KAAK,CAAC,KAAiC;QAC3C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}
@@ -0,0 +1,8 @@
1
+ import type { ClaimRegistration, FarmResult } from '../types';
2
+ import { BaseConnector } from './base/BaseConnector';
3
+ export declare class CoinbaseFarm extends BaseConnector {
4
+ readonly name = "CoinbaseFarm";
5
+ fetch(claim: ClaimRegistration): Promise<FarmResult>;
6
+ fetch(claim: string): Promise<FarmResult>;
7
+ }
8
+ //# sourceMappingURL=CoinbaseFarm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoinbaseFarm.d.ts","sourceRoot":"","sources":["../../src/connectors/CoinbaseFarm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAUrD,qBAAa,YAAa,SAAQ,aAAa;IAC7C,QAAQ,CAAC,IAAI,kBAAkB;IAEzB,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IACpD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAsChD"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoinbaseFarm = void 0;
4
+ const types_1 = require("../types");
5
+ const BaseConnector_1 = require("./base/BaseConnector");
6
+ class CoinbaseFarm extends BaseConnector_1.BaseConnector {
7
+ name = 'CoinbaseFarm';
8
+ async fetch(claim) {
9
+ const registration = typeof claim === 'string' ? this.claimFromString(claim) : claim;
10
+ const startedAt = Date.now();
11
+ try {
12
+ const payload = await this.requestJson('https://api.coinbase.com/v2/currencies');
13
+ const query = registration.query.toLowerCase();
14
+ const matches = (payload.data ?? [])
15
+ .filter((currency) => {
16
+ const id = currency.id.toLowerCase();
17
+ const name = currency.name.toLowerCase();
18
+ return id.includes(query) || name.includes(query);
19
+ })
20
+ .slice(0, 5);
21
+ const sources = matches.map((currency) => ({
22
+ url: `https://www.coinbase.com/price/${currency.id.toLowerCase()}`,
23
+ title: `${currency.name} (${currency.id})`,
24
+ snippet: currency.min_size
25
+ ? `Coinbase listing with minimum trade size ${currency.min_size}.`
26
+ : 'Coinbase currency listing available on the public exchange catalog.',
27
+ publishedAt: new Date().toISOString(),
28
+ credibility: 0.9,
29
+ }));
30
+ return this.buildResult(registration, sources, startedAt);
31
+ }
32
+ catch (error) {
33
+ if (error instanceof types_1.FarmConnectorError) {
34
+ throw error;
35
+ }
36
+ throw new types_1.FarmConnectorError(this.name, 'Failed to fetch Coinbase market data', error);
37
+ }
38
+ }
39
+ }
40
+ exports.CoinbaseFarm = CoinbaseFarm;
41
+ //# sourceMappingURL=CoinbaseFarm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoinbaseFarm.js","sourceRoot":"","sources":["../../src/connectors/CoinbaseFarm.ts"],"names":[],"mappings":";;;AACA,oCAA8C;AAE9C,wDAAqD;AAUrD,MAAa,YAAa,SAAQ,6BAAa;IACpC,IAAI,GAAG,cAAc,CAAC;IAI/B,KAAK,CAAC,KAAK,CAAC,KAAiC;QAC3C,MAAM,YAAY,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACrF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CACpC,wCAAwC,CACzC,CAAC;YACF,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAE/C,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;iBACjC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACnB,MAAM,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;gBACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACzC,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACpD,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAEf,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBACzC,GAAG,EAAE,kCAAkC,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE;gBAClE,KAAK,EAAE,GAAG,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,GAAG;gBAC1C,OAAO,EAAE,QAAQ,CAAC,QAAQ;oBACxB,CAAC,CAAC,4CAA4C,QAAQ,CAAC,QAAQ,GAAG;oBAClE,CAAC,CAAC,qEAAqE;gBACzE,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACrC,WAAW,EAAE,GAAG;aACjB,CAAC,CAAC,CAAC;YAEJ,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,0BAAkB,EAAE,CAAC;gBACxC,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,IAAI,0BAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,sCAAsC,EAAE,KAAK,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;CACF;AA1CD,oCA0CC"}
@@ -0,0 +1,8 @@
1
+ import type { ClaimRegistration, FarmResult } from '../types';
2
+ import { BaseConnector } from './base/BaseConnector';
3
+ export declare class NewsApiFarm extends BaseConnector {
4
+ readonly name = "NewsApiFarm";
5
+ fetch(claim: ClaimRegistration): Promise<FarmResult>;
6
+ fetch(claim: string): Promise<FarmResult>;
7
+ }
8
+ //# sourceMappingURL=NewsApiFarm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NewsApiFarm.d.ts","sourceRoot":"","sources":["../../src/connectors/NewsApiFarm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAWrD,qBAAa,WAAY,SAAQ,aAAa;IAC5C,QAAQ,CAAC,IAAI,iBAAiB;IAExB,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IACpD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CA6BhD"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NewsApiFarm = void 0;
4
+ const types_1 = require("../types");
5
+ const BaseConnector_1 = require("./base/BaseConnector");
6
+ class NewsApiFarm extends BaseConnector_1.BaseConnector {
7
+ name = 'NewsApiFarm';
8
+ async fetch(claim) {
9
+ const registration = typeof claim === 'string' ? this.claimFromString(claim) : claim;
10
+ const startedAt = Date.now();
11
+ const apiKey = this.requireApiKey();
12
+ try {
13
+ const query = encodeURIComponent(registration.query);
14
+ const payload = await this.requestJson(`https://newsapi.org/v2/everything?q=${query}&apiKey=${apiKey}`);
15
+ const sources = (payload.articles ?? []).slice(0, 5).map((article) => ({
16
+ url: article.url,
17
+ title: article.title,
18
+ snippet: article.description ?? 'NewsAPI result without a summary description.',
19
+ publishedAt: article.publishedAt,
20
+ credibility: 0.7,
21
+ }));
22
+ return this.buildResult(registration, sources, startedAt);
23
+ }
24
+ catch (error) {
25
+ if (error instanceof types_1.FarmConnectorError) {
26
+ throw error;
27
+ }
28
+ throw new types_1.FarmConnectorError(this.name, 'Failed to fetch NewsAPI results', error);
29
+ }
30
+ }
31
+ }
32
+ exports.NewsApiFarm = NewsApiFarm;
33
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,CAAC;gBACxC,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,IAAI,0BAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;CACF;AAjCD,kCAiCC"}
@@ -0,0 +1,8 @@
1
+ import type { ClaimRegistration, FarmResult } from '../types';
2
+ import { BaseConnector } from './base/BaseConnector';
3
+ export declare class PerplexityFarm extends BaseConnector {
4
+ readonly name = "PerplexityFarm";
5
+ fetch(claim: ClaimRegistration): Promise<FarmResult>;
6
+ fetch(claim: string): Promise<FarmResult>;
7
+ }
8
+ //# sourceMappingURL=PerplexityFarm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PerplexityFarm.d.ts","sourceRoot":"","sources":["../../src/connectors/PerplexityFarm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAUrD,qBAAa,cAAe,SAAQ,aAAa;IAC/C,QAAQ,CAAC,IAAI,oBAAoB;IAE3B,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IACpD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAkDhD"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PerplexityFarm = void 0;
4
+ const types_1 = require("../types");
5
+ const BaseConnector_1 = require("./base/BaseConnector");
6
+ class PerplexityFarm extends BaseConnector_1.BaseConnector {
7
+ name = 'PerplexityFarm';
8
+ async fetch(claim) {
9
+ const registration = typeof claim === 'string' ? this.claimFromString(claim) : claim;
10
+ const startedAt = Date.now();
11
+ const apiKey = this.requireApiKey();
12
+ try {
13
+ const payload = await this.requestJson('https://api.perplexity.ai/chat/completions', {
14
+ method: 'POST',
15
+ headers: {
16
+ Authorization: `Bearer ${apiKey}`,
17
+ 'Content-Type': 'application/json',
18
+ },
19
+ body: JSON.stringify({
20
+ model: 'sonar',
21
+ messages: [
22
+ {
23
+ role: 'user',
24
+ content: `Summarize the latest evidence for: ${registration.query}`,
25
+ },
26
+ ],
27
+ }),
28
+ });
29
+ const content = payload.choices?.[0]?.message?.content?.trim();
30
+ const sources = content
31
+ ? [
32
+ {
33
+ url: 'https://www.perplexity.ai/',
34
+ title: `Perplexity synthesis for ${registration.label}`,
35
+ snippet: content,
36
+ publishedAt: new Date().toISOString(),
37
+ credibility: 0.75,
38
+ },
39
+ ]
40
+ : [];
41
+ return this.buildResult(registration, sources, startedAt);
42
+ }
43
+ catch (error) {
44
+ if (error instanceof types_1.FarmConnectorError) {
45
+ throw error;
46
+ }
47
+ throw new types_1.FarmConnectorError(this.name, 'Failed to fetch Perplexity synthesis', error);
48
+ }
49
+ }
50
+ }
51
+ exports.PerplexityFarm = PerplexityFarm;
52
+ //# sourceMappingURL=PerplexityFarm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PerplexityFarm.js","sourceRoot":"","sources":["../../src/connectors/PerplexityFarm.ts"],"names":[],"mappings":";;;AACA,oCAA8C;AAE9C,wDAAqD;AAUrD,MAAa,cAAe,SAAQ,6BAAa;IACtC,IAAI,GAAG,gBAAgB,CAAC;IAIjC,KAAK,CAAC,KAAK,CAAC,KAAiC;QAC3C,MAAM,YAAY,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACrF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAEpC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CACpC,4CAA4C,EAC5C;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,MAAM,EAAE;oBACjC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,KAAK,EAAE,OAAO;oBACd,QAAQ,EAAE;wBACR;4BACE,IAAI,EAAE,MAAM;4BACZ,OAAO,EAAE,sCAAsC,YAAY,CAAC,KAAK,EAAE;yBACpE;qBACF;iBACF,CAAC;aACH,CACF,CAAC;YAEF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAE/D,MAAM,OAAO,GAAG,OAAO;gBACrB,CAAC,CAAC;oBACE;wBACE,GAAG,EAAE,4BAA4B;wBACjC,KAAK,EAAE,4BAA4B,YAAY,CAAC,KAAK,EAAE;wBACvD,OAAO,EAAE,OAAO;wBAChB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;wBACrC,WAAW,EAAE,IAAI;qBAClB;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YAEP,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,0BAAkB,EAAE,CAAC;gBACxC,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,IAAI,0BAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,sCAAsC,EAAE,KAAK,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;CACF;AAtDD,wCAsDC"}
@@ -0,0 +1,16 @@
1
+ import type { ClaimRegistration, FarmConnector, FarmResult } from '@uvrn/agent';
2
+ import { type ConnectorConfig } from '../../types';
3
+ export declare abstract class BaseConnector implements FarmConnector {
4
+ abstract readonly name: string;
5
+ protected readonly config: Required<Pick<ConnectorConfig, 'timeout' | 'maxRetries'>> & ConnectorConfig;
6
+ constructor(config?: ConnectorConfig);
7
+ abstract fetch(claim: ClaimRegistration): Promise<FarmResult>;
8
+ protected claimFromString(claim: string): ClaimRegistration;
9
+ protected withRetry<T>(fn: () => Promise<T>): Promise<T>;
10
+ protected withTimeout<T>(fn: () => Promise<T>, ms?: number): Promise<T>;
11
+ protected requestJson<T>(url: string, init?: RequestInit): Promise<T>;
12
+ protected buildResult(claim: ClaimRegistration, sources: FarmResult['sources'], startedAt: number): FarmResult;
13
+ protected requireApiKey(): string;
14
+ private sleep;
15
+ }
16
+ //# sourceMappingURL=BaseConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseConnector.d.ts","sourceRoot":"","sources":["../../../src/connectors/base/BaseConnector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhF,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,aAAa,CAAC;AAGvE,8BAAsB,aAAc,YAAW,aAAa;IAC1D,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,YAAY,CAAC,CAAC,GAAG,eAAe,CAAC;gBAE3F,MAAM,GAAE,eAAoB;IAQxC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAE7D,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB;cAI3C,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;cAkB9C,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;cAoB7D,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAc3E,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU;IAS9G,SAAS,CAAC,aAAa,IAAI,MAAM;IAQjC,OAAO,CAAC,KAAK;CAGd"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseConnector = void 0;
4
+ const types_1 = require("../../types");
5
+ const defaultClaimRegistration_1 = require("../../internal/defaultClaimRegistration");
6
+ class BaseConnector {
7
+ config;
8
+ constructor(config = {}) {
9
+ this.config = {
10
+ timeout: 10_000,
11
+ maxRetries: 3,
12
+ ...config,
13
+ };
14
+ }
15
+ claimFromString(claim) {
16
+ return (0, defaultClaimRegistration_1.defaultClaimRegistration)(claim);
17
+ }
18
+ async withRetry(fn) {
19
+ const maxRetries = this.config.maxRetries;
20
+ let lastError;
21
+ for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
22
+ try {
23
+ return await fn();
24
+ }
25
+ catch (error) {
26
+ lastError = error;
27
+ if (attempt < maxRetries) {
28
+ await this.sleep(200 * (2 ** attempt));
29
+ }
30
+ }
31
+ }
32
+ throw new types_1.FarmConnectorError(this.name, 'Max retries exceeded', lastError);
33
+ }
34
+ async withTimeout(fn, ms) {
35
+ const timeout = ms ?? this.config.timeout;
36
+ return new Promise((resolve, reject) => {
37
+ const timer = setTimeout(() => {
38
+ reject(new types_1.FarmConnectorError(this.name, `Timed out after ${timeout}ms`));
39
+ }, timeout);
40
+ void fn()
41
+ .then((value) => {
42
+ clearTimeout(timer);
43
+ resolve(value);
44
+ })
45
+ .catch((error) => {
46
+ clearTimeout(timer);
47
+ reject(error);
48
+ });
49
+ });
50
+ }
51
+ async requestJson(url, init) {
52
+ return this.withRetry(async () => this.withTimeout(async () => {
53
+ const response = await fetch(url, init);
54
+ if (!response.ok) {
55
+ throw new types_1.FarmConnectorError(this.name, `Request failed with status ${response.status}`);
56
+ }
57
+ return response.json();
58
+ }));
59
+ }
60
+ buildResult(claim, sources, startedAt) {
61
+ return {
62
+ claimId: claim.id,
63
+ sources,
64
+ fetchedAt: new Date().toISOString(),
65
+ durationMs: Date.now() - startedAt,
66
+ };
67
+ }
68
+ requireApiKey() {
69
+ if (!this.config.apiKey) {
70
+ throw new types_1.FarmConnectorError(this.name, 'Missing required apiKey');
71
+ }
72
+ return this.config.apiKey;
73
+ }
74
+ sleep(ms) {
75
+ return new Promise((resolve) => setTimeout(resolve, ms));
76
+ }
77
+ }
78
+ exports.BaseConnector = BaseConnector;
79
+ //# sourceMappingURL=BaseConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseConnector.js","sourceRoot":"","sources":["../../../src/connectors/base/BaseConnector.ts"],"names":[],"mappings":";;;AAEA,uCAAuE;AACvE,sFAAmF;AAEnF,MAAsB,aAAa;IAEd,MAAM,CAA8E;IAEvG,YAAY,SAA0B,EAAE;QACtC,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,CAAC;YACb,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAIS,eAAe,CAAC,KAAa;QACrC,OAAO,IAAA,mDAAwB,EAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAES,KAAK,CAAC,SAAS,CAAI,EAAoB;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QAC1C,IAAI,SAAkB,CAAC;QAEvB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;YAC1D,IAAI,CAAC;gBACH,OAAO,MAAM,EAAE,EAAE,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,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAExC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,0BAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,8BAA8B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3F,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;QACvC,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAES,WAAW,CAAC,KAAwB,EAAE,OAA8B,EAAE,SAAiB;QAC/F,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,OAAO;YACP,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACnC,CAAC;IACJ,CAAC;IAES,aAAa;QACrB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,IAAI,0BAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AA1FD,sCA0FC"}
@@ -0,0 +1,6 @@
1
+ export { BaseConnector } from './base/BaseConnector';
2
+ export { CoinGeckoFarm } from './CoinGeckoFarm';
3
+ export { CoinbaseFarm } from './CoinbaseFarm';
4
+ export { PerplexityFarm } from './PerplexityFarm';
5
+ export { NewsApiFarm } from './NewsApiFarm';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NewsApiFarm = exports.PerplexityFarm = exports.CoinbaseFarm = exports.CoinGeckoFarm = exports.BaseConnector = void 0;
4
+ var BaseConnector_1 = require("./base/BaseConnector");
5
+ Object.defineProperty(exports, "BaseConnector", { enumerable: true, get: function () { return BaseConnector_1.BaseConnector; } });
6
+ var CoinGeckoFarm_1 = require("./CoinGeckoFarm");
7
+ Object.defineProperty(exports, "CoinGeckoFarm", { enumerable: true, get: function () { return CoinGeckoFarm_1.CoinGeckoFarm; } });
8
+ var CoinbaseFarm_1 = require("./CoinbaseFarm");
9
+ Object.defineProperty(exports, "CoinbaseFarm", { enumerable: true, get: function () { return CoinbaseFarm_1.CoinbaseFarm; } });
10
+ var PerplexityFarm_1 = require("./PerplexityFarm");
11
+ Object.defineProperty(exports, "PerplexityFarm", { enumerable: true, get: function () { return PerplexityFarm_1.PerplexityFarm; } });
12
+ var NewsApiFarm_1 = require("./NewsApiFarm");
13
+ Object.defineProperty(exports, "NewsApiFarm", { enumerable: true, get: function () { return NewsApiFarm_1.NewsApiFarm; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":";;;AAAA,sDAAqD;AAA5C,8GAAA,aAAa,OAAA;AACtB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA"}
@@ -0,0 +1,9 @@
1
+ export * from './types';
2
+ export { BaseConnector } from './connectors/base/BaseConnector';
3
+ export { CoinGeckoFarm } from './connectors/CoinGeckoFarm';
4
+ export { CoinbaseFarm } from './connectors/CoinbaseFarm';
5
+ export { PerplexityFarm } from './connectors/PerplexityFarm';
6
+ export { NewsApiFarm } from './connectors/NewsApiFarm';
7
+ export { MultiFarm } from './multi/MultiFarm';
8
+ export { ConnectorRegistry, registry } from './registry/ConnectorRegistry';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.registry = exports.ConnectorRegistry = exports.MultiFarm = exports.NewsApiFarm = exports.PerplexityFarm = exports.CoinbaseFarm = exports.CoinGeckoFarm = exports.BaseConnector = void 0;
18
+ __exportStar(require("./types"), exports);
19
+ var BaseConnector_1 = require("./connectors/base/BaseConnector");
20
+ Object.defineProperty(exports, "BaseConnector", { enumerable: true, get: function () { return BaseConnector_1.BaseConnector; } });
21
+ var CoinGeckoFarm_1 = require("./connectors/CoinGeckoFarm");
22
+ Object.defineProperty(exports, "CoinGeckoFarm", { enumerable: true, get: function () { return CoinGeckoFarm_1.CoinGeckoFarm; } });
23
+ var CoinbaseFarm_1 = require("./connectors/CoinbaseFarm");
24
+ Object.defineProperty(exports, "CoinbaseFarm", { enumerable: true, get: function () { return CoinbaseFarm_1.CoinbaseFarm; } });
25
+ var PerplexityFarm_1 = require("./connectors/PerplexityFarm");
26
+ Object.defineProperty(exports, "PerplexityFarm", { enumerable: true, get: function () { return PerplexityFarm_1.PerplexityFarm; } });
27
+ var NewsApiFarm_1 = require("./connectors/NewsApiFarm");
28
+ Object.defineProperty(exports, "NewsApiFarm", { enumerable: true, get: function () { return NewsApiFarm_1.NewsApiFarm; } });
29
+ var MultiFarm_1 = require("./multi/MultiFarm");
30
+ Object.defineProperty(exports, "MultiFarm", { enumerable: true, get: function () { return MultiFarm_1.MultiFarm; } });
31
+ var ConnectorRegistry_1 = require("./registry/ConnectorRegistry");
32
+ Object.defineProperty(exports, "ConnectorRegistry", { enumerable: true, get: function () { return ConnectorRegistry_1.ConnectorRegistry; } });
33
+ Object.defineProperty(exports, "registry", { enumerable: true, get: function () { return ConnectorRegistry_1.registry; } });
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,iEAAgE;AAAvD,8GAAA,aAAa,OAAA;AACtB,4DAA2D;AAAlD,8GAAA,aAAa,OAAA;AACtB,0DAAyD;AAAhD,4GAAA,YAAY,OAAA;AACrB,8DAA6D;AAApD,gHAAA,cAAc,OAAA;AACvB,wDAAuD;AAA9C,0GAAA,WAAW,OAAA;AACpB,+CAA8C;AAArC,sGAAA,SAAS,OAAA;AAClB,kEAA2E;AAAlE,sHAAA,iBAAiB,OAAA;AAAE,6GAAA,QAAQ,OAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ClaimRegistration } from '@uvrn/agent';
2
+ export declare function defaultClaimRegistration(claim: string): ClaimRegistration;
3
+ //# sourceMappingURL=defaultClaimRegistration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultClaimRegistration.d.ts","sourceRoot":"","sources":["../../src/internal/defaultClaimRegistration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAczE"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultClaimRegistration = defaultClaimRegistration;
4
+ function defaultClaimRegistration(claim) {
5
+ return {
6
+ id: claim,
7
+ label: claim,
8
+ query: claim,
9
+ driftConfig: {
10
+ name: 'default',
11
+ curve: 'LINEAR',
12
+ rate: 0.15,
13
+ staleAfterHours: 720,
14
+ scoreFloor: 0,
15
+ },
16
+ intervalMs: 60_000,
17
+ };
18
+ }
19
+ //# sourceMappingURL=defaultClaimRegistration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultClaimRegistration.js","sourceRoot":"","sources":["../../src/internal/defaultClaimRegistration.ts"],"names":[],"mappings":";;AAEA,4DAcC;AAdD,SAAgB,wBAAwB,CAAC,KAAa;IACpD,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,KAAK;QACZ,WAAW,EAAE;YACX,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,IAAI;YACV,eAAe,EAAE,GAAG;YACpB,UAAU,EAAE,CAAC;SACd;QACD,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { ClaimRegistration, FarmConnector, FarmResult } from '../types';
2
+ import { type MultiFarmOptions } from '../types';
3
+ export declare class MultiFarm implements FarmConnector {
4
+ private readonly connectors;
5
+ private readonly options;
6
+ constructor(connectors: Array<FarmConnector & {
7
+ name?: string;
8
+ }>, options?: MultiFarmOptions);
9
+ fetch(claim: ClaimRegistration): Promise<FarmResult>;
10
+ fetch(claim: string): Promise<FarmResult>;
11
+ add(connector: FarmConnector & {
12
+ name?: string;
13
+ }): void;
14
+ remove(name: string): void;
15
+ list(): string[];
16
+ private runWithTimeout;
17
+ }
18
+ //# sourceMappingURL=MultiFarm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiFarm.d.ts","sourceRoot":"","sources":["../../src/multi/MultiFarm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,UAAU,CAAC;AAOrE,qBAAa,SAAU,YAAW,aAAa;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwD;IACnF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6D;gBAEzE,UAAU,EAAE,KAAK,CAAC,aAAa,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,OAAO,GAAE,gBAAqB;IAW1F,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IACpD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAgD/C,GAAG,CAAC,SAAS,EAAE,aAAa,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAIvD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI1B,IAAI,IAAI,MAAM,EAAE;YAIF,cAAc;CAiB7B"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MultiFarm = void 0;
4
+ const types_1 = require("../types");
5
+ const defaultClaimRegistration_1 = require("../internal/defaultClaimRegistration");
6
+ function connectorName(connector) {
7
+ return connector.name ?? connector.constructor.name ?? 'AnonymousConnector';
8
+ }
9
+ class MultiFarm {
10
+ connectors = new Map();
11
+ options;
12
+ constructor(connectors, options = {}) {
13
+ this.options = {
14
+ timeoutMs: options.timeoutMs ?? 10_000,
15
+ failFast: options.failFast ?? false,
16
+ };
17
+ for (const connector of connectors) {
18
+ this.add(connector);
19
+ }
20
+ }
21
+ async fetch(claim) {
22
+ const registration = typeof claim === 'string' ? (0, defaultClaimRegistration_1.defaultClaimRegistration)(claim) : claim;
23
+ const startedAt = Date.now();
24
+ const connectorEntries = Array.from(this.connectors.entries());
25
+ if (connectorEntries.length === 0) {
26
+ return {
27
+ claimId: registration.id,
28
+ sources: [],
29
+ fetchedAt: new Date().toISOString(),
30
+ durationMs: 0,
31
+ };
32
+ }
33
+ const pending = connectorEntries.map(([name, connector]) => this.runWithTimeout(name, connector.fetch(registration)));
34
+ const settled = await Promise.allSettled(pending);
35
+ const sources = [];
36
+ for (let index = 0; index < settled.length; index += 1) {
37
+ const result = settled[index];
38
+ if (result.status === 'fulfilled') {
39
+ sources.push(...result.value.sources);
40
+ continue;
41
+ }
42
+ const [name] = connectorEntries[index];
43
+ const reason = result.reason instanceof Error
44
+ ? result.reason
45
+ : new types_1.FarmConnectorError(name, 'Connector execution failed', result.reason);
46
+ if (this.options.failFast) {
47
+ throw reason;
48
+ }
49
+ }
50
+ return {
51
+ claimId: registration.id,
52
+ sources,
53
+ fetchedAt: new Date().toISOString(),
54
+ durationMs: Date.now() - startedAt,
55
+ };
56
+ }
57
+ add(connector) {
58
+ this.connectors.set(connectorName(connector), connector);
59
+ }
60
+ remove(name) {
61
+ this.connectors.delete(name);
62
+ }
63
+ list() {
64
+ return Array.from(this.connectors.keys());
65
+ }
66
+ async runWithTimeout(name, promise) {
67
+ return new Promise((resolve, reject) => {
68
+ const timer = setTimeout(() => {
69
+ reject(new types_1.FarmConnectorError(name, `Timed out after ${this.options.timeoutMs}ms`));
70
+ }, this.options.timeoutMs);
71
+ void promise
72
+ .then((value) => {
73
+ clearTimeout(timer);
74
+ resolve(value);
75
+ })
76
+ .catch((error) => {
77
+ clearTimeout(timer);
78
+ reject(error);
79
+ });
80
+ });
81
+ }
82
+ }
83
+ exports.MultiFarm = MultiFarm;
84
+ //# sourceMappingURL=MultiFarm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiFarm.js","sourceRoot":"","sources":["../../src/multi/MultiFarm.ts"],"names":[],"mappings":";;;AACA,oCAAqE;AACrE,mFAAgF;AAEhF,SAAS,aAAa,CAAC,SAA4C;IACjE,OAAO,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,WAAW,CAAC,IAAI,IAAI,oBAAoB,CAAC;AAC9E,CAAC;AAED,MAAa,SAAS;IACH,UAAU,GAAG,IAAI,GAAG,EAA6C,CAAC;IAClE,OAAO,CAA6D;IAErF,YAAY,UAAoD,EAAE,UAA4B,EAAE;QAC9F,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,MAAM;YACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,KAAK;SACpC,CAAC;QAEF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,IAAI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3B,KAAK,OAAO;iBACT,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACd,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBACxB,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7FD,8BA6FC"}
@@ -0,0 +1,13 @@
1
+ import type { FarmConnector } from '../types';
2
+ import { MultiFarm } from '../multi/MultiFarm';
3
+ export declare class ConnectorRegistry {
4
+ private readonly connectors;
5
+ register(connector: FarmConnector & {
6
+ name: string;
7
+ }): void;
8
+ get(name: string): FarmConnector | undefined;
9
+ list(): string[];
10
+ createMultiFarm(names?: string[]): MultiFarm;
11
+ }
12
+ export declare const registry: ConnectorRegistry;
13
+ //# sourceMappingURL=ConnectorRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectorRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/ConnectorRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuD;IAElF,QAAQ,CAAC,SAAS,EAAE,aAAa,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAI3D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAI5C,IAAI,IAAI,MAAM,EAAE;IAIhB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS;CAS7C;AAED,eAAO,MAAM,QAAQ,mBAA0B,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registry = exports.ConnectorRegistry = void 0;
4
+ const MultiFarm_1 = require("../multi/MultiFarm");
5
+ class ConnectorRegistry {
6
+ connectors = new Map();
7
+ register(connector) {
8
+ this.connectors.set(connector.name, connector);
9
+ }
10
+ get(name) {
11
+ return this.connectors.get(name);
12
+ }
13
+ list() {
14
+ return Array.from(this.connectors.keys());
15
+ }
16
+ createMultiFarm(names) {
17
+ const selected = names == null
18
+ ? Array.from(this.connectors.values())
19
+ : names
20
+ .map((name) => this.connectors.get(name))
21
+ .filter((connector) => connector != null);
22
+ return new MultiFarm_1.MultiFarm(selected);
23
+ }
24
+ }
25
+ exports.ConnectorRegistry = ConnectorRegistry;
26
+ exports.registry = new ConnectorRegistry();
27
+ //# sourceMappingURL=ConnectorRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectorRegistry.js","sourceRoot":"","sources":["../../src/registry/ConnectorRegistry.ts"],"names":[],"mappings":";;;AAEA,kDAA+C;AAE/C,MAAa,iBAAiB;IACX,UAAU,GAAG,IAAI,GAAG,EAA4C,CAAC;IAElF,QAAQ,CAAC,SAA2C;QAClD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,eAAe,CAAC,KAAgB;QAC9B,MAAM,QAAQ,GAAG,KAAK,IAAI,IAAI;YAC5B,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACtC,CAAC,CAAC,KAAK;iBACF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;iBACxC,MAAM,CAAC,CAAC,SAAS,EAAiD,EAAE,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;QAE/F,OAAO,IAAI,qBAAS,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF;AAxBD,8CAwBC;AAEY,QAAA,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ export type { ClaimRegistration, FarmConnector, FarmResult, FarmSource, } from '@uvrn/agent';
2
+ export interface ConnectorConfig {
3
+ apiKey?: string;
4
+ timeout?: number;
5
+ maxRetries?: number;
6
+ rateLimitPerMinute?: number;
7
+ }
8
+ export interface MultiFarmOptions {
9
+ timeoutMs?: number;
10
+ failFast?: boolean;
11
+ }
12
+ export declare class FarmConnectorError extends Error {
13
+ readonly connectorName: string;
14
+ readonly cause?: unknown;
15
+ constructor(connectorName: string, message: string, cause?: unknown);
16
+ }
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEtB,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAMpE"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FarmConnectorError = void 0;
4
+ class FarmConnectorError extends Error {
5
+ connectorName;
6
+ cause;
7
+ constructor(connectorName, message, cause) {
8
+ super(`[${connectorName}] ${message}`);
9
+ this.name = 'FarmConnectorError';
10
+ this.connectorName = connectorName;
11
+ this.cause = cause;
12
+ }
13
+ }
14
+ exports.FarmConnectorError = FarmConnectorError;
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAmBA,MAAa,kBAAmB,SAAQ,KAAK;IAClC,aAAa,CAAS;IACb,KAAK,CAAW;IAElC,YAAY,aAAqB,EAAE,OAAe,EAAE,KAAe;QACjE,KAAK,CAAC,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAVD,gDAUC"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@uvrn/farm",
3
+ "version": "1.0.0",
4
+ "description": "Standardized data source connectors for the UVRN protocol",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./connectors": {
18
+ "types": "./dist/connectors/index.d.ts",
19
+ "default": "./dist/connectors/index.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "test": "jest",
25
+ "test:watch": "jest --watch",
26
+ "clean": "rm -rf dist"
27
+ },
28
+ "peerDependencies": {
29
+ "@uvrn/core": ">=1.0.0",
30
+ "@uvrn/agent": ">=1.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@uvrn/core": "workspace:*",
34
+ "@uvrn/agent": "workspace:*",
35
+ "@uvrn/test": "workspace:*",
36
+ "@types/jest": "^29.5.0",
37
+ "@types/node": "^20.0.0",
38
+ "jest": "^29.5.0",
39
+ "ts-jest": "^29.1.0",
40
+ "typescript": "^5.3.0"
41
+ },
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ },
45
+ "license": "MIT",
46
+ "keywords": [
47
+ "uvrn",
48
+ "farm",
49
+ "connectors",
50
+ "data-sources",
51
+ "financial",
52
+ "news"
53
+ ],
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/UVRN-org/uvrn-packages.git",
57
+ "directory": "uvrn-farm"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public"
61
+ }
62
+ }