@dexto/server 1.3.0 → 1.5.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/approval/manual-approval-handler.cjs +23 -15
- package/dist/approval/manual-approval-handler.d.ts.map +1 -1
- package/dist/approval/manual-approval-handler.js +23 -15
- package/dist/events/webhook-subscriber.cjs +1 -1
- package/dist/events/webhook-subscriber.d.ts.map +1 -1
- package/dist/events/webhook-subscriber.js +1 -1
- package/dist/hono/__tests__/test-fixtures.cjs +3 -3
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +3 -3
- package/dist/hono/index.cjs +46 -5
- package/dist/hono/index.d.ts +928 -584
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +46 -5
- package/dist/hono/middleware/error.d.ts.map +1 -1
- package/dist/hono/routes/a2a-jsonrpc.cjs +3 -3
- package/dist/hono/routes/a2a-jsonrpc.d.ts +4 -1
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-jsonrpc.js +3 -3
- package/dist/hono/routes/a2a-tasks.cjs +5 -5
- package/dist/hono/routes/a2a-tasks.d.ts +13 -10
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +5 -5
- package/dist/hono/routes/agents.cjs +30 -42
- package/dist/hono/routes/agents.d.ts +7 -401
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +32 -42
- package/dist/hono/routes/approvals.cjs +53 -2
- package/dist/hono/routes/approvals.d.ts +29 -1
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +53 -2
- package/dist/hono/routes/discovery.cjs +67 -0
- package/dist/hono/routes/discovery.d.ts +44 -0
- package/dist/hono/routes/discovery.d.ts.map +1 -0
- package/dist/hono/routes/discovery.js +43 -0
- package/dist/hono/routes/greeting.cjs +2 -2
- package/dist/hono/routes/greeting.d.ts +2 -2
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +2 -2
- package/dist/hono/routes/health.d.ts +2 -2
- package/dist/hono/routes/health.d.ts.map +1 -1
- package/dist/hono/routes/key.cjs +110 -0
- package/dist/hono/routes/key.d.ts +48 -0
- package/dist/hono/routes/key.d.ts.map +1 -0
- package/dist/hono/routes/key.js +90 -0
- package/dist/hono/routes/llm.cjs +119 -62
- package/dist/hono/routes/llm.d.ts +242 -42
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +118 -58
- package/dist/hono/routes/mcp.cjs +16 -12
- package/dist/hono/routes/mcp.d.ts +6 -3
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +17 -13
- package/dist/hono/routes/memory.cjs +5 -5
- package/dist/hono/routes/memory.d.ts +5 -2
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +5 -5
- package/dist/hono/routes/messages.cjs +58 -66
- package/dist/hono/routes/messages.d.ts +99 -55
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +59 -67
- package/dist/hono/routes/models.cjs +319 -0
- package/dist/hono/routes/models.d.ts +107 -0
- package/dist/hono/routes/models.d.ts.map +1 -0
- package/dist/hono/routes/models.js +305 -0
- package/dist/hono/routes/openrouter.cjs +153 -0
- package/dist/hono/routes/openrouter.d.ts +54 -0
- package/dist/hono/routes/openrouter.d.ts.map +1 -0
- package/dist/hono/routes/openrouter.js +134 -0
- package/dist/hono/routes/prompts.cjs +5 -5
- package/dist/hono/routes/prompts.d.ts +10 -7
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +5 -5
- package/dist/hono/routes/queue.cjs +202 -0
- package/dist/hono/routes/queue.d.ts +174 -0
- package/dist/hono/routes/queue.d.ts.map +1 -0
- package/dist/hono/routes/queue.js +178 -0
- package/dist/hono/routes/resources.cjs +3 -3
- package/dist/hono/routes/resources.d.ts +3 -3
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +3 -3
- package/dist/hono/routes/search.cjs +2 -2
- package/dist/hono/routes/search.d.ts +39 -10
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +2 -2
- package/dist/hono/routes/sessions.cjs +74 -20
- package/dist/hono/routes/sessions.d.ts +25 -4
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +74 -20
- package/dist/hono/routes/tools.cjs +126 -0
- package/dist/hono/routes/tools.d.ts +42 -0
- package/dist/hono/routes/tools.d.ts.map +1 -0
- package/dist/hono/routes/tools.js +102 -0
- package/dist/hono/routes/webhooks.cjs +4 -4
- package/dist/hono/routes/webhooks.d.ts +4 -1
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +4 -4
- package/dist/hono/schemas/responses.cjs +24 -5
- package/dist/hono/schemas/responses.d.ts +838 -120
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +24 -10
- package/dist/hono/start-server.cjs +102 -0
- package/dist/hono/start-server.d.ts +61 -0
- package/dist/hono/start-server.d.ts.map +1 -0
- package/dist/hono/start-server.js +78 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +5 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createResourcesRouter(getAgent:
|
|
2
|
+
import type { GetAgentFn } from '../index.js';
|
|
3
|
+
export declare function createResourcesRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
|
|
4
4
|
"/resources": {
|
|
5
5
|
$get: {
|
|
6
6
|
input: {};
|
|
@@ -11,10 +11,10 @@ export declare function createResourcesRouter(getAgent: () => DextoAgent): OpenA
|
|
|
11
11
|
source: "mcp" | "internal";
|
|
12
12
|
description?: string | undefined;
|
|
13
13
|
mimeType?: string | undefined;
|
|
14
|
-
name?: string | undefined;
|
|
15
14
|
metadata?: {
|
|
16
15
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
17
16
|
} | undefined;
|
|
17
|
+
name?: string | undefined;
|
|
18
18
|
serverName?: string | undefined;
|
|
19
19
|
size?: number | undefined;
|
|
20
20
|
lastModified?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAwD9C,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqEzD"}
|
|
@@ -66,16 +66,16 @@ function createResourcesRouter(getAgent) {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
return app.openapi(listRoute, async (ctx) => {
|
|
69
|
-
const agent = getAgent();
|
|
69
|
+
const agent = await getAgent(ctx);
|
|
70
70
|
const resources = await agent.listResources();
|
|
71
71
|
return ctx.json({ ok: true, resources: Object.values(resources) });
|
|
72
72
|
}).openapi(getContentRoute, async (ctx) => {
|
|
73
|
-
const agent = getAgent();
|
|
73
|
+
const agent = await getAgent(ctx);
|
|
74
74
|
const { resourceId } = ctx.req.valid("param");
|
|
75
75
|
const content = await agent.readResource(resourceId);
|
|
76
76
|
return ctx.json({ ok: true, content });
|
|
77
77
|
}).openapi(headRoute, async (ctx) => {
|
|
78
|
-
const agent = getAgent();
|
|
78
|
+
const agent = await getAgent(ctx);
|
|
79
79
|
const { resourceId } = ctx.req.valid("param");
|
|
80
80
|
const exists = await agent.hasResource(resourceId);
|
|
81
81
|
return ctx.body(null, exists ? 200 : 404);
|
|
@@ -64,7 +64,7 @@ function createSearchRouter(getAgent) {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
return app.openapi(messagesRoute, async (ctx) => {
|
|
67
|
-
const agent = getAgent();
|
|
67
|
+
const agent = await getAgent(ctx);
|
|
68
68
|
const { q, limit, offset, sessionId, role } = ctx.req.valid("query");
|
|
69
69
|
const options = {
|
|
70
70
|
limit: limit || 20,
|
|
@@ -75,7 +75,7 @@ function createSearchRouter(getAgent) {
|
|
|
75
75
|
const searchResults = await agent.searchMessages(q, options);
|
|
76
76
|
return ctx.json(searchResults);
|
|
77
77
|
}).openapi(sessionsRoute, async (ctx) => {
|
|
78
|
-
const agent = getAgent();
|
|
78
|
+
const agent = await getAgent(ctx);
|
|
79
79
|
const { q } = ctx.req.valid("query");
|
|
80
80
|
const searchResults = await agent.searchSessions(q);
|
|
81
81
|
return ctx.json(searchResults);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
2
|
import type { DextoAgent } from '@dexto/core';
|
|
3
|
-
|
|
3
|
+
import type { Context } from 'hono';
|
|
4
|
+
type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
|
|
5
|
+
export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
|
|
4
6
|
"/search/messages": {
|
|
5
7
|
$get: {
|
|
6
8
|
input: {
|
|
@@ -28,6 +30,19 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
|
|
|
28
30
|
mimeType: string;
|
|
29
31
|
data: string;
|
|
30
32
|
filename?: string | undefined;
|
|
33
|
+
} | {
|
|
34
|
+
type: "ui-resource";
|
|
35
|
+
mimeType: string;
|
|
36
|
+
uri: string;
|
|
37
|
+
content?: string | undefined;
|
|
38
|
+
blob?: string | undefined;
|
|
39
|
+
metadata?: {
|
|
40
|
+
title?: string | undefined;
|
|
41
|
+
preferredSize?: {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
} | undefined;
|
|
45
|
+
} | undefined;
|
|
31
46
|
})[] | null;
|
|
32
47
|
role: "system" | "user" | "assistant" | "tool";
|
|
33
48
|
id?: string | undefined;
|
|
@@ -41,8 +56,7 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
|
|
|
41
56
|
totalTokens?: number | undefined;
|
|
42
57
|
} | undefined;
|
|
43
58
|
model?: string | undefined;
|
|
44
|
-
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
|
|
45
|
-
router?: "vercel" | "in-built" | undefined;
|
|
59
|
+
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | undefined;
|
|
46
60
|
toolCalls?: {
|
|
47
61
|
function: {
|
|
48
62
|
name: string;
|
|
@@ -52,6 +66,7 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
|
|
|
52
66
|
id: string;
|
|
53
67
|
}[] | undefined;
|
|
54
68
|
toolCallId?: string | undefined;
|
|
69
|
+
success?: boolean | undefined;
|
|
55
70
|
};
|
|
56
71
|
sessionId: string;
|
|
57
72
|
matchedText: string;
|
|
@@ -77,6 +92,11 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
|
|
|
77
92
|
query: string;
|
|
78
93
|
results: {
|
|
79
94
|
sessionId: string;
|
|
95
|
+
metadata: {
|
|
96
|
+
createdAt: number;
|
|
97
|
+
lastActivity: number;
|
|
98
|
+
messageCount: number;
|
|
99
|
+
};
|
|
80
100
|
matchCount: number;
|
|
81
101
|
firstMatch: {
|
|
82
102
|
message: {
|
|
@@ -92,6 +112,19 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
|
|
|
92
112
|
mimeType: string;
|
|
93
113
|
data: string;
|
|
94
114
|
filename?: string | undefined;
|
|
115
|
+
} | {
|
|
116
|
+
type: "ui-resource";
|
|
117
|
+
mimeType: string;
|
|
118
|
+
uri: string;
|
|
119
|
+
content?: string | undefined;
|
|
120
|
+
blob?: string | undefined;
|
|
121
|
+
metadata?: {
|
|
122
|
+
title?: string | undefined;
|
|
123
|
+
preferredSize?: {
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
} | undefined;
|
|
127
|
+
} | undefined;
|
|
95
128
|
})[] | null;
|
|
96
129
|
role: "system" | "user" | "assistant" | "tool";
|
|
97
130
|
id?: string | undefined;
|
|
@@ -105,8 +138,7 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
|
|
|
105
138
|
totalTokens?: number | undefined;
|
|
106
139
|
} | undefined;
|
|
107
140
|
model?: string | undefined;
|
|
108
|
-
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
|
|
109
|
-
router?: "vercel" | "in-built" | undefined;
|
|
141
|
+
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | undefined;
|
|
110
142
|
toolCalls?: {
|
|
111
143
|
function: {
|
|
112
144
|
name: string;
|
|
@@ -116,17 +148,13 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
|
|
|
116
148
|
id: string;
|
|
117
149
|
}[] | undefined;
|
|
118
150
|
toolCallId?: string | undefined;
|
|
151
|
+
success?: boolean | undefined;
|
|
119
152
|
};
|
|
120
153
|
sessionId: string;
|
|
121
154
|
matchedText: string;
|
|
122
155
|
context: string;
|
|
123
156
|
messageIndex: number;
|
|
124
157
|
};
|
|
125
|
-
metadata: {
|
|
126
|
-
createdAt: number;
|
|
127
|
-
lastActivity: number;
|
|
128
|
-
messageCount: number;
|
|
129
|
-
};
|
|
130
158
|
}[];
|
|
131
159
|
total: number;
|
|
132
160
|
hasMore: boolean;
|
|
@@ -136,4 +164,5 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
|
|
|
136
164
|
};
|
|
137
165
|
};
|
|
138
166
|
}, "/">;
|
|
167
|
+
export {};
|
|
139
168
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AA0BrE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwDtD"}
|
|
@@ -41,7 +41,7 @@ function createSearchRouter(getAgent) {
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
return app.openapi(messagesRoute, async (ctx) => {
|
|
44
|
-
const agent = getAgent();
|
|
44
|
+
const agent = await getAgent(ctx);
|
|
45
45
|
const { q, limit, offset, sessionId, role } = ctx.req.valid("query");
|
|
46
46
|
const options = {
|
|
47
47
|
limit: limit || 20,
|
|
@@ -52,7 +52,7 @@ function createSearchRouter(getAgent) {
|
|
|
52
52
|
const searchResults = await agent.searchMessages(q, options);
|
|
53
53
|
return ctx.json(searchResults);
|
|
54
54
|
}).openapi(sessionsRoute, async (ctx) => {
|
|
55
|
-
const agent = getAgent();
|
|
55
|
+
const agent = await getAgent(ctx);
|
|
56
56
|
const { q } = ctx.req.valid("query");
|
|
57
57
|
const searchResults = await agent.searchSessions(q);
|
|
58
58
|
return ctx.json(searchResults);
|
|
@@ -95,7 +95,7 @@ function createSessionsRouter(getAgent) {
|
|
|
95
95
|
method: "get",
|
|
96
96
|
path: "/sessions/{sessionId}/history",
|
|
97
97
|
summary: "Get Session History",
|
|
98
|
-
description: "Retrieves the conversation history for a session",
|
|
98
|
+
description: "Retrieves the conversation history for a session along with processing status",
|
|
99
99
|
tags: ["sessions"],
|
|
100
100
|
request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
|
|
101
101
|
responses: {
|
|
@@ -104,7 +104,10 @@ function createSessionsRouter(getAgent) {
|
|
|
104
104
|
content: {
|
|
105
105
|
"application/json": {
|
|
106
106
|
schema: import_zod_openapi.z.object({
|
|
107
|
-
history: import_zod_openapi.z.array(import_responses.InternalMessageSchema).describe("Array of messages in conversation history")
|
|
107
|
+
history: import_zod_openapi.z.array(import_responses.InternalMessageSchema).describe("Array of messages in conversation history"),
|
|
108
|
+
isBusy: import_zod_openapi.z.boolean().describe(
|
|
109
|
+
"Whether the session is currently processing a message"
|
|
110
|
+
)
|
|
108
111
|
}).strict()
|
|
109
112
|
}
|
|
110
113
|
}
|
|
@@ -136,9 +139,23 @@ function createSessionsRouter(getAgent) {
|
|
|
136
139
|
method: "post",
|
|
137
140
|
path: "/sessions/{sessionId}/cancel",
|
|
138
141
|
summary: "Cancel Session Run",
|
|
139
|
-
description: "Cancels an in-flight agent run for the specified session",
|
|
142
|
+
description: "Cancels an in-flight agent run for the specified session. By default (soft cancel), only the current LLM call is cancelled and queued messages continue processing. Set clearQueue=true for hard cancel to also clear any queued messages.",
|
|
140
143
|
tags: ["sessions"],
|
|
141
|
-
request: {
|
|
144
|
+
request: {
|
|
145
|
+
params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }),
|
|
146
|
+
body: {
|
|
147
|
+
content: {
|
|
148
|
+
"application/json": {
|
|
149
|
+
schema: import_zod_openapi.z.object({
|
|
150
|
+
clearQueue: import_zod_openapi.z.boolean().optional().default(false).describe(
|
|
151
|
+
"If true (hard cancel), clears queued messages. If false (soft cancel, default), queued messages continue processing."
|
|
152
|
+
)
|
|
153
|
+
}).strict()
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
required: false
|
|
157
|
+
}
|
|
158
|
+
},
|
|
142
159
|
responses: {
|
|
143
160
|
200: {
|
|
144
161
|
description: "Cancel operation result",
|
|
@@ -146,7 +163,11 @@ function createSessionsRouter(getAgent) {
|
|
|
146
163
|
"application/json": {
|
|
147
164
|
schema: import_zod_openapi.z.object({
|
|
148
165
|
cancelled: import_zod_openapi.z.boolean().describe("Whether a run was cancelled"),
|
|
149
|
-
sessionId: import_zod_openapi.z.string().describe("Session ID")
|
|
166
|
+
sessionId: import_zod_openapi.z.string().describe("Session ID"),
|
|
167
|
+
queueCleared: import_zod_openapi.z.boolean().describe("Whether queued messages were cleared"),
|
|
168
|
+
clearedCount: import_zod_openapi.z.number().describe(
|
|
169
|
+
"Number of queued messages cleared (0 if soft cancel)"
|
|
170
|
+
)
|
|
150
171
|
}).strict()
|
|
151
172
|
}
|
|
152
173
|
}
|
|
@@ -157,7 +178,7 @@ function createSessionsRouter(getAgent) {
|
|
|
157
178
|
method: "get",
|
|
158
179
|
path: "/sessions/{sessionId}/load",
|
|
159
180
|
summary: "Load Session",
|
|
160
|
-
description: "Validates and retrieves session information. The client should track the active session.",
|
|
181
|
+
description: "Validates and retrieves session information including processing status. The client should track the active session.",
|
|
161
182
|
tags: ["sessions"],
|
|
162
183
|
request: {
|
|
163
184
|
params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
|
|
@@ -168,7 +189,11 @@ function createSessionsRouter(getAgent) {
|
|
|
168
189
|
content: {
|
|
169
190
|
"application/json": {
|
|
170
191
|
schema: import_zod_openapi.z.object({
|
|
171
|
-
session: import_responses.SessionMetadataSchema.
|
|
192
|
+
session: import_responses.SessionMetadataSchema.extend({
|
|
193
|
+
isBusy: import_zod_openapi.z.boolean().describe(
|
|
194
|
+
"Whether the session is currently processing a message"
|
|
195
|
+
)
|
|
196
|
+
}).describe("Session metadata with processing status")
|
|
172
197
|
}).strict()
|
|
173
198
|
}
|
|
174
199
|
}
|
|
@@ -243,7 +268,7 @@ function createSessionsRouter(getAgent) {
|
|
|
243
268
|
}
|
|
244
269
|
});
|
|
245
270
|
return app.openapi(listRoute, async (ctx) => {
|
|
246
|
-
const agent = getAgent();
|
|
271
|
+
const agent = await getAgent(ctx);
|
|
247
272
|
const sessionIds = await agent.listSessions();
|
|
248
273
|
const sessions = await Promise.all(
|
|
249
274
|
sessionIds.map(async (id) => {
|
|
@@ -269,7 +294,7 @@ function createSessionsRouter(getAgent) {
|
|
|
269
294
|
);
|
|
270
295
|
return ctx.json({ sessions });
|
|
271
296
|
}).openapi(createRouteDef, async (ctx) => {
|
|
272
|
-
const agent = getAgent();
|
|
297
|
+
const agent = await getAgent(ctx);
|
|
273
298
|
const { sessionId } = ctx.req.valid("json");
|
|
274
299
|
const session = await agent.createSession(sessionId);
|
|
275
300
|
const metadata = await agent.getSessionMetadata(session.id);
|
|
@@ -286,7 +311,7 @@ function createSessionsRouter(getAgent) {
|
|
|
286
311
|
201
|
|
287
312
|
);
|
|
288
313
|
}).openapi(getRoute, async (ctx) => {
|
|
289
|
-
const agent = getAgent();
|
|
314
|
+
const agent = await getAgent(ctx);
|
|
290
315
|
const { sessionId } = ctx.req.param();
|
|
291
316
|
const metadata = await agent.getSessionMetadata(sessionId);
|
|
292
317
|
const history = await agent.getSessionHistory(sessionId);
|
|
@@ -301,31 +326,59 @@ function createSessionsRouter(getAgent) {
|
|
|
301
326
|
}
|
|
302
327
|
});
|
|
303
328
|
}).openapi(historyRoute, async (ctx) => {
|
|
304
|
-
const agent = getAgent();
|
|
329
|
+
const agent = await getAgent(ctx);
|
|
305
330
|
const { sessionId } = ctx.req.param();
|
|
306
|
-
const history = await
|
|
307
|
-
|
|
331
|
+
const [history, isBusy] = await Promise.all([
|
|
332
|
+
agent.getSessionHistory(sessionId),
|
|
333
|
+
agent.isSessionBusy(sessionId)
|
|
334
|
+
]);
|
|
335
|
+
return ctx.json({
|
|
336
|
+
history,
|
|
337
|
+
isBusy
|
|
338
|
+
});
|
|
308
339
|
}).openapi(deleteRoute, async (ctx) => {
|
|
309
|
-
const agent = getAgent();
|
|
340
|
+
const agent = await getAgent(ctx);
|
|
310
341
|
const { sessionId } = ctx.req.param();
|
|
311
342
|
await agent.deleteSession(sessionId);
|
|
312
343
|
return ctx.json({ status: "deleted", sessionId });
|
|
313
344
|
}).openapi(cancelRoute, async (ctx) => {
|
|
314
|
-
const agent = getAgent();
|
|
345
|
+
const agent = await getAgent(ctx);
|
|
315
346
|
const { sessionId } = ctx.req.valid("param");
|
|
347
|
+
let clearQueue = false;
|
|
348
|
+
try {
|
|
349
|
+
const body = ctx.req.valid("json");
|
|
350
|
+
clearQueue = body?.clearQueue ?? false;
|
|
351
|
+
} catch {
|
|
352
|
+
}
|
|
353
|
+
let clearedCount = 0;
|
|
354
|
+
if (clearQueue) {
|
|
355
|
+
try {
|
|
356
|
+
clearedCount = await agent.clearMessageQueue(sessionId);
|
|
357
|
+
agent.logger.debug(
|
|
358
|
+
`Hard cancel: cleared ${clearedCount} queued message(s) for session: ${sessionId}`
|
|
359
|
+
);
|
|
360
|
+
} catch {
|
|
361
|
+
}
|
|
362
|
+
}
|
|
316
363
|
const cancelled = await agent.cancel(sessionId);
|
|
317
364
|
if (!cancelled) {
|
|
318
365
|
agent.logger.debug(`No in-flight run to cancel for session: ${sessionId}`);
|
|
319
366
|
}
|
|
320
|
-
return ctx.json({
|
|
367
|
+
return ctx.json({
|
|
368
|
+
cancelled,
|
|
369
|
+
sessionId,
|
|
370
|
+
queueCleared: clearQueue,
|
|
371
|
+
clearedCount
|
|
372
|
+
});
|
|
321
373
|
}).openapi(loadRoute, async (ctx) => {
|
|
322
|
-
const agent = getAgent();
|
|
374
|
+
const agent = await getAgent(ctx);
|
|
323
375
|
const { sessionId } = ctx.req.valid("param");
|
|
324
376
|
const sessionIds = await agent.listSessions();
|
|
325
377
|
if (!sessionIds.includes(sessionId)) {
|
|
326
378
|
return ctx.json({ error: `Session not found: ${sessionId}` }, 404);
|
|
327
379
|
}
|
|
328
380
|
const metadata = await agent.getSessionMetadata(sessionId);
|
|
381
|
+
const isBusy = await agent.isSessionBusy(sessionId);
|
|
329
382
|
return ctx.json(
|
|
330
383
|
{
|
|
331
384
|
session: {
|
|
@@ -333,13 +386,14 @@ function createSessionsRouter(getAgent) {
|
|
|
333
386
|
createdAt: metadata?.createdAt || null,
|
|
334
387
|
lastActivity: metadata?.lastActivity || null,
|
|
335
388
|
messageCount: metadata?.messageCount || 0,
|
|
336
|
-
title: metadata?.title || null
|
|
389
|
+
title: metadata?.title || null,
|
|
390
|
+
isBusy
|
|
337
391
|
}
|
|
338
392
|
},
|
|
339
393
|
200
|
|
340
394
|
);
|
|
341
395
|
}).openapi(patchRoute, async (ctx) => {
|
|
342
|
-
const agent = getAgent();
|
|
396
|
+
const agent = await getAgent(ctx);
|
|
343
397
|
const { sessionId } = ctx.req.valid("param");
|
|
344
398
|
const { title } = ctx.req.valid("json");
|
|
345
399
|
await agent.setSessionTitle(sessionId, title);
|
|
@@ -354,7 +408,7 @@ function createSessionsRouter(getAgent) {
|
|
|
354
408
|
}
|
|
355
409
|
});
|
|
356
410
|
}).openapi(generateTitleRoute, async (ctx) => {
|
|
357
|
-
const agent = getAgent();
|
|
411
|
+
const agent = await getAgent(ctx);
|
|
358
412
|
const { sessionId } = ctx.req.valid("param");
|
|
359
413
|
const title = await agent.generateSessionTitle(sessionId);
|
|
360
414
|
return ctx.json({ title, sessionId });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createSessionsRouter(getAgent:
|
|
2
|
+
import type { GetAgentFn } from '../index.js';
|
|
3
|
+
export declare function createSessionsRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
|
|
4
4
|
"/sessions": {
|
|
5
5
|
$get: {
|
|
6
6
|
input: {};
|
|
@@ -82,6 +82,19 @@ export declare function createSessionsRouter(getAgent: () => DextoAgent): OpenAP
|
|
|
82
82
|
mimeType: string;
|
|
83
83
|
data: string;
|
|
84
84
|
filename?: string | undefined;
|
|
85
|
+
} | {
|
|
86
|
+
type: "ui-resource";
|
|
87
|
+
mimeType: string;
|
|
88
|
+
uri: string;
|
|
89
|
+
content?: string | undefined;
|
|
90
|
+
blob?: string | undefined;
|
|
91
|
+
metadata?: {
|
|
92
|
+
title?: string | undefined;
|
|
93
|
+
preferredSize?: {
|
|
94
|
+
width: number;
|
|
95
|
+
height: number;
|
|
96
|
+
} | undefined;
|
|
97
|
+
} | undefined;
|
|
85
98
|
})[] | null;
|
|
86
99
|
role: "system" | "user" | "assistant" | "tool";
|
|
87
100
|
id?: string | undefined;
|
|
@@ -95,8 +108,7 @@ export declare function createSessionsRouter(getAgent: () => DextoAgent): OpenAP
|
|
|
95
108
|
totalTokens?: number | undefined;
|
|
96
109
|
} | undefined;
|
|
97
110
|
model?: string | undefined;
|
|
98
|
-
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
|
|
99
|
-
router?: "vercel" | "in-built" | undefined;
|
|
111
|
+
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | undefined;
|
|
100
112
|
toolCalls?: {
|
|
101
113
|
function: {
|
|
102
114
|
name: string;
|
|
@@ -106,7 +118,9 @@ export declare function createSessionsRouter(getAgent: () => DextoAgent): OpenAP
|
|
|
106
118
|
id: string;
|
|
107
119
|
}[] | undefined;
|
|
108
120
|
toolCallId?: string | undefined;
|
|
121
|
+
success?: boolean | undefined;
|
|
109
122
|
}[];
|
|
123
|
+
isBusy: boolean;
|
|
110
124
|
};
|
|
111
125
|
outputFormat: "json";
|
|
112
126
|
status: 200;
|
|
@@ -135,10 +149,16 @@ export declare function createSessionsRouter(getAgent: () => DextoAgent): OpenAP
|
|
|
135
149
|
param: {
|
|
136
150
|
sessionId: string;
|
|
137
151
|
};
|
|
152
|
+
} & {
|
|
153
|
+
json: {
|
|
154
|
+
clearQueue?: boolean | undefined;
|
|
155
|
+
};
|
|
138
156
|
};
|
|
139
157
|
output: {
|
|
140
158
|
sessionId: string;
|
|
141
159
|
cancelled: boolean;
|
|
160
|
+
queueCleared: boolean;
|
|
161
|
+
clearedCount: number;
|
|
142
162
|
};
|
|
143
163
|
outputFormat: "json";
|
|
144
164
|
status: 200;
|
|
@@ -158,6 +178,7 @@ export declare function createSessionsRouter(getAgent: () => DextoAgent): OpenAP
|
|
|
158
178
|
createdAt: number | null;
|
|
159
179
|
lastActivity: number | null;
|
|
160
180
|
messageCount: number;
|
|
181
|
+
isBusy: boolean;
|
|
161
182
|
title?: string | null | undefined;
|
|
162
183
|
};
|
|
163
184
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQ9C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAiexD"}
|