@nordsym/apiclaw 1.7.8 → 1.7.10

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 (141) hide show
  1. package/convex/adminStats.ts +66 -1
  2. package/convex/providers.ts +39 -0
  3. package/convex/workspaces.ts +2 -2
  4. package/package.json +1 -1
  5. package/src/index.ts +27 -18
  6. package/convex/adminActivate.d.ts +0 -3
  7. package/convex/adminActivate.d.ts.map +0 -1
  8. package/convex/adminActivate.js +0 -47
  9. package/convex/adminActivate.js.map +0 -1
  10. package/convex/adminStats.d.ts +0 -3
  11. package/convex/adminStats.d.ts.map +0 -1
  12. package/convex/adminStats.js +0 -42
  13. package/convex/adminStats.js.map +0 -1
  14. package/convex/agents.d.ts +0 -76
  15. package/convex/agents.d.ts.map +0 -1
  16. package/convex/agents.js +0 -699
  17. package/convex/agents.js.map +0 -1
  18. package/convex/analytics.d.ts +0 -5
  19. package/convex/analytics.d.ts.map +0 -1
  20. package/convex/analytics.js +0 -166
  21. package/convex/analytics.js.map +0 -1
  22. package/convex/billing.d.ts +0 -88
  23. package/convex/billing.d.ts.map +0 -1
  24. package/convex/billing.js +0 -655
  25. package/convex/billing.js.map +0 -1
  26. package/convex/capabilities.d.ts +0 -9
  27. package/convex/capabilities.d.ts.map +0 -1
  28. package/convex/capabilities.js +0 -145
  29. package/convex/capabilities.js.map +0 -1
  30. package/convex/chains.d.ts +0 -68
  31. package/convex/chains.d.ts.map +0 -1
  32. package/convex/chains.js +0 -1105
  33. package/convex/chains.js.map +0 -1
  34. package/convex/credits.d.ts +0 -25
  35. package/convex/credits.d.ts.map +0 -1
  36. package/convex/credits.js +0 -186
  37. package/convex/credits.js.map +0 -1
  38. package/convex/crons.d.ts +0 -3
  39. package/convex/crons.d.ts.map +0 -1
  40. package/convex/crons.js +0 -17
  41. package/convex/crons.js.map +0 -1
  42. package/convex/directCall.d.ts +0 -72
  43. package/convex/directCall.d.ts.map +0 -1
  44. package/convex/directCall.js +0 -627
  45. package/convex/directCall.js.map +0 -1
  46. package/convex/earnProgress.d.ts +0 -58
  47. package/convex/earnProgress.d.ts.map +0 -1
  48. package/convex/earnProgress.js +0 -649
  49. package/convex/earnProgress.js.map +0 -1
  50. package/convex/email.d.ts +0 -14
  51. package/convex/email.d.ts.map +0 -1
  52. package/convex/email.js +0 -300
  53. package/convex/email.js.map +0 -1
  54. package/convex/feedback.d.ts +0 -7
  55. package/convex/feedback.d.ts.map +0 -1
  56. package/convex/feedback.js +0 -227
  57. package/convex/feedback.js.map +0 -1
  58. package/convex/http.d.ts +0 -3
  59. package/convex/http.d.ts.map +0 -1
  60. package/convex/http.js +0 -1405
  61. package/convex/http.js.map +0 -1
  62. package/convex/inbound.d.ts +0 -2
  63. package/convex/inbound.d.ts.map +0 -1
  64. package/convex/inbound.js +0 -32
  65. package/convex/inbound.js.map +0 -1
  66. package/convex/logs.d.ts +0 -48
  67. package/convex/logs.d.ts.map +0 -1
  68. package/convex/logs.js +0 -605
  69. package/convex/logs.js.map +0 -1
  70. package/convex/mou.d.ts +0 -6
  71. package/convex/mou.d.ts.map +0 -1
  72. package/convex/mou.js +0 -82
  73. package/convex/mou.js.map +0 -1
  74. package/convex/providerKeys.d.ts +0 -31
  75. package/convex/providerKeys.d.ts.map +0 -1
  76. package/convex/providerKeys.js +0 -257
  77. package/convex/providerKeys.js.map +0 -1
  78. package/convex/providers.d.ts +0 -32
  79. package/convex/providers.d.ts.map +0 -1
  80. package/convex/providers.js +0 -814
  81. package/convex/providers.js.map +0 -1
  82. package/convex/purchases.d.ts +0 -7
  83. package/convex/purchases.d.ts.map +0 -1
  84. package/convex/purchases.js +0 -157
  85. package/convex/purchases.js.map +0 -1
  86. package/convex/ratelimit.d.ts +0 -4
  87. package/convex/ratelimit.d.ts.map +0 -1
  88. package/convex/ratelimit.js +0 -91
  89. package/convex/ratelimit.js.map +0 -1
  90. package/convex/searchLogs.d.ts +0 -4
  91. package/convex/searchLogs.d.ts.map +0 -1
  92. package/convex/searchLogs.js +0 -129
  93. package/convex/searchLogs.js.map +0 -1
  94. package/convex/seedAPILayerAPIs.d.ts +0 -7
  95. package/convex/seedAPILayerAPIs.d.ts.map +0 -1
  96. package/convex/seedAPILayerAPIs.js +0 -177
  97. package/convex/seedAPILayerAPIs.js.map +0 -1
  98. package/convex/seedDirectCallConfigs.d.ts +0 -2
  99. package/convex/seedDirectCallConfigs.d.ts.map +0 -1
  100. package/convex/seedDirectCallConfigs.js +0 -324
  101. package/convex/seedDirectCallConfigs.js.map +0 -1
  102. package/convex/seedPratham.d.ts +0 -6
  103. package/convex/seedPratham.d.ts.map +0 -1
  104. package/convex/seedPratham.js +0 -150
  105. package/convex/seedPratham.js.map +0 -1
  106. package/convex/spendAlerts.d.ts +0 -36
  107. package/convex/spendAlerts.d.ts.map +0 -1
  108. package/convex/spendAlerts.js +0 -380
  109. package/convex/spendAlerts.js.map +0 -1
  110. package/convex/stripeActions.d.ts +0 -19
  111. package/convex/stripeActions.d.ts.map +0 -1
  112. package/convex/stripeActions.js +0 -411
  113. package/convex/stripeActions.js.map +0 -1
  114. package/convex/teams.d.ts +0 -21
  115. package/convex/teams.d.ts.map +0 -1
  116. package/convex/teams.js +0 -215
  117. package/convex/teams.js.map +0 -1
  118. package/convex/telemetry.d.ts +0 -4
  119. package/convex/telemetry.d.ts.map +0 -1
  120. package/convex/telemetry.js +0 -74
  121. package/convex/telemetry.js.map +0 -1
  122. package/convex/updateAPIStatus.d.ts +0 -6
  123. package/convex/updateAPIStatus.d.ts.map +0 -1
  124. package/convex/updateAPIStatus.js +0 -40
  125. package/convex/updateAPIStatus.js.map +0 -1
  126. package/convex/usage.d.ts +0 -27
  127. package/convex/usage.d.ts.map +0 -1
  128. package/convex/usage.js +0 -229
  129. package/convex/usage.js.map +0 -1
  130. package/convex/waitlist.d.ts +0 -4
  131. package/convex/waitlist.d.ts.map +0 -1
  132. package/convex/waitlist.js +0 -49
  133. package/convex/waitlist.js.map +0 -1
  134. package/convex/webhooks.d.ts +0 -12
  135. package/convex/webhooks.d.ts.map +0 -1
  136. package/convex/webhooks.js +0 -410
  137. package/convex/webhooks.js.map +0 -1
  138. package/convex/workspaces.d.ts +0 -31
  139. package/convex/workspaces.d.ts.map +0 -1
  140. package/convex/workspaces.js +0 -975
  141. package/convex/workspaces.js.map +0 -1
@@ -1,4 +1,5 @@
1
- import { query } from "./_generated/server";
1
+ import { query, mutation } from "./_generated/server";
2
+ import { v } from "convex/values";
2
3
 
3
4
  // Get total user/workspace count
4
5
  export const getTotalWorkspaces = query({
@@ -42,3 +43,67 @@ export const listWorkspaces = query({
42
43
  }));
43
44
  },
44
45
  });
46
+
47
+ // Delete workspace by email or empty email ghosts
48
+ export const cleanupWorkspaces = mutation({
49
+ args: {
50
+ deleteEmptyEmail: v.optional(v.boolean()),
51
+ deleteEmail: v.optional(v.string()),
52
+ deleteEmailWithTier: v.optional(v.string()),
53
+ activateEmail: v.optional(v.string()),
54
+ },
55
+ handler: async (ctx, { deleteEmptyEmail, deleteEmail, deleteEmailWithTier, activateEmail }) => {
56
+ const workspaces = await ctx.db.query("workspaces").collect();
57
+ let deleted = 0;
58
+
59
+ // Activate a pending workspace
60
+ if (activateEmail) {
61
+ for (const ws of workspaces) {
62
+ if (ws.email === activateEmail && ws.status === "pending") {
63
+ await ctx.db.patch(ws._id, { status: "active" });
64
+ return { activated: activateEmail };
65
+ }
66
+ }
67
+ return { error: "not found or not pending" };
68
+ }
69
+
70
+ for (const ws of workspaces) {
71
+ let shouldDelete = false;
72
+
73
+ if (deleteEmptyEmail && (!ws.email || ws.email === "")) {
74
+ shouldDelete = true;
75
+ }
76
+ if (deleteEmail && ws.email === deleteEmail) {
77
+ shouldDelete = true;
78
+ }
79
+ // Delete specific email+tier combo (e.g. remove free duplicate but keep founder)
80
+ if (deleteEmailWithTier) {
81
+ const [email, tier] = deleteEmailWithTier.split(":");
82
+ if (ws.email === email && ws.tier === tier) {
83
+ shouldDelete = true;
84
+ }
85
+ }
86
+
87
+ if (shouldDelete) {
88
+ // Delete associated sessions
89
+ const sessions = await ctx.db.query("sessions").collect();
90
+ for (const s of sessions) {
91
+ if ((s as any).workspaceId === ws._id) {
92
+ await ctx.db.delete(s._id);
93
+ }
94
+ }
95
+ // Delete associated agents
96
+ const agents = await ctx.db.query("agents").collect();
97
+ for (const a of agents) {
98
+ if (a.workspaceId === ws._id) {
99
+ await ctx.db.delete(a._id);
100
+ }
101
+ }
102
+ await ctx.db.delete(ws._id);
103
+ deleted++;
104
+ }
105
+ }
106
+
107
+ return { deleted };
108
+ },
109
+ });
@@ -159,6 +159,45 @@ export const trackDiscovery = mutation({
159
159
  },
160
160
  });
161
161
 
162
+ // Track discovery by provider name + query keyword matching
163
+ // Called from MCP server when discover_apis matches provider keywords
164
+ export const trackDiscoveryByProvider = mutation({
165
+ args: { provider: v.string(), query: v.string() },
166
+ handler: async (ctx, args) => {
167
+ // Find all APIs belonging to this provider's workspace
168
+ const providerEmailMap: Record<string, string> = {
169
+ apilayer: "gustav_hemmingsson@hotmail.com",
170
+ };
171
+ const email = providerEmailMap[args.provider];
172
+ if (!email) return;
173
+
174
+ const workspace = await ctx.db
175
+ .query("workspaces")
176
+ .withIndex("by_email", (q: any) => q.eq("email", email))
177
+ .first();
178
+ if (!workspace) return;
179
+
180
+ // Find provider record
181
+ const providers = await ctx.db.query("providers").collect();
182
+ const provider = providers.find((p: any) => p.workspaceId === workspace._id);
183
+ if (!provider) return;
184
+
185
+ // Get all APIs for this provider
186
+ const apis = await ctx.db.query("providerAPIs").collect();
187
+ const providerApis = apis.filter((a: any) => a.providerId === provider._id);
188
+
189
+ // Increment discoveryCount on ALL provider APIs (the whole catalog was discovered)
190
+ for (const api of providerApis) {
191
+ await ctx.db.patch(api._id, {
192
+ discoveryCount: (api.discoveryCount || 0) + 1,
193
+ lastDiscoveredAt: Date.now(),
194
+ });
195
+ }
196
+
197
+ return { updated: providerApis.length };
198
+ },
199
+ });
200
+
162
201
  // Admin: List pending providers
163
202
  export const getPendingProviders = query({
164
203
  handler: async (ctx) => {
@@ -95,9 +95,9 @@ export const verifyMagicLink = mutation({
95
95
  status: "active",
96
96
  tier: "free",
97
97
  usageCount: 0,
98
- usageLimit: 50, // Legacy field, now using weekly limits
98
+ usageLimit: 50, // 50 calls/month for free tier
99
99
  weeklyUsageCount: 0,
100
- weeklyUsageLimit: 50, // 50 calls/week for free tier
100
+ weeklyUsageLimit: 50, // Monthly limit (field name is legacy)
101
101
  hourlyUsageCount: 0,
102
102
  referralCode: newReferralCode!,
103
103
  createdAt: Date.now(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordsym/apiclaw",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "The API layer for AI agents. Dashboard + 22K APIs + 18 Direct Call providers. MCP native.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -97,7 +97,7 @@ const anonymousRateLimits = new Map<string, AnonymousRateLimitState>();
97
97
  // Rate limit constants
98
98
  const ANONYMOUS_HOURLY_LIMIT = 5;
99
99
  const ANONYMOUS_WEEKLY_LIMIT = 10;
100
- const FREE_WEEKLY_LIMIT = 50;
100
+ const FREE_MONTHLY_LIMIT = 50;
101
101
 
102
102
  /**
103
103
  * Calculate minutes until next hour
@@ -112,14 +112,10 @@ function calculateMinutesUntilNextHour(): number {
112
112
  /**
113
113
  * Get next Monday 00:00 UTC as ISO string
114
114
  */
115
- function getNextMondayUTC(): string {
115
+ function getNextMonthUTC(): string {
116
116
  const now = new Date();
117
- const dayOfWeek = now.getUTCDay(); // 0 = Sunday, 1 = Monday, etc.
118
- const daysUntilMonday = dayOfWeek === 0 ? 1 : 8 - dayOfWeek;
119
- const nextMonday = new Date(now);
120
- nextMonday.setUTCDate(now.getUTCDate() + daysUntilMonday);
121
- nextMonday.setUTCHours(0, 0, 0, 0);
122
- return nextMonday.toISOString().replace('T', ' ').slice(0, 16) + ' UTC';
117
+ const nextMonth = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 1, 1));
118
+ return nextMonth.toISOString().replace('T', ' ').slice(0, 16) + ' UTC';
123
119
  }
124
120
 
125
121
  /**
@@ -174,10 +170,10 @@ function checkAnonymousRateLimit(fingerprint: string): { allowed: boolean; error
174
170
  allowed: false,
175
171
  error: JSON.stringify({
176
172
  success: false,
177
- error: `Weekly limit reached (${ANONYMOUS_WEEKLY_LIMIT} calls)`,
178
- hint: "Register to get 50 calls/week",
173
+ error: `Monthly limit reached (${ANONYMOUS_WEEKLY_LIMIT} calls)`,
174
+ hint: "Register to get 50 calls/month",
179
175
  action: "Run: register_owner({ email: 'you@example.com' })",
180
- retry_after: getNextMondayUTC()
176
+ retry_after: getNextMonthUTC()
181
177
  }, null, 2)
182
178
  };
183
179
  }
@@ -267,7 +263,7 @@ async function trackEarnProgress(workspaceId: string, provider: string, action:
267
263
  /**
268
264
  * Rate limiting for anonymous proxy usage
269
265
  * Limits: 10 calls/week, 5 calls/hour (anonymous)
270
- * 50 calls/week, 10 calls/hour (authenticated)
266
+ * 50 calls/month, 10 calls/hour (authenticated)
271
267
  */
272
268
  interface RateLimitState {
273
269
  hourly: { count: number; resetAt: number };
@@ -326,7 +322,7 @@ function checkWorkspaceAccess(providerId?: string): { allowed: boolean; error?:
326
322
  error: JSON.stringify({
327
323
  success: false,
328
324
  error: `Register to continue. You've used ${UNREGISTERED_CALL_LIMIT} free calls.`,
329
- hint: "Run register_owner with your email to unlock 50 calls/week.",
325
+ hint: "Run register_owner with your email to unlock 50 calls/month.",
330
326
  action: "register_owner"
331
327
  }, null, 2)
332
328
  };
@@ -339,10 +335,10 @@ function checkWorkspaceAccess(providerId?: string): { allowed: boolean; error?:
339
335
  allowed: false,
340
336
  error: JSON.stringify({
341
337
  success: false,
342
- error: `Weekly limit reached (${FREE_WEEKLY_LIMIT} calls)`,
338
+ error: `Monthly limit reached (${FREE_MONTHLY_LIMIT} calls)`,
343
339
  hint: "Upgrade to Backer for unlimited calls",
344
340
  upgrade_url: "https://apiclaw.nordsym.com/upgrade",
345
- retry_after: getNextMondayUTC()
341
+ retry_after: getNextMonthUTC()
346
342
  }, null, 2)
347
343
  };
348
344
  }
@@ -887,7 +883,7 @@ Docs: https://apiclaw.nordsym.com
887
883
 
888
884
  // Log search to Convex analytics (authenticated + anonymous)
889
885
  const analyticsUserId = workspaceContext?.workspaceId || `anon:${getMachineFingerprint()}`;
890
- const convexUrl = process.env.APICLAW_CONVEX_URL || process.env.NEXT_PUBLIC_CONVEX_URL;
886
+ const convexUrl = CONVEX_URL;
891
887
  if (convexUrl) {
892
888
  fetch(`${convexUrl}/api/mutation`, {
893
889
  method: 'POST',
@@ -939,6 +935,7 @@ Docs: https://apiclaw.nordsym.com
939
935
  const queryLower = query.toLowerCase();
940
936
  for (const [provider, keywords] of Object.entries(PROVIDER_KEYWORDS)) {
941
937
  if (keywords.some(kw => queryLower.includes(kw))) {
938
+ // Log to apiLogs (for analytics timeline)
942
939
  fetch(`${convexUrl}/api/mutation`, {
943
940
  method: 'POST',
944
941
  headers: { 'Content-Type': 'application/json' },
@@ -949,7 +946,19 @@ Docs: https://apiclaw.nordsym.com
949
946
  action: `discovery:${query.substring(0, 50)}`,
950
947
  status: 'success' as const,
951
948
  latencyMs: responseTimeMs,
952
- callerWorkspaceId: workspaceContext.workspaceId,
949
+ callerWorkspaceId: workspaceContext?.workspaceId || 'anonymous',
950
+ },
951
+ }),
952
+ }).catch(() => {});
953
+ // Increment discoveryCount on provider APIs (for dashboard counters)
954
+ fetch(`${convexUrl}/api/mutation`, {
955
+ method: 'POST',
956
+ headers: { 'Content-Type': 'application/json' },
957
+ body: JSON.stringify({
958
+ path: 'providers:trackDiscoveryByProvider',
959
+ args: {
960
+ provider,
961
+ query: query.substring(0, 100),
953
962
  },
954
963
  }),
955
964
  }).catch(() => {});
@@ -1574,7 +1583,7 @@ Docs: https://apiclaw.nordsym.com
1574
1583
  if (result.success && workspaceContext && !workspaceContext.email) {
1575
1584
  const remaining = UNREGISTERED_CALL_LIMIT - (workspaceContext.usageCount || 0);
1576
1585
  if (remaining > 0 && remaining <= 3) {
1577
- responseData._notice = `${remaining} free calls remaining. Run register_owner to unlock 50/week.`;
1586
+ responseData._notice = `${remaining} free calls remaining. Run register_owner to unlock 50/month.`;
1578
1587
  }
1579
1588
  }
1580
1589
 
@@ -1,3 +0,0 @@
1
- export declare const activateWorkspace: any;
2
- export declare const createSessionForWorkspace: any;
3
- //# sourceMappingURL=adminActivate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adminActivate.d.ts","sourceRoot":"","sources":["adminActivate.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,KAmB5B,CAAC;AAWH,eAAO,MAAM,yBAAyB,KAoBpC,CAAC"}
@@ -1,47 +0,0 @@
1
- import { mutation } from "./_generated/server";
2
- import { v } from "convex/values";
3
- export const activateWorkspace = mutation({
4
- args: { workspaceId: v.id("workspaces") },
5
- handler: async (ctx, { workspaceId }) => {
6
- const workspace = await ctx.db.get(workspaceId);
7
- if (!workspace) {
8
- return { success: false, error: "not_found" };
9
- }
10
- await ctx.db.patch(workspaceId, {
11
- status: "active",
12
- tier: "backer", // Give Hivr bees backer status
13
- weeklyUsageLimit: 999999,
14
- usageLimit: 999999,
15
- backerUntil: new Date("2026-12-31T23:59:59Z").getTime(), // Founding Backer until end of 2026
16
- updatedAt: Date.now(),
17
- });
18
- return { success: true };
19
- },
20
- });
21
- function generateToken() {
22
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
23
- let result = '';
24
- for (let i = 0; i < 32; i++) {
25
- result += chars.charAt(Math.floor(Math.random() * chars.length));
26
- }
27
- return result;
28
- }
29
- export const createSessionForWorkspace = mutation({
30
- args: { workspaceId: v.id("workspaces") },
31
- handler: async (ctx, { workspaceId }) => {
32
- const workspace = await ctx.db.get(workspaceId);
33
- if (!workspace || workspace.status !== "active") {
34
- return { success: false, error: "workspace_not_active" };
35
- }
36
- const sessionToken = "apiclaw_" + generateToken();
37
- await ctx.db.insert("agentSessions", {
38
- workspaceId,
39
- sessionToken,
40
- fingerprint: "hivr-bees",
41
- lastUsedAt: Date.now(),
42
- createdAt: Date.now(),
43
- });
44
- return { success: true, sessionToken };
45
- },
46
- });
47
- //# sourceMappingURL=adminActivate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adminActivate.js","sourceRoot":"","sources":["adminActivate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE;IACzC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;QAChD,CAAC;QAED,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE;YAC9B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,QAAQ,EAAE,+BAA+B;YAC/C,gBAAgB,EAAE,MAAM;YACxB,UAAU,EAAE,MAAM;YAClB,WAAW,EAAE,IAAI,IAAI,CAAC,sBAAsB,CAAC,CAAC,OAAO,EAAE,EAAE,oCAAoC;YAC7F,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;QAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,aAAa;IACp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d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adminStats.d.ts","sourceRoot":"","sources":["adminStats.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,KAwB7B,CAAC;AAGH,eAAO,MAAM,cAAc,KAazB,CAAC"}
@@ -1,42 +0,0 @@
1
- import { query } from "./_generated/server";
2
- // Get total user/workspace count
3
- export const getTotalWorkspaces = query({
4
- args: {},
5
- handler: async (ctx) => {
6
- const workspaces = await ctx.db.query("workspaces").collect();
7
- const providers = await ctx.db.query("providers").collect();
8
- return {
9
- totalWorkspaces: workspaces.length,
10
- totalProviders: providers.length,
11
- activeWorkspaces: workspaces.filter(w => w.status === "active").length,
12
- backers: workspaces.filter(w => w.tier === "backer").length,
13
- workspaceBreakdown: {
14
- free: workspaces.filter(w => w.tier === "free").length,
15
- pro: workspaces.filter(w => w.tier === "pro").length,
16
- enterprise: workspaces.filter(w => w.tier === "enterprise").length,
17
- backer: workspaces.filter(w => w.tier === "backer").length,
18
- },
19
- providerBreakdown: {
20
- pending: providers.filter(p => p.status === "pending").length,
21
- approved: providers.filter(p => p.status === "approved").length,
22
- rejected: providers.filter(p => p.status === "rejected").length,
23
- }
24
- };
25
- },
26
- });
27
- // List all workspace emails (for inspection)
28
- export const listWorkspaces = query({
29
- args: {},
30
- handler: async (ctx) => {
31
- const workspaces = await ctx.db.query("workspaces").collect();
32
- return workspaces.map(w => ({
33
- email: w.email,
34
- status: w.status,
35
- tier: w.tier,
36
- usageCount: w.usageCount,
37
- createdAt: w.createdAt,
38
- lastActiveAt: w.lastActiveAt,
39
- }));
40
- },
41
- });
42
- //# sourceMappingURL=adminStats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adminStats.js","sourceRoot":"","sources":["adminStats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,iCAAiC;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;IACtC,IAA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,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,MAAM;gBAC/D,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,MAAM;aAChE;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;IAClC,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACrB,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC1B,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,YAAY,EAAE,CAAC,CAAC,YAAY;SAC7B,CAAC,CAAC,CAAC;IACN,CAAC;CACF,CAAC,CAAC"}
@@ -1,76 +0,0 @@
1
- /**
2
- * Get main agent info for a workspace
3
- */
4
- export declare const getMainAgent: any;
5
- /**
6
- * Rename the main agent
7
- */
8
- export declare const renameMainAgent: any;
9
- /**
10
- * Initialize main agent (auto-generate name and ID if not set)
11
- * Called on first API call
12
- */
13
- export declare const ensureMainAgent: any;
14
- /**
15
- * Get all subagents for a workspace
16
- */
17
- export declare const getSubagents: any;
18
- /**
19
- * Get stats for a specific subagent
20
- */
21
- export declare const getSubagentStats: any;
22
- /**
23
- * Rename a subagent
24
- */
25
- export declare const renameSubagent: any;
26
- /**
27
- * Track a subagent call (upsert subagent record)
28
- * Called when X-APIClaw-Subagent header is present
29
- */
30
- export declare const trackSubagentCall: any;
31
- /**
32
- * Pre-register a task agent (subagent)
33
- * Allows agents to be registered before they make their first call
34
- */
35
- export declare const registerTaskAgent: any;
36
- /**
37
- * Update AI backend for workspace or subagent
38
- * Called when X-APIClaw-AI-Backend header is present
39
- */
40
- export declare const updateAIBackend: any;
41
- /**
42
- * Get agent overview for workspace (main + subagents summary)
43
- */
44
- export declare const getAgentOverview: any;
45
- /**
46
- * Delete a subagent
47
- */
48
- export declare const deleteSubagent: any;
49
- /**
50
- * Update subagent stats (call count, last active)
51
- * Internal helper for tracking
52
- */
53
- export declare const updateSubagentStats: any;
54
- /**
55
- * Ensure agent exists for this (fingerprint, mcpClient) pair.
56
- * Auto-provisions a free-tier workspace if none exists.
57
- * Called on every MCP server startup.
58
- */
59
- export declare const ensureAgent: any;
60
- /**
61
- * Link email to an existing workspace (called by register_owner + verifyMagicLink)
62
- */
63
- export declare const linkEmailToWorkspace: any;
64
- /**
65
- * Increment call count for an agent
66
- */
67
- export declare const incrementAgentCalls: any;
68
- /**
69
- * Get all agents for a workspace (for dashboard "My Agents")
70
- */
71
- export declare const getWorkspaceAgents: any;
72
- /**
73
- * Get total agent count (for landing page / admin)
74
- */
75
- export declare const getTotalAgentCount: any;
76
- //# sourceMappingURL=agents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["agents.ts"],"names":[],"mappings":"AA2CA;;GAEG;AACH,eAAO,MAAM,YAAY,KA2BvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,KAiC1B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,KAgC1B,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,YAAY,KAoCvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB,KA4D3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,KAoCzB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB,KAoC5B,CAAC;AAUH;;;GAGG;AACH,eAAO,MAAM,iBAAiB,KA0D5B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,KAmC1B,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,gBAAgB,KAoD3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,KA6BzB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,KAkC9B,CAAC;AAyBH;;;;GAIG;AACH,eAAO,MAAM,WAAW,KA+FtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB,KA0B/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,KAW9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,KA4B7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,KAa7B,CAAC"}