@one_deploy/sdk 1.0.3 → 1.0.5

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 (53) hide show
  1. package/dist/{engine-CrlhH0nw.d.mts → engine-BeVuHpVx.d.mts} +163 -0
  2. package/dist/{engine-5ndtBaCr.d.ts → engine-DSc1Em4V.d.ts} +163 -0
  3. package/dist/hooks/index.d.mts +132 -3
  4. package/dist/hooks/index.d.ts +132 -3
  5. package/dist/hooks/index.js +351 -0
  6. package/dist/hooks/index.js.map +1 -1
  7. package/dist/hooks/index.mjs +345 -2
  8. package/dist/hooks/index.mjs.map +1 -1
  9. package/dist/index.d.mts +3 -3
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.js +352 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +345 -2
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/providers/index.d.mts +1 -1
  16. package/dist/providers/index.d.ts +1 -1
  17. package/dist/providers/index.js +98 -0
  18. package/dist/providers/index.js.map +1 -1
  19. package/dist/providers/index.mjs +98 -0
  20. package/dist/providers/index.mjs.map +1 -1
  21. package/dist/react-native.d.mts +140 -3
  22. package/dist/react-native.d.ts +140 -3
  23. package/dist/react-native.js +642 -0
  24. package/dist/react-native.js.map +1 -1
  25. package/dist/react-native.mjs +636 -1
  26. package/dist/react-native.mjs.map +1 -1
  27. package/dist/services/index.d.mts +99 -79
  28. package/dist/services/index.d.ts +99 -79
  29. package/dist/services/index.js +254 -0
  30. package/dist/services/index.js.map +1 -1
  31. package/dist/services/index.mjs +252 -1
  32. package/dist/services/index.mjs.map +1 -1
  33. package/dist/supabase-BT0c7q9e.d.mts +82 -0
  34. package/dist/supabase-BT0c7q9e.d.ts +82 -0
  35. package/package.json +5 -1
  36. package/src/components/OneSwapWidget.tsx +1 -1
  37. package/src/components/ai/OneChainSelector.tsx +183 -0
  38. package/src/components/ai/OneCycleSelector.tsx +187 -0
  39. package/src/components/ai/OnePairSelector.tsx +181 -0
  40. package/src/components/ai/OneTierSelector.tsx +187 -0
  41. package/src/components/ai/index.ts +17 -0
  42. package/src/components/index.ts +3 -0
  43. package/src/hooks/index.ts +20 -0
  44. package/src/hooks/useAITrading.ts +444 -0
  45. package/src/index.ts +20 -0
  46. package/src/react-native.ts +23 -0
  47. package/src/services/engine.ts +184 -0
  48. package/src/services/index.ts +16 -0
  49. package/src/services/usage.ts +249 -0
  50. package/.turbo/turbo-build.log +0 -0
  51. package/.turbo/turbo-type-check.log +0 -0
  52. package/tsconfig.json +0 -22
  53. package/tsup.config.ts +0 -25
@@ -1063,6 +1063,43 @@ var OneEngineClient = class {
1063
1063
  async adminClearRateLimits(identifier) {
1064
1064
  return this.request(`/api/v1/admin/rate-limits/${identifier}`, { method: "DELETE" });
1065
1065
  }
1066
+ // ========== AI Agent Configuration ==========
1067
+ /**
1068
+ * Get all AI agent configurations
1069
+ * This returns the full agent setup including tiers, cycles, and trading parameters
1070
+ */
1071
+ async getAgentConfigs(options) {
1072
+ const params = new URLSearchParams();
1073
+ if (options?.includeInactive) params.set("includeInactive", "true");
1074
+ if (options?.agentId) params.set("agentId", options.agentId);
1075
+ const query = params.toString();
1076
+ return this.request(`/api/v1/agents${query ? `?${query}` : ""}`, { method: "GET" });
1077
+ }
1078
+ /**
1079
+ * Calculate subscription parameters for an agent
1080
+ */
1081
+ async calculateAgentParams(params) {
1082
+ return this.request("/api/v1/agents/calculate", {
1083
+ method: "POST",
1084
+ body: JSON.stringify(params)
1085
+ });
1086
+ }
1087
+ /**
1088
+ * Get supported trading pairs from agents
1089
+ */
1090
+ async getTradingPairs() {
1091
+ const result = await this.getAgentConfigs();
1092
+ if (result.success && result.data?.agents) {
1093
+ const allPairs = /* @__PURE__ */ new Set();
1094
+ const byAgent = {};
1095
+ for (const agent of result.data.agents) {
1096
+ byAgent[agent.id] = agent.supported_pairs;
1097
+ agent.supported_pairs.forEach((p) => allPairs.add(p));
1098
+ }
1099
+ return { success: true, data: { pairs: Array.from(allPairs), byAgent } };
1100
+ }
1101
+ return { success: false, error: result.error };
1102
+ }
1066
1103
  // ========== AI Quant Trading ==========
1067
1104
  /**
1068
1105
  * Get all AI trading strategies
@@ -1201,6 +1238,67 @@ var OneEngineClient = class {
1201
1238
  async getCryptoMarketOverview() {
1202
1239
  return this.request("/api/v1/prices?type=overview", { method: "GET" });
1203
1240
  }
1241
+ // ========== Project Management ==========
1242
+ /**
1243
+ * Get user's projects
1244
+ */
1245
+ async getProjects(options) {
1246
+ const params = new URLSearchParams();
1247
+ if (options?.isActive !== void 0) params.set("isActive", String(options.isActive));
1248
+ const query = params.toString();
1249
+ return this.request(`/api/v1/projects${query ? `?${query}` : ""}`, { method: "GET" });
1250
+ }
1251
+ /**
1252
+ * Create a new project for ecosystem partners
1253
+ */
1254
+ async createProject(params) {
1255
+ return this.request("/api/v1/projects", {
1256
+ method: "POST",
1257
+ body: JSON.stringify(params)
1258
+ });
1259
+ }
1260
+ /**
1261
+ * Get project details
1262
+ */
1263
+ async getProject(projectId) {
1264
+ return this.request(`/api/v1/projects/${projectId}`, { method: "GET" });
1265
+ }
1266
+ /**
1267
+ * Update project settings
1268
+ */
1269
+ async updateProject(projectId, updates) {
1270
+ return this.request(`/api/v1/projects/${projectId}`, {
1271
+ method: "PATCH",
1272
+ body: JSON.stringify(updates)
1273
+ });
1274
+ }
1275
+ /**
1276
+ * Get project features status
1277
+ */
1278
+ async getProjectFeatures(projectId) {
1279
+ return this.request(`/api/v1/projects/${projectId}/features`, { method: "GET" });
1280
+ }
1281
+ /**
1282
+ * Enable/disable features for a project
1283
+ */
1284
+ async updateProjectFeatures(projectId, features) {
1285
+ return this.request(`/api/v1/projects/${projectId}/features`, {
1286
+ method: "PATCH",
1287
+ body: JSON.stringify(features)
1288
+ });
1289
+ }
1290
+ /**
1291
+ * Regenerate project API key
1292
+ */
1293
+ async regenerateProjectApiKey(projectId) {
1294
+ return this.request(`/api/v1/projects/${projectId}/api-key`, { method: "POST" });
1295
+ }
1296
+ /**
1297
+ * Delete project
1298
+ */
1299
+ async deleteProject(projectId) {
1300
+ return this.request(`/api/v1/projects/${projectId}`, { method: "DELETE" });
1301
+ }
1204
1302
  };
1205
1303
  function createOneEngineClient(options) {
1206
1304
  return new OneEngineClient(options);
@@ -1453,6 +1551,159 @@ var PriceService = class {
1453
1551
  };
1454
1552
  var priceService = new PriceService();
1455
1553
 
1456
- export { OneEngineClient, PriceService, SupabaseService, createOneEngineClient, createSupabaseClient, getSupabaseClient, priceService };
1554
+ // src/services/usage.ts
1555
+ var UsageService = class {
1556
+ constructor(baseUrl) {
1557
+ this.userId = null;
1558
+ this.baseUrl = baseUrl || getConfig().oneEngineUrl || "";
1559
+ }
1560
+ /**
1561
+ * Set the current user ID for tracking
1562
+ */
1563
+ setUserId(userId) {
1564
+ this.userId = userId;
1565
+ }
1566
+ /**
1567
+ * Record Personal Assistant usage (Thirdweb AI)
1568
+ */
1569
+ async trackPersonalAssistant(action, tokens, credits, metadata) {
1570
+ return this.recordUsage({
1571
+ userId: this.userId,
1572
+ category: "ai_thirdweb",
1573
+ action,
1574
+ requestTokens: tokens?.request,
1575
+ responseTokens: tokens?.response,
1576
+ creditsUsed: credits,
1577
+ metadata
1578
+ });
1579
+ }
1580
+ /**
1581
+ * Record Trading Agent usage (Engine AI)
1582
+ */
1583
+ async trackTradingAgent(action, credits, metadata) {
1584
+ return this.recordUsage({
1585
+ userId: this.userId,
1586
+ category: "ai_trading_engine",
1587
+ action,
1588
+ creditsUsed: credits,
1589
+ metadata
1590
+ });
1591
+ }
1592
+ /**
1593
+ * Record wallet operation usage
1594
+ */
1595
+ async trackWallet(action, metadata) {
1596
+ return this.recordUsage({
1597
+ userId: this.userId,
1598
+ category: "wallet",
1599
+ action,
1600
+ metadata
1601
+ });
1602
+ }
1603
+ /**
1604
+ * Record payment usage
1605
+ */
1606
+ async trackPayment(action, metadata) {
1607
+ return this.recordUsage({
1608
+ userId: this.userId,
1609
+ category: "payment",
1610
+ action,
1611
+ metadata
1612
+ });
1613
+ }
1614
+ /**
1615
+ * Record exchange usage (onramper)
1616
+ */
1617
+ async trackOnramper(action, metadata) {
1618
+ return this.recordUsage({
1619
+ userId: this.userId,
1620
+ category: "exchange_onramper",
1621
+ action,
1622
+ metadata
1623
+ });
1624
+ }
1625
+ /**
1626
+ * Record exchange usage (swap)
1627
+ */
1628
+ async trackSwap(action, metadata) {
1629
+ return this.recordUsage({
1630
+ userId: this.userId,
1631
+ category: "exchange_swap",
1632
+ action,
1633
+ metadata
1634
+ });
1635
+ }
1636
+ /**
1637
+ * Record any usage
1638
+ */
1639
+ async recordUsage(record) {
1640
+ if (!record.userId) {
1641
+ console.warn("[UsageService] No userId set, skipping usage tracking");
1642
+ return false;
1643
+ }
1644
+ try {
1645
+ const response = await fetch(`${this.baseUrl}/api/v1/usage/user`, {
1646
+ method: "POST",
1647
+ headers: {
1648
+ "Content-Type": "application/json"
1649
+ },
1650
+ body: JSON.stringify({
1651
+ userId: record.userId,
1652
+ category: record.category,
1653
+ action: record.action,
1654
+ requestTokens: record.requestTokens || 0,
1655
+ responseTokens: record.responseTokens || 0,
1656
+ creditsUsed: record.creditsUsed || 0,
1657
+ metadata: record.metadata || {}
1658
+ })
1659
+ });
1660
+ if (!response.ok) {
1661
+ const error = await response.json().catch(() => ({}));
1662
+ console.error("[UsageService] Failed to record usage:", error);
1663
+ return false;
1664
+ }
1665
+ return true;
1666
+ } catch (error) {
1667
+ console.error("[UsageService] Error recording usage:", error);
1668
+ return false;
1669
+ }
1670
+ }
1671
+ /**
1672
+ * Get AI usage summary for current user
1673
+ */
1674
+ async getAIUsage(days = 30) {
1675
+ if (!this.userId) {
1676
+ console.warn("[UsageService] No userId set");
1677
+ return null;
1678
+ }
1679
+ try {
1680
+ const response = await fetch(
1681
+ `${this.baseUrl}/api/v1/usage/user?userId=${this.userId}&days=${days}`
1682
+ );
1683
+ if (!response.ok) {
1684
+ const error = await response.json().catch(() => ({}));
1685
+ console.error("[UsageService] Failed to get usage:", error);
1686
+ return null;
1687
+ }
1688
+ const result = await response.json();
1689
+ return result.data;
1690
+ } catch (error) {
1691
+ console.error("[UsageService] Error getting usage:", error);
1692
+ return null;
1693
+ }
1694
+ }
1695
+ };
1696
+ var usageServiceInstance = null;
1697
+ function getUsageService() {
1698
+ if (!usageServiceInstance) {
1699
+ usageServiceInstance = new UsageService();
1700
+ }
1701
+ return usageServiceInstance;
1702
+ }
1703
+ function createUsageService(baseUrl) {
1704
+ return new UsageService(baseUrl);
1705
+ }
1706
+
1707
+ export { OneEngineClient, PriceService, SupabaseService, UsageService, createOneEngineClient, createSupabaseClient, createUsageService, getSupabaseClient, getUsageService, priceService };
1457
1708
  //# sourceMappingURL=index.mjs.map
1458
1709
  //# sourceMappingURL=index.mjs.map