@nordsym/apiclaw 1.5.17 → 1.5.19

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 (228) hide show
  1. package/convex/http.js.map +1 -1
  2. package/convex/http.ts +516 -0
  3. package/dist/analytics.d.ts +0 -4
  4. package/dist/analytics.d.ts.map +1 -1
  5. package/dist/analytics.js +0 -1
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/bin.js +1 -1
  8. package/dist/cli/commands/mcp-install.d.ts.map +1 -1
  9. package/dist/cli/commands/mcp-install.js +8 -87
  10. package/dist/cli/commands/mcp-install.js.map +1 -1
  11. package/dist/cli/index.js +0 -7
  12. package/dist/credentials.d.ts.map +1 -1
  13. package/dist/credentials.js +38 -43
  14. package/dist/credentials.js.map +1 -1
  15. package/dist/discovery.d.ts.map +1 -1
  16. package/dist/discovery.js +82 -191
  17. package/dist/discovery.js.map +1 -1
  18. package/dist/http-api.d.ts.map +1 -1
  19. package/dist/http-api.js +33 -17
  20. package/dist/http-api.js.map +1 -1
  21. package/dist/proxy.js +1 -1
  22. package/dist/proxy.js.map +1 -1
  23. package/landing/next-env.d.ts +0 -1
  24. package/landing/src/app/api/auth/magic-link/route.ts +1 -1
  25. package/landing/src/app/auth/verify/page.tsx +0 -6
  26. package/landing/src/app/dashboard/verify/page.tsx +0 -6
  27. package/landing/src/app/join/page.tsx +0 -6
  28. package/landing/src/app/layout.tsx +2 -2
  29. package/landing/src/app/login/page.tsx +1 -1
  30. package/landing/src/app/mou/[partnerId]/page.tsx +0 -6
  31. package/landing/src/app/page.tsx +18 -39
  32. package/landing/src/app/providers/dashboard/[apiId]/actions/[actionId]/edit/page.tsx +0 -6
  33. package/landing/src/app/providers/dashboard/[apiId]/actions/new/page.tsx +0 -5
  34. package/landing/src/app/providers/dashboard/[apiId]/actions/page.tsx +0 -5
  35. package/landing/src/app/providers/dashboard/[apiId]/direct-call/page.tsx +1 -6
  36. package/landing/src/app/providers/dashboard/[apiId]/page.tsx +0 -5
  37. package/landing/src/app/providers/dashboard/[apiId]/test/page.tsx +0 -5
  38. package/landing/src/app/providers/dashboard/layout.tsx +6 -6
  39. package/landing/src/app/providers/dashboard/login/page.tsx +1 -1
  40. package/landing/src/app/providers/dashboard/page.tsx +1 -1
  41. package/landing/src/app/providers/dashboard/verify/page.tsx +0 -6
  42. package/landing/src/app/providers/layout.tsx +1 -1
  43. package/landing/src/app/upgrade/page.tsx +0 -6
  44. package/landing/src/app/workspace/page.tsx +0 -6
  45. package/landing/src/components/HeroTabs.tsx +2 -2
  46. package/landing/src/components/{Workspace.tsx → ProviderDashboard.tsx} +2 -2
  47. package/landing/src/components/VideoDemo.tsx +10 -21
  48. package/landing/src/lib/mock-data.ts +1 -1
  49. package/landing/src/lib/stats.json +1 -1
  50. package/package.json +3 -8
  51. package/src/analytics.ts +0 -5
  52. package/src/bin.ts +1 -1
  53. package/src/cli/commands/mcp-install.ts +8 -90
  54. package/src/cli/index.ts +0 -8
  55. package/src/credentials.ts +39 -44
  56. package/src/discovery.ts +82 -191
  57. package/src/http-api.ts +34 -18
  58. package/src/proxy.ts +1 -1
  59. package/APILAYER_STATUS_2026-03-24.md +0 -38
  60. package/CHANGELOG-WHITELIST-V2.md +0 -269
  61. package/HIVR-WHITELIST-STATUS.md +0 -205
  62. package/HIVR-WHITELIST.md +0 -148
  63. package/TERMINOLOGY-AUDIT.md +0 -99
  64. package/TERMINOLOGY-FIXED.md +0 -74
  65. package/VIDEO-DEMO-GUIDE.md +0 -82
  66. package/WHITELIST-ARCHITECTURE.md +0 -379
  67. package/api/discover.ts +0 -71
  68. package/api/health.ts +0 -20
  69. package/convex/adminActivate.d.ts +0 -3
  70. package/convex/adminActivate.js +0 -47
  71. package/convex/adminStats.d.ts +0 -3
  72. package/convex/adminStats.js +0 -42
  73. package/convex/agents.d.ts +0 -54
  74. package/convex/agents.js +0 -499
  75. package/convex/analytics.d.ts +0 -5
  76. package/convex/analytics.js +0 -166
  77. package/convex/billing.d.ts +0 -88
  78. package/convex/billing.js +0 -655
  79. package/convex/capabilities.d.ts +0 -9
  80. package/convex/capabilities.js +0 -145
  81. package/convex/chains.d.ts +0 -67
  82. package/convex/chains.js +0 -1042
  83. package/convex/credits.d.ts +0 -25
  84. package/convex/credits.js +0 -186
  85. package/convex/crons.d.ts +0 -3
  86. package/convex/crons.js +0 -17
  87. package/convex/directCall.d.ts +0 -72
  88. package/convex/directCall.js +0 -627
  89. package/convex/earnProgress.d.ts +0 -58
  90. package/convex/earnProgress.js +0 -649
  91. package/convex/email.d.ts +0 -14
  92. package/convex/email.js +0 -300
  93. package/convex/feedback.d.ts +0 -7
  94. package/convex/feedback.js +0 -227
  95. package/convex/http.d.ts +0 -3
  96. package/convex/http.js +0 -910
  97. package/convex/logs.d.ts +0 -38
  98. package/convex/logs.js +0 -487
  99. package/convex/mou.d.ts +0 -6
  100. package/convex/mou.js +0 -82
  101. package/convex/providerKeys.d.ts +0 -31
  102. package/convex/providerKeys.js +0 -257
  103. package/convex/providers.d.ts +0 -29
  104. package/convex/providers.js +0 -756
  105. package/convex/purchases.d.ts +0 -7
  106. package/convex/purchases.js +0 -157
  107. package/convex/ratelimit.d.ts +0 -4
  108. package/convex/ratelimit.js +0 -91
  109. package/convex/searchLogs.d.ts +0 -4
  110. package/convex/searchLogs.js +0 -129
  111. package/convex/spendAlerts.d.ts +0 -36
  112. package/convex/spendAlerts.js +0 -380
  113. package/convex/stripeActions.d.ts +0 -19
  114. package/convex/stripeActions.js +0 -411
  115. package/convex/teams.d.ts +0 -21
  116. package/convex/teams.js +0 -215
  117. package/convex/telemetry.d.ts +0 -4
  118. package/convex/telemetry.js +0 -74
  119. package/convex/usage.d.ts +0 -27
  120. package/convex/usage.js +0 -229
  121. package/convex/waitlist.d.ts +0 -4
  122. package/convex/waitlist.js +0 -49
  123. package/convex/webhooks.d.ts +0 -12
  124. package/convex/webhooks.js +0 -410
  125. package/convex/workspaces.d.ts +0 -29
  126. package/convex/workspaces.js +0 -880
  127. package/direct-test.mjs +0 -51
  128. package/dist/access-control.d.ts +0 -45
  129. package/dist/access-control.d.ts.map +0 -1
  130. package/dist/access-control.js +0 -142
  131. package/dist/access-control.js.map +0 -1
  132. package/dist/chain-types.d.ts +0 -187
  133. package/dist/chain-types.d.ts.map +0 -1
  134. package/dist/chain-types.js +0 -33
  135. package/dist/chain-types.js.map +0 -1
  136. package/dist/convex/adminActivate.js +0 -46
  137. package/dist/convex/adminStats.js +0 -41
  138. package/dist/convex/agents.js +0 -498
  139. package/dist/convex/analytics.js +0 -165
  140. package/dist/convex/billing.js +0 -654
  141. package/dist/convex/capabilities.js +0 -144
  142. package/dist/convex/chains.js +0 -1041
  143. package/dist/convex/credits.js +0 -185
  144. package/dist/convex/crons.js +0 -16
  145. package/dist/convex/directCall.js +0 -626
  146. package/dist/convex/earnProgress.js +0 -648
  147. package/dist/convex/email.js +0 -299
  148. package/dist/convex/feedback.js +0 -226
  149. package/dist/convex/http.js +0 -909
  150. package/dist/convex/logs.js +0 -486
  151. package/dist/convex/mou.js +0 -81
  152. package/dist/convex/providerKeys.js +0 -256
  153. package/dist/convex/providers.js +0 -755
  154. package/dist/convex/purchases.js +0 -156
  155. package/dist/convex/ratelimit.js +0 -90
  156. package/dist/convex/schema.js +0 -709
  157. package/dist/convex/searchLogs.js +0 -128
  158. package/dist/convex/spendAlerts.js +0 -379
  159. package/dist/convex/stripeActions.js +0 -410
  160. package/dist/convex/teams.js +0 -214
  161. package/dist/convex/telemetry.js +0 -73
  162. package/dist/convex/usage.js +0 -228
  163. package/dist/convex/waitlist.js +0 -48
  164. package/dist/convex/webhooks.js +0 -409
  165. package/dist/convex/workspaces.js +0 -879
  166. package/dist/hivr-whitelist.d.ts +0 -18
  167. package/dist/hivr-whitelist.d.ts.map +0 -1
  168. package/dist/hivr-whitelist.js +0 -95
  169. package/dist/hivr-whitelist.js.map +0 -1
  170. package/dist/http-server-minimal.d.ts +0 -7
  171. package/dist/http-server-minimal.d.ts.map +0 -1
  172. package/dist/http-server-minimal.js +0 -126
  173. package/dist/http-server-minimal.js.map +0 -1
  174. package/dist/product-whitelist.d.ts +0 -37
  175. package/dist/product-whitelist.d.ts.map +0 -1
  176. package/dist/product-whitelist.js +0 -203
  177. package/dist/product-whitelist.js.map +0 -1
  178. package/dist/src/analytics.js +0 -129
  179. package/dist/src/bin.js +0 -17
  180. package/dist/src/capability-router.js +0 -240
  181. package/dist/src/chainExecutor.js +0 -451
  182. package/dist/src/chainResolver.js +0 -518
  183. package/dist/src/cli/commands/doctor.js +0 -324
  184. package/dist/src/cli/commands/mcp-install.js +0 -255
  185. package/dist/src/cli/commands/restore.js +0 -259
  186. package/dist/src/cli/commands/setup.js +0 -205
  187. package/dist/src/cli/commands/uninstall.js +0 -188
  188. package/dist/src/cli/index.js +0 -111
  189. package/dist/src/cli.js +0 -302
  190. package/dist/src/confirmation.js +0 -240
  191. package/dist/src/credentials.js +0 -357
  192. package/dist/src/credits.js +0 -260
  193. package/dist/src/crypto.js +0 -66
  194. package/dist/src/discovery.js +0 -504
  195. package/dist/src/enterprise/env.js +0 -123
  196. package/dist/src/enterprise/script-generator.js +0 -460
  197. package/dist/src/execute-dynamic.js +0 -473
  198. package/dist/src/execute.js +0 -1727
  199. package/dist/src/index.js +0 -2062
  200. package/dist/src/metered.js +0 -80
  201. package/dist/src/open-apis.js +0 -276
  202. package/dist/src/proxy.js +0 -28
  203. package/dist/src/session.js +0 -86
  204. package/dist/src/stripe.js +0 -407
  205. package/dist/src/telemetry.js +0 -49
  206. package/dist/src/types.js +0 -2
  207. package/dist/src/utils/backup.js +0 -181
  208. package/dist/src/utils/config.js +0 -220
  209. package/dist/src/utils/os.js +0 -105
  210. package/dist/src/utils/paths.js +0 -159
  211. package/landing/pages/api/discover.ts +0 -43
  212. package/landing/pages/api/health.ts +0 -20
  213. package/scripts/test-whitelist-v2.sh +0 -128
  214. package/src/access-control.ts +0 -174
  215. package/src/hivr-whitelist.ts +0 -110
  216. package/src/http-server-minimal.ts +0 -154
  217. package/src/product-whitelist.ts +0 -246
  218. package/test-actual-handlers.ts +0 -92
  219. package/test-apilayer-all-14.ts +0 -249
  220. package/test-apilayer-fixed.ts +0 -248
  221. package/test-direct-endpoints.ts +0 -174
  222. package/test-exact-endpoints.ts +0 -144
  223. package/test-final.ts +0 -83
  224. package/test-full-routing.ts +0 -100
  225. package/test-handlers-correct.ts +0 -217
  226. package/test-numverify-key.ts +0 -41
  227. package/test-via-handlers.ts +0 -92
  228. package/test-worldnews.mjs +0 -26
package/src/http-api.ts CHANGED
@@ -17,7 +17,23 @@ import { isOpenAPI, executeOpenAPI } from './open-apis.js';
17
17
  import { executeMetered } from './metered.js';
18
18
  import { logAPICall } from './analytics.js';
19
19
  import { getMachineFingerprint } from './session.js';
20
- import { isAuthorized, getProduct } from './product-whitelist.js';
20
+
21
+ // Hivr bees whitelist - these agents get free unlimited access
22
+ const HIVR_BEES_WHITELIST = [
23
+ 'bytebee',
24
+ 'analyzerbee',
25
+ 'buildbee',
26
+ 'buzzwriter',
27
+ 'hivemind',
28
+ 'hivesage',
29
+ 'symbot',
30
+ 'hivrqueen',
31
+ 'marketmaven',
32
+ 'reconbee',
33
+ 'sprintbee',
34
+ 'quillbee',
35
+ // Add more as Hivr grows
36
+ ];
21
37
 
22
38
  interface APIRequest {
23
39
  provider: string;
@@ -26,6 +42,15 @@ interface APIRequest {
26
42
  agentId: string;
27
43
  }
28
44
 
45
+ /**
46
+ * Check if agent is authorized (Hivr bee)
47
+ */
48
+ function isAuthorized(agentId: string | undefined): boolean {
49
+ if (!agentId) return false;
50
+ const normalized = agentId.toLowerCase().trim();
51
+ return HIVR_BEES_WHITELIST.includes(normalized);
52
+ }
53
+
29
54
  /**
30
55
  * Parse JSON body from request
31
56
  */
@@ -72,7 +97,7 @@ async function handleDiscover(req: IncomingMessage, res: ServerResponse, url: UR
72
97
  return;
73
98
  }
74
99
 
75
- if (!(await isAuthorized(agentId || undefined))) {
100
+ if (!isAuthorized(agentId || undefined)) {
76
101
  sendJSON(res, 403, {
77
102
  error: 'Unauthorized',
78
103
  message: 'This endpoint is restricted to Hivr bees. Contact admin@nordsym.com for access.',
@@ -84,17 +109,15 @@ async function handleDiscover(req: IncomingMessage, res: ServerResponse, url: UR
84
109
  const results = discoverAPIs(query, { category, maxResults });
85
110
  const responseTimeMs = Date.now() - startTime;
86
111
 
87
- // Log to analytics with product info
88
- const product = agentId ? getProduct(agentId) : null;
112
+ // Log to analytics
89
113
  logAPICall({
90
114
  timestamp: new Date().toISOString(),
91
115
  provider: 'apiclaw_discovery',
92
116
  action: 'discover',
93
117
  type: 'open',
94
- userId: agentId || 'unknown',
118
+ userId: `hivr:${agentId}`,
95
119
  success: true,
96
120
  latencyMs: responseTimeMs,
97
- metadata: product ? { product } : undefined,
98
121
  });
99
122
 
100
123
  sendJSON(res, 200, {
@@ -135,15 +158,10 @@ async function handleCallAPI(req: IncomingMessage, res: ServerResponse): Promise
135
158
  return;
136
159
  }
137
160
 
138
- // Check whitelist + access control
139
- const { isAllowed } = await import('./access-control.js');
140
- const accessCheck = await isAllowed(agentId, provider);
141
-
142
- if (!accessCheck.allowed) {
161
+ if (!isAuthorized(agentId)) {
143
162
  sendJSON(res, 403, {
144
- error: 'Access Denied',
145
- message: accessCheck.reason || 'Not authorized',
146
- hint: 'Contact admin@nordsym.com for access',
163
+ error: 'Unauthorized',
164
+ message: 'This endpoint is restricted to Hivr bees. Contact admin@nordsym.com for access.',
147
165
  });
148
166
  return;
149
167
  }
@@ -183,18 +201,16 @@ async function handleCallAPI(req: IncomingMessage, res: ServerResponse): Promise
183
201
 
184
202
  const latencyMs = Date.now() - startTime;
185
203
 
186
- // Log to analytics with product info
187
- const product = getProduct(agentId);
204
+ // Log to analytics
188
205
  logAPICall({
189
206
  timestamp: new Date().toISOString(),
190
207
  provider,
191
208
  action,
192
209
  type: apiType!,
193
- userId: agentId,
210
+ userId: `hivr:${agentId}`,
194
211
  success,
195
212
  latencyMs,
196
213
  error,
197
- metadata: product ? { product } : undefined,
198
214
  });
199
215
 
200
216
  sendJSON(res, success ? 200 : 500, {
package/src/proxy.ts CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { readSession, getMachineFingerprint } from './session.js';
6
6
 
7
- const PROXY_BASE = "https://brilliant-puffin-712.eu-west-1.convex.site/proxy";
7
+ const PROXY_BASE = "https://adventurous-avocet-799.convex.site/proxy";
8
8
 
9
9
  export async function callProxy(provider: string, params: any): Promise<any> {
10
10
  const url = `${PROXY_BASE}/${provider}`;
@@ -1,38 +0,0 @@
1
- # APILayer 14 Services Status Report
2
- **Date:** 2026-03-24, 11:55 CET
3
- **Meeting:** Pratham (APILayer DevReal) @ 3:30pm
4
- **Status:** 11/14 WORKING
5
-
6
- ## ✅ CONFIRMED WORKING (11/14)
7
- 1. **ExchangeRate API** — HTTP 200 ✓
8
- 2. **AviationStack API** — HTTP 200 ✓
9
- 3. **ScreenshotLayer API** — HTTP 200 ✓
10
- 4. **Number Verification API** — HTTP 200 ✓
11
- 5. **Email Verification API** — HTTP 200 ✓
12
- 6. **Marketstack API** — HTTP 200 ✓
13
- 7. **VAT Layer API** — HTTP 200 ✓
14
- 8. **Finance News API** — HTTP 200 (endpoint: `/financelayer/news`) ✓
15
- 9. **Image Crop API** — HTTP 200 (endpoint: `/smart_crop/url`) ✓
16
- 10. **Advanced Scraper API** — HTTP 200 ✓
17
- 11. **PDFLayer** — HTTP 200 (POST to `https://api.pdflayer.com/api`, separate domain) ✓
18
-
19
- ## ❌ NOT WORKING (3/14)
20
- - **WorldNews API** — 404 (endpoint path unknown — needs documentation)
21
- - **SkillAPI** — 401 "Invalid authentication credentials" (on api.promptapi.com, separate service)
22
- - **FormAPI** — 403 "You cannot consume this service" (permission issue, parked)
23
-
24
- ## KEY DISCOVERIES
25
- - PDFLayer is **NOT** on api.apilayer.com — it's on **api.pdflayer.com** (separate domain)
26
- - PDFLayer requires **POST** method (not GET)
27
- - Some services use namespace prefixes: `/financelayer/`, `/smart_crop/`
28
- - SkillAPI is on **promptapi.com** (different domain from apilayer)
29
-
30
- ## CREDENTIALS UPDATED
31
- - PDFLayer key updated in `~/.secrets/apilayer.env`
32
- - All 19 Direct Call providers have credentials in src/credentials.ts
33
- - Product messaging reordered (AI-first) in src/discovery.ts
34
-
35
- ## NEXT STEPS
36
- 1. Get WorldNews endpoint documentation
37
- 2. Verify/resolve SkillAPI authentication issue
38
- 3. Update discovery.ts with PDFLayer details (POST method, separate domain)
@@ -1,269 +0,0 @@
1
- # APIClaw Whitelist v2.0 - Implementation Summary
2
-
3
- **Date:** 2026-03-18
4
- **Status:** ✅ Complete
5
-
6
- ---
7
-
8
- ## Changes Made
9
-
10
- ### 🎯 New Files
11
-
12
- 1. **`src/product-whitelist.ts`** (6.2 KB)
13
- - Multi-product whitelist system
14
- - Namespaced agentIds (`product:agent`)
15
- - Dynamic fetching from multiple Convex sources
16
- - Per-product caching (5 min TTL)
17
- - Legacy format backward compatibility
18
-
19
- 2. **`src/access-control.ts`** (4.4 KB)
20
- - Per-provider access rules
21
- - Pattern matching (`hivr:*`, `nordsym:mollebot`)
22
- - Wildcard provider support (`*`, `brave_*`)
23
- - Deny by default security model
24
-
25
- 3. **`WHITELIST-ARCHITECTURE.md`** (9.4 KB)
26
- - Complete architecture documentation
27
- - Usage examples
28
- - Security model
29
- - Testing guide
30
- - Troubleshooting
31
-
32
- 4. **`CHANGELOG-WHITELIST-V2.md`** (this file)
33
-
34
- ### 📝 Modified Files
35
-
36
- 1. **`src/http-api.ts`**
37
- - Import `product-whitelist` instead of `hivr-whitelist`
38
- - Integrated access control checks
39
- - Enhanced analytics logging with product info
40
- - Better error messages
41
-
42
- 2. **`src/analytics.ts`**
43
- - Added `metadata` field to `APICallLog` interface
44
- - Product tracking in Convex logs
45
- - Enhanced metadata spreading
46
-
47
- ### 🗑️ Deprecated Files
48
-
49
- - `src/hivr-whitelist.ts` — Replaced by `product-whitelist.ts`
50
- - **Note:** Can be safely deleted, but kept for reference
51
- - Old `HIVR-WHITELIST.md` also superseded
52
-
53
- ---
54
-
55
- ## Features Delivered
56
-
57
- ### ✅ Multi-Product Support
58
- - Products configured in `PRODUCT_SOURCES` array
59
- - Each product can have own Convex URL, query path, auth token
60
- - Agents namespaced as `product:agentId`
61
- - Parallel fetching from all sources
62
- - Fallback if individual sources fail
63
-
64
- ### ✅ Access Control
65
- - Per-provider permissions
66
- - Pattern-based rules (wildcards, prefixes)
67
- - Configurable in `DEFAULT_RULES` array
68
- - Future: Can be moved to Convex table
69
-
70
- ### ✅ Enhanced Analytics
71
- - Product-level tracking
72
- - Per-agent usage within products
73
- - Metadata field for extensibility
74
- - Logs include product info
75
-
76
- ### ✅ Backward Compatibility
77
- - Legacy agentIds (without namespace) still work
78
- - Old Hivr agents auto-detected
79
- - No breaking changes for existing users
80
-
81
- ### ✅ Security Model
82
- - Two-layer check: whitelist + access control
83
- - Deny by default
84
- - Clear error messages
85
- - Audit trail in logs
86
-
87
- ---
88
-
89
- ## Configuration
90
-
91
- ### Adding New Product
92
-
93
- **File:** `src/product-whitelist.ts`
94
-
95
- ```typescript
96
- const PRODUCT_SOURCES: ProductSource[] = [
97
- {
98
- name: 'new_product',
99
- convexUrl: 'https://product.convex.cloud',
100
- queryPath: 'agents:list',
101
- agentIdField: 'agentId',
102
- authToken: process.env.PRODUCT_API_TOKEN, // Optional
103
- },
104
- ];
105
- ```
106
-
107
- ### Adding Access Rules
108
-
109
- **File:** `src/access-control.ts`
110
-
111
- ```typescript
112
- const DEFAULT_RULES: AccessRule[] = [
113
- {
114
- agentPattern: 'new_product:*',
115
- allowedProviders: ['brave_search', 'groq'],
116
- description: 'New product gets limited access',
117
- },
118
- ];
119
- ```
120
-
121
- ---
122
-
123
- ## Testing Checklist
124
-
125
- - [x] Whitelist fetching from Hivr Convex
126
- - [x] Namespaced agentId authorization
127
- - [x] Legacy agentId backward compat
128
- - [x] Access control deny
129
- - [x] Access control allow
130
- - [x] Analytics product tracking
131
- - [x] Cache invalidation
132
- - [x] Fallback on source failure
133
- - [x] Error messages clear
134
- - [ ] **Production test pending** (needs HTTP server running)
135
-
136
- ---
137
-
138
- ## Deployment Steps
139
-
140
- 1. **Backup current whitelist logic** (already done - kept hivr-whitelist.ts)
141
- 2. **Build TypeScript** (pending - has unrelated errors)
142
- 3. **Deploy HTTP API server** (manual restart needed)
143
- 4. **Test with real Hivr agents**
144
- 5. **Monitor analytics for product data**
145
- 6. **Add NordSym when ready**
146
-
147
- ---
148
-
149
- ## Known Issues / Limitations
150
-
151
- ### TypeScript Build Errors
152
- - Many unrelated TS errors in Convex files
153
- - New files (`product-whitelist.ts`, `access-control.ts`) are syntactically correct
154
- - Errors in `convex/` folder not related to whitelist v2
155
-
156
- ### Not Implemented Yet
157
- - Access rules in Convex table (currently hardcoded)
158
- - Webhook for instant whitelist updates
159
- - Per-agent rate limits
160
- - Admin UI for whitelist management
161
-
162
- ---
163
-
164
- ## Performance Impact
165
-
166
- ### Positive
167
- - **Parallel fetching** — All products fetched simultaneously
168
- - **Per-product caching** — Only expired caches refresh
169
- - **Lazy pattern compilation** — Access rules compiled once
170
-
171
- ### Neutral
172
- - **One extra check** — Access control adds ~1ms per request
173
- - **Metadata in logs** — Minimal overhead
174
-
175
- ---
176
-
177
- ## Migration Path for Existing Users
178
-
179
- ### Hivr (Current)
180
- - ✅ No action needed
181
- - ✅ Agents auto-prefixed with `hivr:`
182
- - ✅ Full access maintained (`allowedProviders: ['*']`)
183
-
184
- ### NordSym (Future)
185
- 1. Configure Convex source in `PRODUCT_SOURCES`
186
- 2. Add access rule in `DEFAULT_RULES`
187
- 3. Test with one agent
188
- 4. Roll out to team
189
-
190
- ### Partners (Future)
191
- 1. Get Convex URL + query details
192
- 2. Add to `PRODUCT_SOURCES`
193
- 3. Define access rules (likely restricted)
194
- 4. Onboard first agent
195
- 5. Monitor usage
196
-
197
- ---
198
-
199
- ## Rollback Plan
200
-
201
- If issues arise:
202
-
203
- 1. **Revert http-api.ts imports:**
204
- ```typescript
205
- import { isAuthorized } from './hivr-whitelist.js';
206
- ```
207
-
208
- 2. **Remove access control check:**
209
- ```typescript
210
- if (!(await isAuthorized(agentId))) {
211
- // Old error handling
212
- }
213
- ```
214
-
215
- 3. **Restart HTTP server**
216
-
217
- ---
218
-
219
- ## Next Steps
220
-
221
- ### Immediate
222
- - [ ] Production test with Hivr agents
223
- - [ ] Verify analytics product field populated
224
- - [ ] Monitor error logs for edge cases
225
-
226
- ### Short-term (1-2 weeks)
227
- - [ ] Add NordSym product source
228
- - [ ] Define NordSym access rules
229
- - [ ] Test with Molle's team
230
-
231
- ### Long-term (1-3 months)
232
- - [ ] Move access rules to Convex table
233
- - [ ] Build admin UI for whitelist management
234
- - [ ] Add webhook support for instant updates
235
- - [ ] Per-agent rate limiting
236
-
237
- ---
238
-
239
- ## Success Metrics
240
-
241
- Track these post-deployment:
242
-
243
- - ✅ Zero unauthorized access (403s for invalid agents)
244
- - ✅ Product field populated in analytics
245
- - ✅ Cache hit rate >90%
246
- - ✅ Latency increase <5ms
247
- - ✅ No whitelist-related errors
248
-
249
- ---
250
-
251
- ## Documentation Links
252
-
253
- - **Architecture:** `WHITELIST-ARCHITECTURE.md`
254
- - **Old docs:** `HIVR-WHITELIST.md` (deprecated)
255
- - **Code:**
256
- - `src/product-whitelist.ts`
257
- - `src/access-control.ts`
258
- - `src/http-api.ts`
259
- - `src/analytics.ts`
260
-
261
- ---
262
-
263
- **Implementation complete. Ready for production testing.** 🦞✨
264
-
265
- ---
266
-
267
- **Questions:** admin@nordsym.com
268
- **Version:** 2.0.0
269
- **Git tag:** `whitelist-v2` (when committed)
@@ -1,205 +0,0 @@
1
- # Hivr Whitelist - Status & Verification
2
-
3
- **Date:** 2026-03-19
4
- **Issue:** Whitelist checking wrong field, no account attribution
5
-
6
- ---
7
-
8
- ## ✅ What I Fixed
9
-
10
- ### 1. Hivr Whitelist — Field Name Mismatch
11
-
12
- **Problem:** Both whitelist files were looking for `agentId` field, but Hivr agents have `handle`
13
-
14
- **Files Fixed:**
15
- - `src/hivr-whitelist.ts` — Line 60: `a.agentId` → `a.handle`
16
- - `src/product-whitelist.ts` — Line 15: `agentIdField: 'agentId'` → `agentIdField: 'handle'`
17
-
18
- **Result:** Whitelist will now correctly extract bee handles from Hivr Convex
19
-
20
- ---
21
-
22
- ## ⚠️ What's Missing: Account Attribution
23
-
24
- **Your expectation:** All Hivr bee requests counted under `gustav@nordsym.com`
25
-
26
- **Current reality:** Requests logged only by bee handle (`bytebee`, `elderbee`, etc.)
27
-
28
- **Where tracking happens:**
29
- ```typescript
30
- // src/http-api.ts line ~94
31
- logAPICall({
32
- userId: agentId || 'unknown', // Just the bee handle, no account email
33
- // ...
34
- });
35
- ```
36
-
37
- **No account/email field exists in the current system.**
38
-
39
- ---
40
-
41
- ## 🔍 Verification Steps
42
-
43
- ### 1. Check Whitelist Works
44
-
45
- **Start APIClaw HTTP server:**
46
- ```bash
47
- cd ~/Projects/apiclaw
48
- npm run start:http
49
- ```
50
-
51
- **Expected log:**
52
- ```
53
- [Hivr Whitelist] Fetched 12 agents from Hivr
54
- ```
55
-
56
- **Test authorization:**
57
- ```bash
58
- # Should return 200 (authorized)
59
- curl "http://localhost:3000/api/discover?query=web&agentId=elderbee"
60
-
61
- # Should return 403 (unauthorized)
62
- curl "http://localhost:3000/api/discover?query=web&agentId=fakeagent"
63
- ```
64
-
65
- ### 2. Check Which Bees Are Whitelisted
66
-
67
- **In APIClaw console (when server running):**
68
- ```typescript
69
- import { getWhitelist } from './hivr-whitelist.js';
70
- const bees = await getWhitelist();
71
- console.log(bees); // Should list all Hivr bee handles
72
- ```
73
-
74
- ---
75
-
76
- ## 📊 Account Attribution (NOT Implemented)
77
-
78
- **If you want gustav@nordsym.com attribution:**
79
-
80
- ### Option A: Product Namespace (Already in place)
81
-
82
- Current system namespaces as `hivr:bytebee`, `hivr:elderbee`
83
-
84
- You can group by product:
85
- ```typescript
86
- // In analytics
87
- const hivrRequests = logs.filter(log => log.userId.startsWith('hivr:'));
88
- const nordsymRequests = logs.filter(log => log.userId.startsWith('nordsym:'));
89
- ```
90
-
91
- **Pros:** Works now with the fix
92
- **Cons:** Still no email/account tracking
93
-
94
- ### Option B: Add Account Field (Requires Implementation)
95
-
96
- **Change needed:**
97
- ```typescript
98
- // src/http-api.ts
99
- logAPICall({
100
- userId: agentId,
101
- accountEmail: 'gustav@nordsym.com', // ← Add this
102
- product: getProduct(agentId), // Already exists
103
- // ...
104
- });
105
- ```
106
-
107
- **Pros:** Clear separation NordSym vs Hivr
108
- **Cons:** Requires code changes + analytics schema update
109
-
110
- ### Option C: Convex Metadata (Clean Approach)
111
-
112
- **Store account mapping in Convex:**
113
- ```typescript
114
- // apiclawProviders table (already exists!)
115
- {
116
- agentId: "elderbee",
117
- slug: "hivr-elderbee",
118
- accountEmail: "gustav@nordsym.com", // ← Add this field
119
- }
120
- ```
121
-
122
- **Then in APIClaw:**
123
- ```typescript
124
- const provider = await getProviderByAgent(agentId);
125
- logAPICall({
126
- userId: agentId,
127
- accountEmail: provider?.accountEmail,
128
- // ...
129
- });
130
- ```
131
-
132
- **Pros:** Clean, uses existing infrastructure
133
- **Cons:** Requires schema update + backfill
134
-
135
- ---
136
-
137
- ## 🎯 Recommendation
138
-
139
- **Immediate (today):**
140
- 1. ✅ Field fix deployed (handle instead of agentId)
141
- 2. Restart APIClaw HTTP server to apply
142
- 3. Verify whitelist works (see steps above)
143
-
144
- **Short-term (if account attribution needed):**
145
- - Option C (Convex metadata) is cleanest
146
- - Add `accountEmail` to `apiclawProviders` table
147
- - Update HTTP API to include it in logs
148
- - **This aligns with the provider registration work already started**
149
-
150
- ---
151
-
152
- ## 📝 Current Whitelist Status
153
-
154
- **Bees expected to be whitelisted after fix:**
155
- - hivrqueen
156
- - elderbee
157
- - hivemind
158
- - hivesage_hivr_bot
159
- - buzzwriter
160
- - analyzerbee
161
- - buildbee
162
- - bytebee
163
- - reconbee
164
- - sprintbee
165
- - quillbee
166
- - marketmaven
167
-
168
- **Total:** 12 bees (all active Hivr agents)
169
-
170
- ---
171
-
172
- **Created:** 2026-03-19 12:20 CET
173
- **Updated:** 2026-03-19 12:26 CET
174
- **Status:** ✅ VERIFIED WORKING — All Hivr bees whitelisted
175
- **Server:** Running on localhost:3001
176
-
177
- ---
178
-
179
- ## ✅ Verification Complete (2026-03-19 12:26)
180
-
181
- **Issues Fixed:**
182
- 1. Field name: `agentId` → `handle` ✓
183
- 2. Convex HTTP response parsing: Access `.value` field ✓
184
-
185
- **Whitelist Status:** 14 Hivr bees successfully fetched and authorized
186
-
187
- **Tested Bees (all authorized ✓):**
188
- - bytebee
189
- - elderbee
190
- - hivrqueen
191
- - symbot
192
- - marketmaven
193
- - reconbee
194
- - HiveMind_Hivr_bot
195
- - AnalyzerBee_Hivr_bot
196
- - Buzzwriter_Hivr_bot
197
- - BuildBee_Hivr_bot
198
- - HiveSage_Hivr_bot
199
- - OutreachBee_Hivr_bot
200
- - quillbee
201
- - sprintbee
202
-
203
- **Authorization Test:** Fake agents correctly blocked ✓
204
-
205
- **Next:** Account attribution (gustav@nordsym.com) — see Option C above