@andrewkimjoseph/celina-sdk 0.2.12 → 0.3.1
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/README.md +3 -0
- package/build/abis/self-registry.d.ts +194 -0
- package/build/abis/self-registry.js +120 -0
- package/build/abis/self-registry.js.map +1 -0
- package/build/analytics/amplitude.d.ts +5 -0
- package/build/analytics/amplitude.js +56 -0
- package/build/analytics/amplitude.js.map +1 -0
- package/build/analytics/config.d.ts +7 -0
- package/build/analytics/config.js +30 -0
- package/build/analytics/config.js.map +1 -0
- package/build/analytics/mcp-tool-events.d.ts +5 -0
- package/build/analytics/mcp-tool-events.js +55 -0
- package/build/analytics/mcp-tool-events.js.map +1 -0
- package/build/analytics/wrap-service.d.ts +5 -0
- package/build/analytics/wrap-service.js +36 -0
- package/build/analytics/wrap-service.js.map +1 -0
- package/build/clients/carbon-rest.d.ts +17 -0
- package/build/clients/carbon-rest.js +59 -0
- package/build/clients/carbon-rest.js.map +1 -0
- package/build/clients/carbon-sdk.d.ts +31 -0
- package/build/clients/carbon-sdk.js +48 -0
- package/build/clients/carbon-sdk.js.map +1 -0
- package/build/clients/self-api.d.ts +82 -0
- package/build/clients/self-api.js +242 -0
- package/build/clients/self-api.js.map +1 -0
- package/build/config/carbon.d.ts +12 -0
- package/build/config/carbon.js +13 -0
- package/build/config/carbon.js.map +1 -0
- package/build/config/sdk-config.d.ts +14 -0
- package/build/config/sdk-config.js +16 -0
- package/build/config/sdk-config.js.map +1 -1
- package/build/config/self.d.ts +22 -0
- package/build/config/self.js +27 -0
- package/build/config/self.js.map +1 -0
- package/build/index.d.ts +16 -0
- package/build/index.js +27 -13
- package/build/index.js.map +1 -1
- package/build/services/carbon.service.d.ts +68 -0
- package/build/services/carbon.service.js +189 -0
- package/build/services/carbon.service.js.map +1 -0
- package/build/services/self-session-store.d.ts +19 -0
- package/build/services/self-session-store.js +28 -0
- package/build/services/self-session-store.js.map +1 -0
- package/build/services/self.service.d.ts +241 -0
- package/build/services/self.service.js +692 -0
- package/build/services/self.service.js.map +1 -0
- package/build/types/carbon.d.ts +31 -0
- package/build/types/carbon.js +2 -0
- package/build/types/carbon.js.map +1 -0
- package/build/utils/carbon-prepared-flow.d.ts +11 -0
- package/build/utils/carbon-prepared-flow.js +25 -0
- package/build/utils/carbon-prepared-flow.js.map +1 -0
- package/build/utils/carbon-rest-adapter.d.ts +8 -0
- package/build/utils/carbon-rest-adapter.js +72 -0
- package/build/utils/carbon-rest-adapter.js.map +1 -0
- package/build/utils/self-format.d.ts +28 -0
- package/build/utils/self-format.js +79 -0
- package/build/utils/self-format.js.map +1 -0
- package/build/utils/self-signing.d.ts +4 -0
- package/build/utils/self-signing.js +38 -0
- package/build/utils/self-signing.js.map +1 -0
- package/package.json +7 -2
- package/tests/catalog/domains/carbon.ts +409 -0
- package/tests/catalog/domains/self.ts +63 -4
- package/tests/catalog/operations.ts +2 -0
package/README.md
CHANGED
|
@@ -18,6 +18,9 @@ Requires Node.js ≥ 20.
|
|
|
18
18
|
|
|
19
19
|
- [Quick start](https://andrewkimjoseph.gitbook.io/celina-sdk/getting-started/quick-start)
|
|
20
20
|
- [wagmi integration](https://andrewkimjoseph.gitbook.io/celina-sdk/guides/wagmi-integration)
|
|
21
|
+
- [Carbon DeFi on Celo](docs/guides/carbon.md) — hybrid Carbon REST + `@bancor/carbon-sdk` (25 operations)
|
|
22
|
+
- [Self Agent ID](docs/guides/self-agent-id.md) — verify, register, and refresh human-backed agents on Celo
|
|
23
|
+
- [Telemetry](docs/guides/telemetry.md) — optional Amplitude read metrics (opt out with `CELINA_ANALYTICS_DISABLED=1`)
|
|
21
24
|
- [API reference](https://andrewkimjoseph.gitbook.io/celina-sdk/api-reference)
|
|
22
25
|
|
|
23
26
|
Docs source lives in [`docs/`](docs/) in this repository.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
export declare const selfRegistryAbi: readonly [{
|
|
2
|
+
readonly name: "isVerifiedAgent";
|
|
3
|
+
readonly type: "function";
|
|
4
|
+
readonly stateMutability: "view";
|
|
5
|
+
readonly inputs: readonly [{
|
|
6
|
+
readonly name: "agentPubKey";
|
|
7
|
+
readonly type: "bytes32";
|
|
8
|
+
}];
|
|
9
|
+
readonly outputs: readonly [{
|
|
10
|
+
readonly name: "";
|
|
11
|
+
readonly type: "bool";
|
|
12
|
+
}];
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "getAgentId";
|
|
15
|
+
readonly type: "function";
|
|
16
|
+
readonly stateMutability: "view";
|
|
17
|
+
readonly inputs: readonly [{
|
|
18
|
+
readonly name: "agentPubKey";
|
|
19
|
+
readonly type: "bytes32";
|
|
20
|
+
}];
|
|
21
|
+
readonly outputs: readonly [{
|
|
22
|
+
readonly name: "";
|
|
23
|
+
readonly type: "uint256";
|
|
24
|
+
}];
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "hasHumanProof";
|
|
27
|
+
readonly type: "function";
|
|
28
|
+
readonly stateMutability: "view";
|
|
29
|
+
readonly inputs: readonly [{
|
|
30
|
+
readonly name: "agentId";
|
|
31
|
+
readonly type: "uint256";
|
|
32
|
+
}];
|
|
33
|
+
readonly outputs: readonly [{
|
|
34
|
+
readonly name: "";
|
|
35
|
+
readonly type: "bool";
|
|
36
|
+
}];
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "getHumanNullifier";
|
|
39
|
+
readonly type: "function";
|
|
40
|
+
readonly stateMutability: "view";
|
|
41
|
+
readonly inputs: readonly [{
|
|
42
|
+
readonly name: "agentId";
|
|
43
|
+
readonly type: "uint256";
|
|
44
|
+
}];
|
|
45
|
+
readonly outputs: readonly [{
|
|
46
|
+
readonly name: "";
|
|
47
|
+
readonly type: "uint256";
|
|
48
|
+
}];
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "getAgentCountForHuman";
|
|
51
|
+
readonly type: "function";
|
|
52
|
+
readonly stateMutability: "view";
|
|
53
|
+
readonly inputs: readonly [{
|
|
54
|
+
readonly name: "nullifier";
|
|
55
|
+
readonly type: "uint256";
|
|
56
|
+
}];
|
|
57
|
+
readonly outputs: readonly [{
|
|
58
|
+
readonly name: "";
|
|
59
|
+
readonly type: "uint256";
|
|
60
|
+
}];
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "getProofProvider";
|
|
63
|
+
readonly type: "function";
|
|
64
|
+
readonly stateMutability: "view";
|
|
65
|
+
readonly inputs: readonly [{
|
|
66
|
+
readonly name: "agentId";
|
|
67
|
+
readonly type: "uint256";
|
|
68
|
+
}];
|
|
69
|
+
readonly outputs: readonly [{
|
|
70
|
+
readonly name: "";
|
|
71
|
+
readonly type: "address";
|
|
72
|
+
}];
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "selfProofProvider";
|
|
75
|
+
readonly type: "function";
|
|
76
|
+
readonly stateMutability: "view";
|
|
77
|
+
readonly inputs: readonly [];
|
|
78
|
+
readonly outputs: readonly [{
|
|
79
|
+
readonly name: "";
|
|
80
|
+
readonly type: "address";
|
|
81
|
+
}];
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "getAgentCredentials";
|
|
84
|
+
readonly type: "function";
|
|
85
|
+
readonly stateMutability: "view";
|
|
86
|
+
readonly inputs: readonly [{
|
|
87
|
+
readonly name: "agentId";
|
|
88
|
+
readonly type: "uint256";
|
|
89
|
+
}];
|
|
90
|
+
readonly outputs: readonly [{
|
|
91
|
+
readonly name: "";
|
|
92
|
+
readonly type: "tuple";
|
|
93
|
+
readonly components: readonly [{
|
|
94
|
+
readonly name: "issuingState";
|
|
95
|
+
readonly type: "string";
|
|
96
|
+
}, {
|
|
97
|
+
readonly name: "name";
|
|
98
|
+
readonly type: "string[]";
|
|
99
|
+
}, {
|
|
100
|
+
readonly name: "idNumber";
|
|
101
|
+
readonly type: "string";
|
|
102
|
+
}, {
|
|
103
|
+
readonly name: "nationality";
|
|
104
|
+
readonly type: "string";
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "dateOfBirth";
|
|
107
|
+
readonly type: "string";
|
|
108
|
+
}, {
|
|
109
|
+
readonly name: "gender";
|
|
110
|
+
readonly type: "string";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "expiryDate";
|
|
113
|
+
readonly type: "string";
|
|
114
|
+
}, {
|
|
115
|
+
readonly name: "olderThan";
|
|
116
|
+
readonly type: "uint256";
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "ofac";
|
|
119
|
+
readonly type: "bool[3]";
|
|
120
|
+
}];
|
|
121
|
+
}];
|
|
122
|
+
}, {
|
|
123
|
+
readonly name: "agentRegisteredAt";
|
|
124
|
+
readonly type: "function";
|
|
125
|
+
readonly stateMutability: "view";
|
|
126
|
+
readonly inputs: readonly [{
|
|
127
|
+
readonly name: "agentId";
|
|
128
|
+
readonly type: "uint256";
|
|
129
|
+
}];
|
|
130
|
+
readonly outputs: readonly [{
|
|
131
|
+
readonly name: "";
|
|
132
|
+
readonly type: "uint256";
|
|
133
|
+
}];
|
|
134
|
+
}, {
|
|
135
|
+
readonly name: "proofExpiresAt";
|
|
136
|
+
readonly type: "function";
|
|
137
|
+
readonly stateMutability: "view";
|
|
138
|
+
readonly inputs: readonly [{
|
|
139
|
+
readonly name: "agentId";
|
|
140
|
+
readonly type: "uint256";
|
|
141
|
+
}];
|
|
142
|
+
readonly outputs: readonly [{
|
|
143
|
+
readonly name: "";
|
|
144
|
+
readonly type: "uint256";
|
|
145
|
+
}];
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "isProofFresh";
|
|
148
|
+
readonly type: "function";
|
|
149
|
+
readonly stateMutability: "view";
|
|
150
|
+
readonly inputs: readonly [{
|
|
151
|
+
readonly name: "agentId";
|
|
152
|
+
readonly type: "uint256";
|
|
153
|
+
}];
|
|
154
|
+
readonly outputs: readonly [{
|
|
155
|
+
readonly name: "";
|
|
156
|
+
readonly type: "bool";
|
|
157
|
+
}];
|
|
158
|
+
}, {
|
|
159
|
+
readonly name: "getAgentsForNullifier";
|
|
160
|
+
readonly type: "function";
|
|
161
|
+
readonly stateMutability: "view";
|
|
162
|
+
readonly inputs: readonly [{
|
|
163
|
+
readonly name: "nullifier";
|
|
164
|
+
readonly type: "uint256";
|
|
165
|
+
}];
|
|
166
|
+
readonly outputs: readonly [{
|
|
167
|
+
readonly name: "";
|
|
168
|
+
readonly type: "uint256[]";
|
|
169
|
+
}];
|
|
170
|
+
}, {
|
|
171
|
+
readonly name: "ownerOf";
|
|
172
|
+
readonly type: "function";
|
|
173
|
+
readonly stateMutability: "view";
|
|
174
|
+
readonly inputs: readonly [{
|
|
175
|
+
readonly name: "tokenId";
|
|
176
|
+
readonly type: "uint256";
|
|
177
|
+
}];
|
|
178
|
+
readonly outputs: readonly [{
|
|
179
|
+
readonly name: "";
|
|
180
|
+
readonly type: "address";
|
|
181
|
+
}];
|
|
182
|
+
}, {
|
|
183
|
+
readonly name: "updateAgentMetadata";
|
|
184
|
+
readonly type: "function";
|
|
185
|
+
readonly stateMutability: "nonpayable";
|
|
186
|
+
readonly inputs: readonly [{
|
|
187
|
+
readonly name: "agentId";
|
|
188
|
+
readonly type: "uint256";
|
|
189
|
+
}, {
|
|
190
|
+
readonly name: "metadata";
|
|
191
|
+
readonly type: "string";
|
|
192
|
+
}];
|
|
193
|
+
readonly outputs: readonly [];
|
|
194
|
+
}];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export const selfRegistryAbi = [
|
|
2
|
+
{
|
|
3
|
+
name: "isVerifiedAgent",
|
|
4
|
+
type: "function",
|
|
5
|
+
stateMutability: "view",
|
|
6
|
+
inputs: [{ name: "agentPubKey", type: "bytes32" }],
|
|
7
|
+
outputs: [{ name: "", type: "bool" }],
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
name: "getAgentId",
|
|
11
|
+
type: "function",
|
|
12
|
+
stateMutability: "view",
|
|
13
|
+
inputs: [{ name: "agentPubKey", type: "bytes32" }],
|
|
14
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "hasHumanProof",
|
|
18
|
+
type: "function",
|
|
19
|
+
stateMutability: "view",
|
|
20
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
21
|
+
outputs: [{ name: "", type: "bool" }],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "getHumanNullifier",
|
|
25
|
+
type: "function",
|
|
26
|
+
stateMutability: "view",
|
|
27
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
28
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "getAgentCountForHuman",
|
|
32
|
+
type: "function",
|
|
33
|
+
stateMutability: "view",
|
|
34
|
+
inputs: [{ name: "nullifier", type: "uint256" }],
|
|
35
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "getProofProvider",
|
|
39
|
+
type: "function",
|
|
40
|
+
stateMutability: "view",
|
|
41
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
42
|
+
outputs: [{ name: "", type: "address" }],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "selfProofProvider",
|
|
46
|
+
type: "function",
|
|
47
|
+
stateMutability: "view",
|
|
48
|
+
inputs: [],
|
|
49
|
+
outputs: [{ name: "", type: "address" }],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "getAgentCredentials",
|
|
53
|
+
type: "function",
|
|
54
|
+
stateMutability: "view",
|
|
55
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
56
|
+
outputs: [
|
|
57
|
+
{
|
|
58
|
+
name: "",
|
|
59
|
+
type: "tuple",
|
|
60
|
+
components: [
|
|
61
|
+
{ name: "issuingState", type: "string" },
|
|
62
|
+
{ name: "name", type: "string[]" },
|
|
63
|
+
{ name: "idNumber", type: "string" },
|
|
64
|
+
{ name: "nationality", type: "string" },
|
|
65
|
+
{ name: "dateOfBirth", type: "string" },
|
|
66
|
+
{ name: "gender", type: "string" },
|
|
67
|
+
{ name: "expiryDate", type: "string" },
|
|
68
|
+
{ name: "olderThan", type: "uint256" },
|
|
69
|
+
{ name: "ofac", type: "bool[3]" },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "agentRegisteredAt",
|
|
76
|
+
type: "function",
|
|
77
|
+
stateMutability: "view",
|
|
78
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
79
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "proofExpiresAt",
|
|
83
|
+
type: "function",
|
|
84
|
+
stateMutability: "view",
|
|
85
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
86
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "isProofFresh",
|
|
90
|
+
type: "function",
|
|
91
|
+
stateMutability: "view",
|
|
92
|
+
inputs: [{ name: "agentId", type: "uint256" }],
|
|
93
|
+
outputs: [{ name: "", type: "bool" }],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "getAgentsForNullifier",
|
|
97
|
+
type: "function",
|
|
98
|
+
stateMutability: "view",
|
|
99
|
+
inputs: [{ name: "nullifier", type: "uint256" }],
|
|
100
|
+
outputs: [{ name: "", type: "uint256[]" }],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "ownerOf",
|
|
104
|
+
type: "function",
|
|
105
|
+
stateMutability: "view",
|
|
106
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
107
|
+
outputs: [{ name: "", type: "address" }],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "updateAgentMetadata",
|
|
111
|
+
type: "function",
|
|
112
|
+
stateMutability: "nonpayable",
|
|
113
|
+
inputs: [
|
|
114
|
+
{ name: "agentId", type: "uint256" },
|
|
115
|
+
{ name: "metadata", type: "string" },
|
|
116
|
+
],
|
|
117
|
+
outputs: [],
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
//# sourceMappingURL=self-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-registry.js","sourceRoot":"","sources":["../../src/abis/self-registry.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B;QACE,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAClD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KACtC;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAClD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KACzC;IACD;QACE,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KACtC;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAA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,EAAE,SAAS,EAAE,CAAC;QAChD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;KAC3C;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KACzC;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACpC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;SACrC;QACD,OAAO,EAAE,EAAE;KACZ;CACqB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SdkConfig } from "../config/sdk-config.js";
|
|
2
|
+
/** Test-only hook to assert telemetry without calling Amplitude. */
|
|
3
|
+
export declare function setTrackFnForTests(fn: ((eventName: string, config: SdkConfig) => void) | null): void;
|
|
4
|
+
/** Fire-and-forget MCP tool name event; never throws to callers. */
|
|
5
|
+
export declare function trackMcpTool(eventName: string, config: SdkConfig): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isAnalyticsEnabled, resolveAmplitudeApiKey, resolveDeviceId, } from "./config.js";
|
|
2
|
+
let initialized = false;
|
|
3
|
+
let testTrackFn = null;
|
|
4
|
+
/** Test-only hook to assert telemetry without calling Amplitude. */
|
|
5
|
+
export function setTrackFnForTests(fn) {
|
|
6
|
+
testTrackFn = fn;
|
|
7
|
+
initialized = false;
|
|
8
|
+
}
|
|
9
|
+
async function ensureInit(config) {
|
|
10
|
+
const apiKey = resolveAmplitudeApiKey(config);
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (initialized) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const amplitude = await import("@amplitude/analytics-node");
|
|
19
|
+
amplitude.init(apiKey);
|
|
20
|
+
initialized = true;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Fire-and-forget MCP tool name event; never throws to callers. */
|
|
28
|
+
export function trackMcpTool(eventName, config) {
|
|
29
|
+
if (!isAnalyticsEnabled(config)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (testTrackFn) {
|
|
33
|
+
try {
|
|
34
|
+
testTrackFn(eventName, config);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// ignore test hook failures
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
void (async () => {
|
|
42
|
+
try {
|
|
43
|
+
if (!(await ensureInit(config))) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const amplitude = await import("@amplitude/analytics-node");
|
|
47
|
+
amplitude.track(eventName, undefined, {
|
|
48
|
+
device_id: resolveDeviceId(config),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// telemetry must not break SDK reads
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=amplitude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amplitude.js","sourceRoot":"","sources":["../../src/analytics/amplitude.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,WAAW,GACb,IAAI,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M,CAAC;aACnC,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,qCAAqC;QACvC,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SdkConfig } from "../config/sdk-config.js";
|
|
2
|
+
/** Public Amplitude project ingestion key (bundled for default telemetry on Node installs). */
|
|
3
|
+
export declare const DEFAULT_AMPLITUDE_API_KEY = "f36f9a7fdc253ed864072edc627b2a55";
|
|
4
|
+
/** Whether Amplitude read telemetry is active for this process. */
|
|
5
|
+
export declare function isAnalyticsEnabled(config: SdkConfig): boolean;
|
|
6
|
+
export declare function resolveAmplitudeApiKey(config: SdkConfig): string | undefined;
|
|
7
|
+
export declare function resolveDeviceId(config: SdkConfig): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Public Amplitude project ingestion key (bundled for default telemetry on Node installs). */
|
|
2
|
+
export const DEFAULT_AMPLITUDE_API_KEY = "f36f9a7fdc253ed864072edc627b2a55";
|
|
3
|
+
const DEFAULT_DEVICE_ID = "celina-sdk";
|
|
4
|
+
/** Whether Amplitude read telemetry is active for this process. */
|
|
5
|
+
export function isAnalyticsEnabled(config) {
|
|
6
|
+
if (typeof process === "undefined") {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (process.env.CELINA_ANALYTICS_DISABLED === "1") {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (config.analyticsEnabled === false) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
export function resolveAmplitudeApiKey(config) {
|
|
18
|
+
if (!isAnalyticsEnabled(config)) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return (config.amplitudeApiKey ??
|
|
22
|
+
process.env.AMPLITUDE_API_KEY ??
|
|
23
|
+
DEFAULT_AMPLITUDE_API_KEY);
|
|
24
|
+
}
|
|
25
|
+
export function resolveDeviceId(config) {
|
|
26
|
+
return (config.analyticsDeviceId ??
|
|
27
|
+
process.env.CELINA_ANALYTICS_DEVICE_ID ??
|
|
28
|
+
DEFAULT_DEVICE_ID);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/analytics/config.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,MAAM,CAAC,MAAM,yBAAyB,GAAG,kCAAkC,CAAC;AAE5E,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAEvC,mEAAmE;AACnE,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,yBAAyB,KAAK,GAAG,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,MAAM,CAAC,gBAAgB,KAAK,KAAK,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,CACL,MAAM,CAAC,eAAe;QACtB,OAAO,CAAC,GAAG,CAAC,iBAAiB;QAC7B,yBAAyB,CAC1B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,OAAO,CACL,MAAM,CAAC,iBAAiB;QACxB,OAAO,CAAC,GAAG,CAAC,0BAA0B;QACtC,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/generate-mcp-analytics-map.mjs — do not edit by hand.
|
|
3
|
+
* Maps SDK method keys (catalog OperationSpec.id) to MCP tool event names.
|
|
4
|
+
*/
|
|
5
|
+
export const MCP_TOOL_EVENT_BY_SDK_METHOD = {
|
|
6
|
+
"account.getAccount": "get_account",
|
|
7
|
+
"blockchain.getBlock": "get_block",
|
|
8
|
+
"blockchain.getLatestBlocks": "get_latest_blocks",
|
|
9
|
+
"blockchain.getNetworkStatus": "get_network_status",
|
|
10
|
+
"blockchain.getTransaction": "get_transaction",
|
|
11
|
+
"carbon.explorePair": "explore_carbon_pair",
|
|
12
|
+
"carbon.findOpportunities": "find_carbon_opportunities",
|
|
13
|
+
"carbon.getActivity": "get_carbon_activity",
|
|
14
|
+
"carbon.getPriceHistory": "get_carbon_price_history",
|
|
15
|
+
"carbon.getProtocolStats": "get_carbon_protocol_stats",
|
|
16
|
+
"carbon.getStrategies": "get_carbon_strategies",
|
|
17
|
+
"carbon.getStrategy": "get_carbon_strategy",
|
|
18
|
+
"carbon.getTradeQuote": "get_carbon_trade_quote",
|
|
19
|
+
"carbon.help": "carbon_help",
|
|
20
|
+
"carbon.learn": "carbon_learn",
|
|
21
|
+
"carbon.resolveToken": "resolve_carbon_token",
|
|
22
|
+
"carbon.simulateStrategy": "simulate_carbon_strategy",
|
|
23
|
+
"contract.callFunction": "call_contract_function",
|
|
24
|
+
"contract.estimateGas": "estimate_contract_gas",
|
|
25
|
+
"ens.resolveEns": "resolve_ens",
|
|
26
|
+
"gooddollar.getWhitelistingInfo": "get_gooddollar_whitelisting_info",
|
|
27
|
+
"governance.getGovernanceProposals": "get_governance_proposals",
|
|
28
|
+
"governance.getProposalDetails": "get_proposal_details",
|
|
29
|
+
"mentoFx.estimateFx": "estimate_mento_fx",
|
|
30
|
+
"mentoFx.getFxQuote": "get_mento_fx_quote",
|
|
31
|
+
"nft.getNftBalance": "get_nft_balance",
|
|
32
|
+
"nft.getNftInfo": "get_nft_info",
|
|
33
|
+
"self.authenticatedSelfFetch": "authenticated_self_fetch",
|
|
34
|
+
"self.checkSelfRegistration": "check_self_registration",
|
|
35
|
+
"self.getSelfIdentity": "get_self_identity",
|
|
36
|
+
"self.lookupSelfAgent": "lookup_self_agent",
|
|
37
|
+
"self.signSelfRequest": "sign_self_request",
|
|
38
|
+
"self.verifySelfAgent": "verify_self_agent",
|
|
39
|
+
"self.verifySelfRequest": "verify_self_request",
|
|
40
|
+
"staking.getActivatableStakes": "get_activatable_stakes",
|
|
41
|
+
"staking.getStakingBalances": "get_staking_balances",
|
|
42
|
+
"staking.getTotalStakingInfo": "get_total_staking_info",
|
|
43
|
+
"staking.getValidatorGroupDetails": "get_validator_group_details",
|
|
44
|
+
"staking.getValidatorGroups": "get_validator_groups",
|
|
45
|
+
"token.getBalances": "get_celo_balances",
|
|
46
|
+
"token.getStablecoinBalances": "get_stablecoin_balances",
|
|
47
|
+
"token.getTokenBalance": "get_token_balance",
|
|
48
|
+
"token.getTokenInfo": "get_token_info",
|
|
49
|
+
"transaction.estimateSend": "estimate_send",
|
|
50
|
+
"transaction.estimateTransaction": "estimate_transaction",
|
|
51
|
+
"transaction.getGasFeeData": "get_gas_fee_data",
|
|
52
|
+
"uniswap.estimateSwap": "estimate_uniswap_swap",
|
|
53
|
+
"uniswap.getSwapQuote": "get_uniswap_quote",
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=mcp-tool-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool-events.js","sourceRoot":"","sources":["../../src/analytics/mcp-tool-events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAqC;IAC5E,oBAAoB,EAAE,aAAa;IACnC,qBAAqB,EAAE,WAAW;IAClC,4BAA4B,EAAE,mBAAmB;IACjD,6BAA6B,EAAE,oBAAoB;IACnD,2BAA2B,EAAE,iBAAiB;IAC9C,oBAAoB,EAAE,qBAAqB;IAC3C,0BAA0B,EAAE,2BAA2B;IACvD,oBAAoB,E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dkConfig } from "../config/sdk-config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wrap a domain service so catalog-mapped async reads emit Amplitude events (MCP tool names).
|
|
4
|
+
*/
|
|
5
|
+
export declare function wrapServiceForAnalytics<T extends object>(serviceKey: string, service: T, config: SdkConfig): T;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { trackMcpTool } from "./amplitude.js";
|
|
2
|
+
import { isAnalyticsEnabled } from "./config.js";
|
|
3
|
+
import { MCP_TOOL_EVENT_BY_SDK_METHOD } from "./mcp-tool-events.js";
|
|
4
|
+
/**
|
|
5
|
+
* Wrap a domain service so catalog-mapped async reads emit Amplitude events (MCP tool names).
|
|
6
|
+
*/
|
|
7
|
+
export function wrapServiceForAnalytics(serviceKey, service, config) {
|
|
8
|
+
if (!isAnalyticsEnabled(config)) {
|
|
9
|
+
return service;
|
|
10
|
+
}
|
|
11
|
+
return new Proxy(service, {
|
|
12
|
+
get(target, prop, receiver) {
|
|
13
|
+
const value = Reflect.get(target, prop, receiver);
|
|
14
|
+
if (typeof prop !== "string" || typeof value !== "function") {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
const eventName = MCP_TOOL_EVENT_BY_SDK_METHOD[`${serviceKey}.${prop}`];
|
|
18
|
+
if (!eventName) {
|
|
19
|
+
return value.bind(target);
|
|
20
|
+
}
|
|
21
|
+
const fn = value;
|
|
22
|
+
return (...args) => {
|
|
23
|
+
const result = fn.apply(target, args);
|
|
24
|
+
if (result !== null && typeof result === "object" && "then" in result) {
|
|
25
|
+
return result.then((resolved) => {
|
|
26
|
+
trackMcpTool(eventName, config);
|
|
27
|
+
return resolved;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
trackMcpTool(eventName, config);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=wrap-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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AAM,CAAC,CAAC;wBAChC,OAAO,QAAQ,CAAC;oBAClB,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBAChC,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CarbonRestSuccess } from "../types/carbon.js";
|
|
2
|
+
export declare class CarbonRestError extends Error {
|
|
3
|
+
readonly toolName: string;
|
|
4
|
+
readonly statusCode?: number | undefined;
|
|
5
|
+
constructor(message: string, toolName: string, statusCode?: number | undefined);
|
|
6
|
+
}
|
|
7
|
+
export type CarbonRestBody = Record<string, unknown>;
|
|
8
|
+
export declare class CarbonRestClient {
|
|
9
|
+
private readonly baseUrl;
|
|
10
|
+
private readonly timeoutMs;
|
|
11
|
+
constructor(baseUrl?: string, timeoutMs?: number);
|
|
12
|
+
private url;
|
|
13
|
+
/**
|
|
14
|
+
* POST to Carbon MCP REST. Always injects `chain: celo` unless caller overrides.
|
|
15
|
+
*/
|
|
16
|
+
postTool<T extends CarbonRestSuccess = CarbonRestSuccess>(toolName: string, body?: CarbonRestBody): Promise<T>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CARBON_CHAIN, DEFAULT_CARBON_REST_BASE_URL } from "../config/carbon.js";
|
|
2
|
+
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
3
|
+
export class CarbonRestError extends Error {
|
|
4
|
+
toolName;
|
|
5
|
+
statusCode;
|
|
6
|
+
constructor(message, toolName, statusCode) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.toolName = toolName;
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
this.name = "CarbonRestError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class CarbonRestClient {
|
|
14
|
+
baseUrl;
|
|
15
|
+
timeoutMs;
|
|
16
|
+
constructor(baseUrl = DEFAULT_CARBON_REST_BASE_URL, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
17
|
+
this.baseUrl = baseUrl;
|
|
18
|
+
this.timeoutMs = timeoutMs;
|
|
19
|
+
}
|
|
20
|
+
url(toolName) {
|
|
21
|
+
const base = this.baseUrl.replace(/\/$/, "");
|
|
22
|
+
return `${base}/tools/${toolName}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* POST to Carbon MCP REST. Always injects `chain: celo` unless caller overrides.
|
|
26
|
+
*/
|
|
27
|
+
async postTool(toolName, body = {}) {
|
|
28
|
+
const payload = {
|
|
29
|
+
chain: CARBON_CHAIN,
|
|
30
|
+
...body,
|
|
31
|
+
};
|
|
32
|
+
const response = await fetch(this.url(toolName), {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: { "Content-Type": "application/json" },
|
|
35
|
+
body: JSON.stringify(payload),
|
|
36
|
+
signal: AbortSignal.timeout(this.timeoutMs),
|
|
37
|
+
});
|
|
38
|
+
const text = await response.text();
|
|
39
|
+
let json;
|
|
40
|
+
try {
|
|
41
|
+
json = text ? JSON.parse(text) : {};
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
throw new CarbonRestError(`Carbon API returned non-JSON (${response.status})`, toolName, response.status);
|
|
45
|
+
}
|
|
46
|
+
if (json.error && typeof json.error === "string") {
|
|
47
|
+
throw new CarbonRestError(json.error, toolName, response.status);
|
|
48
|
+
}
|
|
49
|
+
if (json.status === "not_found") {
|
|
50
|
+
const msg = typeof json.message === "string" ? json.message : "Carbon API not found";
|
|
51
|
+
throw new CarbonRestError(msg, toolName, response.status);
|
|
52
|
+
}
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new CarbonRestError(`Carbon API HTTP ${response.status}`, toolName, response.status);
|
|
55
|
+
}
|
|
56
|
+
return json;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=carbon-rest.js.map
|
|
@@ -0,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