@nordsym/apiclaw 1.5.2 → 1.5.4

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 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") || "unknown";
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
- // Always log to analytics (anonymous or authenticated)
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
- // 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
- }
138
-
139
- // Try to increment workspace usage
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
- 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 };
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
+ });
@@ -1,6 +1,6 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
 
3
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
3
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
4
4
 
5
5
  export async function POST(req: NextRequest) {
6
6
  try {
@@ -1,6 +1,6 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
 
3
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
3
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
4
4
 
5
5
  export async function POST(req: NextRequest) {
6
6
  try {
@@ -1,6 +1,6 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
 
3
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
3
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
4
4
 
5
5
  export async function POST(req: NextRequest) {
6
6
  try {
@@ -1,7 +1,7 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
  import Stripe from "stripe";
3
3
 
4
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
4
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
5
5
  const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
6
6
 
7
7
  const stripe = stripeSecretKey ? new Stripe(stripeSecretKey) : null;
@@ -1,7 +1,7 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
  import Stripe from "stripe";
3
3
 
4
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
4
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
5
5
  const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
6
6
 
7
7
  const stripe = stripeSecretKey ? new Stripe(stripeSecretKey) : null;
@@ -1,7 +1,7 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
  import Stripe from "stripe";
3
3
 
4
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
4
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
5
5
  const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
6
6
 
7
7
  const stripe = stripeSecretKey ? new Stripe(stripeSecretKey) : null;
@@ -1,7 +1,7 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
  import Stripe from "stripe";
3
3
 
4
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
4
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
5
5
 
6
6
  // Initialize Stripe
7
7
  const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
@@ -1,6 +1,6 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
 
3
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
3
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
4
4
 
5
5
  export async function POST(req: NextRequest) {
6
6
  try {
@@ -1,6 +1,6 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
 
3
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
3
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
4
4
 
5
5
  export async function GET(req: NextRequest) {
6
6
  try {
@@ -1,6 +1,6 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
 
3
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
3
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
4
4
 
5
5
  export async function POST(req: NextRequest) {
6
6
  try {
@@ -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 === "pro" || workspace?.tier === "usage_based"
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
 
@@ -1,6 +1,6 @@
1
1
  // Simple Convex HTTP client for the dashboard
2
2
 
3
- const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://brilliant-puffin-712.eu-west-1.convex.cloud";
3
+ const CONVEX_URL = process.env.NEXT_PUBLIC_CONVEX_URL || "https://adventurous-avocet-799.convex.cloud";
4
4
 
5
5
  export async function convexQuery<T>(path: string, args: Record<string, unknown>): Promise<T> {
6
6
  const response = await fetch(`${CONVEX_URL}/api/query`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordsym/apiclaw",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "The API layer for AI agents. Dashboard + 22K APIs + 18 Direct Call providers. MCP native.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",