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 { type Static, type TSchema, Type } from "@sinclair/typebox";
|
||||||
import { SESSION_LABEL_MAX_LENGTH } from "../../sessions/session-label.js";
|
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 NonEmptyString = Type.String({ minLength: 1 });
|
||||||
const SessionLabelString = Type.String({
|
const SessionLabelString = Type.String({
|
||||||
@@ -8,10 +7,6 @@ const SessionLabelString = Type.String({
|
|||||||
maxLength: SESSION_LABEL_MAX_LENGTH,
|
maxLength: SESSION_LABEL_MAX_LENGTH,
|
||||||
});
|
});
|
||||||
|
|
||||||
const AgentProviderSchema = Type.Union(
|
|
||||||
GATEWAY_AGENT_PROVIDER_VALUES.map((provider) => Type.Literal(provider)),
|
|
||||||
);
|
|
||||||
|
|
||||||
export const PresenceEntrySchema = Type.Object(
|
export const PresenceEntrySchema = Type.Object(
|
||||||
{
|
{
|
||||||
host: Type.Optional(NonEmptyString),
|
host: Type.Optional(NonEmptyString),
|
||||||
@@ -230,7 +225,7 @@ export const AgentParamsSchema = Type.Object(
|
|||||||
sessionKey: Type.Optional(Type.String()),
|
sessionKey: Type.Optional(Type.String()),
|
||||||
thinking: Type.Optional(Type.String()),
|
thinking: Type.Optional(Type.String()),
|
||||||
deliver: Type.Optional(Type.Boolean()),
|
deliver: Type.Optional(Type.Boolean()),
|
||||||
provider: Type.Optional(AgentProviderSchema),
|
provider: Type.Optional(Type.String()),
|
||||||
timeout: Type.Optional(Type.Integer({ minimum: 0 })),
|
timeout: Type.Optional(Type.Integer({ minimum: 0 })),
|
||||||
lane: Type.Optional(Type.String()),
|
lane: Type.Optional(Type.String()),
|
||||||
extraSystemPrompt: Type.Optional(Type.String()),
|
extraSystemPrompt: Type.Optional(Type.String()),
|
||||||
|
|||||||
@@ -70,6 +70,26 @@ export const agentHandlers: GatewayRequestHandlers = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const message = request.message.trim();
|
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 =
|
const requestedSessionKey =
|
||||||
typeof request.sessionKey === "string" && request.sessionKey.trim()
|
typeof request.sessionKey === "string" && request.sessionKey.trim()
|
||||||
|
|||||||
Reference in New Issue
Block a user