@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
package/convex/credits.ts DELETED
@@ -1,211 +0,0 @@
1
- import { v } from "convex/values";
2
- import { mutation, query } from "./_generated/server";
3
-
4
- // Credit packages
5
- export const CREDIT_PACKAGES = {
6
- starter: { amountUsd: 10, credits: 100, bonus: 0 },
7
- growth: { amountUsd: 50, credits: 550, bonus: 50 }, // 10% bonus
8
- scale: { amountUsd: 100, credits: 1200, bonus: 200 }, // 20% bonus
9
- } as const;
10
-
11
- // Get or create agent credits account
12
- export const getOrCreateAgent = mutation({
13
- args: { agentId: v.string() },
14
- handler: async (ctx, args) => {
15
- const existing = await ctx.db
16
- .query("agentCredits")
17
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
18
- .first();
19
-
20
- if (existing) return existing;
21
-
22
- const now = Date.now();
23
- const id = await ctx.db.insert("agentCredits", {
24
- agentId: args.agentId,
25
- balanceUsd: 0,
26
- currency: "USD",
27
- createdAt: now,
28
- updatedAt: now,
29
- });
30
-
31
- return await ctx.db.get(id);
32
- },
33
- });
34
-
35
- // Get agent credits
36
- export const getAgentCredits = query({
37
- args: { agentId: v.string() },
38
- handler: async (ctx, args) => {
39
- return await ctx.db
40
- .query("agentCredits")
41
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
42
- .first();
43
- },
44
- });
45
-
46
- // Add credits to agent account (called by webhook or admin)
47
- export const addCredits = mutation({
48
- args: {
49
- agentId: v.string(),
50
- amountUsd: v.number(),
51
- source: v.optional(v.string()),
52
- },
53
- handler: async (ctx, args) => {
54
- const credits = await ctx.db
55
- .query("agentCredits")
56
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
57
- .first();
58
-
59
- const now = Date.now();
60
-
61
- if (credits) {
62
- await ctx.db.patch(credits._id, {
63
- balanceUsd: credits.balanceUsd + args.amountUsd,
64
- updatedAt: now,
65
- });
66
- return await ctx.db.get(credits._id);
67
- } else {
68
- const id = await ctx.db.insert("agentCredits", {
69
- agentId: args.agentId,
70
- balanceUsd: args.amountUsd,
71
- currency: "USD",
72
- createdAt: now,
73
- updatedAt: now,
74
- });
75
- return await ctx.db.get(id);
76
- }
77
- },
78
- });
79
-
80
- // Deduct credits (internal use)
81
- export const deductCredits = mutation({
82
- args: {
83
- agentId: v.string(),
84
- amountUsd: v.number(),
85
- },
86
- handler: async (ctx, args) => {
87
- const credits = await ctx.db
88
- .query("agentCredits")
89
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
90
- .first();
91
-
92
- if (!credits) {
93
- throw new Error(`No credits account for agent: ${args.agentId}`);
94
- }
95
-
96
- if (credits.balanceUsd < args.amountUsd) {
97
- throw new Error(
98
- `Insufficient balance: have $${credits.balanceUsd.toFixed(2)}, need $${args.amountUsd.toFixed(2)}`
99
- );
100
- }
101
-
102
- await ctx.db.patch(credits._id, {
103
- balanceUsd: credits.balanceUsd - args.amountUsd,
104
- updatedAt: Date.now(),
105
- });
106
-
107
- return await ctx.db.get(credits._id);
108
- },
109
- });
110
-
111
- // Record credit top-up from Stripe
112
- export const recordTopup = mutation({
113
- args: {
114
- agentId: v.string(),
115
- stripeSessionId: v.optional(v.string()),
116
- stripePaymentIntentId: v.optional(v.string()),
117
- amountUsd: v.number(),
118
- creditsGranted: v.number(),
119
- packageType: v.string(),
120
- status: v.string(),
121
- },
122
- handler: async (ctx, args) => {
123
- const now = Date.now();
124
- return await ctx.db.insert("creditTopups", {
125
- agentId: args.agentId,
126
- stripeSessionId: args.stripeSessionId,
127
- stripePaymentIntentId: args.stripePaymentIntentId,
128
- amountUsd: args.amountUsd,
129
- creditsGranted: args.creditsGranted,
130
- packageType: args.packageType,
131
- status: args.status,
132
- createdAt: now,
133
- completedAt: args.status === "completed" ? now : undefined,
134
- });
135
- },
136
- });
137
-
138
- // Complete a pending top-up
139
- export const completeTopup = mutation({
140
- args: {
141
- stripeSessionId: v.optional(v.string()),
142
- stripePaymentIntentId: v.optional(v.string()),
143
- },
144
- handler: async (ctx, args) => {
145
- let topup;
146
-
147
- if (args.stripeSessionId) {
148
- topup = await ctx.db
149
- .query("creditTopups")
150
- .withIndex("by_stripeSessionId", (q) =>
151
- q.eq("stripeSessionId", args.stripeSessionId)
152
- )
153
- .first();
154
- } else if (args.stripePaymentIntentId) {
155
- topup = await ctx.db
156
- .query("creditTopups")
157
- .withIndex("by_stripePaymentIntentId", (q) =>
158
- q.eq("stripePaymentIntentId", args.stripePaymentIntentId)
159
- )
160
- .first();
161
- }
162
-
163
- if (!topup) {
164
- throw new Error("Top-up not found");
165
- }
166
-
167
- if (topup.status === "completed") {
168
- return topup; // Already completed, idempotent
169
- }
170
-
171
- // Update top-up status
172
- await ctx.db.patch(topup._id, {
173
- status: "completed",
174
- completedAt: Date.now(),
175
- });
176
-
177
- // Add credits to agent
178
- const credits = await ctx.db
179
- .query("agentCredits")
180
- .withIndex("by_agentId", (q) => q.eq("agentId", topup.agentId))
181
- .first();
182
-
183
- if (credits) {
184
- await ctx.db.patch(credits._id, {
185
- balanceUsd: credits.balanceUsd + topup.creditsGranted,
186
- updatedAt: Date.now(),
187
- });
188
- } else {
189
- await ctx.db.insert("agentCredits", {
190
- agentId: topup.agentId,
191
- balanceUsd: topup.creditsGranted,
192
- currency: "USD",
193
- createdAt: Date.now(),
194
- updatedAt: Date.now(),
195
- });
196
- }
197
-
198
- return topup;
199
- },
200
- });
201
-
202
- // Get all top-ups for an agent
203
- export const getTopups = query({
204
- args: { agentId: v.string() },
205
- handler: async (ctx, args) => {
206
- return await ctx.db
207
- .query("creditTopups")
208
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
209
- .collect();
210
- },
211
- });
package/convex/crons.ts DELETED
@@ -1,50 +0,0 @@
1
- import { cronJobs } from "convex/server";
2
- import { internal } from "./_generated/api";
3
-
4
- const crons = cronJobs();
5
-
6
- /**
7
- * Daily Usage Reporting to Stripe
8
- * Runs at 00:05 UTC every day
9
- * Reports metered usage for all active subscriptions
10
- */
11
- crons.daily(
12
- "report-usage-to-stripe",
13
- { hourUTC: 0, minuteUTC: 5 },
14
- internal.billing.reportAllUsageToStripe
15
- );
16
-
17
- /**
18
- * Monthly Spend Reset
19
- * Runs at 00:01 UTC on the 1st of each month
20
- * Resets monthlySpendCents and budgetAlertSentAt for all workspaces
21
- */
22
- crons.monthly(
23
- "reset-monthly-spend",
24
- { day: 1, hourUTC: 0, minuteUTC: 1 },
25
- internal.spendAlerts.resetMonthlySpend
26
- );
27
-
28
- /**
29
- * Weekly Usage Report
30
- * Runs every Monday at 08:00 UTC (10:00 CEST)
31
- * Sends usage summary email to all workspaces with activity
32
- */
33
- crons.weekly(
34
- "weekly-usage-report",
35
- { dayOfWeek: "monday", hourUTC: 8, minuteUTC: 0 },
36
- internal.usageReports.sendWeeklyReports
37
- );
38
-
39
- /**
40
- * Monthly Usage Report
41
- * Runs on the 1st of each month at 09:00 UTC
42
- * Sends full monthly summary to all workspaces
43
- */
44
- crons.monthly(
45
- "monthly-usage-report",
46
- { day: 1, hourUTC: 9, minuteUTC: 0 },
47
- internal.usageReports.sendMonthlyReports
48
- );
49
-
50
- export default crons;
@@ -1,16 +0,0 @@
1
- import { query } from "./_generated/server";
2
- export const run = query({
3
- args: {},
4
- handler: async (ctx) => {
5
- const logs = await ctx.db
6
- .query("apiLogs")
7
- .withIndex("by_workspaceId_createdAt", (q: any) => q.eq("workspaceId", "n175gprvbbvygmhtg8cfk8jzbd83m0p8"))
8
- .collect();
9
- const byAction: Record<string, number> = {};
10
- for (const l of logs) {
11
- const k = (l.action || "?").startsWith("discovery:") ? "discovery" : (l.action || "?");
12
- byAction[k] = (byAction[k] || 0) + 1;
13
- }
14
- return { total: logs.length, byAction, sample: logs.slice(0,3).map((l: any) => ({ action: l.action, createdAt: l.createdAt })) };
15
- },
16
- });
@@ -1,18 +0,0 @@
1
- import { query } from "./_generated/server";
2
- import { v } from "convex/values";
3
-
4
- export const getForWorkspace = query({
5
- args: { workspaceId: v.id("workspaces") },
6
- handler: async (ctx, { workspaceId }) => {
7
- const sessions = await ctx.db
8
- .query("agentSessions")
9
- .withIndex("by_workspaceId", (q) => q.eq("workspaceId", workspaceId))
10
- .collect();
11
- return sessions.map(s => ({
12
- id: s._id,
13
- sessionToken: s.sessionToken,
14
- fingerprint: s.fingerprint,
15
- createdAt: s.createdAt,
16
- }));
17
- },
18
- });