fix(protocol): keep agent provider string
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { type Static, type TSchema, Type } from "@sinclair/typebox";
|
||||
import { SESSION_LABEL_MAX_LENGTH } from "../../sessions/session-label.js";
|
||||
import { GATEWAY_AGENT_PROVIDER_VALUES } from "../../utils/message-provider.js";
|
||||
|
||||
const NonEmptyString = Type.String({ minLength: 1 });
|
||||
const SessionLabelString = Type.String({
|
||||
@@ -8,10 +7,6 @@ const SessionLabelString = Type.String({
|
||||
maxLength: SESSION_LABEL_MAX_LENGTH,
|
||||
});
|
||||
|
||||
const AgentProviderSchema = Type.Union(
|
||||
GATEWAY_AGENT_PROVIDER_VALUES.map((provider) => Type.Literal(provider)),
|
||||
);
|
||||
|
||||
export const PresenceEntrySchema = Type.Object(
|
||||
{
|
||||
host: Type.Optional(NonEmptyString),
|
||||
@@ -230,7 +225,7 @@ export const AgentParamsSchema = Type.Object(
|
||||
sessionKey: Type.Optional(Type.String()),
|
||||
thinking: Type.Optional(Type.String()),
|
||||
deliver: Type.Optional(Type.Boolean()),
|
||||
provider: Type.Optional(AgentProviderSchema),
|
||||
provider: Type.Optional(Type.String()),
|
||||
timeout: Type.Optional(Type.Integer({ minimum: 0 })),
|
||||
lane: Type.Optional(Type.String()),
|
||||
extraSystemPrompt: Type.Optional(Type.String()),
|
||||
|
||||
@@ -70,6 +70,26 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
return;
|
||||
}
|
||||
const message = request.message.trim();
|
||||
const rawProvider =
|
||||
typeof request.provider === "string" ? request.provider.trim() : "";
|
||||
if (rawProvider) {
|
||||
const normalized = normalizeMessageProvider(rawProvider);
|
||||
if (
|
||||
normalized &&
|
||||
normalized !== "last" &&
|
||||
!isGatewayMessageProvider(normalized)
|
||||
) {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
errorShape(
|
||||
ErrorCodes.INVALID_REQUEST,
|
||||
`invalid agent params: unknown provider: ${normalized}`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const requestedSessionKey =
|
||||
typeof request.sessionKey === "string" && request.sessionKey.trim()
|
||||
|
||||
Reference in New Issue
Block a user