@nordsym/apiclaw 1.5.13 → 1.5.14
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/dist/bin.js +1 -1
- package/dist/cli/index.js +7 -0
- package/dist/convex/adminActivate.js +46 -0
- package/dist/convex/adminStats.js +41 -0
- package/dist/convex/agents.js +498 -0
- package/dist/convex/analytics.js +165 -0
- package/dist/convex/billing.js +654 -0
- package/dist/convex/capabilities.js +144 -0
- package/dist/convex/chains.js +1041 -0
- package/dist/convex/credits.js +185 -0
- package/dist/convex/crons.js +16 -0
- package/dist/convex/directCall.js +626 -0
- package/dist/convex/earnProgress.js +648 -0
- package/dist/convex/email.js +299 -0
- package/dist/convex/feedback.js +226 -0
- package/dist/convex/http.js +909 -0
- package/dist/convex/logs.js +486 -0
- package/dist/convex/mou.js +81 -0
- package/dist/convex/providerKeys.js +256 -0
- package/dist/convex/providers.js +755 -0
- package/dist/convex/purchases.js +156 -0
- package/dist/convex/ratelimit.js +90 -0
- package/dist/convex/schema.js +709 -0
- package/dist/convex/searchLogs.js +128 -0
- package/dist/convex/spendAlerts.js +379 -0
- package/dist/convex/stripeActions.js +410 -0
- package/dist/convex/teams.js +214 -0
- package/dist/convex/telemetry.js +73 -0
- package/dist/convex/usage.js +228 -0
- package/dist/convex/waitlist.js +48 -0
- package/dist/convex/webhooks.js +409 -0
- package/dist/convex/workspaces.js +879 -0
- package/dist/src/analytics.js +129 -0
- package/dist/src/bin.js +17 -0
- package/dist/src/capability-router.js +240 -0
- package/dist/src/chainExecutor.js +451 -0
- package/dist/src/chainResolver.js +518 -0
- package/dist/src/cli/commands/doctor.js +324 -0
- package/dist/src/cli/commands/mcp-install.js +255 -0
- package/dist/src/cli/commands/restore.js +259 -0
- package/dist/src/cli/commands/setup.js +205 -0
- package/dist/src/cli/commands/uninstall.js +188 -0
- package/dist/src/cli/index.js +111 -0
- package/dist/src/cli.js +302 -0
- package/dist/src/confirmation.js +240 -0
- package/dist/src/credentials.js +357 -0
- package/dist/src/credits.js +260 -0
- package/dist/src/crypto.js +66 -0
- package/dist/src/discovery.js +504 -0
- package/dist/src/enterprise/env.js +123 -0
- package/dist/src/enterprise/script-generator.js +460 -0
- package/dist/src/execute-dynamic.js +473 -0
- package/dist/src/execute.js +1727 -0
- package/dist/src/index.js +2062 -0
- package/dist/src/metered.js +80 -0
- package/dist/src/open-apis.js +276 -0
- package/dist/src/proxy.js +28 -0
- package/dist/src/session.js +86 -0
- package/dist/src/stripe.js +407 -0
- package/dist/src/telemetry.js +49 -0
- package/dist/src/types.js +2 -0
- package/dist/src/utils/backup.js +181 -0
- package/dist/src/utils/config.js +220 -0
- package/dist/src/utils/os.js +105 -0
- package/dist/src/utils/paths.js +159 -0
- package/package.json +1 -1
- package/src/bin.ts +1 -1
- package/src/cli/index.ts +8 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { query, mutation } from "./_generated/server";
|
|
3
|
+
// Get a capability by ID
|
|
4
|
+
export const getById = query({
|
|
5
|
+
args: { id: v.string() },
|
|
6
|
+
handler: async (ctx, args) => {
|
|
7
|
+
return await ctx.db
|
|
8
|
+
.query("capabilities")
|
|
9
|
+
.withIndex("by_capability_id", (q) => q.eq("id", args.id))
|
|
10
|
+
.first();
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
// List all capabilities
|
|
14
|
+
export const list = query({
|
|
15
|
+
args: {},
|
|
16
|
+
handler: async (ctx) => {
|
|
17
|
+
return await ctx.db.query("capabilities").collect();
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
// List capabilities by category
|
|
21
|
+
export const listByCategory = query({
|
|
22
|
+
args: { category: v.string() },
|
|
23
|
+
handler: async (ctx, args) => {
|
|
24
|
+
return await ctx.db
|
|
25
|
+
.query("capabilities")
|
|
26
|
+
.withIndex("by_category", (q) => q.eq("category", args.category))
|
|
27
|
+
.collect();
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
// Get providers for a capability (sorted by priority, filtered by enabled + healthy)
|
|
31
|
+
export const getProviders = query({
|
|
32
|
+
args: { capabilityId: v.string(), region: v.optional(v.string()) },
|
|
33
|
+
handler: async (ctx, args) => {
|
|
34
|
+
let providers = await ctx.db
|
|
35
|
+
.query("providerCapabilities")
|
|
36
|
+
.withIndex("by_capabilityId_enabled", (q) => q.eq("capabilityId", args.capabilityId).eq("enabled", true))
|
|
37
|
+
.collect();
|
|
38
|
+
// Filter by region if specified
|
|
39
|
+
if (args.region) {
|
|
40
|
+
providers = providers.filter(p => p.regions.includes(args.region));
|
|
41
|
+
}
|
|
42
|
+
// Filter out unhealthy providers
|
|
43
|
+
providers = providers.filter(p => p.healthStatus !== "down");
|
|
44
|
+
// Sort by priority, then price, then latency
|
|
45
|
+
providers.sort((a, b) => {
|
|
46
|
+
if (a.priority !== b.priority)
|
|
47
|
+
return a.priority - b.priority;
|
|
48
|
+
if (a.pricePerUnit !== b.pricePerUnit)
|
|
49
|
+
return a.pricePerUnit - b.pricePerUnit;
|
|
50
|
+
return a.avgLatencyMs - b.avgLatencyMs;
|
|
51
|
+
});
|
|
52
|
+
return providers;
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
// Create a capability
|
|
56
|
+
export const create = mutation({
|
|
57
|
+
args: {
|
|
58
|
+
id: v.string(),
|
|
59
|
+
name: v.string(),
|
|
60
|
+
description: v.string(),
|
|
61
|
+
category: v.string(),
|
|
62
|
+
standardParams: v.array(v.object({
|
|
63
|
+
name: v.string(),
|
|
64
|
+
type: v.string(),
|
|
65
|
+
required: v.boolean(),
|
|
66
|
+
description: v.string(),
|
|
67
|
+
default: v.optional(v.any()),
|
|
68
|
+
})),
|
|
69
|
+
},
|
|
70
|
+
handler: async (ctx, args) => {
|
|
71
|
+
const now = Date.now();
|
|
72
|
+
return await ctx.db.insert("capabilities", {
|
|
73
|
+
...args,
|
|
74
|
+
createdAt: now,
|
|
75
|
+
updatedAt: now,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
// Add provider to capability
|
|
80
|
+
export const addProvider = mutation({
|
|
81
|
+
args: {
|
|
82
|
+
providerId: v.string(),
|
|
83
|
+
capabilityId: v.string(),
|
|
84
|
+
priority: v.number(),
|
|
85
|
+
regions: v.array(v.string()),
|
|
86
|
+
pricePerUnit: v.number(),
|
|
87
|
+
currency: v.string(),
|
|
88
|
+
avgLatencyMs: v.number(),
|
|
89
|
+
paramMapping: v.any(),
|
|
90
|
+
},
|
|
91
|
+
handler: async (ctx, args) => {
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
return await ctx.db.insert("providerCapabilities", {
|
|
94
|
+
...args,
|
|
95
|
+
enabled: true,
|
|
96
|
+
healthStatus: "healthy",
|
|
97
|
+
createdAt: now,
|
|
98
|
+
updatedAt: now,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
// Update provider health status
|
|
103
|
+
export const updateHealth = mutation({
|
|
104
|
+
args: {
|
|
105
|
+
providerId: v.string(),
|
|
106
|
+
capabilityId: v.string(),
|
|
107
|
+
healthStatus: v.string(),
|
|
108
|
+
},
|
|
109
|
+
handler: async (ctx, args) => {
|
|
110
|
+
const mapping = await ctx.db
|
|
111
|
+
.query("providerCapabilities")
|
|
112
|
+
.withIndex("by_providerId", (q) => q.eq("providerId", args.providerId))
|
|
113
|
+
.filter((q) => q.eq(q.field("capabilityId"), args.capabilityId))
|
|
114
|
+
.first();
|
|
115
|
+
if (mapping) {
|
|
116
|
+
await ctx.db.patch(mapping._id, {
|
|
117
|
+
healthStatus: args.healthStatus,
|
|
118
|
+
lastHealthCheck: Date.now(),
|
|
119
|
+
updatedAt: Date.now(),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
// Log capability usage
|
|
125
|
+
export const logUsage = mutation({
|
|
126
|
+
args: {
|
|
127
|
+
capabilityId: v.string(),
|
|
128
|
+
providerId: v.string(),
|
|
129
|
+
userId: v.string(),
|
|
130
|
+
action: v.string(),
|
|
131
|
+
success: v.boolean(),
|
|
132
|
+
fallbackUsed: v.boolean(),
|
|
133
|
+
fallbackReason: v.optional(v.string()),
|
|
134
|
+
latencyMs: v.number(),
|
|
135
|
+
cost: v.number(),
|
|
136
|
+
currency: v.string(),
|
|
137
|
+
},
|
|
138
|
+
handler: async (ctx, args) => {
|
|
139
|
+
return await ctx.db.insert("capabilityLogs", {
|
|
140
|
+
...args,
|
|
141
|
+
timestamp: Date.now(),
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
});
|