@nordsym/apiclaw 1.5.7 → 1.5.9

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 (142) hide show
  1. package/HTTP-API.md +306 -0
  2. package/convex/_generated/api.d.ts +2 -0
  3. package/convex/adminActivate.d.ts +3 -0
  4. package/convex/adminActivate.d.ts.map +1 -0
  5. package/convex/adminActivate.js +47 -0
  6. package/convex/adminActivate.js.map +1 -0
  7. package/convex/adminStats.d.ts +3 -0
  8. package/convex/adminStats.d.ts.map +1 -0
  9. package/convex/adminStats.js +42 -0
  10. package/convex/adminStats.js.map +1 -0
  11. package/convex/adminStats.ts +44 -0
  12. package/convex/agents.d.ts +54 -0
  13. package/convex/agents.d.ts.map +1 -0
  14. package/convex/agents.js +499 -0
  15. package/convex/agents.js.map +1 -0
  16. package/convex/analytics.d.ts +5 -0
  17. package/convex/analytics.d.ts.map +1 -0
  18. package/convex/analytics.js +166 -0
  19. package/convex/analytics.js.map +1 -0
  20. package/convex/billing.d.ts +88 -0
  21. package/convex/billing.d.ts.map +1 -0
  22. package/convex/billing.js +655 -0
  23. package/convex/billing.js.map +1 -0
  24. package/convex/capabilities.d.ts +9 -0
  25. package/convex/capabilities.d.ts.map +1 -0
  26. package/convex/capabilities.js +145 -0
  27. package/convex/capabilities.js.map +1 -0
  28. package/convex/chains.d.ts +67 -0
  29. package/convex/chains.d.ts.map +1 -0
  30. package/convex/chains.js +1042 -0
  31. package/convex/chains.js.map +1 -0
  32. package/convex/credits.d.ts +25 -0
  33. package/convex/credits.d.ts.map +1 -0
  34. package/convex/credits.js +186 -0
  35. package/convex/credits.js.map +1 -0
  36. package/convex/crons.d.ts +3 -0
  37. package/convex/crons.d.ts.map +1 -0
  38. package/convex/crons.js +17 -0
  39. package/convex/crons.js.map +1 -0
  40. package/convex/directCall.d.ts +72 -0
  41. package/convex/directCall.d.ts.map +1 -0
  42. package/convex/directCall.js +627 -0
  43. package/convex/directCall.js.map +1 -0
  44. package/convex/earnProgress.d.ts +58 -0
  45. package/convex/earnProgress.d.ts.map +1 -0
  46. package/convex/earnProgress.js +649 -0
  47. package/convex/earnProgress.js.map +1 -0
  48. package/convex/email.d.ts +14 -0
  49. package/convex/email.d.ts.map +1 -0
  50. package/convex/email.js +300 -0
  51. package/convex/email.js.map +1 -0
  52. package/convex/feedback.d.ts +7 -0
  53. package/convex/feedback.d.ts.map +1 -0
  54. package/convex/feedback.js +227 -0
  55. package/convex/feedback.js.map +1 -0
  56. package/convex/http.d.ts +3 -0
  57. package/convex/http.d.ts.map +1 -0
  58. package/convex/http.js +902 -0
  59. package/convex/http.js.map +1 -0
  60. package/convex/logs.d.ts +38 -0
  61. package/convex/logs.d.ts.map +1 -0
  62. package/convex/logs.js +487 -0
  63. package/convex/logs.js.map +1 -0
  64. package/convex/mou.d.ts +6 -0
  65. package/convex/mou.d.ts.map +1 -0
  66. package/convex/mou.js +82 -0
  67. package/convex/mou.js.map +1 -0
  68. package/convex/providerKeys.d.ts +31 -0
  69. package/convex/providerKeys.d.ts.map +1 -0
  70. package/convex/providerKeys.js +257 -0
  71. package/convex/providerKeys.js.map +1 -0
  72. package/convex/providers.d.ts +29 -0
  73. package/convex/providers.d.ts.map +1 -0
  74. package/convex/providers.js +756 -0
  75. package/convex/providers.js.map +1 -0
  76. package/convex/purchases.d.ts +7 -0
  77. package/convex/purchases.d.ts.map +1 -0
  78. package/convex/purchases.js +157 -0
  79. package/convex/purchases.js.map +1 -0
  80. package/convex/ratelimit.d.ts +4 -0
  81. package/convex/ratelimit.d.ts.map +1 -0
  82. package/convex/ratelimit.js +91 -0
  83. package/convex/ratelimit.js.map +1 -0
  84. package/convex/searchLogs.d.ts +4 -0
  85. package/convex/searchLogs.d.ts.map +1 -0
  86. package/convex/searchLogs.js +129 -0
  87. package/convex/searchLogs.js.map +1 -0
  88. package/convex/spendAlerts.d.ts +36 -0
  89. package/convex/spendAlerts.d.ts.map +1 -0
  90. package/convex/spendAlerts.js +380 -0
  91. package/convex/spendAlerts.js.map +1 -0
  92. package/convex/stripeActions.d.ts +19 -0
  93. package/convex/stripeActions.d.ts.map +1 -0
  94. package/convex/stripeActions.js +411 -0
  95. package/convex/stripeActions.js.map +1 -0
  96. package/convex/teams.d.ts +21 -0
  97. package/convex/teams.d.ts.map +1 -0
  98. package/convex/teams.js +215 -0
  99. package/convex/teams.js.map +1 -0
  100. package/convex/telemetry.d.ts +4 -0
  101. package/convex/telemetry.d.ts.map +1 -0
  102. package/convex/telemetry.js +74 -0
  103. package/convex/telemetry.js.map +1 -0
  104. package/convex/usage.d.ts +27 -0
  105. package/convex/usage.d.ts.map +1 -0
  106. package/convex/usage.js +229 -0
  107. package/convex/usage.js.map +1 -0
  108. package/convex/waitlist.d.ts +4 -0
  109. package/convex/waitlist.d.ts.map +1 -0
  110. package/convex/waitlist.js +49 -0
  111. package/convex/waitlist.js.map +1 -0
  112. package/convex/webhooks.d.ts +12 -0
  113. package/convex/webhooks.d.ts.map +1 -0
  114. package/convex/webhooks.js +410 -0
  115. package/convex/webhooks.js.map +1 -0
  116. package/convex/workspaces.d.ts +29 -0
  117. package/convex/workspaces.d.ts.map +1 -0
  118. package/convex/workspaces.js +880 -0
  119. package/convex/workspaces.js.map +1 -0
  120. package/dist/analytics.d.ts +1 -1
  121. package/dist/analytics.d.ts.map +1 -1
  122. package/dist/analytics.js +51 -2
  123. package/dist/analytics.js.map +1 -1
  124. package/dist/bin-http.d.ts +7 -0
  125. package/dist/bin-http.d.ts.map +1 -0
  126. package/dist/bin-http.js +43 -0
  127. package/dist/bin-http.js.map +1 -0
  128. package/dist/http-api.d.ts +16 -0
  129. package/dist/http-api.d.ts.map +1 -0
  130. package/dist/http-api.js +269 -0
  131. package/dist/http-api.js.map +1 -0
  132. package/dist/index.js +27 -2
  133. package/dist/index.js.map +1 -1
  134. package/landing/scripts/generate-stats.js +9 -5
  135. package/landing/src/app/layout.tsx +5 -5
  136. package/landing/src/app/page.tsx +2 -0
  137. package/landing/src/lib/stats.json +2 -2
  138. package/package.json +3 -2
  139. package/src/analytics.ts +53 -2
  140. package/src/bin-http.ts +45 -0
  141. package/src/http-api.ts +302 -0
  142. package/src/index.ts +28 -2
package/HTTP-API.md ADDED
@@ -0,0 +1,306 @@
1
+ # APIClaw HTTP API
2
+
3
+ REST endpoints for headless agents (Hivr bees, webhooks, serverless functions).
4
+
5
+ ## 🚀 Quick Start
6
+
7
+ **Start server:**
8
+ ```bash
9
+ npx apiclaw-http --port 3000
10
+ ```
11
+
12
+ **Or via npm:**
13
+ ```bash
14
+ npm i -g @nordsym/apiclaw
15
+ apiclaw-http
16
+ ```
17
+
18
+ Server runs on `http://localhost:3000` by default.
19
+
20
+ ---
21
+
22
+ ## 📡 Endpoints
23
+
24
+ ### 1. Discover APIs
25
+
26
+ Search for APIs by capability.
27
+
28
+ **Request:**
29
+ ```http
30
+ GET /api/discover?query=web+search&agentId=bytebee&category=Search&maxResults=5
31
+ ```
32
+
33
+ **Parameters:**
34
+ | Param | Required | Description |
35
+ |-------|----------|-------------|
36
+ | `query` | Yes | Search query (e.g., "web search", "send SMS") |
37
+ | `agentId` | Yes | Your agent ID (must be whitelisted) |
38
+ | `category` | No | Filter by category |
39
+ | `maxResults` | No | Max results to return (default: 5) |
40
+
41
+ **Response:**
42
+ ```json
43
+ {
44
+ "success": true,
45
+ "query": "web search",
46
+ "results": [
47
+ {
48
+ "provider": {
49
+ "id": "brave_search",
50
+ "name": "Brave Search",
51
+ "category": "Search"
52
+ },
53
+ "score": 95,
54
+ "reasons": ["keyword: search", "capability: web search"]
55
+ }
56
+ ],
57
+ "count": 1,
58
+ "responseTimeMs": 12
59
+ }
60
+ ```
61
+
62
+ ---
63
+
64
+ ### 2. Call API
65
+
66
+ Execute an API call.
67
+
68
+ **Request:**
69
+ ```http
70
+ POST /api/call_api
71
+ Content-Type: application/json
72
+
73
+ {
74
+ "provider": "brave_search",
75
+ "action": "search",
76
+ "params": {
77
+ "query": "AI news",
78
+ "count": 5
79
+ },
80
+ "agentId": "bytebee"
81
+ }
82
+ ```
83
+
84
+ **Parameters:**
85
+ | Field | Required | Description |
86
+ |-------|----------|-------------|
87
+ | `provider` | Yes | Provider ID (from discover results) |
88
+ | `action` | Yes | Action to perform (e.g., "search", "send_sms") |
89
+ | `params` | Yes | Action parameters (varies by provider) |
90
+ | `agentId` | Yes | Your agent ID (must be whitelisted) |
91
+
92
+ **Response (success):**
93
+ ```json
94
+ {
95
+ "success": true,
96
+ "provider": "brave_search",
97
+ "action": "search",
98
+ "agentId": "bytebee",
99
+ "data": {
100
+ "results": [
101
+ {
102
+ "title": "Latest AI News",
103
+ "url": "https://example.com/ai-news",
104
+ "snippet": "..."
105
+ }
106
+ ]
107
+ },
108
+ "latencyMs": 234
109
+ }
110
+ ```
111
+
112
+ **Response (error):**
113
+ ```json
114
+ {
115
+ "success": false,
116
+ "provider": "brave_search",
117
+ "action": "search",
118
+ "agentId": "bytebee",
119
+ "error": "Rate limit exceeded",
120
+ "latencyMs": 12
121
+ }
122
+ ```
123
+
124
+ ---
125
+
126
+ ### 3. Health Check
127
+
128
+ Check if server is running.
129
+
130
+ **Request:**
131
+ ```http
132
+ GET /health
133
+ ```
134
+
135
+ **Response:**
136
+ ```json
137
+ {
138
+ "status": "ok",
139
+ "service": "apiclaw-http-api"
140
+ }
141
+ ```
142
+
143
+ ---
144
+
145
+ ## 🔐 Authentication
146
+
147
+ **Hivr Bees Whitelist:**
148
+
149
+ Access is restricted to whitelisted Hivr bees. The `agentId` parameter must match one of these:
150
+
151
+ ```
152
+ bytebee, analyzerbee, buildbee, buzzwriter, hivemind,
153
+ hivesage, symbot, hivrqueen, marketmaven, reconbee,
154
+ sprintbee, quillbee
155
+ ```
156
+
157
+ **Unauthorized response:**
158
+ ```json
159
+ {
160
+ "error": "Unauthorized",
161
+ "message": "This endpoint is restricted to Hivr bees. Contact admin@nordsym.com for access."
162
+ }
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 📊 Usage Logging
168
+
169
+ All API calls are logged to APIClaw analytics with:
170
+ - Provider + action
171
+ - Agent ID (e.g., `hivr:bytebee`)
172
+ - Success/failure
173
+ - Latency
174
+
175
+ This enables usage tracking per Hivr bee.
176
+
177
+ ---
178
+
179
+ ## 🎯 Example: Web Search
180
+
181
+ **1. Discover search APIs:**
182
+ ```bash
183
+ curl "http://localhost:3000/api/discover?query=web+search&agentId=bytebee"
184
+ ```
185
+
186
+ **2. Call Brave Search:**
187
+ ```bash
188
+ curl -X POST http://localhost:3000/api/call_api \
189
+ -H "Content-Type: application/json" \
190
+ -d '{
191
+ "provider": "brave_search",
192
+ "action": "search",
193
+ "params": {
194
+ "query": "latest AI developments",
195
+ "count": 5
196
+ },
197
+ "agentId": "bytebee"
198
+ }'
199
+ ```
200
+
201
+ ---
202
+
203
+ ## 🌐 CORS
204
+
205
+ CORS headers are set to allow cross-origin requests from anywhere:
206
+ - `Access-Control-Allow-Origin: *`
207
+ - `Access-Control-Allow-Methods: GET, POST, OPTIONS`
208
+ - `Access-Control-Allow-Headers: Content-Type, X-Agent-Id`
209
+
210
+ Safe for browser-based agents.
211
+
212
+ ---
213
+
214
+ ## 🚀 Deployment
215
+
216
+ ### Local Development
217
+ ```bash
218
+ apiclaw-http --port 3000
219
+ ```
220
+
221
+ ### Production (systemd)
222
+ ```ini
223
+ [Unit]
224
+ Description=APIClaw HTTP API
225
+ After=network.target
226
+
227
+ [Service]
228
+ Type=simple
229
+ User=apiclaw
230
+ WorkingDirectory=/opt/apiclaw
231
+ ExecStart=/usr/bin/apiclaw-http --port 3000
232
+ Restart=always
233
+ Environment="PORT=3000"
234
+
235
+ [Install]
236
+ WantedBy=multi-user.target
237
+ ```
238
+
239
+ ### Docker
240
+ ```dockerfile
241
+ FROM node:20
242
+ RUN npm i -g @nordsym/apiclaw
243
+ CMD ["apiclaw-http", "--port", "3000"]
244
+ EXPOSE 3000
245
+ ```
246
+
247
+ ### Vercel (Serverless)
248
+ See `landing/` directory for Next.js API routes wrapper.
249
+
250
+ ---
251
+
252
+ ## 🐝 Hivr Integration
253
+
254
+ **In your Hivr bee instructions:**
255
+ ```markdown
256
+ ## APIClaw Access 🦞
257
+
258
+ You have access to APIClaw via HTTP API.
259
+
260
+ **Discover APIs:**
261
+ GET https://apiclaw.nordsym.com/api/discover?query=web+search&agentId=YOUR_HANDLE
262
+
263
+ **Call APIs:**
264
+ POST https://apiclaw.nordsym.com/api/call_api
265
+ Body: { provider: "brave_search", action: "search", params: {...}, agentId: "YOUR_HANDLE" }
266
+
267
+ **Your agent ID:** Replace `YOUR_HANDLE` with your actual handle (e.g., "bytebee").
268
+ ```
269
+
270
+ ---
271
+
272
+ ## 📚 API Provider Reference
273
+
274
+ See [apiclaw.nordsym.com/docs](https://apiclaw.nordsym.com/docs) for:
275
+ - List of all 18 Direct Call providers
276
+ - Available actions per provider
277
+ - Parameter schemas
278
+ - Rate limits & pricing
279
+
280
+ ---
281
+
282
+ ## 🔧 Development
283
+
284
+ **Run from source:**
285
+ ```bash
286
+ cd apiclaw
287
+ npm run build
288
+ node dist/bin-http.js --port 3000
289
+ ```
290
+
291
+ **Watch mode:**
292
+ ```bash
293
+ tsx watch src/bin-http.ts
294
+ ```
295
+
296
+ ---
297
+
298
+ ## ❓ Support
299
+
300
+ - **Docs:** [apiclaw.nordsym.com/docs](https://apiclaw.nordsym.com/docs)
301
+ - **Issues:** [github.com/nordsym/apiclaw/issues](https://github.com/nordsym/apiclaw/issues)
302
+ - **Email:** admin@nordsym.com
303
+
304
+ ---
305
+
306
+ MIT © [NordSym](https://nordsym.com)
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import type * as adminActivate from "../adminActivate.js";
12
+ import type * as adminStats from "../adminStats.js";
12
13
  import type * as agents from "../agents.js";
13
14
  import type * as analytics from "../analytics.js";
14
15
  import type * as billing from "../billing.js";
@@ -45,6 +46,7 @@ import type {
45
46
 
46
47
  declare const fullApi: ApiFromModules<{
47
48
  adminActivate: typeof adminActivate;
49
+ adminStats: typeof adminStats;
48
50
  agents: typeof agents;
49
51
  analytics: typeof analytics;
50
52
  billing: typeof billing;
@@ -0,0 +1,3 @@
1
+ export declare const activateWorkspace: any;
2
+ export declare const createSessionForWorkspace: any;
3
+ //# sourceMappingURL=adminActivate.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,47 @@
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
@@ -0,0 +1 @@
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;IACpB,MAAM,KAAK,GAAG,gEAAgE,CAAC;IAC/E,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAChD,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,IAAI,SAAS,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAChD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;QAC3D,CAAC;QAED,MAAM,YAAY,GAAG,UAAU,GAAG,aAAa,EAAE,CAAC;QAElD,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,eAAe,EAAE;YACnC,WAAW;YACX,YAAY;YACZ,WAAW,EAAE,WAAW;YACxB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;QAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACzC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const getTotalWorkspaces: any;
2
+ export declare const listWorkspaces: any;
3
+ //# sourceMappingURL=adminStats.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,42 @@
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
@@ -0,0 +1 @@
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,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,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAC;QAE5D,OAAO;YACL,eAAe,EAAE,UAAU,CAAC,MAAM;YAClC,cAAc,EAAE,SAAS,CAAC,MAAM;YAChC,gBAAgB,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM;YACtE,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,MAAM;YAC3D,kBAAkB,EAAE;gBAClB,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,MAAM;gBACtD,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,MAAM;gBACpD,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,MAAM;gBAClE,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,MAAM;aAC3D;YACD,iBAAiB,EAAE;gBACjB,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM;gBAC7D,QAAQ,EAAE,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"}
@@ -0,0 +1,44 @@
1
+ import { query } from "./_generated/server";
2
+
3
+ // Get total user/workspace count
4
+ export const getTotalWorkspaces = query({
5
+ args: {},
6
+ handler: async (ctx) => {
7
+ const workspaces = await ctx.db.query("workspaces").collect();
8
+ const providers = await ctx.db.query("providers").collect();
9
+
10
+ return {
11
+ totalWorkspaces: workspaces.length,
12
+ totalProviders: providers.length,
13
+ activeWorkspaces: workspaces.filter(w => w.status === "active").length,
14
+ backers: workspaces.filter(w => w.tier === "backer").length,
15
+ workspaceBreakdown: {
16
+ free: workspaces.filter(w => w.tier === "free").length,
17
+ pro: workspaces.filter(w => w.tier === "pro").length,
18
+ enterprise: workspaces.filter(w => w.tier === "enterprise").length,
19
+ backer: workspaces.filter(w => w.tier === "backer").length,
20
+ },
21
+ providerBreakdown: {
22
+ pending: providers.filter(p => p.status === "pending").length,
23
+ approved: providers.filter(p => p.status === "approved").length,
24
+ rejected: providers.filter(p => p.status === "rejected").length,
25
+ }
26
+ };
27
+ },
28
+ });
29
+
30
+ // List all workspace emails (for inspection)
31
+ export const listWorkspaces = query({
32
+ args: {},
33
+ handler: async (ctx) => {
34
+ const workspaces = await ctx.db.query("workspaces").collect();
35
+ return workspaces.map(w => ({
36
+ email: w.email,
37
+ status: w.status,
38
+ tier: w.tier,
39
+ usageCount: w.usageCount,
40
+ createdAt: w.createdAt,
41
+ lastActiveAt: w.lastActiveAt,
42
+ }));
43
+ },
44
+ });
@@ -0,0 +1,54 @@
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
+ //# sourceMappingURL=agents.d.ts.map
@@ -0,0 +1 @@
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"}