@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,25 +0,0 @@
1
- export declare const CREDIT_PACKAGES: {
2
- readonly starter: {
3
- readonly amountUsd: 10;
4
- readonly credits: 100;
5
- readonly bonus: 0;
6
- };
7
- readonly growth: {
8
- readonly amountUsd: 50;
9
- readonly credits: 550;
10
- readonly bonus: 50;
11
- };
12
- readonly scale: {
13
- readonly amountUsd: 100;
14
- readonly credits: 1200;
15
- readonly bonus: 200;
16
- };
17
- };
18
- export declare const getOrCreateAgent: any;
19
- export declare const getAgentCredits: any;
20
- export declare const addCredits: any;
21
- export declare const deductCredits: any;
22
- export declare const recordTopup: any;
23
- export declare const completeTopup: any;
24
- export declare const getTopups: any;
25
- //# sourceMappingURL=credits.d.ts.map
package/convex/credits.js DELETED
@@ -1,186 +0,0 @@
1
- import { v } from "convex/values";
2
- import { mutation, query } from "./_generated/server";
3
- // Credit packages
4
- export const CREDIT_PACKAGES = {
5
- starter: { amountUsd: 10, credits: 100, bonus: 0 },
6
- growth: { amountUsd: 50, credits: 550, bonus: 50 }, // 10% bonus
7
- scale: { amountUsd: 100, credits: 1200, bonus: 200 }, // 20% bonus
8
- };
9
- // Get or create agent credits account
10
- export const getOrCreateAgent = mutation({
11
- args: { agentId: v.string() },
12
- handler: async (ctx, args) => {
13
- const existing = await ctx.db
14
- .query("agentCredits")
15
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
16
- .first();
17
- if (existing)
18
- return existing;
19
- const now = Date.now();
20
- const id = await ctx.db.insert("agentCredits", {
21
- agentId: args.agentId,
22
- balanceUsd: 0,
23
- currency: "USD",
24
- createdAt: now,
25
- updatedAt: now,
26
- });
27
- return await ctx.db.get(id);
28
- },
29
- });
30
- // Get agent credits
31
- export const getAgentCredits = query({
32
- args: { agentId: v.string() },
33
- handler: async (ctx, args) => {
34
- return await ctx.db
35
- .query("agentCredits")
36
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
37
- .first();
38
- },
39
- });
40
- // Add credits to agent account (called by webhook or admin)
41
- export const addCredits = mutation({
42
- args: {
43
- agentId: v.string(),
44
- amountUsd: v.number(),
45
- source: v.optional(v.string()),
46
- },
47
- handler: async (ctx, args) => {
48
- const credits = await ctx.db
49
- .query("agentCredits")
50
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
51
- .first();
52
- const now = Date.now();
53
- if (credits) {
54
- await ctx.db.patch(credits._id, {
55
- balanceUsd: credits.balanceUsd + args.amountUsd,
56
- updatedAt: now,
57
- });
58
- return await ctx.db.get(credits._id);
59
- }
60
- else {
61
- const id = await ctx.db.insert("agentCredits", {
62
- agentId: args.agentId,
63
- balanceUsd: args.amountUsd,
64
- currency: "USD",
65
- createdAt: now,
66
- updatedAt: now,
67
- });
68
- return await ctx.db.get(id);
69
- }
70
- },
71
- });
72
- // Deduct credits (internal use)
73
- export const deductCredits = mutation({
74
- args: {
75
- agentId: v.string(),
76
- amountUsd: v.number(),
77
- },
78
- handler: async (ctx, args) => {
79
- const credits = await ctx.db
80
- .query("agentCredits")
81
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
82
- .first();
83
- if (!credits) {
84
- throw new Error(`No credits account for agent: ${args.agentId}`);
85
- }
86
- if (credits.balanceUsd < args.amountUsd) {
87
- throw new Error(`Insufficient balance: have $${credits.balanceUsd.toFixed(2)}, need $${args.amountUsd.toFixed(2)}`);
88
- }
89
- await ctx.db.patch(credits._id, {
90
- balanceUsd: credits.balanceUsd - args.amountUsd,
91
- updatedAt: Date.now(),
92
- });
93
- return await ctx.db.get(credits._id);
94
- },
95
- });
96
- // Record credit top-up from Stripe
97
- export const recordTopup = mutation({
98
- args: {
99
- agentId: v.string(),
100
- stripeSessionId: v.optional(v.string()),
101
- stripePaymentIntentId: v.optional(v.string()),
102
- amountUsd: v.number(),
103
- creditsGranted: v.number(),
104
- packageType: v.string(),
105
- status: v.string(),
106
- },
107
- handler: async (ctx, args) => {
108
- const now = Date.now();
109
- return await ctx.db.insert("creditTopups", {
110
- agentId: args.agentId,
111
- stripeSessionId: args.stripeSessionId,
112
- stripePaymentIntentId: args.stripePaymentIntentId,
113
- amountUsd: args.amountUsd,
114
- creditsGranted: args.creditsGranted,
115
- packageType: args.packageType,
116
- status: args.status,
117
- createdAt: now,
118
- completedAt: args.status === "completed" ? now : undefined,
119
- });
120
- },
121
- });
122
- // Complete a pending top-up
123
- export const completeTopup = mutation({
124
- args: {
125
- stripeSessionId: v.optional(v.string()),
126
- stripePaymentIntentId: v.optional(v.string()),
127
- },
128
- handler: async (ctx, args) => {
129
- let topup;
130
- if (args.stripeSessionId) {
131
- topup = await ctx.db
132
- .query("creditTopups")
133
- .withIndex("by_stripeSessionId", (q) => q.eq("stripeSessionId", args.stripeSessionId))
134
- .first();
135
- }
136
- else if (args.stripePaymentIntentId) {
137
- topup = await ctx.db
138
- .query("creditTopups")
139
- .withIndex("by_stripePaymentIntentId", (q) => q.eq("stripePaymentIntentId", args.stripePaymentIntentId))
140
- .first();
141
- }
142
- if (!topup) {
143
- throw new Error("Top-up not found");
144
- }
145
- if (topup.status === "completed") {
146
- return topup; // Already completed, idempotent
147
- }
148
- // Update top-up status
149
- await ctx.db.patch(topup._id, {
150
- status: "completed",
151
- completedAt: Date.now(),
152
- });
153
- // Add credits to agent
154
- const credits = await ctx.db
155
- .query("agentCredits")
156
- .withIndex("by_agentId", (q) => q.eq("agentId", topup.agentId))
157
- .first();
158
- if (credits) {
159
- await ctx.db.patch(credits._id, {
160
- balanceUsd: credits.balanceUsd + topup.creditsGranted,
161
- updatedAt: Date.now(),
162
- });
163
- }
164
- else {
165
- await ctx.db.insert("agentCredits", {
166
- agentId: topup.agentId,
167
- balanceUsd: topup.creditsGranted,
168
- currency: "USD",
169
- createdAt: Date.now(),
170
- updatedAt: Date.now(),
171
- });
172
- }
173
- return topup;
174
- },
175
- });
176
- // Get all top-ups for an agent
177
- export const getTopups = query({
178
- args: { agentId: v.string() },
179
- handler: async (ctx, args) => {
180
- return await ctx.db
181
- .query("creditTopups")
182
- .withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
183
- .collect();
184
- },
185
- });
186
- //# sourceMappingURL=credits.js.map
package/convex/crons.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare const crons: import("convex/server").Crons;
2
- export default crons;
3
- //# sourceMappingURL=crons.d.ts.map
package/convex/crons.js DELETED
@@ -1,17 +0,0 @@
1
- import { cronJobs } from "convex/server";
2
- import { internal } from "./_generated/api";
3
- const crons = cronJobs();
4
- /**
5
- * Daily Usage Reporting to Stripe
6
- * Runs at 00:05 UTC every day
7
- * Reports metered usage for all active subscriptions
8
- */
9
- crons.daily("report-usage-to-stripe", { hourUTC: 0, minuteUTC: 5 }, internal.billing.reportAllUsageToStripe);
10
- /**
11
- * Monthly Spend Reset
12
- * Runs at 00:01 UTC on the 1st of each month
13
- * Resets monthlySpendCents and budgetAlertSentAt for all workspaces
14
- */
15
- crons.monthly("reset-monthly-spend", { day: 1, hourUTC: 0, minuteUTC: 1 }, internal.spendAlerts.resetMonthlySpend);
16
- export default crons;
17
- //# sourceMappingURL=crons.js.map
@@ -1,2 +0,0 @@
1
- export declare const run: any;
2
- //# sourceMappingURL=debugFilestackLogs.d.ts.map
@@ -1,17 +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) => q.eq("workspaceId", "n175gprvbbvygmhtg8cfk8jzbd83m0p8"))
8
- .collect();
9
- const byAction = {};
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) => ({ action: l.action, createdAt: l.createdAt })) };
15
- },
16
- });
17
- //# sourceMappingURL=debugFilestackLogs.js.map
@@ -1,2 +0,0 @@
1
- export declare const getForWorkspace: any;
2
- //# sourceMappingURL=debugGetToken.d.ts.map
@@ -1,18 +0,0 @@
1
- import { query } from "./_generated/server";
2
- import { v } from "convex/values";
3
- export const getForWorkspace = query({
4
- args: { workspaceId: v.id("workspaces") },
5
- handler: async (ctx, { workspaceId }) => {
6
- const sessions = await ctx.db
7
- .query("agentSessions")
8
- .withIndex("by_workspaceId", (q) => q.eq("workspaceId", workspaceId))
9
- .collect();
10
- return sessions.map(s => ({
11
- id: s._id,
12
- sessionToken: s.sessionToken,
13
- fingerprint: s.fingerprint,
14
- createdAt: s.createdAt,
15
- }));
16
- },
17
- });
18
- //# sourceMappingURL=debugGetToken.js.map
@@ -1,72 +0,0 @@
1
- /**
2
- * Save/update provider's Direct Call configuration
3
- */
4
- export declare const saveDirectCallConfig: any;
5
- /**
6
- * Save Direct Call config with token auth (used by frontend)
7
- */
8
- export declare const saveConfig: any;
9
- /**
10
- * Create/update an action for a Direct Call config
11
- */
12
- export declare const saveAction: any;
13
- /**
14
- * Delete an action
15
- */
16
- export declare const deleteAction: any;
17
- /**
18
- * Publish Direct Call - set status to live
19
- * Also marks apiListed earn progress for the provider's workspace
20
- */
21
- export declare const publishDirectCall: any;
22
- /**
23
- * Set Direct Call status (draft, testing, live)
24
- */
25
- export declare const setStatus: any;
26
- /**
27
- * Get Direct Call config by providerId
28
- */
29
- export declare const getDirectCallConfig: any;
30
- /**
31
- * Get Direct Call config by ID
32
- */
33
- export declare const getDirectCallConfigById: any;
34
- /**
35
- * Get Direct Call config by API ID
36
- */
37
- export declare const getDirectCallConfigByApiId: any;
38
- /**
39
- * Get all actions for a Direct Call config
40
- */
41
- export declare const getActions: any;
42
- /**
43
- * Get single action by directCallId + name
44
- */
45
- export declare const getActionByName: any;
46
- /**
47
- * Get action by ID
48
- */
49
- export declare const getActionById: any;
50
- /**
51
- * DEBUG: Get all Direct Call configs
52
- */
53
- export declare const getAllConfigs: any;
54
- /**
55
- * Get all live Direct Call configs (for public API discovery)
56
- */
57
- export declare const getLiveConfigs: any;
58
- /**
59
- * Get Direct Call config by API ID (for test console)
60
- */
61
- export declare const getConfig: any;
62
- /**
63
- * Get Direct Call config by API slug (for MCP/agent execution)
64
- * Looks up API by name, then gets the Direct Call config
65
- */
66
- export declare const getByApiSlug: any;
67
- /**
68
- * Test an action by calling the actual provider API
69
- * For V1: Provider passes their own test key
70
- */
71
- export declare const testAction: any;
72
- //# sourceMappingURL=directCall.d.ts.map