@elizaos/plugin-elizacloud 2.0.0-beta.1 → 2.0.11-beta.7

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 (285) hide show
  1. package/README.md +20 -44
  2. package/auto-enable.ts +10 -5
  3. package/dist/browser/index.browser.js +2 -2
  4. package/dist/browser/index.browser.js.map +4 -4
  5. package/dist/cjs/index.node.cjs +2874 -5915
  6. package/dist/cjs/index.node.js.map +47 -116
  7. package/dist/cloud/auth-service-types.d.ts +8 -0
  8. package/dist/cloud/auth-service-types.d.ts.map +1 -0
  9. package/dist/cloud/auth-service-types.js +36 -0
  10. package/dist/cloud/auth-service-types.js.map +10 -0
  11. package/dist/cloud/auth.js +4 -51
  12. package/dist/cloud/auth.js.map +4 -4
  13. package/dist/cloud/base-url.d.ts +6 -2
  14. package/dist/cloud/base-url.d.ts.map +1 -1
  15. package/dist/cloud/base-url.js +3 -51
  16. package/dist/cloud/base-url.js.map +3 -3
  17. package/dist/cloud/bridge-client.d.ts +3 -3
  18. package/dist/cloud/bridge-client.d.ts.map +1 -1
  19. package/dist/cloud/bridge-client.js +3 -51
  20. package/dist/cloud/bridge-client.js.map +3 -3
  21. package/dist/cloud/clack-observer.d.ts +35 -0
  22. package/dist/cloud/clack-observer.d.ts.map +1 -0
  23. package/dist/cloud/clack-observer.js +143 -0
  24. package/dist/cloud/clack-observer.js.map +10 -0
  25. package/dist/cloud/cloud-manager.js +45 -92
  26. package/dist/cloud/cloud-manager.js.map +6 -6
  27. package/dist/cloud/cloud-wallet.js +2 -4835
  28. package/dist/cloud/cloud-wallet.js.map +3 -82
  29. package/dist/cloud/duffel-client.d.ts +181 -0
  30. package/dist/cloud/duffel-client.d.ts.map +1 -0
  31. package/dist/cloud/duffel-client.js +506 -0
  32. package/dist/cloud/duffel-client.js.map +11 -0
  33. package/dist/cloud/index.d.ts +6 -0
  34. package/dist/cloud/index.d.ts.map +1 -1
  35. package/dist/cloud/index.js +1782 -1
  36. package/dist/cloud/index.js.map +18 -3
  37. package/dist/cloud/lifeops-schedule-sync-client.d.ts +43 -0
  38. package/dist/cloud/lifeops-schedule-sync-client.d.ts.map +1 -0
  39. package/dist/cloud/lifeops-schedule-sync-client.js +180 -0
  40. package/dist/cloud/lifeops-schedule-sync-client.js.map +11 -0
  41. package/dist/cloud/lifeops-schedule-sync-contracts.d.ts +89 -0
  42. package/dist/cloud/lifeops-schedule-sync-contracts.d.ts.map +1 -0
  43. package/dist/cloud/lifeops-schedule-sync-contracts.js +39 -0
  44. package/dist/cloud/lifeops-schedule-sync-contracts.js.map +10 -0
  45. package/dist/cloud/managed-payment-clients.d.ts +166 -0
  46. package/dist/cloud/managed-payment-clients.d.ts.map +1 -0
  47. package/dist/cloud/managed-payment-clients.js +238 -0
  48. package/dist/cloud/managed-payment-clients.js.map +11 -0
  49. package/dist/cloud/null-observer.d.ts +35 -0
  50. package/dist/cloud/null-observer.d.ts.map +1 -0
  51. package/dist/cloud/null-observer.js +45 -0
  52. package/dist/cloud/null-observer.js.map +10 -0
  53. package/dist/cloud/setup-observer.d.ts +98 -0
  54. package/dist/cloud/setup-observer.d.ts.map +1 -0
  55. package/dist/cloud/setup-observer.js +2 -0
  56. package/dist/cloud/setup-observer.js.map +9 -0
  57. package/dist/cloud/validate-url.d.ts.map +1 -1
  58. package/dist/cloud/validate-url.js +2 -1
  59. package/dist/cloud/validate-url.js.map +3 -3
  60. package/dist/cloud/x402-payment-handler.d.ts +85 -0
  61. package/dist/cloud/x402-payment-handler.d.ts.map +1 -0
  62. package/dist/cloud/x402-payment-handler.js +119 -0
  63. package/dist/cloud/x402-payment-handler.js.map +10 -0
  64. package/dist/cloud-setup.d.ts +36 -0
  65. package/dist/cloud-setup.d.ts.map +1 -0
  66. package/dist/{onboarding.js → cloud-setup.js} +139 -139
  67. package/dist/cloud-setup.js.map +14 -0
  68. package/dist/cloud-voice-catalog.d.ts +65 -0
  69. package/dist/cloud-voice-catalog.d.ts.map +1 -0
  70. package/dist/cloud-voice-catalog.js +278 -0
  71. package/dist/cloud-voice-catalog.js.map +12 -0
  72. package/dist/index.browser.d.ts +11 -0
  73. package/dist/index.browser.d.ts.map +1 -1
  74. package/dist/index.d.ts +7 -1
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +5416 -8405
  77. package/dist/index.js.map +48 -116
  78. package/dist/index.node.d.ts +8 -1
  79. package/dist/index.node.d.ts.map +1 -1
  80. package/dist/init.js +17 -4
  81. package/dist/init.js.map +4 -4
  82. package/dist/lib/cloud-connection.d.ts +0 -1
  83. package/dist/lib/cloud-connection.d.ts.map +1 -1
  84. package/dist/lib/cloud-connection.js +14 -91
  85. package/dist/lib/cloud-connection.js.map +7 -7
  86. package/dist/lib/cloud-secrets.d.ts +5 -18
  87. package/dist/lib/cloud-secrets.d.ts.map +1 -1
  88. package/dist/lib/cloud-secrets.js +8 -36
  89. package/dist/lib/cloud-secrets.js.map +3 -3
  90. package/dist/lib/config-like.d.ts +1 -1
  91. package/dist/lib/config-like.d.ts.map +1 -1
  92. package/dist/lib/config-like.js +3 -3
  93. package/dist/lib/config-like.js.map +3 -3
  94. package/dist/lib/credential-type-map.d.ts +1 -1
  95. package/dist/lib/credential-type-map.js.map +1 -1
  96. package/dist/lib/http.d.ts +0 -11
  97. package/dist/lib/http.d.ts.map +1 -1
  98. package/dist/lib/http.js.map +2 -2
  99. package/dist/lib/server-cloud-tts.d.ts +12 -25
  100. package/dist/lib/server-cloud-tts.d.ts.map +1 -1
  101. package/dist/lib/server-cloud-tts.js +31 -329
  102. package/dist/lib/server-cloud-tts.js.map +4 -7
  103. package/dist/lib/tts-debug.d.ts +5 -3
  104. package/dist/lib/tts-debug.d.ts.map +1 -1
  105. package/dist/lib/tts-debug.js +1 -34
  106. package/dist/lib/tts-debug.js.map +3 -4
  107. package/dist/models/embeddings.d.ts.map +1 -1
  108. package/dist/models/embeddings.js +79 -69
  109. package/dist/models/embeddings.js.map +6 -6
  110. package/dist/models/image.d.ts.map +1 -1
  111. package/dist/models/image.js +42 -15
  112. package/dist/models/image.js.map +6 -6
  113. package/dist/models/index.js +676 -166
  114. package/dist/models/index.js.map +11 -12
  115. package/dist/models/research.d.ts.map +1 -1
  116. package/dist/models/research.js +24 -7
  117. package/dist/models/research.js.map +6 -6
  118. package/dist/models/speech.d.ts +61 -3
  119. package/dist/models/speech.d.ts.map +1 -1
  120. package/dist/models/speech.js +173 -17
  121. package/dist/models/speech.js.map +5 -5
  122. package/dist/models/text.d.ts +106 -1
  123. package/dist/models/text.d.ts.map +1 -1
  124. package/dist/models/text.js +452 -82
  125. package/dist/models/text.js.map +7 -8
  126. package/dist/models/tokenization.d.ts.map +1 -1
  127. package/dist/models/tokenization.js.map +2 -2
  128. package/dist/models/transcription.d.ts.map +1 -1
  129. package/dist/models/transcription.js +20 -6
  130. package/dist/models/transcription.js.map +5 -5
  131. package/dist/node/index.node.js +2828 -5838
  132. package/dist/node/index.node.js.map +47 -116
  133. package/dist/plugin.d.ts.map +1 -1
  134. package/dist/plugin.js +376 -5050
  135. package/dist/plugin.js.map +16 -92
  136. package/dist/providers/openai.js +11 -2
  137. package/dist/providers/openai.js.map +3 -3
  138. package/dist/register-routes.js +376 -5050
  139. package/dist/register-routes.js.map +16 -92
  140. package/dist/routes/cloud-billing-routes.d.ts.map +1 -1
  141. package/dist/routes/cloud-billing-routes.js +17 -60
  142. package/dist/routes/cloud-billing-routes.js.map +8 -7
  143. package/dist/routes/cloud-coding-container-routes.d.ts +8 -0
  144. package/dist/routes/cloud-coding-container-routes.d.ts.map +1 -0
  145. package/dist/routes/cloud-coding-container-routes.js +214 -0
  146. package/dist/routes/cloud-coding-container-routes.js.map +11 -0
  147. package/dist/routes/cloud-compat-routes.d.ts.map +1 -1
  148. package/dist/routes/cloud-compat-routes.js +17 -60
  149. package/dist/routes/cloud-compat-routes.js.map +8 -7
  150. package/dist/routes/cloud-features-routes.js +2 -2
  151. package/dist/routes/cloud-features-routes.js.map +4 -4
  152. package/dist/routes/cloud-relay-routes.d.ts +2 -1
  153. package/dist/routes/cloud-relay-routes.d.ts.map +1 -1
  154. package/dist/routes/cloud-relay-routes.js +84 -2
  155. package/dist/routes/cloud-relay-routes.js.map +5 -4
  156. package/dist/routes/cloud-routes-autonomous.d.ts +3 -4
  157. package/dist/routes/cloud-routes-autonomous.d.ts.map +1 -1
  158. package/dist/routes/cloud-routes-autonomous.js +11 -4893
  159. package/dist/routes/cloud-routes-autonomous.js.map +8 -87
  160. package/dist/routes/cloud-routes.d.ts +2 -2
  161. package/dist/routes/cloud-routes.d.ts.map +1 -1
  162. package/dist/routes/cloud-routes.js +343 -5058
  163. package/dist/routes/cloud-routes.js.map +13 -90
  164. package/dist/routes/cloud-status-routes-autonomous.d.ts +1 -2
  165. package/dist/routes/cloud-status-routes-autonomous.d.ts.map +1 -1
  166. package/dist/routes/cloud-status-routes-autonomous.js +4 -51
  167. package/dist/routes/cloud-status-routes-autonomous.js.map +5 -5
  168. package/dist/routes/cloud-status-routes.js +14 -90
  169. package/dist/routes/cloud-status-routes.js.map +7 -7
  170. package/dist/routes/home-remote-runner-access-url.d.ts +16 -0
  171. package/dist/routes/home-remote-runner-access-url.d.ts.map +1 -0
  172. package/dist/routes/home-remote-runner-access-url.js +91 -0
  173. package/dist/routes/home-remote-runner-access-url.js.map +10 -0
  174. package/dist/routes/travel-provider-relay-routes.d.ts +9 -0
  175. package/dist/routes/travel-provider-relay-routes.d.ts.map +1 -0
  176. package/dist/routes/travel-provider-relay-routes.js +358 -0
  177. package/dist/routes/travel-provider-relay-routes.js.map +14 -0
  178. package/dist/services/cloud-auth.d.ts +1 -1
  179. package/dist/services/cloud-auth.d.ts.map +1 -1
  180. package/dist/services/cloud-auth.js +7 -2
  181. package/dist/services/cloud-auth.js.map +4 -4
  182. package/dist/services/cloud-backup.js.map +2 -2
  183. package/dist/services/cloud-bootstrap.d.ts.map +1 -1
  184. package/dist/services/cloud-bootstrap.js.map +2 -2
  185. package/dist/services/cloud-bridge.js.map +3 -3
  186. package/dist/services/cloud-container.d.ts +5 -1
  187. package/dist/services/cloud-container.d.ts.map +1 -1
  188. package/dist/services/cloud-container.js +52 -1
  189. package/dist/services/cloud-container.js.map +4 -4
  190. package/dist/services/cloud-credential-provider.js.map +2 -2
  191. package/dist/services/cloud-model-registry.js.map +2 -2
  192. package/dist/types/cloud.d.ts +1 -0
  193. package/dist/types/cloud.d.ts.map +1 -1
  194. package/dist/types/cloud.js.map +2 -2
  195. package/dist/types/index.d.ts +1 -1
  196. package/dist/types/index.d.ts.map +1 -1
  197. package/dist/utils/cloud-sdk/client.d.ts.map +1 -1
  198. package/dist/utils/cloud-sdk/client.js +136 -4
  199. package/dist/utils/cloud-sdk/client.js.map +5 -5
  200. package/dist/utils/cloud-sdk/http.js.map +1 -1
  201. package/dist/utils/cloud-sdk/public-routes.d.ts +186 -0
  202. package/dist/utils/cloud-sdk/public-routes.d.ts.map +1 -1
  203. package/dist/utils/cloud-sdk/public-routes.js +99 -1
  204. package/dist/utils/cloud-sdk/public-routes.js.map +3 -3
  205. package/dist/utils/cloud-sdk/types.d.ts +0 -2
  206. package/dist/utils/cloud-sdk/types.d.ts.map +1 -1
  207. package/dist/utils/cloud-sdk/types.js.map +1 -1
  208. package/dist/utils/config.d.ts +10 -1
  209. package/dist/utils/config.d.ts.map +1 -1
  210. package/dist/utils/config.js +12 -2
  211. package/dist/utils/config.js.map +3 -3
  212. package/dist/utils/events.d.ts +23 -2
  213. package/dist/utils/events.d.ts.map +1 -1
  214. package/dist/utils/events.js +5 -3
  215. package/dist/utils/events.js.map +3 -3
  216. package/dist/utils/sdk-client.d.ts.map +1 -1
  217. package/dist/utils/sdk-client.js +17 -4
  218. package/dist/utils/sdk-client.js.map +4 -4
  219. package/dist/utils/waifu-metering.d.ts +108 -0
  220. package/dist/utils/waifu-metering.d.ts.map +1 -0
  221. package/dist/utils/waifu-metering.js +166 -0
  222. package/dist/utils/waifu-metering.js.map +10 -0
  223. package/package.json +51 -22
  224. package/src/cloud/auth-service-types.ts +24 -0
  225. package/src/cloud/base-url.ts +6 -62
  226. package/src/cloud/clack-observer.ts +189 -0
  227. package/src/cloud/duffel-client.ts +847 -0
  228. package/src/cloud/index.ts +10 -0
  229. package/src/cloud/lifeops-schedule-sync-client.ts +245 -0
  230. package/src/cloud/lifeops-schedule-sync-contracts.ts +124 -0
  231. package/src/cloud/managed-payment-clients.ts +374 -0
  232. package/src/cloud/null-observer.ts +45 -0
  233. package/src/cloud/setup-observer.ts +125 -0
  234. package/src/cloud/validate-url.ts +7 -1
  235. package/src/cloud/x402-payment-handler.ts +215 -0
  236. package/src/cloud-setup.ts +531 -0
  237. package/src/cloud-voice-catalog.test.ts +254 -0
  238. package/src/cloud-voice-catalog.ts +246 -0
  239. package/src/index.browser.ts +29 -0
  240. package/src/index.node.ts +31 -1
  241. package/src/index.ts +76 -4
  242. package/src/lib/cloud-connection.ts +2 -4
  243. package/src/lib/cloud-secrets.ts +10 -54
  244. package/src/lib/config-like.ts +1 -1
  245. package/src/lib/credential-type-map.ts +2 -2
  246. package/src/lib/http.ts +0 -17
  247. package/src/lib/server-cloud-tts.ts +33 -341
  248. package/src/lib/tts-debug.ts +5 -34
  249. package/src/models/embeddings.ts +140 -76
  250. package/src/models/image.ts +29 -14
  251. package/src/models/research.ts +11 -1
  252. package/src/models/speech.ts +269 -23
  253. package/src/models/text.ts +704 -110
  254. package/src/models/tokenization.ts +2 -2
  255. package/src/models/transcription.ts +7 -3
  256. package/src/plugin.ts +38 -0
  257. package/src/routes/cloud-billing-routes.ts +4 -14
  258. package/src/routes/cloud-coding-container-routes.ts +198 -0
  259. package/src/routes/cloud-compat-routes.ts +4 -14
  260. package/src/routes/cloud-features-routes.ts +1 -1
  261. package/src/routes/cloud-relay-routes.ts +47 -1
  262. package/src/routes/cloud-routes-autonomous.ts +7 -10
  263. package/src/routes/cloud-routes.ts +68 -7
  264. package/src/routes/cloud-status-routes-autonomous.ts +6 -2
  265. package/src/routes/home-remote-runner-access-url.ts +83 -0
  266. package/src/routes/travel-provider-relay-routes.ts +193 -0
  267. package/src/services/cloud-auth.ts +9 -2
  268. package/src/services/cloud-bootstrap.ts +1 -3
  269. package/src/services/cloud-bridge.ts +1 -1
  270. package/src/services/cloud-container.ts +93 -0
  271. package/src/services/cloud-credential-provider.ts +1 -1
  272. package/src/services/cloud-model-registry.ts +1 -1
  273. package/src/types/cloud.ts +22 -0
  274. package/src/types/index.ts +19 -0
  275. package/src/utils/cloud-sdk/client.ts +42 -3
  276. package/src/utils/cloud-sdk/public-routes.ts +168 -0
  277. package/src/utils/cloud-sdk/types.ts +0 -2
  278. package/src/utils/config.ts +20 -1
  279. package/src/utils/events.ts +30 -2
  280. package/src/utils/sdk-client.ts +5 -1
  281. package/src/utils/waifu-metering.ts +302 -0
  282. package/dist/onboarding.d.ts +0 -35
  283. package/dist/onboarding.d.ts.map +0 -1
  284. package/dist/onboarding.js.map +0 -14
  285. package/src/onboarding.ts +0 -396
@@ -0,0 +1,374 @@
1
+ import {
2
+ normalizeCloudSiteUrl,
3
+ resolveCloudApiBaseUrl,
4
+ } from "./base-url.js";
5
+
6
+ export { normalizeCloudSiteUrl, resolveCloudApiBaseUrl } from "./base-url.js";
7
+
8
+ export interface ElizaCloudManagedClientConfig {
9
+ configured: boolean;
10
+ apiKey: string | null;
11
+ apiBaseUrl: string;
12
+ siteUrl: string;
13
+ }
14
+
15
+ export function normalizeElizaCloudApiKey(
16
+ value: string | undefined | null,
17
+ ): string | null {
18
+ const trimmed = value?.trim();
19
+ if (!trimmed) return null;
20
+ return trimmed.toUpperCase() === "[REDACTED]" ? null : trimmed;
21
+ }
22
+
23
+ export function resolveEnvElizaCloudManagedClientConfig(
24
+ env: Record<string, string | undefined> =
25
+ typeof process === "undefined" ? {} : process.env,
26
+ ): ElizaCloudManagedClientConfig {
27
+ const apiKey = normalizeElizaCloudApiKey(env.ELIZAOS_CLOUD_API_KEY);
28
+ const baseUrl = env.ELIZAOS_CLOUD_BASE_URL;
29
+ return {
30
+ configured: Boolean(apiKey),
31
+ apiKey,
32
+ apiBaseUrl: resolveCloudApiBaseUrl(baseUrl),
33
+ siteUrl: normalizeCloudSiteUrl(baseUrl),
34
+ };
35
+ }
36
+
37
+ const PLAID_REQUEST_TIMEOUT_MS = 30_000;
38
+ const PAYPAL_REQUEST_TIMEOUT_MS = 30_000;
39
+
40
+ type ConfigSource = () => ElizaCloudManagedClientConfig;
41
+
42
+ export class PlaidManagedClientError extends Error {
43
+ constructor(
44
+ public readonly status: number,
45
+ message: string,
46
+ ) {
47
+ super(message);
48
+ this.name = "PlaidManagedClientError";
49
+ }
50
+ }
51
+
52
+ export class PaypalManagedClientError extends Error {
53
+ constructor(
54
+ public readonly status: number,
55
+ message: string,
56
+ public readonly fallback: "csv_export" | null = null,
57
+ ) {
58
+ super(message);
59
+ this.name = "PaypalManagedClientError";
60
+ }
61
+ }
62
+
63
+ async function readPlaidJson<T>(response: Response): Promise<T> {
64
+ if (!response.ok) {
65
+ let detail = `${response.status} ${response.statusText}`.trim();
66
+ const text = await response.text();
67
+ if (text.trim().length > 0) {
68
+ try {
69
+ const parsed = JSON.parse(text) as {
70
+ error?: string;
71
+ message?: string;
72
+ };
73
+ detail = parsed.message ?? parsed.error ?? text.slice(0, 240);
74
+ } catch {
75
+ detail = text.slice(0, 240);
76
+ }
77
+ }
78
+ throw new PlaidManagedClientError(response.status, detail);
79
+ }
80
+ return (await response.json()) as T;
81
+ }
82
+
83
+ async function readPaypalJson<T>(response: Response): Promise<T> {
84
+ if (!response.ok) {
85
+ let detail = `${response.status} ${response.statusText}`.trim();
86
+ let fallback: "csv_export" | null = null;
87
+ const text = await response.text();
88
+ if (text.trim().length > 0) {
89
+ try {
90
+ const parsed = JSON.parse(text) as {
91
+ error?: string;
92
+ message?: string;
93
+ fallback?: "csv_export" | null;
94
+ };
95
+ detail = parsed.message ?? parsed.error ?? text.slice(0, 240);
96
+ fallback = parsed.fallback ?? null;
97
+ } catch {
98
+ detail = text.slice(0, 240);
99
+ }
100
+ }
101
+ throw new PaypalManagedClientError(response.status, detail, fallback);
102
+ }
103
+ return (await response.json()) as T;
104
+ }
105
+
106
+ export interface PlaidLinkTokenResponse {
107
+ linkToken: string;
108
+ expiration: string;
109
+ environment: "sandbox" | "development" | "production";
110
+ }
111
+
112
+ export interface PlaidExchangeResponse {
113
+ accessToken: string;
114
+ itemId: string;
115
+ institution: {
116
+ institutionId: string;
117
+ institutionName: string;
118
+ primaryAccountMask: string | null;
119
+ accounts: Array<{
120
+ accountId: string;
121
+ name: string;
122
+ mask: string | null;
123
+ type: string;
124
+ subtype: string | null;
125
+ }>;
126
+ };
127
+ }
128
+
129
+ export interface PlaidSyncResponse {
130
+ added: PlaidTransactionDto[];
131
+ modified: PlaidTransactionDto[];
132
+ removed: Array<{ transaction_id: string }>;
133
+ nextCursor: string;
134
+ hasMore: boolean;
135
+ }
136
+
137
+ export interface PlaidTransactionDto {
138
+ transaction_id: string;
139
+ account_id: string;
140
+ amount: number;
141
+ iso_currency_code: string | null;
142
+ unofficial_currency_code: string | null;
143
+ date: string;
144
+ authorized_date: string | null;
145
+ name: string;
146
+ merchant_name: string | null;
147
+ pending: boolean;
148
+ category: string[] | null;
149
+ personal_finance_category: {
150
+ primary: string;
151
+ detailed: string;
152
+ } | null;
153
+ }
154
+
155
+ export class PlaidManagedClient {
156
+ constructor(
157
+ private readonly configSource: ConfigSource =
158
+ resolveEnvElizaCloudManagedClientConfig,
159
+ ) {}
160
+
161
+ private requireConfig(): ElizaCloudManagedClientConfig & { apiKey: string } {
162
+ const config = this.configSource();
163
+ if (!config.apiKey) {
164
+ throw new PlaidManagedClientError(409, "Eliza Cloud is not connected.");
165
+ }
166
+ return { ...config, apiKey: config.apiKey };
167
+ }
168
+
169
+ get configured(): boolean {
170
+ return this.configSource().configured;
171
+ }
172
+
173
+ async createLinkToken(): Promise<PlaidLinkTokenResponse> {
174
+ const config = this.requireConfig();
175
+ const response = await fetch(
176
+ `${config.apiBaseUrl}/v1/eliza/plaid/link-token`,
177
+ {
178
+ method: "POST",
179
+ headers: {
180
+ Authorization: `Bearer ${config.apiKey}`,
181
+ "Content-Type": "application/json",
182
+ },
183
+ body: "{}",
184
+ signal: AbortSignal.timeout(PLAID_REQUEST_TIMEOUT_MS),
185
+ },
186
+ );
187
+ return readPlaidJson<PlaidLinkTokenResponse>(response);
188
+ }
189
+
190
+ async exchangePublicToken(args: {
191
+ publicToken: string;
192
+ }): Promise<PlaidExchangeResponse> {
193
+ const config = this.requireConfig();
194
+ const response = await fetch(
195
+ `${config.apiBaseUrl}/v1/eliza/plaid/exchange`,
196
+ {
197
+ method: "POST",
198
+ headers: {
199
+ Authorization: `Bearer ${config.apiKey}`,
200
+ "Content-Type": "application/json",
201
+ },
202
+ body: JSON.stringify({ publicToken: args.publicToken }),
203
+ signal: AbortSignal.timeout(PLAID_REQUEST_TIMEOUT_MS),
204
+ },
205
+ );
206
+ return readPlaidJson<PlaidExchangeResponse>(response);
207
+ }
208
+
209
+ async syncTransactions(args: {
210
+ accessToken: string;
211
+ cursor?: string;
212
+ count?: number;
213
+ }): Promise<PlaidSyncResponse> {
214
+ const config = this.requireConfig();
215
+ const response = await fetch(`${config.apiBaseUrl}/v1/eliza/plaid/sync`, {
216
+ method: "POST",
217
+ headers: {
218
+ Authorization: `Bearer ${config.apiKey}`,
219
+ "Content-Type": "application/json",
220
+ },
221
+ body: JSON.stringify({
222
+ accessToken: args.accessToken,
223
+ cursor: args.cursor ?? "",
224
+ count: args.count ?? 250,
225
+ }),
226
+ signal: AbortSignal.timeout(PLAID_REQUEST_TIMEOUT_MS * 2),
227
+ });
228
+ return readPlaidJson<PlaidSyncResponse>(response);
229
+ }
230
+ }
231
+
232
+ export interface PaypalAuthorizeUrlResponse {
233
+ url: string;
234
+ scope: string;
235
+ environment: "live" | "sandbox";
236
+ }
237
+
238
+ export interface PaypalCallbackResponse {
239
+ accessToken: string;
240
+ refreshToken: string | null;
241
+ expiresIn: number;
242
+ scope: string;
243
+ capability: { hasReporting: boolean; hasIdentity: boolean };
244
+ identity: { payerId: string; emails: string[]; name: string | null } | null;
245
+ }
246
+
247
+ export interface PaypalTransactionDto {
248
+ transaction_info: {
249
+ transaction_id: string;
250
+ transaction_initiation_date: string;
251
+ transaction_updated_date: string | null;
252
+ transaction_amount: { currency_code: string; value: string };
253
+ transaction_status: string;
254
+ transaction_subject: string | null;
255
+ transaction_note: string | null;
256
+ };
257
+ payer_info?: {
258
+ email_address?: string;
259
+ payer_name?: { alternate_full_name?: string };
260
+ };
261
+ shipping_info?: { name?: string };
262
+ cart_info?: {
263
+ item_details?: Array<{
264
+ item_name?: string;
265
+ item_amount?: { currency_code: string; value: string };
266
+ }>;
267
+ };
268
+ }
269
+
270
+ export interface PaypalTransactionsResponse {
271
+ transactions: PaypalTransactionDto[];
272
+ totalItems: number;
273
+ totalPages: number;
274
+ page: number;
275
+ }
276
+
277
+ export class PaypalManagedClient {
278
+ constructor(
279
+ private readonly configSource: ConfigSource =
280
+ resolveEnvElizaCloudManagedClientConfig,
281
+ ) {}
282
+
283
+ private requireConfig(): ElizaCloudManagedClientConfig & { apiKey: string } {
284
+ const config = this.configSource();
285
+ if (!config.apiKey) {
286
+ throw new PaypalManagedClientError(409, "Eliza Cloud is not connected.");
287
+ }
288
+ return { ...config, apiKey: config.apiKey };
289
+ }
290
+
291
+ get configured(): boolean {
292
+ return this.configSource().configured;
293
+ }
294
+
295
+ async buildAuthorizeUrl(args: {
296
+ state: string;
297
+ }): Promise<PaypalAuthorizeUrlResponse> {
298
+ const config = this.requireConfig();
299
+ const response = await fetch(
300
+ `${config.apiBaseUrl}/v1/eliza/paypal/authorize`,
301
+ {
302
+ method: "POST",
303
+ headers: {
304
+ Authorization: `Bearer ${config.apiKey}`,
305
+ "Content-Type": "application/json",
306
+ },
307
+ body: JSON.stringify({ state: args.state }),
308
+ signal: AbortSignal.timeout(PAYPAL_REQUEST_TIMEOUT_MS),
309
+ },
310
+ );
311
+ return readPaypalJson<PaypalAuthorizeUrlResponse>(response);
312
+ }
313
+
314
+ async exchangeCode(args: { code: string }): Promise<PaypalCallbackResponse> {
315
+ const config = this.requireConfig();
316
+ const response = await fetch(
317
+ `${config.apiBaseUrl}/v1/eliza/paypal/callback`,
318
+ {
319
+ method: "POST",
320
+ headers: {
321
+ Authorization: `Bearer ${config.apiKey}`,
322
+ "Content-Type": "application/json",
323
+ },
324
+ body: JSON.stringify({ code: args.code }),
325
+ signal: AbortSignal.timeout(PAYPAL_REQUEST_TIMEOUT_MS),
326
+ },
327
+ );
328
+ return readPaypalJson<PaypalCallbackResponse>(response);
329
+ }
330
+
331
+ async refreshAccessToken(args: { refreshToken: string }): Promise<{
332
+ accessToken: string;
333
+ refreshToken: string | null;
334
+ expiresIn: number;
335
+ scope: string;
336
+ }> {
337
+ const config = this.requireConfig();
338
+ const response = await fetch(
339
+ `${config.apiBaseUrl}/v1/eliza/paypal/refresh`,
340
+ {
341
+ method: "POST",
342
+ headers: {
343
+ Authorization: `Bearer ${config.apiKey}`,
344
+ "Content-Type": "application/json",
345
+ },
346
+ body: JSON.stringify({ refreshToken: args.refreshToken }),
347
+ signal: AbortSignal.timeout(PAYPAL_REQUEST_TIMEOUT_MS),
348
+ },
349
+ );
350
+ return readPaypalJson(response);
351
+ }
352
+
353
+ async searchTransactions(args: {
354
+ accessToken: string;
355
+ startDate: string;
356
+ endDate: string;
357
+ page?: number;
358
+ }): Promise<PaypalTransactionsResponse> {
359
+ const config = this.requireConfig();
360
+ const response = await fetch(
361
+ `${config.apiBaseUrl}/v1/eliza/paypal/transactions`,
362
+ {
363
+ method: "POST",
364
+ headers: {
365
+ Authorization: `Bearer ${config.apiKey}`,
366
+ "Content-Type": "application/json",
367
+ },
368
+ body: JSON.stringify(args),
369
+ signal: AbortSignal.timeout(PAYPAL_REQUEST_TIMEOUT_MS * 2),
370
+ },
371
+ );
372
+ return readPaypalJson<PaypalTransactionsResponse>(response);
373
+ }
374
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Silent `CloudSetupObserver` for tests and headless runs.
3
+ *
4
+ * - All event methods intentionally ignore their inputs.
5
+ * - All prompt methods resolve to `null` (i.e. "user cancelled"), which
6
+ * lets the orchestrator exercise its cancel branches without surfacing
7
+ * any UI.
8
+ *
9
+ * Tests that want to assert observer calls should use a capturing
10
+ * observer instead.
11
+ *
12
+ * @module cloud/null-observer
13
+ */
14
+ import type {
15
+ CloudSetupObserver,
16
+ ConfirmPrompt,
17
+ ProvisionSuccessInfo,
18
+ SelectChoicePrompt,
19
+ } from "./setup-observer.js";
20
+
21
+ export class NullCloudSetupObserver implements CloudSetupObserver {
22
+ onAvailabilityChecked(_result: { ok: boolean; reason?: string }): void {}
23
+ onAuthStart(_loginUrl: string): void {}
24
+ onAuthBrowserOpenFailed(_loginUrl: string, _error: Error): void {}
25
+ onAuthPollStatus(_status: string): void {}
26
+ onAuthSuccess(): void {}
27
+ onAuthFailure(_message: string): void {}
28
+ onProvisionStart(_agentName: string): void {}
29
+ onProvisionStatus(_status: string): void {}
30
+ onProvisionTimeout(_agentId: string, _lastStatus: string): void {}
31
+ onProvisionFailure(_reason: string): void {}
32
+ onProvisionSuccess(_result: ProvisionSuccessInfo): void {}
33
+ onNotice(_message: string): void {}
34
+ onFatalError(_error: Error, _context: string): void {}
35
+
36
+ async confirm(_prompt: ConfirmPrompt): Promise<boolean | null> {
37
+ return null;
38
+ }
39
+
40
+ async selectChoice<T extends string>(
41
+ _prompt: SelectChoicePrompt<T>,
42
+ ): Promise<T | null> {
43
+ return null;
44
+ }
45
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Transport-agnostic observer for the cloud setup orchestrator.
3
+ *
4
+ * `runCloudSetup` calls into this interface for every user-visible
5
+ * event and every interactive prompt. CLI provides a `@clack/prompts`-
6
+ * backed implementation; web/desktop provides an event-bridge
7
+ * implementation; tests provide a capturing observer.
8
+ *
9
+ * The orchestrator MUST stay free of any presentation-layer concerns
10
+ * (spinners, terminal output, GUI events). It only knows about the
11
+ * methods defined here.
12
+ *
13
+ * @module cloud/setup-observer
14
+ */
15
+ import type { ProvisionInfo } from "./bridge-client.js";
16
+
17
+ // ---------------------------------------------------------------------------
18
+ // Events
19
+ // ---------------------------------------------------------------------------
20
+
21
+ export interface AvailabilityResult {
22
+ ok: boolean;
23
+ /** Human-readable reason when `ok` is false. */
24
+ reason?: string;
25
+ }
26
+
27
+ export interface ProvisionSuccessInfo {
28
+ agentId: string;
29
+ bridgeUrl?: string;
30
+ }
31
+
32
+ // ---------------------------------------------------------------------------
33
+ // Prompts
34
+ // ---------------------------------------------------------------------------
35
+
36
+ export interface ConfirmPrompt {
37
+ message: string;
38
+ /** Optional override for the default value when the user just presses enter. */
39
+ defaultValue?: boolean;
40
+ /** Optional label for the "true" branch. CLI surfaces use this on a toggle. */
41
+ activeLabel?: string;
42
+ /** Optional label for the "false" branch. CLI surfaces use this on a toggle. */
43
+ inactiveLabel?: string;
44
+ }
45
+
46
+ export interface SelectChoiceOption<T extends string> {
47
+ label: string;
48
+ value: T;
49
+ hint?: string;
50
+ }
51
+
52
+ export interface SelectChoicePrompt<T extends string> {
53
+ message: string;
54
+ options: SelectChoiceOption<T>[];
55
+ }
56
+
57
+ // ---------------------------------------------------------------------------
58
+ // Observer
59
+ // ---------------------------------------------------------------------------
60
+
61
+ /**
62
+ * Sink for every event the cloud setup orchestrator surfaces, plus the
63
+ * interactive prompts it needs to resolve.
64
+ *
65
+ * Implementation contract:
66
+ *
67
+ * - Event methods are fire-and-forget; they MUST NOT throw. Implementations
68
+ * that fail to render an event are responsible for their own logging.
69
+ * - Prompt methods are async. A `null` return from `selectChoice` or a
70
+ * cancellation from `confirm` is interpreted by the orchestrator as
71
+ * "user cancelled" — the orchestrator decides what that means for the
72
+ * flow. The observer MUST NOT exit the process or throw on cancel.
73
+ */
74
+ export interface CloudSetupObserver {
75
+ // ── Events ──────────────────────────────────────────────────────────────
76
+ onAvailabilityChecked(result: AvailabilityResult): void;
77
+
78
+ onAuthStart(loginUrl: string): void;
79
+ /**
80
+ * The orchestrator could not spawn the OS browser (no `open` / `xdg-open`
81
+ * / `cmd.exe` on PATH, etc.). The login URL is unchanged — the observer
82
+ * can render an inline "visit this URL manually" affordance, retry, or
83
+ * surface the error however it wants. This was previously swallowed
84
+ * silently behind a debug log.
85
+ */
86
+ onAuthBrowserOpenFailed(loginUrl: string, error: Error): void;
87
+ onAuthPollStatus(status: string): void;
88
+ onAuthSuccess(): void;
89
+ onAuthFailure(message: string): void;
90
+
91
+ onProvisionStart(agentName: string): void;
92
+ onProvisionStatus(status: string, current?: ProvisionInfo): void;
93
+ onProvisionTimeout(agentId: string, lastStatus: string): void;
94
+ onProvisionFailure(reason: string): void;
95
+ onProvisionSuccess(result: ProvisionSuccessInfo): void;
96
+
97
+ /**
98
+ * A categorized user-facing message that doesn't map onto a specific
99
+ * lifecycle event — e.g. "Cloud login was not completed", "Cloud agent
100
+ * is still starting up. You can try `eliza cloud connect` once it's
101
+ * ready." The CLI implementation renders these as `log.warn`.
102
+ */
103
+ onNotice(message: string): void;
104
+
105
+ /**
106
+ * An unexpected, non-flow-control error. The orchestrator does not
107
+ * itself swallow errors — it surfaces them here and lets the observer
108
+ * decide whether to retry, fall back, or rethrow.
109
+ */
110
+ onFatalError(error: Error, context: string): void;
111
+
112
+ // ── Prompts ─────────────────────────────────────────────────────────────
113
+ /**
114
+ * Resolve to `true` / `false` for a yes/no decision, or `null` when the
115
+ * user explicitly cancels (e.g. Ctrl-C on CLI, modal dismiss on GUI).
116
+ */
117
+ confirm(prompt: ConfirmPrompt): Promise<boolean | null>;
118
+
119
+ /**
120
+ * Resolve to the chosen value, or `null` on cancel.
121
+ */
122
+ selectChoice<T extends string>(
123
+ prompt: SelectChoicePrompt<T>,
124
+ ): Promise<T | null>;
125
+ }
@@ -150,7 +150,13 @@ export async function validateCloudBaseUrl(
150
150
  }
151
151
 
152
152
  // Dev-mode bypass: skip IP-range blocking but keep URL format checks above.
153
- if (process.env.NODE_ENV === "development" || process.env.ELIZA_DEV) {
153
+ const elizaDev = process.env.ELIZA_DEV?.trim().toLowerCase();
154
+ if (
155
+ process.env.NODE_ENV === "development" ||
156
+ elizaDev === "1" ||
157
+ elizaDev === "true" ||
158
+ elizaDev === "yes"
159
+ ) {
154
160
  return null;
155
161
  }
156
162