@railbeam/stardorm-api-contract 0.0.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/dist/index.d.mts +5504 -0
- package/dist/index.d.ts +5504 -0
- package/dist/index.js +983 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +888 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -0
- package/src/agent-feedbacks.ts +58 -0
- package/src/agent.ts +58 -0
- package/src/auth.ts +29 -0
- package/src/billing-handlers.ts +92 -0
- package/src/catalog-build.ts +31 -0
- package/src/catalog-marketplace-response.ts +53 -0
- package/src/catalog.ts +11 -0
- package/src/chat-api.ts +139 -0
- package/src/conversation.ts +132 -0
- package/src/credit-card.ts +150 -0
- package/src/handlers.ts +40 -0
- package/src/index.ts +192 -0
- package/src/iso-3166-1-alpha2.ts +30 -0
- package/src/kyc.ts +34 -0
- package/src/on-ramp.ts +103 -0
- package/src/payment-request.ts +87 -0
- package/src/storage.ts +13 -0
- package/src/tax-rate-for-country.ts +50 -0
- package/src/transfer-drafts.ts +91 -0
- package/src/user.ts +70 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +10 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,983 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/agent.ts
|
|
6
|
+
var agentCategorySchema = zod.z.enum([
|
|
7
|
+
"Payments",
|
|
8
|
+
"Taxes",
|
|
9
|
+
"Reports",
|
|
10
|
+
"DeFi",
|
|
11
|
+
"Compliance",
|
|
12
|
+
"General"
|
|
13
|
+
]);
|
|
14
|
+
var skillHandleSchema = zod.z.object({
|
|
15
|
+
handle: zod.z.string().min(1),
|
|
16
|
+
label: zod.z.string().min(1)
|
|
17
|
+
});
|
|
18
|
+
var agentAvatarSchema = zod.z.union([
|
|
19
|
+
zod.z.string().url(),
|
|
20
|
+
zod.z.string().regex(/^\/\S+/, "avatar must be a URL or a root-relative path")
|
|
21
|
+
]);
|
|
22
|
+
var agentSchema = zod.z.object({
|
|
23
|
+
id: zod.z.string().min(1),
|
|
24
|
+
name: zod.z.string().min(1),
|
|
25
|
+
handle: zod.z.string().min(1),
|
|
26
|
+
avatar: agentAvatarSchema,
|
|
27
|
+
category: agentCategorySchema,
|
|
28
|
+
tagline: zod.z.string(),
|
|
29
|
+
description: zod.z.string(),
|
|
30
|
+
/** From on-chain feedback / analytics when wired; omit if unknown. */
|
|
31
|
+
rating: zod.z.number().min(0).max(5).optional(),
|
|
32
|
+
reviews: zod.z.number().int().nonnegative().optional(),
|
|
33
|
+
hires: zod.z.number().int().nonnegative().optional(),
|
|
34
|
+
reputation: zod.z.number().min(0).max(100).optional(),
|
|
35
|
+
/** Estimated from indexer `feePerDay` (wei) when available; omit if unknown. */
|
|
36
|
+
pricePerMonth: zod.z.number().nonnegative().optional(),
|
|
37
|
+
/** Raw `feePerDay` (wei, decimal string) from the subgraph. `subscribe` must send exactly `feePerDay * numDays` wei. */
|
|
38
|
+
feePerDayWei: zod.z.string().regex(/^\d+$/).optional(),
|
|
39
|
+
/** Presence-only when we have a live signal; omit if unknown. */
|
|
40
|
+
online: zod.z.boolean().optional(),
|
|
41
|
+
skills: zod.z.array(zod.z.string()),
|
|
42
|
+
creator: zod.z.string().min(1),
|
|
43
|
+
skillHandles: zod.z.array(skillHandleSchema).optional(),
|
|
44
|
+
chainAgentId: zod.z.number().int().positive().optional(),
|
|
45
|
+
/** From indexer when the token is an ERC-7857 clone of another agent. */
|
|
46
|
+
isCloned: zod.z.boolean().optional(),
|
|
47
|
+
/** Lowercase `0x` registry owner (subgraph); used for “my clone” ownership checks. */
|
|
48
|
+
ownerAddress: zod.z.string().regex(/^0x[a-f0-9]{40}$/).optional(),
|
|
49
|
+
/** Raw on-chain registration string (hex or JSON) for owner-only URI updates. */
|
|
50
|
+
registrationUriRaw: zod.z.string().optional()
|
|
51
|
+
});
|
|
52
|
+
var agentsListSchema = zod.z.array(agentSchema).nonempty();
|
|
53
|
+
var catalogResponseSchema = zod.z.object({
|
|
54
|
+
agents: agentsListSchema,
|
|
55
|
+
categories: zod.z.array(agentCategorySchema),
|
|
56
|
+
defaultHiredIds: zod.z.array(zod.z.string().min(1)),
|
|
57
|
+
chatSuggestions: zod.z.array(zod.z.string())
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// src/catalog-marketplace-response.ts
|
|
61
|
+
var CHAT_SUGGESTIONS = [
|
|
62
|
+
"Summarize last month\u2019s onchain P&L",
|
|
63
|
+
"Draft an invoice for Acme Labs",
|
|
64
|
+
"What are the best stablecoin yields right now?",
|
|
65
|
+
"Estimate my crypto tax exposure for Q3",
|
|
66
|
+
"Create an x402 checkout link I can send to a payer",
|
|
67
|
+
"Help me buy stablecoins on 0G with a card",
|
|
68
|
+
"Start identity verification for my account",
|
|
69
|
+
"Create a virtual payment card with my billing address"
|
|
70
|
+
];
|
|
71
|
+
var DEFAULT_HIRED_IDS = ["beam-default"];
|
|
72
|
+
var ALL_CATEGORIES = [
|
|
73
|
+
"Payments",
|
|
74
|
+
"Taxes",
|
|
75
|
+
"Reports",
|
|
76
|
+
"DeFi",
|
|
77
|
+
"Compliance",
|
|
78
|
+
"General"
|
|
79
|
+
];
|
|
80
|
+
var BEAM_DEFAULT_AGENT = {
|
|
81
|
+
id: "beam-default",
|
|
82
|
+
name: "Beam",
|
|
83
|
+
handle: "beam.0g",
|
|
84
|
+
avatar: "/images/beam.png",
|
|
85
|
+
category: "General",
|
|
86
|
+
tagline: "Your default conversational agent",
|
|
87
|
+
description: "Beam routes your prompts to the best hired agent and handles general financial questions.",
|
|
88
|
+
skills: ["Routing", "General Q&A", "Wallet"],
|
|
89
|
+
creator: "Beam",
|
|
90
|
+
chainAgentId: 1
|
|
91
|
+
};
|
|
92
|
+
function buildStardormCatalogResponse() {
|
|
93
|
+
return catalogResponseSchema.parse({
|
|
94
|
+
agents: [BEAM_DEFAULT_AGENT],
|
|
95
|
+
categories: [...ALL_CATEGORIES],
|
|
96
|
+
defaultHiredIds: [...DEFAULT_HIRED_IDS],
|
|
97
|
+
chatSuggestions: [...CHAT_SUGGESTIONS]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/catalog-build.ts
|
|
102
|
+
function resolveStardormChainAgentId(agentKey) {
|
|
103
|
+
const trimmed = agentKey.trim();
|
|
104
|
+
if (/^\d+$/.test(trimmed)) {
|
|
105
|
+
const n = Number.parseInt(trimmed, 10);
|
|
106
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
107
|
+
}
|
|
108
|
+
if (/^beam-default$/i.test(trimmed)) return 1;
|
|
109
|
+
const m = /^chain-(\d+)$/i.exec(trimmed);
|
|
110
|
+
if (m) {
|
|
111
|
+
const n = Number.parseInt(m[1], 10);
|
|
112
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
function resolveStardormAgentKey(chainAgentId) {
|
|
117
|
+
const n = typeof chainAgentId === "string" ? Number.parseInt(chainAgentId, 10) : Number(chainAgentId);
|
|
118
|
+
if (!Number.isFinite(n) || n <= 0) return null;
|
|
119
|
+
if (n === 1) return "beam-default";
|
|
120
|
+
return `chain-${n}`;
|
|
121
|
+
}
|
|
122
|
+
var authChallengeBodySchema = zod.z.object({
|
|
123
|
+
walletAddress: zod.z.string().min(1)
|
|
124
|
+
});
|
|
125
|
+
var authChallengeResponseSchema = zod.z.object({
|
|
126
|
+
message: zod.z.string().min(1)
|
|
127
|
+
});
|
|
128
|
+
var authVerifyBodySchema = zod.z.object({
|
|
129
|
+
walletAddress: zod.z.string().min(1),
|
|
130
|
+
message: zod.z.string().min(1),
|
|
131
|
+
signature: zod.z.string().min(1)
|
|
132
|
+
});
|
|
133
|
+
var authVerifyResponseSchema = zod.z.object({
|
|
134
|
+
accessToken: zod.z.string().min(1)
|
|
135
|
+
});
|
|
136
|
+
var authMeResponseSchema = zod.z.object({
|
|
137
|
+
walletAddress: zod.z.string().min(1)
|
|
138
|
+
});
|
|
139
|
+
var HANDLER_ACTION_IDS = [
|
|
140
|
+
"generate_tax_report",
|
|
141
|
+
"create_x402_payment",
|
|
142
|
+
/** Fiat checkout via Stripe; webhook fulfills ERC-20 transfer from treasury key. */
|
|
143
|
+
"on_ramp_tokens",
|
|
144
|
+
/** Stripe Identity hosted verification for the signed-in wallet user. */
|
|
145
|
+
"complete_stripe_kyc",
|
|
146
|
+
/** Issue a virtual payment card record with billing profile and spend balance. */
|
|
147
|
+
"create_credit_card",
|
|
148
|
+
/** PDF + structured snapshot: payment requests, on-ramps, cards, KYC for this wallet. */
|
|
149
|
+
"generate_payment_invoice",
|
|
150
|
+
/** Summary report across payment requests, on-ramps, virtual cards, and KYC status. */
|
|
151
|
+
"generate_financial_activity_report",
|
|
152
|
+
/** Confirms a native (gas token) transfer draft; user signs in their wallet / Beam Send. */
|
|
153
|
+
"draft_native_transfer",
|
|
154
|
+
/** Confirms an ERC-20 transfer draft; user signs in their wallet / Beam Send. */
|
|
155
|
+
"draft_erc20_transfer",
|
|
156
|
+
/** Confirms an NFT (ERC-721 / ERC-1155) transfer draft; user signs in their wallet / Beam Send. */
|
|
157
|
+
"draft_nft_transfer"
|
|
158
|
+
];
|
|
159
|
+
function isHandlerActionId(id) {
|
|
160
|
+
return HANDLER_ACTION_IDS.includes(id);
|
|
161
|
+
}
|
|
162
|
+
var handlerActionIdSchema = zod.z.enum(HANDLER_ACTION_IDS);
|
|
163
|
+
var handlersListResponseSchema = zod.z.object({
|
|
164
|
+
handlers: zod.z.array(handlerActionIdSchema)
|
|
165
|
+
});
|
|
166
|
+
var storageUploadBodySchema = zod.z.object({
|
|
167
|
+
content: zod.z.string().min(1)
|
|
168
|
+
});
|
|
169
|
+
var storageUploadResponseSchema = zod.z.object({
|
|
170
|
+
rootHash: zod.z.string().min(1),
|
|
171
|
+
txHash: zod.z.string().optional()
|
|
172
|
+
});
|
|
173
|
+
var stardormChatRichRowSchema = zod.z.object({
|
|
174
|
+
label: zod.z.string(),
|
|
175
|
+
value: zod.z.string()
|
|
176
|
+
});
|
|
177
|
+
var x402SupportedAssetSchema = zod.z.object({
|
|
178
|
+
name: zod.z.string().min(1).max(64),
|
|
179
|
+
symbol: zod.z.string().min(1).max(32),
|
|
180
|
+
icon: zod.z.string().min(1).max(512),
|
|
181
|
+
decimals: zod.z.number().int().min(0).max(36),
|
|
182
|
+
address: zod.z.string().min(1).max(66),
|
|
183
|
+
usdValue: zod.z.number().finite().nonnegative().optional()
|
|
184
|
+
});
|
|
185
|
+
var stardormChatRichRows = zod.z.array(stardormChatRichRowSchema).max(32).optional();
|
|
186
|
+
var stardormChatRichBlockSchema = zod.z.discriminatedUnion("type", [
|
|
187
|
+
zod.z.object({
|
|
188
|
+
type: zod.z.literal("report"),
|
|
189
|
+
title: zod.z.string().min(1),
|
|
190
|
+
rows: stardormChatRichRows
|
|
191
|
+
}),
|
|
192
|
+
zod.z.object({
|
|
193
|
+
type: zod.z.literal("invoice"),
|
|
194
|
+
title: zod.z.string().min(1),
|
|
195
|
+
rows: stardormChatRichRows
|
|
196
|
+
}),
|
|
197
|
+
zod.z.object({
|
|
198
|
+
type: zod.z.literal("tx"),
|
|
199
|
+
title: zod.z.string().min(1),
|
|
200
|
+
rows: stardormChatRichRows
|
|
201
|
+
}),
|
|
202
|
+
zod.z.object({
|
|
203
|
+
type: zod.z.literal("x402_checkout_form"),
|
|
204
|
+
title: zod.z.string().min(1).max(200),
|
|
205
|
+
intro: zod.z.string().max(2e3).optional(),
|
|
206
|
+
/** Paywalled HTTP resource URL for x402 clients (optional). */
|
|
207
|
+
resourceUrl: zod.z.string().url().max(2048).optional(),
|
|
208
|
+
supportedAssets: zod.z.array(x402SupportedAssetSchema).min(1).max(24),
|
|
209
|
+
networks: zod.z.array(
|
|
210
|
+
zod.z.object({
|
|
211
|
+
id: zod.z.string().min(1).max(64),
|
|
212
|
+
label: zod.z.string().min(1).max(120)
|
|
213
|
+
})
|
|
214
|
+
).max(16).optional()
|
|
215
|
+
}),
|
|
216
|
+
zod.z.object({
|
|
217
|
+
type: zod.z.literal("on_ramp_checkout_form"),
|
|
218
|
+
title: zod.z.string().min(1).max(200),
|
|
219
|
+
intro: zod.z.string().max(2e3).optional(),
|
|
220
|
+
supportedAssets: zod.z.array(x402SupportedAssetSchema).min(1).max(24),
|
|
221
|
+
networks: zod.z.array(
|
|
222
|
+
zod.z.object({
|
|
223
|
+
id: zod.z.string().min(1).max(64),
|
|
224
|
+
label: zod.z.string().min(1).max(120)
|
|
225
|
+
})
|
|
226
|
+
).max(16).optional()
|
|
227
|
+
}),
|
|
228
|
+
zod.z.object({
|
|
229
|
+
type: zod.z.literal("credit_card_checkout_form"),
|
|
230
|
+
title: zod.z.string().min(1).max(200),
|
|
231
|
+
intro: zod.z.string().max(2e3).optional(),
|
|
232
|
+
/** Pre-filled ISO 4217 currency in the form (e.g. USD). */
|
|
233
|
+
defaultCurrency: zod.z.string().length(3).optional()
|
|
234
|
+
}),
|
|
235
|
+
zod.z.object({
|
|
236
|
+
type: zod.z.literal("credit_card"),
|
|
237
|
+
title: zod.z.string().min(1),
|
|
238
|
+
rows: stardormChatRichRows
|
|
239
|
+
})
|
|
240
|
+
]);
|
|
241
|
+
var stardormChatJsonBodySchema = zod.z.object({
|
|
242
|
+
message: zod.z.string().min(1)
|
|
243
|
+
});
|
|
244
|
+
var stardormChatStructuredSchema = zod.z.object({
|
|
245
|
+
text: zod.z.string(),
|
|
246
|
+
handler: handlerActionIdSchema.optional(),
|
|
247
|
+
params: zod.z.unknown().optional()
|
|
248
|
+
});
|
|
249
|
+
var stardormChatComputeSchema = zod.z.object({
|
|
250
|
+
model: zod.z.string(),
|
|
251
|
+
verified: zod.z.boolean(),
|
|
252
|
+
chatId: zod.z.string().optional(),
|
|
253
|
+
provider: zod.z.string(),
|
|
254
|
+
computeNetwork: zod.z.string()
|
|
255
|
+
});
|
|
256
|
+
var stardormChatAttachmentSchema = zod.z.object({
|
|
257
|
+
id: zod.z.string().min(1),
|
|
258
|
+
name: zod.z.string(),
|
|
259
|
+
mimeType: zod.z.string(),
|
|
260
|
+
hash: zod.z.string().min(1),
|
|
261
|
+
size: zod.z.string().optional()
|
|
262
|
+
});
|
|
263
|
+
var stardormChatSuccessSchema = zod.z.object({
|
|
264
|
+
agentKey: zod.z.string().min(1),
|
|
265
|
+
reply: zod.z.string(),
|
|
266
|
+
structured: stardormChatStructuredSchema.optional(),
|
|
267
|
+
/** Structured card rows for the client (model or server-generated). */
|
|
268
|
+
rich: stardormChatRichBlockSchema.optional(),
|
|
269
|
+
/** Files the server uploaded to 0G Storage from the user's chat turn (echoed for immediate render). */
|
|
270
|
+
attachments: zod.z.array(stardormChatAttachmentSchema).optional(),
|
|
271
|
+
compute: stardormChatComputeSchema
|
|
272
|
+
});
|
|
273
|
+
var stardormChatClientErrorSchema = zod.z.object({
|
|
274
|
+
error: zod.z.string().min(1)
|
|
275
|
+
});
|
|
276
|
+
var stardormChatClientResultSchema = zod.z.union([
|
|
277
|
+
stardormChatSuccessSchema,
|
|
278
|
+
stardormChatClientErrorSchema
|
|
279
|
+
]);
|
|
280
|
+
|
|
281
|
+
// src/user.ts
|
|
282
|
+
var userAvatarPresetSchema = zod.z.enum(["male", "female"]);
|
|
283
|
+
var userPreferencesSchema = zod.z.object({
|
|
284
|
+
autoRoutePrompts: zod.z.boolean(),
|
|
285
|
+
onchainReceipts: zod.z.boolean(),
|
|
286
|
+
emailNotifications: zod.z.boolean(),
|
|
287
|
+
avatarPreset: userAvatarPresetSchema.default("male")
|
|
288
|
+
});
|
|
289
|
+
var publicUserSchema = zod.z.object({
|
|
290
|
+
id: zod.z.string().min(1),
|
|
291
|
+
walletAddress: zod.z.string().min(1),
|
|
292
|
+
displayName: zod.z.string().optional(),
|
|
293
|
+
email: zod.z.string().optional(),
|
|
294
|
+
activeAgentId: zod.z.string().min(1),
|
|
295
|
+
/** Selected chat thread id when multi-conversation is enabled. */
|
|
296
|
+
activeConversationId: zod.z.string().min(1).optional(),
|
|
297
|
+
preferences: userPreferencesSchema,
|
|
298
|
+
lastLoginAt: zod.z.coerce.date().optional(),
|
|
299
|
+
createdAt: zod.z.coerce.date().optional(),
|
|
300
|
+
updatedAt: zod.z.coerce.date().optional()
|
|
301
|
+
});
|
|
302
|
+
var updateUserBodySchema = zod.z.object({
|
|
303
|
+
displayName: zod.z.string().optional(),
|
|
304
|
+
email: zod.z.string().nullable().optional(),
|
|
305
|
+
activeAgentId: zod.z.string().optional(),
|
|
306
|
+
activeConversationId: zod.z.string().nullable().optional(),
|
|
307
|
+
preferences: userPreferencesSchema.partial().optional()
|
|
308
|
+
});
|
|
309
|
+
var userUploadResultSchema = zod.z.object({
|
|
310
|
+
rootHash: zod.z.string().min(1),
|
|
311
|
+
txHash: zod.z.string().optional(),
|
|
312
|
+
originalName: zod.z.string(),
|
|
313
|
+
mimeType: zod.z.string(),
|
|
314
|
+
size: zod.z.number().int().nonnegative()
|
|
315
|
+
});
|
|
316
|
+
var executeHandlerBodySchema = zod.z.object({
|
|
317
|
+
handler: handlerActionIdSchema,
|
|
318
|
+
params: zod.z.unknown().optional(),
|
|
319
|
+
/** Mongo id of the chat message that displayed the handler CTA (required). */
|
|
320
|
+
ctaMessageId: zod.z.string().min(1)
|
|
321
|
+
});
|
|
322
|
+
var handlerAttachmentSchema = zod.z.object({
|
|
323
|
+
rootHash: zod.z.string(),
|
|
324
|
+
mimeType: zod.z.string(),
|
|
325
|
+
name: zod.z.string()
|
|
326
|
+
});
|
|
327
|
+
var executeHandlerResponseSchema = zod.z.object({
|
|
328
|
+
message: zod.z.string(),
|
|
329
|
+
attachments: zod.z.array(handlerAttachmentSchema).optional(),
|
|
330
|
+
data: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
331
|
+
rich: stardormChatRichBlockSchema.optional()
|
|
332
|
+
});
|
|
333
|
+
var chatHistoryQuerySchema = zod.z.object({
|
|
334
|
+
limit: zod.z.coerce.number().int().min(1).max(100).default(40),
|
|
335
|
+
/** When omitted, the server uses the user’s active conversation. */
|
|
336
|
+
conversationId: zod.z.string().min(1).optional(),
|
|
337
|
+
/**
|
|
338
|
+
* Opaque cursor from the previous response’s `nextCursorOlder` — loads older messages
|
|
339
|
+
* than the oldest message in the last batch (prepends chronologically in the client).
|
|
340
|
+
*/
|
|
341
|
+
cursor: zod.z.string().min(1).optional()
|
|
342
|
+
});
|
|
343
|
+
var chatHistoryAttachmentSchema = zod.z.object({
|
|
344
|
+
id: zod.z.string(),
|
|
345
|
+
mimeType: zod.z.string(),
|
|
346
|
+
name: zod.z.string(),
|
|
347
|
+
hash: zod.z.string(),
|
|
348
|
+
size: zod.z.string().optional()
|
|
349
|
+
});
|
|
350
|
+
var chatHistoryHandlerCtaSchema = zod.z.object({
|
|
351
|
+
handler: handlerActionIdSchema,
|
|
352
|
+
params: zod.z.record(zod.z.unknown())
|
|
353
|
+
});
|
|
354
|
+
var chatFollowUpSchema = zod.z.discriminatedUnion("kind", [
|
|
355
|
+
zod.z.object({
|
|
356
|
+
kind: zod.z.literal("x402_checkout"),
|
|
357
|
+
/** App-relative path, e.g. `/pay/<mongoId>`. */
|
|
358
|
+
payPath: zod.z.string().min(1),
|
|
359
|
+
paymentRequestId: zod.z.string().min(1)
|
|
360
|
+
}),
|
|
361
|
+
zod.z.object({
|
|
362
|
+
kind: zod.z.literal("tax_report_pdf"),
|
|
363
|
+
attachmentId: zod.z.string().min(1),
|
|
364
|
+
name: zod.z.string().min(1)
|
|
365
|
+
}),
|
|
366
|
+
zod.z.object({
|
|
367
|
+
kind: zod.z.literal("stripe_on_ramp"),
|
|
368
|
+
checkoutUrl: zod.z.string().url(),
|
|
369
|
+
onRampId: zod.z.string().min(1)
|
|
370
|
+
}),
|
|
371
|
+
zod.z.object({
|
|
372
|
+
kind: zod.z.literal("stripe_identity"),
|
|
373
|
+
verificationUrl: zod.z.string().url(),
|
|
374
|
+
verificationSessionId: zod.z.string().min(1)
|
|
375
|
+
}),
|
|
376
|
+
zod.z.object({
|
|
377
|
+
kind: zod.z.literal("credit_card_ready"),
|
|
378
|
+
creditCardId: zod.z.string().min(1),
|
|
379
|
+
/** App path for managing the card balance (e.g. /dashboard). */
|
|
380
|
+
dashboardPath: zod.z.string().min(1)
|
|
381
|
+
})
|
|
382
|
+
]);
|
|
383
|
+
var chatHistoryMessageSchema = zod.z.object({
|
|
384
|
+
id: zod.z.string(),
|
|
385
|
+
role: zod.z.enum(["user", "agent"]),
|
|
386
|
+
agentKey: zod.z.string().optional(),
|
|
387
|
+
content: zod.z.string(),
|
|
388
|
+
createdAt: zod.z.number(),
|
|
389
|
+
attachments: zod.z.array(chatHistoryAttachmentSchema).optional(),
|
|
390
|
+
rich: stardormChatRichBlockSchema.optional(),
|
|
391
|
+
handlerCta: chatHistoryHandlerCtaSchema.optional(),
|
|
392
|
+
followUp: chatFollowUpSchema.optional(),
|
|
393
|
+
model: zod.z.string().optional(),
|
|
394
|
+
verified: zod.z.boolean().optional(),
|
|
395
|
+
chatId: zod.z.string().optional(),
|
|
396
|
+
provider: zod.z.string().optional()
|
|
397
|
+
});
|
|
398
|
+
var chatHistoryResponseSchema = zod.z.object({
|
|
399
|
+
conversationId: zod.z.string(),
|
|
400
|
+
agentKey: zod.z.string(),
|
|
401
|
+
messages: zod.z.array(chatHistoryMessageSchema),
|
|
402
|
+
/** True when more older messages exist before this batch. */
|
|
403
|
+
hasMoreOlder: zod.z.boolean(),
|
|
404
|
+
/** Pass as `cursor` on the next request to load older messages. */
|
|
405
|
+
nextCursorOlder: zod.z.string().optional()
|
|
406
|
+
});
|
|
407
|
+
var conversationSummarySchema = zod.z.object({
|
|
408
|
+
id: zod.z.string().min(1),
|
|
409
|
+
agentKey: zod.z.string().min(1),
|
|
410
|
+
title: zod.z.string().optional(),
|
|
411
|
+
lastMessageAt: zod.z.coerce.date(),
|
|
412
|
+
createdAt: zod.z.coerce.date().optional()
|
|
413
|
+
});
|
|
414
|
+
var conversationsQuerySchema = zod.z.object({
|
|
415
|
+
limit: zod.z.coerce.number().int().min(1).max(50).default(25),
|
|
416
|
+
/** Opaque cursor from the previous response’s `nextCursor`. */
|
|
417
|
+
cursor: zod.z.string().min(1).optional()
|
|
418
|
+
});
|
|
419
|
+
var conversationsPageResponseSchema = zod.z.object({
|
|
420
|
+
conversations: zod.z.array(conversationSummarySchema),
|
|
421
|
+
hasMore: zod.z.boolean(),
|
|
422
|
+
nextCursor: zod.z.string().optional()
|
|
423
|
+
});
|
|
424
|
+
var conversationsListResponseSchema = conversationsPageResponseSchema;
|
|
425
|
+
var createConversationBodySchema = zod.z.object({
|
|
426
|
+
title: zod.z.string().max(120).optional(),
|
|
427
|
+
agentKey: zod.z.string().min(1).optional()
|
|
428
|
+
});
|
|
429
|
+
var deleteConversationResponseSchema = zod.z.object({
|
|
430
|
+
deleted: zod.z.literal(true)
|
|
431
|
+
});
|
|
432
|
+
var agentOnchainFeedbackItemSchema = zod.z.object({
|
|
433
|
+
id: zod.z.string(),
|
|
434
|
+
agentId: zod.z.number(),
|
|
435
|
+
clientAddress: zod.z.string(),
|
|
436
|
+
feedbackIndex: zod.z.string(),
|
|
437
|
+
value: zod.z.string(),
|
|
438
|
+
valueDecimals: zod.z.number().int().min(0).max(18),
|
|
439
|
+
tag1: zod.z.string(),
|
|
440
|
+
tag2: zod.z.string(),
|
|
441
|
+
endpoint: zod.z.string(),
|
|
442
|
+
feedbackURI: zod.z.string(),
|
|
443
|
+
feedbackHash: zod.z.string(),
|
|
444
|
+
revoked: zod.z.boolean(),
|
|
445
|
+
blockNumber: zod.z.number(),
|
|
446
|
+
blockTimestamp: zod.z.number(),
|
|
447
|
+
transactionHash: zod.z.string()
|
|
448
|
+
});
|
|
449
|
+
var agentFeedbacksQuerySchema = zod.z.object({
|
|
450
|
+
limit: zod.z.union([zod.z.string(), zod.z.number()]).optional().transform((v) => {
|
|
451
|
+
if (v === void 0) return 20;
|
|
452
|
+
const n = typeof v === "string" ? Number.parseInt(v, 10) : v;
|
|
453
|
+
if (!Number.isFinite(n)) return 20;
|
|
454
|
+
return Math.min(50, Math.max(1, Math.trunc(n)));
|
|
455
|
+
}),
|
|
456
|
+
skip: zod.z.union([zod.z.string(), zod.z.number()]).optional().transform((v) => {
|
|
457
|
+
if (v === void 0) return 0;
|
|
458
|
+
const n = typeof v === "string" ? Number.parseInt(v, 10) : v;
|
|
459
|
+
if (!Number.isFinite(n)) return 0;
|
|
460
|
+
return Math.max(0, Math.trunc(n));
|
|
461
|
+
})
|
|
462
|
+
});
|
|
463
|
+
var agentFeedbacksPageResponseSchema = zod.z.object({
|
|
464
|
+
feedbacks: zod.z.array(agentOnchainFeedbackItemSchema),
|
|
465
|
+
page: zod.z.object({
|
|
466
|
+
limit: zod.z.number().int().min(1).max(50),
|
|
467
|
+
skip: zod.z.number().int().min(0),
|
|
468
|
+
hasMore: zod.z.boolean()
|
|
469
|
+
})
|
|
470
|
+
});
|
|
471
|
+
var evmTxHashSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{64}$/i, "Invalid transaction hash");
|
|
472
|
+
var evmAddressSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{40}$/i, "Invalid address");
|
|
473
|
+
var paymentSettlementBodySchema = zod.z.object({
|
|
474
|
+
txHash: evmTxHashSchema.optional(),
|
|
475
|
+
payerAddress: evmAddressSchema.optional(),
|
|
476
|
+
/** Matches @x402/core `PaymentPayload` (x402Version, accepted, payload, …). */
|
|
477
|
+
x402PaymentPayload: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
478
|
+
}).superRefine((val, ctx) => {
|
|
479
|
+
if (!val.txHash && !val.x402PaymentPayload) {
|
|
480
|
+
ctx.addIssue({
|
|
481
|
+
code: zod.z.ZodIssueCode.custom,
|
|
482
|
+
message: "Provide txHash (direct settlement) or x402PaymentPayload (facilitator).",
|
|
483
|
+
path: ["txHash"]
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
if (val.txHash && val.x402PaymentPayload) {
|
|
487
|
+
ctx.addIssue({
|
|
488
|
+
code: zod.z.ZodIssueCode.custom,
|
|
489
|
+
message: "Provide only one of txHash or x402PaymentPayload.",
|
|
490
|
+
path: ["txHash"]
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
var paymentRequestTypeSchema = zod.z.enum(["on-chain", "x402"]);
|
|
495
|
+
var paymentRequestStatusSchema = zod.z.enum([
|
|
496
|
+
"pending",
|
|
497
|
+
"paid",
|
|
498
|
+
"expired",
|
|
499
|
+
"cancelled"
|
|
500
|
+
]);
|
|
501
|
+
var publicPaymentRequestSchema = zod.z.object({
|
|
502
|
+
id: zod.z.string(),
|
|
503
|
+
type: paymentRequestTypeSchema,
|
|
504
|
+
status: paymentRequestStatusSchema,
|
|
505
|
+
title: zod.z.string(),
|
|
506
|
+
description: zod.z.string().optional(),
|
|
507
|
+
asset: zod.z.string(),
|
|
508
|
+
amount: zod.z.string(),
|
|
509
|
+
payTo: zod.z.string(),
|
|
510
|
+
network: zod.z.string(),
|
|
511
|
+
expiresAt: zod.z.string().optional(),
|
|
512
|
+
resourceId: zod.z.string().optional(),
|
|
513
|
+
resourceUrl: zod.z.string().max(2048).optional(),
|
|
514
|
+
decimals: zod.z.number().int().min(0).max(36).optional(),
|
|
515
|
+
x402Payload: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
516
|
+
attachment: stardormChatAttachmentSchema.optional(),
|
|
517
|
+
/** Set when status is `paid` (on-chain settlement recorded). */
|
|
518
|
+
txHash: zod.z.string().optional(),
|
|
519
|
+
paidByWallet: zod.z.string().optional()
|
|
520
|
+
});
|
|
521
|
+
var mePaymentRequestsQuerySchema = zod.z.object({
|
|
522
|
+
limit: zod.z.coerce.number().int().min(1).max(50).default(20)
|
|
523
|
+
});
|
|
524
|
+
var paymentRequestsListResponseSchema = zod.z.object({
|
|
525
|
+
items: zod.z.array(publicPaymentRequestSchema)
|
|
526
|
+
});
|
|
527
|
+
var onRampFormNetworkOptionSchema = zod.z.object({
|
|
528
|
+
id: zod.z.string().min(1).max(64),
|
|
529
|
+
label: zod.z.string().min(1).max(120)
|
|
530
|
+
});
|
|
531
|
+
var onRampFormCtaParamsSchema = zod.z.object({
|
|
532
|
+
_onRampForm: zod.z.literal(true),
|
|
533
|
+
supportedAssets: zod.z.array(x402SupportedAssetSchema).min(1).max(24),
|
|
534
|
+
networks: zod.z.array(onRampFormNetworkOptionSchema).max(16).optional(),
|
|
535
|
+
intro: zod.z.string().max(2e3).optional()
|
|
536
|
+
});
|
|
537
|
+
function isOnRampFormCtaParams(v) {
|
|
538
|
+
return onRampFormCtaParamsSchema.safeParse(v).success;
|
|
539
|
+
}
|
|
540
|
+
var weiString = zod.z.union([
|
|
541
|
+
zod.z.string().trim().regex(
|
|
542
|
+
/^[1-9]\d*$/,
|
|
543
|
+
"tokenAmountWei must be base units (positive integer string, no decimals)"
|
|
544
|
+
),
|
|
545
|
+
zod.z.number().int().positive().transform((n) => String(n))
|
|
546
|
+
]);
|
|
547
|
+
var evmAddr = zod.z.string().min(1).refine(
|
|
548
|
+
(s) => /^0x[a-fA-F0-9]{40}$/.test(s.trim()),
|
|
549
|
+
"must be a 0x-prefixed 20-byte address"
|
|
550
|
+
).transform((s) => s.trim().toLowerCase());
|
|
551
|
+
var onRampTokensInputSchema = zod.z.object({
|
|
552
|
+
recipientWallet: evmAddr,
|
|
553
|
+
network: zod.z.string().min(1).max(64),
|
|
554
|
+
tokenAddress: evmAddr,
|
|
555
|
+
tokenDecimals: zod.z.number().int().min(0).max(36),
|
|
556
|
+
tokenSymbol: zod.z.string().min(1).max(32),
|
|
557
|
+
tokenAmountWei: weiString,
|
|
558
|
+
/** Optional spot reference for analytics / UI (per supported token). */
|
|
559
|
+
usdValue: zod.z.number().finite().nonnegative().optional(),
|
|
560
|
+
/** Total USD charged via Stripe (cents). Minimum $1.00. */
|
|
561
|
+
usdAmountCents: zod.z.number().int().min(100).max(1e7)
|
|
562
|
+
});
|
|
563
|
+
var onRampRecordStatusSchema = zod.z.enum([
|
|
564
|
+
"pending_checkout",
|
|
565
|
+
"pending_payment",
|
|
566
|
+
"paid_pending_transfer",
|
|
567
|
+
"fulfilled",
|
|
568
|
+
"failed",
|
|
569
|
+
"canceled"
|
|
570
|
+
]);
|
|
571
|
+
var onRampRecordSchema = zod.z.object({
|
|
572
|
+
id: zod.z.string().min(1),
|
|
573
|
+
status: onRampRecordStatusSchema,
|
|
574
|
+
walletAddress: zod.z.string().min(1),
|
|
575
|
+
recipientWallet: zod.z.string().min(1),
|
|
576
|
+
network: zod.z.string().min(1),
|
|
577
|
+
tokenAddress: zod.z.string().min(1),
|
|
578
|
+
tokenDecimals: zod.z.number().int().min(0).max(36),
|
|
579
|
+
tokenSymbol: zod.z.string().min(1),
|
|
580
|
+
tokenAmountWei: zod.z.string().min(1),
|
|
581
|
+
usdAmountCents: zod.z.number().int().nonnegative(),
|
|
582
|
+
usdValue: zod.z.number().finite().nonnegative().optional(),
|
|
583
|
+
stripeCheckoutSessionId: zod.z.string().optional(),
|
|
584
|
+
stripePaymentIntentId: zod.z.string().optional(),
|
|
585
|
+
fulfillmentTxHash: zod.z.string().optional(),
|
|
586
|
+
errorMessage: zod.z.string().optional(),
|
|
587
|
+
createdAt: zod.z.coerce.date().optional(),
|
|
588
|
+
updatedAt: zod.z.coerce.date().optional()
|
|
589
|
+
});
|
|
590
|
+
var meOnRampsQuerySchema = zod.z.object({
|
|
591
|
+
limit: zod.z.coerce.number().int().min(1).max(50).default(20)
|
|
592
|
+
});
|
|
593
|
+
var onRampsListResponseSchema = zod.z.object({
|
|
594
|
+
items: zod.z.array(onRampRecordSchema)
|
|
595
|
+
});
|
|
596
|
+
var userKycStatusSchema = zod.z.enum([
|
|
597
|
+
"not_started",
|
|
598
|
+
"pending",
|
|
599
|
+
"processing",
|
|
600
|
+
"verified",
|
|
601
|
+
"requires_input",
|
|
602
|
+
"canceled"
|
|
603
|
+
]);
|
|
604
|
+
var stripeKycInputSchema = zod.z.object({
|
|
605
|
+
/** App path + query (e.g. `/` or `/?conversation=<id>`); joined with `APP_PUBLIC_URL` for Stripe `return_url`. */
|
|
606
|
+
returnPath: zod.z.string().min(1).max(512).optional()
|
|
607
|
+
}).strict();
|
|
608
|
+
var userKycStatusDocumentSchema = zod.z.object({
|
|
609
|
+
walletAddress: zod.z.string().min(1),
|
|
610
|
+
status: userKycStatusSchema,
|
|
611
|
+
stripeVerificationSessionId: zod.z.string().optional(),
|
|
612
|
+
lastStripeEventType: zod.z.string().optional(),
|
|
613
|
+
lastError: zod.z.string().optional(),
|
|
614
|
+
createdAt: zod.z.coerce.date().optional(),
|
|
615
|
+
updatedAt: zod.z.coerce.date().optional()
|
|
616
|
+
});
|
|
617
|
+
var createCreditCardInputSchema = zod.z.object({
|
|
618
|
+
firstName: zod.z.string().trim().min(1).max(80),
|
|
619
|
+
lastName: zod.z.string().trim().min(1).max(80),
|
|
620
|
+
line1: zod.z.string().trim().min(1).max(120),
|
|
621
|
+
line2: zod.z.string().trim().max(120).optional(),
|
|
622
|
+
city: zod.z.string().trim().min(1).max(80),
|
|
623
|
+
region: zod.z.string().trim().min(1).max(80),
|
|
624
|
+
postalCode: zod.z.string().trim().min(1).max(20),
|
|
625
|
+
countryCode: zod.z.string().trim().length(2).transform((c) => c.toUpperCase()),
|
|
626
|
+
cardLabel: zod.z.string().trim().min(1).max(80).optional(),
|
|
627
|
+
currency: zod.z.string().trim().length(3).transform((c) => c.toUpperCase()).optional(),
|
|
628
|
+
/** Opening balance in minor units (e.g. USD cents). */
|
|
629
|
+
initialBalanceCents: zod.z.coerce.number().int().min(0).max(1e8).optional()
|
|
630
|
+
});
|
|
631
|
+
var creditCardFormCtaParamsSchema = zod.z.object({
|
|
632
|
+
_creditCardForm: zod.z.literal(true),
|
|
633
|
+
intro: zod.z.string().max(2e3).optional(),
|
|
634
|
+
defaultCurrency: zod.z.string().trim().length(3).transform((c) => c.toUpperCase()).optional()
|
|
635
|
+
});
|
|
636
|
+
function isCreditCardFormCtaParams(v) {
|
|
637
|
+
return creditCardFormCtaParamsSchema.safeParse(v).success;
|
|
638
|
+
}
|
|
639
|
+
var creditCardPublicSchema = zod.z.object({
|
|
640
|
+
id: zod.z.string().min(1),
|
|
641
|
+
firstName: zod.z.string(),
|
|
642
|
+
lastName: zod.z.string(),
|
|
643
|
+
cardLabel: zod.z.string().optional(),
|
|
644
|
+
line1: zod.z.string(),
|
|
645
|
+
line2: zod.z.string().optional(),
|
|
646
|
+
city: zod.z.string(),
|
|
647
|
+
region: zod.z.string(),
|
|
648
|
+
postalCode: zod.z.string(),
|
|
649
|
+
countryCode: zod.z.string(),
|
|
650
|
+
currency: zod.z.string(),
|
|
651
|
+
balanceCents: zod.z.number().int().nonnegative(),
|
|
652
|
+
last4: zod.z.string(),
|
|
653
|
+
networkBrand: zod.z.string(),
|
|
654
|
+
status: zod.z.enum(["active", "frozen"]),
|
|
655
|
+
createdAt: zod.z.coerce.date().optional(),
|
|
656
|
+
updatedAt: zod.z.coerce.date().optional(),
|
|
657
|
+
/** Present on some `POST …/withdraw` responses when native 0G was sent from the treasury. */
|
|
658
|
+
lastWithdrawTxHash: zod.z.string().regex(/^0x[a-fA-F0-9]{64}$/).optional()
|
|
659
|
+
});
|
|
660
|
+
var creditCardSensitiveDetailsSchema = zod.z.object({
|
|
661
|
+
cardId: zod.z.string().min(1),
|
|
662
|
+
pan: zod.z.string().regex(/^\d{16}$/),
|
|
663
|
+
expiryMonth: zod.z.coerce.number().int().min(1).max(12),
|
|
664
|
+
expiryYear: zod.z.coerce.number().int().min(2e3).max(2100),
|
|
665
|
+
cvv: zod.z.string().regex(/^\d{3,4}$/)
|
|
666
|
+
});
|
|
667
|
+
var creditCardsListResponseSchema = zod.z.object({
|
|
668
|
+
cards: zod.z.array(creditCardPublicSchema)
|
|
669
|
+
});
|
|
670
|
+
var creditCardFundBodySchema = zod.z.object({
|
|
671
|
+
amountCents: zod.z.coerce.number().int().min(1).max(1e8),
|
|
672
|
+
fundingTxHash: zod.z.string().regex(/^0x[a-fA-F0-9]{64}$/).optional(),
|
|
673
|
+
fundingChainId: zod.z.coerce.number().int().positive().optional()
|
|
674
|
+
}).refine(
|
|
675
|
+
(d) => d.fundingTxHash == null && d.fundingChainId == null || d.fundingTxHash != null && d.fundingChainId != null,
|
|
676
|
+
{
|
|
677
|
+
message: "fundingTxHash and fundingChainId must both be provided or both omitted",
|
|
678
|
+
path: ["fundingTxHash"]
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
var creditCardFundQuoteQuerySchema = zod.z.object({
|
|
682
|
+
amountCents: zod.z.coerce.number().int().min(1).max(1e8)
|
|
683
|
+
});
|
|
684
|
+
var creditCardFundQuoteOffChainSchema = zod.z.object({
|
|
685
|
+
onchainFundingRequired: zod.z.literal(false)
|
|
686
|
+
});
|
|
687
|
+
var creditCardFundQuoteOnChainSchema = zod.z.object({
|
|
688
|
+
onchainFundingRequired: zod.z.literal(true),
|
|
689
|
+
chainId: zod.z.number().int(),
|
|
690
|
+
recipient: zod.z.string().min(1),
|
|
691
|
+
minNativeWei: zod.z.string().regex(/^\d+$/),
|
|
692
|
+
usdValue: zod.z.number().finite().positive(),
|
|
693
|
+
nativeSymbol: zod.z.string().min(1),
|
|
694
|
+
nativeDecimals: zod.z.number().int().min(0).max(18)
|
|
695
|
+
});
|
|
696
|
+
var creditCardFundQuoteResponseSchema = zod.z.discriminatedUnion(
|
|
697
|
+
"onchainFundingRequired",
|
|
698
|
+
[creditCardFundQuoteOffChainSchema, creditCardFundQuoteOnChainSchema]
|
|
699
|
+
);
|
|
700
|
+
var creditCardWithdrawBodySchema = zod.z.object({
|
|
701
|
+
amountCents: zod.z.coerce.number().int().min(1).max(1e8)
|
|
702
|
+
});
|
|
703
|
+
var billingDatePartSchema = zod.z.object({
|
|
704
|
+
year: zod.z.number().int().min(2020).max(2036),
|
|
705
|
+
month: zod.z.number().int().min(1).max(12),
|
|
706
|
+
day: zod.z.number().int().min(1).max(31)
|
|
707
|
+
});
|
|
708
|
+
function billingDatePartToUtc(p) {
|
|
709
|
+
return new Date(Date.UTC(p.year, p.month - 1, p.day));
|
|
710
|
+
}
|
|
711
|
+
function billingRangeEndOfDay(p) {
|
|
712
|
+
const d = billingDatePartToUtc(p);
|
|
713
|
+
d.setUTCHours(23, 59, 59, 999);
|
|
714
|
+
return d;
|
|
715
|
+
}
|
|
716
|
+
function billingPeriodBounds(input) {
|
|
717
|
+
return {
|
|
718
|
+
from: input.from ? billingDatePartToUtc(input.from) : void 0,
|
|
719
|
+
to: input.to ? billingRangeEndOfDay(input.to) : void 0
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
var generatePaymentInvoiceInputSchema = zod.z.object({
|
|
723
|
+
from: billingDatePartSchema.optional(),
|
|
724
|
+
to: billingDatePartSchema.optional(),
|
|
725
|
+
invoiceTitle: zod.z.string().trim().min(1).max(120).optional()
|
|
726
|
+
}).superRefine((val, ctx) => {
|
|
727
|
+
if (!val.from || !val.to) return;
|
|
728
|
+
const a = billingDatePartToUtc(val.from);
|
|
729
|
+
const b = billingDatePartToUtc(val.to);
|
|
730
|
+
if (Number.isNaN(a.getTime()) || Number.isNaN(b.getTime())) {
|
|
731
|
+
ctx.addIssue({
|
|
732
|
+
code: zod.z.ZodIssueCode.custom,
|
|
733
|
+
message: "Invalid calendar date"
|
|
734
|
+
});
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (a > b) {
|
|
738
|
+
ctx.addIssue({
|
|
739
|
+
code: zod.z.ZodIssueCode.custom,
|
|
740
|
+
message: "`from` must be on or before `to`",
|
|
741
|
+
path: ["from"]
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
var generateFinancialActivityReportInputSchema = zod.z.object({
|
|
746
|
+
from: billingDatePartSchema.optional(),
|
|
747
|
+
to: billingDatePartSchema.optional(),
|
|
748
|
+
reportTitle: zod.z.string().trim().min(1).max(120).optional()
|
|
749
|
+
}).superRefine((val, ctx) => {
|
|
750
|
+
if (!val.from || !val.to) return;
|
|
751
|
+
const a = billingDatePartToUtc(val.from);
|
|
752
|
+
const b = billingDatePartToUtc(val.to);
|
|
753
|
+
if (Number.isNaN(a.getTime()) || Number.isNaN(b.getTime())) {
|
|
754
|
+
ctx.addIssue({
|
|
755
|
+
code: zod.z.ZodIssueCode.custom,
|
|
756
|
+
message: "Invalid calendar date"
|
|
757
|
+
});
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
if (a > b) {
|
|
761
|
+
ctx.addIssue({
|
|
762
|
+
code: zod.z.ZodIssueCode.custom,
|
|
763
|
+
message: "`from` must be on or before `to`",
|
|
764
|
+
path: ["from"]
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
// src/iso-3166-1-alpha2.ts
|
|
770
|
+
var ISO_3166_1_ALPHA2_CODES_RAW = "AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW";
|
|
771
|
+
var ISO_3166_1_ALPHA2_CODES = Object.freeze(
|
|
772
|
+
ISO_3166_1_ALPHA2_CODES_RAW.split(/\s+/)
|
|
773
|
+
);
|
|
774
|
+
var ISO_3166_1_ALPHA2_SET = new Set(ISO_3166_1_ALPHA2_CODES);
|
|
775
|
+
function isIso3166Alpha2(code) {
|
|
776
|
+
const c = code.length === 2 ? code.toUpperCase() : "";
|
|
777
|
+
return ISO_3166_1_ALPHA2_SET.has(c);
|
|
778
|
+
}
|
|
779
|
+
function isoCountryDisplayName(code, locale = "en") {
|
|
780
|
+
const c = code.length === 2 ? code.toUpperCase() : code;
|
|
781
|
+
try {
|
|
782
|
+
const dn = new Intl.DisplayNames(locale, { type: "region" });
|
|
783
|
+
return dn.of(c) ?? c;
|
|
784
|
+
} catch {
|
|
785
|
+
return c;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// src/tax-rate-for-country.ts
|
|
790
|
+
var EU27 = /* @__PURE__ */ new Set([
|
|
791
|
+
"AT",
|
|
792
|
+
"BE",
|
|
793
|
+
"BG",
|
|
794
|
+
"HR",
|
|
795
|
+
"CY",
|
|
796
|
+
"CZ",
|
|
797
|
+
"DK",
|
|
798
|
+
"EE",
|
|
799
|
+
"FI",
|
|
800
|
+
"FR",
|
|
801
|
+
"DE",
|
|
802
|
+
"GR",
|
|
803
|
+
"HU",
|
|
804
|
+
"IE",
|
|
805
|
+
"IT",
|
|
806
|
+
"LV",
|
|
807
|
+
"LT",
|
|
808
|
+
"LU",
|
|
809
|
+
"MT",
|
|
810
|
+
"NL",
|
|
811
|
+
"PL",
|
|
812
|
+
"PT",
|
|
813
|
+
"RO",
|
|
814
|
+
"SK",
|
|
815
|
+
"SI",
|
|
816
|
+
"ES",
|
|
817
|
+
"SE"
|
|
818
|
+
]);
|
|
819
|
+
var EEA_NON_EU = /* @__PURE__ */ new Set(["IS", "LI", "NO"]);
|
|
820
|
+
var HIGH_TIER_OECD = /* @__PURE__ */ new Set(["AU", "CA", "JP", "KR", "NZ"]);
|
|
821
|
+
function taxRateForCountry(country) {
|
|
822
|
+
const c = country.toUpperCase();
|
|
823
|
+
if (c === "US") return 0.22;
|
|
824
|
+
if (c === "GB" || c === "UK") return 0.2;
|
|
825
|
+
if (c === "DE" || c === "FR") return 0.25;
|
|
826
|
+
if (c === "SG") return 0.17;
|
|
827
|
+
if (EU27.has(c)) return 0.24;
|
|
828
|
+
if (EEA_NON_EU.has(c)) return 0.24;
|
|
829
|
+
if (HIGH_TIER_OECD.has(c)) return 0.25;
|
|
830
|
+
return 0.2;
|
|
831
|
+
}
|
|
832
|
+
var caip2Eip155 = zod.z.string().min(8).max(64).regex(
|
|
833
|
+
/^eip155:\d+$/,
|
|
834
|
+
"network must be CAIP-2 form eip155:<chainId> (e.g. eip155:16602)"
|
|
835
|
+
);
|
|
836
|
+
var evmAddress20 = zod.z.string().trim().refine(
|
|
837
|
+
(s) => /^0x[a-fA-F0-9]{40}$/.test(s),
|
|
838
|
+
"must be a 0x-prefixed 20-byte EVM address"
|
|
839
|
+
).transform((s) => s.trim().toLowerCase());
|
|
840
|
+
var positiveWeiString = zod.z.string().trim().regex(
|
|
841
|
+
/^[1-9]\d*$/,
|
|
842
|
+
"must be a positive integer decimal string (base units / wei)"
|
|
843
|
+
);
|
|
844
|
+
var decimalStringNonNeg = zod.z.string().trim().regex(/^\d+$/, "must be a non-negative integer decimal string");
|
|
845
|
+
var nftStandardSchema = zod.z.enum(["erc721", "erc1155"]);
|
|
846
|
+
var draftNativeTransferInputSchema = zod.z.object({
|
|
847
|
+
network: caip2Eip155,
|
|
848
|
+
to: evmAddress20,
|
|
849
|
+
valueWei: positiveWeiString,
|
|
850
|
+
note: zod.z.string().max(500).optional()
|
|
851
|
+
});
|
|
852
|
+
var draftErc20TransferInputSchema = zod.z.object({
|
|
853
|
+
network: caip2Eip155,
|
|
854
|
+
token: evmAddress20,
|
|
855
|
+
tokenSymbol: zod.z.string().min(1).max(32).optional(),
|
|
856
|
+
tokenDecimals: zod.z.number().int().min(0).max(36),
|
|
857
|
+
to: evmAddress20,
|
|
858
|
+
amountWei: positiveWeiString,
|
|
859
|
+
note: zod.z.string().max(500).optional()
|
|
860
|
+
});
|
|
861
|
+
var draftNftTransferInputSchema = zod.z.object({
|
|
862
|
+
network: caip2Eip155,
|
|
863
|
+
contract: evmAddress20,
|
|
864
|
+
standard: nftStandardSchema.default("erc721"),
|
|
865
|
+
to: evmAddress20,
|
|
866
|
+
tokenId: decimalStringNonNeg,
|
|
867
|
+
/** Required for ERC-1155; omit for ERC-721. */
|
|
868
|
+
amount: positiveWeiString.optional(),
|
|
869
|
+
note: zod.z.string().max(500).optional()
|
|
870
|
+
}).superRefine((val, ctx) => {
|
|
871
|
+
if (val.standard === "erc1155") {
|
|
872
|
+
if (!val.amount) {
|
|
873
|
+
ctx.addIssue({
|
|
874
|
+
code: zod.z.ZodIssueCode.custom,
|
|
875
|
+
message: "amount (base units) is required for ERC-1155",
|
|
876
|
+
path: ["amount"]
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
} else if (val.amount != null) {
|
|
880
|
+
ctx.addIssue({
|
|
881
|
+
code: zod.z.ZodIssueCode.custom,
|
|
882
|
+
message: "amount must be omitted for ERC-721",
|
|
883
|
+
path: ["amount"]
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
exports.HANDLER_ACTION_IDS = HANDLER_ACTION_IDS;
|
|
889
|
+
exports.ISO_3166_1_ALPHA2_CODES = ISO_3166_1_ALPHA2_CODES;
|
|
890
|
+
exports.agentAvatarSchema = agentAvatarSchema;
|
|
891
|
+
exports.agentCategorySchema = agentCategorySchema;
|
|
892
|
+
exports.agentFeedbacksPageResponseSchema = agentFeedbacksPageResponseSchema;
|
|
893
|
+
exports.agentFeedbacksQuerySchema = agentFeedbacksQuerySchema;
|
|
894
|
+
exports.agentOnchainFeedbackItemSchema = agentOnchainFeedbackItemSchema;
|
|
895
|
+
exports.agentSchema = agentSchema;
|
|
896
|
+
exports.agentsListSchema = agentsListSchema;
|
|
897
|
+
exports.authChallengeBodySchema = authChallengeBodySchema;
|
|
898
|
+
exports.authChallengeResponseSchema = authChallengeResponseSchema;
|
|
899
|
+
exports.authMeResponseSchema = authMeResponseSchema;
|
|
900
|
+
exports.authVerifyBodySchema = authVerifyBodySchema;
|
|
901
|
+
exports.authVerifyResponseSchema = authVerifyResponseSchema;
|
|
902
|
+
exports.billingDatePartSchema = billingDatePartSchema;
|
|
903
|
+
exports.billingDatePartToUtc = billingDatePartToUtc;
|
|
904
|
+
exports.billingPeriodBounds = billingPeriodBounds;
|
|
905
|
+
exports.billingRangeEndOfDay = billingRangeEndOfDay;
|
|
906
|
+
exports.buildStardormCatalogResponse = buildStardormCatalogResponse;
|
|
907
|
+
exports.catalogResponseSchema = catalogResponseSchema;
|
|
908
|
+
exports.chatFollowUpSchema = chatFollowUpSchema;
|
|
909
|
+
exports.chatHistoryAttachmentSchema = chatHistoryAttachmentSchema;
|
|
910
|
+
exports.chatHistoryHandlerCtaSchema = chatHistoryHandlerCtaSchema;
|
|
911
|
+
exports.chatHistoryMessageSchema = chatHistoryMessageSchema;
|
|
912
|
+
exports.chatHistoryQuerySchema = chatHistoryQuerySchema;
|
|
913
|
+
exports.chatHistoryResponseSchema = chatHistoryResponseSchema;
|
|
914
|
+
exports.conversationSummarySchema = conversationSummarySchema;
|
|
915
|
+
exports.conversationsListResponseSchema = conversationsListResponseSchema;
|
|
916
|
+
exports.conversationsPageResponseSchema = conversationsPageResponseSchema;
|
|
917
|
+
exports.conversationsQuerySchema = conversationsQuerySchema;
|
|
918
|
+
exports.createConversationBodySchema = createConversationBodySchema;
|
|
919
|
+
exports.createCreditCardInputSchema = createCreditCardInputSchema;
|
|
920
|
+
exports.creditCardFormCtaParamsSchema = creditCardFormCtaParamsSchema;
|
|
921
|
+
exports.creditCardFundBodySchema = creditCardFundBodySchema;
|
|
922
|
+
exports.creditCardFundQuoteOffChainSchema = creditCardFundQuoteOffChainSchema;
|
|
923
|
+
exports.creditCardFundQuoteOnChainSchema = creditCardFundQuoteOnChainSchema;
|
|
924
|
+
exports.creditCardFundQuoteQuerySchema = creditCardFundQuoteQuerySchema;
|
|
925
|
+
exports.creditCardFundQuoteResponseSchema = creditCardFundQuoteResponseSchema;
|
|
926
|
+
exports.creditCardPublicSchema = creditCardPublicSchema;
|
|
927
|
+
exports.creditCardSensitiveDetailsSchema = creditCardSensitiveDetailsSchema;
|
|
928
|
+
exports.creditCardWithdrawBodySchema = creditCardWithdrawBodySchema;
|
|
929
|
+
exports.creditCardsListResponseSchema = creditCardsListResponseSchema;
|
|
930
|
+
exports.deleteConversationResponseSchema = deleteConversationResponseSchema;
|
|
931
|
+
exports.draftErc20TransferInputSchema = draftErc20TransferInputSchema;
|
|
932
|
+
exports.draftNativeTransferInputSchema = draftNativeTransferInputSchema;
|
|
933
|
+
exports.draftNftTransferInputSchema = draftNftTransferInputSchema;
|
|
934
|
+
exports.executeHandlerBodySchema = executeHandlerBodySchema;
|
|
935
|
+
exports.executeHandlerResponseSchema = executeHandlerResponseSchema;
|
|
936
|
+
exports.generateFinancialActivityReportInputSchema = generateFinancialActivityReportInputSchema;
|
|
937
|
+
exports.generatePaymentInvoiceInputSchema = generatePaymentInvoiceInputSchema;
|
|
938
|
+
exports.handlerActionIdSchema = handlerActionIdSchema;
|
|
939
|
+
exports.handlersListResponseSchema = handlersListResponseSchema;
|
|
940
|
+
exports.isCreditCardFormCtaParams = isCreditCardFormCtaParams;
|
|
941
|
+
exports.isHandlerActionId = isHandlerActionId;
|
|
942
|
+
exports.isIso3166Alpha2 = isIso3166Alpha2;
|
|
943
|
+
exports.isOnRampFormCtaParams = isOnRampFormCtaParams;
|
|
944
|
+
exports.isoCountryDisplayName = isoCountryDisplayName;
|
|
945
|
+
exports.meOnRampsQuerySchema = meOnRampsQuerySchema;
|
|
946
|
+
exports.mePaymentRequestsQuerySchema = mePaymentRequestsQuerySchema;
|
|
947
|
+
exports.onRampFormCtaParamsSchema = onRampFormCtaParamsSchema;
|
|
948
|
+
exports.onRampFormNetworkOptionSchema = onRampFormNetworkOptionSchema;
|
|
949
|
+
exports.onRampRecordSchema = onRampRecordSchema;
|
|
950
|
+
exports.onRampRecordStatusSchema = onRampRecordStatusSchema;
|
|
951
|
+
exports.onRampTokensInputSchema = onRampTokensInputSchema;
|
|
952
|
+
exports.onRampsListResponseSchema = onRampsListResponseSchema;
|
|
953
|
+
exports.paymentRequestStatusSchema = paymentRequestStatusSchema;
|
|
954
|
+
exports.paymentRequestTypeSchema = paymentRequestTypeSchema;
|
|
955
|
+
exports.paymentRequestsListResponseSchema = paymentRequestsListResponseSchema;
|
|
956
|
+
exports.paymentSettlementBodySchema = paymentSettlementBodySchema;
|
|
957
|
+
exports.publicPaymentRequestSchema = publicPaymentRequestSchema;
|
|
958
|
+
exports.publicUserSchema = publicUserSchema;
|
|
959
|
+
exports.resolveStardormAgentKey = resolveStardormAgentKey;
|
|
960
|
+
exports.resolveStardormChainAgentId = resolveStardormChainAgentId;
|
|
961
|
+
exports.skillHandleSchema = skillHandleSchema;
|
|
962
|
+
exports.stardormChatAttachmentSchema = stardormChatAttachmentSchema;
|
|
963
|
+
exports.stardormChatClientErrorSchema = stardormChatClientErrorSchema;
|
|
964
|
+
exports.stardormChatClientResultSchema = stardormChatClientResultSchema;
|
|
965
|
+
exports.stardormChatComputeSchema = stardormChatComputeSchema;
|
|
966
|
+
exports.stardormChatJsonBodySchema = stardormChatJsonBodySchema;
|
|
967
|
+
exports.stardormChatRichBlockSchema = stardormChatRichBlockSchema;
|
|
968
|
+
exports.stardormChatRichRowSchema = stardormChatRichRowSchema;
|
|
969
|
+
exports.stardormChatStructuredSchema = stardormChatStructuredSchema;
|
|
970
|
+
exports.stardormChatSuccessSchema = stardormChatSuccessSchema;
|
|
971
|
+
exports.storageUploadBodySchema = storageUploadBodySchema;
|
|
972
|
+
exports.storageUploadResponseSchema = storageUploadResponseSchema;
|
|
973
|
+
exports.stripeKycInputSchema = stripeKycInputSchema;
|
|
974
|
+
exports.taxRateForCountry = taxRateForCountry;
|
|
975
|
+
exports.updateUserBodySchema = updateUserBodySchema;
|
|
976
|
+
exports.userAvatarPresetSchema = userAvatarPresetSchema;
|
|
977
|
+
exports.userKycStatusDocumentSchema = userKycStatusDocumentSchema;
|
|
978
|
+
exports.userKycStatusSchema = userKycStatusSchema;
|
|
979
|
+
exports.userPreferencesSchema = userPreferencesSchema;
|
|
980
|
+
exports.userUploadResultSchema = userUploadResultSchema;
|
|
981
|
+
exports.x402SupportedAssetSchema = x402SupportedAssetSchema;
|
|
982
|
+
//# sourceMappingURL=index.js.map
|
|
983
|
+
//# sourceMappingURL=index.js.map
|