@dexto/server 1.7.2 → 1.8.1
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.d.ts +1 -1
- package/dist/events/usage-event-subscriber.cjs +3 -2
- package/dist/events/usage-event-subscriber.d.ts.map +1 -1
- package/dist/events/usage-event-subscriber.js +1 -2
- package/dist/events/usage-event-types.d.ts +1 -1
- package/dist/events/usage-event-types.d.ts.map +1 -1
- package/dist/hono/index.cjs +13 -3
- package/dist/hono/index.d.ts +2 -1
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +13 -3
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/approvals.cjs +1 -1
- package/dist/hono/routes/approvals.js +1 -1
- package/dist/hono/routes/discovery.cjs +18 -22
- package/dist/hono/routes/discovery.d.ts +8 -33
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +18 -22
- package/dist/hono/routes/key.cjs +5 -5
- package/dist/hono/routes/key.js +1 -1
- package/dist/hono/routes/llm.cjs +29 -29
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +11 -6
- package/dist/hono/routes/messages.cjs +23 -13
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +23 -13
- package/dist/hono/routes/prompts.d.ts +0 -45
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/queue.cjs +193 -82
- package/dist/hono/routes/queue.d.ts +2456 -21
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +193 -82
- package/dist/hono/routes/sessions.cjs +13 -14
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +13 -14
- package/dist/hono/routes/skills.cjs +116 -0
- package/dist/hono/routes/skills.d.ts +602 -0
- package/dist/hono/routes/skills.d.ts.map +1 -0
- package/dist/hono/routes/skills.js +97 -0
- package/dist/hono/routes/static.cjs +6 -1
- package/dist/hono/routes/static.d.ts +1 -1
- package/dist/hono/routes/static.d.ts.map +1 -1
- package/dist/hono/routes/static.js +6 -1
- package/dist/hono/schemas/responses.cjs +18 -17
- package/dist/hono/schemas/responses.d.ts +13 -18
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +13 -17
- package/package.json +8 -7
package/dist/hono/routes/llm.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(llm_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(llm_exports);
|
|
24
24
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
25
25
|
var import_core = require("@dexto/core");
|
|
26
|
-
var
|
|
26
|
+
var import_llm = require("@dexto/llm");
|
|
27
27
|
var import_agent_management = require("@dexto/agent-management");
|
|
28
28
|
var import_responses = require("../schemas/responses.js");
|
|
29
29
|
const MODEL_PICKER_FEATURED_LIMIT = 8;
|
|
@@ -43,28 +43,28 @@ const CatalogQuerySchema = import_zod_openapi.z.object({
|
|
|
43
43
|
hasKey: import_zod_openapi.z.union([import_zod_openapi.z.literal("true"), import_zod_openapi.z.literal("false"), import_zod_openapi.z.literal("1"), import_zod_openapi.z.literal("0")]).optional().transform(
|
|
44
44
|
(raw) => raw === "true" || raw === "1" ? true : raw === "false" || raw === "0" ? false : void 0
|
|
45
45
|
).describe("Filter by API key presence (true or false)"),
|
|
46
|
-
fileType: import_zod_openapi.z.enum(
|
|
46
|
+
fileType: import_zod_openapi.z.enum(import_llm.SUPPORTED_FILE_TYPES).optional().describe("Filter by supported file type (audio, pdf, image, video, or document)"),
|
|
47
47
|
defaultOnly: import_zod_openapi.z.union([import_zod_openapi.z.literal("true"), import_zod_openapi.z.literal("false"), import_zod_openapi.z.literal("1"), import_zod_openapi.z.literal("0")]).optional().transform(
|
|
48
48
|
(raw) => raw === "true" || raw === "1" ? true : raw === "false" || raw === "0" ? false : void 0
|
|
49
49
|
).describe("Include only default models (true or false)"),
|
|
50
50
|
mode: import_zod_openapi.z.enum(["grouped", "flat"]).default("grouped").describe("Response format mode (grouped by provider or flat list)")
|
|
51
51
|
}).strict().describe("Query parameters for filtering and formatting the LLM catalog");
|
|
52
|
-
const SwitchLLMBodySchema =
|
|
52
|
+
const SwitchLLMBodySchema = import_core.LLMUpdatesSchema.and(
|
|
53
53
|
import_zod_openapi.z.object({
|
|
54
54
|
sessionId: import_zod_openapi.z.string().optional().describe("Session identifier for session-specific LLM configuration")
|
|
55
55
|
})
|
|
56
56
|
).describe("LLM switch request body with optional session ID and LLM fields");
|
|
57
57
|
const ModelPickerModelRefSchema = import_zod_openapi.z.object({
|
|
58
|
-
provider: import_zod_openapi.z.enum(
|
|
58
|
+
provider: import_zod_openapi.z.enum(import_llm.LLM_PROVIDERS).describe("LLM provider"),
|
|
59
59
|
model: import_zod_openapi.z.string().trim().min(1).describe("Model ID"),
|
|
60
60
|
baseURL: import_zod_openapi.z.string().trim().url().optional().describe("Variant-specific base URL")
|
|
61
61
|
}).strict().describe("Provider/model pair for model picker state operations");
|
|
62
62
|
const ModelPickerEntrySchema = import_zod_openapi.z.object({
|
|
63
|
-
provider: import_zod_openapi.z.enum(
|
|
63
|
+
provider: import_zod_openapi.z.enum(import_llm.LLM_PROVIDERS).describe("LLM provider"),
|
|
64
64
|
model: import_zod_openapi.z.string().describe("Model ID"),
|
|
65
65
|
baseURL: import_zod_openapi.z.string().url().optional().describe("Variant-specific base URL"),
|
|
66
66
|
displayName: import_zod_openapi.z.string().optional().describe("Human-readable model name"),
|
|
67
|
-
supportedFileTypes: import_zod_openapi.z.array(import_zod_openapi.z.enum(
|
|
67
|
+
supportedFileTypes: import_zod_openapi.z.array(import_zod_openapi.z.enum(import_llm.SUPPORTED_FILE_TYPES)).describe("File types supported by this model"),
|
|
68
68
|
source: import_zod_openapi.z.enum(["catalog", "custom", "local-installed"]).describe("Where this model comes from")
|
|
69
69
|
}).strict().describe("Hydrated model picker entry");
|
|
70
70
|
const ModelPickerErrorSchema = import_responses.StandardErrorEnvelopeSchema.describe(
|
|
@@ -97,7 +97,7 @@ const ModelPickerErrorResponses = {
|
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
const CapabilitiesQuerySchema = import_zod_openapi.z.object({
|
|
100
|
-
provider: import_zod_openapi.z.enum(
|
|
100
|
+
provider: import_zod_openapi.z.enum(import_llm.LLM_PROVIDERS).describe("LLM provider name"),
|
|
101
101
|
model: import_zod_openapi.z.string().min(1).describe("Model name (supports both native and OpenRouter format)")
|
|
102
102
|
}).strict().describe("Query parameters for model capability lookup");
|
|
103
103
|
const SetFavoritesBodySchema = import_zod_openapi.z.object({
|
|
@@ -147,7 +147,7 @@ const catalogRoute = (0, import_zod_openapi.createRoute)({
|
|
|
147
147
|
"application/json": {
|
|
148
148
|
schema: import_zod_openapi.z.union([
|
|
149
149
|
import_zod_openapi.z.object({
|
|
150
|
-
providers: import_zod_openapi.z.partialRecord(import_zod_openapi.z.enum(
|
|
150
|
+
providers: import_zod_openapi.z.partialRecord(import_zod_openapi.z.enum(import_llm.LLM_PROVIDERS), import_responses.ProviderCatalogSchema).describe(
|
|
151
151
|
"Providers grouped by ID with their models and capabilities"
|
|
152
152
|
)
|
|
153
153
|
}).strict().describe("Grouped catalog response (mode=grouped)"),
|
|
@@ -294,9 +294,9 @@ const capabilitiesRoute = (0, import_zod_openapi.createRoute)({
|
|
|
294
294
|
content: {
|
|
295
295
|
"application/json": {
|
|
296
296
|
schema: import_zod_openapi.z.object({
|
|
297
|
-
provider: import_zod_openapi.z.enum(
|
|
297
|
+
provider: import_zod_openapi.z.enum(import_llm.LLM_PROVIDERS).describe("Provider name"),
|
|
298
298
|
model: import_zod_openapi.z.string().describe("Model name as provided"),
|
|
299
|
-
supportedFileTypes: import_zod_openapi.z.array(import_zod_openapi.z.enum(
|
|
299
|
+
supportedFileTypes: import_zod_openapi.z.array(import_zod_openapi.z.enum(import_llm.SUPPORTED_FILE_TYPES)).describe("File types supported by this model"),
|
|
300
300
|
reasoning: import_zod_openapi.z.object({
|
|
301
301
|
capable: import_zod_openapi.z.boolean().describe(
|
|
302
302
|
"Whether Dexto considers this provider/model reasoning-capable (derived from registry metadata plus explicit provider/model rules)"
|
|
@@ -482,7 +482,7 @@ function createLlmRouter(getAgent) {
|
|
|
482
482
|
const byKey = /* @__PURE__ */ new Map();
|
|
483
483
|
const customSection = [];
|
|
484
484
|
const hydrateStateEntry = (entry) => {
|
|
485
|
-
const providerInfo =
|
|
485
|
+
const providerInfo = import_llm.LLM_REGISTRY[entry.provider];
|
|
486
486
|
const modelInfo = providerInfo.models.find((model) => model.name === entry.model);
|
|
487
487
|
const supportedFileTypes = Array.isArray(modelInfo?.supportedFileTypes) && modelInfo.supportedFileTypes.length > 0 ? modelInfo.supportedFileTypes : providerInfo.supportedFileTypes;
|
|
488
488
|
const source = entry.provider === "local" ? "local-installed" : entry.baseURL ? "custom" : "catalog";
|
|
@@ -495,12 +495,12 @@ function createLlmRouter(getAgent) {
|
|
|
495
495
|
source
|
|
496
496
|
};
|
|
497
497
|
};
|
|
498
|
-
for (const provider of
|
|
498
|
+
for (const provider of import_llm.LLM_PROVIDERS) {
|
|
499
499
|
if (!isProviderEnabled(provider)) {
|
|
500
500
|
continue;
|
|
501
501
|
}
|
|
502
|
-
const providerInfo =
|
|
503
|
-
for (const model of (0,
|
|
502
|
+
const providerInfo = import_llm.LLM_REGISTRY[provider];
|
|
503
|
+
for (const model of (0, import_core.getAllModelsForProvider)(provider)) {
|
|
504
504
|
const supportedFileTypes = Array.isArray(model.supportedFileTypes) && model.supportedFileTypes.length > 0 ? model.supportedFileTypes : providerInfo.supportedFileTypes;
|
|
505
505
|
const entry = {
|
|
506
506
|
provider,
|
|
@@ -521,7 +521,7 @@ function createLlmRouter(getAgent) {
|
|
|
521
521
|
if (!isProviderEnabled(provider)) {
|
|
522
522
|
continue;
|
|
523
523
|
}
|
|
524
|
-
const providerInfo =
|
|
524
|
+
const providerInfo = import_llm.LLM_REGISTRY[provider];
|
|
525
525
|
const entry = {
|
|
526
526
|
provider,
|
|
527
527
|
model: customModel.name,
|
|
@@ -533,10 +533,10 @@ function createLlmRouter(getAgent) {
|
|
|
533
533
|
byKey.set((0, import_agent_management.toModelPickerKey)(entry), entry);
|
|
534
534
|
customSection.push(entry);
|
|
535
535
|
}
|
|
536
|
-
const localProviderSupportedFileTypes =
|
|
536
|
+
const localProviderSupportedFileTypes = import_llm.LLM_REGISTRY.local.supportedFileTypes;
|
|
537
537
|
const installedLocalModels = await (0, import_agent_management.getAllInstalledModels)();
|
|
538
538
|
for (const installedModel of installedLocalModels) {
|
|
539
|
-
const modelInfo = (0,
|
|
539
|
+
const modelInfo = (0, import_core.getLocalModelById)(installedModel.id);
|
|
540
540
|
const entry = {
|
|
541
541
|
provider: "local",
|
|
542
542
|
model: installedModel.id,
|
|
@@ -546,8 +546,8 @@ function createLlmRouter(getAgent) {
|
|
|
546
546
|
};
|
|
547
547
|
byKey.set((0, import_agent_management.toModelPickerKey)(entry), entry);
|
|
548
548
|
}
|
|
549
|
-
const featuredProviders =
|
|
550
|
-
const featured = (0,
|
|
549
|
+
const featuredProviders = import_llm.LLM_PROVIDERS.filter((provider) => isProviderEnabled(provider));
|
|
550
|
+
const featured = (0, import_core.getCuratedModelRefsForProviders)({
|
|
551
551
|
providers: featuredProviders,
|
|
552
552
|
max: MODEL_PICKER_FEATURED_LIMIT
|
|
553
553
|
}).map((ref) => byKey.get((0, import_agent_management.toModelPickerKey)(ref))).filter((entry) => Boolean(entry));
|
|
@@ -588,7 +588,7 @@ function createLlmRouter(getAgent) {
|
|
|
588
588
|
const currentConfig = sessionId ? agent.getEffectiveConfig(sessionId).llm : agent.getCurrentLLMConfig();
|
|
589
589
|
let displayName;
|
|
590
590
|
try {
|
|
591
|
-
const model =
|
|
591
|
+
const model = import_llm.LLM_REGISTRY[currentConfig.provider]?.models.find(
|
|
592
592
|
(m) => m.name.toLowerCase() === String(currentConfig.model).toLowerCase()
|
|
593
593
|
);
|
|
594
594
|
displayName = model?.displayName || void 0;
|
|
@@ -621,25 +621,25 @@ function createLlmRouter(getAgent) {
|
|
|
621
621
|
const includeModels = queryParams.includeModels ?? true;
|
|
622
622
|
const scope = queryParams.scope ?? "all";
|
|
623
623
|
const providers = {};
|
|
624
|
-
for (const provider of
|
|
624
|
+
for (const provider of import_llm.LLM_PROVIDERS) {
|
|
625
625
|
if (provider === "dexto-nova" && !(0, import_agent_management.isDextoAuthEnabled)()) {
|
|
626
626
|
continue;
|
|
627
627
|
}
|
|
628
|
-
const info =
|
|
628
|
+
const info = import_llm.LLM_REGISTRY[provider];
|
|
629
629
|
const displayName = provider === "dexto-nova" ? "Dexto Nova" : provider.charAt(0).toUpperCase() + provider.slice(1);
|
|
630
630
|
const keyStatus = (0, import_agent_management.getProviderKeyStatus)(provider);
|
|
631
631
|
const models = (() => {
|
|
632
632
|
if (!includeModels) return [];
|
|
633
633
|
if (scope === "all") {
|
|
634
|
-
return (0,
|
|
634
|
+
return (0, import_core.getAllModelsForProvider)(provider);
|
|
635
635
|
}
|
|
636
|
-
return (0,
|
|
636
|
+
return (0, import_core.getCuratedModelsForProvider)(provider);
|
|
637
637
|
})();
|
|
638
638
|
providers[provider] = {
|
|
639
639
|
name: displayName,
|
|
640
640
|
hasApiKey: keyStatus.hasApiKey,
|
|
641
641
|
primaryEnvVar: keyStatus.envVar,
|
|
642
|
-
supportsBaseURL: (0,
|
|
642
|
+
supportsBaseURL: (0, import_llm.supportsBaseURL)(provider),
|
|
643
643
|
models,
|
|
644
644
|
supportedFileTypes: info.supportedFileTypes
|
|
645
645
|
};
|
|
@@ -648,7 +648,7 @@ function createLlmRouter(getAgent) {
|
|
|
648
648
|
if (queryParams.provider && queryParams.provider.length > 0) {
|
|
649
649
|
const allowed = new Set(
|
|
650
650
|
queryParams.provider.filter(
|
|
651
|
-
(p) =>
|
|
651
|
+
(p) => import_llm.LLM_PROVIDERS.includes(p)
|
|
652
652
|
)
|
|
653
653
|
);
|
|
654
654
|
const filteredByProvider = {};
|
|
@@ -779,12 +779,12 @@ function createLlmRouter(getAgent) {
|
|
|
779
779
|
const { provider, model } = ctx.req.valid("query");
|
|
780
780
|
let supportedFileTypes;
|
|
781
781
|
try {
|
|
782
|
-
supportedFileTypes = (0,
|
|
782
|
+
supportedFileTypes = (0, import_core.getSupportedFileTypesForModel)(provider, model);
|
|
783
783
|
} catch {
|
|
784
|
-
const providerInfo =
|
|
784
|
+
const providerInfo = import_llm.LLM_REGISTRY[provider];
|
|
785
785
|
supportedFileTypes = providerInfo?.supportedFileTypes ?? [];
|
|
786
786
|
}
|
|
787
|
-
const reasoning = (0,
|
|
787
|
+
const reasoning = (0, import_llm.getReasoningProfile)(provider, model);
|
|
788
788
|
return ctx.json(
|
|
789
789
|
{
|
|
790
790
|
provider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAuBhE,OAAO,EAaH,iBAAiB,EAEpB,MAAM,yBAAyB,CAAC;AAWjC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGlE,QAAA,MAAM,kBAAkB;;kBAQ+C,CAAC;AAExE,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;kBA0DsD,CAAC;AAI/E,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAOoD,CAAC;AAE9E,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;kBAOuC,CAAC;AAiDvE,QAAA,MAAM,uBAAuB;;;;;;;;;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CAAA;CAAE,CACnD,CAAC;AAEF,MAAM,MAAM,eAAe,GACrB,kBAAkB,GAClB,kBAAkB,GAClB,iBAAiB,GACjB,2BAA2B,GAC3B,4BAA4B,GAC5B,4BAA4B,GAC5B,uBAAuB,GACvB,2BAA2B,GAC3B,4BAA4B,GAC5B,8BAA8B,GAC9B,uBAAuB,CAAC"}
|
package/dist/hono/routes/llm.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
-
import { DextoRuntimeError, ErrorScope, ErrorType, logger } from "@dexto/core";
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
DextoRuntimeError,
|
|
4
|
+
ErrorScope,
|
|
5
|
+
ErrorType,
|
|
6
|
+
logger,
|
|
8
7
|
getAllModelsForProvider,
|
|
9
8
|
getCuratedModelsForProvider,
|
|
10
9
|
getCuratedModelRefsForProviders,
|
|
11
10
|
getSupportedFileTypesForModel,
|
|
12
11
|
getLocalModelById,
|
|
13
|
-
getReasoningProfile,
|
|
14
12
|
LLMUpdatesSchema
|
|
15
13
|
} from "@dexto/core";
|
|
14
|
+
import {
|
|
15
|
+
LLM_REGISTRY,
|
|
16
|
+
LLM_PROVIDERS,
|
|
17
|
+
SUPPORTED_FILE_TYPES,
|
|
18
|
+
getReasoningProfile,
|
|
19
|
+
supportsBaseURL
|
|
20
|
+
} from "@dexto/llm";
|
|
16
21
|
import {
|
|
17
22
|
getProviderKeyStatus,
|
|
18
23
|
loadCustomModels,
|
|
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(messages_exports);
|
|
|
24
24
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
25
25
|
var import_streaming = require("hono/streaming");
|
|
26
26
|
var import_core = require("@dexto/core");
|
|
27
|
+
var import_llm = require("@dexto/llm");
|
|
27
28
|
var import_responses = require("../schemas/responses.js");
|
|
28
29
|
const MessageBodySchema = import_zod_openapi.z.object({
|
|
29
30
|
content: import_responses.RequestContentSchema,
|
|
@@ -48,7 +49,7 @@ const MessageSyncResponseSchema = import_zod_openapi.z.object({
|
|
|
48
49
|
),
|
|
49
50
|
reasoning: import_zod_openapi.z.string().optional().describe("Extended thinking content from reasoning models"),
|
|
50
51
|
model: import_zod_openapi.z.string().optional().describe("Model used for this response"),
|
|
51
|
-
provider: import_zod_openapi.z.enum(
|
|
52
|
+
provider: import_zod_openapi.z.enum(import_llm.LLM_PROVIDERS).optional().describe("LLM provider"),
|
|
52
53
|
hostRuntime: import_core.HostRuntimeContextSchema.optional().describe(
|
|
53
54
|
"Host-owned runtime IDs surfaced by core runtime flows"
|
|
54
55
|
)
|
|
@@ -60,7 +61,7 @@ const ResetResponseSchema = import_zod_openapi.z.object({
|
|
|
60
61
|
const MessageStreamBusyResponseSchema = import_zod_openapi.z.object({
|
|
61
62
|
busy: import_zod_openapi.z.literal(true).describe("Indicates session is busy"),
|
|
62
63
|
sessionId: import_zod_openapi.z.string().describe("The session ID"),
|
|
63
|
-
queueLength: import_zod_openapi.z.number().describe("Current number of
|
|
64
|
+
queueLength: import_zod_openapi.z.number().describe("Current number of queued follow-up messages"),
|
|
64
65
|
hint: import_zod_openapi.z.string().describe("Instructions for the client")
|
|
65
66
|
}).strict().describe("Busy response for streaming requests");
|
|
66
67
|
const messageRoute = (0, import_zod_openapi.createRoute)({
|
|
@@ -179,7 +180,7 @@ const messageStreamRoute = (0, import_zod_openapi.createRoute)({
|
|
|
179
180
|
}
|
|
180
181
|
},
|
|
181
182
|
202: {
|
|
182
|
-
description: "Session is busy processing another message. Use the
|
|
183
|
+
description: "Session is busy processing another message. Use the follow-up endpoint to queue input for the next turn.",
|
|
183
184
|
content: {
|
|
184
185
|
"application/json": {
|
|
185
186
|
schema: MessageStreamBusyResponseSchema
|
|
@@ -242,13 +243,13 @@ function createMessagesRouter(getAgent, _approvalCoordinator) {
|
|
|
242
243
|
const content = (0, import_responses.toContentInput)(rawContent);
|
|
243
244
|
const isBusy = await agent.isSessionBusy(sessionId);
|
|
244
245
|
if (isBusy) {
|
|
245
|
-
const
|
|
246
|
+
const followUpMessages = await agent.getFollowUpMessages(sessionId);
|
|
246
247
|
return ctx.json(
|
|
247
248
|
{
|
|
248
249
|
busy: true,
|
|
249
250
|
sessionId,
|
|
250
|
-
queueLength:
|
|
251
|
-
hint: "Use POST /api/
|
|
251
|
+
queueLength: followUpMessages.length,
|
|
252
|
+
hint: "Use POST /api/follow-up/{sessionId} to queue a follow-up message, or wait for the current request to complete."
|
|
252
253
|
},
|
|
253
254
|
202
|
|
254
255
|
);
|
|
@@ -290,8 +291,15 @@ function createMessagesRouter(getAgent, _approvalCoordinator) {
|
|
|
290
291
|
});
|
|
291
292
|
return writeChain;
|
|
292
293
|
};
|
|
294
|
+
let sawFatalStreamError = false;
|
|
293
295
|
try {
|
|
294
296
|
for await (const event of iterator) {
|
|
297
|
+
if (event.name === "llm:error" && event.recoverable !== true) {
|
|
298
|
+
sawFatalStreamError = true;
|
|
299
|
+
}
|
|
300
|
+
if (event.name === "run:complete" && event.finishReason === "error") {
|
|
301
|
+
sawFatalStreamError = true;
|
|
302
|
+
}
|
|
295
303
|
const eventData = event.name === "llm:error" && event.error instanceof Error ? {
|
|
296
304
|
...event,
|
|
297
305
|
error: {
|
|
@@ -303,13 +311,15 @@ function createMessagesRouter(getAgent, _approvalCoordinator) {
|
|
|
303
311
|
await enqueueSSEWrite(event.name, eventData);
|
|
304
312
|
}
|
|
305
313
|
} catch (error) {
|
|
306
|
-
|
|
307
|
-
error
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
314
|
+
if (!sawFatalStreamError) {
|
|
315
|
+
await enqueueSSEWrite("llm:error", {
|
|
316
|
+
error: {
|
|
317
|
+
message: error instanceof Error ? error.message : String(error)
|
|
318
|
+
},
|
|
319
|
+
recoverable: false,
|
|
320
|
+
sessionId
|
|
321
|
+
});
|
|
322
|
+
}
|
|
313
323
|
} finally {
|
|
314
324
|
requestDisconnectSignal.removeEventListener("abort", abortOnDisconnect);
|
|
315
325
|
abortController.abort();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,KAAK,0BAA0B,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEjG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,KAAK,0BAA0B,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEjG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAa3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;iBAQyC,CAAC;AAEjE,QAAA,MAAM,eAAe;;iBAOqC,CAAC;AA2D3D,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BhB,CAAC;AAEH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,CAAC,CACtD,CAAC;AAEF,KAAK,gBAAgB,GAAG,QAAQ,CAC5B,MAAM,EACN,QAAQ,EACR;IAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;CAAE,EACzC,0BAA0B,CAAC,OAAO,UAAU,CAAC,CAChD,CAAC;AAEF,KAAK,wBAAwB,GAAG,QAAQ,CACpC,MAAM,EACN,iBAAiB,EACjB;IAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;CAAE,EAC3C,0BAA0B,CAAC,OAAO,kBAAkB,CAAC,CACxD,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC1B,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,wBAAwB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
2
|
import { streamSSE } from "hono/streaming";
|
|
3
|
-
import { HostRuntimeContextSchema
|
|
3
|
+
import { HostRuntimeContextSchema } from "@dexto/core";
|
|
4
|
+
import { LLM_PROVIDERS } from "@dexto/llm";
|
|
4
5
|
import {
|
|
5
6
|
ApiErrorResponseSchema,
|
|
6
7
|
BadRequestErrorResponse,
|
|
@@ -46,7 +47,7 @@ const ResetResponseSchema = z.object({
|
|
|
46
47
|
const MessageStreamBusyResponseSchema = z.object({
|
|
47
48
|
busy: z.literal(true).describe("Indicates session is busy"),
|
|
48
49
|
sessionId: z.string().describe("The session ID"),
|
|
49
|
-
queueLength: z.number().describe("Current number of
|
|
50
|
+
queueLength: z.number().describe("Current number of queued follow-up messages"),
|
|
50
51
|
hint: z.string().describe("Instructions for the client")
|
|
51
52
|
}).strict().describe("Busy response for streaming requests");
|
|
52
53
|
const messageRoute = createRoute({
|
|
@@ -165,7 +166,7 @@ const messageStreamRoute = createRoute({
|
|
|
165
166
|
}
|
|
166
167
|
},
|
|
167
168
|
202: {
|
|
168
|
-
description: "Session is busy processing another message. Use the
|
|
169
|
+
description: "Session is busy processing another message. Use the follow-up endpoint to queue input for the next turn.",
|
|
169
170
|
content: {
|
|
170
171
|
"application/json": {
|
|
171
172
|
schema: MessageStreamBusyResponseSchema
|
|
@@ -228,13 +229,13 @@ function createMessagesRouter(getAgent, _approvalCoordinator) {
|
|
|
228
229
|
const content = toContentInput(rawContent);
|
|
229
230
|
const isBusy = await agent.isSessionBusy(sessionId);
|
|
230
231
|
if (isBusy) {
|
|
231
|
-
const
|
|
232
|
+
const followUpMessages = await agent.getFollowUpMessages(sessionId);
|
|
232
233
|
return ctx.json(
|
|
233
234
|
{
|
|
234
235
|
busy: true,
|
|
235
236
|
sessionId,
|
|
236
|
-
queueLength:
|
|
237
|
-
hint: "Use POST /api/
|
|
237
|
+
queueLength: followUpMessages.length,
|
|
238
|
+
hint: "Use POST /api/follow-up/{sessionId} to queue a follow-up message, or wait for the current request to complete."
|
|
238
239
|
},
|
|
239
240
|
202
|
|
240
241
|
);
|
|
@@ -276,8 +277,15 @@ function createMessagesRouter(getAgent, _approvalCoordinator) {
|
|
|
276
277
|
});
|
|
277
278
|
return writeChain;
|
|
278
279
|
};
|
|
280
|
+
let sawFatalStreamError = false;
|
|
279
281
|
try {
|
|
280
282
|
for await (const event of iterator) {
|
|
283
|
+
if (event.name === "llm:error" && event.recoverable !== true) {
|
|
284
|
+
sawFatalStreamError = true;
|
|
285
|
+
}
|
|
286
|
+
if (event.name === "run:complete" && event.finishReason === "error") {
|
|
287
|
+
sawFatalStreamError = true;
|
|
288
|
+
}
|
|
281
289
|
const eventData = event.name === "llm:error" && event.error instanceof Error ? {
|
|
282
290
|
...event,
|
|
283
291
|
error: {
|
|
@@ -289,13 +297,15 @@ function createMessagesRouter(getAgent, _approvalCoordinator) {
|
|
|
289
297
|
await enqueueSSEWrite(event.name, eventData);
|
|
290
298
|
}
|
|
291
299
|
} catch (error) {
|
|
292
|
-
|
|
293
|
-
error
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
300
|
+
if (!sawFatalStreamError) {
|
|
301
|
+
await enqueueSSEWrite("llm:error", {
|
|
302
|
+
error: {
|
|
303
|
+
message: error instanceof Error ? error.message : String(error)
|
|
304
|
+
},
|
|
305
|
+
recoverable: false,
|
|
306
|
+
sessionId
|
|
307
|
+
});
|
|
308
|
+
}
|
|
299
309
|
} finally {
|
|
300
310
|
requestDisconnectSignal.removeEventListener("abort", abortOnDisconnect);
|
|
301
311
|
abortController.abort();
|
|
@@ -44,16 +44,7 @@ declare const listRoute: {
|
|
|
44
44
|
description: z.ZodOptional<z.ZodString>;
|
|
45
45
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
46
46
|
}, z.core.$strict>>>;
|
|
47
|
-
disableModelInvocation: z.ZodOptional<z.ZodBoolean>;
|
|
48
47
|
userInvocable: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
-
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
-
toolkits: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
51
|
-
model: z.ZodOptional<z.ZodString>;
|
|
52
|
-
context: z.ZodOptional<z.ZodEnum<{
|
|
53
|
-
inline: "inline";
|
|
54
|
-
fork: "fork";
|
|
55
|
-
}>>;
|
|
56
|
-
agent: z.ZodOptional<z.ZodString>;
|
|
57
48
|
source: z.ZodEnum<{
|
|
58
49
|
mcp: "mcp";
|
|
59
50
|
custom: "custom";
|
|
@@ -302,16 +293,7 @@ declare const createCustomRoute: {
|
|
|
302
293
|
description: z.ZodOptional<z.ZodString>;
|
|
303
294
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
304
295
|
}, z.core.$strict>>>;
|
|
305
|
-
disableModelInvocation: z.ZodOptional<z.ZodBoolean>;
|
|
306
296
|
userInvocable: z.ZodOptional<z.ZodBoolean>;
|
|
307
|
-
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
308
|
-
toolkits: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
309
|
-
model: z.ZodOptional<z.ZodString>;
|
|
310
|
-
context: z.ZodOptional<z.ZodEnum<{
|
|
311
|
-
inline: "inline";
|
|
312
|
-
fork: "fork";
|
|
313
|
-
}>>;
|
|
314
|
-
agent: z.ZodOptional<z.ZodString>;
|
|
315
297
|
source: z.ZodEnum<{
|
|
316
298
|
mcp: "mcp";
|
|
317
299
|
custom: "custom";
|
|
@@ -694,16 +676,7 @@ declare const getPromptRoute: {
|
|
|
694
676
|
description: z.ZodOptional<z.ZodString>;
|
|
695
677
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
696
678
|
}, z.core.$strict>>>;
|
|
697
|
-
disableModelInvocation: z.ZodOptional<z.ZodBoolean>;
|
|
698
679
|
userInvocable: z.ZodOptional<z.ZodBoolean>;
|
|
699
|
-
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
700
|
-
toolkits: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
701
|
-
model: z.ZodOptional<z.ZodString>;
|
|
702
|
-
context: z.ZodOptional<z.ZodEnum<{
|
|
703
|
-
inline: "inline";
|
|
704
|
-
fork: "fork";
|
|
705
|
-
}>>;
|
|
706
|
-
agent: z.ZodOptional<z.ZodString>;
|
|
707
680
|
}, z.core.$strict>;
|
|
708
681
|
}, z.core.$strict>;
|
|
709
682
|
};
|
|
@@ -1056,13 +1029,7 @@ export declare function createPromptsRouter(getAgent: GetAgentFn): OpenAPIHono<i
|
|
|
1056
1029
|
description?: string | undefined;
|
|
1057
1030
|
required?: boolean | undefined;
|
|
1058
1031
|
}[] | undefined;
|
|
1059
|
-
disableModelInvocation?: boolean | undefined;
|
|
1060
1032
|
userInvocable?: boolean | undefined;
|
|
1061
|
-
allowedTools?: string[] | undefined;
|
|
1062
|
-
toolkits?: string[] | undefined;
|
|
1063
|
-
model?: string | undefined;
|
|
1064
|
-
context?: "inline" | "fork" | undefined;
|
|
1065
|
-
agent?: string | undefined;
|
|
1066
1033
|
displayName?: string | undefined;
|
|
1067
1034
|
commandName?: string | undefined;
|
|
1068
1035
|
metadata?: {
|
|
@@ -1198,13 +1165,7 @@ export declare function createPromptsRouter(getAgent: GetAgentFn): OpenAPIHono<i
|
|
|
1198
1165
|
description?: string | undefined;
|
|
1199
1166
|
required?: boolean | undefined;
|
|
1200
1167
|
}[] | undefined;
|
|
1201
|
-
disableModelInvocation?: boolean | undefined;
|
|
1202
1168
|
userInvocable?: boolean | undefined;
|
|
1203
|
-
allowedTools?: string[] | undefined;
|
|
1204
|
-
toolkits?: string[] | undefined;
|
|
1205
|
-
model?: string | undefined;
|
|
1206
|
-
context?: "inline" | "fork" | undefined;
|
|
1207
|
-
agent?: string | undefined;
|
|
1208
1169
|
displayName?: string | undefined;
|
|
1209
1170
|
commandName?: string | undefined;
|
|
1210
1171
|
metadata?: {
|
|
@@ -1280,13 +1241,7 @@ export declare function createPromptsRouter(getAgent: GetAgentFn): OpenAPIHono<i
|
|
|
1280
1241
|
description?: string | undefined;
|
|
1281
1242
|
required?: boolean | undefined;
|
|
1282
1243
|
}[] | undefined;
|
|
1283
|
-
disableModelInvocation?: boolean | undefined;
|
|
1284
1244
|
userInvocable?: boolean | undefined;
|
|
1285
|
-
allowedTools?: string[] | undefined;
|
|
1286
|
-
toolkits?: string[] | undefined;
|
|
1287
|
-
model?: string | undefined;
|
|
1288
|
-
context?: "inline" | "fork" | undefined;
|
|
1289
|
-
agent?: string | undefined;
|
|
1290
1245
|
};
|
|
1291
1246
|
};
|
|
1292
1247
|
outputFormat: "json";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAShE,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAElE,QAAA,MAAM,yBAAyB;;;;;;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