@nordsym/apiclaw 1.5.2 → 1.5.3
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 +68 -24
- package/dist/proxy.js +1 -1
- package/dist/proxy.js.map +1 -1
- package/landing/src/app/workspace/page.tsx +6 -4
- package/package.json +1 -1
- package/src/proxy.ts +1 -1
package/convex/http.ts
CHANGED
|
@@ -118,40 +118,53 @@ async function validateAndLogProxyCall(
|
|
|
118
118
|
provider: string,
|
|
119
119
|
action: string
|
|
120
120
|
): Promise<{ valid: boolean; workspaceId?: string; subagentId?: string; error?: string }> {
|
|
121
|
-
const identifier = request.headers.get("X-APIClaw-Identifier")
|
|
121
|
+
const identifier = request.headers.get("X-APIClaw-Identifier");
|
|
122
122
|
const subagentId = request.headers.get("X-APIClaw-Subagent") || "main";
|
|
123
123
|
|
|
124
|
+
console.log("[Proxy] Call received", { provider, action, identifier, subagentId });
|
|
125
|
+
|
|
126
|
+
// ALWAYS log to analytics (even if identifier is missing)
|
|
124
127
|
try {
|
|
125
|
-
|
|
126
|
-
await ctx.runMutation(api.analytics.log, {
|
|
128
|
+
const result = await ctx.runMutation(api.analytics.log, {
|
|
127
129
|
event: "api_call",
|
|
128
130
|
provider,
|
|
129
|
-
identifier,
|
|
131
|
+
identifier: identifier || "unknown",
|
|
130
132
|
metadata: { action, subagentId },
|
|
131
133
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
console.log("[Proxy] Analytics logged:", result);
|
|
135
|
+
} catch (e: any) {
|
|
136
|
+
console.error("[Proxy] Analytics logging failed:", e.message, e.stack);
|
|
137
|
+
// Continue even if analytics fails
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// If we have an identifier and it's a workspace ID (not anon:), log to workspace
|
|
141
|
+
if (identifier && !identifier.startsWith("anon:") && identifier !== "unknown") {
|
|
140
142
|
try {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
// Validate it's actually a workspace ID by checking format
|
|
144
|
+
if (identifier.length > 20) {
|
|
145
|
+
await ctx.runMutation(api.logs.createProxyLog, {
|
|
146
|
+
workspaceId: identifier as any,
|
|
147
|
+
provider,
|
|
148
|
+
action,
|
|
149
|
+
subagentId,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Increment workspace usage
|
|
153
|
+
await ctx.runMutation(api.workspaces.incrementUsage, {
|
|
154
|
+
workspaceId: identifier as any,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
console.log("[Proxy] Workspace logged for:", identifier);
|
|
158
|
+
return { valid: true, workspaceId: identifier, subagentId };
|
|
159
|
+
}
|
|
160
|
+
} catch (e: any) {
|
|
161
|
+
console.error("[Proxy] Workspace logging failed:", e.message);
|
|
162
|
+
// Continue even if workspace logging fails
|
|
149
163
|
}
|
|
150
|
-
} catch (e: any) {
|
|
151
|
-
console.error("[Proxy] Logging error:", e);
|
|
152
|
-
// Always allow call even if logging fails
|
|
153
|
-
return { valid: true, subagentId };
|
|
154
164
|
}
|
|
165
|
+
|
|
166
|
+
// Return success regardless (don't block API calls)
|
|
167
|
+
return { valid: true, subagentId };
|
|
155
168
|
}
|
|
156
169
|
|
|
157
170
|
// OPTIONS handler for CORS
|
|
@@ -1007,3 +1020,34 @@ http.route({
|
|
|
1007
1020
|
method: "OPTIONS",
|
|
1008
1021
|
handler: webhookOptions,
|
|
1009
1022
|
});
|
|
1023
|
+
|
|
1024
|
+
// Test endpoint to debug logging
|
|
1025
|
+
http.route({
|
|
1026
|
+
path: "/proxy/test-logging",
|
|
1027
|
+
method: "POST",
|
|
1028
|
+
handler: httpAction(async (ctx, request) => {
|
|
1029
|
+
const identifier = request.headers.get("X-APIClaw-Identifier");
|
|
1030
|
+
|
|
1031
|
+
try {
|
|
1032
|
+
const logId = await ctx.runMutation(api.analytics.log, {
|
|
1033
|
+
event: "test_endpoint",
|
|
1034
|
+
provider: "test",
|
|
1035
|
+
identifier: identifier || "test",
|
|
1036
|
+
metadata: { test: true },
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
return jsonResponse({
|
|
1040
|
+
success: true,
|
|
1041
|
+
identifier,
|
|
1042
|
+
logId,
|
|
1043
|
+
message: "Logged successfully"
|
|
1044
|
+
});
|
|
1045
|
+
} catch (e: any) {
|
|
1046
|
+
return jsonResponse({
|
|
1047
|
+
success: false,
|
|
1048
|
+
error: e.message,
|
|
1049
|
+
stack: e.stack
|
|
1050
|
+
}, 500);
|
|
1051
|
+
}
|
|
1052
|
+
}),
|
|
1053
|
+
});
|
package/dist/proxy.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* APIClaw Proxy - Fallback to hosted API when no local credentials
|
|
3
3
|
*/
|
|
4
4
|
import { readSession, getMachineFingerprint } from './session.js';
|
|
5
|
-
const PROXY_BASE = "https://
|
|
5
|
+
const PROXY_BASE = "https://brilliant-puffin-712.eu-west-1.convex.site/proxy";
|
|
6
6
|
export async function callProxy(provider, params) {
|
|
7
7
|
const url = `${PROXY_BASE}/${provider}`;
|
|
8
8
|
// Get session and fingerprint for tracking
|
package/dist/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,0DAA0D,CAAC;AAE9E,MA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CAAC"}
|
|
@@ -5868,7 +5868,7 @@ function SettingsTab({ workspace, sessionToken }: { workspace: Workspace | null;
|
|
|
5868
5868
|
<p className="text-sm text-[var(--text-muted)]">Current subscription plan</p>
|
|
5869
5869
|
</div>
|
|
5870
5870
|
<span className="px-3 py-1 rounded-full bg-[#ef4444]/20 text-[#ef4444] text-sm font-medium capitalize">
|
|
5871
|
-
{workspace?.tier || "Free"}
|
|
5871
|
+
{workspace?.tier === "backer" ? "Founding Backer" : workspace?.tier === "pro" ? "Pro" : workspace?.tier === "usage_based" ? "Pay as you go" : workspace?.tier || "Free"}
|
|
5872
5872
|
</span>
|
|
5873
5873
|
</div>
|
|
5874
5874
|
</div>
|
|
@@ -5889,15 +5889,17 @@ function SettingsTab({ workspace, sessionToken }: { workspace: Workspace | null;
|
|
|
5889
5889
|
<div>
|
|
5890
5890
|
<p className="font-medium">Current Plan</p>
|
|
5891
5891
|
<p className="text-sm text-[var(--text-muted)]">
|
|
5892
|
-
{workspace?.tier === "pro" || workspace?.tier === "usage_based" ? "Usage-Based" : "Free Tier"}
|
|
5892
|
+
{workspace?.tier === "backer" ? "Unlimited until 2027" : workspace?.tier === "pro" || workspace?.tier === "usage_based" ? "Usage-Based" : "Free Tier"}
|
|
5893
5893
|
</p>
|
|
5894
5894
|
</div>
|
|
5895
5895
|
<span className={`px-3 py-1 rounded-full text-sm font-medium ${
|
|
5896
|
-
workspace?.tier === "
|
|
5896
|
+
workspace?.tier === "backer"
|
|
5897
|
+
? "bg-[#ef4444]/20 text-[#ef4444]"
|
|
5898
|
+
: workspace?.tier === "pro" || workspace?.tier === "usage_based"
|
|
5897
5899
|
? "bg-green-500/20 text-green-500"
|
|
5898
5900
|
: "bg-[var(--surface-elevated)] text-[var(--text-muted)]"
|
|
5899
5901
|
}`}>
|
|
5900
|
-
{workspace?.tier === "pro" || workspace?.tier === "usage_based" ? "Active" : "Free"}
|
|
5902
|
+
{workspace?.tier === "backer" ? "Active" : workspace?.tier === "pro" || workspace?.tier === "usage_based" ? "Active" : "Free"}
|
|
5901
5903
|
</span>
|
|
5902
5904
|
</div>
|
|
5903
5905
|
|
package/package.json
CHANGED
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://
|
|
7
|
+
const PROXY_BASE = "https://brilliant-puffin-712.eu-west-1.convex.site/proxy";
|
|
8
8
|
|
|
9
9
|
export async function callProxy(provider: string, params: any): Promise<any> {
|
|
10
10
|
const url = `${PROXY_BASE}/${provider}`;
|