@andrewkimjoseph/celina 0.2.17 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +45 -15
  2. package/build/abis/self-registry.d.ts +194 -0
  3. package/build/abis/self-registry.js +120 -0
  4. package/build/abis/self-registry.js.map +1 -0
  5. package/build/clients/self-api.d.ts +82 -0
  6. package/build/clients/self-api.js +242 -0
  7. package/build/clients/self-api.js.map +1 -0
  8. package/build/config/env.d.ts +1 -0
  9. package/build/config/env.js +1 -0
  10. package/build/config/env.js.map +1 -1
  11. package/build/config/self.d.ts +22 -0
  12. package/build/config/self.js +27 -0
  13. package/build/config/self.js.map +1 -0
  14. package/build/context/app-context.d.ts +4 -1
  15. package/build/context/app-context.js +4 -1
  16. package/build/context/app-context.js.map +1 -1
  17. package/build/server/create-server.js +1 -1
  18. package/build/server/create-server.js.map +1 -1
  19. package/build/server/instructions.js +6 -2
  20. package/build/server/instructions.js.map +1 -1
  21. package/build/services/self-session-store.d.ts +19 -0
  22. package/build/services/self-session-store.js +28 -0
  23. package/build/services/self-session-store.js.map +1 -0
  24. package/build/services/self.service.d.ts +250 -0
  25. package/build/services/self.service.js +689 -0
  26. package/build/services/self.service.js.map +1 -0
  27. package/build/tools/index.js +2 -0
  28. package/build/tools/index.js.map +1 -1
  29. package/build/tools/self.tools.d.ts +2 -0
  30. package/build/tools/self.tools.js +256 -0
  31. package/build/tools/self.tools.js.map +1 -0
  32. package/build/utils/self-format.d.ts +16 -0
  33. package/build/utils/self-format.js +59 -0
  34. package/build/utils/self-format.js.map +1 -0
  35. package/build/utils/self-signing.d.ts +4 -0
  36. package/build/utils/self-signing.js +38 -0
  37. package/build/utils/self-signing.js.map +1 -0
  38. package/package.json +3 -2
@@ -0,0 +1,242 @@
1
+ import { SELF_API_BASE, SELF_API_NETWORK, SELF_CHAIN_ID, } from "../config/self.js";
2
+ const DEFAULT_POLL_INTERVAL_MS = 5000;
3
+ const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000;
4
+ export class SelfApiError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = "SelfApiError";
8
+ }
9
+ }
10
+ export class SelfExpiredSessionError extends Error {
11
+ constructor(message = "Session expired. Start a new registration flow.") {
12
+ super(message);
13
+ this.name = "SelfExpiredSessionError";
14
+ }
15
+ }
16
+ function resolveApiBase(apiBase) {
17
+ return (apiBase ?? process.env.SELF_AGENT_API_BASE ?? SELF_API_BASE).replace(/\/+$/, "");
18
+ }
19
+ function sleep(ms) {
20
+ return new Promise((resolve) => setTimeout(resolve, ms));
21
+ }
22
+ async function apiFetch(url, init) {
23
+ const res = await fetch(url, init);
24
+ const body = (await res.json());
25
+ if (!res.ok) {
26
+ const errorMsg = typeof body.error === "string" ? body.error : `HTTP ${res.status}`;
27
+ throw new SelfApiError(errorMsg);
28
+ }
29
+ return body;
30
+ }
31
+ function sessionAuthHeaders(sessionToken) {
32
+ return { Authorization: `Bearer ${sessionToken}` };
33
+ }
34
+ async function fetchSessionStatus(apiBase, path, sessionToken) {
35
+ return apiFetch(`${apiBase}${path}?token=${encodeURIComponent(sessionToken)}`, { headers: sessionAuthHeaders(sessionToken) });
36
+ }
37
+ function handleSessionStatusError(error, expiredMessage) {
38
+ if (error instanceof SelfApiError &&
39
+ error.message.toLowerCase().includes("expired")) {
40
+ throw new SelfExpiredSessionError(expiredMessage);
41
+ }
42
+ throw error;
43
+ }
44
+ function optionalScanUrl(data) {
45
+ return typeof data.scanUrl === "string" ? data.scanUrl : undefined;
46
+ }
47
+ function buildRegistrationSession(data, apiBase) {
48
+ let currentToken = String(data.sessionToken);
49
+ return {
50
+ sessionToken: currentToken,
51
+ stage: String(data.stage),
52
+ deepLink: String(data.deepLink),
53
+ scanUrl: optionalScanUrl(data),
54
+ agentAddress: String(data.agentAddress),
55
+ expiresAt: String(data.expiresAt),
56
+ timeRemainingMs: typeof data.timeRemainingMs === "number" ? data.timeRemainingMs : undefined,
57
+ humanInstructions: Array.isArray(data.humanInstructions)
58
+ ? data.humanInstructions.map(String)
59
+ : [],
60
+ async waitForCompletion(opts) {
61
+ const timeout = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
62
+ const interval = opts?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
63
+ const deadline = Date.now() + timeout;
64
+ while (Date.now() < deadline) {
65
+ await sleep(interval);
66
+ let status;
67
+ try {
68
+ status = await fetchSessionStatus(apiBase, "/api/agent/register/status", currentToken);
69
+ }
70
+ catch (error) {
71
+ handleSessionStatusError(error, "Session expired. Start a new registration flow.");
72
+ }
73
+ currentToken = String(status.sessionToken);
74
+ if (status.stage === "completed") {
75
+ return {
76
+ agentId: Number(status.agentId),
77
+ agentAddress: String(status.agentAddress ?? data.agentAddress),
78
+ credentials: status.credentials,
79
+ txHash: typeof status.txHash === "string" ? status.txHash : undefined,
80
+ };
81
+ }
82
+ if (status.stage === "failed") {
83
+ throw new SelfApiError("Registration failed on-chain.");
84
+ }
85
+ if (status.stage === "expired") {
86
+ throw new SelfExpiredSessionError();
87
+ }
88
+ }
89
+ throw new SelfApiError(`Registration did not complete within ${timeout}ms. Call check_self_registration again to resume polling.`);
90
+ },
91
+ async exportKey() {
92
+ const result = await apiFetch(`${apiBase}/api/agent/register/export`, {
93
+ method: "POST",
94
+ headers: {
95
+ "Content-Type": "application/json",
96
+ ...sessionAuthHeaders(currentToken),
97
+ },
98
+ body: JSON.stringify({ token: currentToken }),
99
+ });
100
+ return result.privateKey;
101
+ },
102
+ };
103
+ }
104
+ function buildRefreshSession(data, apiBase) {
105
+ let currentToken = String(data.sessionToken);
106
+ return {
107
+ sessionToken: currentToken,
108
+ stage: String(data.stage),
109
+ deepLink: String(data.deepLink),
110
+ scanUrl: optionalScanUrl(data),
111
+ expiresAt: String(data.expiresAt),
112
+ timeRemainingMs: typeof data.timeRemainingMs === "number" ? data.timeRemainingMs : undefined,
113
+ humanInstructions: Array.isArray(data.humanInstructions)
114
+ ? data.humanInstructions.map(String)
115
+ : [],
116
+ async waitForCompletion(opts) {
117
+ const timeout = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
118
+ const interval = opts?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
119
+ const deadline = Date.now() + timeout;
120
+ while (Date.now() < deadline) {
121
+ await sleep(interval);
122
+ let status;
123
+ try {
124
+ status = await fetchSessionStatus(apiBase, "/api/agent/refresh/status", currentToken);
125
+ }
126
+ catch (error) {
127
+ handleSessionStatusError(error, "Proof refresh session expired. Call refresh_self_proof to start a new session.");
128
+ }
129
+ currentToken = String(status.sessionToken);
130
+ if (status.stage === "completed") {
131
+ const expiresAtRaw = status.proofExpiresAt;
132
+ const proofExpiresAt = typeof expiresAtRaw === "string" || typeof expiresAtRaw === "number"
133
+ ? new Date(expiresAtRaw)
134
+ : new Date(Date.now() + 365 * 24 * 60 * 60 * 1000);
135
+ return { proofExpiresAt };
136
+ }
137
+ if (status.stage === "failed") {
138
+ throw new SelfApiError("Proof refresh failed on-chain.");
139
+ }
140
+ if (status.stage === "expired") {
141
+ throw new SelfExpiredSessionError("Proof refresh session expired. Call refresh_self_proof to start a new session.");
142
+ }
143
+ }
144
+ throw new SelfApiError(`Proof refresh did not complete within ${timeout}ms. Call check_self_registration again to resume polling.`);
145
+ },
146
+ };
147
+ }
148
+ function buildDeregistrationSession(data, apiBase) {
149
+ let currentToken = String(data.sessionToken);
150
+ return {
151
+ sessionToken: currentToken,
152
+ stage: String(data.stage),
153
+ deepLink: String(data.deepLink),
154
+ scanUrl: optionalScanUrl(data),
155
+ expiresAt: String(data.expiresAt),
156
+ timeRemainingMs: typeof data.timeRemainingMs === "number" ? data.timeRemainingMs : undefined,
157
+ humanInstructions: Array.isArray(data.humanInstructions)
158
+ ? data.humanInstructions.map(String)
159
+ : [],
160
+ async waitForCompletion(opts) {
161
+ const timeout = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
162
+ const interval = opts?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
163
+ const deadline = Date.now() + timeout;
164
+ while (Date.now() < deadline) {
165
+ await sleep(interval);
166
+ let status;
167
+ try {
168
+ status = await fetchSessionStatus(apiBase, "/api/agent/deregister/status", currentToken);
169
+ }
170
+ catch (error) {
171
+ handleSessionStatusError(error, "Deregistration session expired. Call deregister_self_agent to start a new session.");
172
+ }
173
+ currentToken = String(status.sessionToken);
174
+ if (status.stage === "completed") {
175
+ return;
176
+ }
177
+ if (status.stage === "failed") {
178
+ throw new SelfApiError("Deregistration failed on-chain.");
179
+ }
180
+ if (status.stage === "expired") {
181
+ throw new SelfExpiredSessionError("Deregistration session expired. Call deregister_self_agent to start a new session.");
182
+ }
183
+ }
184
+ throw new SelfApiError(`Deregistration did not complete within ${timeout}ms. Call check_self_registration again to resume polling.`);
185
+ },
186
+ };
187
+ }
188
+ export async function requestRegistration(opts) {
189
+ const base = resolveApiBase(opts.apiBase);
190
+ const payload = {
191
+ mode: opts.mode ?? "wallet-free",
192
+ network: SELF_API_NETWORK,
193
+ disclosures: opts.disclosures,
194
+ humanAddress: opts.humanAddress,
195
+ agentName: opts.agentName,
196
+ agentDescription: opts.agentDescription,
197
+ };
198
+ const data = await apiFetch(`${base}/api/agent/register`, {
199
+ method: "POST",
200
+ headers: { "Content-Type": "application/json" },
201
+ body: JSON.stringify(payload),
202
+ });
203
+ return buildRegistrationSession(data, base);
204
+ }
205
+ export async function requestDeregistration(opts) {
206
+ const base = resolveApiBase(opts.apiBase);
207
+ const data = await apiFetch(`${base}/api/agent/deregister`, {
208
+ method: "POST",
209
+ headers: { "Content-Type": "application/json" },
210
+ body: JSON.stringify({
211
+ network: SELF_API_NETWORK,
212
+ agentAddress: opts.agentAddress,
213
+ disclosures: opts.disclosures,
214
+ }),
215
+ });
216
+ return buildDeregistrationSession(data, base);
217
+ }
218
+ export async function requestProofRefresh(opts) {
219
+ const base = resolveApiBase(opts.apiBase);
220
+ const data = await apiFetch(`${base}/api/agent/refresh`, {
221
+ method: "POST",
222
+ headers: { "Content-Type": "application/json" },
223
+ body: JSON.stringify({
224
+ agentId: opts.agentId,
225
+ network: SELF_API_NETWORK,
226
+ disclosures: opts.disclosures,
227
+ }),
228
+ });
229
+ return buildRefreshSession(data, base);
230
+ }
231
+ export async function getAgentInfo(agentId, apiBase) {
232
+ const base = resolveApiBase(apiBase);
233
+ return apiFetch(`${base}/api/agent/info/${SELF_CHAIN_ID}/${agentId}`);
234
+ }
235
+ export async function getAgentsForHuman(address, apiBase) {
236
+ const base = resolveApiBase(apiBase);
237
+ return apiFetch(`${base}/api/agent/agents/${SELF_CHAIN_ID}/${address}`);
238
+ }
239
+ export function selfQrUrl(sessionToken, apiBase) {
240
+ return `${resolveApiBase(apiBase)}/scan/${sessionToken}`;
241
+ }
242
+ //# sourceMappingURL=self-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-api.js","sourceRoot":"","sources":["../../src/clients/self-api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,GAEd,MAAM,mBAAmB,CAAC;AAE3B,MAAM,wBAAwB,GAAG,IAAI,CAAC;AACtC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1C,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAO,GAAG,iDAAiD;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AA8DD,SAAS,cAAc,CAAC,OAAgB;IACtC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,aAAa,CAAC,CAAC,OAAO,CAC1E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 +1,6 @@
1
1
  export interface AppConfig {
2
2
  rpcUrl: string;
3
3
  privateKey?: `0x${string}`;
4
+ selfAgentPrivateKey?: `0x${string}`;
4
5
  }
5
6
  export declare function loadConfig(): AppConfig;
@@ -2,6 +2,7 @@ export function loadConfig() {
2
2
  return {
3
3
  rpcUrl: process.env.CELO_RPC_URL_MAINNET ?? "https://forno.celo.org",
4
4
  privateKey: process.env.CELO_PRIVATE_KEY,
5
+ selfAgentPrivateKey: process.env.SELF_AGENT_PRIVATE_KEY,
5
6
  };
6
7
  }
7
8
  //# sourceMappingURL=env.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,wBAAwB;QACpE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA6C;KACtE,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,wBAAwB;QACpE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA6C;QACrE,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,sBAEpB;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ export declare const SELF_REGISTRY_ADDRESS: "0xaC3DF9ABf80d0F5c020C06B04Cced27763355944";
2
+ export declare const SELF_API_BASE = "https://app.ai.self.xyz";
3
+ /** Network value for Self lifecycle REST APIs (register, refresh, deregister). */
4
+ export declare const SELF_API_NETWORK = "mainnet";
5
+ /** Query param for Self demo/gated HTTP endpoints on Celo mainnet. */
6
+ export declare const SELF_DEMO_NETWORK = "celo-mainnet";
7
+ export declare const SELF_CHAIN_ID = 42220;
8
+ export declare function selfDemoUrl(path: string, network?: string): string;
9
+ export declare const SELF_SESSION_TTL_MS: number;
10
+ export declare const SELF_MAX_SESSIONS = 50;
11
+ export declare const SELF_DEFAULT_MAX_AGE_MS: number;
12
+ export declare const SELF_FETCH_MAX_BYTES: number;
13
+ /** Warning threshold for upcoming proof expiry (matches Self SDK isProofExpiringSoon). */
14
+ export declare const SELF_PROOF_EXPIRING_SOON_DAYS = 30;
15
+ export declare const SELF_HEADERS: {
16
+ readonly ADDRESS: "x-self-agent-address";
17
+ readonly SIGNATURE: "x-self-agent-signature";
18
+ readonly TIMESTAMP: "x-self-agent-timestamp";
19
+ readonly KEYTYPE: "x-self-agent-keytype";
20
+ readonly KEY: "x-self-agent-key";
21
+ };
22
+ export type SelfRegistrationMode = "linked" | "wallet-free" | "smartwallet" | "self-custody" | "ed25519" | "ed25519-linked";
@@ -0,0 +1,27 @@
1
+ export const SELF_REGISTRY_ADDRESS = "0xaC3DF9ABf80d0F5c020C06B04Cced27763355944";
2
+ export const SELF_API_BASE = "https://app.ai.self.xyz";
3
+ /** Network value for Self lifecycle REST APIs (register, refresh, deregister). */
4
+ export const SELF_API_NETWORK = "mainnet";
5
+ /** Query param for Self demo/gated HTTP endpoints on Celo mainnet. */
6
+ export const SELF_DEMO_NETWORK = "celo-mainnet";
7
+ export const SELF_CHAIN_ID = 42220;
8
+ export function selfDemoUrl(path, network = SELF_DEMO_NETWORK) {
9
+ const base = SELF_API_BASE.replace(/\/+$/, "");
10
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
11
+ const separator = normalizedPath.includes("?") ? "&" : "?";
12
+ return `${base}${normalizedPath}${separator}network=${network}`;
13
+ }
14
+ export const SELF_SESSION_TTL_MS = 10 * 60 * 1000;
15
+ export const SELF_MAX_SESSIONS = 50;
16
+ export const SELF_DEFAULT_MAX_AGE_MS = 5 * 60 * 1000;
17
+ export const SELF_FETCH_MAX_BYTES = 10 * 1024;
18
+ /** Warning threshold for upcoming proof expiry (matches Self SDK isProofExpiringSoon). */
19
+ export const SELF_PROOF_EXPIRING_SOON_DAYS = 30;
20
+ export const SELF_HEADERS = {
21
+ ADDRESS: "x-self-agent-address",
22
+ SIGNATURE: "x-self-agent-signature",
23
+ TIMESTAMP: "x-self-agent-timestamp",
24
+ KEYTYPE: "x-self-agent-keytype",
25
+ KEY: "x-self-agent-key",
26
+ };
27
+ //# sourceMappingURL=self.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self.js","sourceRoot":"","sources":["../../src/config/self.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAChC,4CAAqD,CAAC;AAExD,MAAM,CAAC,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAEvD,kFAAkF;AAClF,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAE1C,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAEnC,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,OAAO,GAAG,iBAAiB;IACnE,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAChE,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3D,OAAO,GAAG,IAAI,GAAG,cAAc,GAAG,SAAS,WAAW,OAAO,EAAE,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,sBAAsB;IAC/B,SAAS,EAAE,wBAAwB;IACnC,SAAS,EAAE,wBAAwB;IACnC,OAAO,EAAE,sBAAsB;IAC/B,GAAG,EAAE,kBAAkB;CACf,CAAC"}
@@ -6,10 +6,12 @@ import { TransactionService } from "../services/transaction.service.js";
6
6
  import { MentoFxService } from "../services/mento-fx.service.js";
7
7
  import { GoodDollarService } from "../services/gooddollar.service.js";
8
8
  import { AaveService } from "../services/aave.service.js";
9
+ import { SelfService } from "../services/self.service.js";
9
10
  export interface AppContext {
10
11
  config: {
11
12
  hasWallet: boolean;
12
13
  walletAddress?: `0x${string}`;
14
+ hasSelfAgentKey: boolean;
13
15
  };
14
16
  blockchain: BlockchainService;
15
17
  account: AccountService;
@@ -18,5 +20,6 @@ export interface AppContext {
18
20
  mentoFx: MentoFxService;
19
21
  gooddollar: GoodDollarService;
20
22
  aave: AaveService;
23
+ self: SelfService;
21
24
  }
22
- export declare function createAppContext(clientFactory: CeloClientFactory, walletAddress?: `0x${string}`): AppContext;
25
+ export declare function createAppContext(clientFactory: CeloClientFactory, walletAddress?: `0x${string}`, selfAgentPrivateKey?: `0x${string}`): AppContext;
@@ -5,11 +5,13 @@ import { TransactionService } from "../services/transaction.service.js";
5
5
  import { MentoFxService } from "../services/mento-fx.service.js";
6
6
  import { GoodDollarService } from "../services/gooddollar.service.js";
7
7
  import { AaveService } from "../services/aave.service.js";
8
- export function createAppContext(clientFactory, walletAddress) {
8
+ import { SelfService } from "../services/self.service.js";
9
+ export function createAppContext(clientFactory, walletAddress, selfAgentPrivateKey) {
9
10
  return {
10
11
  config: {
11
12
  hasWallet: Boolean(walletAddress),
12
13
  walletAddress,
14
+ hasSelfAgentKey: Boolean(selfAgentPrivateKey),
13
15
  },
14
16
  blockchain: new BlockchainService(clientFactory),
15
17
  account: new AccountService(clientFactory),
@@ -18,6 +20,7 @@ export function createAppContext(clientFactory, walletAddress) {
18
20
  mentoFx: new MentoFxService(clientFactory),
19
21
  gooddollar: new GoodDollarService(clientFactory),
20
22
  aave: new AaveService(clientFactory),
23
+ self: new SelfService(clientFactory, selfAgentPrivateKey),
21
24
  };
22
25
  }
23
26
  //# sourceMappingURL=app-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-context.js","sourceRoot":"","sources":["../../src/context/app-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAgB1D,MAAM,UAAU,gBAAgB,CAC9B,aAAgC,EAChC,aAA6B;IAE7B,OAAO;QACL,MAAM,EAAE;YACN,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC;YACjC,aAAa;SACd;QACD,UAAU,EAAE,IAAI,iBAAiB,CAAC,aAAa,CAAC;QAChD,OAAO,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC;QAC1C,KAAK,EAAE,IAAI,YAAY,CAAC,aAAa,CAAC;QACtC,WAAW,EAAE,IAAI,kBAAkB,CAAC,aAAa,CAAC;QAClD,OAAO,EAAE,IAAI,cAAc,CAAC,aAAa,CAAC;QAC1C,UAAU,EAAE,IAAI,iBAAiB,CAAC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function createServer() {
15
15
  logging: {},
16
16
  },
17
17
  });
18
- registerAllTools(server, createAppContext(clientFactory, clients.accountAddress));
18
+ registerAllTools(server, createAppContext(clientFactory, clients.accountAddress, config.selfAgentPrivateKey));
19
19
  return server;
20
20
  }
21
21
  //# sourceMappingURL=create-server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-server.js","sourceRoot":"","sources":["../../src/server/create-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,aAAa,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,EAAE,CAAC;IAE3C,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EACpC;QACE,YAAY,EAAE,mBAAmB;QACjC,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;YAC5B,OAAO,EAAE,EAAE;SACZ;KACF,CACF,CAAC;IAEF,gBAAgB,CACd,MAAM,EACN,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,cAAc,CAAC,CACxD,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"create-server.js","sourceRoot":"","sources":["../../src/server/create-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,aAAa,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,EAAE,CAAC;IAE3C,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EACpC;QACE,YAAY,EAAE,mBAAmB;QACjC,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;YAC5B,OAAO,EAAE,EAAE;SACZ;KACF,CACF,CAAC;IAEF,gBAAgB,CACd,MAAM,EACN,gBAAgB,CACd,aAAa,EACb,OAAO,CAAC,cAAc,EACtB,MAAM,CAAC,mBAAmB,CAC3B,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -11,7 +11,11 @@ Guidelines:
11
11
  - Use get_gooddollar_whitelisting_info to check GoodDollar IdentityV4 whitelist status, whitelisting date, and reverification progress for a wallet.
12
12
  - Mento FX tools (get_mento_fx_quote, estimate_mento_fx, execute_mento_fx) convert between Mento oracle-priced tokens (USDm, EURm, CELO, etc.). They are unavailable when the Mento FX market is closed.
13
13
  - Aave tools (supply_aave_usdt, withdraw_aave_usdt) supply and withdraw USDT on Aave V3 Celo. Use get_celo_balances with tokens ["USDT"] before supplying; use withdrawMax on withdraw to redeem the full supplied balance.
14
-
15
- Future tools (add as new modules in src/tools/): Self verify, Self Agent ID check.
14
+ - Self Agent ID tools (ai.self.xyz on Celo mainnet):
15
+ - Read: verify_self_agent, lookup_self_agent, verify_self_request, get_self_identity
16
+ - Register: register_self_agent → human scans QR → check_self_registration (returns private_key_hex on success)
17
+ - Lifecycle: refresh_self_proof (only after on-chain proof expiry), deregister_self_agent (poll with check_self_registration)
18
+ - Auth: sign_self_request, authenticated_self_fetch (require SELF_AGENT_PRIVATE_KEY or encryptedSelfAgentPrivateKey). For Self demo/gated APIs use ?network=celo-mainnet (not mainnet), e.g. POST https://app.ai.self.xyz/api/demo/verify?network=celo-mainnet
19
+ - Self agent keys are separate from CELO_PRIVATE_KEY. Registration sessions are in-memory (~10 min TTL); HTTP multi-instance hosting may require sticky sessions.
16
20
  `.trim();
17
21
  //# sourceMappingURL=instructions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/server/instructions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;CAelC,CAAC,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/server/instructions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;CAmBlC,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { SelfDeregistrationSession, SelfRefreshSession, SelfRegistrationSession } from "../clients/self-api.js";
2
+ export type SelfSessionKind = "registration" | "refresh" | "deregistration";
3
+ export type StoredSelfSession = {
4
+ kind: "registration";
5
+ session: SelfRegistrationSession;
6
+ createdAt: number;
7
+ } | {
8
+ kind: "refresh";
9
+ session: SelfRefreshSession;
10
+ createdAt: number;
11
+ } | {
12
+ kind: "deregistration";
13
+ session: SelfDeregistrationSession;
14
+ createdAt: number;
15
+ };
16
+ export declare function storeSelfSession(sessionToken: string, entry: StoredSelfSession): void;
17
+ export declare function getSelfSession(sessionToken: string): StoredSelfSession | undefined;
18
+ export declare function deleteSelfSession(sessionToken: string): void;
19
+ export declare function clearSelfSessionsForTests(): void;
@@ -0,0 +1,28 @@
1
+ import { SELF_MAX_SESSIONS, SELF_SESSION_TTL_MS } from "../config/self.js";
2
+ const sessions = new Map();
3
+ function pruneExpiredSessions() {
4
+ const now = Date.now();
5
+ for (const [key, entry] of sessions) {
6
+ if (now - entry.createdAt > SELF_SESSION_TTL_MS) {
7
+ sessions.delete(key);
8
+ }
9
+ }
10
+ }
11
+ export function storeSelfSession(sessionToken, entry) {
12
+ pruneExpiredSessions();
13
+ if (sessions.size >= SELF_MAX_SESSIONS) {
14
+ throw new Error("Too many active Self sessions. Wait for existing sessions to expire (10 minutes) or restart the server.");
15
+ }
16
+ sessions.set(sessionToken, entry);
17
+ }
18
+ export function getSelfSession(sessionToken) {
19
+ pruneExpiredSessions();
20
+ return sessions.get(sessionToken);
21
+ }
22
+ export function deleteSelfSession(sessionToken) {
23
+ sessions.delete(sessionToken);
24
+ }
25
+ export function clearSelfSessionsForTests() {
26
+ sessions.clear();
27
+ }
28
+ //# sourceMappingURL=self-session-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-session-store.js","sourceRoot":"","sources":["../../src/services/self-session-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AA0B3E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA6B,CAAC;AAEtD,SAAS,oBAAoB;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEvB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QACpC,IAAI,GAAG,GAAG,KAAK,CAAC,SAAS,GAAG,mBAAmB,EAAE,CAAC;YAChD,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,YAAoB,EACpB,KAAwB;IAExB,oBAAoB,EAAE,CAAC;IAEvB,IAAI,QAAQ,CAAC,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACb,yGAAyG,CAC1G,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,YAAoB;IACjD,oBAAoB,EAAE,CAAC;IACvB,OAAO,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,YAAoB;IACpD,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}