@ucptools/validator 1.0.0 → 1.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.
Files changed (236) hide show
  1. package/.claude/settings.local.json +60 -0
  2. package/.vercel/README.txt +11 -0
  3. package/.vercel/project.json +1 -0
  4. package/dist/cli/index.d.ts +6 -0
  5. package/dist/cli/index.d.ts.map +1 -0
  6. package/dist/cli/index.js +279 -0
  7. package/dist/cli/index.js.map +1 -0
  8. package/dist/compliance/compliance-generator.d.ts +34 -0
  9. package/dist/compliance/compliance-generator.d.ts.map +1 -0
  10. package/dist/compliance/compliance-generator.js +320 -0
  11. package/dist/compliance/compliance-generator.js.map +1 -0
  12. package/dist/compliance/index.d.ts +8 -0
  13. package/dist/compliance/index.d.ts.map +1 -0
  14. package/dist/compliance/index.js +17 -0
  15. package/dist/compliance/index.js.map +1 -0
  16. package/dist/compliance/templates.d.ts +34 -0
  17. package/dist/compliance/templates.d.ts.map +1 -0
  18. package/{src/compliance/templates.ts → dist/compliance/templates.js} +117 -155
  19. package/dist/compliance/templates.js.map +1 -0
  20. package/dist/compliance/types.d.ts +64 -0
  21. package/dist/compliance/types.d.ts.map +1 -0
  22. package/dist/compliance/types.js +64 -0
  23. package/dist/compliance/types.js.map +1 -0
  24. package/dist/db/index.d.ts +11 -0
  25. package/dist/db/index.d.ts.map +1 -0
  26. package/dist/db/index.js +63 -0
  27. package/dist/db/index.js.map +1 -0
  28. package/dist/db/schema.d.ts +444 -0
  29. package/dist/db/schema.d.ts.map +1 -0
  30. package/dist/db/schema.js +65 -0
  31. package/dist/db/schema.js.map +1 -0
  32. package/dist/feed-analyzer/feed-analyzer.d.ts +26 -0
  33. package/dist/feed-analyzer/feed-analyzer.d.ts.map +1 -0
  34. package/{src/feed-analyzer/feed-analyzer.ts → dist/feed-analyzer/feed-analyzer.js} +642 -726
  35. package/dist/feed-analyzer/feed-analyzer.js.map +1 -0
  36. package/dist/feed-analyzer/index.d.ts +8 -0
  37. package/dist/feed-analyzer/index.d.ts.map +1 -0
  38. package/dist/feed-analyzer/index.js +19 -0
  39. package/dist/feed-analyzer/index.js.map +1 -0
  40. package/dist/feed-analyzer/types.d.ts +204 -0
  41. package/dist/feed-analyzer/types.d.ts.map +1 -0
  42. package/dist/feed-analyzer/types.js +162 -0
  43. package/dist/feed-analyzer/types.js.map +1 -0
  44. package/{src/generator/index.ts → dist/generator/index.d.ts} +1 -1
  45. package/dist/generator/index.d.ts.map +1 -0
  46. package/dist/generator/index.js +13 -0
  47. package/dist/generator/index.js.map +1 -0
  48. package/dist/generator/key-generator.d.ts +24 -0
  49. package/dist/generator/key-generator.d.ts.map +1 -0
  50. package/dist/generator/key-generator.js +144 -0
  51. package/dist/generator/key-generator.js.map +1 -0
  52. package/dist/generator/profile-builder.d.ts +15 -0
  53. package/dist/generator/profile-builder.d.ts.map +1 -0
  54. package/dist/generator/profile-builder.js +338 -0
  55. package/dist/generator/profile-builder.js.map +1 -0
  56. package/dist/hosting/artifacts-generator.d.ts +10 -0
  57. package/dist/hosting/artifacts-generator.d.ts.map +1 -0
  58. package/{src/hosting/artifacts-generator.ts → dist/hosting/artifacts-generator.js} +191 -241
  59. package/dist/hosting/artifacts-generator.js.map +1 -0
  60. package/{src/hosting/index.ts → dist/hosting/index.d.ts} +1 -1
  61. package/dist/hosting/index.d.ts.map +1 -0
  62. package/dist/hosting/index.js +10 -0
  63. package/dist/hosting/index.js.map +1 -0
  64. package/dist/index.d.ts +18 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +78 -0
  67. package/dist/index.js.map +1 -0
  68. package/{src/security/index.ts → dist/security/index.d.ts} +8 -15
  69. package/dist/security/index.d.ts.map +1 -0
  70. package/dist/security/index.js +12 -0
  71. package/dist/security/index.js.map +1 -0
  72. package/dist/security/security-scanner.d.ts +10 -0
  73. package/dist/security/security-scanner.d.ts.map +1 -0
  74. package/dist/security/security-scanner.js +541 -0
  75. package/dist/security/security-scanner.js.map +1 -0
  76. package/dist/security/types.d.ts +48 -0
  77. package/dist/security/types.d.ts.map +1 -0
  78. package/dist/security/types.js +21 -0
  79. package/dist/security/types.js.map +1 -0
  80. package/dist/services/directory.d.ts +104 -0
  81. package/dist/services/directory.d.ts.map +1 -0
  82. package/dist/services/directory.js +333 -0
  83. package/dist/services/directory.js.map +1 -0
  84. package/dist/simulator/agent-simulator.d.ts +69 -0
  85. package/dist/simulator/agent-simulator.d.ts.map +1 -0
  86. package/{src/simulator/agent-simulator.ts → dist/simulator/agent-simulator.js} +650 -941
  87. package/dist/simulator/agent-simulator.js.map +1 -0
  88. package/{src/simulator/index.ts → dist/simulator/index.d.ts} +7 -7
  89. package/dist/simulator/index.d.ts.map +1 -0
  90. package/dist/simulator/index.js +23 -0
  91. package/dist/simulator/index.js.map +1 -0
  92. package/{src/simulator/types.ts → dist/simulator/types.d.ts} +145 -170
  93. package/dist/simulator/types.d.ts.map +1 -0
  94. package/dist/simulator/types.js +18 -0
  95. package/dist/simulator/types.js.map +1 -0
  96. package/dist/types/generator.d.ts +106 -0
  97. package/dist/types/generator.d.ts.map +1 -0
  98. package/dist/types/generator.js +6 -0
  99. package/dist/types/generator.js.map +1 -0
  100. package/{src/types/index.ts → dist/types/index.d.ts} +1 -1
  101. package/dist/types/index.d.ts.map +1 -0
  102. package/dist/types/index.js +23 -0
  103. package/dist/types/index.js.map +1 -0
  104. package/dist/types/ucp-profile.d.ts +103 -0
  105. package/dist/types/ucp-profile.d.ts.map +1 -0
  106. package/dist/types/ucp-profile.js +45 -0
  107. package/dist/types/ucp-profile.js.map +1 -0
  108. package/dist/types/validation.d.ts +68 -0
  109. package/dist/types/validation.d.ts.map +1 -0
  110. package/dist/types/validation.js +32 -0
  111. package/dist/types/validation.js.map +1 -0
  112. package/dist/validator/index.d.ts +26 -0
  113. package/dist/validator/index.d.ts.map +1 -0
  114. package/dist/validator/index.js +161 -0
  115. package/dist/validator/index.js.map +1 -0
  116. package/dist/validator/network-validator.d.ts +28 -0
  117. package/dist/validator/network-validator.d.ts.map +1 -0
  118. package/dist/validator/network-validator.js +319 -0
  119. package/dist/validator/network-validator.js.map +1 -0
  120. package/dist/validator/rules-validator.d.ts +11 -0
  121. package/dist/validator/rules-validator.d.ts.map +1 -0
  122. package/dist/validator/rules-validator.js +257 -0
  123. package/dist/validator/rules-validator.js.map +1 -0
  124. package/dist/validator/sdk-validator.d.ts +58 -0
  125. package/dist/validator/sdk-validator.d.ts.map +1 -0
  126. package/{src/validator/sdk-validator.ts → dist/validator/sdk-validator.js} +273 -330
  127. package/dist/validator/sdk-validator.js.map +1 -0
  128. package/dist/validator/structural-validator.d.ts +11 -0
  129. package/dist/validator/structural-validator.d.ts.map +1 -0
  130. package/dist/validator/structural-validator.js +415 -0
  131. package/dist/validator/structural-validator.js.map +1 -0
  132. package/package.json +1 -1
  133. package/publish-output.txt +0 -0
  134. package/CLAUDE.md +0 -109
  135. package/api/analyze-feed.js +0 -140
  136. package/api/badge.js +0 -185
  137. package/api/benchmark.js +0 -177
  138. package/api/directory-stats.ts +0 -29
  139. package/api/directory.ts +0 -73
  140. package/api/generate-compliance.js +0 -143
  141. package/api/generate-schema.js +0 -457
  142. package/api/generate.js +0 -132
  143. package/api/security-scan.js +0 -133
  144. package/api/simulate.js +0 -187
  145. package/api/tsconfig.json +0 -10
  146. package/api/validate.js +0 -1351
  147. package/apify-actor/.actor/actor.json +0 -68
  148. package/apify-actor/.actor/input_schema.json +0 -32
  149. package/apify-actor/APIFY-STORE-LISTING.md +0 -412
  150. package/apify-actor/Dockerfile +0 -8
  151. package/apify-actor/README.md +0 -166
  152. package/apify-actor/main.ts +0 -111
  153. package/apify-actor/package.json +0 -17
  154. package/apify-actor/src/main.js +0 -199
  155. package/docs/BRAND-IDENTITY.md +0 -238
  156. package/docs/BRAND-STYLE-GUIDE.md +0 -356
  157. package/drizzle/0000_black_king_cobra.sql +0 -39
  158. package/drizzle/meta/0000_snapshot.json +0 -309
  159. package/drizzle/meta/_journal.json +0 -13
  160. package/drizzle.config.ts +0 -10
  161. package/public/.well-known/ucp +0 -25
  162. package/public/android-chrome-192x192.png +0 -0
  163. package/public/android-chrome-512x512.png +0 -0
  164. package/public/apple-touch-icon.png +0 -0
  165. package/public/brand.css +0 -321
  166. package/public/directory.html +0 -701
  167. package/public/favicon-16x16.png +0 -0
  168. package/public/favicon-32x32.png +0 -0
  169. package/public/favicon.ico +0 -0
  170. package/public/guides/bigcommerce.html +0 -743
  171. package/public/guides/fastucp.html +0 -838
  172. package/public/guides/magento.html +0 -779
  173. package/public/guides/shopify.html +0 -726
  174. package/public/guides/squarespace.html +0 -749
  175. package/public/guides/wix.html +0 -747
  176. package/public/guides/woocommerce.html +0 -733
  177. package/public/index.html +0 -3835
  178. package/public/learn.html +0 -396
  179. package/public/logo.jpeg +0 -0
  180. package/public/og-image-icon.png +0 -0
  181. package/public/og-image.png +0 -0
  182. package/public/robots.txt +0 -6
  183. package/public/site.webmanifest +0 -31
  184. package/public/sitemap.xml +0 -69
  185. package/public/social/linkedin-banner-1128x191.png +0 -0
  186. package/public/social/temp.PNG +0 -0
  187. package/public/social/x-header-1500x500.png +0 -0
  188. package/public/verify.html +0 -410
  189. package/scripts/generate-favicons.js +0 -44
  190. package/scripts/generate-ico.js +0 -23
  191. package/scripts/generate-og-image.js +0 -45
  192. package/scripts/reset-db.ts +0 -77
  193. package/scripts/seed-db.ts +0 -71
  194. package/scripts/setup-benchmark-db.js +0 -70
  195. package/src/api/server.ts +0 -266
  196. package/src/cli/index.ts +0 -302
  197. package/src/compliance/compliance-generator.ts +0 -452
  198. package/src/compliance/index.ts +0 -28
  199. package/src/compliance/types.ts +0 -170
  200. package/src/db/index.ts +0 -28
  201. package/src/db/schema.ts +0 -84
  202. package/src/feed-analyzer/index.ts +0 -34
  203. package/src/feed-analyzer/types.ts +0 -354
  204. package/src/generator/key-generator.ts +0 -124
  205. package/src/generator/profile-builder.ts +0 -402
  206. package/src/index.ts +0 -105
  207. package/src/security/security-scanner.ts +0 -604
  208. package/src/security/types.ts +0 -55
  209. package/src/services/directory.ts +0 -434
  210. package/src/types/generator.ts +0 -140
  211. package/src/types/ucp-profile.ts +0 -140
  212. package/src/types/validation.ts +0 -89
  213. package/src/validator/index.ts +0 -194
  214. package/src/validator/network-validator.ts +0 -417
  215. package/src/validator/rules-validator.ts +0 -297
  216. package/src/validator/structural-validator.ts +0 -476
  217. package/tests/fixtures/non-compliant-profile.json +0 -25
  218. package/tests/fixtures/official-sample-profile.json +0 -75
  219. package/tests/integration/benchmark.test.ts +0 -207
  220. package/tests/integration/database.test.ts +0 -163
  221. package/tests/integration/directory-api.test.ts +0 -268
  222. package/tests/integration/simulate-api.test.ts +0 -230
  223. package/tests/integration/validate-api.test.ts +0 -269
  224. package/tests/setup.ts +0 -15
  225. package/tests/unit/agent-simulator.test.ts +0 -575
  226. package/tests/unit/compliance-generator.test.ts +0 -374
  227. package/tests/unit/directory-service.test.ts +0 -272
  228. package/tests/unit/feed-analyzer.test.ts +0 -517
  229. package/tests/unit/lint-suggestions.test.ts +0 -423
  230. package/tests/unit/official-samples.test.ts +0 -211
  231. package/tests/unit/pdf-report.test.ts +0 -390
  232. package/tests/unit/sdk-validator.test.ts +0 -531
  233. package/tests/unit/security-scanner.test.ts +0 -410
  234. package/tests/unit/validation.test.ts +0 -390
  235. package/vercel.json +0 -34
  236. package/vitest.config.ts +0 -22
package/api/generate.js DELETED
@@ -1,132 +0,0 @@
1
- /**
2
- * Vercel Serverless Function: Generate UCP Profile
3
- * POST /api/generate
4
- */
5
-
6
- function generateProfile({ domain, endpoint, capabilities }) {
7
- const today = new Date().toISOString().split('T')[0];
8
-
9
- const profile = {
10
- ucp: {
11
- version: today,
12
- services: {
13
- shopping: {
14
- version: "1.0",
15
- spec: "https://ucp.dev/specs/shopping/1.0",
16
- rest: {
17
- endpoint: endpoint,
18
- auth: {
19
- type: "oauth2",
20
- flows: ["client_credentials"],
21
- token_url: `${endpoint}/oauth/token`
22
- }
23
- }
24
- }
25
- },
26
- capabilities: []
27
- }
28
- };
29
-
30
- // Always add checkout (required)
31
- profile.ucp.capabilities.push({
32
- name: "dev.ucp.shopping.checkout",
33
- version: "1.0",
34
- spec: "https://ucp.dev/specs/shopping/checkout/1.0",
35
- schema: "https://ucp.dev/schemas/shopping/checkout/1.0.json"
36
- });
37
-
38
- // Add optional capabilities
39
- if (capabilities?.order) {
40
- profile.ucp.capabilities.push({
41
- name: "dev.ucp.shopping.order",
42
- version: "1.0",
43
- spec: "https://ucp.dev/specs/shopping/order/1.0",
44
- schema: "https://ucp.dev/schemas/shopping/order/1.0.json"
45
- });
46
-
47
- // Add signing_keys for order capability
48
- profile.signing_keys = [
49
- {
50
- kid: `${domain.replace(/\./g, '-')}-key-1`,
51
- alg: "ES256",
52
- use: "sig",
53
- kty: "EC",
54
- crv: "P-256",
55
- x: "PLACEHOLDER_X_COORDINATE",
56
- y: "PLACEHOLDER_Y_COORDINATE"
57
- }
58
- ];
59
- }
60
-
61
- if (capabilities?.fulfillment) {
62
- profile.ucp.capabilities.push({
63
- name: "dev.ucp.shopping.fulfillment",
64
- version: "1.0",
65
- spec: "https://ucp.dev/specs/shopping/fulfillment/1.0",
66
- schema: "https://ucp.dev/schemas/shopping/fulfillment/1.0.json"
67
- });
68
- }
69
-
70
- if (capabilities?.discount) {
71
- profile.ucp.capabilities.push({
72
- name: "dev.ucp.shopping.discount",
73
- version: "1.0",
74
- spec: "https://ucp.dev/specs/shopping/discount/1.0",
75
- schema: "https://ucp.dev/schemas/shopping/discount/1.0.json"
76
- });
77
- }
78
-
79
- return profile;
80
- }
81
-
82
- export default async function handler(req, res) {
83
- // CORS headers
84
- res.setHeader('Access-Control-Allow-Origin', '*');
85
- res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
86
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
87
-
88
- if (req.method === 'OPTIONS') {
89
- return res.status(200).end();
90
- }
91
-
92
- if (req.method !== 'POST') {
93
- return res.status(405).json({ error: 'Method not allowed' });
94
- }
95
-
96
- const { domain, endpoint, capabilities } = req.body;
97
-
98
- if (!domain) {
99
- return res.status(400).json({ error: 'Missing required field: domain' });
100
- }
101
-
102
- if (!endpoint) {
103
- return res.status(400).json({ error: 'Missing required field: endpoint' });
104
- }
105
-
106
- if (!endpoint.startsWith('https://')) {
107
- return res.status(400).json({ error: 'Endpoint must use HTTPS' });
108
- }
109
-
110
- const cleanDomain = domain.replace(/^https?:\/\//, '').replace(/\/$/, '');
111
- const cleanEndpoint = endpoint.replace(/\/$/, '');
112
-
113
- const profile = generateProfile({
114
- domain: cleanDomain,
115
- endpoint: cleanEndpoint,
116
- capabilities: capabilities || { checkout: true }
117
- });
118
-
119
- return res.status(200).json({
120
- ok: true,
121
- domain: cleanDomain,
122
- profile,
123
- deploy_to: `https://${cleanDomain}/.well-known/ucp`,
124
- instructions: [
125
- 'Save this JSON as "ucp" (no extension) or "ucp.json"',
126
- `Upload to your server at /.well-known/ucp`,
127
- 'Set Content-Type: application/json',
128
- 'Add CORS header: Access-Control-Allow-Origin: *',
129
- profile.signing_keys ? 'Replace PLACEHOLDER values in signing_keys with your actual EC key' : null
130
- ].filter(Boolean)
131
- });
132
- }
@@ -1,133 +0,0 @@
1
- /**
2
- * Vercel Serverless Function: Security Posture Scanner
3
- * POST /api/security-scan
4
- *
5
- * Scans UCP endpoints for common security misconfigurations.
6
- * Helps merchants understand their security posture before exposing
7
- * endpoints to AI agents.
8
- *
9
- * Request body:
10
- * { "domain": "example.com", "options"?: { timeoutMs?: number } }
11
- *
12
- * Response:
13
- * Security scan result including checks, score, grade, and recommendations.
14
- */
15
-
16
- export default async function handler(req, res) {
17
- // Handle CORS
18
- res.setHeader('Access-Control-Allow-Origin', '*');
19
- res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
20
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
21
-
22
- if (req.method === 'OPTIONS') {
23
- return res.status(200).end();
24
- }
25
-
26
- if (req.method !== 'POST') {
27
- return res.status(405).json({
28
- error: 'Method not allowed',
29
- message: 'Use POST to run a security scan',
30
- });
31
- }
32
-
33
- try {
34
- const { domain, options = {} } = req.body || {};
35
-
36
- if (!domain) {
37
- return res.status(400).json({
38
- error: 'Missing domain',
39
- message: 'Please provide a domain to scan',
40
- });
41
- }
42
-
43
- // Clean domain
44
- const cleanDomain = domain
45
- .replace(/^https?:\/\//, '')
46
- .replace(/\/.*$/, '')
47
- .toLowerCase()
48
- .trim();
49
-
50
- if (!cleanDomain) {
51
- return res.status(400).json({
52
- error: 'Invalid domain',
53
- message: 'Please provide a valid domain',
54
- });
55
- }
56
-
57
- // Dynamic import of the security scanner
58
- const { scanEndpointSecurity } = await import('../src/security/index.js');
59
-
60
- // Run security scan
61
- const scanOptions = {
62
- timeoutMs: options.timeoutMs || 15000,
63
- };
64
-
65
- const result = await scanEndpointSecurity(cleanDomain, scanOptions);
66
-
67
- // Build response
68
- const response = {
69
- ok: result.score >= 60,
70
- domain: result.domain,
71
- endpoint: result.endpoint,
72
- scanned_at: result.scanned_at,
73
-
74
- // Score and grade
75
- score: result.score,
76
- grade: result.grade,
77
-
78
- // Summary
79
- summary: result.summary,
80
-
81
- // All checks with details
82
- checks: result.checks.map(check => ({
83
- id: check.id,
84
- name: check.name,
85
- description: check.description,
86
- status: check.status,
87
- severity: check.severity,
88
- details: check.details,
89
- recommendation: check.recommendation,
90
- })),
91
-
92
- // Group by status for easier UI rendering
93
- by_status: {
94
- passed: result.checks.filter(c => c.status === 'pass'),
95
- failed: result.checks.filter(c => c.status === 'fail'),
96
- warnings: result.checks.filter(c => c.status === 'warn'),
97
- skipped: result.checks.filter(c => c.status === 'skip'),
98
- },
99
-
100
- // Critical issues that need immediate attention
101
- critical_issues: result.checks.filter(
102
- c => c.status === 'fail' && (c.severity === 'critical' || c.severity === 'high')
103
- ),
104
-
105
- // Badge
106
- badge: {
107
- text: `Security: ${result.grade} (${result.score}/100)`,
108
- color: getBadgeColor(result.score),
109
- },
110
- };
111
-
112
- return res.status(200).json(response);
113
-
114
- } catch (error) {
115
- console.error('Security scan error:', error);
116
- return res.status(500).json({
117
- error: 'Security scan failed',
118
- message: error.message || 'An unexpected error occurred',
119
- });
120
- }
121
- }
122
-
123
- /**
124
- * Get badge color from score
125
- */
126
- function getBadgeColor(score) {
127
- if (score >= 90) return 'brightgreen';
128
- if (score >= 80) return 'green';
129
- if (score >= 70) return 'yellowgreen';
130
- if (score >= 60) return 'yellow';
131
- if (score >= 40) return 'orange';
132
- return 'red';
133
- }
package/api/simulate.js DELETED
@@ -1,187 +0,0 @@
1
- /**
2
- * Vercel Serverless Function: AI Agent Simulation
3
- * POST /api/simulate
4
- *
5
- * Simulates how an AI agent would interact with a UCP-enabled merchant.
6
- * Tests real-world functionality, not just spec compliance.
7
- *
8
- * Request body:
9
- * { "domain": "example.com", "options"?: { ... } }
10
- *
11
- * Response:
12
- * Complete simulation result including discovery, capabilities,
13
- * services, checkout flow, and payment readiness.
14
- */
15
-
16
- export default async function handler(req, res) {
17
- // Handle CORS
18
- res.setHeader('Access-Control-Allow-Origin', '*');
19
- res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
20
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
21
-
22
- if (req.method === 'OPTIONS') {
23
- return res.status(200).end();
24
- }
25
-
26
- if (req.method !== 'POST') {
27
- return res.status(405).json({
28
- error: 'Method not allowed',
29
- message: 'Use POST to simulate AI agent interaction',
30
- });
31
- }
32
-
33
- try {
34
- const { domain, options = {} } = req.body || {};
35
-
36
- if (!domain) {
37
- return res.status(400).json({
38
- error: 'Missing domain',
39
- message: 'Please provide a domain to simulate',
40
- });
41
- }
42
-
43
- // Clean domain
44
- const cleanDomain = domain
45
- .replace(/^https?:\/\//, '')
46
- .replace(/\/.*$/, '')
47
- .toLowerCase()
48
- .trim();
49
-
50
- if (!cleanDomain) {
51
- return res.status(400).json({
52
- error: 'Invalid domain',
53
- message: 'Please provide a valid domain',
54
- });
55
- }
56
-
57
- // Dynamic import of the simulator
58
- const { simulateAgentInteraction } = await import('../src/simulator/index.js');
59
-
60
- // Run simulation with timeout
61
- const simulationOptions = {
62
- timeoutMs: options.timeoutMs || 30000,
63
- skipRestApiTest: options.skipRestApiTest || false,
64
- skipSchemaValidation: options.skipSchemaValidation || false,
65
- testCheckoutFlow: options.testCheckoutFlow !== false,
66
- verbose: options.verbose || false,
67
- };
68
-
69
- const result = await simulateAgentInteraction(cleanDomain, simulationOptions);
70
-
71
- // Build response
72
- const response = {
73
- ok: result.ok,
74
- domain: result.domain,
75
- simulated_at: result.simulatedAt,
76
- duration_ms: result.durationMs,
77
-
78
- // Score and grade
79
- score: result.overallScore,
80
- grade: getGrade(result.overallScore),
81
-
82
- // Summary
83
- summary: {
84
- total_steps: result.summary.totalSteps,
85
- passed: result.summary.passedSteps,
86
- failed: result.summary.failedSteps,
87
- warnings: result.summary.warningSteps,
88
- skipped: result.summary.skippedSteps,
89
- },
90
-
91
- // Discovery
92
- discovery: {
93
- success: result.discovery.success,
94
- profile_url: result.discovery.profileUrl,
95
- services: result.discovery.services,
96
- capabilities: result.discovery.capabilities,
97
- transports: result.discovery.transports,
98
- steps: result.discovery.steps,
99
- },
100
-
101
- // Capabilities
102
- capabilities: result.capabilities.map(cap => ({
103
- name: cap.name,
104
- version: cap.version,
105
- schema_accessible: cap.schemaAccessible,
106
- spec_accessible: cap.specAccessible,
107
- is_extension: cap.isExtension,
108
- parent: cap.parentCapability,
109
- })),
110
-
111
- // Services
112
- services: result.services.map(svc => ({
113
- name: svc.name,
114
- version: svc.version,
115
- transports: svc.transports,
116
- })),
117
-
118
- // REST API (if tested)
119
- rest_api: result.restApi ? {
120
- success: result.restApi.success,
121
- schema_loaded: result.restApi.schemaLoaded,
122
- endpoint_accessible: result.restApi.endpointAccessible,
123
- steps: result.restApi.steps,
124
- } : null,
125
-
126
- // Checkout flow (if tested)
127
- checkout: result.checkout ? {
128
- success: result.checkout.success,
129
- can_create_checkout: result.checkout.canCreateCheckout,
130
- checkout_schema_valid: result.checkout.checkoutSchemaValid,
131
- order_flow_supported: result.checkout.orderFlowSupported,
132
- fulfillment_supported: result.checkout.fulfillmentSupported,
133
- steps: result.checkout.steps,
134
- } : null,
135
-
136
- // Payment readiness
137
- payment: result.payment ? {
138
- success: result.payment.success,
139
- handlers_found: result.payment.handlersFound,
140
- webhook_verifiable: result.payment.webhookVerifiable,
141
- signing_key_valid: result.payment.signingKeyValid,
142
- steps: result.payment.steps,
143
- } : null,
144
-
145
- // Recommendations
146
- recommendations: result.recommendations,
147
-
148
- // Badge
149
- badge: {
150
- text: `AI Agent Ready: ${getGrade(result.overallScore)} (${result.overallScore}/100)`,
151
- color: getBadgeColor(result.overallScore),
152
- },
153
- };
154
-
155
- return res.status(200).json(response);
156
-
157
- } catch (error) {
158
- console.error('Simulation error:', error);
159
- return res.status(500).json({
160
- error: 'Simulation failed',
161
- message: error.message || 'An unexpected error occurred',
162
- });
163
- }
164
- }
165
-
166
- /**
167
- * Get letter grade from score
168
- */
169
- function getGrade(score) {
170
- if (score >= 90) return 'A';
171
- if (score >= 80) return 'B';
172
- if (score >= 70) return 'C';
173
- if (score >= 60) return 'D';
174
- return 'F';
175
- }
176
-
177
- /**
178
- * Get badge color from score
179
- */
180
- function getBadgeColor(score) {
181
- if (score >= 90) return 'brightgreen';
182
- if (score >= 80) return 'green';
183
- if (score >= 70) return 'yellowgreen';
184
- if (score >= 60) return 'yellow';
185
- if (score >= 40) return 'orange';
186
- return 'red';
187
- }
package/api/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "..",
5
- "outDir": "../.vercel/output/functions",
6
- "noEmit": true
7
- },
8
- "include": ["./**/*.ts", "../src/**/*.ts"],
9
- "exclude": ["../node_modules", "../dist"]
10
- }