@layer-ai/core 2.0.28 → 2.0.29
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AASpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AASpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AA4lBpC,eAAe,MAAM,CAAC"}
|
package/dist/routes/v1/gates.js
CHANGED
|
@@ -76,6 +76,59 @@ router.get('/', async (req, res) => {
|
|
|
76
76
|
res.status(500).json({ error: 'internal_error', message: 'Failed to list gates' });
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
+
// GET /openclaw - Get gates tagged with "openclaw" with analytics
|
|
80
|
+
router.get('/openclaw', async (req, res) => {
|
|
81
|
+
if (!req.userId) {
|
|
82
|
+
res.status(401).json({ error: 'unauthorized', message: 'Missing user ID' });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const result = await db.query(`SELECT
|
|
87
|
+
g.id,
|
|
88
|
+
g.user_id,
|
|
89
|
+
g.name,
|
|
90
|
+
g.model,
|
|
91
|
+
g.task_type,
|
|
92
|
+
g.description,
|
|
93
|
+
g.created_at,
|
|
94
|
+
g.updated_at,
|
|
95
|
+
g.spending_limit,
|
|
96
|
+
g.spending_current,
|
|
97
|
+
g.spending_status,
|
|
98
|
+
COALESCE(COUNT(r.id), 0)::integer as request_count,
|
|
99
|
+
COALESCE(SUM(r.cost_usd), 0)::numeric as total_cost,
|
|
100
|
+
COALESCE(AVG(r.latency_ms), 0)::integer as avg_latency,
|
|
101
|
+
MAX(r.created_at) as last_request
|
|
102
|
+
FROM gates g
|
|
103
|
+
LEFT JOIN requests r ON g.id = r.gate_id
|
|
104
|
+
WHERE g.user_id = $1
|
|
105
|
+
AND g.tags @> '["openclaw"]'::jsonb
|
|
106
|
+
GROUP BY g.id
|
|
107
|
+
ORDER BY g.created_at DESC`, [req.userId]);
|
|
108
|
+
const gates = result.rows.map((row) => ({
|
|
109
|
+
id: row.id,
|
|
110
|
+
userId: row.user_id,
|
|
111
|
+
name: row.name,
|
|
112
|
+
model: row.model,
|
|
113
|
+
taskType: row.task_type,
|
|
114
|
+
description: row.description,
|
|
115
|
+
createdAt: row.created_at,
|
|
116
|
+
updatedAt: row.updated_at,
|
|
117
|
+
spendingLimit: row.spending_limit,
|
|
118
|
+
spendingCurrent: row.spending_current ? parseFloat(row.spending_current) : undefined,
|
|
119
|
+
spendingStatus: row.spending_status,
|
|
120
|
+
requestCount: row.request_count,
|
|
121
|
+
totalCost: parseFloat(row.total_cost),
|
|
122
|
+
avgLatency: row.avg_latency,
|
|
123
|
+
lastRequest: row.last_request,
|
|
124
|
+
}));
|
|
125
|
+
res.json(gates);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.error('List OpenClaw gates error:', error);
|
|
129
|
+
res.status(500).json({ error: 'internal_error', message: 'Failed to list OpenClaw gates' });
|
|
130
|
+
}
|
|
131
|
+
});
|
|
79
132
|
// GET /name/:name - Get a single gate by name
|
|
80
133
|
router.get('/name/:name', async (req, res) => {
|
|
81
134
|
if (!req.userId) {
|