@metamask-previews/ai-controllers 1.0.0-preview-8bfa290fb → 2.0.0-preview-0a30e47

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 (64) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/{AiDigestController-method-action-types.d.mts → AiDigestController-method-action-types.d.ts} +2 -2
  3. package/dist/AiDigestController-method-action-types.d.ts.map +1 -0
  4. package/dist/{AiDigestController-method-action-types.mjs → AiDigestController-method-action-types.js} +1 -1
  5. package/dist/AiDigestController-method-action-types.js.map +1 -0
  6. package/dist/{AiDigestController.d.cts → AiDigestController.d.ts} +7 -7
  7. package/dist/AiDigestController.d.ts.map +1 -0
  8. package/dist/{AiDigestController.mjs → AiDigestController.js} +8 -21
  9. package/dist/AiDigestController.js.map +1 -0
  10. package/dist/{AiDigestService.d.cts → AiDigestService.d.ts} +2 -2
  11. package/dist/AiDigestService.d.ts.map +1 -0
  12. package/dist/{AiDigestService.mjs → AiDigestService.js} +8 -21
  13. package/dist/AiDigestService.js.map +1 -0
  14. package/dist/ai-digest-constants.d.ts +8 -0
  15. package/dist/ai-digest-constants.d.ts.map +1 -0
  16. package/dist/{ai-digest-constants.mjs → ai-digest-constants.js} +1 -1
  17. package/dist/ai-digest-constants.js.map +1 -0
  18. package/dist/{ai-digest-types.d.cts → ai-digest-types.d.ts} +1 -1
  19. package/dist/ai-digest-types.d.ts.map +1 -0
  20. package/dist/{ai-digest-types.mjs → ai-digest-types.js} +1 -1
  21. package/dist/ai-digest-types.js.map +1 -0
  22. package/dist/{index.d.cts → index.d.ts} +8 -8
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +4 -0
  25. package/dist/index.js.map +1 -0
  26. package/package.json +14 -18
  27. package/dist/AiDigestController-method-action-types.cjs +0 -7
  28. package/dist/AiDigestController-method-action-types.cjs.map +0 -1
  29. package/dist/AiDigestController-method-action-types.d.cts +0 -49
  30. package/dist/AiDigestController-method-action-types.d.cts.map +0 -1
  31. package/dist/AiDigestController-method-action-types.d.mts.map +0 -1
  32. package/dist/AiDigestController-method-action-types.mjs.map +0 -1
  33. package/dist/AiDigestController.cjs +0 -85
  34. package/dist/AiDigestController.cjs.map +0 -1
  35. package/dist/AiDigestController.d.cts.map +0 -1
  36. package/dist/AiDigestController.d.mts +0 -51
  37. package/dist/AiDigestController.d.mts.map +0 -1
  38. package/dist/AiDigestController.mjs.map +0 -1
  39. package/dist/AiDigestService.cjs +0 -217
  40. package/dist/AiDigestService.cjs.map +0 -1
  41. package/dist/AiDigestService.d.cts.map +0 -1
  42. package/dist/AiDigestService.d.mts +0 -40
  43. package/dist/AiDigestService.d.mts.map +0 -1
  44. package/dist/AiDigestService.mjs.map +0 -1
  45. package/dist/ai-digest-constants.cjs +0 -11
  46. package/dist/ai-digest-constants.cjs.map +0 -1
  47. package/dist/ai-digest-constants.d.cts +0 -8
  48. package/dist/ai-digest-constants.d.cts.map +0 -1
  49. package/dist/ai-digest-constants.d.mts +0 -8
  50. package/dist/ai-digest-constants.d.mts.map +0 -1
  51. package/dist/ai-digest-constants.mjs.map +0 -1
  52. package/dist/ai-digest-types.cjs +0 -6
  53. package/dist/ai-digest-types.cjs.map +0 -1
  54. package/dist/ai-digest-types.d.cts.map +0 -1
  55. package/dist/ai-digest-types.d.mts +0 -195
  56. package/dist/ai-digest-types.d.mts.map +0 -1
  57. package/dist/ai-digest-types.mjs.map +0 -1
  58. package/dist/index.cjs +0 -12
  59. package/dist/index.cjs.map +0 -1
  60. package/dist/index.d.cts.map +0 -1
  61. package/dist/index.d.mts +0 -8
  62. package/dist/index.d.mts.map +0 -1
  63. package/dist/index.mjs +0 -4
  64. package/dist/index.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,9 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.0]
11
+
10
12
  ### Changed
11
13
 
14
+ - **BREAKING:** Drop CommonJS support ([#9536](https://github.com/MetaMask/core/pull/9536))
15
+ - This package is now ESM-only, but can still be used in CommonJS projects via `require(esm)` in modern Node.js versions (22+), or dynamic imports in older Node.js versions.
16
+ - **BREAKING:** Bump minimum Node.js version to 22 ([#9976](https://github.com/MetaMask/core/pull/9976))
17
+ - **BREAKING:** Bump TypeScript target to ES2022 ([#10019](https://github.com/MetaMask/core/pull/10019))
18
+ - This package now ships ES2022 code, requiring a compatible modern environment or bundler configuration to consume.
12
19
  - Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076))
20
+ - Bump `@metamask/base-controller` from `^9.1.0` to `^10.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160))
21
+ - Bump `@metamask/messenger` from `^2.0.0` to `^3.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160))
13
22
 
14
23
  ## [1.0.0]
15
24
 
@@ -136,7 +145,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
136
145
  - Removes `fetchDigest`, `clearDigest`, and `clearAllDigests` actions from the controller action surface.
137
146
  - Removes `DigestData`/`DigestEntry` types and the `digests` state branch.
138
147
 
139
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/ai-controllers@1.0.0...HEAD
148
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/ai-controllers@2.0.0...HEAD
149
+ [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/ai-controllers@1.0.0...@metamask/ai-controllers@2.0.0
140
150
  [1.0.0]: https://github.com/MetaMask/core/compare/@metamask/ai-controllers@0.8.0...@metamask/ai-controllers@1.0.0
141
151
  [0.8.0]: https://github.com/MetaMask/core/compare/@metamask/ai-controllers@0.7.0...@metamask/ai-controllers@0.8.0
142
152
  [0.7.0]: https://github.com/MetaMask/core/compare/@metamask/ai-controllers@0.6.3...@metamask/ai-controllers@0.7.0
@@ -2,7 +2,7 @@
2
2
  * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
- import type { AiDigestController } from "./AiDigestController.mjs";
5
+ import type { AiDigestController } from './AiDigestController.js';
6
6
  /**
7
7
  * Fetches market insights for a given asset identifier.
8
8
  *
@@ -46,4 +46,4 @@ export type AiDigestControllerFetchFrontPageItemAction = {
46
46
  * Union of all AiDigestController action types.
47
47
  */
48
48
  export type AiDigestControllerMethodActions = AiDigestControllerFetchMarketInsightsAction | AiDigestControllerFetchMarketOverviewAction | AiDigestControllerFetchFrontPageItemAction;
49
- //# sourceMappingURL=AiDigestController-method-action-types.d.mts.map
49
+ //# sourceMappingURL=AiDigestController-method-action-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiDigestController-method-action-types.d.ts","sourceRoot":"","sources":["../src/AiDigestController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;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"}
@@ -3,4 +3,4 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=AiDigestController-method-action-types.mjs.map
6
+ //# sourceMappingURL=AiDigestController-method-action-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiDigestController-method-action-types.js","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,9 +1,9 @@
1
- import type { ControllerStateChangeEvent, ControllerGetStateAction } from "@metamask/base-controller";
2
- import { BaseController } from "@metamask/base-controller";
3
- import type { Messenger } from "@metamask/messenger";
4
- import { controllerName } from "./ai-digest-constants.cjs";
5
- import type { AiDigestControllerState, DigestService, MarketInsightsReport, MarketOverview, MarketOverviewFrontPage } from "./ai-digest-types.cjs";
6
- import type { AiDigestControllerMethodActions } from "./AiDigestController-method-action-types.cjs";
1
+ import type { ControllerStateChangeEvent, ControllerGetStateAction } from '@metamask/base-controller';
2
+ import { BaseController } from '@metamask/base-controller';
3
+ import type { Messenger } from '@metamask/messenger';
4
+ import { controllerName } from './ai-digest-constants.js';
5
+ import type { AiDigestControllerState, DigestService, MarketInsightsReport, MarketOverview, MarketOverviewFrontPage } from './ai-digest-types.js';
6
+ import type { AiDigestControllerMethodActions } from './AiDigestController-method-action-types.js';
7
7
  export type AiDigestControllerGetStateAction = ControllerGetStateAction<typeof controllerName, AiDigestControllerState>;
8
8
  export type AiDigestControllerActions = AiDigestControllerGetStateAction | AiDigestControllerMethodActions;
9
9
  export type AiDigestControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, AiDigestControllerState>;
@@ -48,4 +48,4 @@ export declare class AiDigestController extends BaseController<typeof controller
48
48
  */
49
49
  fetchFrontPageItem(id: string): Promise<MarketOverviewFrontPage | null>;
50
50
  }
51
- //# sourceMappingURL=AiDigestController.d.cts.map
51
+ //# sourceMappingURL=AiDigestController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiDigestController.d.ts","sourceRoot":"","sources":["../src/AiDigestController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAEL,cAAc,EACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;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,EACrB,uBAAuB,EACvB,2BAA2B,CAC5B;;IAGC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,yBAAyB,EAalE;IAED;;;;;;;;;OASG;IACG,mBAAmB,CACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAMtC;IAED;;;;;;OAMG;IACG,mBAAmB,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAE1D;IAED;;;;;;;;;OASG;IACG,kBAAkB,CACtB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAMzC;CACF"}
@@ -1,17 +1,5 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _AiDigestController_digestService;
13
- import { BaseController } from "@metamask/base-controller";
14
- import { AiDigestControllerErrorMessage, controllerName } from "./ai-digest-constants.mjs";
1
+ import { BaseController } from '@metamask/base-controller';
2
+ import { AiDigestControllerErrorMessage, controllerName, } from './ai-digest-constants.js';
15
3
  export function getDefaultAiDigestControllerState() {
16
4
  return {};
17
5
  }
@@ -22,6 +10,7 @@ const MESSENGER_EXPOSED_METHODS = [
22
10
  'fetchFrontPageItem',
23
11
  ];
24
12
  export class AiDigestController extends BaseController {
13
+ #digestService;
25
14
  constructor({ messenger, digestService }) {
26
15
  super({
27
16
  name: controllerName,
@@ -29,8 +18,7 @@ export class AiDigestController extends BaseController {
29
18
  state: getDefaultAiDigestControllerState(),
30
19
  messenger,
31
20
  });
32
- _AiDigestController_digestService.set(this, void 0);
33
- __classPrivateFieldSet(this, _AiDigestController_digestService, digestService, "f");
21
+ this.#digestService = digestService;
34
22
  this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
35
23
  }
36
24
  /**
@@ -47,7 +35,7 @@ export class AiDigestController extends BaseController {
47
35
  if (!assetIdentifier) {
48
36
  throw new Error(AiDigestControllerErrorMessage.INVALID_ASSET_IDENTIFIER);
49
37
  }
50
- return __classPrivateFieldGet(this, _AiDigestController_digestService, "f").searchDigest(assetIdentifier);
38
+ return this.#digestService.searchDigest(assetIdentifier);
51
39
  }
52
40
  /**
53
41
  * Fetches the market overview report.
@@ -57,7 +45,7 @@ export class AiDigestController extends BaseController {
57
45
  * @returns The market overview report, or `null` if none exists.
58
46
  */
59
47
  async fetchMarketOverview() {
60
- return __classPrivateFieldGet(this, _AiDigestController_digestService, "f").fetchMarketOverview();
48
+ return this.#digestService.fetchMarketOverview();
61
49
  }
62
50
  /**
63
51
  * Fetches a single market overview front page by id.
@@ -73,8 +61,7 @@ export class AiDigestController extends BaseController {
73
61
  if (!id) {
74
62
  throw new Error(AiDigestControllerErrorMessage.INVALID_FRONT_PAGE_ID);
75
63
  }
76
- return __classPrivateFieldGet(this, _AiDigestController_digestService, "f").fetchFrontPageItem(id);
64
+ return this.#digestService.fetchFrontPageItem(id);
77
65
  }
78
66
  }
79
- _AiDigestController_digestService = new WeakMap();
80
- //# sourceMappingURL=AiDigestController.mjs.map
67
+ //# sourceMappingURL=AiDigestController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiDigestController.js","sourceRoot":"","sources":["../src/AiDigestController.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EACL,8BAA8B,EAC9B,cAAc,GACf,MAAM,0BAA0B,CAAC;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;IACU,cAAc,CAAgB;IAEvC,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;QAEH,IAAI,CAAC,cAAc,GAAG,aAAa,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,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB;QACvB,OAAO,IAAI,CAAC,cAAc,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,IAAI,CAAC,cAAc,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,4 +1,4 @@
1
- import type { DigestService, MarketInsightsReport, MarketOverview, MarketOverviewFrontPage } from "./ai-digest-types.cjs";
1
+ import type { DigestService, MarketInsightsReport, MarketOverview, MarketOverviewFrontPage } from './ai-digest-types.js';
2
2
  export type AiDigestServiceConfig = {
3
3
  baseUrl: string;
4
4
  };
@@ -37,4 +37,4 @@ export declare class AiDigestService implements DigestService {
37
37
  */
38
38
  searchDigest(assetIdentifier: string): Promise<MarketInsightsReport | null>;
39
39
  }
40
- //# sourceMappingURL=AiDigestService.d.cts.map
40
+ //# sourceMappingURL=AiDigestService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiDigestService.d.ts","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EAExB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA2JF,qBAAa,eAAgB,YAAW,aAAa;;IAGnD,YAAY,MAAM,EAAE,qBAAqB,EAExC;IAED;;;;;;OAMG;IACG,mBAAmB,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAoB1D;IAED;;;;;;;OAOG;IACG,kBAAkB,CACtB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAsBzC;IAED;;;;;;;;;;;;OAYG;IACG,YAAY,CAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAsBtC;CACF"}
@@ -1,17 +1,5 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _AiDigestService_baseUrl;
13
- import { array, enums, is, optional, string, type as structType } from "@metamask/superstruct";
14
- import { AiDigestControllerErrorMessage } from "./ai-digest-constants.mjs";
1
+ import { array, enums, is, optional, string, type as structType, } from '@metamask/superstruct';
2
+ import { AiDigestControllerErrorMessage } from './ai-digest-constants.js';
15
3
  // Shared sub-type structs
16
4
  const ArticleStruct = structType({
17
5
  title: string(),
@@ -134,9 +122,9 @@ const getNormalizedMarketInsightsReport = (value) => {
134
122
  return null;
135
123
  };
136
124
  export class AiDigestService {
125
+ #baseUrl;
137
126
  constructor(config) {
138
- _AiDigestService_baseUrl.set(this, void 0);
139
- __classPrivateFieldSet(this, _AiDigestService_baseUrl, config.baseUrl, "f");
127
+ this.#baseUrl = config.baseUrl;
140
128
  }
141
129
  /**
142
130
  * Fetch the market overview report.
@@ -146,7 +134,7 @@ export class AiDigestService {
146
134
  * @returns The market overview report, or `null` if none exists (404).
147
135
  */
148
136
  async fetchMarketOverview() {
149
- const response = await fetch(`${__classPrivateFieldGet(this, _AiDigestService_baseUrl, "f")}/market-overview`);
137
+ const response = await fetch(`${this.#baseUrl}/market-overview`);
150
138
  if (response.status === 404) {
151
139
  return null;
152
140
  }
@@ -168,7 +156,7 @@ export class AiDigestService {
168
156
  * @returns The market overview front page, or `null` if none exists (404).
169
157
  */
170
158
  async fetchFrontPageItem(id) {
171
- const response = await fetch(`${__classPrivateFieldGet(this, _AiDigestService_baseUrl, "f")}/market-overview/front-page/${encodeURIComponent(id)}`);
159
+ const response = await fetch(`${this.#baseUrl}/market-overview/front-page/${encodeURIComponent(id)}`);
172
160
  if (response.status === 404) {
173
161
  return null;
174
162
  }
@@ -195,7 +183,7 @@ export class AiDigestService {
195
183
  * @returns The market insights report, or `null` if none exists (404).
196
184
  */
197
185
  async searchDigest(assetIdentifier) {
198
- const response = await fetch(`${__classPrivateFieldGet(this, _AiDigestService_baseUrl, "f")}/asset-summary?asset=${encodeURIComponent(assetIdentifier)}`);
186
+ const response = await fetch(`${this.#baseUrl}/asset-summary?asset=${encodeURIComponent(assetIdentifier)}`);
199
187
  if (response.status === 404) {
200
188
  return null;
201
189
  }
@@ -209,5 +197,4 @@ export class AiDigestService {
209
197
  return report;
210
198
  }
211
199
  }
212
- _AiDigestService_baseUrl = new WeakMap();
213
- //# sourceMappingURL=AiDigestService.mjs.map
200
+ //# sourceMappingURL=AiDigestService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiDigestService.js","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EACL,EAAE,EACF,QAAQ,EACR,MAAM,EACN,IAAI,IAAI,UAAU,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAa1E,0BAA0B;AAE1B,MAAM,aAAa,GAAG,UAAU,CAAC;IAC/B,KAAK,EAAE,MAAM,EAAE;IACf,GAAG,EAAE,MAAM,EAAE;IACb,MAAM,EAAE,MAAM,EAAE;IAChB,I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AO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import {\n array,\n enums,\n is,\n optional,\n string,\n type as structType,\n} from '@metamask/superstruct';\n\nimport { AiDigestControllerErrorMessage } from './ai-digest-constants.js';\nimport type {\n DigestService,\n MarketInsightsReport,\n MarketOverview,\n MarketOverviewFrontPage,\n MarketOverviewTrend,\n} from './ai-digest-types.js';\n\nexport type AiDigestServiceConfig = {\n baseUrl: string;\n};\n\n// Shared sub-type structs\n\nconst ArticleStruct = structType({\n title: string(),\n url: string(),\n source: string(),\n date: string(),\n});\n\nconst TweetStruct = structType({\n contentSummary: string(),\n url: string(),\n author: string(),\n date: string(),\n});\n\nconst SourceStruct = structType({\n name: string(),\n url: string(),\n type: enums(['news', 'data', 'social'] as const),\n});\n\nconst AIResponseMetadataStruct = structType({\n provider: string(),\n});\n\nconst trendCategoryValues = [\n 'geopolitical',\n 'macro',\n 'regulatory',\n 'technical',\n 'social',\n 'other',\n] as const;\n\nconst trendImpactValues = ['positive', 'negative', 'neutral'] as const;\n\n// Market Insights structs\n\nconst MarketInsightsTrendStruct = structType({\n title: string(),\n description: string(),\n category: enums(trendCategoryValues),\n impact: enums(trendImpactValues),\n articles: array(ArticleStruct),\n tweets: array(TweetStruct),\n});\n\nconst MarketInsightsReportStruct = structType({\n version: optional(string()),\n asset: string(),\n generatedAt: string(),\n headline: string(),\n summary: string(),\n trends: array(MarketInsightsTrendStruct),\n social: optional(array(TweetStruct)),\n sources: array(SourceStruct),\n metadata: optional(array(AIResponseMetadataStruct)),\n});\n\nconst MarketInsightsDigestEnvelopeStruct = structType({\n id: string(),\n digest: MarketInsightsReportStruct,\n});\n\n// Market Overview structs\n\nconst RelatedAssetStruct = structType({\n name: optional(string()),\n symbol: string(),\n caip19: optional(array(string())),\n sourceAssetId: optional(string()),\n hlPerpsMarket: optional(array(string())),\n});\n\nconst MarketOverviewTrendStruct = structType({\n title: string(),\n description: string(),\n category: optional(enums(trendCategoryValues)),\n impact: optional(enums(trendImpactValues)),\n articles: array(ArticleStruct),\n relatedAssets: array(RelatedAssetStruct),\n});\n\nconst MarketOverviewStruct = structType({\n version: optional(string()),\n generatedAt: string(),\n trends: array(MarketOverviewTrendStruct),\n metadata: optional(array(AIResponseMetadataStruct)),\n});\n\nconst MarketOverviewReportEnvelopeStruct = structType({\n report: MarketOverviewStruct,\n});\n\n// A single front-page row. `item` shares the exact same schema as an\n// individual market overview trend; `ctaTitle`/`ctaDescription` are the\n// AI-authored call-to-action copy layered on top.\nconst MarketOverviewFrontPageStruct = structType({\n id: string(),\n item: MarketOverviewTrendStruct,\n ctaTitle: string(),\n ctaDescription: string(),\n createdAt: string(),\n});\n\nconst normalizeItemRelatedAssets = (\n item: MarketOverviewTrend,\n): MarketOverviewTrend => ({\n ...item,\n relatedAssets: item.relatedAssets.map((asset) => ({\n ...asset,\n caip19: asset.caip19 ?? [],\n })),\n});\n\nconst normalizeRelatedAssets = (raw: MarketOverview): MarketOverview => ({\n ...raw,\n trends: raw.trends.map(normalizeItemRelatedAssets),\n});\n\nconst getNormalizedMarketOverview = (value: unknown): MarketOverview | null => {\n if (is(value, MarketOverviewStruct)) {\n return normalizeRelatedAssets(value);\n }\n\n if (is(value, MarketOverviewReportEnvelopeStruct)) {\n return normalizeRelatedAssets(value.report);\n }\n\n return null;\n};\n\nconst getNormalizedFrontPage = (\n value: unknown,\n): MarketOverviewFrontPage | null => {\n if (!is(value, MarketOverviewFrontPageStruct)) {\n return null;\n }\n\n return { ...value, item: normalizeItemRelatedAssets(value.item) };\n};\n\nconst getNormalizedMarketInsightsReport = (\n value: unknown,\n): MarketInsightsReport | null => {\n if (is(value, MarketInsightsDigestEnvelopeStruct)) {\n return { ...value.digest, digestId: value.id };\n }\n\n return null;\n};\n\nexport class AiDigestService implements DigestService {\n readonly #baseUrl: string;\n\n constructor(config: AiDigestServiceConfig) {\n this.#baseUrl = config.baseUrl;\n }\n\n /**\n * Fetch the market overview report.\n *\n * Calls `GET ${this.#baseUrl}/market-overview`.\n *\n * @returns The market overview report, or `null` if none exists (404).\n */\n async fetchMarketOverview(): Promise<MarketOverview | null> {\n const response = await fetch(`${this.#baseUrl}/market-overview`);\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new Error(\n `${AiDigestControllerErrorMessage.API_REQUEST_FAILED}: ${response.status}`,\n );\n }\n\n const overview = getNormalizedMarketOverview(await response.json());\n\n if (!overview) {\n throw new Error(AiDigestControllerErrorMessage.API_INVALID_RESPONSE);\n }\n\n return overview;\n }\n\n /**\n * Fetch a single market overview front page by id.\n *\n * Calls `GET ${this.#baseUrl}/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 async fetchFrontPageItem(\n id: string,\n ): Promise<MarketOverviewFrontPage | null> {\n const response = await fetch(\n `${this.#baseUrl}/market-overview/front-page/${encodeURIComponent(id)}`,\n );\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new Error(\n `${AiDigestControllerErrorMessage.API_REQUEST_FAILED}: ${response.status}`,\n );\n }\n\n const frontPage = getNormalizedFrontPage(await response.json());\n\n if (!frontPage) {\n throw new Error(AiDigestControllerErrorMessage.API_INVALID_RESPONSE);\n }\n\n return frontPage;\n }\n\n /**\n * Search for market insights by asset identifier.\n *\n * Accepts any identifier the API understands (CAIP-19 asset type, ticker\n * symbol, asset name, HyperLiquid perps market id, etc.) and forwards it\n * unchanged via the universal `asset` query parameter.\n *\n * Calls `GET ${baseUrl}/asset-summary?asset=<assetIdentifier>`.\n *\n * @param assetIdentifier - The asset identifier (e.g. `eip155:1/slip44:60`,\n * `ETH`, `Bitcoin`, `xyz:TSLA`).\n * @returns The market insights report, or `null` if none exists (404).\n */\n async searchDigest(\n assetIdentifier: string,\n ): Promise<MarketInsightsReport | null> {\n const response = await fetch(\n `${this.#baseUrl}/asset-summary?asset=${encodeURIComponent(assetIdentifier)}`,\n );\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new Error(\n `${AiDigestControllerErrorMessage.API_REQUEST_FAILED}: ${response.status}`,\n );\n }\n\n const report = getNormalizedMarketInsightsReport(await response.json());\n\n if (!report) {\n throw new Error(AiDigestControllerErrorMessage.API_INVALID_RESPONSE);\n }\n\n return report;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare const controllerName = "AiDigestController";
2
+ export declare const AiDigestControllerErrorMessage: {
3
+ readonly API_REQUEST_FAILED: 'API request failed';
4
+ readonly API_INVALID_RESPONSE: 'API returned invalid response';
5
+ readonly INVALID_ASSET_IDENTIFIER: 'Invalid asset identifier';
6
+ readonly INVALID_FRONT_PAGE_ID: 'Invalid front page id';
7
+ };
8
+ //# sourceMappingURL=ai-digest-constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-digest-constants.d.ts","sourceRoot":"","sources":["../src/ai-digest-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,eAAO,MAAM,8BAA8B;aACzC,kBAAkB,EAAE,oBAAoB;aACxC,oBAAoB,EAAE,+BAA+B;aACrD,wBAAwB,EAAE,0BAA0B;aACpD,qBAAqB,EAAE,uBAAuB;CACtC,CAAC"}
@@ -5,4 +5,4 @@ export const AiDigestControllerErrorMessage = {
5
5
  INVALID_ASSET_IDENTIFIER: 'Invalid asset identifier',
6
6
  INVALID_FRONT_PAGE_ID: 'Invalid front page id',
7
7
  };
8
- //# sourceMappingURL=ai-digest-constants.mjs.map
8
+ //# sourceMappingURL=ai-digest-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-digest-constants.js","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"]}
@@ -192,4 +192,4 @@ export type DigestService = {
192
192
  */
193
193
  fetchFrontPageItem(id: string): Promise<MarketOverviewFrontPage | null>;
194
194
  };
195
- //# sourceMappingURL=ai-digest-types.d.cts.map
195
+ //# sourceMappingURL=ai-digest-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-digest-types.d.ts","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,CA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a,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"}
@@ -2,4 +2,4 @@
2
2
  // Shared sub-types
3
3
  // ---------------------------------------------------------------------------
4
4
  export {};
5
- //# sourceMappingURL=ai-digest-types.mjs.map
5
+ //# sourceMappingURL=ai-digest-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-digest-types.js","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,8 +1,8 @@
1
- export type { AiDigestControllerActions, AiDigestControllerEvents, AiDigestControllerGetStateAction, AiDigestControllerMessenger, AiDigestControllerOptions, AiDigestControllerStateChangeEvent, } from "./AiDigestController.cjs";
2
- export { AiDigestController, getDefaultAiDigestControllerState, } from "./AiDigestController.cjs";
3
- export type { AiDigestControllerFetchMarketInsightsAction, AiDigestControllerFetchMarketOverviewAction, AiDigestControllerFetchFrontPageItemAction, } from "./AiDigestController-method-action-types.cjs";
4
- export type { AiDigestServiceConfig } from "./AiDigestService.cjs";
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";
8
- //# sourceMappingURL=index.d.cts.map
1
+ export type { AiDigestControllerActions, AiDigestControllerEvents, AiDigestControllerGetStateAction, AiDigestControllerMessenger, AiDigestControllerOptions, AiDigestControllerStateChangeEvent, } from './AiDigestController.js';
2
+ export { AiDigestController, getDefaultAiDigestControllerState, } from './AiDigestController.js';
3
+ export type { AiDigestControllerFetchMarketInsightsAction, AiDigestControllerFetchMarketOverviewAction, AiDigestControllerFetchFrontPageItemAction, } from './AiDigestController-method-action-types.js';
4
+ export type { AiDigestServiceConfig } from './AiDigestService.js';
5
+ export { AiDigestService } from './AiDigestService.js';
6
+ export type { AiDigestControllerState, AIResponseMetadata, Article, DigestService, MarketInsightsArticle, MarketInsightsReport, MarketInsightsSource, MarketInsightsTrend, MarketInsightsTweet, MarketOverview, MarketOverviewFrontPage, MarketOverviewItem, MarketOverviewTrend, RelatedAsset, Source, Tweet, } from './ai-digest-types.js';
7
+ export { controllerName as aiDigestControllerName, AiDigestControllerErrorMessage, } from './ai-digest-constants.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,gCAAgC,EAChC,2BAA2B,EAC3B,yBAAyB,EACzB,kCAAkC,GACnC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,2CAA2C,EAC3C,2CAA2C,EAC3C,0CAA0C,GAC3C,MAAM,6CAA6C,CAAC;AAErD,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;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,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,cAAc,IAAI,sBAAsB,EACxC,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { AiDigestController, getDefaultAiDigestControllerState, } from './AiDigestController.js';
2
+ export { AiDigestService } from './AiDigestService.js';
3
+ export { controllerName as aiDigestControllerName, AiDigestControllerErrorMessage, } from './ai-digest-constants.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAqBvD,OAAO,EACL,cAAc,IAAI,sBAAsB,EACxC,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/ai-controllers",
3
- "version": "1.0.0-preview-8bfa290fb",
3
+ "version": "2.0.0-preview-0a30e47",
4
4
  "description": "A collection of AI-related controllers",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -18,19 +18,12 @@
18
18
  "files": [
19
19
  "dist/"
20
20
  ],
21
+ "type": "module",
21
22
  "sideEffects": false,
22
- "main": "./dist/index.cjs",
23
- "types": "./dist/index.d.cts",
24
23
  "exports": {
25
24
  ".": {
26
- "import": {
27
- "types": "./dist/index.d.mts",
28
- "default": "./dist/index.mjs"
29
- },
30
- "require": {
31
- "types": "./dist/index.d.cts",
32
- "default": "./dist/index.cjs"
33
- }
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
34
27
  },
35
28
  "./package.json": "./package.json"
36
29
  },
@@ -39,9 +32,11 @@
39
32
  "registry": "https://registry.npmjs.org/"
40
33
  },
41
34
  "scripts": {
42
- "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
43
- "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
35
+ "build": "tsc --project tsconfig.build.json",
36
+ "build:all": "tsc --build tsconfig.build.json --verbose",
37
+ "build:clean": "yarn build:only-clean && yarn build",
44
38
  "build:docs": "typedoc",
39
+ "build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
45
40
  "changelog:update": "../../scripts/update-changelog.sh @metamask/ai-controllers",
46
41
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/ai-controllers",
47
42
  "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
@@ -55,24 +50,25 @@
55
50
  "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
56
51
  },
57
52
  "dependencies": {
58
- "@metamask/base-controller": "^9.1.0",
59
- "@metamask/messenger": "^2.0.0",
53
+ "@metamask/base-controller": "^10.0.0",
54
+ "@metamask/messenger": "^3.0.0",
60
55
  "@metamask/superstruct": "^3.4.1",
61
56
  "@metamask/utils": "^11.12.0"
62
57
  },
63
58
  "devDependencies": {
64
59
  "@metamask/auto-changelog": "^6.1.0",
65
- "@ts-bridge/cli": "^0.6.4",
66
60
  "@types/jest": "^30.0.0",
61
+ "@typescript/native": "npm:typescript@^7.0.2",
67
62
  "deepmerge": "^4.2.2",
68
63
  "jest": "^30.4.2",
64
+ "rimraf": "^5.0.5",
69
65
  "ts-jest": "^29.4.11",
70
66
  "tsx": "^4.20.5",
71
67
  "typedoc": "^0.25.13",
72
68
  "typedoc-plugin-missing-exports": "^2.0.0",
73
- "typescript": "~5.3.3"
69
+ "typescript": "npm:@typescript/typescript6@^6.0.2"
74
70
  },
75
71
  "engines": {
76
- "node": "^18.18 || >=20"
72
+ "node": "^22.14.0 || ^24"
77
73
  }
78
74
  }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * This file is auto generated.
4
- * Do not edit manually.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# sourceMappingURL=AiDigestController-method-action-types.cjs.map
@@ -1 +0,0 @@
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,49 +0,0 @@
1
- /**
2
- * This file is auto generated.
3
- * Do not edit manually.
4
- */
5
- import type { AiDigestController } from "./AiDigestController.cjs";
6
- /**
7
- * Fetches market insights for a given asset identifier.
8
- *
9
- * Accepts either a CAIP-19 asset type (e.g. `eip155:1/slip44:60`) or a perps
10
- * market symbol (e.g. `ETH`). The service handles choosing the correct API
11
- * query parameter automatically. Clients own freshness/caching.
12
- *
13
- * @param assetIdentifier - The asset identifier (CAIP-19 ID or perps market symbol).
14
- * @returns The market insights report, or `null` if none exists.
15
- */
16
- export type AiDigestControllerFetchMarketInsightsAction = {
17
- type: `AiDigestController:fetchMarketInsights`;
18
- handler: AiDigestController['fetchMarketInsights'];
19
- };
20
- /**
21
- * Fetches the market overview report.
22
- *
23
- * Clients own freshness/caching.
24
- *
25
- * @returns The market overview report, or `null` if none exists.
26
- */
27
- export type AiDigestControllerFetchMarketOverviewAction = {
28
- type: `AiDigestController:fetchMarketOverview`;
29
- handler: AiDigestController['fetchMarketOverview'];
30
- };
31
- /**
32
- * Fetches a single market overview front page by id.
33
- *
34
- * Unlike the market overview report (which only returns the latest items),
35
- * this resolves an older item that has since dropped out of the report, so
36
- * clients can render it directly (e.g. from a deep link).
37
- *
38
- * @param id - The front-page identifier (UUID).
39
- * @returns The market overview front page, or `null` if none exists.
40
- */
41
- export type AiDigestControllerFetchFrontPageItemAction = {
42
- type: `AiDigestController:fetchFrontPageItem`;
43
- handler: AiDigestController['fetchFrontPageItem'];
44
- };
45
- /**
46
- * Union of all AiDigestController action types.
47
- */
48
- export type AiDigestControllerMethodActions = AiDigestControllerFetchMarketInsightsAction | AiDigestControllerFetchMarketOverviewAction | AiDigestControllerFetchFrontPageItemAction;
49
- //# sourceMappingURL=AiDigestController-method-action-types.d.cts.map
@@ -1 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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"]}