@nordsym/apiclaw 1.5.17 → 1.5.19

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 (228) hide show
  1. package/convex/http.js.map +1 -1
  2. package/convex/http.ts +516 -0
  3. package/dist/analytics.d.ts +0 -4
  4. package/dist/analytics.d.ts.map +1 -1
  5. package/dist/analytics.js +0 -1
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/bin.js +1 -1
  8. package/dist/cli/commands/mcp-install.d.ts.map +1 -1
  9. package/dist/cli/commands/mcp-install.js +8 -87
  10. package/dist/cli/commands/mcp-install.js.map +1 -1
  11. package/dist/cli/index.js +0 -7
  12. package/dist/credentials.d.ts.map +1 -1
  13. package/dist/credentials.js +38 -43
  14. package/dist/credentials.js.map +1 -1
  15. package/dist/discovery.d.ts.map +1 -1
  16. package/dist/discovery.js +82 -191
  17. package/dist/discovery.js.map +1 -1
  18. package/dist/http-api.d.ts.map +1 -1
  19. package/dist/http-api.js +33 -17
  20. package/dist/http-api.js.map +1 -1
  21. package/dist/proxy.js +1 -1
  22. package/dist/proxy.js.map +1 -1
  23. package/landing/next-env.d.ts +0 -1
  24. package/landing/src/app/api/auth/magic-link/route.ts +1 -1
  25. package/landing/src/app/auth/verify/page.tsx +0 -6
  26. package/landing/src/app/dashboard/verify/page.tsx +0 -6
  27. package/landing/src/app/join/page.tsx +0 -6
  28. package/landing/src/app/layout.tsx +2 -2
  29. package/landing/src/app/login/page.tsx +1 -1
  30. package/landing/src/app/mou/[partnerId]/page.tsx +0 -6
  31. package/landing/src/app/page.tsx +18 -39
  32. package/landing/src/app/providers/dashboard/[apiId]/actions/[actionId]/edit/page.tsx +0 -6
  33. package/landing/src/app/providers/dashboard/[apiId]/actions/new/page.tsx +0 -5
  34. package/landing/src/app/providers/dashboard/[apiId]/actions/page.tsx +0 -5
  35. package/landing/src/app/providers/dashboard/[apiId]/direct-call/page.tsx +1 -6
  36. package/landing/src/app/providers/dashboard/[apiId]/page.tsx +0 -5
  37. package/landing/src/app/providers/dashboard/[apiId]/test/page.tsx +0 -5
  38. package/landing/src/app/providers/dashboard/layout.tsx +6 -6
  39. package/landing/src/app/providers/dashboard/login/page.tsx +1 -1
  40. package/landing/src/app/providers/dashboard/page.tsx +1 -1
  41. package/landing/src/app/providers/dashboard/verify/page.tsx +0 -6
  42. package/landing/src/app/providers/layout.tsx +1 -1
  43. package/landing/src/app/upgrade/page.tsx +0 -6
  44. package/landing/src/app/workspace/page.tsx +0 -6
  45. package/landing/src/components/HeroTabs.tsx +2 -2
  46. package/landing/src/components/{Workspace.tsx → ProviderDashboard.tsx} +2 -2
  47. package/landing/src/components/VideoDemo.tsx +10 -21
  48. package/landing/src/lib/mock-data.ts +1 -1
  49. package/landing/src/lib/stats.json +1 -1
  50. package/package.json +3 -8
  51. package/src/analytics.ts +0 -5
  52. package/src/bin.ts +1 -1
  53. package/src/cli/commands/mcp-install.ts +8 -90
  54. package/src/cli/index.ts +0 -8
  55. package/src/credentials.ts +39 -44
  56. package/src/discovery.ts +82 -191
  57. package/src/http-api.ts +34 -18
  58. package/src/proxy.ts +1 -1
  59. package/APILAYER_STATUS_2026-03-24.md +0 -38
  60. package/CHANGELOG-WHITELIST-V2.md +0 -269
  61. package/HIVR-WHITELIST-STATUS.md +0 -205
  62. package/HIVR-WHITELIST.md +0 -148
  63. package/TERMINOLOGY-AUDIT.md +0 -99
  64. package/TERMINOLOGY-FIXED.md +0 -74
  65. package/VIDEO-DEMO-GUIDE.md +0 -82
  66. package/WHITELIST-ARCHITECTURE.md +0 -379
  67. package/api/discover.ts +0 -71
  68. package/api/health.ts +0 -20
  69. package/convex/adminActivate.d.ts +0 -3
  70. package/convex/adminActivate.js +0 -47
  71. package/convex/adminStats.d.ts +0 -3
  72. package/convex/adminStats.js +0 -42
  73. package/convex/agents.d.ts +0 -54
  74. package/convex/agents.js +0 -499
  75. package/convex/analytics.d.ts +0 -5
  76. package/convex/analytics.js +0 -166
  77. package/convex/billing.d.ts +0 -88
  78. package/convex/billing.js +0 -655
  79. package/convex/capabilities.d.ts +0 -9
  80. package/convex/capabilities.js +0 -145
  81. package/convex/chains.d.ts +0 -67
  82. package/convex/chains.js +0 -1042
  83. package/convex/credits.d.ts +0 -25
  84. package/convex/credits.js +0 -186
  85. package/convex/crons.d.ts +0 -3
  86. package/convex/crons.js +0 -17
  87. package/convex/directCall.d.ts +0 -72
  88. package/convex/directCall.js +0 -627
  89. package/convex/earnProgress.d.ts +0 -58
  90. package/convex/earnProgress.js +0 -649
  91. package/convex/email.d.ts +0 -14
  92. package/convex/email.js +0 -300
  93. package/convex/feedback.d.ts +0 -7
  94. package/convex/feedback.js +0 -227
  95. package/convex/http.d.ts +0 -3
  96. package/convex/http.js +0 -910
  97. package/convex/logs.d.ts +0 -38
  98. package/convex/logs.js +0 -487
  99. package/convex/mou.d.ts +0 -6
  100. package/convex/mou.js +0 -82
  101. package/convex/providerKeys.d.ts +0 -31
  102. package/convex/providerKeys.js +0 -257
  103. package/convex/providers.d.ts +0 -29
  104. package/convex/providers.js +0 -756
  105. package/convex/purchases.d.ts +0 -7
  106. package/convex/purchases.js +0 -157
  107. package/convex/ratelimit.d.ts +0 -4
  108. package/convex/ratelimit.js +0 -91
  109. package/convex/searchLogs.d.ts +0 -4
  110. package/convex/searchLogs.js +0 -129
  111. package/convex/spendAlerts.d.ts +0 -36
  112. package/convex/spendAlerts.js +0 -380
  113. package/convex/stripeActions.d.ts +0 -19
  114. package/convex/stripeActions.js +0 -411
  115. package/convex/teams.d.ts +0 -21
  116. package/convex/teams.js +0 -215
  117. package/convex/telemetry.d.ts +0 -4
  118. package/convex/telemetry.js +0 -74
  119. package/convex/usage.d.ts +0 -27
  120. package/convex/usage.js +0 -229
  121. package/convex/waitlist.d.ts +0 -4
  122. package/convex/waitlist.js +0 -49
  123. package/convex/webhooks.d.ts +0 -12
  124. package/convex/webhooks.js +0 -410
  125. package/convex/workspaces.d.ts +0 -29
  126. package/convex/workspaces.js +0 -880
  127. package/direct-test.mjs +0 -51
  128. package/dist/access-control.d.ts +0 -45
  129. package/dist/access-control.d.ts.map +0 -1
  130. package/dist/access-control.js +0 -142
  131. package/dist/access-control.js.map +0 -1
  132. package/dist/chain-types.d.ts +0 -187
  133. package/dist/chain-types.d.ts.map +0 -1
  134. package/dist/chain-types.js +0 -33
  135. package/dist/chain-types.js.map +0 -1
  136. package/dist/convex/adminActivate.js +0 -46
  137. package/dist/convex/adminStats.js +0 -41
  138. package/dist/convex/agents.js +0 -498
  139. package/dist/convex/analytics.js +0 -165
  140. package/dist/convex/billing.js +0 -654
  141. package/dist/convex/capabilities.js +0 -144
  142. package/dist/convex/chains.js +0 -1041
  143. package/dist/convex/credits.js +0 -185
  144. package/dist/convex/crons.js +0 -16
  145. package/dist/convex/directCall.js +0 -626
  146. package/dist/convex/earnProgress.js +0 -648
  147. package/dist/convex/email.js +0 -299
  148. package/dist/convex/feedback.js +0 -226
  149. package/dist/convex/http.js +0 -909
  150. package/dist/convex/logs.js +0 -486
  151. package/dist/convex/mou.js +0 -81
  152. package/dist/convex/providerKeys.js +0 -256
  153. package/dist/convex/providers.js +0 -755
  154. package/dist/convex/purchases.js +0 -156
  155. package/dist/convex/ratelimit.js +0 -90
  156. package/dist/convex/schema.js +0 -709
  157. package/dist/convex/searchLogs.js +0 -128
  158. package/dist/convex/spendAlerts.js +0 -379
  159. package/dist/convex/stripeActions.js +0 -410
  160. package/dist/convex/teams.js +0 -214
  161. package/dist/convex/telemetry.js +0 -73
  162. package/dist/convex/usage.js +0 -228
  163. package/dist/convex/waitlist.js +0 -48
  164. package/dist/convex/webhooks.js +0 -409
  165. package/dist/convex/workspaces.js +0 -879
  166. package/dist/hivr-whitelist.d.ts +0 -18
  167. package/dist/hivr-whitelist.d.ts.map +0 -1
  168. package/dist/hivr-whitelist.js +0 -95
  169. package/dist/hivr-whitelist.js.map +0 -1
  170. package/dist/http-server-minimal.d.ts +0 -7
  171. package/dist/http-server-minimal.d.ts.map +0 -1
  172. package/dist/http-server-minimal.js +0 -126
  173. package/dist/http-server-minimal.js.map +0 -1
  174. package/dist/product-whitelist.d.ts +0 -37
  175. package/dist/product-whitelist.d.ts.map +0 -1
  176. package/dist/product-whitelist.js +0 -203
  177. package/dist/product-whitelist.js.map +0 -1
  178. package/dist/src/analytics.js +0 -129
  179. package/dist/src/bin.js +0 -17
  180. package/dist/src/capability-router.js +0 -240
  181. package/dist/src/chainExecutor.js +0 -451
  182. package/dist/src/chainResolver.js +0 -518
  183. package/dist/src/cli/commands/doctor.js +0 -324
  184. package/dist/src/cli/commands/mcp-install.js +0 -255
  185. package/dist/src/cli/commands/restore.js +0 -259
  186. package/dist/src/cli/commands/setup.js +0 -205
  187. package/dist/src/cli/commands/uninstall.js +0 -188
  188. package/dist/src/cli/index.js +0 -111
  189. package/dist/src/cli.js +0 -302
  190. package/dist/src/confirmation.js +0 -240
  191. package/dist/src/credentials.js +0 -357
  192. package/dist/src/credits.js +0 -260
  193. package/dist/src/crypto.js +0 -66
  194. package/dist/src/discovery.js +0 -504
  195. package/dist/src/enterprise/env.js +0 -123
  196. package/dist/src/enterprise/script-generator.js +0 -460
  197. package/dist/src/execute-dynamic.js +0 -473
  198. package/dist/src/execute.js +0 -1727
  199. package/dist/src/index.js +0 -2062
  200. package/dist/src/metered.js +0 -80
  201. package/dist/src/open-apis.js +0 -276
  202. package/dist/src/proxy.js +0 -28
  203. package/dist/src/session.js +0 -86
  204. package/dist/src/stripe.js +0 -407
  205. package/dist/src/telemetry.js +0 -49
  206. package/dist/src/types.js +0 -2
  207. package/dist/src/utils/backup.js +0 -181
  208. package/dist/src/utils/config.js +0 -220
  209. package/dist/src/utils/os.js +0 -105
  210. package/dist/src/utils/paths.js +0 -159
  211. package/landing/pages/api/discover.ts +0 -43
  212. package/landing/pages/api/health.ts +0 -20
  213. package/scripts/test-whitelist-v2.sh +0 -128
  214. package/src/access-control.ts +0 -174
  215. package/src/hivr-whitelist.ts +0 -110
  216. package/src/http-server-minimal.ts +0 -154
  217. package/src/product-whitelist.ts +0 -246
  218. package/test-actual-handlers.ts +0 -92
  219. package/test-apilayer-all-14.ts +0 -249
  220. package/test-apilayer-fixed.ts +0 -248
  221. package/test-direct-endpoints.ts +0 -174
  222. package/test-exact-endpoints.ts +0 -144
  223. package/test-final.ts +0 -83
  224. package/test-full-routing.ts +0 -100
  225. package/test-handlers-correct.ts +0 -217
  226. package/test-numverify-key.ts +0 -41
  227. package/test-via-handlers.ts +0 -92
  228. package/test-worldnews.mjs +0 -26
@@ -1,256 +0,0 @@
1
- import { v } from "convex/values";
2
- import { mutation, query, internalQuery } from "./_generated/server";
3
- // ============================================
4
- // BYOK - Bring Your Own Key
5
- // ============================================
6
- // Supported providers for BYOK
7
- export const BYOK_PROVIDERS = [
8
- { id: "brave_search", name: "Brave Search", icon: "🔍" },
9
- { id: "openrouter", name: "OpenRouter", icon: "🤖" },
10
- { id: "elevenlabs", name: "ElevenLabs", icon: "🎙️" },
11
- { id: "twilio", name: "Twilio", icon: "📞" },
12
- { id: "resend", name: "Resend", icon: "📧" },
13
- { id: "e2b", name: "E2B", icon: "💻" },
14
- ];
15
- // Simple base64 encoding for MVP (proper encryption in production)
16
- function encryptKey(key) {
17
- return Buffer.from(key).toString("base64");
18
- }
19
- function decryptKey(encryptedKey) {
20
- return Buffer.from(encryptedKey, "base64").toString("utf-8");
21
- }
22
- function getKeyHint(key) {
23
- if (key.length <= 4)
24
- return "••••";
25
- return key.slice(-4);
26
- }
27
- // ============================================
28
- // ADD KEY
29
- // ============================================
30
- export const addKey = mutation({
31
- args: {
32
- token: v.string(),
33
- provider: v.string(),
34
- apiKey: v.string(),
35
- },
36
- handler: async (ctx, args) => {
37
- // Validate session
38
- const session = await ctx.db
39
- .query("agentSessions")
40
- .withIndex("by_sessionToken", (q) => q.eq("sessionToken", args.token))
41
- .first();
42
- if (!session) {
43
- throw new Error("Invalid session");
44
- }
45
- const workspaceId = session.workspaceId;
46
- // Check if key already exists for this provider
47
- const existingKey = await ctx.db
48
- .query("providerKeys")
49
- .withIndex("by_provider", (q) => q.eq("workspaceId", workspaceId).eq("provider", args.provider))
50
- .first();
51
- const now = Date.now();
52
- const encryptedKey = encryptKey(args.apiKey);
53
- const keyHint = getKeyHint(args.apiKey);
54
- let isFirstKey = false;
55
- if (existingKey) {
56
- // Update existing key
57
- await ctx.db.patch(existingKey._id, {
58
- encryptedKey,
59
- keyHint,
60
- updatedAt: now,
61
- });
62
- }
63
- else {
64
- // Create new key
65
- await ctx.db.insert("providerKeys", {
66
- workspaceId,
67
- provider: args.provider,
68
- encryptedKey,
69
- keyHint,
70
- isCustom: false,
71
- createdAt: now,
72
- updatedAt: now,
73
- });
74
- // Check if this is the first BYOK key for earn progress
75
- const allKeys = await ctx.db
76
- .query("providerKeys")
77
- .withIndex("by_workspaceId", (q) => q.eq("workspaceId", workspaceId))
78
- .collect();
79
- // If this is the only key (the one we just created), mark BYOK setup
80
- if (allKeys.length === 1) {
81
- isFirstKey = true;
82
- // Import and call markByokSetup
83
- const earnProgress = await ctx.db
84
- .query("earnProgress")
85
- .withIndex("by_workspaceId", (q) => q.eq("workspaceId", workspaceId))
86
- .first();
87
- if (earnProgress && !earnProgress.byokSetup) {
88
- const newTotal = calculateEarnTotal({ ...earnProgress, byokSetup: true });
89
- await ctx.db.patch(earnProgress._id, {
90
- byokSetup: true,
91
- byokSetupAt: now,
92
- totalEarned: newTotal,
93
- updatedAt: now,
94
- });
95
- // Add 5 calls to workspace limit
96
- const workspace = await ctx.db.get(workspaceId);
97
- if (workspace) {
98
- await ctx.db.patch(workspaceId, {
99
- usageLimit: workspace.usageLimit + 5,
100
- updatedAt: now,
101
- });
102
- }
103
- }
104
- else if (!earnProgress) {
105
- // Create earn progress with byokSetup
106
- await ctx.db.insert("earnProgress", {
107
- workspaceId,
108
- firstDirectCall: false,
109
- apisUsed: [],
110
- apisUsedComplete: false,
111
- agentListed: false,
112
- apiListed: false,
113
- byokSetup: true,
114
- byokSetupAt: now,
115
- githubStarred: false,
116
- twitterFollowed: false,
117
- referralCount: 0,
118
- totalEarned: 5, // BYOK reward
119
- createdAt: now,
120
- updatedAt: now,
121
- });
122
- // Add 5 calls to workspace limit
123
- const workspace = await ctx.db.get(workspaceId);
124
- if (workspace) {
125
- await ctx.db.patch(workspaceId, {
126
- usageLimit: workspace.usageLimit + 5,
127
- updatedAt: now,
128
- });
129
- }
130
- }
131
- }
132
- }
133
- return {
134
- success: true,
135
- action: existingKey ? "updated" : "created",
136
- earnedByok: isFirstKey,
137
- };
138
- },
139
- });
140
- // Helper to calculate earn total (duplicated to avoid circular import)
141
- function calculateEarnTotal(progress) {
142
- let total = 0;
143
- if (progress.firstDirectCall)
144
- total += 15;
145
- if (progress.apisUsedComplete)
146
- total += 10;
147
- if (progress.agentListed)
148
- total += 10;
149
- if (progress.apiListed)
150
- total += 10;
151
- if (progress.byokSetup)
152
- total += 5;
153
- if (progress.githubStarred)
154
- total += 10;
155
- if (progress.twitterFollowed)
156
- total += 5;
157
- total += (progress.referralCount || 0) * 10;
158
- return total;
159
- }
160
- // ============================================
161
- // REMOVE KEY
162
- // ============================================
163
- export const removeKey = mutation({
164
- args: {
165
- token: v.string(),
166
- provider: v.string(),
167
- },
168
- handler: async (ctx, args) => {
169
- // Validate session
170
- const session = await ctx.db
171
- .query("agentSessions")
172
- .withIndex("by_sessionToken", (q) => q.eq("sessionToken", args.token))
173
- .first();
174
- if (!session) {
175
- throw new Error("Invalid session");
176
- }
177
- const workspaceId = session.workspaceId;
178
- // Find and delete the key
179
- const existingKey = await ctx.db
180
- .query("providerKeys")
181
- .withIndex("by_provider", (q) => q.eq("workspaceId", workspaceId).eq("provider", args.provider))
182
- .first();
183
- if (!existingKey) {
184
- throw new Error("Key not found");
185
- }
186
- await ctx.db.delete(existingKey._id);
187
- return { success: true };
188
- },
189
- });
190
- // ============================================
191
- // GET KEYS (for display - no actual key values)
192
- // ============================================
193
- export const getKeys = query({
194
- args: {
195
- token: v.string(),
196
- },
197
- handler: async (ctx, args) => {
198
- // Validate session
199
- const session = await ctx.db
200
- .query("agentSessions")
201
- .withIndex("by_sessionToken", (q) => q.eq("sessionToken", args.token))
202
- .first();
203
- if (!session) {
204
- return { keys: [] };
205
- }
206
- const workspaceId = session.workspaceId;
207
- // Get all keys for this workspace
208
- const keys = await ctx.db
209
- .query("providerKeys")
210
- .withIndex("by_workspaceId", (q) => q.eq("workspaceId", workspaceId))
211
- .collect();
212
- // Return without actual key values
213
- return {
214
- keys: keys.map((key) => ({
215
- provider: key.provider,
216
- keyHint: key.keyHint,
217
- isCustom: key.isCustom,
218
- customConfig: key.customConfig,
219
- createdAt: key.createdAt,
220
- updatedAt: key.updatedAt,
221
- })),
222
- };
223
- },
224
- });
225
- // ============================================
226
- // GET KEY FOR EXECUTION (internal use only)
227
- // ============================================
228
- export const getKeyForExecution = internalQuery({
229
- args: {
230
- workspaceId: v.id("workspaces"),
231
- provider: v.string(),
232
- },
233
- handler: async (ctx, args) => {
234
- const key = await ctx.db
235
- .query("providerKeys")
236
- .withIndex("by_provider", (q) => q.eq("workspaceId", args.workspaceId).eq("provider", args.provider))
237
- .first();
238
- if (!key) {
239
- return null;
240
- }
241
- return {
242
- apiKey: decryptKey(key.encryptedKey),
243
- isCustom: key.isCustom,
244
- customConfig: key.customConfig,
245
- };
246
- },
247
- });
248
- // ============================================
249
- // GET SUPPORTED PROVIDERS
250
- // ============================================
251
- export const getSupportedProviders = query({
252
- args: {},
253
- handler: async () => {
254
- return BYOK_PROVIDERS;
255
- },
256
- });