@dexto/server 1.6.20 → 1.6.22
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/a2a/jsonrpc/methods.cjs +1 -1
- package/dist/a2a/jsonrpc/methods.d.ts +14 -4
- package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
- package/dist/a2a/jsonrpc/methods.js +1 -1
- package/dist/approval/wire-approval-events.cjs +44 -0
- package/dist/approval/wire-approval-events.d.ts +4 -0
- package/dist/approval/wire-approval-events.d.ts.map +1 -0
- package/dist/approval/wire-approval-events.js +20 -0
- package/dist/events/session-sse-subscriber.cjs +167 -0
- package/dist/events/session-sse-subscriber.d.ts +13 -0
- package/dist/events/session-sse-subscriber.d.ts.map +1 -0
- package/dist/events/session-sse-subscriber.js +143 -0
- package/dist/hono/__tests__/test-fixtures.cjs +8 -0
- package/dist/hono/__tests__/test-fixtures.d.ts +1 -0
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +8 -0
- package/dist/hono/index.cjs +40 -8
- package/dist/hono/index.d.ts +45 -4531
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +43 -9
- package/dist/hono/node/index.cjs +51 -6
- package/dist/hono/node/index.d.ts.map +1 -1
- package/dist/hono/node/index.js +51 -6
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +158 -32
- package/dist/hono/routes/a2a-tasks.d.ts +1 -502
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +162 -32
- package/dist/hono/routes/a2a.d.ts.map +1 -1
- package/dist/hono/routes/agents.cjs +410 -329
- package/dist/hono/routes/agents.d.ts +16043 -68
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +418 -330
- package/dist/hono/routes/approvals.cjs +102 -88
- package/dist/hono/routes/approvals.d.ts +2089 -142
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +108 -89
- package/dist/hono/routes/dexto-auth.cjs +40 -33
- package/dist/hono/routes/dexto-auth.d.ts +401 -2
- package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
- package/dist/hono/routes/dexto-auth.js +40 -33
- package/dist/hono/routes/discovery.cjs +16 -14
- package/dist/hono/routes/discovery.d.ts +586 -1
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +16 -14
- package/dist/hono/routes/greeting.cjs +26 -22
- package/dist/hono/routes/greeting.d.ts +787 -3
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +26 -22
- package/dist/hono/routes/health.d.ts +1 -1
- package/dist/hono/routes/key.cjs +60 -52
- package/dist/hono/routes/key.d.ts +1597 -1
- package/dist/hono/routes/key.d.ts.map +1 -1
- package/dist/hono/routes/key.js +60 -52
- package/dist/hono/routes/llm.cjs +382 -349
- package/dist/hono/routes/llm.d.ts +12148 -98
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +386 -349
- package/dist/hono/routes/mcp.cjs +257 -226
- package/dist/hono/routes/mcp.d.ts +6605 -309
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +263 -225
- package/dist/hono/routes/memory.cjs +102 -89
- package/dist/hono/routes/memory.d.ts +5368 -4
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +108 -90
- package/dist/hono/routes/messages.cjs +189 -191
- package/dist/hono/routes/messages.d.ts +3900 -12
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +192 -191
- package/dist/hono/routes/models.cjs +106 -64
- package/dist/hono/routes/models.d.ts +2875 -2
- package/dist/hono/routes/models.d.ts.map +1 -1
- package/dist/hono/routes/models.js +108 -64
- package/dist/hono/routes/openrouter.cjs +79 -65
- package/dist/hono/routes/openrouter.d.ts +854 -1
- package/dist/hono/routes/openrouter.d.ts.map +1 -1
- package/dist/hono/routes/openrouter.js +79 -65
- package/dist/hono/routes/prompts.cjs +136 -109
- package/dist/hono/routes/prompts.d.ts +2818 -10
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +138 -109
- package/dist/hono/routes/queue.cjs +133 -120
- package/dist/hono/routes/queue.d.ts +5240 -11
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +136 -120
- package/dist/hono/routes/resources.cjs +65 -46
- package/dist/hono/routes/resources.d.ts +1983 -5
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +72 -47
- package/dist/hono/routes/schedules.cjs +233 -226
- package/dist/hono/routes/schedules.d.ts +4198 -22
- package/dist/hono/routes/schedules.d.ts.map +1 -1
- package/dist/hono/routes/schedules.js +233 -226
- package/dist/hono/routes/search.cjs +34 -30
- package/dist/hono/routes/search.d.ts +3094 -17
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +40 -31
- package/dist/hono/routes/sessions.cjs +491 -393
- package/dist/hono/routes/sessions.d.ts +18263 -65
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +497 -395
- package/dist/hono/routes/static.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.cjs +57 -61
- package/dist/hono/routes/system-prompt.d.ts +1228 -2
- package/dist/hono/routes/system-prompt.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.js +58 -62
- package/dist/hono/routes/tools.cjs +29 -34
- package/dist/hono/routes/tools.d.ts +1755 -6
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +33 -33
- package/dist/hono/routes/webhooks.cjs +115 -123
- package/dist/hono/routes/webhooks.d.ts +2501 -11
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +120 -124
- package/dist/hono/routes/workspaces.cjs +84 -79
- package/dist/hono/routes/workspaces.d.ts +2093 -2
- package/dist/hono/routes/workspaces.d.ts.map +1 -1
- package/dist/hono/routes/workspaces.js +89 -80
- package/dist/hono/schemas/responses.cjs +463 -260
- package/dist/hono/schemas/responses.d.ts +1893 -209
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +203 -14
- package/dist/hono/start-server.cjs +9 -0
- package/dist/hono/start-server.d.ts.map +1 -1
- package/dist/hono/start-server.js +9 -0
- package/dist/hono/types.d.ts +11 -0
- package/dist/hono/types.d.ts.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAiBhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA6BtD,QAAA,MAAM,yBAAyB;;;;;;EAIS,CAAC;AAczC,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAO,sBAAsB,EAC7B;IAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;CAAE,CACtD,CAAC;AACF,KAAK,2BAA2B,GAAG,kBAAkB,CACjD,OAAO,qBAAqB,EAC5B;IAAE,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;CAAE,CAClF,CAAC;AAEF,MAAM,MAAM,kBAAkB,GACxB,0BAA0B,GAC1B,2BAA2B,GAC3B,4BAA4B,GAC5B,2BAA2B,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
2
|
import { promises as fs } from "fs";
|
|
3
3
|
import {
|
|
4
|
+
DextoRuntimeError,
|
|
5
|
+
ErrorType,
|
|
4
6
|
getLocalModelById,
|
|
5
7
|
listOllamaModels,
|
|
6
8
|
DEFAULT_OLLAMA_URL,
|
|
@@ -12,6 +14,7 @@ import {
|
|
|
12
14
|
getInstalledModel,
|
|
13
15
|
removeInstalledModel
|
|
14
16
|
} from "@dexto/agent-management";
|
|
17
|
+
import { BadRequestErrorResponse, InternalErrorResponse } from "../schemas/responses.js";
|
|
15
18
|
const LocalModelSchema = z.object({
|
|
16
19
|
id: z.string().describe("Model identifier"),
|
|
17
20
|
displayName: z.string().describe("Human-readable model name"),
|
|
@@ -50,7 +53,8 @@ const listLocalModelsRoute = createRoute({
|
|
|
50
53
|
})
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
|
-
}
|
|
56
|
+
},
|
|
57
|
+
500: InternalErrorResponse
|
|
54
58
|
}
|
|
55
59
|
});
|
|
56
60
|
const listOllamaModelsRoute = createRoute({
|
|
@@ -77,7 +81,9 @@ const listOllamaModelsRoute = createRoute({
|
|
|
77
81
|
})
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
|
-
}
|
|
84
|
+
},
|
|
85
|
+
400: BadRequestErrorResponse,
|
|
86
|
+
500: InternalErrorResponse
|
|
81
87
|
}
|
|
82
88
|
});
|
|
83
89
|
const validateLocalFileRoute = createRoute({
|
|
@@ -103,7 +109,9 @@ const validateLocalFileRoute = createRoute({
|
|
|
103
109
|
schema: ValidateFileResponseSchema
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
|
-
}
|
|
112
|
+
},
|
|
113
|
+
400: BadRequestErrorResponse,
|
|
114
|
+
500: InternalErrorResponse
|
|
107
115
|
}
|
|
108
116
|
});
|
|
109
117
|
const DeleteModelRequestSchema = z.object({
|
|
@@ -150,7 +158,9 @@ const deleteLocalModelRoute = createRoute({
|
|
|
150
158
|
schema: DeleteModelResponseSchema
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
|
-
}
|
|
161
|
+
},
|
|
162
|
+
400: BadRequestErrorResponse,
|
|
163
|
+
500: InternalErrorResponse
|
|
154
164
|
}
|
|
155
165
|
});
|
|
156
166
|
function createModelsRouter() {
|
|
@@ -168,82 +178,112 @@ function createModelsRouter() {
|
|
|
168
178
|
source: model.source
|
|
169
179
|
};
|
|
170
180
|
});
|
|
171
|
-
return ctx.json({ models });
|
|
181
|
+
return ctx.json({ models }, 200);
|
|
172
182
|
}).openapi(listOllamaModelsRoute, async (ctx) => {
|
|
173
183
|
const { baseURL } = ctx.req.valid("query");
|
|
174
184
|
const ollamaURL = baseURL || DEFAULT_OLLAMA_URL;
|
|
175
185
|
try {
|
|
176
186
|
const status = await checkOllamaStatus(ollamaURL);
|
|
177
187
|
if (!status.running) {
|
|
178
|
-
return ctx.json(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
188
|
+
return ctx.json(
|
|
189
|
+
{
|
|
190
|
+
available: false,
|
|
191
|
+
models: [],
|
|
192
|
+
error: "Ollama server is not running"
|
|
193
|
+
},
|
|
194
|
+
200
|
|
195
|
+
);
|
|
183
196
|
}
|
|
184
197
|
const ollamaModels = await listOllamaModels(ollamaURL);
|
|
185
|
-
return ctx.json(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
return ctx.json(
|
|
199
|
+
{
|
|
200
|
+
available: true,
|
|
201
|
+
version: status.version,
|
|
202
|
+
models: ollamaModels.map((m) => ({
|
|
203
|
+
name: m.name,
|
|
204
|
+
size: m.size,
|
|
205
|
+
digest: m.digest,
|
|
206
|
+
modifiedAt: m.modifiedAt
|
|
207
|
+
}))
|
|
208
|
+
},
|
|
209
|
+
200
|
|
210
|
+
);
|
|
195
211
|
} catch (error) {
|
|
196
|
-
return ctx.json(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
212
|
+
return ctx.json(
|
|
213
|
+
{
|
|
214
|
+
available: false,
|
|
215
|
+
models: [],
|
|
216
|
+
error: error instanceof Error ? error.message : "Failed to connect to Ollama server"
|
|
217
|
+
},
|
|
218
|
+
200
|
|
219
|
+
);
|
|
201
220
|
}
|
|
202
221
|
}).openapi(validateLocalFileRoute, async (ctx) => {
|
|
203
222
|
const { filePath } = ctx.req.valid("json");
|
|
204
223
|
if (!filePath.startsWith("/")) {
|
|
205
|
-
return ctx.json(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
224
|
+
return ctx.json(
|
|
225
|
+
{
|
|
226
|
+
valid: false,
|
|
227
|
+
error: "File path must be absolute (start with /)"
|
|
228
|
+
},
|
|
229
|
+
200
|
|
230
|
+
);
|
|
209
231
|
}
|
|
210
232
|
if (!filePath.endsWith(".gguf")) {
|
|
211
|
-
return ctx.json(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
233
|
+
return ctx.json(
|
|
234
|
+
{
|
|
235
|
+
valid: false,
|
|
236
|
+
error: "File must have .gguf extension"
|
|
237
|
+
},
|
|
238
|
+
200
|
|
239
|
+
);
|
|
215
240
|
}
|
|
216
241
|
try {
|
|
217
242
|
const stats = await fs.stat(filePath);
|
|
218
243
|
if (!stats.isFile()) {
|
|
219
|
-
return ctx.json(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
244
|
+
return ctx.json(
|
|
245
|
+
{
|
|
246
|
+
valid: false,
|
|
247
|
+
error: "Path is not a file"
|
|
248
|
+
},
|
|
249
|
+
200
|
|
250
|
+
);
|
|
223
251
|
}
|
|
224
252
|
await fs.access(filePath, fs.constants.R_OK);
|
|
225
|
-
return ctx.json(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
253
|
+
return ctx.json(
|
|
254
|
+
{
|
|
255
|
+
valid: true,
|
|
256
|
+
sizeBytes: stats.size
|
|
257
|
+
},
|
|
258
|
+
200
|
|
259
|
+
);
|
|
229
260
|
} catch (error) {
|
|
230
261
|
const nodeError = error;
|
|
231
262
|
if (nodeError.code === "ENOENT") {
|
|
232
|
-
return ctx.json(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
263
|
+
return ctx.json(
|
|
264
|
+
{
|
|
265
|
+
valid: false,
|
|
266
|
+
error: "File not found"
|
|
267
|
+
},
|
|
268
|
+
200
|
|
269
|
+
);
|
|
236
270
|
}
|
|
237
271
|
if (nodeError.code === "EACCES") {
|
|
238
|
-
return ctx.json(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
272
|
+
return ctx.json(
|
|
273
|
+
{
|
|
274
|
+
valid: false,
|
|
275
|
+
error: "File is not readable (permission denied)"
|
|
276
|
+
},
|
|
277
|
+
200
|
|
278
|
+
);
|
|
242
279
|
}
|
|
243
|
-
return ctx.json(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
280
|
+
return ctx.json(
|
|
281
|
+
{
|
|
282
|
+
valid: false,
|
|
283
|
+
error: error instanceof Error ? error.message : "Failed to access file"
|
|
284
|
+
},
|
|
285
|
+
200
|
|
286
|
+
);
|
|
247
287
|
}
|
|
248
288
|
}).openapi(deleteLocalModelRoute, async (ctx) => {
|
|
249
289
|
const { modelId } = ctx.req.valid("param");
|
|
@@ -286,18 +326,22 @@ function createModelsRouter() {
|
|
|
286
326
|
}
|
|
287
327
|
const removed = await removeInstalledModel(modelId);
|
|
288
328
|
if (!removed) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
329
|
+
throw new DextoRuntimeError(
|
|
330
|
+
"model_state_remove_failed",
|
|
331
|
+
"model",
|
|
332
|
+
ErrorType.SYSTEM,
|
|
333
|
+
"Failed to remove model from state",
|
|
334
|
+
{ modelId, fileDeleted }
|
|
335
|
+
);
|
|
295
336
|
}
|
|
296
|
-
return ctx.json(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
337
|
+
return ctx.json(
|
|
338
|
+
{
|
|
339
|
+
success: true,
|
|
340
|
+
modelId,
|
|
341
|
+
fileDeleted
|
|
342
|
+
},
|
|
343
|
+
200
|
|
344
|
+
);
|
|
301
345
|
});
|
|
302
346
|
}
|
|
303
347
|
export {
|
|
@@ -23,6 +23,7 @@ __export(openrouter_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(openrouter_exports);
|
|
24
24
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
25
25
|
var import_core = require("@dexto/core");
|
|
26
|
+
var import_responses = require("../schemas/responses.js");
|
|
26
27
|
const ValidateModelParamsSchema = import_zod_openapi.z.object({
|
|
27
28
|
modelId: import_zod_openapi.z.string().min(1).describe("OpenRouter model ID to validate (e.g., anthropic/claude-3.5-sonnet)")
|
|
28
29
|
}).describe("Path parameters for model validation");
|
|
@@ -35,59 +36,63 @@ const ValidateModelResponseSchema = import_zod_openapi.z.object({
|
|
|
35
36
|
contextLength: import_zod_openapi.z.number().describe("Model context length in tokens")
|
|
36
37
|
}).optional().describe("Model information if valid")
|
|
37
38
|
}).describe("Model validation response");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
const RefreshSuccessResponseSchema = import_zod_openapi.z.object({
|
|
40
|
+
ok: import_zod_openapi.z.literal(true).describe("Success indicator"),
|
|
41
|
+
message: import_zod_openapi.z.string().describe("Status message")
|
|
42
|
+
}).describe("OpenRouter cache refresh success response");
|
|
43
|
+
const RefreshFailureResponseSchema = import_zod_openapi.z.object({
|
|
44
|
+
ok: import_zod_openapi.z.literal(false).describe("Failure indicator"),
|
|
45
|
+
message: import_zod_openapi.z.string().describe("Error message")
|
|
46
|
+
}).describe("OpenRouter cache refresh failure response");
|
|
47
|
+
const validateRoute = (0, import_zod_openapi.createRoute)({
|
|
48
|
+
method: "get",
|
|
49
|
+
path: "/openrouter/validate/{modelId}",
|
|
50
|
+
summary: "Validate OpenRouter Model",
|
|
51
|
+
description: "Validates an OpenRouter model ID against the cached model registry. Refreshes cache if stale.",
|
|
52
|
+
tags: ["openrouter"],
|
|
53
|
+
request: {
|
|
54
|
+
params: ValidateModelParamsSchema
|
|
55
|
+
},
|
|
56
|
+
responses: {
|
|
57
|
+
200: {
|
|
58
|
+
description: "Validation result",
|
|
59
|
+
content: {
|
|
60
|
+
"application/json": {
|
|
61
|
+
schema: ValidateModelResponseSchema
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
64
|
+
},
|
|
65
|
+
400: import_responses.BadRequestErrorResponse,
|
|
66
|
+
500: import_responses.InternalErrorResponse
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const refreshRoute = (0, import_zod_openapi.createRoute)({
|
|
70
|
+
method: "post",
|
|
71
|
+
path: "/openrouter/refresh-cache",
|
|
72
|
+
summary: "Refresh OpenRouter Model Cache",
|
|
73
|
+
description: "Forces a refresh of the OpenRouter model registry cache from the API.",
|
|
74
|
+
tags: ["openrouter"],
|
|
75
|
+
responses: {
|
|
76
|
+
200: {
|
|
77
|
+
description: "Cache refreshed successfully",
|
|
78
|
+
content: {
|
|
79
|
+
"application/json": {
|
|
80
|
+
schema: RefreshSuccessResponseSchema
|
|
76
81
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
message: import_zod_openapi.z.string().describe("Error message")
|
|
85
|
-
})
|
|
86
|
-
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
500: {
|
|
85
|
+
description: "Cache refresh failed",
|
|
86
|
+
content: {
|
|
87
|
+
"application/json": {
|
|
88
|
+
schema: RefreshFailureResponseSchema
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
|
-
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
function createOpenRouterRouter() {
|
|
95
|
+
const app = new import_zod_openapi.OpenAPIHono();
|
|
91
96
|
return app.openapi(validateRoute, async (ctx) => {
|
|
92
97
|
const { modelId: encodedModelId } = ctx.req.valid("param");
|
|
93
98
|
const modelId = decodeURIComponent(encodedModelId);
|
|
@@ -100,29 +105,38 @@ function createOpenRouterRouter() {
|
|
|
100
105
|
import_core.logger.warn(
|
|
101
106
|
`OpenRouter cache refresh failed during validation: ${error instanceof Error ? error.message : String(error)}`
|
|
102
107
|
);
|
|
103
|
-
return ctx.json(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
return ctx.json(
|
|
109
|
+
{
|
|
110
|
+
valid: false,
|
|
111
|
+
modelId,
|
|
112
|
+
status: "unknown",
|
|
113
|
+
error: "Could not validate model - cache refresh failed"
|
|
114
|
+
},
|
|
115
|
+
200
|
|
116
|
+
);
|
|
109
117
|
}
|
|
110
118
|
}
|
|
111
119
|
if (status === "invalid") {
|
|
112
|
-
return ctx.json(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
return ctx.json(
|
|
121
|
+
{
|
|
122
|
+
valid: false,
|
|
123
|
+
modelId,
|
|
124
|
+
status: "invalid",
|
|
125
|
+
error: `Model '${modelId}' not found in OpenRouter. Check the model ID at https://openrouter.ai/models`
|
|
126
|
+
},
|
|
127
|
+
200
|
|
128
|
+
);
|
|
118
129
|
}
|
|
119
130
|
const info = (0, import_core.getOpenRouterModelInfo)(modelId);
|
|
120
|
-
return ctx.json(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
return ctx.json(
|
|
132
|
+
{
|
|
133
|
+
valid: true,
|
|
134
|
+
modelId,
|
|
135
|
+
status: "valid",
|
|
136
|
+
...info && { info: { contextLength: info.contextLength } }
|
|
137
|
+
},
|
|
138
|
+
200
|
|
139
|
+
);
|
|
126
140
|
}).openapi(refreshRoute, async (ctx) => {
|
|
127
141
|
try {
|
|
128
142
|
await (0, import_core.refreshOpenRouterModelCache)();
|