@nordsym/apiclaw 2.1.0 → 2.2.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 (185) hide show
  1. package/README.md +15 -2
  2. package/dist/bin-http.js +0 -0
  3. package/dist/bin.bundled.js +79288 -0
  4. package/dist/funnel-client.d.ts +24 -0
  5. package/dist/funnel-client.d.ts.map +1 -0
  6. package/dist/funnel-client.js +131 -0
  7. package/dist/funnel-client.js.map +1 -0
  8. package/dist/funnel.test.d.ts +2 -0
  9. package/dist/funnel.test.d.ts.map +1 -0
  10. package/dist/funnel.test.js +145 -0
  11. package/dist/funnel.test.js.map +1 -0
  12. package/dist/gateway-client.d.ts.map +1 -1
  13. package/dist/gateway-client.js +24 -2
  14. package/dist/gateway-client.js.map +1 -1
  15. package/dist/index.bundled.js +61263 -0
  16. package/dist/index.js +161 -74
  17. package/dist/index.js.map +1 -1
  18. package/dist/postinstall.d.ts +0 -5
  19. package/dist/postinstall.d.ts.map +1 -1
  20. package/dist/postinstall.js +24 -3
  21. package/dist/postinstall.js.map +1 -1
  22. package/dist/registration-guard.d.ts +29 -0
  23. package/dist/registration-guard.d.ts.map +1 -0
  24. package/dist/registration-guard.js +87 -0
  25. package/dist/registration-guard.js.map +1 -0
  26. package/package.json +7 -2
  27. package/.claude/settings.local.json +0 -9
  28. package/.env.prod +0 -1
  29. package/apiclaw-README.md +0 -494
  30. package/convex/_generated/api.d.ts +0 -137
  31. package/convex/_generated/api.js +0 -23
  32. package/convex/_generated/dataModel.d.ts +0 -60
  33. package/convex/_generated/server.d.ts +0 -143
  34. package/convex/_generated/server.js +0 -93
  35. package/convex/adminActivate.ts +0 -53
  36. package/convex/adminStats.ts +0 -306
  37. package/convex/agents.ts +0 -939
  38. package/convex/analytics.ts +0 -187
  39. package/convex/apiKeys.ts +0 -220
  40. package/convex/backfillAnalytics.ts +0 -272
  41. package/convex/backfillSearchLogs.ts +0 -35
  42. package/convex/billing.ts +0 -834
  43. package/convex/capabilities.ts +0 -157
  44. package/convex/chains.ts +0 -1318
  45. package/convex/credits.ts +0 -211
  46. package/convex/crons.ts +0 -50
  47. package/convex/debugFilestackLogs.ts +0 -16
  48. package/convex/debugGetToken.ts +0 -18
  49. package/convex/directCall.ts +0 -713
  50. package/convex/earnProgress.ts +0 -753
  51. package/convex/email.ts +0 -329
  52. package/convex/feedback.ts +0 -265
  53. package/convex/http.ts +0 -3430
  54. package/convex/inbound.ts +0 -32
  55. package/convex/logs.ts +0 -701
  56. package/convex/migrateFilestack.ts +0 -81
  57. package/convex/migratePartnersProd.ts +0 -174
  58. package/convex/migratePratham.ts +0 -126
  59. package/convex/migrateProviderWorkspaces.ts +0 -175
  60. package/convex/mou.ts +0 -91
  61. package/convex/providerKeys.ts +0 -289
  62. package/convex/providers.ts +0 -1135
  63. package/convex/purchases.ts +0 -183
  64. package/convex/ratelimit.ts +0 -104
  65. package/convex/schema.ts +0 -869
  66. package/convex/searchLogs.ts +0 -265
  67. package/convex/seedAPILayerAPIs.ts +0 -191
  68. package/convex/seedDirectCallConfigs.ts +0 -336
  69. package/convex/seedPratham.ts +0 -149
  70. package/convex/spendAlerts.ts +0 -442
  71. package/convex/stripeActions.ts +0 -607
  72. package/convex/teams.ts +0 -243
  73. package/convex/telemetry.ts +0 -81
  74. package/convex/tsconfig.json +0 -25
  75. package/convex/updateAPIStatus.ts +0 -44
  76. package/convex/usage.ts +0 -260
  77. package/convex/usageReports.ts +0 -357
  78. package/convex/waitlist.ts +0 -55
  79. package/convex/webhooks.ts +0 -494
  80. package/convex/workspaceSettings.ts +0 -143
  81. package/convex/workspaces.ts +0 -1331
  82. package/convex.json +0 -3
  83. package/direct-test.mjs +0 -51
  84. package/email-templates/filestack-provider-outreach.html +0 -162
  85. package/email-templates/partnership-template.html +0 -116
  86. package/email-templates/pratham-draft-preview.txt +0 -57
  87. package/email-templates/pratham-partnership-draft.html +0 -141
  88. package/reports/APIClaw-Session-Report-2026-04-05.pdf +0 -0
  89. package/reports/pipeline/PIPELINE-REPORT.json +0 -153
  90. package/reports/pipeline/acquire_apisguru.json +0 -17
  91. package/reports/pipeline/capabilities.json +0 -38
  92. package/reports/pipeline/discover_azure_recursive.json +0 -1551
  93. package/reports/pipeline/discover_github.json +0 -25
  94. package/reports/pipeline/discover_github_repos.json +0 -49
  95. package/reports/pipeline/discover_swaggerhub.json +0 -24
  96. package/reports/pipeline/discover_well_known.json +0 -23
  97. package/reports/pipeline/fetch_specs.json +0 -19
  98. package/reports/pipeline/generate_providers.json +0 -14
  99. package/reports/pipeline/match_registry.json +0 -11
  100. package/reports/pipeline/parse_specs.json +0 -17
  101. package/reports/pipeline/promote_candidates.json +0 -34
  102. package/reports/pipeline/validate.json +0 -30
  103. package/reports/pipeline/validate_smoke_details.json +0 -3835
  104. package/reports/session-report-2026-04-05.html +0 -433
  105. package/seed-apis-direct.mjs +0 -106
  106. package/src/access-control.ts +0 -174
  107. package/src/adapters/base.ts +0 -364
  108. package/src/adapters/claude-desktop.ts +0 -41
  109. package/src/adapters/cline.ts +0 -88
  110. package/src/adapters/continue.ts +0 -91
  111. package/src/adapters/cursor.ts +0 -43
  112. package/src/adapters/custom.ts +0 -188
  113. package/src/adapters/detect.ts +0 -202
  114. package/src/adapters/index.ts +0 -47
  115. package/src/adapters/windsurf.ts +0 -44
  116. package/src/bin-http.ts +0 -45
  117. package/src/bin.ts +0 -34
  118. package/src/capability-router.ts +0 -331
  119. package/src/chainExecutor.ts +0 -730
  120. package/src/chainResolver.test.ts +0 -246
  121. package/src/chainResolver.ts +0 -658
  122. package/src/cli/commands/demo.ts +0 -109
  123. package/src/cli/commands/doctor.ts +0 -435
  124. package/src/cli/commands/index.ts +0 -9
  125. package/src/cli/commands/login.ts +0 -203
  126. package/src/cli/commands/mcp-install.ts +0 -373
  127. package/src/cli/commands/restore.ts +0 -333
  128. package/src/cli/commands/setup.ts +0 -297
  129. package/src/cli/commands/uninstall.ts +0 -240
  130. package/src/cli/index.ts +0 -148
  131. package/src/cli.ts +0 -370
  132. package/src/confirmation.ts +0 -296
  133. package/src/credentials.ts +0 -455
  134. package/src/credits.ts +0 -329
  135. package/src/crypto.ts +0 -75
  136. package/src/discovery.ts +0 -568
  137. package/src/enterprise/env.ts +0 -156
  138. package/src/enterprise/index.ts +0 -7
  139. package/src/enterprise/script-generator.ts +0 -481
  140. package/src/execute-dynamic.ts +0 -617
  141. package/src/execute.ts +0 -2386
  142. package/src/gateway-client.ts +0 -192
  143. package/src/hivr-whitelist.ts +0 -110
  144. package/src/http-api.ts +0 -286
  145. package/src/http-server-minimal.ts +0 -154
  146. package/src/index.ts +0 -2611
  147. package/src/intelligent-gateway.ts +0 -339
  148. package/src/mcp-analytics.ts +0 -156
  149. package/src/metered.ts +0 -149
  150. package/src/open-apis-generated.ts +0 -157
  151. package/src/open-apis.ts +0 -558
  152. package/src/postinstall.ts +0 -18
  153. package/src/product-whitelist.ts +0 -246
  154. package/src/proxy.ts +0 -36
  155. package/src/session.ts +0 -129
  156. package/src/stripe.ts +0 -497
  157. package/src/telemetry.ts +0 -71
  158. package/src/test.ts +0 -135
  159. package/src/types/convex-api.d.ts +0 -20
  160. package/src/types/convex-api.ts +0 -21
  161. package/src/types.ts +0 -109
  162. package/src/ui/colors.ts +0 -219
  163. package/src/ui/errors.ts +0 -394
  164. package/src/ui/index.ts +0 -17
  165. package/src/ui/prompts.ts +0 -390
  166. package/src/ui/spinner.ts +0 -325
  167. package/src/utils/backup.ts +0 -224
  168. package/src/utils/config.ts +0 -318
  169. package/src/utils/os.ts +0 -124
  170. package/src/utils/paths.ts +0 -203
  171. package/src/webhook.ts +0 -107
  172. package/test-10-working.cjs +0 -97
  173. package/test-14-final.cjs +0 -96
  174. package/test-actual-handlers.ts +0 -92
  175. package/test-apilayer-all-14.ts +0 -249
  176. package/test-apilayer-fixed.ts +0 -248
  177. package/test-direct-endpoints.ts +0 -174
  178. package/test-exact-endpoints.ts +0 -144
  179. package/test-final.ts +0 -83
  180. package/test-full-routing.ts +0 -100
  181. package/test-handlers-correct.ts +0 -217
  182. package/test-numverify-key.ts +0 -41
  183. package/test-via-handlers.ts +0 -92
  184. package/test-worldnews.mjs +0 -26
  185. package/tsconfig.json +0 -20
@@ -1,289 +0,0 @@
1
- import { v } from "convex/values";
2
- import { mutation, query, internalQuery } from "./_generated/server";
3
-
4
- // ============================================
5
- // BYOK - Bring Your Own Key
6
- // ============================================
7
-
8
- // Supported providers for BYOK
9
- export const BYOK_PROVIDERS = [
10
- { id: "brave_search", name: "Brave Search", icon: "🔍" },
11
- { id: "openrouter", name: "OpenRouter", icon: "🤖" },
12
- { id: "elevenlabs", name: "ElevenLabs", icon: "🎙️" },
13
- { id: "twilio", name: "Twilio", icon: "📞" },
14
- { id: "resend", name: "Resend", icon: "📧" },
15
- { id: "e2b", name: "E2B", icon: "💻" },
16
- ] as const;
17
-
18
- // Simple base64 encoding for MVP (proper encryption in production)
19
- function encryptKey(key: string): string {
20
- return Buffer.from(key).toString("base64");
21
- }
22
-
23
- function decryptKey(encryptedKey: string): string {
24
- return Buffer.from(encryptedKey, "base64").toString("utf-8");
25
- }
26
-
27
- function getKeyHint(key: string): string {
28
- if (key.length <= 4) return "••••";
29
- return key.slice(-4);
30
- }
31
-
32
- // ============================================
33
- // ADD KEY
34
- // ============================================
35
-
36
- export const addKey = mutation({
37
- args: {
38
- token: v.string(),
39
- provider: v.string(),
40
- apiKey: v.string(),
41
- },
42
- handler: async (ctx, args) => {
43
- // Validate session
44
- const session = await ctx.db
45
- .query("agentSessions")
46
- .withIndex("by_sessionToken", (q) => q.eq("sessionToken", args.token))
47
- .first();
48
-
49
- if (!session) {
50
- throw new Error("Invalid session");
51
- }
52
-
53
- const workspaceId = session.workspaceId;
54
-
55
- // Check if key already exists for this provider
56
- const existingKey = await ctx.db
57
- .query("providerKeys")
58
- .withIndex("by_provider", (q) =>
59
- q.eq("workspaceId", workspaceId).eq("provider", args.provider)
60
- )
61
- .first();
62
-
63
- const now = Date.now();
64
- const encryptedKey = encryptKey(args.apiKey);
65
- const keyHint = getKeyHint(args.apiKey);
66
-
67
- let isFirstKey = false;
68
-
69
- if (existingKey) {
70
- // Update existing key
71
- await ctx.db.patch(existingKey._id, {
72
- encryptedKey,
73
- keyHint,
74
- updatedAt: now,
75
- });
76
- } else {
77
- // Create new key
78
- await ctx.db.insert("providerKeys", {
79
- workspaceId,
80
- provider: args.provider,
81
- encryptedKey,
82
- keyHint,
83
- isCustom: false,
84
- createdAt: now,
85
- updatedAt: now,
86
- });
87
-
88
- // Check if this is the first BYOK key for earn progress
89
- const allKeys = await ctx.db
90
- .query("providerKeys")
91
- .withIndex("by_workspaceId", (q) => q.eq("workspaceId", workspaceId))
92
- .collect();
93
-
94
- // If this is the only key (the one we just created), mark BYOK setup
95
- if (allKeys.length === 1) {
96
- isFirstKey = true;
97
- // Import and call markByokSetup
98
- const earnProgress = await ctx.db
99
- .query("earnProgress")
100
- .withIndex("by_workspaceId", (q) => q.eq("workspaceId", workspaceId))
101
- .first();
102
-
103
- if (earnProgress && !earnProgress.byokSetup) {
104
- const newTotal = calculateEarnTotal({ ...earnProgress, byokSetup: true });
105
- await ctx.db.patch(earnProgress._id, {
106
- byokSetup: true,
107
- byokSetupAt: now,
108
- totalEarned: newTotal,
109
- updatedAt: now,
110
- });
111
- // Add 5 calls to workspace limit
112
- const workspace = await ctx.db.get(workspaceId);
113
- if (workspace) {
114
- await ctx.db.patch(workspaceId, {
115
- usageLimit: workspace.usageLimit + 5,
116
- updatedAt: now,
117
- });
118
- }
119
- } else if (!earnProgress) {
120
- // Create earn progress with byokSetup
121
- await ctx.db.insert("earnProgress", {
122
- workspaceId,
123
- firstDirectCall: false,
124
- apisUsed: [],
125
- apisUsedComplete: false,
126
- agentListed: false,
127
- apiListed: false,
128
- byokSetup: true,
129
- byokSetupAt: now,
130
- githubStarred: false,
131
- twitterFollowed: false,
132
- referralCount: 0,
133
- totalEarned: 5, // BYOK reward
134
- createdAt: now,
135
- updatedAt: now,
136
- });
137
- // Add 5 calls to workspace limit
138
- const workspace = await ctx.db.get(workspaceId);
139
- if (workspace) {
140
- await ctx.db.patch(workspaceId, {
141
- usageLimit: workspace.usageLimit + 5,
142
- updatedAt: now,
143
- });
144
- }
145
- }
146
- }
147
- }
148
-
149
- return {
150
- success: true,
151
- action: existingKey ? "updated" : "created",
152
- earnedByok: isFirstKey,
153
- };
154
- },
155
- });
156
-
157
- // Helper to calculate earn total (duplicated to avoid circular import)
158
- function calculateEarnTotal(progress: any): number {
159
- let total = 0;
160
- if (progress.firstDirectCall) total += 15;
161
- if (progress.apisUsedComplete) total += 10;
162
- if (progress.agentListed) total += 10;
163
- if (progress.apiListed) total += 10;
164
- if (progress.byokSetup) total += 5;
165
- if (progress.githubStarred) total += 10;
166
- if (progress.twitterFollowed) total += 5;
167
- total += (progress.referralCount || 0) * 10;
168
- return total;
169
- }
170
-
171
- // ============================================
172
- // REMOVE KEY
173
- // ============================================
174
-
175
- export const removeKey = mutation({
176
- args: {
177
- token: v.string(),
178
- provider: v.string(),
179
- },
180
- handler: async (ctx, args) => {
181
- // Validate session
182
- const session = await ctx.db
183
- .query("agentSessions")
184
- .withIndex("by_sessionToken", (q) => q.eq("sessionToken", args.token))
185
- .first();
186
-
187
- if (!session) {
188
- throw new Error("Invalid session");
189
- }
190
-
191
- const workspaceId = session.workspaceId;
192
-
193
- // Find and delete the key
194
- const existingKey = await ctx.db
195
- .query("providerKeys")
196
- .withIndex("by_provider", (q) =>
197
- q.eq("workspaceId", workspaceId).eq("provider", args.provider)
198
- )
199
- .first();
200
-
201
- if (!existingKey) {
202
- throw new Error("Key not found");
203
- }
204
-
205
- await ctx.db.delete(existingKey._id);
206
- return { success: true };
207
- },
208
- });
209
-
210
- // ============================================
211
- // GET KEYS (for display - no actual key values)
212
- // ============================================
213
-
214
- export const getKeys = query({
215
- args: {
216
- token: v.string(),
217
- },
218
- handler: async (ctx, args) => {
219
- // Validate session
220
- const session = await ctx.db
221
- .query("agentSessions")
222
- .withIndex("by_sessionToken", (q) => q.eq("sessionToken", args.token))
223
- .first();
224
-
225
- if (!session) {
226
- return { keys: [] };
227
- }
228
-
229
- const workspaceId = session.workspaceId;
230
-
231
- // Get all keys for this workspace
232
- const keys = await ctx.db
233
- .query("providerKeys")
234
- .withIndex("by_workspaceId", (q) => q.eq("workspaceId", workspaceId))
235
- .collect();
236
-
237
- // Return without actual key values
238
- return {
239
- keys: keys.map((key) => ({
240
- provider: key.provider,
241
- keyHint: key.keyHint,
242
- isCustom: key.isCustom,
243
- customConfig: key.customConfig,
244
- createdAt: key.createdAt,
245
- updatedAt: key.updatedAt,
246
- })),
247
- };
248
- },
249
- });
250
-
251
- // ============================================
252
- // GET KEY FOR EXECUTION (internal use only)
253
- // ============================================
254
-
255
- export const getKeyForExecution = internalQuery({
256
- args: {
257
- workspaceId: v.id("workspaces"),
258
- provider: v.string(),
259
- },
260
- handler: async (ctx, args) => {
261
- const key = await ctx.db
262
- .query("providerKeys")
263
- .withIndex("by_provider", (q) =>
264
- q.eq("workspaceId", args.workspaceId).eq("provider", args.provider)
265
- )
266
- .first();
267
-
268
- if (!key) {
269
- return null;
270
- }
271
-
272
- return {
273
- apiKey: decryptKey(key.encryptedKey),
274
- isCustom: key.isCustom,
275
- customConfig: key.customConfig,
276
- };
277
- },
278
- });
279
-
280
- // ============================================
281
- // GET SUPPORTED PROVIDERS
282
- // ============================================
283
-
284
- export const getSupportedProviders = query({
285
- args: {},
286
- handler: async () => {
287
- return BYOK_PROVIDERS;
288
- },
289
- });