@skillzmarket/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +313 -0
- package/dist/client.d.ts +18 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +118 -0
- package/dist/client.js.map +1 -0
- package/dist/creator/auth.d.ts +50 -0
- package/dist/creator/auth.d.ts.map +1 -0
- package/dist/creator/auth.js +114 -0
- package/dist/creator/auth.js.map +1 -0
- package/dist/creator/index.d.ts +27 -0
- package/dist/creator/index.d.ts.map +1 -0
- package/dist/creator/index.js +26 -0
- package/dist/creator/index.js.map +1 -0
- package/dist/creator/payment.d.ts +20 -0
- package/dist/creator/payment.d.ts.map +1 -0
- package/dist/creator/payment.js +46 -0
- package/dist/creator/payment.js.map +1 -0
- package/dist/creator/register.d.ts +35 -0
- package/dist/creator/register.d.ts.map +1 -0
- package/dist/creator/register.js +165 -0
- package/dist/creator/register.js.map +1 -0
- package/dist/creator/serve.d.ts +19 -0
- package/dist/creator/serve.d.ts.map +1 -0
- package/dist/creator/serve.js +163 -0
- package/dist/creator/serve.js.map +1 -0
- package/dist/creator/skill.d.ts +20 -0
- package/dist/creator/skill.d.ts.map +1 -0
- package/dist/creator/skill.js +40 -0
- package/dist/creator/skill.js.map +1 -0
- package/dist/creator/types.d.ts +173 -0
- package/dist/creator/types.d.ts.map +1 -0
- package/dist/creator/types.js +2 -0
- package/dist/creator/types.js.map +1 -0
- package/dist/creator/utils/price.d.ts +19 -0
- package/dist/creator/utils/price.d.ts.map +1 -0
- package/dist/creator/utils/price.js +62 -0
- package/dist/creator/utils/price.js.map +1 -0
- package/dist/creator/utils/wallet.d.ts +22 -0
- package/dist/creator/utils/wallet.d.ts.map +1 -0
- package/dist/creator/utils/wallet.js +45 -0
- package/dist/creator/utils/wallet.js.map +1 -0
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +40 -0
- package/dist/discovery.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/payment.d.ts +20 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/payment.js +34 -0
- package/dist/payment.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* JSON Schema type for describing skill input/output
|
|
4
|
+
*/
|
|
5
|
+
export interface JsonSchema {
|
|
6
|
+
type: string;
|
|
7
|
+
properties?: Record<string, JsonSchema>;
|
|
8
|
+
required?: string[];
|
|
9
|
+
items?: JsonSchema;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for defining a skill
|
|
14
|
+
*/
|
|
15
|
+
export interface SkillOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Price per call in human-friendly format.
|
|
18
|
+
* Examples: '$0.001', '0.005 USDC', '0.01'
|
|
19
|
+
*/
|
|
20
|
+
price: string;
|
|
21
|
+
/**
|
|
22
|
+
* Description of what the skill does
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum timeout in milliseconds (default: 60000)
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
/**
|
|
30
|
+
* JSON Schema describing the expected input format
|
|
31
|
+
*/
|
|
32
|
+
inputSchema?: JsonSchema;
|
|
33
|
+
/**
|
|
34
|
+
* JSON Schema describing the output format
|
|
35
|
+
*/
|
|
36
|
+
outputSchema?: JsonSchema;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parsed price information
|
|
40
|
+
*/
|
|
41
|
+
export interface ParsedPrice {
|
|
42
|
+
/** Amount as a decimal string (e.g., '0.001') */
|
|
43
|
+
amount: string;
|
|
44
|
+
/** Currency (currently only 'USDC' supported) */
|
|
45
|
+
currency: 'USDC';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Handler function for a skill
|
|
49
|
+
*/
|
|
50
|
+
export type SkillHandler<TInput = unknown, TOutput = unknown> = (input: TInput) => Promise<TOutput>;
|
|
51
|
+
/**
|
|
52
|
+
* A defined skill ready to be served
|
|
53
|
+
*/
|
|
54
|
+
export interface SkillDefinition<TInput = unknown, TOutput = unknown> {
|
|
55
|
+
options: SkillOptions;
|
|
56
|
+
handler: SkillHandler<TInput, TOutput>;
|
|
57
|
+
parsedPrice: ParsedPrice;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Map of skill names to their definitions
|
|
61
|
+
* Uses `any` for type parameters to allow mixing skills with different input/output types
|
|
62
|
+
*/
|
|
63
|
+
export type SkillsMap = Record<string, SkillDefinition<any, any>>;
|
|
64
|
+
/**
|
|
65
|
+
* Options for skill registration
|
|
66
|
+
*/
|
|
67
|
+
export interface RegistrationOptions {
|
|
68
|
+
/**
|
|
69
|
+
* API URL for the Skillz Market registry.
|
|
70
|
+
* Default: 'https://api.skillz.market'
|
|
71
|
+
*/
|
|
72
|
+
apiUrl?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Public endpoint URL where the skill server is accessible.
|
|
75
|
+
* This is required for registration.
|
|
76
|
+
*/
|
|
77
|
+
endpoint: string;
|
|
78
|
+
/**
|
|
79
|
+
* Whether registration is enabled.
|
|
80
|
+
* Default: true
|
|
81
|
+
*/
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Error handling mode.
|
|
85
|
+
* - 'throw': Throw an error if registration fails
|
|
86
|
+
* - 'warn': Log a warning if registration fails (default)
|
|
87
|
+
* - 'silent': Silently ignore registration failures
|
|
88
|
+
*/
|
|
89
|
+
onError?: 'throw' | 'warn' | 'silent';
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Result of registering a skill
|
|
93
|
+
*/
|
|
94
|
+
export interface RegistrationResult {
|
|
95
|
+
/** Name of the skill */
|
|
96
|
+
name: string;
|
|
97
|
+
/** Whether registration was successful */
|
|
98
|
+
success: boolean;
|
|
99
|
+
/** Slug assigned by the registry (if successful) */
|
|
100
|
+
slug?: string;
|
|
101
|
+
/** Error message (if failed) */
|
|
102
|
+
error?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Options for the serve function
|
|
106
|
+
*/
|
|
107
|
+
export interface ServeOptions {
|
|
108
|
+
/**
|
|
109
|
+
* Port to listen on (default: 3002)
|
|
110
|
+
*/
|
|
111
|
+
port?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Wallet private key for receiving payments.
|
|
114
|
+
* Falls back to SKILLZ_WALLET_KEY environment variable.
|
|
115
|
+
*/
|
|
116
|
+
wallet?: Hex;
|
|
117
|
+
/**
|
|
118
|
+
* Network identifier for x402 payments.
|
|
119
|
+
* Default: 'eip155:8453' (Base mainnet)
|
|
120
|
+
*/
|
|
121
|
+
network?: `${string}:${string}`;
|
|
122
|
+
/**
|
|
123
|
+
* Facilitator URL for x402.
|
|
124
|
+
* Default: 'https://x402.dexter.cash'
|
|
125
|
+
*/
|
|
126
|
+
facilitatorUrl?: string;
|
|
127
|
+
/**
|
|
128
|
+
* App name shown in payment prompts.
|
|
129
|
+
* Default: 'Skillz Market Skill'
|
|
130
|
+
*/
|
|
131
|
+
appName?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Callback when a skill is called
|
|
134
|
+
*/
|
|
135
|
+
onCall?: (skillName: string, input: unknown) => void;
|
|
136
|
+
/**
|
|
137
|
+
* Callback when an error occurs
|
|
138
|
+
*/
|
|
139
|
+
onError?: (skillName: string, error: Error) => void;
|
|
140
|
+
/**
|
|
141
|
+
* Registration options for auto-registering skills with the Skillz Market registry.
|
|
142
|
+
* If provided, skills will be registered after the server starts.
|
|
143
|
+
*/
|
|
144
|
+
register?: RegistrationOptions;
|
|
145
|
+
/**
|
|
146
|
+
* Whether to track skill calls to Skillz Market analytics.
|
|
147
|
+
* Default: true
|
|
148
|
+
*/
|
|
149
|
+
trackCalls?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* API URL for analytics tracking.
|
|
152
|
+
* Default: 'https://api.skillz.market'
|
|
153
|
+
*/
|
|
154
|
+
apiUrl?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* x402 protected route configuration
|
|
158
|
+
*/
|
|
159
|
+
export interface ProtectedRoute {
|
|
160
|
+
accepts: {
|
|
161
|
+
scheme: 'exact';
|
|
162
|
+
price: string;
|
|
163
|
+
network: `${string}:${string}`;
|
|
164
|
+
payTo: string;
|
|
165
|
+
maxTimeoutSeconds: number;
|
|
166
|
+
};
|
|
167
|
+
description: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Map of route patterns to their x402 configuration
|
|
171
|
+
*/
|
|
172
|
+
export type ProtectedRoutes = Record<`${string} ${string}`, ProtectedRoute>;
|
|
173
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/creator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,E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
import type { ParsedPrice } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a human-friendly price string into structured price info.
|
|
4
|
+
*
|
|
5
|
+
* Supported formats:
|
|
6
|
+
* - '$0.001' → { amount: '0.001', currency: 'USDC' }
|
|
7
|
+
* - '0.005 USDC' → { amount: '0.005', currency: 'USDC' }
|
|
8
|
+
* - '0.01' → { amount: '0.01', currency: 'USDC' }
|
|
9
|
+
*
|
|
10
|
+
* @param price - Human-friendly price string
|
|
11
|
+
* @returns Parsed price with amount and currency
|
|
12
|
+
* @throws Error if price format is invalid
|
|
13
|
+
*/
|
|
14
|
+
export declare function parsePrice(price: string): ParsedPrice;
|
|
15
|
+
/**
|
|
16
|
+
* Format a parsed price back to x402 format (e.g., '$0.001')
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatPriceForX402(parsed: ParsedPrice): string;
|
|
19
|
+
//# sourceMappingURL=price.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../src/creator/utils/price.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAgCrD;AAwBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE9D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a human-friendly price string into structured price info.
|
|
3
|
+
*
|
|
4
|
+
* Supported formats:
|
|
5
|
+
* - '$0.001' → { amount: '0.001', currency: 'USDC' }
|
|
6
|
+
* - '0.005 USDC' → { amount: '0.005', currency: 'USDC' }
|
|
7
|
+
* - '0.01' → { amount: '0.01', currency: 'USDC' }
|
|
8
|
+
*
|
|
9
|
+
* @param price - Human-friendly price string
|
|
10
|
+
* @returns Parsed price with amount and currency
|
|
11
|
+
* @throws Error if price format is invalid
|
|
12
|
+
*/
|
|
13
|
+
export function parsePrice(price) {
|
|
14
|
+
const trimmed = price.trim();
|
|
15
|
+
// Format: $0.001
|
|
16
|
+
if (trimmed.startsWith('$')) {
|
|
17
|
+
const amount = trimmed.slice(1).trim();
|
|
18
|
+
// Use strict decimal regex to prevent malformed values like "1.2.3"
|
|
19
|
+
if (!/^\d+(?:\.\d+)?$/.test(amount)) {
|
|
20
|
+
throw new Error(`Invalid price amount: "${amount}" is not a valid decimal number`);
|
|
21
|
+
}
|
|
22
|
+
validateAmount(amount);
|
|
23
|
+
return { amount, currency: 'USDC' };
|
|
24
|
+
}
|
|
25
|
+
// Format: 0.005 USDC (with proper decimal validation)
|
|
26
|
+
const usdcMatch = trimmed.match(/^(\d+(?:\.\d+)?)\s*USDC$/i);
|
|
27
|
+
if (usdcMatch?.[1]) {
|
|
28
|
+
const amount = usdcMatch[1];
|
|
29
|
+
validateAmount(amount);
|
|
30
|
+
return { amount, currency: 'USDC' };
|
|
31
|
+
}
|
|
32
|
+
// Format: just a number (assume USDC) with proper decimal validation
|
|
33
|
+
if (/^\d+(?:\.\d+)?$/.test(trimmed)) {
|
|
34
|
+
validateAmount(trimmed);
|
|
35
|
+
return { amount: trimmed, currency: 'USDC' };
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`Invalid price format: "${price}". ` +
|
|
38
|
+
`Expected formats: '$0.001', '0.005 USDC', or '0.01'`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Validate that an amount is a valid positive number
|
|
42
|
+
*/
|
|
43
|
+
function validateAmount(amount) {
|
|
44
|
+
const num = parseFloat(amount);
|
|
45
|
+
if (isNaN(num)) {
|
|
46
|
+
throw new Error(`Invalid price amount: "${amount}" is not a number`);
|
|
47
|
+
}
|
|
48
|
+
if (num <= 0) {
|
|
49
|
+
throw new Error(`Invalid price amount: "${amount}" must be positive`);
|
|
50
|
+
}
|
|
51
|
+
if (num > 1000) {
|
|
52
|
+
throw new Error(`Invalid price amount: "${amount}" seems too high. ` +
|
|
53
|
+
`Did you mean $${amount}?`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Format a parsed price back to x402 format (e.g., '$0.001')
|
|
58
|
+
*/
|
|
59
|
+
export function formatPriceForX402(parsed) {
|
|
60
|
+
return `$${parsed.amount}`;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/creator/utils/price.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE7B,iBAAiB;IACjB,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACvC,oEAAoE;QACpE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,iCAAiC,CAAC,CAAC;QACrF,CAAC;QACD,cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACtC,CAAC;IAED,sDAAsD;IACtD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC7D,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC5B,cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACtC,CAAC;IAED,qEAAqE;IACrE,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,cAAc,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC/C,CAAC;IAED,MAAM,IAAI,KAAK,CACb,0BAA0B,KAAK,KAAK;QAClC,qDAAqD,CACxD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,MAAc;IACpC,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAE/B,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,mBAAmB,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,oBAAoB,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,0BAA0B,MAAM,oBAAoB;YAClD,iBAAiB,MAAM,GAAG,CAC7B,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAmB;IACpD,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Hex, Address } from 'viem';
|
|
2
|
+
import type { PrivateKeyAccount } from 'viem/accounts';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve wallet configuration from options or environment.
|
|
5
|
+
*
|
|
6
|
+
* Priority:
|
|
7
|
+
* 1. Explicit wallet option
|
|
8
|
+
* 2. SKILLZ_WALLET_KEY environment variable
|
|
9
|
+
*
|
|
10
|
+
* @param wallet - Optional explicit wallet private key
|
|
11
|
+
* @returns Object with account and address
|
|
12
|
+
* @throws Error if no wallet is configured
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveWallet(wallet?: Hex): {
|
|
15
|
+
account: PrivateKeyAccount;
|
|
16
|
+
address: Address;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Mask a private key for safe logging (show first 6 and last 4 chars)
|
|
20
|
+
*/
|
|
21
|
+
export declare function maskPrivateKey(key: Hex): string;
|
|
22
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/creator/utils/wallet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG;IAC3C,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;CAClB,CA8BA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAK/C"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve wallet configuration from options or environment.
|
|
4
|
+
*
|
|
5
|
+
* Priority:
|
|
6
|
+
* 1. Explicit wallet option
|
|
7
|
+
* 2. SKILLZ_WALLET_KEY environment variable
|
|
8
|
+
*
|
|
9
|
+
* @param wallet - Optional explicit wallet private key
|
|
10
|
+
* @returns Object with account and address
|
|
11
|
+
* @throws Error if no wallet is configured
|
|
12
|
+
*/
|
|
13
|
+
export function resolveWallet(wallet) {
|
|
14
|
+
const privateKey = wallet ?? process.env.SKILLZ_WALLET_KEY;
|
|
15
|
+
if (!privateKey) {
|
|
16
|
+
throw new Error('No wallet configured. Either:\n' +
|
|
17
|
+
'1. Pass `wallet` option to serve(): serve({ skills }, { wallet: "0x..." })\n' +
|
|
18
|
+
'2. Set SKILLZ_WALLET_KEY environment variable\n\n' +
|
|
19
|
+
'The wallet receives payments from skill calls.');
|
|
20
|
+
}
|
|
21
|
+
if (!privateKey.startsWith('0x')) {
|
|
22
|
+
throw new Error('Invalid wallet format. Private key must start with "0x".\n' +
|
|
23
|
+
'Example: 0x1234567890abcdef...');
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const account = privateKeyToAccount(privateKey);
|
|
27
|
+
return {
|
|
28
|
+
account,
|
|
29
|
+
address: account.address,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new Error(`Invalid wallet private key: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Mask a private key for safe logging (show first 6 and last 4 chars)
|
|
38
|
+
*/
|
|
39
|
+
export function maskPrivateKey(key) {
|
|
40
|
+
if (key.length < 20) {
|
|
41
|
+
return '0x****';
|
|
42
|
+
}
|
|
43
|
+
return `${key.slice(0, 6)}...${key.slice(-4)}`;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/creator/utils/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,MAAY;IAIxC,MAAM,UAAU,GAAG,MAAM,IAAK,OAAO,CAAC,GAAG,CAAC,iBAAqC,CAAC;IAEhF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,iCAAiC;YAC/B,8EAA8E;YAC9E,mDAAmD;YACnD,gDAAgD,CACnD,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,4DAA4D;YAC1D,gCAAgC,CACnC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAChD,OAAO;YACL,OAAO;YACP,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAC1F,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,GAAQ;IACrC,IAAI,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACpB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Skill, Creator, Review, SearchFilters } from './types.js';
|
|
2
|
+
export declare class DiscoveryClient {
|
|
3
|
+
private apiUrl;
|
|
4
|
+
constructor(apiUrl: string);
|
|
5
|
+
search(query: string, filters?: SearchFilters): Promise<Skill[]>;
|
|
6
|
+
getSkill(slug: string): Promise<Skill>;
|
|
7
|
+
getCreator(address: string): Promise<Creator>;
|
|
8
|
+
getReviews(skillSlug: string): Promise<Review[]>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAExE,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE5B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAYhE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAMtC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM7C,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAKvD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class DiscoveryClient {
|
|
2
|
+
apiUrl;
|
|
3
|
+
constructor(apiUrl) {
|
|
4
|
+
this.apiUrl = apiUrl;
|
|
5
|
+
}
|
|
6
|
+
async search(query, filters) {
|
|
7
|
+
const params = new URLSearchParams({ q: query });
|
|
8
|
+
if (filters?.category)
|
|
9
|
+
params.set('category', filters.category);
|
|
10
|
+
if (filters?.minPrice)
|
|
11
|
+
params.set('minPrice', filters.minPrice);
|
|
12
|
+
if (filters?.maxPrice)
|
|
13
|
+
params.set('maxPrice', filters.maxPrice);
|
|
14
|
+
if (filters?.creator)
|
|
15
|
+
params.set('creator', filters.creator);
|
|
16
|
+
const res = await fetch(`${this.apiUrl}/skills?${params}`);
|
|
17
|
+
if (!res.ok)
|
|
18
|
+
throw new Error(`Search failed: ${res.statusText}`);
|
|
19
|
+
return res.json();
|
|
20
|
+
}
|
|
21
|
+
async getSkill(slug) {
|
|
22
|
+
const res = await fetch(`${this.apiUrl}/skills/${slug}`);
|
|
23
|
+
if (!res.ok)
|
|
24
|
+
throw new Error(`Skill not found: ${slug}`);
|
|
25
|
+
return res.json();
|
|
26
|
+
}
|
|
27
|
+
async getCreator(address) {
|
|
28
|
+
const res = await fetch(`${this.apiUrl}/creators/${address}`);
|
|
29
|
+
if (!res.ok)
|
|
30
|
+
throw new Error(`Creator not found: ${address}`);
|
|
31
|
+
return res.json();
|
|
32
|
+
}
|
|
33
|
+
async getReviews(skillSlug) {
|
|
34
|
+
const res = await fetch(`${this.apiUrl}/skills/${skillSlug}/reviews`);
|
|
35
|
+
if (!res.ok)
|
|
36
|
+
throw new Error(`Failed to get reviews`);
|
|
37
|
+
return res.json();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAEtC,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,OAAuB;QACjD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACjD,IAAI,OAAO,EAAE,QAAQ;YAAE,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,OAAO,EAAE,QAAQ;YAAE,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,OAAO,EAAE,QAAQ;YAAE,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,OAAO,EAAE,OAAO;YAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE7D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,WAAW,MAAM,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACjE,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,WAAW,IAAI,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;QACzD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,aAAa,OAAO,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAC;QAC9D,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,SAAiB;QAChC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,WAAW,SAAS,UAAU,CAAC,CAAC;QACtE,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACtD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { SkillzMarket } from './client.js';
|
|
2
|
+
export { DiscoveryClient } from './discovery.js';
|
|
3
|
+
export { createPaymentFetch, resolveAccount, getWalletAddress, DEFAULT_NETWORK } from './payment.js';
|
|
4
|
+
export type { Skill, Creator, Review, SearchFilters, SkillzMarketOptions, WalletConfig, } from './types.js';
|
|
5
|
+
export type { SkillOptions, ParsedPrice } from './creator/types.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACrG,YAAY,EACV,KAAK,EACL,OAAO,EACP,MAAM,EACN,aAAa,EACb,mBAAmB,EACnB,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type PrivateKeyAccount } from 'viem/accounts';
|
|
2
|
+
import type { WalletConfig } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Default network for x402 payments (Base mainnet).
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_NETWORK: `${string}:${string}`;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a WalletConfig to a PrivateKeyAccount.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveAccount(walletConfig: WalletConfig): PrivateKeyAccount;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a fetch function that automatically handles x402 payments.
|
|
13
|
+
* Uses the official x402 registration pattern with wildcard network support.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createPaymentFetch(walletConfig: WalletConfig, _network?: `${string}:${string}`): typeof fetch;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the wallet address from a WalletConfig.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getWalletAddress(walletConfig: WalletConfig): string;
|
|
20
|
+
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,GAAG,MAAM,IAAI,MAAM,EAAkB,CAAC;AAEpE;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,YAAY,GAAG,iBAAiB,CAK5E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,YAAY,EAC1B,QAAQ,GAAE,GAAG,MAAM,IAAI,MAAM,EAAoB,GAChD,OAAO,KAAK,CAOd;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAGnE"}
|
package/dist/payment.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { x402Client, wrapFetchWithPayment } from '@x402/fetch';
|
|
2
|
+
import { registerExactEvmScheme } from '@x402/evm/exact/client';
|
|
3
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
|
+
/**
|
|
5
|
+
* Default network for x402 payments (Base mainnet).
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_NETWORK = 'eip155:8453';
|
|
8
|
+
/**
|
|
9
|
+
* Converts a WalletConfig to a PrivateKeyAccount.
|
|
10
|
+
*/
|
|
11
|
+
export function resolveAccount(walletConfig) {
|
|
12
|
+
if (typeof walletConfig === 'string') {
|
|
13
|
+
return privateKeyToAccount(walletConfig);
|
|
14
|
+
}
|
|
15
|
+
return walletConfig;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a fetch function that automatically handles x402 payments.
|
|
19
|
+
* Uses the official x402 registration pattern with wildcard network support.
|
|
20
|
+
*/
|
|
21
|
+
export function createPaymentFetch(walletConfig, _network = DEFAULT_NETWORK) {
|
|
22
|
+
const account = resolveAccount(walletConfig);
|
|
23
|
+
const client = new x402Client();
|
|
24
|
+
registerExactEvmScheme(client, { signer: account });
|
|
25
|
+
return wrapFetchWithPayment(fetch, client);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets the wallet address from a WalletConfig.
|
|
29
|
+
*/
|
|
30
|
+
export function getWalletAddress(walletConfig) {
|
|
31
|
+
const account = resolveAccount(walletConfig);
|
|
32
|
+
return account.address;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAA0B,MAAM,eAAe,CAAC;AAI5E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA0B,aAAa,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,YAA0B;IACvD,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,mBAAmB,CAAC,YAAmB,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,YAAiC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,YAA0B,EAC1B,WAAkC,eAAe;IAEjD,MAAM,OAAO,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAE7C,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAChC,sBAAsB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAEpD,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,YAA0B;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface Skill {
|
|
2
|
+
id: string;
|
|
3
|
+
slug: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string | null;
|
|
6
|
+
price: string;
|
|
7
|
+
currency: string;
|
|
8
|
+
endpoint: string;
|
|
9
|
+
inputSchema: Record<string, unknown> | null;
|
|
10
|
+
outputSchema: Record<string, unknown> | null;
|
|
11
|
+
paymentAddress: string;
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
creatorId: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Creator {
|
|
18
|
+
id: string;
|
|
19
|
+
walletAddress: string;
|
|
20
|
+
name: string | null;
|
|
21
|
+
avatar: string | null;
|
|
22
|
+
bio: string | null;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
}
|
|
25
|
+
export interface Review {
|
|
26
|
+
id: string;
|
|
27
|
+
skillId: string;
|
|
28
|
+
consumerAddress: string;
|
|
29
|
+
score: number;
|
|
30
|
+
comment: string | null;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
}
|
|
33
|
+
export interface SearchFilters {
|
|
34
|
+
category?: string;
|
|
35
|
+
minPrice?: string;
|
|
36
|
+
maxPrice?: string;
|
|
37
|
+
creator?: string;
|
|
38
|
+
}
|
|
39
|
+
import type { Hex } from 'viem';
|
|
40
|
+
import type { PrivateKeyAccount } from 'viem/accounts';
|
|
41
|
+
/**
|
|
42
|
+
* Wallet configuration for x402 payments.
|
|
43
|
+
* Can be either:
|
|
44
|
+
* - A viem PrivateKeyAccount object (from privateKeyToAccount)
|
|
45
|
+
* - A private key hex string (will be converted to account internally)
|
|
46
|
+
*/
|
|
47
|
+
export type WalletConfig = PrivateKeyAccount | Hex;
|
|
48
|
+
export interface SkillzMarketOptions {
|
|
49
|
+
apiUrl?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Wallet for x402 payments. Can be:
|
|
52
|
+
* - A viem PrivateKeyAccount object (from privateKeyToAccount)
|
|
53
|
+
* - A private key hex string (0x...)
|
|
54
|
+
*/
|
|
55
|
+
wallet?: WalletConfig;
|
|
56
|
+
/**
|
|
57
|
+
* Network identifier for x402 payments (e.g., 'eip155:8453' for Base mainnet).
|
|
58
|
+
* Defaults to Base mainnet (eip155:8453).
|
|
59
|
+
*/
|
|
60
|
+
network?: `${string}:${string}`;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC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":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skillzmarket/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SDK for discovering and calling paid AI skills with automatic x402 payments",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./creator": {
|
|
16
|
+
"types": "./dist/creator/index.d.ts",
|
|
17
|
+
"import": "./dist/creator/index.js",
|
|
18
|
+
"default": "./dist/creator/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"dev": "tsc --watch",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"prepublishOnly": "npm run build && npm run test"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"ai",
|
|
35
|
+
"skills",
|
|
36
|
+
"marketplace",
|
|
37
|
+
"x402",
|
|
38
|
+
"crypto",
|
|
39
|
+
"payments",
|
|
40
|
+
"usdc",
|
|
41
|
+
"base",
|
|
42
|
+
"ethereum",
|
|
43
|
+
"sdk",
|
|
44
|
+
"creator",
|
|
45
|
+
"monetize"
|
|
46
|
+
],
|
|
47
|
+
"author": "Hiich",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/skillzmarket/sdk.git"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://skillz.market",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/skillzmarket/sdk/issues"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=18.0.0"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@hono/node-server": "^1.19.9",
|
|
62
|
+
"@x402/core": "^2.2.0",
|
|
63
|
+
"@x402/evm": "^2.2.0",
|
|
64
|
+
"@x402/fetch": "^2.2.0",
|
|
65
|
+
"@x402/hono": "^2.2.0",
|
|
66
|
+
"hono": "^4.0.0",
|
|
67
|
+
"viem": "^2.0.0"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"viem": "^2.0.0"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@types/node": "^20.0.0",
|
|
74
|
+
"tsx": "^4.21.0",
|
|
75
|
+
"typescript": "^5.0.0",
|
|
76
|
+
"vitest": "^1.0.0"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public"
|
|
80
|
+
}
|
|
81
|
+
}
|