@metamask-previews/ai-controllers 0.8.0-preview-e3275932a → 0.8.0-preview-99421bfe4

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 (38) hide show
  1. package/CHANGELOG.md +0 -7
  2. package/dist/AiDigestController-method-action-types.cjs.map +1 -1
  3. package/dist/AiDigestController-method-action-types.d.cts +3 -3
  4. package/dist/AiDigestController-method-action-types.d.cts.map +1 -1
  5. package/dist/AiDigestController-method-action-types.d.mts +3 -3
  6. package/dist/AiDigestController-method-action-types.d.mts.map +1 -1
  7. package/dist/AiDigestController-method-action-types.mjs.map +1 -1
  8. package/dist/AiDigestController.cjs +99 -11
  9. package/dist/AiDigestController.cjs.map +1 -1
  10. package/dist/AiDigestController.d.cts +5 -4
  11. package/dist/AiDigestController.d.cts.map +1 -1
  12. package/dist/AiDigestController.d.mts +5 -4
  13. package/dist/AiDigestController.d.mts.map +1 -1
  14. package/dist/AiDigestController.mjs +100 -12
  15. package/dist/AiDigestController.mjs.map +1 -1
  16. package/dist/ai-digest-constants.cjs +3 -1
  17. package/dist/ai-digest-constants.cjs.map +1 -1
  18. package/dist/ai-digest-constants.d.cts +2 -0
  19. package/dist/ai-digest-constants.d.cts.map +1 -1
  20. package/dist/ai-digest-constants.d.mts +2 -0
  21. package/dist/ai-digest-constants.d.mts.map +1 -1
  22. package/dist/ai-digest-constants.mjs +2 -0
  23. package/dist/ai-digest-constants.mjs.map +1 -1
  24. package/dist/ai-digest-types.cjs.map +1 -1
  25. package/dist/ai-digest-types.d.cts +24 -5
  26. package/dist/ai-digest-types.d.cts.map +1 -1
  27. package/dist/ai-digest-types.d.mts +24 -5
  28. package/dist/ai-digest-types.d.mts.map +1 -1
  29. package/dist/ai-digest-types.mjs.map +1 -1
  30. package/dist/index.cjs +3 -1
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +2 -2
  33. package/dist/index.d.cts.map +1 -1
  34. package/dist/index.d.mts +2 -2
  35. package/dist/index.d.mts.map +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/index.mjs.map +1 -1
  38. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -9,15 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Changed
11
11
 
12
- - **BREAKING:** `AiDigestController` no longer caches `fetchMarketInsights` or `fetchMarketOverview` results (no TTL, eviction, or persisted `marketInsights` / `marketOverview` state). Each call is a passthrough to `AiDigestService`. Clients must own freshness.
13
- - `AiDigestControllerState` is now an empty object (`Record<string, never>`).
14
- - The constructor no longer accepts a `state` option.
15
12
  - Bump `@metamask/superstruct` from `^3.1.0` to `^3.4.1` ([#9754](https://github.com/MetaMask/core/pull/9754))
16
13
 
17
- ### Removed
18
-
19
- - **BREAKING:** Remove `MarketInsightsEntry`, `MarketOverviewEntry`, `CACHE_DURATION_MS`, and `MAX_CACHE_ENTRIES`. Cache policy belongs to clients.
20
-
21
14
  ## [0.8.0]
22
15
 
23
16
  ### Added
@@ -1 +1 @@
1
- {"version":3,"file":"AiDigestController-method-action-types.cjs","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AiDigestController } from './AiDigestController.js';\n\n/**\n * Fetches market insights for a given asset identifier.\n *\n * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps\n * market symbol (e.g. `ETH`). The service handles choosing the correct API\n * query parameter automatically. Clients own freshness/caching.\n *\n * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).\n * @returns The market insights report, or `null` if none exists.\n */\nexport type AiDigestControllerFetchMarketInsightsAction = {\n type: `AiDigestController:fetchMarketInsights`;\n handler: AiDigestController['fetchMarketInsights'];\n};\n\n/**\n * Fetches the market overview report.\n *\n * Clients own freshness/caching.\n *\n * @returns The market overview report, or `null` if none exists.\n */\nexport type AiDigestControllerFetchMarketOverviewAction = {\n type: `AiDigestController:fetchMarketOverview`;\n handler: AiDigestController['fetchMarketOverview'];\n};\n\n/**\n * Fetches a single market overview front page by id.\n *\n * Unlike the market overview report (which only returns the latest items),\n * this resolves an older item that has since dropped out of the report, so\n * clients can render it directly (e.g. from a deep link).\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists.\n */\nexport type AiDigestControllerFetchFrontPageItemAction = {\n type: `AiDigestController:fetchFrontPageItem`;\n handler: AiDigestController['fetchFrontPageItem'];\n};\n\n/**\n * Union of all AiDigestController action types.\n */\nexport type AiDigestControllerMethodActions =\n | AiDigestControllerFetchMarketInsightsAction\n | AiDigestControllerFetchMarketOverviewAction\n | AiDigestControllerFetchFrontPageItemAction;\n"]}
1
+ {"version":3,"file":"AiDigestController-method-action-types.cjs","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AiDigestController } from './AiDigestController.js';\n\n/**\n * Fetches market insights for a given asset identifier.\n * Returns cached data if still fresh, otherwise calls the service.\n *\n * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps\n * market symbol (e.g. `ETH`). The service handles choosing the correct API\n * query parameter automatically.\n *\n * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).\n * @returns The market insights report, or `null` if none exists.\n */\nexport type AiDigestControllerFetchMarketInsightsAction = {\n type: `AiDigestController:fetchMarketInsights`;\n handler: AiDigestController['fetchMarketInsights'];\n};\n\n/**\n * Fetches the market overview report.\n * Returns cached data if still fresh, otherwise calls the service.\n *\n * @returns The market overview report, or `null` if none exists.\n */\nexport type AiDigestControllerFetchMarketOverviewAction = {\n type: `AiDigestController:fetchMarketOverview`;\n handler: AiDigestController['fetchMarketOverview'];\n};\n\n/**\n * Fetches a single market overview front page by id.\n *\n * Unlike the market overview report (which only returns the latest items),\n * this resolves an older item that has since dropped out of the report, so\n * clients can render it directly (e.g. from a deep link).\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists.\n */\nexport type AiDigestControllerFetchFrontPageItemAction = {\n type: `AiDigestController:fetchFrontPageItem`;\n handler: AiDigestController['fetchFrontPageItem'];\n};\n\n/**\n * Union of all AiDigestController action types.\n */\nexport type AiDigestControllerMethodActions =\n | AiDigestControllerFetchMarketInsightsAction\n | AiDigestControllerFetchMarketOverviewAction\n | AiDigestControllerFetchFrontPageItemAction;\n"]}
@@ -5,10 +5,11 @@
5
5
  import type { AiDigestController } from "./AiDigestController.cjs";
6
6
  /**
7
7
  * Fetches market insights for a given asset identifier.
8
+ * Returns cached data if still fresh, otherwise calls the service.
8
9
  *
9
10
  * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps
10
11
  * market symbol (e.g. `ETH`). The service handles choosing the correct API
11
- * query parameter automatically. Clients own freshness/caching.
12
+ * query parameter automatically.
12
13
  *
13
14
  * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).
14
15
  * @returns The market insights report, or `null` if none exists.
@@ -19,8 +20,7 @@ export type AiDigestControllerFetchMarketInsightsAction = {
19
20
  };
20
21
  /**
21
22
  * Fetches the market overview report.
22
- *
23
- * Clients own freshness/caching.
23
+ * Returns cached data if still fresh, otherwise calls the service.
24
24
  *
25
25
  * @returns The market overview report, or `null` if none exists.
26
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AiDigestController-method-action-types.d.cts","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iCAAgC;AAElE;;;;;;;;;GASG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,2CAA2C,GAC3C,2CAA2C,GAC3C,0CAA0C,CAAC"}
1
+ {"version":3,"file":"AiDigestController-method-action-types.d.cts","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iCAAgC;AAElE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,2CAA2C,GAC3C,2CAA2C,GAC3C,0CAA0C,CAAC"}
@@ -5,10 +5,11 @@
5
5
  import type { AiDigestController } from "./AiDigestController.mjs";
6
6
  /**
7
7
  * Fetches market insights for a given asset identifier.
8
+ * Returns cached data if still fresh, otherwise calls the service.
8
9
  *
9
10
  * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps
10
11
  * market symbol (e.g. `ETH`). The service handles choosing the correct API
11
- * query parameter automatically. Clients own freshness/caching.
12
+ * query parameter automatically.
12
13
  *
13
14
  * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).
14
15
  * @returns The market insights report, or `null` if none exists.
@@ -19,8 +20,7 @@ export type AiDigestControllerFetchMarketInsightsAction = {
19
20
  };
20
21
  /**
21
22
  * Fetches the market overview report.
22
- *
23
- * Clients own freshness/caching.
23
+ * Returns cached data if still fresh, otherwise calls the service.
24
24
  *
25
25
  * @returns The market overview report, or `null` if none exists.
26
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AiDigestController-method-action-types.d.mts","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iCAAgC;AAElE;;;;;;;;;GASG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,2CAA2C,GAC3C,2CAA2C,GAC3C,0CAA0C,CAAC"}
1
+ {"version":3,"file":"AiDigestController-method-action-types.d.mts","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iCAAgC;AAElE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,2CAA2C,GAC3C,2CAA2C,GAC3C,0CAA0C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AiDigestController-method-action-types.mjs","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AiDigestController } from './AiDigestController.js';\n\n/**\n * Fetches market insights for a given asset identifier.\n *\n * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps\n * market symbol (e.g. `ETH`). The service handles choosing the correct API\n * query parameter automatically. Clients own freshness/caching.\n *\n * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).\n * @returns The market insights report, or `null` if none exists.\n */\nexport type AiDigestControllerFetchMarketInsightsAction = {\n type: `AiDigestController:fetchMarketInsights`;\n handler: AiDigestController['fetchMarketInsights'];\n};\n\n/**\n * Fetches the market overview report.\n *\n * Clients own freshness/caching.\n *\n * @returns The market overview report, or `null` if none exists.\n */\nexport type AiDigestControllerFetchMarketOverviewAction = {\n type: `AiDigestController:fetchMarketOverview`;\n handler: AiDigestController['fetchMarketOverview'];\n};\n\n/**\n * Fetches a single market overview front page by id.\n *\n * Unlike the market overview report (which only returns the latest items),\n * this resolves an older item that has since dropped out of the report, so\n * clients can render it directly (e.g. from a deep link).\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists.\n */\nexport type AiDigestControllerFetchFrontPageItemAction = {\n type: `AiDigestController:fetchFrontPageItem`;\n handler: AiDigestController['fetchFrontPageItem'];\n};\n\n/**\n * Union of all AiDigestController action types.\n */\nexport type AiDigestControllerMethodActions =\n | AiDigestControllerFetchMarketInsightsAction\n | AiDigestControllerFetchMarketOverviewAction\n | AiDigestControllerFetchFrontPageItemAction;\n"]}
1
+ {"version":3,"file":"AiDigestController-method-action-types.mjs","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AiDigestController } from './AiDigestController.js';\n\n/**\n * Fetches market insights for a given asset identifier.\n * Returns cached data if still fresh, otherwise calls the service.\n *\n * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps\n * market symbol (e.g. `ETH`). The service handles choosing the correct API\n * query parameter automatically.\n *\n * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).\n * @returns The market insights report, or `null` if none exists.\n */\nexport type AiDigestControllerFetchMarketInsightsAction = {\n type: `AiDigestController:fetchMarketInsights`;\n handler: AiDigestController['fetchMarketInsights'];\n};\n\n/**\n * Fetches the market overview report.\n * Returns cached data if still fresh, otherwise calls the service.\n *\n * @returns The market overview report, or `null` if none exists.\n */\nexport type AiDigestControllerFetchMarketOverviewAction = {\n type: `AiDigestController:fetchMarketOverview`;\n handler: AiDigestController['fetchMarketOverview'];\n};\n\n/**\n * Fetches a single market overview front page by id.\n *\n * Unlike the market overview report (which only returns the latest items),\n * this resolves an older item that has since dropped out of the report, so\n * clients can render it directly (e.g. from a deep link).\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists.\n */\nexport type AiDigestControllerFetchFrontPageItemAction = {\n type: `AiDigestController:fetchFrontPageItem`;\n handler: AiDigestController['fetchFrontPageItem'];\n};\n\n/**\n * Union of all AiDigestController action types.\n */\nexport type AiDigestControllerMethodActions =\n | AiDigestControllerFetchMarketInsightsAction\n | AiDigestControllerFetchMarketOverviewAction\n | AiDigestControllerFetchFrontPageItemAction;\n"]}
@@ -10,39 +10,60 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _AiDigestController_digestService;
13
+ var _AiDigestController_instances, _AiDigestController_digestService, _AiDigestController_evictStaleCachedEntries;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AiDigestController = exports.getDefaultAiDigestControllerState = void 0;
16
16
  const base_controller_1 = require("@metamask/base-controller");
17
17
  const ai_digest_constants_js_1 = require("./ai-digest-constants.cjs");
18
18
  function getDefaultAiDigestControllerState() {
19
- return {};
19
+ return {
20
+ marketInsights: {},
21
+ marketOverview: null,
22
+ };
20
23
  }
21
24
  exports.getDefaultAiDigestControllerState = getDefaultAiDigestControllerState;
22
- const aiDigestControllerMetadata = {};
25
+ const aiDigestControllerMetadata = {
26
+ marketInsights: {
27
+ persist: true,
28
+ includeInDebugSnapshot: true,
29
+ includeInStateLogs: true,
30
+ usedInUi: true,
31
+ },
32
+ marketOverview: {
33
+ persist: true,
34
+ includeInDebugSnapshot: true,
35
+ includeInStateLogs: true,
36
+ usedInUi: true,
37
+ },
38
+ };
23
39
  const MESSENGER_EXPOSED_METHODS = [
24
40
  'fetchMarketInsights',
25
41
  'fetchMarketOverview',
26
42
  'fetchFrontPageItem',
27
43
  ];
28
44
  class AiDigestController extends base_controller_1.BaseController {
29
- constructor({ messenger, digestService }) {
45
+ constructor({ messenger, state, digestService }) {
30
46
  super({
31
47
  name: ai_digest_constants_js_1.controllerName,
32
48
  metadata: aiDigestControllerMetadata,
33
- state: getDefaultAiDigestControllerState(),
49
+ state: {
50
+ ...getDefaultAiDigestControllerState(),
51
+ ...state,
52
+ },
34
53
  messenger,
35
54
  });
55
+ _AiDigestController_instances.add(this);
36
56
  _AiDigestController_digestService.set(this, void 0);
37
57
  __classPrivateFieldSet(this, _AiDigestController_digestService, digestService, "f");
38
58
  this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
39
59
  }
40
60
  /**
41
61
  * Fetches market insights for a given asset identifier.
62
+ * Returns cached data if still fresh, otherwise calls the service.
42
63
  *
43
64
  * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps
44
65
  * market symbol (e.g. `ETH`). The service handles choosing the correct API
45
- * query parameter automatically. Clients own freshness/caching.
66
+ * query parameter automatically.
46
67
  *
47
68
  * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).
48
69
  * @returns The market insights report, or `null` if none exists.
@@ -51,17 +72,61 @@ class AiDigestController extends base_controller_1.BaseController {
51
72
  if (!assetIdentifier) {
52
73
  throw new Error(ai_digest_constants_js_1.AiDigestControllerErrorMessage.INVALID_ASSET_IDENTIFIER);
53
74
  }
54
- return __classPrivateFieldGet(this, _AiDigestController_digestService, "f").searchDigest(assetIdentifier);
75
+ const existing = this.state.marketInsights[assetIdentifier];
76
+ if (existing) {
77
+ const age = Date.now() - existing.fetchedAt;
78
+ if (age < ai_digest_constants_js_1.CACHE_DURATION_MS) {
79
+ return existing.data;
80
+ }
81
+ }
82
+ const data = await __classPrivateFieldGet(this, _AiDigestController_digestService, "f").searchDigest(assetIdentifier);
83
+ if (data === null) {
84
+ // No insights available for this asset — clear any stale cache entry
85
+ this.update((state) => {
86
+ delete state.marketInsights[assetIdentifier];
87
+ });
88
+ return null;
89
+ }
90
+ const entry = {
91
+ assetIdentifier,
92
+ fetchedAt: Date.now(),
93
+ data,
94
+ };
95
+ this.update((state) => {
96
+ state.marketInsights[assetIdentifier] = entry;
97
+ __classPrivateFieldGet(this, _AiDigestController_instances, "m", _AiDigestController_evictStaleCachedEntries).call(this, state.marketInsights);
98
+ });
99
+ return data;
55
100
  }
56
101
  /**
57
102
  * Fetches the market overview report.
58
- *
59
- * Clients own freshness/caching.
103
+ * Returns cached data if still fresh, otherwise calls the service.
60
104
  *
61
105
  * @returns The market overview report, or `null` if none exists.
62
106
  */
63
107
  async fetchMarketOverview() {
64
- return __classPrivateFieldGet(this, _AiDigestController_digestService, "f").fetchMarketOverview();
108
+ const existing = this.state.marketOverview;
109
+ if (existing) {
110
+ const age = Date.now() - existing.fetchedAt;
111
+ if (age < ai_digest_constants_js_1.CACHE_DURATION_MS) {
112
+ return existing.data;
113
+ }
114
+ }
115
+ const data = await __classPrivateFieldGet(this, _AiDigestController_digestService, "f").fetchMarketOverview();
116
+ if (data === null) {
117
+ this.update((state) => {
118
+ state.marketOverview = null;
119
+ });
120
+ return null;
121
+ }
122
+ const entry = {
123
+ fetchedAt: Date.now(),
124
+ data,
125
+ };
126
+ this.update((state) => {
127
+ state.marketOverview = entry;
128
+ });
129
+ return data;
65
130
  }
66
131
  /**
67
132
  * Fetches a single market overview front page by id.
@@ -81,5 +146,28 @@ class AiDigestController extends base_controller_1.BaseController {
81
146
  }
82
147
  }
83
148
  exports.AiDigestController = AiDigestController;
84
- _AiDigestController_digestService = new WeakMap();
149
+ _AiDigestController_digestService = new WeakMap(), _AiDigestController_instances = new WeakSet(), _AiDigestController_evictStaleCachedEntries = function _AiDigestController_evictStaleCachedEntries(cache) {
150
+ const now = Date.now();
151
+ const entries = Object.entries(cache);
152
+ const keysToDelete = [];
153
+ const freshEntries = [];
154
+ for (const [key, entry] of entries) {
155
+ if (now - entry.fetchedAt >= ai_digest_constants_js_1.CACHE_DURATION_MS) {
156
+ keysToDelete.push(key);
157
+ }
158
+ else {
159
+ freshEntries.push([key, entry]);
160
+ }
161
+ }
162
+ if (freshEntries.length > ai_digest_constants_js_1.MAX_CACHE_ENTRIES) {
163
+ freshEntries.sort((a, b) => a[1].fetchedAt - b[1].fetchedAt);
164
+ const entriesToRemove = freshEntries.length - ai_digest_constants_js_1.MAX_CACHE_ENTRIES;
165
+ for (let i = 0; i < entriesToRemove; i++) {
166
+ keysToDelete.push(freshEntries[i][0]);
167
+ }
168
+ }
169
+ for (const key of keysToDelete) {
170
+ delete cache[key];
171
+ }
172
+ };
85
173
  //# sourceMappingURL=AiDigestController.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AiDigestController.cjs","sourceRoot":"","sources":["../src/AiDigestController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAG3D,sEAGkC;AAqClC,SAAgB,iCAAiC;IAC/C,OAAO,EAAE,CAAC;AACZ,CAAC;AAFD,8EAEC;AAED,MAAM,0BAA0B,GAA2C,EAAE,CAAC;AAE9E,MAAM,yBAAyB,GAAG;IAChC,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;CACZ,CAAC;AAEX,MAAa,kBAAmB,SAAQ,gCAIvC;IAGC,YAAY,EAAE,SAAS,EAAE,aAAa,EAA6B;QACjE,KAAK,CAAC;YACJ,IAAI,EAAE,uCAAc;YACpB,QAAQ,EAAE,0BAA0B;YACpC,KAAK,EAAE,iCAAiC,EAAE;YAC1C,SAAS;SACV,CAAC,CAAC;QARI,oDAA8B;QAUrC,uBAAA,IAAI,qCAAkB,aAAa,MAAA,CAAC;QACpC,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,mBAAmB,CACvB,eAAuB;QAEvB,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,uDAA8B,CAAC,wBAAwB,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,uBAAA,IAAI,yCAAe,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB;QACvB,OAAO,uBAAA,IAAI,yCAAe,CAAC,mBAAmB,EAAE,CAAC;IACnD,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,kBAAkB,CACtB,EAAU;QAEV,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,uDAA8B,CAAC,qBAAqB,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,uBAAA,IAAI,yCAAe,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF;AAxED,gDAwEC","sourcesContent":["import type {\n StateMetadata,\n ControllerStateChangeEvent,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport {\n AiDigestControllerErrorMessage,\n controllerName,\n} from './ai-digest-constants.js';\nimport type {\n AiDigestControllerState,\n DigestService,\n MarketInsightsReport,\n MarketOverview,\n MarketOverviewFrontPage,\n} from './ai-digest-types.js';\nimport type { AiDigestControllerMethodActions } from './AiDigestController-method-action-types.js';\n\nexport type AiDigestControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AiDigestControllerState\n>;\n\nexport type AiDigestControllerActions =\n | AiDigestControllerGetStateAction\n | AiDigestControllerMethodActions;\n\nexport type AiDigestControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AiDigestControllerState\n>;\n\nexport type AiDigestControllerEvents = AiDigestControllerStateChangeEvent;\n\nexport type AiDigestControllerMessenger = Messenger<\n typeof controllerName,\n AiDigestControllerActions,\n AiDigestControllerEvents\n>;\n\nexport type AiDigestControllerOptions = {\n messenger: AiDigestControllerMessenger;\n digestService: DigestService;\n};\n\nexport function getDefaultAiDigestControllerState(): AiDigestControllerState {\n return {};\n}\n\nconst aiDigestControllerMetadata: StateMetadata<AiDigestControllerState> = {};\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'fetchMarketInsights',\n 'fetchMarketOverview',\n 'fetchFrontPageItem',\n] as const;\n\nexport class AiDigestController extends BaseController<\n typeof controllerName,\n AiDigestControllerState,\n AiDigestControllerMessenger\n> {\n readonly #digestService: DigestService;\n\n constructor({ messenger, digestService }: AiDigestControllerOptions) {\n super({\n name: controllerName,\n metadata: aiDigestControllerMetadata,\n state: getDefaultAiDigestControllerState(),\n messenger,\n });\n\n this.#digestService = digestService;\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches market insights for a given asset identifier.\n *\n * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps\n * market symbol (e.g. `ETH`). The service handles choosing the correct API\n * query parameter automatically. Clients own freshness/caching.\n *\n * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).\n * @returns The market insights report, or `null` if none exists.\n */\n async fetchMarketInsights(\n assetIdentifier: string,\n ): Promise<MarketInsightsReport | null> {\n if (!assetIdentifier) {\n throw new Error(AiDigestControllerErrorMessage.INVALID_ASSET_IDENTIFIER);\n }\n\n return this.#digestService.searchDigest(assetIdentifier);\n }\n\n /**\n * Fetches the market overview report.\n *\n * Clients own freshness/caching.\n *\n * @returns The market overview report, or `null` if none exists.\n */\n async fetchMarketOverview(): Promise<MarketOverview | null> {\n return this.#digestService.fetchMarketOverview();\n }\n\n /**\n * Fetches a single market overview front page by id.\n *\n * Unlike the market overview report (which only returns the latest items),\n * this resolves an older item that has since dropped out of the report, so\n * clients can render it directly (e.g. from a deep link).\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists.\n */\n async fetchFrontPageItem(\n id: string,\n ): Promise<MarketOverviewFrontPage | null> {\n if (!id) {\n throw new Error(AiDigestControllerErrorMessage.INVALID_FRONT_PAGE_ID);\n }\n\n return this.#digestService.fetchFrontPageItem(id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;aAAM,CAAC;YACN,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,IAAI,YAAY,CAAC,MAAM,GAAG,0CAAiB,EAAE,CAAC;QAC5C,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC7D,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,GAAG,0CAAiB,CAAC;QAChE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["import type {\n StateMetadata,\n ControllerStateChangeEvent,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport {\n AiDigestControllerErrorMessage,\n controllerName,\n CACHE_DURATION_MS,\n MAX_CACHE_ENTRIES,\n} from './ai-digest-constants.js';\nimport type {\n AiDigestControllerState,\n DigestService,\n MarketInsightsReport,\n MarketInsightsEntry,\n MarketOverview,\n MarketOverviewEntry,\n MarketOverviewFrontPage,\n} from './ai-digest-types.js';\nimport type { AiDigestControllerMethodActions } from './AiDigestController-method-action-types.js';\n\nexport type AiDigestControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AiDigestControllerState\n>;\n\nexport type AiDigestControllerActions =\n | AiDigestControllerGetStateAction\n | AiDigestControllerMethodActions;\n\nexport type AiDigestControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AiDigestControllerState\n>;\n\nexport type AiDigestControllerEvents = AiDigestControllerStateChangeEvent;\n\nexport type AiDigestControllerMessenger = Messenger<\n typeof controllerName,\n AiDigestControllerActions,\n AiDigestControllerEvents\n>;\n\nexport type AiDigestControllerOptions = {\n messenger: AiDigestControllerMessenger;\n state?: Partial<AiDigestControllerState>;\n digestService: DigestService;\n};\n\nexport function getDefaultAiDigestControllerState(): AiDigestControllerState {\n return {\n marketInsights: {},\n marketOverview: null,\n };\n}\n\nconst aiDigestControllerMetadata: StateMetadata<AiDigestControllerState> = {\n marketInsights: {\n persist: true,\n includeInDebugSnapshot: true,\n includeInStateLogs: true,\n usedInUi: true,\n },\n marketOverview: {\n persist: true,\n includeInDebugSnapshot: true,\n includeInStateLogs: true,\n usedInUi: true,\n },\n};\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'fetchMarketInsights',\n 'fetchMarketOverview',\n 'fetchFrontPageItem',\n] as const;\n\nexport class AiDigestController extends BaseController<\n typeof controllerName,\n AiDigestControllerState,\n AiDigestControllerMessenger\n> {\n readonly #digestService: DigestService;\n\n constructor({ messenger, state, digestService }: AiDigestControllerOptions) {\n super({\n name: controllerName,\n metadata: aiDigestControllerMetadata,\n state: {\n ...getDefaultAiDigestControllerState(),\n ...state,\n },\n messenger,\n });\n\n this.#digestService = digestService;\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches market insights for a given asset identifier.\n * Returns cached data if still fresh, otherwise calls the service.\n *\n * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps\n * market symbol (e.g. `ETH`). The service handles choosing the correct API\n * query parameter automatically.\n *\n * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).\n * @returns The market insights report, or `null` if none exists.\n */\n async fetchMarketInsights(\n assetIdentifier: string,\n ): Promise<MarketInsightsReport | null> {\n if (!assetIdentifier) {\n throw new Error(AiDigestControllerErrorMessage.INVALID_ASSET_IDENTIFIER);\n }\n\n const existing = this.state.marketInsights[assetIdentifier];\n if (existing) {\n const age = Date.now() - existing.fetchedAt;\n if (age < CACHE_DURATION_MS) {\n return existing.data;\n }\n }\n\n const data = await this.#digestService.searchDigest(assetIdentifier);\n\n if (data === null) {\n // No insights available for this asset — clear any stale cache entry\n this.update((state) => {\n delete state.marketInsights[assetIdentifier];\n });\n return null;\n }\n\n const entry: MarketInsightsEntry = {\n assetIdentifier,\n fetchedAt: Date.now(),\n data,\n };\n\n this.update((state) => {\n state.marketInsights[assetIdentifier] = entry;\n this.#evictStaleCachedEntries(state.marketInsights);\n });\n\n return data;\n }\n\n /**\n * Fetches the market overview report.\n * Returns cached data if still fresh, otherwise calls the service.\n *\n * @returns The market overview report, or `null` if none exists.\n */\n async fetchMarketOverview(): Promise<MarketOverview | null> {\n const existing = this.state.marketOverview;\n if (existing) {\n const age = Date.now() - existing.fetchedAt;\n if (age < CACHE_DURATION_MS) {\n return existing.data;\n }\n }\n\n const data = await this.#digestService.fetchMarketOverview();\n\n if (data === null) {\n this.update((state) => {\n state.marketOverview = null;\n });\n return null;\n }\n\n const entry: MarketOverviewEntry = {\n fetchedAt: Date.now(),\n data,\n };\n\n this.update((state) => {\n state.marketOverview = entry;\n });\n\n return data;\n }\n\n /**\n * Fetches a single market overview front page by id.\n *\n * Unlike the market overview report (which only returns the latest items),\n * this resolves an older item that has since dropped out of the report, so\n * clients can render it directly (e.g. from a deep link).\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists.\n */\n async fetchFrontPageItem(\n id: string,\n ): Promise<MarketOverviewFrontPage | null> {\n if (!id) {\n throw new Error(AiDigestControllerErrorMessage.INVALID_FRONT_PAGE_ID);\n }\n\n return this.#digestService.fetchFrontPageItem(id);\n }\n\n /**\n * Evicts stale (TTL expired) and oldest entries (FIFO) if cache exceeds max size.\n *\n * @param cache - The cache record to evict entries from.\n */\n #evictStaleCachedEntries<EntryType extends { fetchedAt: number }>(\n cache: Record<string, EntryType>,\n ): void {\n const now = Date.now();\n const entries = Object.entries(cache);\n const keysToDelete: string[] = [];\n const freshEntries: [string, EntryType][] = [];\n\n for (const [key, entry] of entries) {\n if (now - entry.fetchedAt >= CACHE_DURATION_MS) {\n keysToDelete.push(key);\n } else {\n freshEntries.push([key, entry]);\n }\n }\n\n if (freshEntries.length > MAX_CACHE_ENTRIES) {\n freshEntries.sort((a, b) => a[1].fetchedAt - b[1].fetchedAt);\n const entriesToRemove = freshEntries.length - MAX_CACHE_ENTRIES;\n for (let i = 0; i < entriesToRemove; i++) {\n keysToDelete.push(freshEntries[i][0]);\n }\n }\n\n for (const key of keysToDelete) {\n delete cache[key];\n }\n }\n}\n"]}
@@ -11,18 +11,20 @@ export type AiDigestControllerEvents = AiDigestControllerStateChangeEvent;
11
11
  export type AiDigestControllerMessenger = Messenger<typeof controllerName, AiDigestControllerActions, AiDigestControllerEvents>;
12
12
  export type AiDigestControllerOptions = {
13
13
  messenger: AiDigestControllerMessenger;
14
+ state?: Partial<AiDigestControllerState>;
14
15
  digestService: DigestService;
15
16
  };
16
17
  export declare function getDefaultAiDigestControllerState(): AiDigestControllerState;
17
18
  export declare class AiDigestController extends BaseController<typeof controllerName, AiDigestControllerState, AiDigestControllerMessenger> {
18
19
  #private;
19
- constructor({ messenger, digestService }: AiDigestControllerOptions);
20
+ constructor({ messenger, state, digestService }: AiDigestControllerOptions);
20
21
  /**
21
22
  * Fetches market insights for a given asset identifier.
23
+ * Returns cached data if still fresh, otherwise calls the service.
22
24
  *
23
25
  * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps
24
26
  * market symbol (e.g. `ETH`). The service handles choosing the correct API
25
- * query parameter automatically. Clients own freshness/caching.
27
+ * query parameter automatically.
26
28
  *
27
29
  * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).
28
30
  * @returns The market insights report, or `null` if none exists.
@@ -30,8 +32,7 @@ export declare class AiDigestController extends BaseController<typeof controller
30
32
  fetchMarketInsights(assetIdentifier: string): Promise<MarketInsightsReport | null>;
31
33
  /**
32
34
  * Fetches the market overview report.
33
- *
34
- * Clients own freshness/caching.
35
+ * Returns cached data if still fresh, otherwise calls the service.
35
36
  *
36
37
  * @returns The market overview report, or `null` if none exists.
37
38
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AiDigestController.d.cts","sourceRoot":"","sources":["../src/AiDigestController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,0BAA0B,EAC1B,wBAAwB,EACzB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAEL,cAAc,EACf,kCAAiC;AAClC,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACxB,8BAA6B;AAC9B,OAAO,KAAK,EAAE,+BAA+B,EAAE,qDAAoD;AAEnG,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,CACrE,OAAO,cAAc,EACrB,uBAAuB,CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACjC,gCAAgC,GAChC,+BAA+B,CAAC;AAEpC,MAAM,MAAM,kCAAkC,GAAG,0BAA0B,CACzE,OAAO,cAAc,EACrB,uBAAuB,CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,kCAAkC,CAAC;AAE1E,MAAM,MAAM,2BAA2B,GAAG,SAAS,CACjD,OAAO,cAAc,EACrB,yBAAyB,EACzB,wBAAwB,CACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,2BAA2B,CAAC;IACvC,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,wBAAgB,iCAAiC,IAAI,uBAAuB,CAE3E;AAUD,qBAAa,kBAAmB,SAAQ,cAAc,CACpD,OAAO,cAAc,EAC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vC,KAAK,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzC,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,wBAAgB,iCAAiC,IAAI,uBAAuB,CAK3E;AAuBD,qBAAa,kBAAmB,SAAQ,cAAc,CACpD,OAAO,cAAc,EACrB,uBAAuB,EACvB,2BAA2B,CAC5B;;gBAGa,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,yBAAyB;IAkB1E;;;;;;;;;;OAUG;IACG,mBAAmB,CACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAqCvC;;;;;OAKG;IACG,mBAAmB,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IA8B3D;;;;;;;;;OASG;IACG,kBAAkB,CACtB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;CAyC3C"}
@@ -11,18 +11,20 @@ export type AiDigestControllerEvents = AiDigestControllerStateChangeEvent;
11
11
  export type AiDigestControllerMessenger = Messenger<typeof controllerName, AiDigestControllerActions, AiDigestControllerEvents>;
12
12
  export type AiDigestControllerOptions = {
13
13
  messenger: AiDigestControllerMessenger;
14
+ state?: Partial<AiDigestControllerState>;
14
15
  digestService: DigestService;
15
16
  };
16
17
  export declare function getDefaultAiDigestControllerState(): AiDigestControllerState;
17
18
  export declare class AiDigestController extends BaseController<typeof controllerName, AiDigestControllerState, AiDigestControllerMessenger> {
18
19
  #private;
19
- constructor({ messenger, digestService }: AiDigestControllerOptions);
20
+ constructor({ messenger, state, digestService }: AiDigestControllerOptions);
20
21
  /**
21
22
  * Fetches market insights for a given asset identifier.
23
+ * Returns cached data if still fresh, otherwise calls the service.
22
24
  *
23
25
  * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps
24
26
  * market symbol (e.g. `ETH`). The service handles choosing the correct API
25
- * query parameter automatically. Clients own freshness/caching.
27
+ * query parameter automatically.
26
28
  *
27
29
  * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).
28
30
  * @returns The market insights report, or `null` if none exists.
@@ -30,8 +32,7 @@ export declare class AiDigestController extends BaseController<typeof controller
30
32
  fetchMarketInsights(assetIdentifier: string): Promise<MarketInsightsReport | null>;
31
33
  /**
32
34
  * Fetches the market overview report.
33
- *
34
- * Clients own freshness/caching.
35
+ * Returns cached data if still fresh, otherwise calls the service.
35
36
  *
36
37
  * @returns The market overview report, or `null` if none exists.
37
38
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AiDigestController.d.mts","sourceRoot":"","sources":["../src/AiDigestController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,0BAA0B,EAC1B,wBAAwB,EACzB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAEL,cAAc,EACf,kCAAiC;AAClC,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACxB,8BAA6B;AAC9B,OAAO,KAAK,EAAE,+BAA+B,EAAE,qDAAoD;AAEnG,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,CACrE,OAAO,cAAc,EACrB,uBAAuB,CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACjC,gCAAgC,GAChC,+BAA+B,CAAC;AAEpC,MAAM,MAAM,kCAAkC,GAAG,0BAA0B,CACzE,OAAO,cAAc,EACrB,uBAAuB,CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,kCAAkC,CAAC;AAE1E,MAAM,MAAM,2BAA2B,GAAG,SAAS,CACjD,OAAO,cAAc,EACrB,yBAAyB,EACzB,wBAAwB,CACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,2BAA2B,CAAC;IACvC,aAAa,EAAE,aAAa,CAAC;CAC9B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ACrB,yBAAyB,EACzB,wBAAwB,CACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,2BAA2B,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzC,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,wBAAgB,iCAAiC,IAAI,uBAAuB,CAK3E;AAuBD,qBAAa,kBAAmB,SAAQ,cAAc,CACpD,OAAO,cAAc,EACrB,uBAAuB,EACvB,2BAA2B,CAC5B;;gBAGa,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,yBAAyB;IAkB1E;;;;;;;;;;OAUG;IACG,mBAAmB,CACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAqCvC;;;;;OAKG;IACG,mBAAmB,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IA8B3D;;;;;;;;;OASG;IACG,kBAAkB,CACtB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;CAyC3C"}
@@ -9,36 +9,57 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _AiDigestController_digestService;
12
+ var _AiDigestController_instances, _AiDigestController_digestService, _AiDigestController_evictStaleCachedEntries;
13
13
  import { BaseController } from "@metamask/base-controller";
14
- import { AiDigestControllerErrorMessage, controllerName } from "./ai-digest-constants.mjs";
14
+ import { AiDigestControllerErrorMessage, controllerName, CACHE_DURATION_MS, MAX_CACHE_ENTRIES } from "./ai-digest-constants.mjs";
15
15
  export function getDefaultAiDigestControllerState() {
16
- return {};
16
+ return {
17
+ marketInsights: {},
18
+ marketOverview: null,
19
+ };
17
20
  }
18
- const aiDigestControllerMetadata = {};
21
+ const aiDigestControllerMetadata = {
22
+ marketInsights: {
23
+ persist: true,
24
+ includeInDebugSnapshot: true,
25
+ includeInStateLogs: true,
26
+ usedInUi: true,
27
+ },
28
+ marketOverview: {
29
+ persist: true,
30
+ includeInDebugSnapshot: true,
31
+ includeInStateLogs: true,
32
+ usedInUi: true,
33
+ },
34
+ };
19
35
  const MESSENGER_EXPOSED_METHODS = [
20
36
  'fetchMarketInsights',
21
37
  'fetchMarketOverview',
22
38
  'fetchFrontPageItem',
23
39
  ];
24
40
  export class AiDigestController extends BaseController {
25
- constructor({ messenger, digestService }) {
41
+ constructor({ messenger, state, digestService }) {
26
42
  super({
27
43
  name: controllerName,
28
44
  metadata: aiDigestControllerMetadata,
29
- state: getDefaultAiDigestControllerState(),
45
+ state: {
46
+ ...getDefaultAiDigestControllerState(),
47
+ ...state,
48
+ },
30
49
  messenger,
31
50
  });
51
+ _AiDigestController_instances.add(this);
32
52
  _AiDigestController_digestService.set(this, void 0);
33
53
  __classPrivateFieldSet(this, _AiDigestController_digestService, digestService, "f");
34
54
  this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
35
55
  }
36
56
  /**
37
57
  * Fetches market insights for a given asset identifier.
58
+ * Returns cached data if still fresh, otherwise calls the service.
38
59
  *
39
60
  * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps
40
61
  * market symbol (e.g. `ETH`). The service handles choosing the correct API
41
- * query parameter automatically. Clients own freshness/caching.
62
+ * query parameter automatically.
42
63
  *
43
64
  * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).
44
65
  * @returns The market insights report, or `null` if none exists.
@@ -47,17 +68,61 @@ export class AiDigestController extends BaseController {
47
68
  if (!assetIdentifier) {
48
69
  throw new Error(AiDigestControllerErrorMessage.INVALID_ASSET_IDENTIFIER);
49
70
  }
50
- return __classPrivateFieldGet(this, _AiDigestController_digestService, "f").searchDigest(assetIdentifier);
71
+ const existing = this.state.marketInsights[assetIdentifier];
72
+ if (existing) {
73
+ const age = Date.now() - existing.fetchedAt;
74
+ if (age < CACHE_DURATION_MS) {
75
+ return existing.data;
76
+ }
77
+ }
78
+ const data = await __classPrivateFieldGet(this, _AiDigestController_digestService, "f").searchDigest(assetIdentifier);
79
+ if (data === null) {
80
+ // No insights available for this asset — clear any stale cache entry
81
+ this.update((state) => {
82
+ delete state.marketInsights[assetIdentifier];
83
+ });
84
+ return null;
85
+ }
86
+ const entry = {
87
+ assetIdentifier,
88
+ fetchedAt: Date.now(),
89
+ data,
90
+ };
91
+ this.update((state) => {
92
+ state.marketInsights[assetIdentifier] = entry;
93
+ __classPrivateFieldGet(this, _AiDigestController_instances, "m", _AiDigestController_evictStaleCachedEntries).call(this, state.marketInsights);
94
+ });
95
+ return data;
51
96
  }
52
97
  /**
53
98
  * Fetches the market overview report.
54
- *
55
- * Clients own freshness/caching.
99
+ * Returns cached data if still fresh, otherwise calls the service.
56
100
  *
57
101
  * @returns The market overview report, or `null` if none exists.
58
102
  */
59
103
  async fetchMarketOverview() {
60
- return __classPrivateFieldGet(this, _AiDigestController_digestService, "f").fetchMarketOverview();
104
+ const existing = this.state.marketOverview;
105
+ if (existing) {
106
+ const age = Date.now() - existing.fetchedAt;
107
+ if (age < CACHE_DURATION_MS) {
108
+ return existing.data;
109
+ }
110
+ }
111
+ const data = await __classPrivateFieldGet(this, _AiDigestController_digestService, "f").fetchMarketOverview();
112
+ if (data === null) {
113
+ this.update((state) => {
114
+ state.marketOverview = null;
115
+ });
116
+ return null;
117
+ }
118
+ const entry = {
119
+ fetchedAt: Date.now(),
120
+ data,
121
+ };
122
+ this.update((state) => {
123
+ state.marketOverview = entry;
124
+ });
125
+ return data;
61
126
  }
62
127
  /**
63
128
  * Fetches a single market overview front page by id.
@@ -76,5 +141,28 @@ export class AiDigestController extends BaseController {
76
141
  return __classPrivateFieldGet(this, _AiDigestController_digestService, "f").fetchFrontPageItem(id);
77
142
  }
78
143
  }
79
- _AiDigestController_digestService = new WeakMap();
144
+ _AiDigestController_digestService = new WeakMap(), _AiDigestController_instances = new WeakSet(), _AiDigestController_evictStaleCachedEntries = function _AiDigestController_evictStaleCachedEntries(cache) {
145
+ const now = Date.now();
146
+ const entries = Object.entries(cache);
147
+ const keysToDelete = [];
148
+ const freshEntries = [];
149
+ for (const [key, entry] of entries) {
150
+ if (now - entry.fetchedAt >= CACHE_DURATION_MS) {
151
+ keysToDelete.push(key);
152
+ }
153
+ else {
154
+ freshEntries.push([key, entry]);
155
+ }
156
+ }
157
+ if (freshEntries.length > MAX_CACHE_ENTRIES) {
158
+ freshEntries.sort((a, b) => a[1].fetchedAt - b[1].fetchedAt);
159
+ const entriesToRemove = freshEntries.length - MAX_CACHE_ENTRIES;
160
+ for (let i = 0; i < entriesToRemove; i++) {
161
+ keysToDelete.push(freshEntries[i][0]);
162
+ }
163
+ }
164
+ for (const key of keysToDelete) {
165
+ delete cache[key];
166
+ }
167
+ };
80
168
  //# sourceMappingURL=AiDigestController.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AiDigestController.mjs","sourceRoot":"","sources":["../src/AiDigestController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAG3D,OAAO,EACL,8BAA8B,EAC9B,cAAc,EACf,kCAAiC;AAqClC,MAAM,UAAU,iCAAiC;IAC/C,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,0BAA0B,GAA2C,EAAE,CAAC;AAE9E,MAAM,yBAAyB,GAAG;IAChC,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;CACZ,CAAC;AAEX,MAAM,OAAO,kBAAmB,SAAQ,cAIvC;IAGC,YAAY,EAAE,SAAS,EAAE,aAAa,EAA6B;QACjE,KAAK,CAAC;YACJ,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,0BAA0B;YACpC,KAAK,EAAE,iCAAiC,EAAE;YAC1C,SAAS;SACV,CAAC,CAAC;QARI,oDAA8B;QAUrC,uBAAA,IAAI,qCAAkB,aAAa,MAAA,CAAC;QACpC,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,mBAAmB,CACvB,eAAuB;QAEvB,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,wBAAwB,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,uBAAA,IAAI,yCAAe,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB;QACvB,OAAO,uBAAA,IAAI,yCAAe,CAAC,mBAAmB,EAAE,CAAC;IACnD,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,kBAAkB,CACtB,EAAU;QAEV,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,qBAAqB,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,uBAAA,IAAI,yCAAe,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import type {\n StateMetadata,\n ControllerStateChangeEvent,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport {\n AiDigestControllerErrorMessage,\n controllerName,\n} from './ai-digest-constants.js';\nimport type {\n AiDigestControllerState,\n DigestService,\n MarketInsightsReport,\n MarketOverview,\n MarketOverviewFrontPage,\n} from './ai-digest-types.js';\nimport type { AiDigestControllerMethodActions } from './AiDigestController-method-action-types.js';\n\nexport type AiDigestControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AiDigestControllerState\n>;\n\nexport type AiDigestControllerActions =\n | AiDigestControllerGetStateAction\n | AiDigestControllerMethodActions;\n\nexport type AiDigestControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AiDigestControllerState\n>;\n\nexport type AiDigestControllerEvents = AiDigestControllerStateChangeEvent;\n\nexport type AiDigestControllerMessenger = Messenger<\n typeof controllerName,\n AiDigestControllerActions,\n AiDigestControllerEvents\n>;\n\nexport type AiDigestControllerOptions = {\n messenger: AiDigestControllerMessenger;\n digestService: DigestService;\n};\n\nexport function getDefaultAiDigestControllerState(): AiDigestControllerState {\n return {};\n}\n\nconst aiDigestControllerMetadata: StateMetadata<AiDigestControllerState> = {};\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'fetchMarketInsights',\n 'fetchMarketOverview',\n 'fetchFrontPageItem',\n] as const;\n\nexport class AiDigestController extends BaseController<\n typeof controllerName,\n AiDigestControllerState,\n AiDigestControllerMessenger\n> {\n readonly #digestService: DigestService;\n\n constructor({ messenger, digestService }: AiDigestControllerOptions) {\n super({\n name: controllerName,\n metadata: aiDigestControllerMetadata,\n state: getDefaultAiDigestControllerState(),\n messenger,\n });\n\n this.#digestService = digestService;\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches market insights for a given asset identifier.\n *\n * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps\n * market symbol (e.g. `ETH`). The service handles choosing the correct API\n * query parameter automatically. Clients own freshness/caching.\n *\n * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).\n * @returns The market insights report, or `null` if none exists.\n */\n async fetchMarketInsights(\n assetIdentifier: string,\n ): Promise<MarketInsightsReport | null> {\n if (!assetIdentifier) {\n throw new Error(AiDigestControllerErrorMessage.INVALID_ASSET_IDENTIFIER);\n }\n\n return this.#digestService.searchDigest(assetIdentifier);\n }\n\n /**\n * Fetches the market overview report.\n *\n * Clients own freshness/caching.\n *\n * @returns The market overview report, or `null` if none exists.\n */\n async fetchMarketOverview(): Promise<MarketOverview | null> {\n return this.#digestService.fetchMarketOverview();\n }\n\n /**\n * Fetches a single market overview front page by id.\n *\n * Unlike the market overview report (which only returns the latest items),\n * this resolves an older item that has since dropped out of the report, so\n * clients can render it directly (e.g. from a deep link).\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists.\n */\n async fetchFrontPageItem(\n id: string,\n ): Promise<MarketOverviewFrontPage | null> {\n if (!id) {\n throw new Error(AiDigestControllerErrorMessage.INVALID_FRONT_PAGE_ID);\n }\n\n return this.#digestService.fetchFrontPageItem(id);\n }\n}\n"]}
1
+ {"version":3,"file":"AiDigestController.mjs","sourceRoot":"","sources":["../src/AiDigestController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAG3D,OAAO,EACL,8BAA8B,EAC9B,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EAClB,kCAAiC;AAwClC,MAAM,UAAU,iCAAiC;IAC/C,OAAO;QACL,cAAc,EAAE,EAAE;QAClB,cAAc,EAAE,IAAI;KACrB,CAAC;AACJ,CAAC;AAED,MAAM,0BAA0B,GAA2C;IACzE,cAAc,EAAE;QACd,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,IAAI;KACf;IACD,cAAc,EAAE;QACd,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,yBAAyB,GAAG;IAChC,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;CACZ,CAAC;AAEX,MAAM,OAAO,kBAAmB,SAAQ,cAIvC;IAGC,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAA6B;QACxE,KAAK,CAAC;YACJ,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,0BAA0B;YACpC,KAAK,EAAE;gBACL,GAAG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AAgC;IAEhC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,YAAY,GAA0B,EAAE,CAAC;IAE/C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,IAAI,GAAG,GAAG,KAAK,CAAC,SAAS,IAAI,iBAAiB,EAAE,CAAC;YAC/C,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,IAAI,YAAY,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;QAC5C,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC7D,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,GAAG,iBAAiB,CAAC;QAChE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["import type {\n StateMetadata,\n ControllerStateChangeEvent,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport {\n AiDigestControllerErrorMessage,\n controllerName,\n CACHE_DURATION_MS,\n MAX_CACHE_ENTRIES,\n} from './ai-digest-constants.js';\nimport type {\n AiDigestControllerState,\n DigestService,\n MarketInsightsReport,\n MarketInsightsEntry,\n MarketOverview,\n MarketOverviewEntry,\n MarketOverviewFrontPage,\n} from './ai-digest-types.js';\nimport type { AiDigestControllerMethodActions } from './AiDigestController-method-action-types.js';\n\nexport type AiDigestControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AiDigestControllerState\n>;\n\nexport type AiDigestControllerActions =\n | AiDigestControllerGetStateAction\n | AiDigestControllerMethodActions;\n\nexport type AiDigestControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AiDigestControllerState\n>;\n\nexport type AiDigestControllerEvents = AiDigestControllerStateChangeEvent;\n\nexport type AiDigestControllerMessenger = Messenger<\n typeof controllerName,\n AiDigestControllerActions,\n AiDigestControllerEvents\n>;\n\nexport type AiDigestControllerOptions = {\n messenger: AiDigestControllerMessenger;\n state?: Partial<AiDigestControllerState>;\n digestService: DigestService;\n};\n\nexport function getDefaultAiDigestControllerState(): AiDigestControllerState {\n return {\n marketInsights: {},\n marketOverview: null,\n };\n}\n\nconst aiDigestControllerMetadata: StateMetadata<AiDigestControllerState> = {\n marketInsights: {\n persist: true,\n includeInDebugSnapshot: true,\n includeInStateLogs: true,\n usedInUi: true,\n },\n marketOverview: {\n persist: true,\n includeInDebugSnapshot: true,\n includeInStateLogs: true,\n usedInUi: true,\n },\n};\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'fetchMarketInsights',\n 'fetchMarketOverview',\n 'fetchFrontPageItem',\n] as const;\n\nexport class AiDigestController extends BaseController<\n typeof controllerName,\n AiDigestControllerState,\n AiDigestControllerMessenger\n> {\n readonly #digestService: DigestService;\n\n constructor({ messenger, state, digestService }: AiDigestControllerOptions) {\n super({\n name: controllerName,\n metadata: aiDigestControllerMetadata,\n state: {\n ...getDefaultAiDigestControllerState(),\n ...state,\n },\n messenger,\n });\n\n this.#digestService = digestService;\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches market insights for a given asset identifier.\n * Returns cached data if still fresh, otherwise calls the service.\n *\n * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps\n * market symbol (e.g. `ETH`). The service handles choosing the correct API\n * query parameter automatically.\n *\n * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).\n * @returns The market insights report, or `null` if none exists.\n */\n async fetchMarketInsights(\n assetIdentifier: string,\n ): Promise<MarketInsightsReport | null> {\n if (!assetIdentifier) {\n throw new Error(AiDigestControllerErrorMessage.INVALID_ASSET_IDENTIFIER);\n }\n\n const existing = this.state.marketInsights[assetIdentifier];\n if (existing) {\n const age = Date.now() - existing.fetchedAt;\n if (age < CACHE_DURATION_MS) {\n return existing.data;\n }\n }\n\n const data = await this.#digestService.searchDigest(assetIdentifier);\n\n if (data === null) {\n // No insights available for this asset — clear any stale cache entry\n this.update((state) => {\n delete state.marketInsights[assetIdentifier];\n });\n return null;\n }\n\n const entry: MarketInsightsEntry = {\n assetIdentifier,\n fetchedAt: Date.now(),\n data,\n };\n\n this.update((state) => {\n state.marketInsights[assetIdentifier] = entry;\n this.#evictStaleCachedEntries(state.marketInsights);\n });\n\n return data;\n }\n\n /**\n * Fetches the market overview report.\n * Returns cached data if still fresh, otherwise calls the service.\n *\n * @returns The market overview report, or `null` if none exists.\n */\n async fetchMarketOverview(): Promise<MarketOverview | null> {\n const existing = this.state.marketOverview;\n if (existing) {\n const age = Date.now() - existing.fetchedAt;\n if (age < CACHE_DURATION_MS) {\n return existing.data;\n }\n }\n\n const data = await this.#digestService.fetchMarketOverview();\n\n if (data === null) {\n this.update((state) => {\n state.marketOverview = null;\n });\n return null;\n }\n\n const entry: MarketOverviewEntry = {\n fetchedAt: Date.now(),\n data,\n };\n\n this.update((state) => {\n state.marketOverview = entry;\n });\n\n return data;\n }\n\n /**\n * Fetches a single market overview front page by id.\n *\n * Unlike the market overview report (which only returns the latest items),\n * this resolves an older item that has since dropped out of the report, so\n * clients can render it directly (e.g. from a deep link).\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists.\n */\n async fetchFrontPageItem(\n id: string,\n ): Promise<MarketOverviewFrontPage | null> {\n if (!id) {\n throw new Error(AiDigestControllerErrorMessage.INVALID_FRONT_PAGE_ID);\n }\n\n return this.#digestService.fetchFrontPageItem(id);\n }\n\n /**\n * Evicts stale (TTL expired) and oldest entries (FIFO) if cache exceeds max size.\n *\n * @param cache - The cache record to evict entries from.\n */\n #evictStaleCachedEntries<EntryType extends { fetchedAt: number }>(\n cache: Record<string, EntryType>,\n ): void {\n const now = Date.now();\n const entries = Object.entries(cache);\n const keysToDelete: string[] = [];\n const freshEntries: [string, EntryType][] = [];\n\n for (const [key, entry] of entries) {\n if (now - entry.fetchedAt >= CACHE_DURATION_MS) {\n keysToDelete.push(key);\n } else {\n freshEntries.push([key, entry]);\n }\n }\n\n if (freshEntries.length > MAX_CACHE_ENTRIES) {\n freshEntries.sort((a, b) => a[1].fetchedAt - b[1].fetchedAt);\n const entriesToRemove = freshEntries.length - MAX_CACHE_ENTRIES;\n for (let i = 0; i < entriesToRemove; i++) {\n keysToDelete.push(freshEntries[i][0]);\n }\n }\n\n for (const key of keysToDelete) {\n delete cache[key];\n }\n }\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AiDigestControllerErrorMessage = exports.controllerName = void 0;
3
+ exports.AiDigestControllerErrorMessage = exports.MAX_CACHE_ENTRIES = exports.CACHE_DURATION_MS = exports.controllerName = void 0;
4
4
  exports.controllerName = 'AiDigestController';
5
+ exports.CACHE_DURATION_MS = 10 * 60 * 1000; // 10 minutes
6
+ exports.MAX_CACHE_ENTRIES = 50;
5
7
  exports.AiDigestControllerErrorMessage = {
6
8
  API_REQUEST_FAILED: 'API request failed',
7
9
  API_INVALID_RESPONSE: 'API returned invalid response',
@@ -1 +1 @@
1
- {"version":3,"file":"ai-digest-constants.cjs","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,oBAAoB,CAAC;AAEtC,QAAA,8BAA8B,GAAG;IAC5C,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,+BAA+B;IACrD,wBAAwB,EAAE,0BAA0B;IACpD,qBAAqB,EAAE,uBAAuB;CACtC,CAAC","sourcesContent":["export const controllerName = 'AiDigestController';\n\nexport const AiDigestControllerErrorMessage = {\n API_REQUEST_FAILED: 'API request failed',\n API_INVALID_RESPONSE: 'API returned invalid response',\n INVALID_ASSET_IDENTIFIER: 'Invalid asset identifier',\n INVALID_FRONT_PAGE_ID: 'Invalid front page id',\n} as const;\n"]}
1
+ {"version":3,"file":"ai-digest-constants.cjs","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,oBAAoB,CAAC;AAEtC,QAAA,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAEjD,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAEvB,QAAA,8BAA8B,GAAG;IAC5C,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,+BAA+B;IACrD,wBAAwB,EAAE,0BAA0B;IACpD,qBAAqB,EAAE,uBAAuB;CACtC,CAAC","sourcesContent":["export const controllerName = 'AiDigestController';\n\nexport const CACHE_DURATION_MS = 10 * 60 * 1000; // 10 minutes\n\nexport const MAX_CACHE_ENTRIES = 50;\n\nexport const AiDigestControllerErrorMessage = {\n API_REQUEST_FAILED: 'API request failed',\n API_INVALID_RESPONSE: 'API returned invalid response',\n INVALID_ASSET_IDENTIFIER: 'Invalid asset identifier',\n INVALID_FRONT_PAGE_ID: 'Invalid front page id',\n} as const;\n"]}
@@ -1,4 +1,6 @@
1
1
  export declare const controllerName = "AiDigestController";
2
+ export declare const CACHE_DURATION_MS: number;
3
+ export declare const MAX_CACHE_ENTRIES = 50;
2
4
  export declare const AiDigestControllerErrorMessage: {
3
5
  readonly API_REQUEST_FAILED: "API request failed";
4
6
  readonly API_INVALID_RESPONSE: "API returned invalid response";
@@ -1 +1 @@
1
- {"version":3,"file":"ai-digest-constants.d.cts","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,eAAO,MAAM,8BAA8B;;;;;CAKjC,CAAC"}
1
+ {"version":3,"file":"ai-digest-constants.d.cts","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,QAAiB,CAAC;AAEhD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,8BAA8B;;;;;CAKjC,CAAC"}
@@ -1,4 +1,6 @@
1
1
  export declare const controllerName = "AiDigestController";
2
+ export declare const CACHE_DURATION_MS: number;
3
+ export declare const MAX_CACHE_ENTRIES = 50;
2
4
  export declare const AiDigestControllerErrorMessage: {
3
5
  readonly API_REQUEST_FAILED: "API request failed";
4
6
  readonly API_INVALID_RESPONSE: "API returned invalid response";
@@ -1 +1 @@
1
- {"version":3,"file":"ai-digest-constants.d.mts","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,eAAO,MAAM,8BAA8B;;;;;CAKjC,CAAC"}
1
+ {"version":3,"file":"ai-digest-constants.d.mts","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,QAAiB,CAAC;AAEhD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,8BAA8B;;;;;CAKjC,CAAC"}
@@ -1,4 +1,6 @@
1
1
  export const controllerName = 'AiDigestController';
2
+ export const CACHE_DURATION_MS = 10 * 60 * 1000; // 10 minutes
3
+ export const MAX_CACHE_ENTRIES = 50;
2
4
  export const AiDigestControllerErrorMessage = {
3
5
  API_REQUEST_FAILED: 'API request failed',
4
6
  API_INVALID_RESPONSE: 'API returned invalid response',
@@ -1 +1 @@
1
- {"version":3,"file":"ai-digest-constants.mjs","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAEnD,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,+BAA+B;IACrD,wBAAwB,EAAE,0BAA0B;IACpD,qBAAqB,EAAE,uBAAuB;CACtC,CAAC","sourcesContent":["export const controllerName = 'AiDigestController';\n\nexport const AiDigestControllerErrorMessage = {\n API_REQUEST_FAILED: 'API request failed',\n API_INVALID_RESPONSE: 'API returned invalid response',\n INVALID_ASSET_IDENTIFIER: 'Invalid asset identifier',\n INVALID_FRONT_PAGE_ID: 'Invalid front page id',\n} as const;\n"]}
1
+ {"version":3,"file":"ai-digest-constants.mjs","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,+BAA+B;IACrD,wBAAwB,EAAE,0BAA0B;IACpD,qBAAqB,EAAE,uBAAuB;CACtC,CAAC","sourcesContent":["export const controllerName = 'AiDigestController';\n\nexport const CACHE_DURATION_MS = 10 * 60 * 1000; // 10 minutes\n\nexport const MAX_CACHE_ENTRIES = 50;\n\nexport const AiDigestControllerErrorMessage = {\n API_REQUEST_FAILED: 'API request failed',\n API_INVALID_RESPONSE: 'API returned invalid response',\n INVALID_ASSET_IDENTIFIER: 'Invalid asset identifier',\n INVALID_FRONT_PAGE_ID: 'Invalid front page id',\n} as const;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-digest-types.cjs","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E","sourcesContent":["// ---------------------------------------------------------------------------\n// Shared sub-types\n// ---------------------------------------------------------------------------\n\n/**\n * A news article referenced by a trend.\n */\nexport type Article = {\n /** Article title */\n title: string;\n /** Full URL to the article */\n url: string;\n /** Source domain name (e.g. \"coindesk.com\") */\n source: string;\n /** ISO date string */\n date: string;\n};\n\n/**\n * A social media post referenced by a trend.\n */\nexport type Tweet = {\n /** Summary of the tweet content */\n contentSummary: string;\n /** Full URL to the tweet */\n url: string;\n /** Author handle (e.g. \"@saylordocs\") */\n author: string;\n /** ISO date string */\n date: string;\n};\n\n/**\n * A data source used to generate a report.\n */\nexport type Source = {\n /** Source name (e.g. \"CoinDesk\") */\n name: string;\n /** Source URL */\n url: string;\n /** Source type */\n type: 'news' | 'data' | 'social';\n};\n\nexport type MarketInsightsArticle = Article;\nexport type MarketInsightsTweet = Tweet;\nexport type MarketInsightsSource = Source;\n\n// ---------------------------------------------------------------------------\n// Market Insights types (asset-specific)\n// ---------------------------------------------------------------------------\n\n/**\n * A key market trend identified in the insights report.\n */\nexport type MarketInsightsTrend = {\n /** Trend title (e.g. \"Institutions Buying the Dip\") */\n title: string;\n /** Detailed description of the trend */\n description: string;\n /** Category of the trend */\n category:\n | 'geopolitical'\n | 'macro'\n | 'regulatory'\n | 'technical'\n | 'social'\n | 'other';\n /** Impact direction */\n impact: 'positive' | 'negative' | 'neutral';\n /** Related news articles */\n articles: Article[];\n /** Related social media posts */\n tweets: Tweet[];\n};\n\n/**\n * AI-generated market insights report for a crypto asset.\n * Returned by `GET /asset-summary?asset=<identifier>`.\n */\nexport type MarketInsightsReport = {\n /** Unique identifier for this digest, sourced from the API response envelope. */\n digestId: string;\n /** API version */\n version?: string;\n /** Asset symbol (lowercase, e.g. \"btc\") */\n asset: string;\n /** ISO date string when the report was generated */\n generatedAt: string;\n /** Main headline */\n headline: string;\n /** Summary paragraph */\n summary: string;\n /** Key market trends */\n trends: MarketInsightsTrend[];\n /** Optional top-level social posts included by the API */\n social?: Tweet[];\n /** Data sources used to generate the report */\n sources: Source[];\n /** Provider metadata */\n metadata?: AIResponseMetadata[];\n};\n\n// ---------------------------------------------------------------------------\n// Market Overview types (non-asset-specific)\n// ---------------------------------------------------------------------------\n\n/**\n * A crypto asset related to a market overview trend.\n * Returned by the `/market-overview` API as a rich object.\n */\nexport type RelatedAsset = {\n /**\n * Human-readable asset name (e.g. \"Bitcoin\"). Optional — clients must fall\n * back to `symbol` when absent.\n */\n name?: string;\n /** Ticker symbol (e.g. \"BTC\"). The only field guaranteed to be present. */\n symbol: string;\n /**\n * CAIP-19 identifiers for this asset across chains. May be absent for\n * purely synthetic / perps-only assets (e.g. ETHFI). The service\n * normalises missing values to `[]`.\n */\n caip19?: string[];\n /**\n * Canonical source asset identifier (e.g. \"bitcoin\"). Optional — may be\n * absent when the API pipeline cannot enrich the asset record.\n */\n sourceAssetId?: string;\n /**\n * Optional HyperLiquid market identifiers for this asset (e.g. `BTC`, `ETH`,\n * `xyz:TSLA`). Covers both regular crypto tokens that trade on HyperLiquid\n * and purely synthetic perps assets. Use this to resolve Perps icon URLs via\n * `getAssetIconUrls` on clients when `caip19` is empty.\n */\n hlPerpsMarket?: string[];\n};\n\nexport type MarketOverviewTrend = {\n title: string;\n description: string;\n category?:\n | 'geopolitical'\n | 'macro'\n | 'regulatory'\n | 'technical'\n | 'social'\n | 'other';\n impact?: 'positive' | 'negative' | 'neutral';\n articles: Article[];\n relatedAssets: RelatedAsset[];\n};\n\n/**\n * Provider metadata included in AI API responses.\n */\nexport type AIResponseMetadata = {\n provider: string;\n};\n\nexport type MarketOverview = {\n version?: string;\n generatedAt: string;\n trends: MarketOverviewTrend[];\n metadata?: AIResponseMetadata[];\n};\n\n/**\n * A single market overview item. Shares the exact same schema as a\n * {@link MarketOverviewTrend} — i.e. one entry of `MarketOverview.trends`.\n */\nexport type MarketOverviewItem = MarketOverviewTrend;\n\n/**\n * A market overview \"front page\": a single AI-selected item (mirroring the\n * front page of a newspaper) plus its call-to-action copy, addressable by id.\n *\n * Returned by `GET /market-overview/front-page/:id` (and `.../latest`). Unlike\n * `/market-overview`, which only ever returns the latest report, this lets\n * clients fetch an older item that has since dropped out of the report.\n */\nexport type MarketOverviewFrontPage = {\n /** Unique identifier of the front-page row (UUID). */\n id: string;\n /** The selected item — same schema as an individual market overview item. */\n item: MarketOverviewItem;\n /** Call-to-action title for the front-page item. */\n ctaTitle: string;\n /** Call-to-action description for the front-page item. */\n ctaDescription: string;\n /** ISO date string when the front-page row was created. */\n createdAt: string;\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\n/**\n * AiDigestController has no persisted cache. Digest freshness is owned by\n * clients (e.g. React Query).\n */\nexport type AiDigestControllerState = Record<string, never>;\n\n// ---------------------------------------------------------------------------\n// Service interface\n// ---------------------------------------------------------------------------\n\nexport type DigestService = {\n /**\n * Search for market insights by asset identifier.\n *\n * Accepts any identifier the API understands — CAIP-19 asset type\n * (e.g. `eip155:1/slip44:60`), ticker symbol (e.g. `ETH`), asset name\n * (e.g. `Bitcoin`), or HyperLiquid perps market id (e.g. `xyz:TSLA`).\n *\n * Calls `GET /asset-summary?asset=<assetIdentifier>`.\n *\n * @param assetIdentifier - The asset identifier.\n * @returns The market insights report, or `null` if no insights exist (404).\n */\n searchDigest(assetIdentifier: string): Promise<MarketInsightsReport | null>;\n\n /**\n * Fetch the market overview report.\n * Calls `GET /market-overview`.\n *\n * @returns The market overview report, or `null` if none exists (404).\n */\n fetchMarketOverview(): Promise<MarketOverview | null>;\n\n /**\n * Fetch a single market overview front page by id.\n * Calls `GET /market-overview/front-page/:id`.\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists (404).\n */\n fetchFrontPageItem(id: string): Promise<MarketOverviewFrontPage | null>;\n};\n"]}
1
+ {"version":3,"file":"ai-digest-types.cjs","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E","sourcesContent":["// ---------------------------------------------------------------------------\n// Shared sub-types\n// ---------------------------------------------------------------------------\n\n/**\n * A news article referenced by a trend.\n */\nexport type Article = {\n /** Article title */\n title: string;\n /** Full URL to the article */\n url: string;\n /** Source domain name (e.g. \"coindesk.com\") */\n source: string;\n /** ISO date string */\n date: string;\n};\n\n/**\n * A social media post referenced by a trend.\n */\nexport type Tweet = {\n /** Summary of the tweet content */\n contentSummary: string;\n /** Full URL to the tweet */\n url: string;\n /** Author handle (e.g. \"@saylordocs\") */\n author: string;\n /** ISO date string */\n date: string;\n};\n\n/**\n * A data source used to generate a report.\n */\nexport type Source = {\n /** Source name (e.g. \"CoinDesk\") */\n name: string;\n /** Source URL */\n url: string;\n /** Source type */\n type: 'news' | 'data' | 'social';\n};\n\nexport type MarketInsightsArticle = Article;\nexport type MarketInsightsTweet = Tweet;\nexport type MarketInsightsSource = Source;\n\n// ---------------------------------------------------------------------------\n// Market Insights types (asset-specific)\n// ---------------------------------------------------------------------------\n\n/**\n * A key market trend identified in the insights report.\n */\nexport type MarketInsightsTrend = {\n /** Trend title (e.g. \"Institutions Buying the Dip\") */\n title: string;\n /** Detailed description of the trend */\n description: string;\n /** Category of the trend */\n category:\n | 'geopolitical'\n | 'macro'\n | 'regulatory'\n | 'technical'\n | 'social'\n | 'other';\n /** Impact direction */\n impact: 'positive' | 'negative' | 'neutral';\n /** Related news articles */\n articles: Article[];\n /** Related social media posts */\n tweets: Tweet[];\n};\n\n/**\n * AI-generated market insights report for a crypto asset.\n * Returned by `GET /asset-summary?asset=<identifier>`.\n */\nexport type MarketInsightsReport = {\n /** Unique identifier for this digest, sourced from the API response envelope. */\n digestId: string;\n /** API version */\n version?: string;\n /** Asset symbol (lowercase, e.g. \"btc\") */\n asset: string;\n /** ISO date string when the report was generated */\n generatedAt: string;\n /** Main headline */\n headline: string;\n /** Summary paragraph */\n summary: string;\n /** Key market trends */\n trends: MarketInsightsTrend[];\n /** Optional top-level social posts included by the API */\n social?: Tweet[];\n /** Data sources used to generate the report */\n sources: Source[];\n /** Provider metadata */\n metadata?: AIResponseMetadata[];\n};\n\n/**\n * A cached market insights entry.\n */\nexport type MarketInsightsEntry = {\n /** Asset identifier — either a CAIP-19 ID (e.g. \"eip155:1/slip44:60\") or a perps market symbol (e.g. \"ETH\") */\n assetIdentifier: string;\n /** Timestamp when the entry was fetched */\n fetchedAt: number;\n /** The market insights report data */\n data: MarketInsightsReport;\n};\n\n/**\n * A cached market overview entry.\n */\nexport type MarketOverviewEntry = {\n /** Timestamp when the entry was fetched */\n fetchedAt: number;\n /** The market overview data */\n data: MarketOverview;\n};\n\n// ---------------------------------------------------------------------------\n// Market Overview types (non-asset-specific)\n// ---------------------------------------------------------------------------\n\n/**\n * A crypto asset related to a market overview trend.\n * Returned by the `/market-overview` API as a rich object.\n */\nexport type RelatedAsset = {\n /**\n * Human-readable asset name (e.g. \"Bitcoin\"). Optional — clients must fall\n * back to `symbol` when absent.\n */\n name?: string;\n /** Ticker symbol (e.g. \"BTC\"). The only field guaranteed to be present. */\n symbol: string;\n /**\n * CAIP-19 identifiers for this asset across chains. May be absent for\n * purely synthetic / perps-only assets (e.g. ETHFI). The service\n * normalises missing values to `[]`.\n */\n caip19?: string[];\n /**\n * Canonical source asset identifier (e.g. \"bitcoin\"). Optional — may be\n * absent when the API pipeline cannot enrich the asset record.\n */\n sourceAssetId?: string;\n /**\n * Optional HyperLiquid market identifiers for this asset (e.g. `BTC`, `ETH`,\n * `xyz:TSLA`). Covers both regular crypto tokens that trade on HyperLiquid\n * and purely synthetic perps assets. Use this to resolve Perps icon URLs via\n * `getAssetIconUrls` on clients when `caip19` is empty.\n */\n hlPerpsMarket?: string[];\n};\n\nexport type MarketOverviewTrend = {\n title: string;\n description: string;\n category?:\n | 'geopolitical'\n | 'macro'\n | 'regulatory'\n | 'technical'\n | 'social'\n | 'other';\n impact?: 'positive' | 'negative' | 'neutral';\n articles: Article[];\n relatedAssets: RelatedAsset[];\n};\n\n/**\n * Provider metadata included in AI API responses.\n */\nexport type AIResponseMetadata = {\n provider: string;\n};\n\nexport type MarketOverview = {\n version?: string;\n generatedAt: string;\n trends: MarketOverviewTrend[];\n metadata?: AIResponseMetadata[];\n};\n\n/**\n * A single market overview item. Shares the exact same schema as a\n * {@link MarketOverviewTrend} — i.e. one entry of `MarketOverview.trends`.\n */\nexport type MarketOverviewItem = MarketOverviewTrend;\n\n/**\n * A market overview \"front page\": a single AI-selected item (mirroring the\n * front page of a newspaper) plus its call-to-action copy, addressable by id.\n *\n * Returned by `GET /market-overview/front-page/:id` (and `.../latest`). Unlike\n * `/market-overview`, which only ever returns the latest report, this lets\n * clients fetch an older item that has since dropped out of the report.\n */\nexport type MarketOverviewFrontPage = {\n /** Unique identifier of the front-page row (UUID). */\n id: string;\n /** The selected item — same schema as an individual market overview item. */\n item: MarketOverviewItem;\n /** Call-to-action title for the front-page item. */\n ctaTitle: string;\n /** Call-to-action description for the front-page item. */\n ctaDescription: string;\n /** ISO date string when the front-page row was created. */\n createdAt: string;\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\nexport type AiDigestControllerState = {\n marketInsights: Record<string, MarketInsightsEntry>;\n marketOverview: MarketOverviewEntry | null;\n};\n\n// ---------------------------------------------------------------------------\n// Service interface\n// ---------------------------------------------------------------------------\n\nexport type DigestService = {\n /**\n * Search for market insights by asset identifier.\n *\n * Accepts any identifier the API understands — CAIP-19 asset type\n * (e.g. `eip155:1/slip44:60`), ticker symbol (e.g. `ETH`), asset name\n * (e.g. `Bitcoin`), or HyperLiquid perps market id (e.g. `xyz:TSLA`).\n *\n * Calls `GET /asset-summary?asset=<assetIdentifier>`.\n *\n * @param assetIdentifier - The asset identifier.\n * @returns The market insights report, or `null` if no insights exist (404).\n */\n searchDigest(assetIdentifier: string): Promise<MarketInsightsReport | null>;\n\n /**\n * Fetch the market overview report.\n * Calls `GET /market-overview`.\n *\n * @returns The market overview report, or `null` if none exists (404).\n */\n fetchMarketOverview(): Promise<MarketOverview | null>;\n\n /**\n * Fetch a single market overview front page by id.\n * Calls `GET /market-overview/front-page/:id`.\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists (404).\n */\n fetchFrontPageItem(id: string): Promise<MarketOverviewFrontPage | null>;\n};\n"]}
@@ -81,6 +81,26 @@ export type MarketInsightsReport = {
81
81
  /** Provider metadata */
82
82
  metadata?: AIResponseMetadata[];
83
83
  };
84
+ /**
85
+ * A cached market insights entry.
86
+ */
87
+ export type MarketInsightsEntry = {
88
+ /** Asset identifier — either a CAIP-19 ID (e.g. "eip155:1/slip44:60") or a perps market symbol (e.g. "ETH") */
89
+ assetIdentifier: string;
90
+ /** Timestamp when the entry was fetched */
91
+ fetchedAt: number;
92
+ /** The market insights report data */
93
+ data: MarketInsightsReport;
94
+ };
95
+ /**
96
+ * A cached market overview entry.
97
+ */
98
+ export type MarketOverviewEntry = {
99
+ /** Timestamp when the entry was fetched */
100
+ fetchedAt: number;
101
+ /** The market overview data */
102
+ data: MarketOverview;
103
+ };
84
104
  /**
85
105
  * A crypto asset related to a market overview trend.
86
106
  * Returned by the `/market-overview` API as a rich object.
@@ -157,11 +177,10 @@ export type MarketOverviewFrontPage = {
157
177
  /** ISO date string when the front-page row was created. */
158
178
  createdAt: string;
159
179
  };
160
- /**
161
- * AiDigestController has no persisted cache. Digest freshness is owned by
162
- * clients (e.g. React Query).
163
- */
164
- export type AiDigestControllerState = Record<string, never>;
180
+ export type AiDigestControllerState = {
181
+ marketInsights: Record<string, MarketInsightsEntry>;
182
+ marketOverview: MarketOverviewEntry | null;
183
+ };
165
184
  export type DigestService = {
166
185
  /**
167
186
  * Search for market insights by asset identifier.
@@ -1 +1 @@
1
- {"version":3,"file":"ai-digest-types.d.cts","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,kBAAkB;IAClB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAC5C,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC;AACxC,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAM1C;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACx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AC,CAAC;IACpD,cAAc,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC5C,CAAC;AAMF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAE5E;;;;;OAKG;IACH,mBAAmB,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAEtD;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;CACzE,CAAC"}
@@ -81,6 +81,26 @@ export type MarketInsightsReport = {
81
81
  /** Provider metadata */
82
82
  metadata?: AIResponseMetadata[];
83
83
  };
84
+ /**
85
+ * A cached market insights entry.
86
+ */
87
+ export type MarketInsightsEntry = {
88
+ /** Asset identifier — either a CAIP-19 ID (e.g. "eip155:1/slip44:60") or a perps market symbol (e.g. "ETH") */
89
+ assetIdentifier: string;
90
+ /** Timestamp when the entry was fetched */
91
+ fetchedAt: number;
92
+ /** The market insights report data */
93
+ data: MarketInsightsReport;
94
+ };
95
+ /**
96
+ * A cached market overview entry.
97
+ */
98
+ export type MarketOverviewEntry = {
99
+ /** Timestamp when the entry was fetched */
100
+ fetchedAt: number;
101
+ /** The market overview data */
102
+ data: MarketOverview;
103
+ };
84
104
  /**
85
105
  * A crypto asset related to a market overview trend.
86
106
  * Returned by the `/market-overview` API as a rich object.
@@ -157,11 +177,10 @@ export type MarketOverviewFrontPage = {
157
177
  /** ISO date string when the front-page row was created. */
158
178
  createdAt: string;
159
179
  };
160
- /**
161
- * AiDigestController has no persisted cache. Digest freshness is owned by
162
- * clients (e.g. React Query).
163
- */
164
- export type AiDigestControllerState = Record<string, never>;
180
+ export type AiDigestControllerState = {
181
+ marketInsights: Record<string, MarketInsightsEntry>;
182
+ marketOverview: MarketOverviewEntry | null;
183
+ };
165
184
  export type DigestService = {
166
185
  /**
167
186
  * Search for market insights by asset identifier.
@@ -1 +1 @@
1
- {"version":3,"file":"ai-digest-types.d.mts","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,kBAAkB;IAClB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAC5C,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC;AACxC,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAM1C;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,QAAQ,EACJ,cAAc,GACd,OAAO,GACP,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,OAAO,CAAC;IACZ,uBAAuB;IACvB,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,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AG,IAAI,CAAC,CAAC;IAE5E;;;;;OAKG;IACH,mBAAmB,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAEtD;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;CACzE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-digest-types.mjs","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E","sourcesContent":["// ---------------------------------------------------------------------------\n// Shared sub-types\n// ---------------------------------------------------------------------------\n\n/**\n * A news article referenced by a trend.\n */\nexport type Article = {\n /** Article title */\n title: string;\n /** Full URL to the article */\n url: string;\n /** Source domain name (e.g. \"coindesk.com\") */\n source: string;\n /** ISO date string */\n date: string;\n};\n\n/**\n * A social media post referenced by a trend.\n */\nexport type Tweet = {\n /** Summary of the tweet content */\n contentSummary: string;\n /** Full URL to the tweet */\n url: string;\n /** Author handle (e.g. \"@saylordocs\") */\n author: string;\n /** ISO date string */\n date: string;\n};\n\n/**\n * A data source used to generate a report.\n */\nexport type Source = {\n /** Source name (e.g. \"CoinDesk\") */\n name: string;\n /** Source URL */\n url: string;\n /** Source type */\n type: 'news' | 'data' | 'social';\n};\n\nexport type MarketInsightsArticle = Article;\nexport type MarketInsightsTweet = Tweet;\nexport type MarketInsightsSource = Source;\n\n// ---------------------------------------------------------------------------\n// Market Insights types (asset-specific)\n// ---------------------------------------------------------------------------\n\n/**\n * A key market trend identified in the insights report.\n */\nexport type MarketInsightsTrend = {\n /** Trend title (e.g. \"Institutions Buying the Dip\") */\n title: string;\n /** Detailed description of the trend */\n description: string;\n /** Category of the trend */\n category:\n | 'geopolitical'\n | 'macro'\n | 'regulatory'\n | 'technical'\n | 'social'\n | 'other';\n /** Impact direction */\n impact: 'positive' | 'negative' | 'neutral';\n /** Related news articles */\n articles: Article[];\n /** Related social media posts */\n tweets: Tweet[];\n};\n\n/**\n * AI-generated market insights report for a crypto asset.\n * Returned by `GET /asset-summary?asset=<identifier>`.\n */\nexport type MarketInsightsReport = {\n /** Unique identifier for this digest, sourced from the API response envelope. */\n digestId: string;\n /** API version */\n version?: string;\n /** Asset symbol (lowercase, e.g. \"btc\") */\n asset: string;\n /** ISO date string when the report was generated */\n generatedAt: string;\n /** Main headline */\n headline: string;\n /** Summary paragraph */\n summary: string;\n /** Key market trends */\n trends: MarketInsightsTrend[];\n /** Optional top-level social posts included by the API */\n social?: Tweet[];\n /** Data sources used to generate the report */\n sources: Source[];\n /** Provider metadata */\n metadata?: AIResponseMetadata[];\n};\n\n// ---------------------------------------------------------------------------\n// Market Overview types (non-asset-specific)\n// ---------------------------------------------------------------------------\n\n/**\n * A crypto asset related to a market overview trend.\n * Returned by the `/market-overview` API as a rich object.\n */\nexport type RelatedAsset = {\n /**\n * Human-readable asset name (e.g. \"Bitcoin\"). Optional — clients must fall\n * back to `symbol` when absent.\n */\n name?: string;\n /** Ticker symbol (e.g. \"BTC\"). The only field guaranteed to be present. */\n symbol: string;\n /**\n * CAIP-19 identifiers for this asset across chains. May be absent for\n * purely synthetic / perps-only assets (e.g. ETHFI). The service\n * normalises missing values to `[]`.\n */\n caip19?: string[];\n /**\n * Canonical source asset identifier (e.g. \"bitcoin\"). Optional — may be\n * absent when the API pipeline cannot enrich the asset record.\n */\n sourceAssetId?: string;\n /**\n * Optional HyperLiquid market identifiers for this asset (e.g. `BTC`, `ETH`,\n * `xyz:TSLA`). Covers both regular crypto tokens that trade on HyperLiquid\n * and purely synthetic perps assets. Use this to resolve Perps icon URLs via\n * `getAssetIconUrls` on clients when `caip19` is empty.\n */\n hlPerpsMarket?: string[];\n};\n\nexport type MarketOverviewTrend = {\n title: string;\n description: string;\n category?:\n | 'geopolitical'\n | 'macro'\n | 'regulatory'\n | 'technical'\n | 'social'\n | 'other';\n impact?: 'positive' | 'negative' | 'neutral';\n articles: Article[];\n relatedAssets: RelatedAsset[];\n};\n\n/**\n * Provider metadata included in AI API responses.\n */\nexport type AIResponseMetadata = {\n provider: string;\n};\n\nexport type MarketOverview = {\n version?: string;\n generatedAt: string;\n trends: MarketOverviewTrend[];\n metadata?: AIResponseMetadata[];\n};\n\n/**\n * A single market overview item. Shares the exact same schema as a\n * {@link MarketOverviewTrend} — i.e. one entry of `MarketOverview.trends`.\n */\nexport type MarketOverviewItem = MarketOverviewTrend;\n\n/**\n * A market overview \"front page\": a single AI-selected item (mirroring the\n * front page of a newspaper) plus its call-to-action copy, addressable by id.\n *\n * Returned by `GET /market-overview/front-page/:id` (and `.../latest`). Unlike\n * `/market-overview`, which only ever returns the latest report, this lets\n * clients fetch an older item that has since dropped out of the report.\n */\nexport type MarketOverviewFrontPage = {\n /** Unique identifier of the front-page row (UUID). */\n id: string;\n /** The selected item — same schema as an individual market overview item. */\n item: MarketOverviewItem;\n /** Call-to-action title for the front-page item. */\n ctaTitle: string;\n /** Call-to-action description for the front-page item. */\n ctaDescription: string;\n /** ISO date string when the front-page row was created. */\n createdAt: string;\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\n/**\n * AiDigestController has no persisted cache. Digest freshness is owned by\n * clients (e.g. React Query).\n */\nexport type AiDigestControllerState = Record<string, never>;\n\n// ---------------------------------------------------------------------------\n// Service interface\n// ---------------------------------------------------------------------------\n\nexport type DigestService = {\n /**\n * Search for market insights by asset identifier.\n *\n * Accepts any identifier the API understands — CAIP-19 asset type\n * (e.g. `eip155:1/slip44:60`), ticker symbol (e.g. `ETH`), asset name\n * (e.g. `Bitcoin`), or HyperLiquid perps market id (e.g. `xyz:TSLA`).\n *\n * Calls `GET /asset-summary?asset=<assetIdentifier>`.\n *\n * @param assetIdentifier - The asset identifier.\n * @returns The market insights report, or `null` if no insights exist (404).\n */\n searchDigest(assetIdentifier: string): Promise<MarketInsightsReport | null>;\n\n /**\n * Fetch the market overview report.\n * Calls `GET /market-overview`.\n *\n * @returns The market overview report, or `null` if none exists (404).\n */\n fetchMarketOverview(): Promise<MarketOverview | null>;\n\n /**\n * Fetch a single market overview front page by id.\n * Calls `GET /market-overview/front-page/:id`.\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists (404).\n */\n fetchFrontPageItem(id: string): Promise<MarketOverviewFrontPage | null>;\n};\n"]}
1
+ {"version":3,"file":"ai-digest-types.mjs","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E","sourcesContent":["// ---------------------------------------------------------------------------\n// Shared sub-types\n// ---------------------------------------------------------------------------\n\n/**\n * A news article referenced by a trend.\n */\nexport type Article = {\n /** Article title */\n title: string;\n /** Full URL to the article */\n url: string;\n /** Source domain name (e.g. \"coindesk.com\") */\n source: string;\n /** ISO date string */\n date: string;\n};\n\n/**\n * A social media post referenced by a trend.\n */\nexport type Tweet = {\n /** Summary of the tweet content */\n contentSummary: string;\n /** Full URL to the tweet */\n url: string;\n /** Author handle (e.g. \"@saylordocs\") */\n author: string;\n /** ISO date string */\n date: string;\n};\n\n/**\n * A data source used to generate a report.\n */\nexport type Source = {\n /** Source name (e.g. \"CoinDesk\") */\n name: string;\n /** Source URL */\n url: string;\n /** Source type */\n type: 'news' | 'data' | 'social';\n};\n\nexport type MarketInsightsArticle = Article;\nexport type MarketInsightsTweet = Tweet;\nexport type MarketInsightsSource = Source;\n\n// ---------------------------------------------------------------------------\n// Market Insights types (asset-specific)\n// ---------------------------------------------------------------------------\n\n/**\n * A key market trend identified in the insights report.\n */\nexport type MarketInsightsTrend = {\n /** Trend title (e.g. \"Institutions Buying the Dip\") */\n title: string;\n /** Detailed description of the trend */\n description: string;\n /** Category of the trend */\n category:\n | 'geopolitical'\n | 'macro'\n | 'regulatory'\n | 'technical'\n | 'social'\n | 'other';\n /** Impact direction */\n impact: 'positive' | 'negative' | 'neutral';\n /** Related news articles */\n articles: Article[];\n /** Related social media posts */\n tweets: Tweet[];\n};\n\n/**\n * AI-generated market insights report for a crypto asset.\n * Returned by `GET /asset-summary?asset=<identifier>`.\n */\nexport type MarketInsightsReport = {\n /** Unique identifier for this digest, sourced from the API response envelope. */\n digestId: string;\n /** API version */\n version?: string;\n /** Asset symbol (lowercase, e.g. \"btc\") */\n asset: string;\n /** ISO date string when the report was generated */\n generatedAt: string;\n /** Main headline */\n headline: string;\n /** Summary paragraph */\n summary: string;\n /** Key market trends */\n trends: MarketInsightsTrend[];\n /** Optional top-level social posts included by the API */\n social?: Tweet[];\n /** Data sources used to generate the report */\n sources: Source[];\n /** Provider metadata */\n metadata?: AIResponseMetadata[];\n};\n\n/**\n * A cached market insights entry.\n */\nexport type MarketInsightsEntry = {\n /** Asset identifier — either a CAIP-19 ID (e.g. \"eip155:1/slip44:60\") or a perps market symbol (e.g. \"ETH\") */\n assetIdentifier: string;\n /** Timestamp when the entry was fetched */\n fetchedAt: number;\n /** The market insights report data */\n data: MarketInsightsReport;\n};\n\n/**\n * A cached market overview entry.\n */\nexport type MarketOverviewEntry = {\n /** Timestamp when the entry was fetched */\n fetchedAt: number;\n /** The market overview data */\n data: MarketOverview;\n};\n\n// ---------------------------------------------------------------------------\n// Market Overview types (non-asset-specific)\n// ---------------------------------------------------------------------------\n\n/**\n * A crypto asset related to a market overview trend.\n * Returned by the `/market-overview` API as a rich object.\n */\nexport type RelatedAsset = {\n /**\n * Human-readable asset name (e.g. \"Bitcoin\"). Optional — clients must fall\n * back to `symbol` when absent.\n */\n name?: string;\n /** Ticker symbol (e.g. \"BTC\"). The only field guaranteed to be present. */\n symbol: string;\n /**\n * CAIP-19 identifiers for this asset across chains. May be absent for\n * purely synthetic / perps-only assets (e.g. ETHFI). The service\n * normalises missing values to `[]`.\n */\n caip19?: string[];\n /**\n * Canonical source asset identifier (e.g. \"bitcoin\"). Optional — may be\n * absent when the API pipeline cannot enrich the asset record.\n */\n sourceAssetId?: string;\n /**\n * Optional HyperLiquid market identifiers for this asset (e.g. `BTC`, `ETH`,\n * `xyz:TSLA`). Covers both regular crypto tokens that trade on HyperLiquid\n * and purely synthetic perps assets. Use this to resolve Perps icon URLs via\n * `getAssetIconUrls` on clients when `caip19` is empty.\n */\n hlPerpsMarket?: string[];\n};\n\nexport type MarketOverviewTrend = {\n title: string;\n description: string;\n category?:\n | 'geopolitical'\n | 'macro'\n | 'regulatory'\n | 'technical'\n | 'social'\n | 'other';\n impact?: 'positive' | 'negative' | 'neutral';\n articles: Article[];\n relatedAssets: RelatedAsset[];\n};\n\n/**\n * Provider metadata included in AI API responses.\n */\nexport type AIResponseMetadata = {\n provider: string;\n};\n\nexport type MarketOverview = {\n version?: string;\n generatedAt: string;\n trends: MarketOverviewTrend[];\n metadata?: AIResponseMetadata[];\n};\n\n/**\n * A single market overview item. Shares the exact same schema as a\n * {@link MarketOverviewTrend} — i.e. one entry of `MarketOverview.trends`.\n */\nexport type MarketOverviewItem = MarketOverviewTrend;\n\n/**\n * A market overview \"front page\": a single AI-selected item (mirroring the\n * front page of a newspaper) plus its call-to-action copy, addressable by id.\n *\n * Returned by `GET /market-overview/front-page/:id` (and `.../latest`). Unlike\n * `/market-overview`, which only ever returns the latest report, this lets\n * clients fetch an older item that has since dropped out of the report.\n */\nexport type MarketOverviewFrontPage = {\n /** Unique identifier of the front-page row (UUID). */\n id: string;\n /** The selected item — same schema as an individual market overview item. */\n item: MarketOverviewItem;\n /** Call-to-action title for the front-page item. */\n ctaTitle: string;\n /** Call-to-action description for the front-page item. */\n ctaDescription: string;\n /** ISO date string when the front-page row was created. */\n createdAt: string;\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\nexport type AiDigestControllerState = {\n marketInsights: Record<string, MarketInsightsEntry>;\n marketOverview: MarketOverviewEntry | null;\n};\n\n// ---------------------------------------------------------------------------\n// Service interface\n// ---------------------------------------------------------------------------\n\nexport type DigestService = {\n /**\n * Search for market insights by asset identifier.\n *\n * Accepts any identifier the API understands — CAIP-19 asset type\n * (e.g. `eip155:1/slip44:60`), ticker symbol (e.g. `ETH`), asset name\n * (e.g. `Bitcoin`), or HyperLiquid perps market id (e.g. `xyz:TSLA`).\n *\n * Calls `GET /asset-summary?asset=<assetIdentifier>`.\n *\n * @param assetIdentifier - The asset identifier.\n * @returns The market insights report, or `null` if no insights exist (404).\n */\n searchDigest(assetIdentifier: string): Promise<MarketInsightsReport | null>;\n\n /**\n * Fetch the market overview report.\n * Calls `GET /market-overview`.\n *\n * @returns The market overview report, or `null` if none exists (404).\n */\n fetchMarketOverview(): Promise<MarketOverview | null>;\n\n /**\n * Fetch a single market overview front page by id.\n * Calls `GET /market-overview/front-page/:id`.\n *\n * @param id - The front-page identifier (UUID).\n * @returns The market overview front page, or `null` if none exists (404).\n */\n fetchFrontPageItem(id: string): Promise<MarketOverviewFrontPage | null>;\n};\n"]}
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AiDigestControllerErrorMessage = exports.aiDigestControllerName = exports.AiDigestService = exports.getDefaultAiDigestControllerState = exports.AiDigestController = void 0;
3
+ exports.AiDigestControllerErrorMessage = exports.MAX_CACHE_ENTRIES = exports.CACHE_DURATION_MS = exports.aiDigestControllerName = exports.AiDigestService = exports.getDefaultAiDigestControllerState = exports.AiDigestController = void 0;
4
4
  var AiDigestController_js_1 = require("./AiDigestController.cjs");
5
5
  Object.defineProperty(exports, "AiDigestController", { enumerable: true, get: function () { return AiDigestController_js_1.AiDigestController; } });
6
6
  Object.defineProperty(exports, "getDefaultAiDigestControllerState", { enumerable: true, get: function () { return AiDigestController_js_1.getDefaultAiDigestControllerState; } });
@@ -8,5 +8,7 @@ var AiDigestService_js_1 = require("./AiDigestService.cjs");
8
8
  Object.defineProperty(exports, "AiDigestService", { enumerable: true, get: function () { return AiDigestService_js_1.AiDigestService; } });
9
9
  var ai_digest_constants_js_1 = require("./ai-digest-constants.cjs");
10
10
  Object.defineProperty(exports, "aiDigestControllerName", { enumerable: true, get: function () { return ai_digest_constants_js_1.controllerName; } });
11
+ Object.defineProperty(exports, "CACHE_DURATION_MS", { enumerable: true, get: function () { return ai_digest_constants_js_1.CACHE_DURATION_MS; } });
12
+ Object.defineProperty(exports, "MAX_CACHE_ENTRIES", { enumerable: true, get: function () { return ai_digest_constants_js_1.MAX_CACHE_ENTRIES; } });
11
13
  Object.defineProperty(exports, "AiDigestControllerErrorMessage", { enumerable: true, get: function () { return ai_digest_constants_js_1.AiDigestControllerErrorMessage; } });
12
14
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,kEAGiC;AAF/B,2HAAA,kBAAkB,OAAA;AAClB,0IAAA,iCAAiC,OAAA;AASnC,4DAAuD;AAA9C,qHAAA,eAAe,OAAA;AAqBxB,oEAGkC;AAFhC,gIAAA,cAAc,OAA0B;AACxC,wIAAA,8BAA8B,OAAA","sourcesContent":["export type {\n AiDigestControllerActions,\n AiDigestControllerEvents,\n AiDigestControllerGetStateAction,\n AiDigestControllerMessenger,\n AiDigestControllerOptions,\n AiDigestControllerStateChangeEvent,\n} from './AiDigestController.js';\nexport {\n AiDigestController,\n getDefaultAiDigestControllerState,\n} from './AiDigestController.js';\nexport type {\n AiDigestControllerFetchMarketInsightsAction,\n AiDigestControllerFetchMarketOverviewAction,\n AiDigestControllerFetchFrontPageItemAction,\n} from './AiDigestController-method-action-types.js';\n\nexport type { AiDigestServiceConfig } from './AiDigestService.js';\nexport { AiDigestService } from './AiDigestService.js';\n\nexport type {\n AiDigestControllerState,\n AIResponseMetadata,\n Article,\n DigestService,\n MarketInsightsArticle,\n MarketInsightsReport,\n MarketInsightsSource,\n MarketInsightsTrend,\n MarketInsightsTweet,\n MarketOverview,\n MarketOverviewFrontPage,\n MarketOverviewItem,\n MarketOverviewTrend,\n RelatedAsset,\n Source,\n Tweet,\n} from './ai-digest-types.js';\n\nexport {\n controllerName as aiDigestControllerName,\n AiDigestControllerErrorMessage,\n} from './ai-digest-constants.js';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,kEAGiC;AAF/B,2HAAA,kBAAkB,OAAA;AAClB,0IAAA,iCAAiC,OAAA;AASnC,4DAAuD;AAA9C,qHAAA,eAAe,OAAA;AAuBxB,oEAKkC;AAJhC,gIAAA,cAAc,OAA0B;AACxC,2HAAA,iBAAiB,OAAA;AACjB,2HAAA,iBAAiB,OAAA;AACjB,wIAAA,8BAA8B,OAAA","sourcesContent":["export type {\n AiDigestControllerActions,\n AiDigestControllerEvents,\n AiDigestControllerGetStateAction,\n AiDigestControllerMessenger,\n AiDigestControllerOptions,\n AiDigestControllerStateChangeEvent,\n} from './AiDigestController.js';\nexport {\n AiDigestController,\n getDefaultAiDigestControllerState,\n} from './AiDigestController.js';\nexport type {\n AiDigestControllerFetchMarketInsightsAction,\n AiDigestControllerFetchMarketOverviewAction,\n AiDigestControllerFetchFrontPageItemAction,\n} from './AiDigestController-method-action-types.js';\n\nexport type { AiDigestServiceConfig } from './AiDigestService.js';\nexport { AiDigestService } from './AiDigestService.js';\n\nexport type {\n AiDigestControllerState,\n AIResponseMetadata,\n Article,\n DigestService,\n MarketInsightsArticle,\n MarketInsightsEntry,\n MarketInsightsReport,\n MarketInsightsSource,\n MarketInsightsTrend,\n MarketInsightsTweet,\n MarketOverview,\n MarketOverviewEntry,\n MarketOverviewFrontPage,\n MarketOverviewItem,\n MarketOverviewTrend,\n RelatedAsset,\n Source,\n Tweet,\n} from './ai-digest-types.js';\n\nexport {\n controllerName as aiDigestControllerName,\n CACHE_DURATION_MS,\n MAX_CACHE_ENTRIES,\n AiDigestControllerErrorMessage,\n} from './ai-digest-constants.js';\n"]}
package/dist/index.d.cts CHANGED
@@ -3,6 +3,6 @@ export { AiDigestController, getDefaultAiDigestControllerState, } from "./AiDige
3
3
  export type { AiDigestControllerFetchMarketInsightsAction, AiDigestControllerFetchMarketOverviewAction, AiDigestControllerFetchFrontPageItemAction, } from "./AiDigestController-method-action-types.cjs";
4
4
  export type { AiDigestServiceConfig } from "./AiDigestService.cjs";
5
5
  export { AiDigestService } from "./AiDigestService.cjs";
6
- export type { AiDigestControllerState, AIResponseMetadata, Article, DigestService, MarketInsightsArticle, MarketInsightsReport, MarketInsightsSource, MarketInsightsTrend, MarketInsightsTweet, MarketOverview, MarketOverviewFrontPage, MarketOverviewItem, MarketOverviewTrend, RelatedAsset, Source, Tweet, } from "./ai-digest-types.cjs";
7
- export { controllerName as aiDigestControllerName, AiDigestControllerErrorMessage, } from "./ai-digest-constants.cjs";
6
+ export type { AiDigestControllerState, AIResponseMetadata, Article, DigestService, MarketInsightsArticle, MarketInsightsEntry, MarketInsightsReport, MarketInsightsSource, MarketInsightsTrend, MarketInsightsTweet, MarketOverview, MarketOverviewEntry, MarketOverviewFrontPage, MarketOverviewItem, MarketOverviewTrend, RelatedAsset, Source, Tweet, } from "./ai-digest-types.cjs";
7
+ export { controllerName as aiDigestControllerName, CACHE_DURATION_MS, MAX_CACHE_ENTRIES, AiDigestControllerErrorMessage, } from "./ai-digest-constants.cjs";
8
8
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,gCAAgC,EAChC,2BAA2B,EAC3B,yBAAyB,EACzB,kCAAkC,GACnC,iCAAgC;AACjC,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAClC,iCAAgC;AACjC,YAAY,EACV,2CAA2C,EAC3C,2CAA2C,EAC3C,0CAA0C,GAC3C,qDAAoD;AAErD,YAAY,EAAE,qBAAqB,EAAE,8BAA6B;AAClE,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAEvD,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,MAAM,EACN,KAAK,GACN,8BAA6B;AAE9B,OAAO,EACL,cAAc,IAAI,sBAAsB,EACxC,8BAA8B,GAC/B,kCAAiC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,gCAAgC,EAChC,2BAA2B,EAC3B,yBAAyB,EACzB,kCAAkC,GACnC,iCAAgC;AACjC,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAClC,iCAAgC;AACjC,YAAY,EACV,2CAA2C,EAC3C,2CAA2C,EAC3C,0CAA0C,GAC3C,qDAAoD;AAErD,YAAY,EAAE,qBAAqB,EAAE,8BAA6B;AAClE,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAEvD,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,MAAM,EACN,KAAK,GACN,8BAA6B;AAE9B,OAAO,EACL,cAAc,IAAI,sBAAsB,EACxC,iBAAiB,EACjB,iBAAiB,EACjB,8BAA8B,GAC/B,kCAAiC"}
package/dist/index.d.mts CHANGED
@@ -3,6 +3,6 @@ export { AiDigestController, getDefaultAiDigestControllerState, } from "./AiDige
3
3
  export type { AiDigestControllerFetchMarketInsightsAction, AiDigestControllerFetchMarketOverviewAction, AiDigestControllerFetchFrontPageItemAction, } from "./AiDigestController-method-action-types.mjs";
4
4
  export type { AiDigestServiceConfig } from "./AiDigestService.mjs";
5
5
  export { AiDigestService } from "./AiDigestService.mjs";
6
- export type { AiDigestControllerState, AIResponseMetadata, Article, DigestService, MarketInsightsArticle, MarketInsightsReport, MarketInsightsSource, MarketInsightsTrend, MarketInsightsTweet, MarketOverview, MarketOverviewFrontPage, MarketOverviewItem, MarketOverviewTrend, RelatedAsset, Source, Tweet, } from "./ai-digest-types.mjs";
7
- export { controllerName as aiDigestControllerName, AiDigestControllerErrorMessage, } from "./ai-digest-constants.mjs";
6
+ export type { AiDigestControllerState, AIResponseMetadata, Article, DigestService, MarketInsightsArticle, MarketInsightsEntry, MarketInsightsReport, MarketInsightsSource, MarketInsightsTrend, MarketInsightsTweet, MarketOverview, MarketOverviewEntry, MarketOverviewFrontPage, MarketOverviewItem, MarketOverviewTrend, RelatedAsset, Source, Tweet, } from "./ai-digest-types.mjs";
7
+ export { controllerName as aiDigestControllerName, CACHE_DURATION_MS, MAX_CACHE_ENTRIES, AiDigestControllerErrorMessage, } from "./ai-digest-constants.mjs";
8
8
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,gCAAgC,EAChC,2BAA2B,EAC3B,yBAAyB,EACzB,kCAAkC,GACnC,iCAAgC;AACjC,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAClC,iCAAgC;AACjC,YAAY,EACV,2CAA2C,EAC3C,2CAA2C,EAC3C,0CAA0C,GAC3C,qDAAoD;AAErD,YAAY,EAAE,qBAAqB,EAAE,8BAA6B;AAClE,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAEvD,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,MAAM,EACN,KAAK,GACN,8BAA6B;AAE9B,OAAO,EACL,cAAc,IAAI,sBAAsB,EACxC,8BAA8B,GAC/B,kCAAiC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,gCAAgC,EAChC,2BAA2B,EAC3B,yBAAyB,EACzB,kCAAkC,GACnC,iCAAgC;AACjC,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAClC,iCAAgC;AACjC,YAAY,EACV,2CAA2C,EAC3C,2CAA2C,EAC3C,0CAA0C,GAC3C,qDAAoD;AAErD,YAAY,EAAE,qBAAqB,EAAE,8BAA6B;AAClE,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAEvD,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,MAAM,EACN,KAAK,GACN,8BAA6B;AAE9B,OAAO,EACL,cAAc,IAAI,sBAAsB,EACxC,iBAAiB,EACjB,iBAAiB,EACjB,8BAA8B,GAC/B,kCAAiC"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  export { AiDigestController, getDefaultAiDigestControllerState } from "./AiDigestController.mjs";
2
2
  export { AiDigestService } from "./AiDigestService.mjs";
3
- export { controllerName as aiDigestControllerName, AiDigestControllerErrorMessage } from "./ai-digest-constants.mjs";
3
+ export { controllerName as aiDigestControllerName, CACHE_DURATION_MS, MAX_CACHE_ENTRIES, AiDigestControllerErrorMessage } from "./ai-digest-constants.mjs";
4
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EAClC,iCAAgC;AAQjC,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAqBvD,OAAO,EACL,cAAc,IAAI,sBAAsB,EACxC,8BAA8B,EAC/B,kCAAiC","sourcesContent":["export type {\n AiDigestControllerActions,\n AiDigestControllerEvents,\n AiDigestControllerGetStateAction,\n AiDigestControllerMessenger,\n AiDigestControllerOptions,\n AiDigestControllerStateChangeEvent,\n} from './AiDigestController.js';\nexport {\n AiDigestController,\n getDefaultAiDigestControllerState,\n} from './AiDigestController.js';\nexport type {\n AiDigestControllerFetchMarketInsightsAction,\n AiDigestControllerFetchMarketOverviewAction,\n AiDigestControllerFetchFrontPageItemAction,\n} from './AiDigestController-method-action-types.js';\n\nexport type { AiDigestServiceConfig } from './AiDigestService.js';\nexport { AiDigestService } from './AiDigestService.js';\n\nexport type {\n AiDigestControllerState,\n AIResponseMetadata,\n Article,\n DigestService,\n MarketInsightsArticle,\n MarketInsightsReport,\n MarketInsightsSource,\n MarketInsightsTrend,\n MarketInsightsTweet,\n MarketOverview,\n MarketOverviewFrontPage,\n MarketOverviewItem,\n MarketOverviewTrend,\n RelatedAsset,\n Source,\n Tweet,\n} from './ai-digest-types.js';\n\nexport {\n controllerName as aiDigestControllerName,\n AiDigestControllerErrorMessage,\n} from './ai-digest-constants.js';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EAClC,iCAAgC;AAQjC,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAuBvD,OAAO,EACL,cAAc,IAAI,sBAAsB,EACxC,iBAAiB,EACjB,iBAAiB,EACjB,8BAA8B,EAC/B,kCAAiC","sourcesContent":["export type {\n AiDigestControllerActions,\n AiDigestControllerEvents,\n AiDigestControllerGetStateAction,\n AiDigestControllerMessenger,\n AiDigestControllerOptions,\n AiDigestControllerStateChangeEvent,\n} from './AiDigestController.js';\nexport {\n AiDigestController,\n getDefaultAiDigestControllerState,\n} from './AiDigestController.js';\nexport type {\n AiDigestControllerFetchMarketInsightsAction,\n AiDigestControllerFetchMarketOverviewAction,\n AiDigestControllerFetchFrontPageItemAction,\n} from './AiDigestController-method-action-types.js';\n\nexport type { AiDigestServiceConfig } from './AiDigestService.js';\nexport { AiDigestService } from './AiDigestService.js';\n\nexport type {\n AiDigestControllerState,\n AIResponseMetadata,\n Article,\n DigestService,\n MarketInsightsArticle,\n MarketInsightsEntry,\n MarketInsightsReport,\n MarketInsightsSource,\n MarketInsightsTrend,\n MarketInsightsTweet,\n MarketOverview,\n MarketOverviewEntry,\n MarketOverviewFrontPage,\n MarketOverviewItem,\n MarketOverviewTrend,\n RelatedAsset,\n Source,\n Tweet,\n} from './ai-digest-types.js';\n\nexport {\n controllerName as aiDigestControllerName,\n CACHE_DURATION_MS,\n MAX_CACHE_ENTRIES,\n AiDigestControllerErrorMessage,\n} from './ai-digest-constants.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/ai-controllers",
3
- "version": "0.8.0-preview-e3275932a",
3
+ "version": "0.8.0-preview-99421bfe4",
4
4
  "description": "A collection of AI-related controllers",
5
5
  "keywords": [
6
6
  "Ethereum",