@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,5 +0,0 @@
1
- export declare const log: any;
2
- export declare const getStats: any;
3
- export declare const getRecent: any;
4
- export declare const getProviderBreakdown: any;
5
- //# sourceMappingURL=analytics.d.ts.map
@@ -1,167 +0,0 @@
1
- import { mutation, query } from "./_generated/server";
2
- import { v } from "convex/values";
3
- // Log an analytics event
4
- export const log = mutation({
5
- args: {
6
- event: v.string(),
7
- provider: v.optional(v.string()),
8
- query: v.optional(v.string()),
9
- identifier: v.string(),
10
- workspaceId: v.optional(v.id("workspaces")),
11
- metadata: v.optional(v.any()),
12
- },
13
- handler: async (ctx, args) => {
14
- return await ctx.db.insert("analytics", {
15
- ...args,
16
- timestamp: Date.now(),
17
- });
18
- },
19
- });
20
- // Get stats for dashboard
21
- export const getStats = query({
22
- args: {
23
- hoursBack: v.optional(v.number()),
24
- },
25
- handler: async (ctx, args) => {
26
- const hoursBack = args.hoursBack || 24;
27
- const since = Date.now() - hoursBack * 3600000;
28
- const events = await ctx.db
29
- .query("analytics")
30
- .withIndex("by_timestamp")
31
- .filter((q) => q.gte(q.field("timestamp"), since))
32
- .collect();
33
- // Aggregate stats
34
- const stats = {
35
- totalEvents: events.length,
36
- discoveries: events.filter((e) => e.event === "discovery").length,
37
- instantCalls: events.filter((e) => e.event === "instant").length,
38
- uniqueUsers: new Set(events.map((e) => e.identifier)).size,
39
- byProvider: {},
40
- topQueries: [],
41
- hourly: [],
42
- };
43
- // By provider
44
- for (const event of events.filter((e) => e.provider)) {
45
- stats.byProvider[event.provider] = (stats.byProvider[event.provider] || 0) + 1;
46
- }
47
- // Top queries
48
- const queryCounts = {};
49
- for (const event of events.filter((e) => e.query)) {
50
- queryCounts[event.query] = (queryCounts[event.query] || 0) + 1;
51
- }
52
- stats.topQueries = Object.entries(queryCounts)
53
- .sort(([, a], [, b]) => b - a)
54
- .slice(0, 10)
55
- .map(([query, count]) => ({ query, count }));
56
- // Hourly breakdown
57
- const hourlyCounts = {};
58
- for (const event of events) {
59
- const hour = new Date(event.timestamp).toISOString().slice(0, 13);
60
- hourlyCounts[hour] = (hourlyCounts[hour] || 0) + 1;
61
- }
62
- stats.hourly = Object.entries(hourlyCounts)
63
- .sort(([a], [b]) => a.localeCompare(b))
64
- .map(([hour, count]) => ({ hour, count }));
65
- return stats;
66
- },
67
- });
68
- // Get recent events for live feed
69
- export const getRecent = query({
70
- args: {
71
- limit: v.optional(v.number()),
72
- },
73
- handler: async (ctx, args) => {
74
- const limit = args.limit || 50;
75
- return await ctx.db
76
- .query("analytics")
77
- .withIndex("by_timestamp")
78
- .order("desc")
79
- .take(limit);
80
- },
81
- });
82
- // Get provider breakdown for Agent Analytics (workspace-specific)
83
- export const getProviderBreakdown = query({
84
- args: {
85
- token: v.string(),
86
- periodDays: v.optional(v.number()),
87
- },
88
- handler: async (ctx, args) => {
89
- const periodDays = args.periodDays || 7;
90
- const since = Date.now() - periodDays * 24 * 3600000;
91
- // Verify session and get workspace
92
- const session = await ctx.db
93
- .query("agentSessions")
94
- .withIndex("by_sessionToken", (q) => q.eq("sessionToken", args.token))
95
- .first();
96
- if (!session) {
97
- return null;
98
- }
99
- // Get all API logs for this workspace
100
- const logs = await ctx.db
101
- .query("apiLogs")
102
- .withIndex("by_workspaceId_createdAt", (q) => q.eq("workspaceId", session.workspaceId))
103
- .filter((q) => q.gte(q.field("createdAt"), since))
104
- .collect();
105
- if (logs.length === 0) {
106
- return null; // Return null so frontend knows to show empty state, not preview
107
- }
108
- // Aggregate stats
109
- const totalCalls = logs.length;
110
- const successCount = logs.filter((l) => l.status === "success").length;
111
- const failureCount = logs.filter((l) => l.status === "error").length;
112
- const totalLatency = logs.reduce((sum, l) => sum + (l.latencyMs || 0), 0);
113
- const avgLatency = totalCalls > 0 ? Math.round(totalLatency / totalCalls) : 0;
114
- // Provider breakdown
115
- const byProvider = {};
116
- for (const log of logs) {
117
- if (!byProvider[log.provider]) {
118
- byProvider[log.provider] = { count: 0, latency: 0 };
119
- }
120
- byProvider[log.provider].count++;
121
- byProvider[log.provider].latency += log.latencyMs || 0;
122
- }
123
- // Agent breakdown (by subagentId)
124
- const byAgent = {};
125
- for (const log of logs) {
126
- const agent = log.subagentId || "main";
127
- byAgent[agent] = (byAgent[agent] || 0) + 1;
128
- }
129
- // Action breakdown
130
- const byAction = {};
131
- for (const log of logs) {
132
- const key = `${log.provider}:${log.action}`;
133
- byAction[key] = (byAction[key] || 0) + 1;
134
- }
135
- // Time series (daily)
136
- const dailyCounts = {};
137
- for (const log of logs) {
138
- const day = new Date(log.createdAt).toISOString().slice(0, 10);
139
- dailyCounts[day] = (dailyCounts[day] || 0) + 1;
140
- }
141
- return {
142
- totalCalls,
143
- successCount,
144
- failureCount,
145
- successRate: totalCalls > 0 ? (successCount / totalCalls) * 100 : 0,
146
- avgLatency,
147
- byProvider: Object.entries(byProvider).map(([name, data]) => ({
148
- name,
149
- count: data.count,
150
- avgLatency: data.count > 0 ? Math.round(data.latency / data.count) : 0,
151
- })).sort((a, b) => b.count - a.count),
152
- byAgent: Object.entries(byAgent).map(([name, count]) => ({
153
- name,
154
- count,
155
- })).sort((a, b) => b.count - a.count),
156
- byAction: Object.entries(byAction).map(([name, count]) => ({
157
- name,
158
- count,
159
- })).sort((a, b) => b.count - a.count).slice(0, 10),
160
- timeSeries: Object.entries(dailyCounts)
161
- .sort(([a], [b]) => a.localeCompare(b))
162
- .map(([date, count]) => ({ date, count })),
163
- isPreview: false,
164
- };
165
- },
166
- });
167
- //# sourceMappingURL=analytics.js.map
@@ -1,2 +0,0 @@
1
- export declare const run: any;
2
- //# sourceMappingURL=backfillAnalytics.d.ts.map
@@ -1,20 +0,0 @@
1
- import { mutation } from "./_generated/server";
2
- export const run = mutation({
3
- args: {},
4
- handler: async (ctx) => {
5
- const APILAYER_WORKSPACE_ID = "n17bf4raa01r0d4na0bsgg117x83y551";
6
- const events = await ctx.db
7
- .query("analytics")
8
- .withIndex("by_provider", (q) => q.eq("provider", "apilayer"))
9
- .collect();
10
- let patched = 0;
11
- for (const e of events) {
12
- if (!e.workspaceId) {
13
- await ctx.db.patch(e._id, { workspaceId: APILAYER_WORKSPACE_ID });
14
- patched++;
15
- }
16
- }
17
- return { patched };
18
- },
19
- });
20
- //# sourceMappingURL=backfillAnalytics.js.map
@@ -1,2 +0,0 @@
1
- export declare const run: any;
2
- //# sourceMappingURL=backfillSearchLogs.d.ts.map
@@ -1,29 +0,0 @@
1
- import { mutation } from "./_generated/server";
2
- // Backfill searchLogs from apiLogs that have action starting with "discovery:"
3
- export const run = mutation({
4
- args: {},
5
- handler: async (ctx) => {
6
- const APILAYER_WORKSPACE_ID = "n17bf4raa01r0d4na0bsgg117x83y551";
7
- const apiLogs = await ctx.db
8
- .query("apiLogs")
9
- .withIndex("by_workspaceId_createdAt", (q) => q.eq("workspaceId", APILAYER_WORKSPACE_ID))
10
- .collect();
11
- const discoveryLogs = apiLogs.filter((l) => typeof l.action === "string" && l.action.startsWith("discovery:"));
12
- let inserted = 0;
13
- for (const log of discoveryLogs) {
14
- const query = log.action.replace("discovery:", "").trim();
15
- await ctx.db.insert("searchLogs", {
16
- workspaceId: APILAYER_WORKSPACE_ID,
17
- query,
18
- resultCount: 1,
19
- hasResults: true,
20
- matchedProviders: ["apilayer"],
21
- responseTimeMs: log.latencyMs || 20,
22
- timestamp: log.createdAt,
23
- });
24
- inserted++;
25
- }
26
- return { inserted, total: discoveryLogs.length };
27
- },
28
- });
29
- //# sourceMappingURL=backfillSearchLogs.js.map
@@ -1,88 +0,0 @@
1
- /**
2
- * Link a Stripe customer to a workspace
3
- */
4
- export declare const linkCustomer: any;
5
- /**
6
- * Update subscription status for a workspace
7
- */
8
- export declare const updateSubscription: any;
9
- /**
10
- * Record daily usage for billing
11
- */
12
- export declare const recordUsage: any;
13
- /**
14
- * Process a successful payment (from webhook)
15
- */
16
- export declare const processPayment: any;
17
- /**
18
- * Increment credit balance (for prepaid credits)
19
- */
20
- export declare const incrementCredits: any;
21
- /**
22
- * Decrement credit balance (when using prepaid credits)
23
- */
24
- export declare const decrementCredits: any;
25
- /**
26
- * Mark usage as reported to Stripe
27
- */
28
- export declare const markUsageReported: any;
29
- /**
30
- * Update invoice status (from webhook)
31
- */
32
- export declare const updateInvoiceStatus: any;
33
- /**
34
- * Reset usage count on subscription cancellation
35
- * Gives user a clean slate when downgrading to free
36
- */
37
- export declare const resetUsageOnCancellation: any;
38
- /**
39
- * Update payment method info (from webhook)
40
- */
41
- export declare const updatePaymentMethodInfo: any;
42
- /**
43
- * Get billing info for a workspace
44
- */
45
- export declare const getInfo: any;
46
- /**
47
- * Get current period usage
48
- */
49
- export declare const getCurrentUsage: any;
50
- /**
51
- * Get invoices for a workspace
52
- */
53
- export declare const getInvoices: any;
54
- /**
55
- * Get unreported usage records (for cron job)
56
- */
57
- export declare const getUnreportedUsage: any;
58
- /**
59
- * Get workspace by Stripe customer ID
60
- */
61
- export declare const getByStripeCustomerId: any;
62
- /**
63
- * Get workspace by ID
64
- */
65
- export declare const getWorkspace: any;
66
- /**
67
- * Get all workspaces with active Stripe subscriptions (internal)
68
- */
69
- export declare const getActiveSubscriptions: any;
70
- /**
71
- * Get unreported usage records for a specific workspace (internal)
72
- */
73
- export declare const getUnreportedUsageForWorkspace: any;
74
- /**
75
- * Mark multiple usage records as reported (internal)
76
- */
77
- export declare const markUsageRecordsReported: any;
78
- /**
79
- * Report usage to Stripe for a single workspace
80
- * Internal action - called by the daily cron
81
- */
82
- export declare const reportUsageToStripe: any;
83
- /**
84
- * Daily cron job: Report all unreported usage to Stripe
85
- * Runs at 00:05 UTC
86
- */
87
- export declare const reportAllUsageToStripe: any;
88
- //# sourceMappingURL=billing.d.ts.map