@metamask-previews/ai-controllers 0.1.0-preview-25c8c1fad → 0.1.0-preview-e117c8109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/AiDigestService.cjs +41 -15
- package/dist/AiDigestService.cjs.map +1 -1
- package/dist/AiDigestService.d.cts.map +1 -1
- package/dist/AiDigestService.d.mts.map +1 -1
- package/dist/AiDigestService.mjs +41 -15
- package/dist/AiDigestService.mjs.map +1 -1
- package/dist/ai-digest-types.cjs.map +1 -1
- package/dist/ai-digest-types.d.cts +2 -0
- package/dist/ai-digest-types.d.cts.map +1 -1
- package/dist/ai-digest-types.d.mts +2 -0
- package/dist/ai-digest-types.d.mts.map +1 -1
- package/dist/ai-digest-types.mjs.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Strengthen `AiDigestService` response validation using nested `superstruct` schemas for market insights payloads, including deep validation of `trends`/`sources` items and support for optional top-level `social` entries while allowing additional unknown API fields for forward compatibility ([#8006](https://github.com/MetaMask/core/pull/8006)).
|
|
13
|
+
|
|
10
14
|
## [0.1.0]
|
|
11
15
|
|
|
12
16
|
### Added
|
package/dist/AiDigestService.cjs
CHANGED
|
@@ -13,25 +13,51 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _AiDigestService_baseUrl;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AiDigestService = void 0;
|
|
16
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
16
17
|
const ai_digest_constants_1 = require("./ai-digest-constants.cjs");
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
const MarketInsightsArticleStruct = (0, superstruct_1.type)({
|
|
19
|
+
title: (0, superstruct_1.string)(),
|
|
20
|
+
url: (0, superstruct_1.string)(),
|
|
21
|
+
source: (0, superstruct_1.string)(),
|
|
22
|
+
date: (0, superstruct_1.string)(),
|
|
23
|
+
});
|
|
24
|
+
const MarketInsightsTweetStruct = (0, superstruct_1.type)({
|
|
25
|
+
contentSummary: (0, superstruct_1.string)(),
|
|
26
|
+
url: (0, superstruct_1.string)(),
|
|
27
|
+
author: (0, superstruct_1.string)(),
|
|
28
|
+
date: (0, superstruct_1.string)(),
|
|
29
|
+
});
|
|
30
|
+
const MarketInsightsTrendStruct = (0, superstruct_1.type)({
|
|
31
|
+
title: (0, superstruct_1.string)(),
|
|
32
|
+
description: (0, superstruct_1.string)(),
|
|
33
|
+
category: (0, superstruct_1.string)(),
|
|
34
|
+
impact: (0, superstruct_1.string)(),
|
|
35
|
+
articles: (0, superstruct_1.array)(MarketInsightsArticleStruct),
|
|
36
|
+
tweets: (0, superstruct_1.array)(MarketInsightsTweetStruct),
|
|
37
|
+
});
|
|
38
|
+
const MarketInsightsSourceStruct = (0, superstruct_1.type)({
|
|
39
|
+
name: (0, superstruct_1.string)(),
|
|
40
|
+
url: (0, superstruct_1.string)(),
|
|
41
|
+
type: (0, superstruct_1.string)(),
|
|
42
|
+
});
|
|
43
|
+
const MarketInsightsReportStruct = (0, superstruct_1.type)({
|
|
44
|
+
version: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
45
|
+
asset: (0, superstruct_1.string)(),
|
|
46
|
+
generatedAt: (0, superstruct_1.string)(),
|
|
47
|
+
headline: (0, superstruct_1.string)(),
|
|
48
|
+
summary: (0, superstruct_1.string)(),
|
|
49
|
+
trends: (0, superstruct_1.array)(MarketInsightsTrendStruct),
|
|
50
|
+
social: (0, superstruct_1.optional)((0, superstruct_1.array)(MarketInsightsTweetStruct)),
|
|
51
|
+
sources: (0, superstruct_1.array)(MarketInsightsSourceStruct),
|
|
52
|
+
});
|
|
53
|
+
const MarketInsightsDigestEnvelopeStruct = (0, superstruct_1.type)({
|
|
54
|
+
digest: MarketInsightsReportStruct,
|
|
55
|
+
});
|
|
30
56
|
const getNormalizedMarketInsightsReport = (value) => {
|
|
31
|
-
if (
|
|
57
|
+
if ((0, superstruct_1.is)(value, MarketInsightsReportStruct)) {
|
|
32
58
|
return value;
|
|
33
59
|
}
|
|
34
|
-
if (
|
|
60
|
+
if ((0, superstruct_1.is)(value, MarketInsightsDigestEnvelopeStruct)) {
|
|
35
61
|
return value.digest;
|
|
36
62
|
}
|
|
37
63
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiDigestService.cjs","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"AiDigestService.cjs","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAM+B;AAG/B,mEAAuE;AAOvE,MAAM,2BAA2B,GAAG,IAAA,kBAAU,EAAC;IAC7C,KAAK,EAAE,IAAA,oBAAM,GAAE;IACf,GAAG,EAAE,IAAA,oBAAM,GAAE;IACb,MAAM,EAAE,IAAA,oBAAM,GAAE;IAChB,IAAI,EAAE,IAAA,oBAAM,GAAE;CACf,CAAC,CAAC;AAEH,MAAM,yBAAyB,GAAG,IAAA,kBAAU,EAAC;IAC3C,cAAc,EAAE,IAAA,oBAAM,GAAE;IACxB,GAAG,EAAE,IAAA,oBAAM,GAAE;IACb,MAAM,EAAE,IAAA,oBAAM,GAAE;IAChB,IAAI,EAAE,IAAA,oBAAM,GAAE;CACf,CAAC,CAAC;AAEH,MAAM,yBAAyB,GAAG,IAAA,kBAAU,EAAC;IAC3C,KAAK,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AC,MAAM,CAAC;IACtB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAa,eAAe;IAG1B,YAAY,MAA6B;QAFhC,2CAAiB;QAGxB,uBAAA,IAAI,4BAAY,MAAM,CAAC,OAAO,MAAA,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,YAAY,CAChB,QAAuB;QAEvB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,uBAAA,IAAI,gCAAS,0BAA0B,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CACzE,CAAC;QAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,GAAG,oDAA8B,CAAC,kBAAkB,KAAK,QAAQ,CAAC,MAAM,EAAE,CAC3E,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,iCAAiC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAExE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,oDAA8B,CAAC,oBAAoB,CAAC,CAAC;QACvE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAxCD,0CAwCC","sourcesContent":["import {\n array,\n is,\n optional,\n string,\n type as structType,\n} from '@metamask/superstruct';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport { AiDigestControllerErrorMessage } from './ai-digest-constants';\nimport type { DigestService, MarketInsightsReport } from './ai-digest-types';\n\nexport type AiDigestServiceConfig = {\n baseUrl: string;\n};\n\nconst MarketInsightsArticleStruct = structType({\n title: string(),\n url: string(),\n source: string(),\n date: string(),\n});\n\nconst MarketInsightsTweetStruct = structType({\n contentSummary: string(),\n url: string(),\n author: string(),\n date: string(),\n});\n\nconst MarketInsightsTrendStruct = structType({\n title: string(),\n description: string(),\n category: string(),\n impact: string(),\n articles: array(MarketInsightsArticleStruct),\n tweets: array(MarketInsightsTweetStruct),\n});\n\nconst MarketInsightsSourceStruct = structType({\n name: string(),\n url: string(),\n type: string(),\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(MarketInsightsTweetStruct)),\n sources: array(MarketInsightsSourceStruct),\n});\n\nconst MarketInsightsDigestEnvelopeStruct = structType({\n digest: MarketInsightsReportStruct,\n});\n\nconst getNormalizedMarketInsightsReport = (\n value: unknown,\n): MarketInsightsReport | null => {\n if (is(value, MarketInsightsReportStruct)) {\n return value;\n }\n\n if (is(value, MarketInsightsDigestEnvelopeStruct)) {\n return value.digest;\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 * Search for market insights by CAIP-19 asset identifier.\n *\n * Calls `GET ${this.#baseUrl}/digests?caipAssetType=${encodeURIComponent(caip19Id)}`.\n *\n * @param caip19Id - The CAIP-19 identifier of the asset.\n * @returns The market insights report, or `null` if none exists (404).\n */\n async searchDigest(\n caip19Id: CaipAssetType,\n ): Promise<MarketInsightsReport | null> {\n const response = await fetch(\n `${this.#baseUrl}/digests?caipAssetType=${encodeURIComponent(caip19Id)}`,\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiDigestService.d.cts","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AiDigestService.d.cts","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,8BAA0B;AAE7E,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA4DF,qBAAa,eAAgB,YAAW,aAAa;;gBAGvC,MAAM,EAAE,qBAAqB;IAIzC;;;;;;;OAOG;IACG,YAAY,CAChB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;CAuBxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiDigestService.d.mts","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AiDigestService.d.mts","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,8BAA0B;AAE7E,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA4DF,qBAAa,eAAgB,YAAW,aAAa;;gBAGvC,MAAM,EAAE,qBAAqB;IAIzC;;;;;;;OAOG;IACG,YAAY,CAChB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;CAuBxC"}
|
package/dist/AiDigestService.mjs
CHANGED
|
@@ -10,25 +10,51 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _AiDigestService_baseUrl;
|
|
13
|
+
import { array, is, optional, string, type as structType } from "@metamask/superstruct";
|
|
13
14
|
import { AiDigestControllerErrorMessage } from "./ai-digest-constants.mjs";
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const MarketInsightsArticleStruct = structType({
|
|
16
|
+
title: string(),
|
|
17
|
+
url: string(),
|
|
18
|
+
source: string(),
|
|
19
|
+
date: string(),
|
|
20
|
+
});
|
|
21
|
+
const MarketInsightsTweetStruct = structType({
|
|
22
|
+
contentSummary: string(),
|
|
23
|
+
url: string(),
|
|
24
|
+
author: string(),
|
|
25
|
+
date: string(),
|
|
26
|
+
});
|
|
27
|
+
const MarketInsightsTrendStruct = structType({
|
|
28
|
+
title: string(),
|
|
29
|
+
description: string(),
|
|
30
|
+
category: string(),
|
|
31
|
+
impact: string(),
|
|
32
|
+
articles: array(MarketInsightsArticleStruct),
|
|
33
|
+
tweets: array(MarketInsightsTweetStruct),
|
|
34
|
+
});
|
|
35
|
+
const MarketInsightsSourceStruct = structType({
|
|
36
|
+
name: string(),
|
|
37
|
+
url: string(),
|
|
38
|
+
type: string(),
|
|
39
|
+
});
|
|
40
|
+
const MarketInsightsReportStruct = structType({
|
|
41
|
+
version: optional(string()),
|
|
42
|
+
asset: string(),
|
|
43
|
+
generatedAt: string(),
|
|
44
|
+
headline: string(),
|
|
45
|
+
summary: string(),
|
|
46
|
+
trends: array(MarketInsightsTrendStruct),
|
|
47
|
+
social: optional(array(MarketInsightsTweetStruct)),
|
|
48
|
+
sources: array(MarketInsightsSourceStruct),
|
|
49
|
+
});
|
|
50
|
+
const MarketInsightsDigestEnvelopeStruct = structType({
|
|
51
|
+
digest: MarketInsightsReportStruct,
|
|
52
|
+
});
|
|
27
53
|
const getNormalizedMarketInsightsReport = (value) => {
|
|
28
|
-
if (
|
|
54
|
+
if (is(value, MarketInsightsReportStruct)) {
|
|
29
55
|
return value;
|
|
30
56
|
}
|
|
31
|
-
if (
|
|
57
|
+
if (is(value, MarketInsightsDigestEnvelopeStruct)) {
|
|
32
58
|
return value.digest;
|
|
33
59
|
}
|
|
34
60
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiDigestService.mjs","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"AiDigestService.mjs","sourceRoot":"","sources":["../src/AiDigestService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,KAAK,EACL,EAAE,EACF,QAAQ,EACR,MAAM,EACN,IAAI,IAAI,UAAU,EACnB,8BAA8B;AAG/B,OAAO,EAAE,8BAA8B,EAAE,kCAA8B;AAOvE,MAAM,2BAA2B,GAAG,UAAU,CAAC;IAC7C,KAAK,EAAE,MAAM,EAAE;IACf,GAAG,EAAE,MAAM,EAAE;IACb,MAAM,EAAE,MAAM,EAAE;IAChB,IAAI,EAAE,MAAM,EAAE;CACf,CAAC,CAAC;AAEH,MAAM,yBAAyB,GAAG,UAAU,CAAC;IAC3C,cAAc,EAAE,MAAM,EAAE;IACxB,GAAG,EAAE,MAAM,EAAE;IACb,MAAM,EAAE,MAAM,EAAE;IAChB,IAAI,EAAE,MAAM,EAAE;CACf,CAAC,CAAC;AAEH,MAAM,yBAAyB,GAAG,UAAU,CAAC;IAC3C,KAAK,EAAE,MAAM,EAAE;IACf,WAAW,EAAE,MAAM,EAAE;IACrB,QAAQ,EAAE,MAAM,EAAE;IAClB,MAAM,EAAE,MAAM,EAAE;IAChB,QAAQ,EAAE,KAAK,CAAC,2BAA2B,CAAC;IAC5C,MAAM,EAAE,KAAK,CAAC,yBAAyB,CAAC;CACzC,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,UAAU,CAAC;IAC5C,IAAI,EAAE,MAAM,EAAE;IACd,GAAG,EAAE,MA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CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,GAAG,8BAA8B,CAAC,kBAAkB,KAAK,QAAQ,CAAC,MAAM,EAAE,CAC3E,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,iCAAiC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAExE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,oBAAoB,CAAC,CAAC;QACvE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import {\n array,\n is,\n optional,\n string,\n type as structType,\n} from '@metamask/superstruct';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport { AiDigestControllerErrorMessage } from './ai-digest-constants';\nimport type { DigestService, MarketInsightsReport } from './ai-digest-types';\n\nexport type AiDigestServiceConfig = {\n baseUrl: string;\n};\n\nconst MarketInsightsArticleStruct = structType({\n title: string(),\n url: string(),\n source: string(),\n date: string(),\n});\n\nconst MarketInsightsTweetStruct = structType({\n contentSummary: string(),\n url: string(),\n author: string(),\n date: string(),\n});\n\nconst MarketInsightsTrendStruct = structType({\n title: string(),\n description: string(),\n category: string(),\n impact: string(),\n articles: array(MarketInsightsArticleStruct),\n tweets: array(MarketInsightsTweetStruct),\n});\n\nconst MarketInsightsSourceStruct = structType({\n name: string(),\n url: string(),\n type: string(),\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(MarketInsightsTweetStruct)),\n sources: array(MarketInsightsSourceStruct),\n});\n\nconst MarketInsightsDigestEnvelopeStruct = structType({\n digest: MarketInsightsReportStruct,\n});\n\nconst getNormalizedMarketInsightsReport = (\n value: unknown,\n): MarketInsightsReport | null => {\n if (is(value, MarketInsightsReportStruct)) {\n return value;\n }\n\n if (is(value, MarketInsightsDigestEnvelopeStruct)) {\n return value.digest;\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 * Search for market insights by CAIP-19 asset identifier.\n *\n * Calls `GET ${this.#baseUrl}/digests?caipAssetType=${encodeURIComponent(caip19Id)}`.\n *\n * @param caip19Id - The CAIP-19 identifier of the asset.\n * @returns The market insights report, or `null` if none exists (404).\n */\n async searchDigest(\n caip19Id: CaipAssetType,\n ): Promise<MarketInsightsReport | null> {\n const response = await fetch(\n `${this.#baseUrl}/digests?caipAssetType=${encodeURIComponent(caip19Id)}`,\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-digest-types.cjs","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType } from '@metamask/utils';\n\n// ---------------------------------------------------------------------------\n// Market Insights types\n// ---------------------------------------------------------------------------\n\n/**\n * A news article referenced by a market insight trend.\n */\nexport type MarketInsightsArticle = {\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 market insight trend.\n */\nexport type MarketInsightsTweet = {\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 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: 'macro' | 'technical' | 'social' | string;\n /** Impact direction */\n impact: 'positive' | 'negative' | 'neutral' | string;\n /** Related news articles */\n articles: MarketInsightsArticle[];\n /** Related social media posts */\n tweets: MarketInsightsTweet[];\n};\n\n/**\n * A data source used to generate the market insights report.\n */\nexport type MarketInsightsSource = {\n /** Source name (e.g. \"CoinDesk\") */\n name: string;\n /** Source URL */\n url: string;\n /** Source type */\n type: 'news' | 'data' | 'social' | string;\n};\n\n/**\n * AI-generated market insights report for a crypto asset.\n * Returned by `GET /digests?caipAssetType=<caip19Id>`.\n */\nexport type MarketInsightsReport = {\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 /** Data sources used to generate the report */\n sources: MarketInsightsSource[];\n};\n\n/**\n * A cached market insights entry.\n */\nexport type MarketInsightsEntry = {\n /** CAIP-19 asset identifier */\n caip19Id: CaipAssetType;\n /** Timestamp when the entry was fetched */\n fetchedAt: number;\n /** The market insights report data */\n data: MarketInsightsReport;\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\nexport type AiDigestControllerState = {\n marketInsights: Record<string, MarketInsightsEntry>;\n};\n\n// ---------------------------------------------------------------------------\n// Service interface\n// ---------------------------------------------------------------------------\n\nexport type DigestService = {\n /**\n * Search for market insights by CAIP-19 asset identifier.\n * Calls `GET /digests?caipAssetType=<caip19Id>`.\n *\n * @param caip19Id - The CAIP-19 identifier of the asset.\n * @returns The market insights report, or `null` if no insights exist (404).\n */\n searchDigest(caip19Id: CaipAssetType): Promise<MarketInsightsReport | null>;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ai-digest-types.cjs","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType } from '@metamask/utils';\n\n// ---------------------------------------------------------------------------\n// Market Insights types\n// ---------------------------------------------------------------------------\n\n/**\n * A news article referenced by a market insight trend.\n */\nexport type MarketInsightsArticle = {\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 market insight trend.\n */\nexport type MarketInsightsTweet = {\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 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: 'macro' | 'technical' | 'social' | string;\n /** Impact direction */\n impact: 'positive' | 'negative' | 'neutral' | string;\n /** Related news articles */\n articles: MarketInsightsArticle[];\n /** Related social media posts */\n tweets: MarketInsightsTweet[];\n};\n\n/**\n * A data source used to generate the market insights report.\n */\nexport type MarketInsightsSource = {\n /** Source name (e.g. \"CoinDesk\") */\n name: string;\n /** Source URL */\n url: string;\n /** Source type */\n type: 'news' | 'data' | 'social' | string;\n};\n\n/**\n * AI-generated market insights report for a crypto asset.\n * Returned by `GET /digests?caipAssetType=<caip19Id>`.\n */\nexport type MarketInsightsReport = {\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?: MarketInsightsTweet[];\n /** Data sources used to generate the report */\n sources: MarketInsightsSource[];\n};\n\n/**\n * A cached market insights entry.\n */\nexport type MarketInsightsEntry = {\n /** CAIP-19 asset identifier */\n caip19Id: CaipAssetType;\n /** Timestamp when the entry was fetched */\n fetchedAt: number;\n /** The market insights report data */\n data: MarketInsightsReport;\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\nexport type AiDigestControllerState = {\n marketInsights: Record<string, MarketInsightsEntry>;\n};\n\n// ---------------------------------------------------------------------------\n// Service interface\n// ---------------------------------------------------------------------------\n\nexport type DigestService = {\n /**\n * Search for market insights by CAIP-19 asset identifier.\n * Calls `GET /digests?caipAssetType=<caip19Id>`.\n *\n * @param caip19Id - The CAIP-19 identifier of the asset.\n * @returns The market insights report, or `null` if no insights exist (404).\n */\n searchDigest(caip19Id: CaipAssetType): Promise<MarketInsightsReport | null>;\n};\n"]}
|
|
@@ -70,6 +70,8 @@ export type MarketInsightsReport = {
|
|
|
70
70
|
summary: string;
|
|
71
71
|
/** Key market trends */
|
|
72
72
|
trends: MarketInsightsTrend[];
|
|
73
|
+
/** Optional top-level social posts included by the API */
|
|
74
|
+
social?: MarketInsightsTweet[];
|
|
73
75
|
/** Data sources used to generate the report */
|
|
74
76
|
sources: MarketInsightsSource[];
|
|
75
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-digest-types.d.cts","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAMrD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,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,mBAAmB,GAAG;IAChC,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,GAAG,EAAE,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AAa,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;CAC7E,CAAC"}
|
|
@@ -70,6 +70,8 @@ export type MarketInsightsReport = {
|
|
|
70
70
|
summary: string;
|
|
71
71
|
/** Key market trends */
|
|
72
72
|
trends: MarketInsightsTrend[];
|
|
73
|
+
/** Optional top-level social posts included by the API */
|
|
74
|
+
social?: MarketInsightsTweet[];
|
|
73
75
|
/** Data sources used to generate the report */
|
|
74
76
|
sources: MarketInsightsSource[];
|
|
75
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-digest-types.d.mts","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAMrD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,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,mBAAmB,GAAG;IAChC,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,mBAAmB,GAAG;IAChC,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,QAAQ,EAAE,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpD,uBAAuB;IACvB,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,M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;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,kBAAkB;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC/B,+CAA+C;IAC/C,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,QAAQ,EAAE,aAAa,CAAC;IACxB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,IAAI,EAAE,oBAAoB,CAAC;CAC5B,CAAC;AAMF,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CACrD,CAAC;AAMF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;OAMG;IACH,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;CAC7E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-digest-types.mjs","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType } from '@metamask/utils';\n\n// ---------------------------------------------------------------------------\n// Market Insights types\n// ---------------------------------------------------------------------------\n\n/**\n * A news article referenced by a market insight trend.\n */\nexport type MarketInsightsArticle = {\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 market insight trend.\n */\nexport type MarketInsightsTweet = {\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 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: 'macro' | 'technical' | 'social' | string;\n /** Impact direction */\n impact: 'positive' | 'negative' | 'neutral' | string;\n /** Related news articles */\n articles: MarketInsightsArticle[];\n /** Related social media posts */\n tweets: MarketInsightsTweet[];\n};\n\n/**\n * A data source used to generate the market insights report.\n */\nexport type MarketInsightsSource = {\n /** Source name (e.g. \"CoinDesk\") */\n name: string;\n /** Source URL */\n url: string;\n /** Source type */\n type: 'news' | 'data' | 'social' | string;\n};\n\n/**\n * AI-generated market insights report for a crypto asset.\n * Returned by `GET /digests?caipAssetType=<caip19Id>`.\n */\nexport type MarketInsightsReport = {\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 /** Data sources used to generate the report */\n sources: MarketInsightsSource[];\n};\n\n/**\n * A cached market insights entry.\n */\nexport type MarketInsightsEntry = {\n /** CAIP-19 asset identifier */\n caip19Id: CaipAssetType;\n /** Timestamp when the entry was fetched */\n fetchedAt: number;\n /** The market insights report data */\n data: MarketInsightsReport;\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\nexport type AiDigestControllerState = {\n marketInsights: Record<string, MarketInsightsEntry>;\n};\n\n// ---------------------------------------------------------------------------\n// Service interface\n// ---------------------------------------------------------------------------\n\nexport type DigestService = {\n /**\n * Search for market insights by CAIP-19 asset identifier.\n * Calls `GET /digests?caipAssetType=<caip19Id>`.\n *\n * @param caip19Id - The CAIP-19 identifier of the asset.\n * @returns The market insights report, or `null` if no insights exist (404).\n */\n searchDigest(caip19Id: CaipAssetType): Promise<MarketInsightsReport | null>;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ai-digest-types.mjs","sourceRoot":"","sources":["../src/ai-digest-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType } from '@metamask/utils';\n\n// ---------------------------------------------------------------------------\n// Market Insights types\n// ---------------------------------------------------------------------------\n\n/**\n * A news article referenced by a market insight trend.\n */\nexport type MarketInsightsArticle = {\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 market insight trend.\n */\nexport type MarketInsightsTweet = {\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 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: 'macro' | 'technical' | 'social' | string;\n /** Impact direction */\n impact: 'positive' | 'negative' | 'neutral' | string;\n /** Related news articles */\n articles: MarketInsightsArticle[];\n /** Related social media posts */\n tweets: MarketInsightsTweet[];\n};\n\n/**\n * A data source used to generate the market insights report.\n */\nexport type MarketInsightsSource = {\n /** Source name (e.g. \"CoinDesk\") */\n name: string;\n /** Source URL */\n url: string;\n /** Source type */\n type: 'news' | 'data' | 'social' | string;\n};\n\n/**\n * AI-generated market insights report for a crypto asset.\n * Returned by `GET /digests?caipAssetType=<caip19Id>`.\n */\nexport type MarketInsightsReport = {\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?: MarketInsightsTweet[];\n /** Data sources used to generate the report */\n sources: MarketInsightsSource[];\n};\n\n/**\n * A cached market insights entry.\n */\nexport type MarketInsightsEntry = {\n /** CAIP-19 asset identifier */\n caip19Id: CaipAssetType;\n /** Timestamp when the entry was fetched */\n fetchedAt: number;\n /** The market insights report data */\n data: MarketInsightsReport;\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\nexport type AiDigestControllerState = {\n marketInsights: Record<string, MarketInsightsEntry>;\n};\n\n// ---------------------------------------------------------------------------\n// Service interface\n// ---------------------------------------------------------------------------\n\nexport type DigestService = {\n /**\n * Search for market insights by CAIP-19 asset identifier.\n * Calls `GET /digests?caipAssetType=<caip19Id>`.\n *\n * @param caip19Id - The CAIP-19 identifier of the asset.\n * @returns The market insights report, or `null` if no insights exist (404).\n */\n searchDigest(caip19Id: CaipAssetType): Promise<MarketInsightsReport | null>;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/ai-controllers",
|
|
3
|
-
"version": "0.1.0-preview-
|
|
3
|
+
"version": "0.1.0-preview-e117c8109",
|
|
4
4
|
"description": "A collection of AI-related controllers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@metamask/base-controller": "^9.0.0",
|
|
52
52
|
"@metamask/messenger": "^0.3.0",
|
|
53
|
+
"@metamask/superstruct": "^3.1.0",
|
|
53
54
|
"@metamask/utils": "^11.9.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|