@layer-ai/core 2.0.27 → 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":"openai-conversion.d.ts","sourceRoot":"","sources":["../../src/lib/openai-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,2BAA2B,EAK3B,4BAA4B,EAC5B,yBAAyB,EAE1B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAOd,MAAM,eAAe,CAAC;AAqFvB,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,2BAA2B,EACtC,MAAM,EAAE,MAAM,GACb,YAAY,CA2Cd;AAwCD,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,aAAa,EACxB,SAAS,CAAC,EAAE,MAAM,GACjB,4BAA4B,CA+B9B;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,aAAa,EACzB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,yBAAyB,CA2C3B"}
1
+ {"version":3,"file":"openai-conversion.d.ts","sourceRoot":"","sources":["../../src/lib/openai-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,2BAA2B,EAK3B,4BAA4B,EAC5B,yBAAyB,EAE1B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAOd,MAAM,eAAe,CAAC;AAqFvB,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,2BAA2B,EACtC,MAAM,EAAE,MAAM,GACb,YAAY,CA4Cd;AAwCD,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,aAAa,EACxB,SAAS,CAAC,EAAE,MAAM,GACjB,4BAA4B,CA+B9B;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,aAAa,EACzB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,yBAAyB,CA2C3B"}
@@ -87,7 +87,8 @@ export function convertOpenAIRequestToLayer(openaiReq, gateId) {
87
87
  const layerRequest = {
88
88
  gateId,
89
89
  type: 'chat',
90
- model: openaiReq.model,
90
+ // NOTE: We intentionally do NOT pass openaiReq.model here
91
+ // The gate's configured model takes precedence for OpenClaw integration
91
92
  data: {
92
93
  messages,
93
94
  systemPrompt,
@@ -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;AAiiBpC,eAAe,MAAM,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"}
@@ -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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layer-ai/core",
3
- "version": "2.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "Core API routes and services for Layer AI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",