@nordsym/apiclaw 1.8.6 → 1.8.7

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 (125) hide show
  1. package/README.md +4 -4
  2. package/apiclaw-README.md +12 -12
  3. package/convex/_generated/api.d.ts +4 -0
  4. package/convex/apiKeys.ts +220 -0
  5. package/convex/directCall.ts +49 -14
  6. package/convex/email.ts +5 -5
  7. package/convex/http.ts +598 -40
  8. package/convex/logs.ts +26 -22
  9. package/convex/migrateProviderWorkspaces.ts +154 -35
  10. package/convex/providers.ts +313 -203
  11. package/convex/schema.ts +50 -1
  12. package/convex/searchLogs.ts +2 -6
  13. package/convex/seedPratham.ts +1 -1
  14. package/convex/spendAlerts.ts +2 -2
  15. package/convex/stripeActions.ts +1 -1
  16. package/convex/updateAPIStatus.ts +2 -3
  17. package/convex/workspaceSettings.ts +136 -0
  18. package/dist/cli/commands/demo.js +2 -2
  19. package/dist/cli/commands/doctor.js +1 -1
  20. package/dist/cli/commands/login.js +1 -1
  21. package/dist/cli/commands/setup.js +2 -2
  22. package/dist/discovery.js +1 -1
  23. package/dist/execute.js +3 -3
  24. package/dist/index.js +13 -13
  25. package/dist/ui/errors.js +16 -16
  26. package/dist/ui/prompts.js +1 -1
  27. package/email-templates/filestack-provider-outreach.html +1 -1
  28. package/email-templates/partnership-template.html +1 -1
  29. package/email-templates/pratham-partnership-draft.html +2 -2
  30. package/package.json +2 -2
  31. package/reports/APIClaw-Session-Report-2026-04-05.pdf +0 -0
  32. package/reports/session-report-2026-04-05.html +433 -0
  33. package/src/cli/commands/demo.ts +2 -2
  34. package/src/cli/commands/doctor.ts +1 -1
  35. package/src/cli/commands/login.ts +1 -1
  36. package/src/cli/commands/setup.ts +2 -2
  37. package/src/discovery.ts +1 -1
  38. package/src/execute.ts +3 -3
  39. package/src/index.ts +14 -14
  40. package/src/ui/errors.ts +16 -16
  41. package/src/ui/prompts.ts +1 -1
  42. package/convex/adminActivate.d.ts +0 -3
  43. package/convex/adminActivate.js +0 -47
  44. package/convex/adminStats.d.ts +0 -9
  45. package/convex/adminStats.js +0 -280
  46. package/convex/agents.d.ts +0 -84
  47. package/convex/agents.js +0 -809
  48. package/convex/analytics.d.ts +0 -5
  49. package/convex/analytics.js +0 -167
  50. package/convex/backfillAnalytics.d.ts +0 -2
  51. package/convex/backfillAnalytics.js +0 -20
  52. package/convex/backfillSearchLogs.d.ts +0 -2
  53. package/convex/backfillSearchLogs.js +0 -29
  54. package/convex/billing.d.ts +0 -88
  55. package/convex/billing.js +0 -655
  56. package/convex/capabilities.d.ts +0 -9
  57. package/convex/capabilities.js +0 -145
  58. package/convex/chains.d.ts +0 -68
  59. package/convex/chains.js +0 -1105
  60. package/convex/credits.d.ts +0 -25
  61. package/convex/credits.js +0 -186
  62. package/convex/crons.d.ts +0 -3
  63. package/convex/crons.js +0 -17
  64. package/convex/debugFilestackLogs.d.ts +0 -2
  65. package/convex/debugFilestackLogs.js +0 -17
  66. package/convex/debugGetToken.d.ts +0 -2
  67. package/convex/debugGetToken.js +0 -18
  68. package/convex/directCall.d.ts +0 -72
  69. package/convex/directCall.js +0 -627
  70. package/convex/earnProgress.d.ts +0 -58
  71. package/convex/earnProgress.js +0 -649
  72. package/convex/email.d.ts +0 -14
  73. package/convex/email.js +0 -300
  74. package/convex/feedback.d.ts +0 -7
  75. package/convex/feedback.js +0 -227
  76. package/convex/http.d.ts +0 -3
  77. package/convex/http.js +0 -1408
  78. package/convex/inbound.d.ts +0 -2
  79. package/convex/inbound.js +0 -32
  80. package/convex/logs.d.ts +0 -48
  81. package/convex/logs.js +0 -621
  82. package/convex/migrateFilestack.d.ts +0 -2
  83. package/convex/migrateFilestack.js +0 -74
  84. package/convex/migratePartnersProd.d.ts +0 -8
  85. package/convex/migratePartnersProd.js +0 -165
  86. package/convex/migratePratham.d.ts +0 -2
  87. package/convex/migratePratham.js +0 -121
  88. package/convex/migrateProviderWorkspaces.d.ts +0 -2
  89. package/convex/migrateProviderWorkspaces.js +0 -55
  90. package/convex/mou.d.ts +0 -6
  91. package/convex/mou.js +0 -82
  92. package/convex/providerKeys.d.ts +0 -31
  93. package/convex/providerKeys.js +0 -257
  94. package/convex/providers.d.ts +0 -35
  95. package/convex/providers.js +0 -922
  96. package/convex/purchases.d.ts +0 -7
  97. package/convex/purchases.js +0 -157
  98. package/convex/ratelimit.d.ts +0 -4
  99. package/convex/ratelimit.js +0 -91
  100. package/convex/searchLogs.d.ts +0 -13
  101. package/convex/searchLogs.js +0 -246
  102. package/convex/seedAPILayerAPIs.d.ts +0 -7
  103. package/convex/seedAPILayerAPIs.js +0 -177
  104. package/convex/seedDirectCallConfigs.d.ts +0 -2
  105. package/convex/seedDirectCallConfigs.js +0 -324
  106. package/convex/seedPratham.d.ts +0 -6
  107. package/convex/seedPratham.js +0 -150
  108. package/convex/spendAlerts.d.ts +0 -36
  109. package/convex/spendAlerts.js +0 -380
  110. package/convex/stripeActions.d.ts +0 -19
  111. package/convex/stripeActions.js +0 -411
  112. package/convex/teams.d.ts +0 -21
  113. package/convex/teams.js +0 -215
  114. package/convex/telemetry.d.ts +0 -4
  115. package/convex/telemetry.js +0 -74
  116. package/convex/updateAPIStatus.d.ts +0 -6
  117. package/convex/updateAPIStatus.js +0 -40
  118. package/convex/usage.d.ts +0 -27
  119. package/convex/usage.js +0 -229
  120. package/convex/waitlist.d.ts +0 -4
  121. package/convex/waitlist.js +0 -49
  122. package/convex/webhooks.d.ts +0 -12
  123. package/convex/webhooks.js +0 -410
  124. package/convex/workspaces.d.ts +0 -33
  125. package/convex/workspaces.js +0 -991
@@ -1,257 +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
- });
257
- //# sourceMappingURL=providerKeys.js.map
@@ -1,35 +0,0 @@
1
- export declare const registerProvider: any;
2
- export declare const getProviderByEmail: any;
3
- export declare const getProviderAPIs: any;
4
- export declare const getApprovedAPIs: any;
5
- export declare const getCategories: any;
6
- export declare const trackDiscovery: any;
7
- export declare const logDiscovery: any;
8
- export declare const trackDiscoveryByProvider: any;
9
- export declare const getPendingProviders: any;
10
- export declare const approveProvider: any;
11
- export declare const rejectProvider: any;
12
- export declare const getProviderStats: any;
13
- export declare const createMagicLink: any;
14
- export declare const verifyMagicLink: any;
15
- export declare const getSession: any;
16
- export declare const getApiById: any;
17
- export declare const getProviderAPIsWithStatus: any;
18
- export declare const debugDeleteAPI: any;
19
- export declare const addAPI: any;
20
- export declare const deleteAPI: any;
21
- export declare const debugUpdateProvider: any;
22
- export declare const debugAddAPI: any;
23
- export declare const debugDeleteProvider: any;
24
- export declare const debugListSessions: any;
25
- export declare const debugListProviders: any;
26
- export declare const getAnalytics: any;
27
- export declare const getEarnings: any;
28
- export declare const getAllProviders: any;
29
- export declare const getAllAPIs: any;
30
- export declare const debugUpdateAPI: any;
31
- export declare const getByWorkspaceId: any;
32
- export declare const createForWorkspace: any;
33
- export declare const deleteForWorkspace: any;
34
- export declare const resetDiscoveryCounts: any;
35
- //# sourceMappingURL=providers.d.ts.map