@dexto/server 1.5.7 → 1.6.0
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/events/a2a-sse-subscriber.d.ts +1 -1
- package/dist/hono/__tests__/test-fixtures.cjs +27 -6
- package/dist/hono/__tests__/test-fixtures.d.ts +2 -1
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +31 -6
- package/dist/hono/index.cjs +17 -2
- package/dist/hono/index.d.ts +897 -76
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +17 -2
- package/dist/hono/routes/a2a-tasks.d.ts +6 -6
- package/dist/hono/routes/agents.cjs +38 -27
- package/dist/hono/routes/agents.d.ts +2 -1
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +37 -31
- package/dist/hono/routes/discovery.cjs +99 -22
- package/dist/hono/routes/discovery.d.ts +14 -12
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +89 -22
- package/dist/hono/routes/key.d.ts +4 -4
- package/dist/hono/routes/llm.cjs +21 -7
- package/dist/hono/routes/llm.d.ts +12 -10
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +22 -7
- package/dist/hono/routes/mcp.cjs +96 -14
- package/dist/hono/routes/mcp.d.ts +138 -3
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +97 -15
- package/dist/hono/routes/memory.d.ts +4 -4
- package/dist/hono/routes/messages.d.ts +1 -1
- package/dist/hono/routes/models.d.ts +1 -1
- package/dist/hono/routes/queue.cjs +9 -3
- package/dist/hono/routes/queue.d.ts +3 -0
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +9 -3
- package/dist/hono/routes/resources.d.ts +1 -1
- package/dist/hono/routes/schedules.cjs +455 -0
- package/dist/hono/routes/schedules.d.ts +472 -0
- package/dist/hono/routes/schedules.d.ts.map +1 -0
- package/dist/hono/routes/schedules.js +439 -0
- package/dist/hono/routes/search.d.ts +3 -3
- package/dist/hono/routes/sessions.cjs +10 -4
- package/dist/hono/routes/sessions.d.ts +136 -6
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +10 -4
- package/dist/hono/routes/tools.cjs +12 -19
- package/dist/hono/routes/tools.d.ts +5 -3
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +12 -19
- package/dist/hono/routes/workspaces.cjs +136 -0
- package/dist/hono/routes/workspaces.d.ts +77 -0
- package/dist/hono/routes/workspaces.d.ts.map +1 -0
- package/dist/hono/routes/workspaces.js +112 -0
- package/dist/hono/schemas/responses.cjs +82 -7
- package/dist/hono/schemas/responses.d.ts +403 -53
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +75 -6
- package/dist/hono/start-server.cjs +4 -3
- package/dist/hono/start-server.d.ts +15 -6
- package/dist/hono/start-server.d.ts.map +1 -1
- package/dist/hono/start-server.js +5 -4
- package/dist/index.cjs +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/mcp/mcp-handler.d.ts +2 -2
- package/dist/mcp/mcp-handler.d.ts.map +1 -1
- package/package.json +8 -5
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import {
|
|
3
|
+
ErrorResponseSchema,
|
|
4
|
+
ExecutionLogSchema,
|
|
5
|
+
ScheduleSchema
|
|
6
|
+
} from "../schemas/responses.js";
|
|
7
|
+
import {
|
|
8
|
+
getSchedulerManager,
|
|
9
|
+
ensureSchedulerManagerForAgent,
|
|
10
|
+
SchedulerErrorCode
|
|
11
|
+
} from "@dexto/tools-scheduler";
|
|
12
|
+
import { DextoRuntimeError, ErrorType } from "@dexto/core";
|
|
13
|
+
const CreateScheduleSchema = z.object({
|
|
14
|
+
name: z.string().min(1).describe("Schedule name"),
|
|
15
|
+
instruction: z.string().min(1).describe("Instruction to run on schedule"),
|
|
16
|
+
cronExpression: z.string().min(1).describe("Cron expression"),
|
|
17
|
+
timezone: z.string().optional().describe("Timezone for schedule"),
|
|
18
|
+
enabled: z.boolean().optional().describe("Whether the schedule is enabled"),
|
|
19
|
+
workspacePath: z.string().optional().nullable().describe("Optional workspace path for scheduled runs")
|
|
20
|
+
}).strict().describe("Request body for creating a schedule");
|
|
21
|
+
const UpdateScheduleSchema = CreateScheduleSchema.partial().strict().describe("Request body for updating a schedule");
|
|
22
|
+
const isScheduleNotFoundError = (error) => error instanceof DextoRuntimeError && error.type === ErrorType.NOT_FOUND && error.code === SchedulerErrorCode.SCHEDULE_NOT_FOUND;
|
|
23
|
+
const logSchedulerError = (agent, message, error) => {
|
|
24
|
+
if (!agent?.logger) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
agent.logger.error(message, {
|
|
28
|
+
error: error instanceof Error ? error.message : String(error ?? "Unknown error"),
|
|
29
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
30
|
+
code: error instanceof DextoRuntimeError ? error.code : void 0
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const toErrorResponse = (message, code) => ({
|
|
34
|
+
ok: false,
|
|
35
|
+
error: {
|
|
36
|
+
message,
|
|
37
|
+
...code ? { code } : {}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function createSchedulesRouter(getAgent) {
|
|
41
|
+
const app = new OpenAPIHono();
|
|
42
|
+
const resolveScheduler = async (ctx) => {
|
|
43
|
+
const agent = await getAgent(ctx);
|
|
44
|
+
const agentId = agent.config?.agentId ?? "default";
|
|
45
|
+
let scheduler = getSchedulerManager(agentId) ?? null;
|
|
46
|
+
if (!scheduler) {
|
|
47
|
+
scheduler = await ensureSchedulerManagerForAgent(agent);
|
|
48
|
+
}
|
|
49
|
+
return { scheduler, agent };
|
|
50
|
+
};
|
|
51
|
+
const listRoute = createRoute({
|
|
52
|
+
method: "get",
|
|
53
|
+
path: "/schedules",
|
|
54
|
+
summary: "List Schedules",
|
|
55
|
+
description: "Retrieves all automation schedules",
|
|
56
|
+
tags: ["schedules"],
|
|
57
|
+
responses: {
|
|
58
|
+
200: {
|
|
59
|
+
description: "List of schedules",
|
|
60
|
+
content: {
|
|
61
|
+
"application/json": {
|
|
62
|
+
schema: z.object({
|
|
63
|
+
schedules: z.array(ScheduleSchema).describe("Schedule list")
|
|
64
|
+
}).strict()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
500: {
|
|
69
|
+
description: "Failed to list schedules",
|
|
70
|
+
content: {
|
|
71
|
+
"application/json": {
|
|
72
|
+
schema: ErrorResponseSchema
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
503: {
|
|
77
|
+
description: "Scheduler tools are not enabled",
|
|
78
|
+
content: {
|
|
79
|
+
"application/json": {
|
|
80
|
+
schema: ErrorResponseSchema
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const createRouteDef = createRoute({
|
|
87
|
+
method: "post",
|
|
88
|
+
path: "/schedules",
|
|
89
|
+
summary: "Create Schedule",
|
|
90
|
+
description: "Creates a new automation schedule",
|
|
91
|
+
tags: ["schedules"],
|
|
92
|
+
request: { body: { content: { "application/json": { schema: CreateScheduleSchema } } } },
|
|
93
|
+
responses: {
|
|
94
|
+
201: {
|
|
95
|
+
description: "Created schedule",
|
|
96
|
+
content: {
|
|
97
|
+
"application/json": {
|
|
98
|
+
schema: z.object({ schedule: ScheduleSchema }).strict()
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
400: {
|
|
103
|
+
description: "Validation error",
|
|
104
|
+
content: {
|
|
105
|
+
"application/json": {
|
|
106
|
+
schema: ErrorResponseSchema
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
429: {
|
|
111
|
+
description: "Schedule limit reached",
|
|
112
|
+
content: {
|
|
113
|
+
"application/json": {
|
|
114
|
+
schema: ErrorResponseSchema
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
500: {
|
|
119
|
+
description: "Failed to create schedule",
|
|
120
|
+
content: {
|
|
121
|
+
"application/json": {
|
|
122
|
+
schema: ErrorResponseSchema
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
503: {
|
|
127
|
+
description: "Scheduler tools are not enabled",
|
|
128
|
+
content: {
|
|
129
|
+
"application/json": {
|
|
130
|
+
schema: ErrorResponseSchema
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
const updateRoute = createRoute({
|
|
137
|
+
method: "patch",
|
|
138
|
+
path: "/schedules/{scheduleId}",
|
|
139
|
+
summary: "Update Schedule",
|
|
140
|
+
description: "Updates an existing schedule",
|
|
141
|
+
tags: ["schedules"],
|
|
142
|
+
request: {
|
|
143
|
+
params: z.object({
|
|
144
|
+
scheduleId: z.string().min(1).describe("Schedule ID")
|
|
145
|
+
}).strict().describe("Schedule identifier params"),
|
|
146
|
+
body: { content: { "application/json": { schema: UpdateScheduleSchema } } }
|
|
147
|
+
},
|
|
148
|
+
responses: {
|
|
149
|
+
200: {
|
|
150
|
+
description: "Updated schedule",
|
|
151
|
+
content: {
|
|
152
|
+
"application/json": {
|
|
153
|
+
schema: z.object({ schedule: ScheduleSchema }).strict()
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
400: {
|
|
158
|
+
description: "Validation error",
|
|
159
|
+
content: {
|
|
160
|
+
"application/json": {
|
|
161
|
+
schema: ErrorResponseSchema
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
404: {
|
|
166
|
+
description: "Schedule not found",
|
|
167
|
+
content: {
|
|
168
|
+
"application/json": {
|
|
169
|
+
schema: ErrorResponseSchema
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
500: {
|
|
174
|
+
description: "Failed to update schedule",
|
|
175
|
+
content: {
|
|
176
|
+
"application/json": {
|
|
177
|
+
schema: ErrorResponseSchema
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
503: {
|
|
182
|
+
description: "Scheduler tools are not enabled",
|
|
183
|
+
content: {
|
|
184
|
+
"application/json": {
|
|
185
|
+
schema: ErrorResponseSchema
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
const deleteRoute = createRoute({
|
|
192
|
+
method: "delete",
|
|
193
|
+
path: "/schedules/{scheduleId}",
|
|
194
|
+
summary: "Delete Schedule",
|
|
195
|
+
description: "Deletes an automation schedule",
|
|
196
|
+
tags: ["schedules"],
|
|
197
|
+
request: {
|
|
198
|
+
params: z.object({
|
|
199
|
+
scheduleId: z.string().min(1).describe("Schedule ID")
|
|
200
|
+
}).strict().describe("Schedule identifier params")
|
|
201
|
+
},
|
|
202
|
+
responses: {
|
|
203
|
+
200: {
|
|
204
|
+
description: "Schedule deleted",
|
|
205
|
+
content: {
|
|
206
|
+
"application/json": {
|
|
207
|
+
schema: z.object({
|
|
208
|
+
deleted: z.boolean().describe("Whether the schedule was deleted")
|
|
209
|
+
}).strict().describe("Delete schedule response")
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
404: {
|
|
214
|
+
description: "Schedule not found",
|
|
215
|
+
content: {
|
|
216
|
+
"application/json": {
|
|
217
|
+
schema: ErrorResponseSchema
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
500: {
|
|
222
|
+
description: "Failed to delete schedule",
|
|
223
|
+
content: {
|
|
224
|
+
"application/json": {
|
|
225
|
+
schema: ErrorResponseSchema
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
503: {
|
|
230
|
+
description: "Scheduler tools are not enabled",
|
|
231
|
+
content: {
|
|
232
|
+
"application/json": {
|
|
233
|
+
schema: ErrorResponseSchema
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
const triggerRoute = createRoute({
|
|
240
|
+
method: "post",
|
|
241
|
+
path: "/schedules/{scheduleId}/trigger",
|
|
242
|
+
summary: "Trigger Schedule",
|
|
243
|
+
description: "Runs a schedule immediately and waits for execution to complete (bounded by executionTimeout, default 5 minutes). Clients should set timeouts accordingly.",
|
|
244
|
+
tags: ["schedules"],
|
|
245
|
+
request: {
|
|
246
|
+
params: z.object({
|
|
247
|
+
scheduleId: z.string().min(1).describe("Schedule ID")
|
|
248
|
+
}).strict().describe("Schedule identifier params")
|
|
249
|
+
},
|
|
250
|
+
responses: {
|
|
251
|
+
200: {
|
|
252
|
+
description: "Schedule triggered",
|
|
253
|
+
content: {
|
|
254
|
+
"application/json": {
|
|
255
|
+
schema: z.object({
|
|
256
|
+
scheduled: z.boolean().describe(
|
|
257
|
+
"Whether the schedule was queued. Execution is omitted when false."
|
|
258
|
+
),
|
|
259
|
+
execution: ExecutionLogSchema.optional().describe(
|
|
260
|
+
"Execution log (present when scheduled is true)"
|
|
261
|
+
)
|
|
262
|
+
}).strict().describe("Trigger schedule response")
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
404: {
|
|
267
|
+
description: "Schedule not found",
|
|
268
|
+
content: {
|
|
269
|
+
"application/json": {
|
|
270
|
+
schema: ErrorResponseSchema
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
500: {
|
|
275
|
+
description: "Failed to trigger schedule",
|
|
276
|
+
content: {
|
|
277
|
+
"application/json": {
|
|
278
|
+
schema: ErrorResponseSchema
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
503: {
|
|
283
|
+
description: "Scheduler tools are not enabled",
|
|
284
|
+
content: {
|
|
285
|
+
"application/json": {
|
|
286
|
+
schema: ErrorResponseSchema
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
return app.openapi(listRoute, async (ctx) => {
|
|
293
|
+
const { scheduler, agent } = await resolveScheduler(ctx);
|
|
294
|
+
if (!scheduler) {
|
|
295
|
+
return ctx.json(
|
|
296
|
+
toErrorResponse("Scheduler tools are not enabled for this agent."),
|
|
297
|
+
503
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
try {
|
|
301
|
+
const schedules = await scheduler.listSchedules();
|
|
302
|
+
return ctx.json({ schedules }, 200);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
const message = error instanceof Error ? error.message : String(error ?? "Unknown error");
|
|
305
|
+
logSchedulerError(agent, "Failed to list schedules", error);
|
|
306
|
+
if (error instanceof DextoRuntimeError) {
|
|
307
|
+
return ctx.json(toErrorResponse(message, String(error.code)), 500);
|
|
308
|
+
}
|
|
309
|
+
return ctx.json(toErrorResponse("Failed to list schedules"), 500);
|
|
310
|
+
}
|
|
311
|
+
}).openapi(createRouteDef, async (ctx) => {
|
|
312
|
+
const { scheduler, agent } = await resolveScheduler(ctx);
|
|
313
|
+
if (!scheduler) {
|
|
314
|
+
return ctx.json(
|
|
315
|
+
toErrorResponse("Scheduler tools are not enabled for this agent."),
|
|
316
|
+
503
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
const input = ctx.req.valid("json");
|
|
320
|
+
const createPayload = {
|
|
321
|
+
name: input.name,
|
|
322
|
+
instruction: input.instruction,
|
|
323
|
+
cronExpression: input.cronExpression,
|
|
324
|
+
...input.timezone !== void 0 ? { timezone: input.timezone } : {},
|
|
325
|
+
enabled: input.enabled ?? true,
|
|
326
|
+
...input.workspacePath !== void 0 ? { workspacePath: input.workspacePath } : {},
|
|
327
|
+
sessionMode: "dedicated"
|
|
328
|
+
};
|
|
329
|
+
try {
|
|
330
|
+
const schedule = await scheduler.createSchedule(createPayload);
|
|
331
|
+
return ctx.json({ schedule }, 201);
|
|
332
|
+
} catch (error) {
|
|
333
|
+
if (error instanceof DextoRuntimeError && error.code === SchedulerErrorCode.SCHEDULE_INVALID_CRON) {
|
|
334
|
+
return ctx.json(toErrorResponse(error.message, String(error.code)), 400);
|
|
335
|
+
}
|
|
336
|
+
if (error instanceof DextoRuntimeError && error.code === SchedulerErrorCode.SCHEDULE_INVALID_INPUT) {
|
|
337
|
+
return ctx.json(toErrorResponse(error.message, String(error.code)), 400);
|
|
338
|
+
}
|
|
339
|
+
if (error instanceof DextoRuntimeError && error.code === SchedulerErrorCode.SCHEDULE_LIMIT_REACHED) {
|
|
340
|
+
return ctx.json(toErrorResponse(error.message, String(error.code)), 429);
|
|
341
|
+
}
|
|
342
|
+
logSchedulerError(agent, "Failed to create schedule", error);
|
|
343
|
+
return ctx.json(toErrorResponse("Failed to create schedule"), 500);
|
|
344
|
+
}
|
|
345
|
+
}).openapi(updateRoute, async (ctx) => {
|
|
346
|
+
const { scheduler, agent } = await resolveScheduler(ctx);
|
|
347
|
+
if (!scheduler) {
|
|
348
|
+
return ctx.json(
|
|
349
|
+
toErrorResponse("Scheduler tools are not enabled for this agent."),
|
|
350
|
+
503
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
const { scheduleId } = ctx.req.valid("param");
|
|
354
|
+
const input = ctx.req.valid("json");
|
|
355
|
+
const updatePayload = {
|
|
356
|
+
...input.name !== void 0 ? { name: input.name } : {},
|
|
357
|
+
...input.instruction !== void 0 ? { instruction: input.instruction } : {},
|
|
358
|
+
...input.cronExpression !== void 0 ? { cronExpression: input.cronExpression } : {},
|
|
359
|
+
...input.timezone !== void 0 ? { timezone: input.timezone } : {},
|
|
360
|
+
...input.enabled !== void 0 ? { enabled: input.enabled } : {},
|
|
361
|
+
...input.workspacePath !== void 0 ? { workspacePath: input.workspacePath } : {}
|
|
362
|
+
};
|
|
363
|
+
try {
|
|
364
|
+
const schedule = await scheduler.updateSchedule(scheduleId, updatePayload);
|
|
365
|
+
return ctx.json({ schedule }, 200);
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (isScheduleNotFoundError(error)) {
|
|
368
|
+
return ctx.json(
|
|
369
|
+
toErrorResponse(
|
|
370
|
+
"Schedule not found",
|
|
371
|
+
SchedulerErrorCode.SCHEDULE_NOT_FOUND
|
|
372
|
+
),
|
|
373
|
+
404
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
if (error instanceof DextoRuntimeError && error.code === SchedulerErrorCode.SCHEDULE_INVALID_CRON) {
|
|
377
|
+
return ctx.json(toErrorResponse(error.message, String(error.code)), 400);
|
|
378
|
+
}
|
|
379
|
+
if (error instanceof DextoRuntimeError && error.code === SchedulerErrorCode.SCHEDULE_INVALID_INPUT) {
|
|
380
|
+
return ctx.json(toErrorResponse(error.message, String(error.code)), 400);
|
|
381
|
+
}
|
|
382
|
+
logSchedulerError(agent, "Failed to update schedule", error);
|
|
383
|
+
return ctx.json(toErrorResponse("Failed to update schedule"), 500);
|
|
384
|
+
}
|
|
385
|
+
}).openapi(deleteRoute, async (ctx) => {
|
|
386
|
+
const { scheduler, agent } = await resolveScheduler(ctx);
|
|
387
|
+
if (!scheduler) {
|
|
388
|
+
return ctx.json(
|
|
389
|
+
toErrorResponse("Scheduler tools are not enabled for this agent."),
|
|
390
|
+
503
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
const { scheduleId } = ctx.req.valid("param");
|
|
394
|
+
try {
|
|
395
|
+
await scheduler.deleteSchedule(scheduleId);
|
|
396
|
+
return ctx.json({ deleted: true }, 200);
|
|
397
|
+
} catch (error) {
|
|
398
|
+
if (isScheduleNotFoundError(error)) {
|
|
399
|
+
return ctx.json(
|
|
400
|
+
toErrorResponse(
|
|
401
|
+
"Schedule not found",
|
|
402
|
+
SchedulerErrorCode.SCHEDULE_NOT_FOUND
|
|
403
|
+
),
|
|
404
|
+
404
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
logSchedulerError(agent, "Failed to delete schedule", error);
|
|
408
|
+
return ctx.json(toErrorResponse("Failed to delete schedule"), 500);
|
|
409
|
+
}
|
|
410
|
+
}).openapi(triggerRoute, async (ctx) => {
|
|
411
|
+
const { scheduler, agent } = await resolveScheduler(ctx);
|
|
412
|
+
if (!scheduler) {
|
|
413
|
+
return ctx.json(
|
|
414
|
+
toErrorResponse("Scheduler tools are not enabled for this agent."),
|
|
415
|
+
503
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
const { scheduleId } = ctx.req.valid("param");
|
|
419
|
+
try {
|
|
420
|
+
const execution = await scheduler.triggerScheduleNow(scheduleId);
|
|
421
|
+
return ctx.json({ scheduled: true, execution }, 200);
|
|
422
|
+
} catch (error) {
|
|
423
|
+
if (isScheduleNotFoundError(error)) {
|
|
424
|
+
return ctx.json(
|
|
425
|
+
toErrorResponse(
|
|
426
|
+
"Schedule not found",
|
|
427
|
+
SchedulerErrorCode.SCHEDULE_NOT_FOUND
|
|
428
|
+
),
|
|
429
|
+
404
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
logSchedulerError(agent, "Failed to trigger schedule", error);
|
|
433
|
+
return ctx.json(toErrorResponse("Failed to trigger schedule"), 500);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
export {
|
|
438
|
+
createSchedulesRouter
|
|
439
|
+
};
|
|
@@ -56,7 +56,7 @@ export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<im
|
|
|
56
56
|
totalTokens?: number | undefined;
|
|
57
57
|
} | undefined;
|
|
58
58
|
model?: string | undefined;
|
|
59
|
-
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto" | undefined;
|
|
59
|
+
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
|
|
60
60
|
toolCalls?: {
|
|
61
61
|
function: {
|
|
62
62
|
name: string;
|
|
@@ -93,9 +93,9 @@ export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<im
|
|
|
93
93
|
results: {
|
|
94
94
|
sessionId: string;
|
|
95
95
|
metadata: {
|
|
96
|
+
messageCount: number;
|
|
96
97
|
createdAt: number;
|
|
97
98
|
lastActivity: number;
|
|
98
|
-
messageCount: number;
|
|
99
99
|
};
|
|
100
100
|
matchCount: number;
|
|
101
101
|
firstMatch: {
|
|
@@ -138,7 +138,7 @@ export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<im
|
|
|
138
138
|
totalTokens?: number | undefined;
|
|
139
139
|
} | undefined;
|
|
140
140
|
model?: string | undefined;
|
|
141
|
-
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto" | undefined;
|
|
141
|
+
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
|
|
142
142
|
toolCalls?: {
|
|
143
143
|
function: {
|
|
144
144
|
name: string;
|
|
@@ -279,7 +279,8 @@ function createSessionsRouter(getAgent) {
|
|
|
279
279
|
createdAt: metadata?.createdAt || null,
|
|
280
280
|
lastActivity: metadata?.lastActivity || null,
|
|
281
281
|
messageCount: metadata?.messageCount || 0,
|
|
282
|
-
title: metadata?.title || null
|
|
282
|
+
title: metadata?.title || null,
|
|
283
|
+
workspaceId: metadata?.workspaceId || null
|
|
283
284
|
};
|
|
284
285
|
} catch {
|
|
285
286
|
return {
|
|
@@ -287,7 +288,8 @@ function createSessionsRouter(getAgent) {
|
|
|
287
288
|
createdAt: null,
|
|
288
289
|
lastActivity: null,
|
|
289
290
|
messageCount: 0,
|
|
290
|
-
title: null
|
|
291
|
+
title: null,
|
|
292
|
+
workspaceId: null
|
|
291
293
|
};
|
|
292
294
|
}
|
|
293
295
|
})
|
|
@@ -305,7 +307,8 @@ function createSessionsRouter(getAgent) {
|
|
|
305
307
|
createdAt: metadata?.createdAt || Date.now(),
|
|
306
308
|
lastActivity: metadata?.lastActivity || Date.now(),
|
|
307
309
|
messageCount: metadata?.messageCount || 0,
|
|
308
|
-
title: metadata?.title || null
|
|
310
|
+
title: metadata?.title || null,
|
|
311
|
+
workspaceId: metadata?.workspaceId || null
|
|
309
312
|
}
|
|
310
313
|
},
|
|
311
314
|
201
|
|
@@ -322,6 +325,7 @@ function createSessionsRouter(getAgent) {
|
|
|
322
325
|
lastActivity: metadata?.lastActivity || null,
|
|
323
326
|
messageCount: metadata?.messageCount || 0,
|
|
324
327
|
title: metadata?.title || null,
|
|
328
|
+
workspaceId: metadata?.workspaceId || null,
|
|
325
329
|
history: history.length
|
|
326
330
|
}
|
|
327
331
|
});
|
|
@@ -387,6 +391,7 @@ function createSessionsRouter(getAgent) {
|
|
|
387
391
|
lastActivity: metadata?.lastActivity || null,
|
|
388
392
|
messageCount: metadata?.messageCount || 0,
|
|
389
393
|
title: metadata?.title || null,
|
|
394
|
+
workspaceId: metadata?.workspaceId || null,
|
|
390
395
|
isBusy
|
|
391
396
|
}
|
|
392
397
|
},
|
|
@@ -404,7 +409,8 @@ function createSessionsRouter(getAgent) {
|
|
|
404
409
|
createdAt: metadata?.createdAt || null,
|
|
405
410
|
lastActivity: metadata?.lastActivity || null,
|
|
406
411
|
messageCount: metadata?.messageCount || 0,
|
|
407
|
-
title: metadata?.title || title
|
|
412
|
+
title: metadata?.title || title,
|
|
413
|
+
workspaceId: metadata?.workspaceId || null
|
|
408
414
|
}
|
|
409
415
|
});
|
|
410
416
|
}).openapi(generateTitleRoute, async (ctx) => {
|