@nordsym/apiclaw 1.5.1 → 1.5.2
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.
- package/convex/http.ts +25 -29
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +11 -1
- package/dist/proxy.js.map +1 -1
- package/landing/src/app/api/billing/checkout/route.ts +2 -2
- package/landing/src/app/page.tsx +1 -1
- package/landing/src/lib/stats.json +1 -1
- package/package.json +1 -1
- package/src/proxy.ts +13 -1
package/convex/http.ts
CHANGED
|
@@ -118,42 +118,38 @@ async function validateAndLogProxyCall(
|
|
|
118
118
|
provider: string,
|
|
119
119
|
action: string
|
|
120
120
|
): Promise<{ valid: boolean; workspaceId?: string; subagentId?: string; error?: string }> {
|
|
121
|
-
const
|
|
122
|
-
const subagentId = request.headers.get("X-APIClaw-Subagent") || "
|
|
123
|
-
|
|
124
|
-
if (!sessionToken) {
|
|
125
|
-
// Allow calls without session but don't log to workspace
|
|
126
|
-
return { valid: true, subagentId };
|
|
127
|
-
}
|
|
121
|
+
const identifier = request.headers.get("X-APIClaw-Identifier") || "unknown";
|
|
122
|
+
const subagentId = request.headers.get("X-APIClaw-Subagent") || "main";
|
|
128
123
|
|
|
129
124
|
try {
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (!session) {
|
|
134
|
-
// Allow call anyway but log warning
|
|
135
|
-
console.warn("[Proxy] Invalid session token, allowing call but not logging");
|
|
136
|
-
return { valid: true, subagentId };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Log the API call
|
|
140
|
-
await ctx.runMutation(api.logs.createProxyLog, {
|
|
141
|
-
workspaceId: session.workspaceId,
|
|
125
|
+
// Always log to analytics (anonymous or authenticated)
|
|
126
|
+
await ctx.runMutation(api.analytics.log, {
|
|
127
|
+
event: "api_call",
|
|
142
128
|
provider,
|
|
143
|
-
|
|
144
|
-
subagentId,
|
|
145
|
-
sessionToken,
|
|
129
|
+
identifier,
|
|
130
|
+
metadata: { action, subagentId },
|
|
146
131
|
});
|
|
147
132
|
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
133
|
+
// If authenticated (workspace ID format), increment usage
|
|
134
|
+
if (identifier.startsWith("anon:")) {
|
|
135
|
+
// Anonymous user - track for rate limiting but don't increment workspace usage
|
|
136
|
+
return { valid: true, subagentId };
|
|
137
|
+
}
|
|
152
138
|
|
|
153
|
-
|
|
139
|
+
// Try to increment workspace usage
|
|
140
|
+
try {
|
|
141
|
+
await ctx.runMutation(api.workspaces.incrementUsage, {
|
|
142
|
+
workspaceId: identifier,
|
|
143
|
+
});
|
|
144
|
+
return { valid: true, workspaceId: identifier, subagentId };
|
|
145
|
+
} catch (e) {
|
|
146
|
+
// Workspace doesn't exist or error - allow call anyway
|
|
147
|
+
console.warn("[Proxy] Could not increment workspace usage:", e);
|
|
148
|
+
return { valid: true, subagentId };
|
|
149
|
+
}
|
|
154
150
|
} catch (e: any) {
|
|
155
|
-
console.error("[Proxy]
|
|
156
|
-
//
|
|
151
|
+
console.error("[Proxy] Logging error:", e);
|
|
152
|
+
// Always allow call even if logging fails
|
|
157
153
|
return { valid: true, subagentId };
|
|
158
154
|
}
|
|
159
155
|
}
|
package/dist/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAyB3E;AAED,eAAO,MAAM,eAAe,UAAkN,CAAC"}
|
package/dist/proxy.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* APIClaw Proxy - Fallback to hosted API when no local credentials
|
|
3
3
|
*/
|
|
4
|
+
import { readSession, getMachineFingerprint } from './session.js';
|
|
4
5
|
const PROXY_BASE = "https://adventurous-avocet-799.convex.site/proxy";
|
|
5
6
|
export async function callProxy(provider, params) {
|
|
6
7
|
const url = `${PROXY_BASE}/${provider}`;
|
|
8
|
+
// Get session and fingerprint for tracking
|
|
9
|
+
const session = readSession();
|
|
10
|
+
const fingerprint = getMachineFingerprint();
|
|
11
|
+
const identifier = session?.workspaceId || `anon:${fingerprint}`;
|
|
7
12
|
const response = await fetch(url, {
|
|
8
13
|
method: "POST",
|
|
9
|
-
headers: {
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
"X-APIClaw-Identifier": identifier,
|
|
17
|
+
"X-APIClaw-Provider": provider,
|
|
18
|
+
"X-APIClaw-Action": params.action || "call",
|
|
19
|
+
},
|
|
10
20
|
body: JSON.stringify(params),
|
|
11
21
|
});
|
|
12
22
|
if (!response.ok) {
|
package/dist/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,GAAG,kDAAkD,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,MAAW;IAC3D,MAAM,GAAG,GAAG,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC;IAExC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,UAAU,GAAG,kDAAkD,CAAC;AAEtE,MA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CAAC"}
|
|
@@ -26,8 +26,8 @@ export async function POST(req: NextRequest) {
|
|
|
26
26
|
method: "POST",
|
|
27
27
|
headers: { "Content-Type": "application/json" },
|
|
28
28
|
body: JSON.stringify({
|
|
29
|
-
path: "workspaces:
|
|
30
|
-
args: { token },
|
|
29
|
+
path: "workspaces:verifySession",
|
|
30
|
+
args: { sessionToken: token },
|
|
31
31
|
}),
|
|
32
32
|
});
|
|
33
33
|
|
package/landing/src/app/page.tsx
CHANGED
|
@@ -14,7 +14,7 @@ import { PhoneDemo } from "@/components/demo";
|
|
|
14
14
|
import { AITestimonials } from "@/components/AITestimonials";
|
|
15
15
|
|
|
16
16
|
const stats = [
|
|
17
|
-
{ number:
|
|
17
|
+
{ number: "4,232+", label: "Installs", live: true },
|
|
18
18
|
{ number: statsData.apiCount.toLocaleString(), label: "APIs Indexed", live: true },
|
|
19
19
|
{ number: statsData.openApiCount.toLocaleString(), label: "Open APIs", live: true },
|
|
20
20
|
{ number: statsData.directCallCount.toString(), label: "Direct Call", live: true },
|
package/package.json
CHANGED
package/src/proxy.ts
CHANGED
|
@@ -2,14 +2,26 @@
|
|
|
2
2
|
* APIClaw Proxy - Fallback to hosted API when no local credentials
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { readSession, getMachineFingerprint } from './session.js';
|
|
6
|
+
|
|
5
7
|
const PROXY_BASE = "https://adventurous-avocet-799.convex.site/proxy";
|
|
6
8
|
|
|
7
9
|
export async function callProxy(provider: string, params: any): Promise<any> {
|
|
8
10
|
const url = `${PROXY_BASE}/${provider}`;
|
|
9
11
|
|
|
12
|
+
// Get session and fingerprint for tracking
|
|
13
|
+
const session = readSession();
|
|
14
|
+
const fingerprint = getMachineFingerprint();
|
|
15
|
+
const identifier = session?.workspaceId || `anon:${fingerprint}`;
|
|
16
|
+
|
|
10
17
|
const response = await fetch(url, {
|
|
11
18
|
method: "POST",
|
|
12
|
-
headers: {
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
"X-APIClaw-Identifier": identifier,
|
|
22
|
+
"X-APIClaw-Provider": provider,
|
|
23
|
+
"X-APIClaw-Action": params.action || "call",
|
|
24
|
+
},
|
|
13
25
|
body: JSON.stringify(params),
|
|
14
26
|
});
|
|
15
27
|
|