@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,112 @@
|
|
|
1
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import { WorkspaceSchema } from "../schemas/responses.js";
|
|
3
|
+
const SetWorkspaceSchema = z.object({
|
|
4
|
+
path: z.string().min(1).describe("Absolute workspace root path"),
|
|
5
|
+
name: z.string().optional().describe("Optional workspace display name")
|
|
6
|
+
}).strict().describe("Request body for setting the active workspace");
|
|
7
|
+
function createWorkspacesRouter(getAgent) {
|
|
8
|
+
const app = new OpenAPIHono();
|
|
9
|
+
const listRoute = createRoute({
|
|
10
|
+
method: "get",
|
|
11
|
+
path: "/workspaces",
|
|
12
|
+
summary: "List Workspaces",
|
|
13
|
+
description: "Retrieves all known workspaces",
|
|
14
|
+
tags: ["workspaces"],
|
|
15
|
+
responses: {
|
|
16
|
+
200: {
|
|
17
|
+
description: "List of workspaces",
|
|
18
|
+
content: {
|
|
19
|
+
"application/json": {
|
|
20
|
+
schema: z.object({
|
|
21
|
+
workspaces: z.array(WorkspaceSchema).describe("Workspace list")
|
|
22
|
+
}).strict()
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const getActiveRoute = createRoute({
|
|
29
|
+
method: "get",
|
|
30
|
+
path: "/workspaces/active",
|
|
31
|
+
summary: "Get Active Workspace",
|
|
32
|
+
description: "Returns the active workspace, if any",
|
|
33
|
+
tags: ["workspaces"],
|
|
34
|
+
responses: {
|
|
35
|
+
200: {
|
|
36
|
+
description: "Active workspace",
|
|
37
|
+
content: {
|
|
38
|
+
"application/json": {
|
|
39
|
+
schema: z.object({
|
|
40
|
+
workspace: WorkspaceSchema.nullable().describe(
|
|
41
|
+
"Active workspace or null if none is set"
|
|
42
|
+
)
|
|
43
|
+
}).strict()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const setActiveRoute = createRoute({
|
|
50
|
+
method: "post",
|
|
51
|
+
path: "/workspaces/active",
|
|
52
|
+
summary: "Set Active Workspace",
|
|
53
|
+
description: "Sets the active workspace for this runtime",
|
|
54
|
+
tags: ["workspaces"],
|
|
55
|
+
request: { body: { content: { "application/json": { schema: SetWorkspaceSchema } } } },
|
|
56
|
+
responses: {
|
|
57
|
+
200: {
|
|
58
|
+
description: "Active workspace updated",
|
|
59
|
+
content: {
|
|
60
|
+
"application/json": {
|
|
61
|
+
schema: z.object({
|
|
62
|
+
workspace: WorkspaceSchema.describe("Updated active workspace")
|
|
63
|
+
}).strict()
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const clearActiveRoute = createRoute({
|
|
70
|
+
method: "delete",
|
|
71
|
+
path: "/workspaces/active",
|
|
72
|
+
summary: "Clear Active Workspace",
|
|
73
|
+
description: "Clears the active workspace for this runtime",
|
|
74
|
+
tags: ["workspaces"],
|
|
75
|
+
responses: {
|
|
76
|
+
200: {
|
|
77
|
+
description: "Active workspace cleared",
|
|
78
|
+
content: {
|
|
79
|
+
"application/json": {
|
|
80
|
+
schema: z.object({
|
|
81
|
+
workspace: WorkspaceSchema.nullable().describe(
|
|
82
|
+
"Active workspace or null if none is set"
|
|
83
|
+
)
|
|
84
|
+
}).strict()
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return app.openapi(listRoute, async (ctx) => {
|
|
91
|
+
const agent = await getAgent(ctx);
|
|
92
|
+
const workspaces = await agent.listWorkspaces();
|
|
93
|
+
return ctx.json({ workspaces });
|
|
94
|
+
}).openapi(getActiveRoute, async (ctx) => {
|
|
95
|
+
const agent = await getAgent(ctx);
|
|
96
|
+
const workspace = await agent.getWorkspace();
|
|
97
|
+
return ctx.json({ workspace: workspace ?? null });
|
|
98
|
+
}).openapi(setActiveRoute, async (ctx) => {
|
|
99
|
+
const agent = await getAgent(ctx);
|
|
100
|
+
const input = ctx.req.valid("json");
|
|
101
|
+
const workspaceInput = input.name === void 0 ? { path: input.path } : { path: input.path, name: input.name };
|
|
102
|
+
const workspace = await agent.setWorkspace(workspaceInput);
|
|
103
|
+
return ctx.json({ workspace });
|
|
104
|
+
}).openapi(clearActiveRoute, async (ctx) => {
|
|
105
|
+
const agent = await getAgent(ctx);
|
|
106
|
+
await agent.clearWorkspace();
|
|
107
|
+
return ctx.json({ workspace: null });
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
createWorkspacesRouter
|
|
112
|
+
};
|
|
@@ -24,11 +24,11 @@ __export(responses_exports, {
|
|
|
24
24
|
ContentPartSchema: () => ContentPartSchema,
|
|
25
25
|
DeleteResponseSchema: () => DeleteResponseSchema,
|
|
26
26
|
ErrorResponseSchema: () => ErrorResponseSchema,
|
|
27
|
+
ExecutionLogSchema: () => ExecutionLogSchema,
|
|
27
28
|
FilePartSchema: () => FilePartSchema,
|
|
28
29
|
HttpServerConfigSchema: () => import_core5.HttpServerConfigSchema,
|
|
29
30
|
ImagePartSchema: () => ImagePartSchema,
|
|
30
31
|
InternalMessageSchema: () => InternalMessageSchema,
|
|
31
|
-
InternalResourceConfigSchema: () => import_core7.InternalResourceConfigSchema,
|
|
32
32
|
LLMConfigBaseSchema: () => import_core3.LLMConfigBaseSchema,
|
|
33
33
|
LLMConfigResponseSchema: () => LLMConfigResponseSchema,
|
|
34
34
|
LLMConfigSchema: () => LLMConfigSchema,
|
|
@@ -36,27 +36,33 @@ __export(responses_exports, {
|
|
|
36
36
|
MemorySchema: () => import_core2.MemorySchema,
|
|
37
37
|
MessageSearchResponseSchema: () => MessageSearchResponseSchema,
|
|
38
38
|
ModelFlatSchema: () => ModelFlatSchema,
|
|
39
|
+
ModelStatisticsSchema: () => ModelStatisticsSchema,
|
|
39
40
|
OkResponseSchema: () => OkResponseSchema,
|
|
41
|
+
PermissionsConfigSchema: () => import_core6.PermissionsConfigSchema,
|
|
40
42
|
PromptArgumentSchema: () => PromptArgumentSchema,
|
|
41
43
|
PromptDefinitionSchema: () => PromptDefinitionSchema,
|
|
42
44
|
PromptInfoSchema: () => PromptInfoSchema,
|
|
43
45
|
PromptSchema: () => PromptSchema,
|
|
44
46
|
ProviderCatalogSchema: () => ProviderCatalogSchema,
|
|
47
|
+
ResourceConfigSchema: () => import_core7.ResourceConfigSchema,
|
|
45
48
|
ResourceSchema: () => ResourceSchema,
|
|
49
|
+
ScheduleSchema: () => ScheduleSchema,
|
|
50
|
+
ScheduleTaskSchema: () => ScheduleTaskSchema,
|
|
46
51
|
SearchResultSchema: () => SearchResultSchema,
|
|
47
52
|
SessionMetadataSchema: () => SessionMetadataSchema,
|
|
48
53
|
SessionSearchResponseSchema: () => SessionSearchResponseSchema,
|
|
49
54
|
SessionSearchResultSchema: () => SessionSearchResultSchema,
|
|
55
|
+
SessionTokenUsageSchema: () => SessionTokenUsageSchema,
|
|
50
56
|
SseServerConfigSchema: () => import_core5.SseServerConfigSchema,
|
|
51
57
|
StatusResponseSchema: () => StatusResponseSchema,
|
|
52
58
|
StdioServerConfigSchema: () => import_core5.StdioServerConfigSchema,
|
|
53
59
|
TextPartSchema: () => TextPartSchema,
|
|
54
60
|
TokenUsageSchema: () => TokenUsageSchema,
|
|
55
61
|
ToolCallSchema: () => ToolCallSchema,
|
|
56
|
-
ToolConfirmationConfigSchema: () => import_core6.ToolConfirmationConfigSchema,
|
|
57
62
|
ToolSchema: () => ToolSchema,
|
|
58
63
|
UIResourcePartSchema: () => UIResourcePartSchema,
|
|
59
|
-
WebhookSchema: () => WebhookSchema
|
|
64
|
+
WebhookSchema: () => WebhookSchema,
|
|
65
|
+
WorkspaceSchema: () => WorkspaceSchema
|
|
60
66
|
});
|
|
61
67
|
module.exports = __toCommonJS(responses_exports);
|
|
62
68
|
var import_zod = require("zod");
|
|
@@ -134,13 +140,76 @@ const LLMConfigResponseSchema = import_core.LLMConfigBaseSchema.omit({ apiKey: t
|
|
|
134
140
|
hasApiKey: import_zod.z.boolean().optional().describe("Whether an API key is configured")
|
|
135
141
|
}).describe("LLM configuration (apiKey omitted for security)");
|
|
136
142
|
const LLMConfigSchema = import_core.LLMConfigBaseSchema.describe("LLM configuration with API key");
|
|
143
|
+
const SessionTokenUsageSchema = import_zod.z.object({
|
|
144
|
+
inputTokens: import_zod.z.number().int().nonnegative().describe("Number of input tokens"),
|
|
145
|
+
outputTokens: import_zod.z.number().int().nonnegative().describe("Number of output tokens"),
|
|
146
|
+
reasoningTokens: import_zod.z.number().int().nonnegative().describe("Number of reasoning tokens"),
|
|
147
|
+
cacheReadTokens: import_zod.z.number().int().nonnegative().describe("Number of cache read tokens"),
|
|
148
|
+
cacheWriteTokens: import_zod.z.number().int().nonnegative().describe("Number of cache write tokens"),
|
|
149
|
+
totalTokens: import_zod.z.number().int().nonnegative().describe("Total tokens used")
|
|
150
|
+
}).strict().describe("Session-level token usage (all fields required for cumulative totals)");
|
|
151
|
+
const ModelStatisticsSchema = import_zod.z.object({
|
|
152
|
+
provider: import_zod.z.string().describe("LLM provider identifier"),
|
|
153
|
+
model: import_zod.z.string().describe("Model identifier"),
|
|
154
|
+
messageCount: import_zod.z.number().int().nonnegative().describe("Number of messages using this model"),
|
|
155
|
+
tokenUsage: SessionTokenUsageSchema.describe("Token usage for this model"),
|
|
156
|
+
estimatedCost: import_zod.z.number().nonnegative().describe("Estimated cost in USD for this model"),
|
|
157
|
+
firstUsedAt: import_zod.z.number().int().positive().describe("First use timestamp (Unix ms)"),
|
|
158
|
+
lastUsedAt: import_zod.z.number().int().positive().describe("Last use timestamp (Unix ms)")
|
|
159
|
+
}).strict().describe("Per-model statistics within a session");
|
|
137
160
|
const SessionMetadataSchema = import_zod.z.object({
|
|
138
161
|
id: import_zod.z.string().describe("Unique session identifier"),
|
|
139
162
|
createdAt: import_zod.z.number().int().positive().nullable().describe("Creation timestamp (Unix ms, null if unavailable)"),
|
|
140
163
|
lastActivity: import_zod.z.number().int().positive().nullable().describe("Last activity timestamp (Unix ms, null if unavailable)"),
|
|
141
164
|
messageCount: import_zod.z.number().int().nonnegative().describe("Total number of messages in session"),
|
|
142
|
-
title: import_zod.z.string().optional().nullable().describe("Optional session title")
|
|
165
|
+
title: import_zod.z.string().optional().nullable().describe("Optional session title"),
|
|
166
|
+
tokenUsage: SessionTokenUsageSchema.optional().describe(
|
|
167
|
+
"Aggregate token usage across all models"
|
|
168
|
+
),
|
|
169
|
+
estimatedCost: import_zod.z.number().nonnegative().optional().describe("Total estimated cost in USD across all models"),
|
|
170
|
+
modelStats: import_zod.z.array(ModelStatisticsSchema).optional().describe("Per-model usage statistics (for multi-model sessions)"),
|
|
171
|
+
workspaceId: import_zod.z.string().optional().nullable().describe("Associated workspace ID, if any")
|
|
143
172
|
}).strict().describe("Session metadata");
|
|
173
|
+
const WorkspaceSchema = import_zod.z.object({
|
|
174
|
+
id: import_zod.z.string().describe("Workspace identifier"),
|
|
175
|
+
path: import_zod.z.string().describe("Workspace root path"),
|
|
176
|
+
name: import_zod.z.string().optional().nullable().describe("Optional workspace display name"),
|
|
177
|
+
createdAt: import_zod.z.number().int().positive().describe("Creation timestamp (Unix ms)"),
|
|
178
|
+
lastActiveAt: import_zod.z.number().int().positive().describe("Last active timestamp (Unix ms)")
|
|
179
|
+
}).strict().describe("Workspace metadata");
|
|
180
|
+
const ScheduleTaskSchema = import_zod.z.object({
|
|
181
|
+
instruction: import_zod.z.string().describe("Instruction to execute"),
|
|
182
|
+
metadata: import_zod.z.record(import_zod.z.unknown()).optional().describe("Optional task metadata")
|
|
183
|
+
}).strict().describe("Schedule task definition");
|
|
184
|
+
const ScheduleSchema = import_zod.z.object({
|
|
185
|
+
id: import_zod.z.string().describe("Schedule ID"),
|
|
186
|
+
name: import_zod.z.string().describe("Schedule name"),
|
|
187
|
+
cronExpression: import_zod.z.string().describe("Cron expression"),
|
|
188
|
+
timezone: import_zod.z.string().describe("Timezone for schedule"),
|
|
189
|
+
enabled: import_zod.z.boolean().describe("Whether the schedule is enabled"),
|
|
190
|
+
task: ScheduleTaskSchema.describe("Schedule task configuration"),
|
|
191
|
+
sessionMode: import_zod.z.enum(["ephemeral", "dedicated", "inherit", "fixed"]).describe("Session context mode"),
|
|
192
|
+
sessionId: import_zod.z.string().optional().describe("Session ID when using fixed/inherit mode"),
|
|
193
|
+
workspacePath: import_zod.z.string().optional().describe("Workspace path override"),
|
|
194
|
+
createdAt: import_zod.z.number().int().positive().describe("Creation timestamp (Unix ms)"),
|
|
195
|
+
updatedAt: import_zod.z.number().int().positive().describe("Last update timestamp (Unix ms)"),
|
|
196
|
+
lastRunAt: import_zod.z.number().int().positive().optional().describe("Last run timestamp (Unix ms)"),
|
|
197
|
+
nextRunAt: import_zod.z.number().int().positive().optional().describe("Next run timestamp (Unix ms)"),
|
|
198
|
+
runCount: import_zod.z.number().int().nonnegative().describe("Total executions"),
|
|
199
|
+
successCount: import_zod.z.number().int().nonnegative().describe("Successful executions"),
|
|
200
|
+
failureCount: import_zod.z.number().int().nonnegative().describe("Failed executions"),
|
|
201
|
+
lastError: import_zod.z.string().optional().describe("Last execution error, if any")
|
|
202
|
+
}).strict().describe("Automation schedule");
|
|
203
|
+
const ExecutionLogSchema = import_zod.z.object({
|
|
204
|
+
id: import_zod.z.string().describe("Execution log ID"),
|
|
205
|
+
scheduleId: import_zod.z.string().describe("Schedule ID"),
|
|
206
|
+
triggeredAt: import_zod.z.number().int().positive().describe("Trigger timestamp (Unix ms)"),
|
|
207
|
+
completedAt: import_zod.z.number().int().positive().optional().describe("Completion timestamp (Unix ms)"),
|
|
208
|
+
status: import_zod.z.enum(["pending", "success", "failed", "timeout"]).describe("Execution status"),
|
|
209
|
+
duration: import_zod.z.number().int().nonnegative().optional().describe("Execution duration in ms"),
|
|
210
|
+
error: import_zod.z.string().optional().describe("Execution error, if any"),
|
|
211
|
+
result: import_zod.z.string().optional().describe("Execution result, if any")
|
|
212
|
+
}).strict().describe("Schedule execution log");
|
|
144
213
|
const SearchResultSchema = import_zod.z.object({
|
|
145
214
|
sessionId: import_zod.z.string().describe("Session ID where the message was found"),
|
|
146
215
|
message: InternalMessageSchema.describe("The message that matched the search"),
|
|
@@ -282,11 +351,11 @@ const DeleteResponseSchema = import_zod.z.object({
|
|
|
282
351
|
ContentPartSchema,
|
|
283
352
|
DeleteResponseSchema,
|
|
284
353
|
ErrorResponseSchema,
|
|
354
|
+
ExecutionLogSchema,
|
|
285
355
|
FilePartSchema,
|
|
286
356
|
HttpServerConfigSchema,
|
|
287
357
|
ImagePartSchema,
|
|
288
358
|
InternalMessageSchema,
|
|
289
|
-
InternalResourceConfigSchema,
|
|
290
359
|
LLMConfigBaseSchema,
|
|
291
360
|
LLMConfigResponseSchema,
|
|
292
361
|
LLMConfigSchema,
|
|
@@ -294,25 +363,31 @@ const DeleteResponseSchema = import_zod.z.object({
|
|
|
294
363
|
MemorySchema,
|
|
295
364
|
MessageSearchResponseSchema,
|
|
296
365
|
ModelFlatSchema,
|
|
366
|
+
ModelStatisticsSchema,
|
|
297
367
|
OkResponseSchema,
|
|
368
|
+
PermissionsConfigSchema,
|
|
298
369
|
PromptArgumentSchema,
|
|
299
370
|
PromptDefinitionSchema,
|
|
300
371
|
PromptInfoSchema,
|
|
301
372
|
PromptSchema,
|
|
302
373
|
ProviderCatalogSchema,
|
|
374
|
+
ResourceConfigSchema,
|
|
303
375
|
ResourceSchema,
|
|
376
|
+
ScheduleSchema,
|
|
377
|
+
ScheduleTaskSchema,
|
|
304
378
|
SearchResultSchema,
|
|
305
379
|
SessionMetadataSchema,
|
|
306
380
|
SessionSearchResponseSchema,
|
|
307
381
|
SessionSearchResultSchema,
|
|
382
|
+
SessionTokenUsageSchema,
|
|
308
383
|
SseServerConfigSchema,
|
|
309
384
|
StatusResponseSchema,
|
|
310
385
|
StdioServerConfigSchema,
|
|
311
386
|
TextPartSchema,
|
|
312
387
|
TokenUsageSchema,
|
|
313
388
|
ToolCallSchema,
|
|
314
|
-
ToolConfirmationConfigSchema,
|
|
315
389
|
ToolSchema,
|
|
316
390
|
UIResourcePartSchema,
|
|
317
|
-
WebhookSchema
|
|
391
|
+
WebhookSchema,
|
|
392
|
+
WorkspaceSchema
|
|
318
393
|
});
|