@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/src/chat-api.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { handlerActionIdSchema } from "./handlers.js";
|
|
3
|
+
|
|
4
|
+
export const stardormChatRichRowSchema = z.object({
|
|
5
|
+
label: z.string(),
|
|
6
|
+
value: z.string(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/** One selectable asset row for the x402 checkout form rich block. */
|
|
10
|
+
export const x402SupportedAssetSchema = z.object({
|
|
11
|
+
name: z.string().min(1).max(64),
|
|
12
|
+
symbol: z.string().min(1).max(32),
|
|
13
|
+
icon: z.string().min(1).max(512),
|
|
14
|
+
decimals: z.number().int().min(0).max(36),
|
|
15
|
+
address: z.string().min(1).max(66),
|
|
16
|
+
usdValue: z.number().finite().nonnegative().optional(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export type X402SupportedAsset = z.infer<typeof x402SupportedAssetSchema>;
|
|
20
|
+
|
|
21
|
+
const stardormChatRichRows = z.array(stardormChatRichRowSchema).max(32).optional();
|
|
22
|
+
|
|
23
|
+
export const stardormChatRichBlockSchema = z.discriminatedUnion("type", [
|
|
24
|
+
z.object({
|
|
25
|
+
type: z.literal("report"),
|
|
26
|
+
title: z.string().min(1),
|
|
27
|
+
rows: stardormChatRichRows,
|
|
28
|
+
}),
|
|
29
|
+
z.object({
|
|
30
|
+
type: z.literal("invoice"),
|
|
31
|
+
title: z.string().min(1),
|
|
32
|
+
rows: stardormChatRichRows,
|
|
33
|
+
}),
|
|
34
|
+
z.object({
|
|
35
|
+
type: z.literal("tx"),
|
|
36
|
+
title: z.string().min(1),
|
|
37
|
+
rows: stardormChatRichRows,
|
|
38
|
+
}),
|
|
39
|
+
z.object({
|
|
40
|
+
type: z.literal("x402_checkout_form"),
|
|
41
|
+
title: z.string().min(1).max(200),
|
|
42
|
+
intro: z.string().max(2000).optional(),
|
|
43
|
+
/** Paywalled HTTP resource URL for x402 clients (optional). */
|
|
44
|
+
resourceUrl: z.string().url().max(2048).optional(),
|
|
45
|
+
supportedAssets: z.array(x402SupportedAssetSchema).min(1).max(24),
|
|
46
|
+
networks: z
|
|
47
|
+
.array(
|
|
48
|
+
z.object({
|
|
49
|
+
id: z.string().min(1).max(64),
|
|
50
|
+
label: z.string().min(1).max(120),
|
|
51
|
+
}),
|
|
52
|
+
)
|
|
53
|
+
.max(16)
|
|
54
|
+
.optional(),
|
|
55
|
+
}),
|
|
56
|
+
z.object({
|
|
57
|
+
type: z.literal("on_ramp_checkout_form"),
|
|
58
|
+
title: z.string().min(1).max(200),
|
|
59
|
+
intro: z.string().max(2000).optional(),
|
|
60
|
+
supportedAssets: z.array(x402SupportedAssetSchema).min(1).max(24),
|
|
61
|
+
networks: z
|
|
62
|
+
.array(
|
|
63
|
+
z.object({
|
|
64
|
+
id: z.string().min(1).max(64),
|
|
65
|
+
label: z.string().min(1).max(120),
|
|
66
|
+
}),
|
|
67
|
+
)
|
|
68
|
+
.max(16)
|
|
69
|
+
.optional(),
|
|
70
|
+
}),
|
|
71
|
+
z.object({
|
|
72
|
+
type: z.literal("credit_card_checkout_form"),
|
|
73
|
+
title: z.string().min(1).max(200),
|
|
74
|
+
intro: z.string().max(2000).optional(),
|
|
75
|
+
/** Pre-filled ISO 4217 currency in the form (e.g. USD). */
|
|
76
|
+
defaultCurrency: z.string().length(3).optional(),
|
|
77
|
+
}),
|
|
78
|
+
z.object({
|
|
79
|
+
type: z.literal("credit_card"),
|
|
80
|
+
title: z.string().min(1),
|
|
81
|
+
rows: stardormChatRichRows,
|
|
82
|
+
}),
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
export type StardormChatRichBlock = z.infer<typeof stardormChatRichBlockSchema>;
|
|
86
|
+
|
|
87
|
+
export const stardormChatJsonBodySchema = z.object({
|
|
88
|
+
message: z.string().min(1),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export type StardormChatJsonBody = z.infer<typeof stardormChatJsonBodySchema>;
|
|
92
|
+
|
|
93
|
+
export const stardormChatStructuredSchema = z.object({
|
|
94
|
+
text: z.string(),
|
|
95
|
+
handler: handlerActionIdSchema.optional(),
|
|
96
|
+
params: z.unknown().optional(),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export const stardormChatComputeSchema = z.object({
|
|
100
|
+
model: z.string(),
|
|
101
|
+
verified: z.boolean(),
|
|
102
|
+
chatId: z.string().optional(),
|
|
103
|
+
provider: z.string(),
|
|
104
|
+
computeNetwork: z.string(),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export const stardormChatAttachmentSchema = z.object({
|
|
108
|
+
id: z.string().min(1),
|
|
109
|
+
name: z.string(),
|
|
110
|
+
mimeType: z.string(),
|
|
111
|
+
hash: z.string().min(1),
|
|
112
|
+
size: z.string().optional(),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export type StardormChatAttachment = z.infer<typeof stardormChatAttachmentSchema>;
|
|
116
|
+
|
|
117
|
+
export const stardormChatSuccessSchema = z.object({
|
|
118
|
+
agentKey: z.string().min(1),
|
|
119
|
+
reply: z.string(),
|
|
120
|
+
structured: stardormChatStructuredSchema.optional(),
|
|
121
|
+
/** Structured card rows for the client (model or server-generated). */
|
|
122
|
+
rich: stardormChatRichBlockSchema.optional(),
|
|
123
|
+
/** Files the server uploaded to 0G Storage from the user's chat turn (echoed for immediate render). */
|
|
124
|
+
attachments: z.array(stardormChatAttachmentSchema).optional(),
|
|
125
|
+
compute: stardormChatComputeSchema,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export type StardormChatSuccess = z.infer<typeof stardormChatSuccessSchema>;
|
|
129
|
+
|
|
130
|
+
export const stardormChatClientErrorSchema = z.object({
|
|
131
|
+
error: z.string().min(1),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export const stardormChatClientResultSchema = z.union([
|
|
135
|
+
stardormChatSuccessSchema,
|
|
136
|
+
stardormChatClientErrorSchema,
|
|
137
|
+
]);
|
|
138
|
+
|
|
139
|
+
export type StardormChatClientResult = z.infer<typeof stardormChatClientResultSchema>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { handlerActionIdSchema } from "./handlers.js";
|
|
3
|
+
import { stardormChatRichBlockSchema } from "./chat-api.js";
|
|
4
|
+
|
|
5
|
+
export const chatHistoryQuerySchema = z.object({
|
|
6
|
+
limit: z.coerce.number().int().min(1).max(100).default(40),
|
|
7
|
+
/** When omitted, the server uses the user’s active conversation. */
|
|
8
|
+
conversationId: z.string().min(1).optional(),
|
|
9
|
+
/**
|
|
10
|
+
* Opaque cursor from the previous response’s `nextCursorOlder` — loads older messages
|
|
11
|
+
* than the oldest message in the last batch (prepends chronologically in the client).
|
|
12
|
+
*/
|
|
13
|
+
cursor: z.string().min(1).optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type ChatHistoryQuery = z.infer<typeof chatHistoryQuerySchema>;
|
|
17
|
+
|
|
18
|
+
export const chatHistoryAttachmentSchema = z.object({
|
|
19
|
+
id: z.string(),
|
|
20
|
+
mimeType: z.string(),
|
|
21
|
+
name: z.string(),
|
|
22
|
+
hash: z.string(),
|
|
23
|
+
size: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const chatHistoryHandlerCtaSchema = z.object({
|
|
27
|
+
handler: handlerActionIdSchema,
|
|
28
|
+
params: z.record(z.unknown()),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/** Post-execute affordances derived from handler result (x402 checkout, tax PDF, …). */
|
|
32
|
+
export const chatFollowUpSchema = z.discriminatedUnion("kind", [
|
|
33
|
+
z.object({
|
|
34
|
+
kind: z.literal("x402_checkout"),
|
|
35
|
+
/** App-relative path, e.g. `/pay/<mongoId>`. */
|
|
36
|
+
payPath: z.string().min(1),
|
|
37
|
+
paymentRequestId: z.string().min(1),
|
|
38
|
+
}),
|
|
39
|
+
z.object({
|
|
40
|
+
kind: z.literal("tax_report_pdf"),
|
|
41
|
+
attachmentId: z.string().min(1),
|
|
42
|
+
name: z.string().min(1),
|
|
43
|
+
}),
|
|
44
|
+
z.object({
|
|
45
|
+
kind: z.literal("stripe_on_ramp"),
|
|
46
|
+
checkoutUrl: z.string().url(),
|
|
47
|
+
onRampId: z.string().min(1),
|
|
48
|
+
}),
|
|
49
|
+
z.object({
|
|
50
|
+
kind: z.literal("stripe_identity"),
|
|
51
|
+
verificationUrl: z.string().url(),
|
|
52
|
+
verificationSessionId: z.string().min(1),
|
|
53
|
+
}),
|
|
54
|
+
z.object({
|
|
55
|
+
kind: z.literal("credit_card_ready"),
|
|
56
|
+
creditCardId: z.string().min(1),
|
|
57
|
+
/** App path for managing the card balance (e.g. /dashboard). */
|
|
58
|
+
dashboardPath: z.string().min(1),
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
export const chatHistoryMessageSchema = z.object({
|
|
63
|
+
id: z.string(),
|
|
64
|
+
role: z.enum(["user", "agent"]),
|
|
65
|
+
agentKey: z.string().optional(),
|
|
66
|
+
content: z.string(),
|
|
67
|
+
createdAt: z.number(),
|
|
68
|
+
attachments: z.array(chatHistoryAttachmentSchema).optional(),
|
|
69
|
+
rich: stardormChatRichBlockSchema.optional(),
|
|
70
|
+
handlerCta: chatHistoryHandlerCtaSchema.optional(),
|
|
71
|
+
followUp: chatFollowUpSchema.optional(),
|
|
72
|
+
model: z.string().optional(),
|
|
73
|
+
verified: z.boolean().optional(),
|
|
74
|
+
chatId: z.string().optional(),
|
|
75
|
+
provider: z.string().optional(),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const chatHistoryResponseSchema = z.object({
|
|
79
|
+
conversationId: z.string(),
|
|
80
|
+
agentKey: z.string(),
|
|
81
|
+
messages: z.array(chatHistoryMessageSchema),
|
|
82
|
+
/** True when more older messages exist before this batch. */
|
|
83
|
+
hasMoreOlder: z.boolean(),
|
|
84
|
+
/** Pass as `cursor` on the next request to load older messages. */
|
|
85
|
+
nextCursorOlder: z.string().optional(),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export type ChatHistoryAttachment = z.infer<typeof chatHistoryAttachmentSchema>;
|
|
89
|
+
export type ChatFollowUp = z.infer<typeof chatFollowUpSchema>;
|
|
90
|
+
export type ChatHistoryMessage = z.infer<typeof chatHistoryMessageSchema>;
|
|
91
|
+
export type ChatHistoryResponse = z.infer<typeof chatHistoryResponseSchema>;
|
|
92
|
+
|
|
93
|
+
export const conversationSummarySchema = z.object({
|
|
94
|
+
id: z.string().min(1),
|
|
95
|
+
agentKey: z.string().min(1),
|
|
96
|
+
title: z.string().optional(),
|
|
97
|
+
lastMessageAt: z.coerce.date(),
|
|
98
|
+
createdAt: z.coerce.date().optional(),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const conversationsQuerySchema = z.object({
|
|
102
|
+
limit: z.coerce.number().int().min(1).max(50).default(25),
|
|
103
|
+
/** Opaque cursor from the previous response’s `nextCursor`. */
|
|
104
|
+
cursor: z.string().min(1).optional(),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export type ConversationsQuery = z.infer<typeof conversationsQuerySchema>;
|
|
108
|
+
|
|
109
|
+
export const conversationsPageResponseSchema = z.object({
|
|
110
|
+
conversations: z.array(conversationSummarySchema),
|
|
111
|
+
hasMore: z.boolean(),
|
|
112
|
+
nextCursor: z.string().optional(),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/** @deprecated Use `conversationsPageResponseSchema` — same shape. */
|
|
116
|
+
export const conversationsListResponseSchema = conversationsPageResponseSchema;
|
|
117
|
+
|
|
118
|
+
export const createConversationBodySchema = z.object({
|
|
119
|
+
title: z.string().max(120).optional(),
|
|
120
|
+
agentKey: z.string().min(1).optional(),
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export type ConversationSummary = z.infer<typeof conversationSummarySchema>;
|
|
124
|
+
export type ConversationsPageResponse = z.infer<typeof conversationsPageResponseSchema>;
|
|
125
|
+
export type ConversationsListResponse = ConversationsPageResponse;
|
|
126
|
+
export type CreateConversationBody = z.infer<typeof createConversationBodySchema>;
|
|
127
|
+
|
|
128
|
+
export const deleteConversationResponseSchema = z.object({
|
|
129
|
+
deleted: z.literal(true),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export type DeleteConversationResponse = z.infer<typeof deleteConversationResponseSchema>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const createCreditCardInputSchema = z.object({
|
|
4
|
+
firstName: z.string().trim().min(1).max(80),
|
|
5
|
+
lastName: z.string().trim().min(1).max(80),
|
|
6
|
+
line1: z.string().trim().min(1).max(120),
|
|
7
|
+
line2: z.string().trim().max(120).optional(),
|
|
8
|
+
city: z.string().trim().min(1).max(80),
|
|
9
|
+
region: z.string().trim().min(1).max(80),
|
|
10
|
+
postalCode: z.string().trim().min(1).max(20),
|
|
11
|
+
countryCode: z
|
|
12
|
+
.string()
|
|
13
|
+
.trim()
|
|
14
|
+
.length(2)
|
|
15
|
+
.transform((c) => c.toUpperCase()),
|
|
16
|
+
cardLabel: z.string().trim().min(1).max(80).optional(),
|
|
17
|
+
currency: z
|
|
18
|
+
.string()
|
|
19
|
+
.trim()
|
|
20
|
+
.length(3)
|
|
21
|
+
.transform((c) => c.toUpperCase())
|
|
22
|
+
.optional(),
|
|
23
|
+
/** Opening balance in minor units (e.g. USD cents). */
|
|
24
|
+
initialBalanceCents: z.coerce.number().int().min(0).max(100_000_000).optional(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type CreateCreditCardInput = z.infer<typeof createCreditCardInputSchema>;
|
|
28
|
+
|
|
29
|
+
/** Persisted on the chat CTA row until the user submits the virtual-card billing form. */
|
|
30
|
+
export const creditCardFormCtaParamsSchema = z.object({
|
|
31
|
+
_creditCardForm: z.literal(true),
|
|
32
|
+
intro: z.string().max(2000).optional(),
|
|
33
|
+
defaultCurrency: z
|
|
34
|
+
.string()
|
|
35
|
+
.trim()
|
|
36
|
+
.length(3)
|
|
37
|
+
.transform((c) => c.toUpperCase())
|
|
38
|
+
.optional(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export type CreditCardFormCtaParams = z.infer<typeof creditCardFormCtaParamsSchema>;
|
|
42
|
+
|
|
43
|
+
export function isCreditCardFormCtaParams(v: unknown): v is CreditCardFormCtaParams {
|
|
44
|
+
return creditCardFormCtaParamsSchema.safeParse(v).success;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const creditCardPublicSchema = z.object({
|
|
48
|
+
id: z.string().min(1),
|
|
49
|
+
firstName: z.string(),
|
|
50
|
+
lastName: z.string(),
|
|
51
|
+
cardLabel: z.string().optional(),
|
|
52
|
+
line1: z.string(),
|
|
53
|
+
line2: z.string().optional(),
|
|
54
|
+
city: z.string(),
|
|
55
|
+
region: z.string(),
|
|
56
|
+
postalCode: z.string(),
|
|
57
|
+
countryCode: z.string(),
|
|
58
|
+
currency: z.string(),
|
|
59
|
+
balanceCents: z.number().int().nonnegative(),
|
|
60
|
+
last4: z.string(),
|
|
61
|
+
networkBrand: z.string(),
|
|
62
|
+
status: z.enum(["active", "frozen"]),
|
|
63
|
+
createdAt: z.coerce.date().optional(),
|
|
64
|
+
updatedAt: z.coerce.date().optional(),
|
|
65
|
+
/** Present on some `POST …/withdraw` responses when native 0G was sent from the treasury. */
|
|
66
|
+
lastWithdrawTxHash: z
|
|
67
|
+
.string()
|
|
68
|
+
.regex(/^0x[a-fA-F0-9]{64}$/)
|
|
69
|
+
.optional(),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export type CreditCardPublic = z.infer<typeof creditCardPublicSchema>;
|
|
73
|
+
|
|
74
|
+
/** Wallet-authenticated only; never included in list cards responses. */
|
|
75
|
+
export const creditCardSensitiveDetailsSchema = z.object({
|
|
76
|
+
cardId: z.string().min(1),
|
|
77
|
+
pan: z.string().regex(/^\d{16}$/),
|
|
78
|
+
expiryMonth: z.coerce.number().int().min(1).max(12),
|
|
79
|
+
expiryYear: z.coerce.number().int().min(2000).max(2100),
|
|
80
|
+
cvv: z.string().regex(/^\d{3,4}$/),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export type CreditCardSensitiveDetails = z.infer<
|
|
84
|
+
typeof creditCardSensitiveDetailsSchema
|
|
85
|
+
>;
|
|
86
|
+
|
|
87
|
+
export const creditCardsListResponseSchema = z.object({
|
|
88
|
+
cards: z.array(creditCardPublicSchema),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export type CreditCardsListResponse = z.infer<typeof creditCardsListResponseSchema>;
|
|
92
|
+
|
|
93
|
+
export const creditCardFundBodySchema = z
|
|
94
|
+
.object({
|
|
95
|
+
amountCents: z.coerce.number().int().min(1).max(100_000_000),
|
|
96
|
+
fundingTxHash: z
|
|
97
|
+
.string()
|
|
98
|
+
.regex(/^0x[a-fA-F0-9]{64}$/)
|
|
99
|
+
.optional(),
|
|
100
|
+
fundingChainId: z.coerce.number().int().positive().optional(),
|
|
101
|
+
})
|
|
102
|
+
.refine(
|
|
103
|
+
(d) =>
|
|
104
|
+
(d.fundingTxHash == null && d.fundingChainId == null) ||
|
|
105
|
+
(d.fundingTxHash != null && d.fundingChainId != null),
|
|
106
|
+
{
|
|
107
|
+
message:
|
|
108
|
+
"fundingTxHash and fundingChainId must both be provided or both omitted",
|
|
109
|
+
path: ["fundingTxHash"],
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
export type CreditCardFundBody = z.infer<typeof creditCardFundBodySchema>;
|
|
114
|
+
|
|
115
|
+
export const creditCardFundQuoteQuerySchema = z.object({
|
|
116
|
+
amountCents: z.coerce.number().int().min(1).max(100_000_000),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export type CreditCardFundQuoteQuery = z.infer<
|
|
120
|
+
typeof creditCardFundQuoteQuerySchema
|
|
121
|
+
>;
|
|
122
|
+
|
|
123
|
+
export const creditCardFundQuoteOffChainSchema = z.object({
|
|
124
|
+
onchainFundingRequired: z.literal(false),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export const creditCardFundQuoteOnChainSchema = z.object({
|
|
128
|
+
onchainFundingRequired: z.literal(true),
|
|
129
|
+
chainId: z.number().int(),
|
|
130
|
+
recipient: z.string().min(1),
|
|
131
|
+
minNativeWei: z.string().regex(/^\d+$/),
|
|
132
|
+
usdValue: z.number().finite().positive(),
|
|
133
|
+
nativeSymbol: z.string().min(1),
|
|
134
|
+
nativeDecimals: z.number().int().min(0).max(18),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export const creditCardFundQuoteResponseSchema = z.discriminatedUnion(
|
|
138
|
+
"onchainFundingRequired",
|
|
139
|
+
[creditCardFundQuoteOffChainSchema, creditCardFundQuoteOnChainSchema],
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
export type CreditCardFundQuoteResponse = z.infer<
|
|
143
|
+
typeof creditCardFundQuoteResponseSchema
|
|
144
|
+
>;
|
|
145
|
+
|
|
146
|
+
export const creditCardWithdrawBodySchema = z.object({
|
|
147
|
+
amountCents: z.coerce.number().int().min(1).max(100_000_000),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export type CreditCardWithdrawBody = z.infer<typeof creditCardWithdrawBodySchema>;
|
package/src/handlers.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Source of truth for backend handler ids implemented in
|
|
5
|
+
* `stardorm/backend/src/handlers/handlers.service.ts`. Keep in sync.
|
|
6
|
+
*/
|
|
7
|
+
export const HANDLER_ACTION_IDS = [
|
|
8
|
+
"generate_tax_report",
|
|
9
|
+
"create_x402_payment",
|
|
10
|
+
/** Fiat checkout via Stripe; webhook fulfills ERC-20 transfer from treasury key. */
|
|
11
|
+
"on_ramp_tokens",
|
|
12
|
+
/** Stripe Identity hosted verification for the signed-in wallet user. */
|
|
13
|
+
"complete_stripe_kyc",
|
|
14
|
+
/** Issue a virtual payment card record with billing profile and spend balance. */
|
|
15
|
+
"create_credit_card",
|
|
16
|
+
/** PDF + structured snapshot: payment requests, on-ramps, cards, KYC for this wallet. */
|
|
17
|
+
"generate_payment_invoice",
|
|
18
|
+
/** Summary report across payment requests, on-ramps, virtual cards, and KYC status. */
|
|
19
|
+
"generate_financial_activity_report",
|
|
20
|
+
/** Confirms a native (gas token) transfer draft; user signs in their wallet / Beam Send. */
|
|
21
|
+
"draft_native_transfer",
|
|
22
|
+
/** Confirms an ERC-20 transfer draft; user signs in their wallet / Beam Send. */
|
|
23
|
+
"draft_erc20_transfer",
|
|
24
|
+
/** Confirms an NFT (ERC-721 / ERC-1155) transfer draft; user signs in their wallet / Beam Send. */
|
|
25
|
+
"draft_nft_transfer",
|
|
26
|
+
] as const;
|
|
27
|
+
|
|
28
|
+
export type HandlerActionId = (typeof HANDLER_ACTION_IDS)[number];
|
|
29
|
+
|
|
30
|
+
export function isHandlerActionId(id: string): id is HandlerActionId {
|
|
31
|
+
return (HANDLER_ACTION_IDS as readonly string[]).includes(id);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const handlerActionIdSchema = z.enum(HANDLER_ACTION_IDS);
|
|
35
|
+
|
|
36
|
+
export const handlersListResponseSchema = z.object({
|
|
37
|
+
handlers: z.array(handlerActionIdSchema),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type HandlersListResponse = z.infer<typeof handlersListResponseSchema>;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export {
|
|
2
|
+
agentAvatarSchema,
|
|
3
|
+
agentCategorySchema,
|
|
4
|
+
agentSchema,
|
|
5
|
+
agentsListSchema,
|
|
6
|
+
skillHandleSchema,
|
|
7
|
+
type Agent,
|
|
8
|
+
type AgentCategory,
|
|
9
|
+
type SkillHandle,
|
|
10
|
+
} from "./agent.js";
|
|
11
|
+
export { catalogResponseSchema, type CatalogResponse } from "./catalog.js";
|
|
12
|
+
export { buildStardormCatalogResponse } from "./catalog-marketplace-response.js";
|
|
13
|
+
export {
|
|
14
|
+
resolveStardormAgentKey,
|
|
15
|
+
resolveStardormChainAgentId,
|
|
16
|
+
} from "./catalog-build.js";
|
|
17
|
+
export {
|
|
18
|
+
authChallengeBodySchema,
|
|
19
|
+
authChallengeResponseSchema,
|
|
20
|
+
authVerifyBodySchema,
|
|
21
|
+
authVerifyResponseSchema,
|
|
22
|
+
authMeResponseSchema,
|
|
23
|
+
type AuthChallengeBody,
|
|
24
|
+
type AuthChallengeResponse,
|
|
25
|
+
type AuthVerifyBody,
|
|
26
|
+
type AuthVerifyResponse,
|
|
27
|
+
type AuthMeResponse,
|
|
28
|
+
} from "./auth.js";
|
|
29
|
+
export {
|
|
30
|
+
HANDLER_ACTION_IDS,
|
|
31
|
+
handlerActionIdSchema,
|
|
32
|
+
handlersListResponseSchema,
|
|
33
|
+
isHandlerActionId,
|
|
34
|
+
type HandlerActionId,
|
|
35
|
+
type HandlersListResponse,
|
|
36
|
+
} from "./handlers.js";
|
|
37
|
+
export {
|
|
38
|
+
storageUploadBodySchema,
|
|
39
|
+
storageUploadResponseSchema,
|
|
40
|
+
type StorageUploadBody,
|
|
41
|
+
type StorageUploadResponse,
|
|
42
|
+
} from "./storage.js";
|
|
43
|
+
export {
|
|
44
|
+
publicUserSchema,
|
|
45
|
+
updateUserBodySchema,
|
|
46
|
+
userUploadResultSchema,
|
|
47
|
+
executeHandlerBodySchema,
|
|
48
|
+
executeHandlerResponseSchema,
|
|
49
|
+
userPreferencesSchema,
|
|
50
|
+
userAvatarPresetSchema,
|
|
51
|
+
type UserAvatarPreset,
|
|
52
|
+
type PublicUser,
|
|
53
|
+
type UpdateUserBody,
|
|
54
|
+
type UserUploadResult,
|
|
55
|
+
type ExecuteHandlerBody,
|
|
56
|
+
type ExecuteHandlerResponse,
|
|
57
|
+
} from "./user.js";
|
|
58
|
+
export {
|
|
59
|
+
stardormChatJsonBodySchema,
|
|
60
|
+
stardormChatStructuredSchema,
|
|
61
|
+
stardormChatComputeSchema,
|
|
62
|
+
stardormChatRichRowSchema,
|
|
63
|
+
stardormChatRichBlockSchema,
|
|
64
|
+
x402SupportedAssetSchema,
|
|
65
|
+
stardormChatSuccessSchema,
|
|
66
|
+
stardormChatAttachmentSchema,
|
|
67
|
+
stardormChatClientErrorSchema,
|
|
68
|
+
stardormChatClientResultSchema,
|
|
69
|
+
type StardormChatJsonBody,
|
|
70
|
+
type StardormChatSuccess,
|
|
71
|
+
type StardormChatClientResult,
|
|
72
|
+
type StardormChatRichBlock,
|
|
73
|
+
type StardormChatAttachment,
|
|
74
|
+
type X402SupportedAsset,
|
|
75
|
+
} from "./chat-api.js";
|
|
76
|
+
export {
|
|
77
|
+
chatHistoryQuerySchema,
|
|
78
|
+
chatHistoryAttachmentSchema,
|
|
79
|
+
chatHistoryHandlerCtaSchema,
|
|
80
|
+
chatFollowUpSchema,
|
|
81
|
+
chatHistoryMessageSchema,
|
|
82
|
+
chatHistoryResponseSchema,
|
|
83
|
+
conversationSummarySchema,
|
|
84
|
+
conversationsQuerySchema,
|
|
85
|
+
conversationsPageResponseSchema,
|
|
86
|
+
conversationsListResponseSchema,
|
|
87
|
+
createConversationBodySchema,
|
|
88
|
+
deleteConversationResponseSchema,
|
|
89
|
+
type ChatHistoryQuery,
|
|
90
|
+
type ChatHistoryAttachment,
|
|
91
|
+
type ChatFollowUp,
|
|
92
|
+
type ChatHistoryMessage,
|
|
93
|
+
type ChatHistoryResponse,
|
|
94
|
+
type ConversationSummary,
|
|
95
|
+
type ConversationsQuery,
|
|
96
|
+
type ConversationsPageResponse,
|
|
97
|
+
type ConversationsListResponse,
|
|
98
|
+
type CreateConversationBody,
|
|
99
|
+
type DeleteConversationResponse,
|
|
100
|
+
} from "./conversation.js";
|
|
101
|
+
export {
|
|
102
|
+
agentOnchainFeedbackItemSchema,
|
|
103
|
+
agentFeedbacksQuerySchema,
|
|
104
|
+
agentFeedbacksPageResponseSchema,
|
|
105
|
+
type AgentOnchainFeedbackItem,
|
|
106
|
+
type AgentFeedbacksQuery,
|
|
107
|
+
type AgentFeedbacksPageResponse,
|
|
108
|
+
} from "./agent-feedbacks.js";
|
|
109
|
+
export {
|
|
110
|
+
paymentRequestTypeSchema,
|
|
111
|
+
paymentRequestStatusSchema,
|
|
112
|
+
paymentSettlementBodySchema,
|
|
113
|
+
publicPaymentRequestSchema,
|
|
114
|
+
mePaymentRequestsQuerySchema,
|
|
115
|
+
paymentRequestsListResponseSchema,
|
|
116
|
+
type PaymentSettlementBody,
|
|
117
|
+
type PublicPaymentRequest,
|
|
118
|
+
type MePaymentRequestsQuery,
|
|
119
|
+
type PaymentRequestsListResponse,
|
|
120
|
+
} from "./payment-request.js";
|
|
121
|
+
export {
|
|
122
|
+
onRampFormCtaParamsSchema,
|
|
123
|
+
onRampFormNetworkOptionSchema,
|
|
124
|
+
onRampTokensInputSchema,
|
|
125
|
+
onRampRecordSchema,
|
|
126
|
+
onRampRecordStatusSchema,
|
|
127
|
+
meOnRampsQuerySchema,
|
|
128
|
+
onRampsListResponseSchema,
|
|
129
|
+
isOnRampFormCtaParams,
|
|
130
|
+
type OnRampFormCtaParams,
|
|
131
|
+
type OnRampTokensInput,
|
|
132
|
+
type OnRampRecord,
|
|
133
|
+
type OnRampRecordStatus,
|
|
134
|
+
type MeOnRampsQuery,
|
|
135
|
+
type OnRampsListResponse,
|
|
136
|
+
} from "./on-ramp.js";
|
|
137
|
+
export {
|
|
138
|
+
stripeKycInputSchema,
|
|
139
|
+
userKycStatusSchema,
|
|
140
|
+
userKycStatusDocumentSchema,
|
|
141
|
+
type StripeKycInput,
|
|
142
|
+
type UserKycStatus,
|
|
143
|
+
type UserKycStatusDocument,
|
|
144
|
+
} from "./kyc.js";
|
|
145
|
+
export {
|
|
146
|
+
createCreditCardInputSchema,
|
|
147
|
+
creditCardFormCtaParamsSchema,
|
|
148
|
+
isCreditCardFormCtaParams,
|
|
149
|
+
creditCardPublicSchema,
|
|
150
|
+
creditCardSensitiveDetailsSchema,
|
|
151
|
+
creditCardsListResponseSchema,
|
|
152
|
+
creditCardFundBodySchema,
|
|
153
|
+
creditCardFundQuoteQuerySchema,
|
|
154
|
+
creditCardFundQuoteOffChainSchema,
|
|
155
|
+
creditCardFundQuoteOnChainSchema,
|
|
156
|
+
creditCardFundQuoteResponseSchema,
|
|
157
|
+
creditCardWithdrawBodySchema,
|
|
158
|
+
type CreateCreditCardInput,
|
|
159
|
+
type CreditCardFormCtaParams,
|
|
160
|
+
type CreditCardPublic,
|
|
161
|
+
type CreditCardSensitiveDetails,
|
|
162
|
+
type CreditCardsListResponse,
|
|
163
|
+
type CreditCardFundBody,
|
|
164
|
+
type CreditCardFundQuoteQuery,
|
|
165
|
+
type CreditCardFundQuoteResponse,
|
|
166
|
+
type CreditCardWithdrawBody,
|
|
167
|
+
} from "./credit-card.js";
|
|
168
|
+
export {
|
|
169
|
+
billingDatePartSchema,
|
|
170
|
+
billingDatePartToUtc,
|
|
171
|
+
billingRangeEndOfDay,
|
|
172
|
+
billingPeriodBounds,
|
|
173
|
+
generatePaymentInvoiceInputSchema,
|
|
174
|
+
generateFinancialActivityReportInputSchema,
|
|
175
|
+
type BillingDatePart,
|
|
176
|
+
type GeneratePaymentInvoiceInput,
|
|
177
|
+
type GenerateFinancialActivityReportInput,
|
|
178
|
+
} from "./billing-handlers.js";
|
|
179
|
+
export {
|
|
180
|
+
ISO_3166_1_ALPHA2_CODES,
|
|
181
|
+
isIso3166Alpha2,
|
|
182
|
+
isoCountryDisplayName,
|
|
183
|
+
} from "./iso-3166-1-alpha2.js";
|
|
184
|
+
export { taxRateForCountry } from "./tax-rate-for-country.js";
|
|
185
|
+
export {
|
|
186
|
+
draftNativeTransferInputSchema,
|
|
187
|
+
draftErc20TransferInputSchema,
|
|
188
|
+
draftNftTransferInputSchema,
|
|
189
|
+
type DraftNativeTransferInput,
|
|
190
|
+
type DraftErc20TransferInput,
|
|
191
|
+
type DraftNftTransferInput,
|
|
192
|
+
} from "./transfer-drafts.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISO 3166-1 alpha-2 codes (officially assigned), sourced from the slim-2 dataset
|
|
3
|
+
* (lukes/ISO-3166-Countries-with-Regional-Codes). UK is accepted as an alias for GB at validation boundaries.
|
|
4
|
+
*/
|
|
5
|
+
const ISO_3166_1_ALPHA2_CODES_RAW =
|
|
6
|
+
"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";
|
|
7
|
+
|
|
8
|
+
export const ISO_3166_1_ALPHA2_CODES: readonly string[] = Object.freeze(
|
|
9
|
+
ISO_3166_1_ALPHA2_CODES_RAW.split(/\s+/),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const ISO_3166_1_ALPHA2_SET = new Set(ISO_3166_1_ALPHA2_CODES);
|
|
13
|
+
|
|
14
|
+
export function isIso3166Alpha2(code: string): boolean {
|
|
15
|
+
const c = code.length === 2 ? code.toUpperCase() : "";
|
|
16
|
+
return ISO_3166_1_ALPHA2_SET.has(c);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isoCountryDisplayName(
|
|
20
|
+
code: string,
|
|
21
|
+
locale: string | string[] = "en",
|
|
22
|
+
): string {
|
|
23
|
+
const c = code.length === 2 ? code.toUpperCase() : code;
|
|
24
|
+
try {
|
|
25
|
+
const dn = new Intl.DisplayNames(locale, { type: "region" });
|
|
26
|
+
return dn.of(c) ?? c;
|
|
27
|
+
} catch {
|
|
28
|
+
return c;
|
|
29
|
+
}
|
|
30
|
+
}
|