import { defineComponent, ref, reactive, computed, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrRenderAttr, ssrInterpolate, ssrRenderStyle, ssrRenderClass, ssrRenderComponent } from 'vue/server-renderer'; import { u as useApi } from './useApi-BNSkSrat.mjs'; import { u as useToast } from './useToast-MBvLaNjH.mjs'; import { L as LANG_OPTIONS } from './useLangOptions-CXXbv5NM.mjs'; import { _ as __nuxt_component_0 } from './LangSelect-Bvw-e1Cn.mjs'; import { _ as _export_sfc } from './server.mjs'; import '../nitro/nitro.mjs'; import 'node:http'; import 'node:https'; import 'node:events'; import 'node:buffer'; import 'node:fs'; import 'node:path'; import 'node:crypto'; import 'node:url'; import '../routes/renderer.mjs'; import 'vue-bundle-renderer/runtime'; import 'unhead/server'; import 'devalue'; import 'unhead/utils'; import 'pinia'; import 'perfect-debounce'; const CAT_STT = 1; const CAT_TTS = 2; const CAT_MT = 3; const CAT_AST = 4; const CAT_LLM = 5; const CAT_STS = 7; const CAT_LLM_VISION = 9; const CAT_MCP = 10; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "agents", __ssrInlineRender: true, setup(__props) { const AGENT_TYPES = [ { value: "chat", label: "chat-agent 对话", icon: "💬", hint: "STT → LLM → TTS 三段拼接", color: "#b45309", bg: "#fef9c3" }, { value: "sts-chat", label: "sts-chat-agent 端到端对话", icon: "⚡", hint: "单个 STS 服务直接完成语音对话", color: "#be185d", bg: "#fce7f3" } ]; const LEGACY_TYPES = { translate: { label: "翻译(已下线)", icon: "🧩", color: "#64748b", bg: "#f1f5f9" }, "ast-translate": { label: "端到端翻译(已下线)", icon: "🚀", color: "#64748b", bg: "#f1f5f9" } }; const SLOTS = { chat: [ { key: "stt_svc_id", slot: "STT", label: "语音识别", cats: [CAT_STT], color: "#1664ff" }, { key: "llm_svc_id", slot: "LLM", label: "大语言模型", cats: [CAT_LLM, CAT_LLM_VISION], color: "#b45309" }, { key: "tts_svc_id", slot: "TTS", label: "语音合成", cats: [CAT_TTS], color: "#7c3aed" } ], translate: [ { key: "stt_svc_id", slot: "STT", label: "语音识别", cats: [CAT_STT], color: "#1664ff" }, { key: "mt_svc_id", slot: "MT", label: "机器翻译", cats: [CAT_MT], color: "#059669" }, { key: "tts_svc_id", slot: "TTS", label: "语音合成", cats: [CAT_TTS], color: "#7c3aed" } ], "sts-chat": [{ key: "sts_svc_id", slot: "STS", label: "端到端语音对话", cats: [CAT_STS], color: "#be185d" }], "ast-translate": [{ key: "ast_svc_id", slot: "AST", label: "端到端语音翻译", cats: [CAT_AST], color: "#f97316" }] }; function slotsOfType(t) { return SLOTS[t] ?? []; } useApi(); useToast(); const scopeApp = ref(""); const scopeApps = ref([]); const agents2 = ref([]); const allSvcs = ref([]); const ttsVoices = ref([]); const modalOpen = ref(false); const isEditing = ref(false); const submitting = ref(false); function emptyForm() { return { app_name: "", id: "", name: "", type: "chat", description: "", avatar_url: "", enable: true, stt_svc_id: "", llm_svc_id: "", tts_svc_id: "", mt_svc_id: "", sts_svc_id: "", ast_svc_id: "", system_prompt: "", gender: 0, greeting_enabled: false, greeting_text: "", support_langs: "", default_lang: "", voice_map: [], mcp_svc_ids: [], variables: [], sort: 0 }; } const form = reactive(emptyForm()); const isChatType = computed(() => form.type === "chat" || form.type === "sts-chat"); const supportedLangOptions = computed(() => { const codes = (form.support_langs || "").split(",").map((x) => x.trim()).filter(Boolean); if (!codes.length) return LANG_OPTIONS; return LANG_OPTIONS.filter((o) => codes.includes(o.code)); }); const bySort = (a, b) => (b.sort || 0) - (a.sort || 0) || (a.name || "").localeCompare(b.name || ""); const grouped = computed(() => { const groups = AGENT_TYPES.map((t) => ({ ...t, type: t.value, items: agents2.value.filter((a) => a.type === t.value).sort(bySort) })).filter((g) => g.items.length); for (const [type, meta] of Object.entries(LEGACY_TYPES)) { const items = agents2.value.filter((a) => a.type === type).sort(bySort); if (items.length) groups.push({ value: type, type, hint: "已下线的类型,仅供查看与清理", ...meta, items }); } return groups; }); const voiceSvcId = computed(() => form.type === "sts-chat" ? form.sts_svc_id : form.tts_svc_id); const voiceProvider = computed(() => allSvcs.value.find((s) => s.id === voiceSvcId.value)?.provider ?? ""); const voiceTableSupported = computed(() => !!voiceProvider.value && ttsVoices.value.some((v) => v.provider === voiceProvider.value)); function voiceOptions(language, gender) { const provider = voiceProvider.value; if (!provider || !language) return []; const base = (language.split("-")[0] || "").toLowerCase(); const hit = ttsVoices.value.filter((v) => { if (v.provider !== provider) return false; if (gender && v.gender !== gender) return false; return v.language.toLowerCase() === language.toLowerCase(); }); if (hit.length) return hit; return ttsVoices.value.filter((v) => { if (v.provider !== provider) return false; if (gender && v.gender !== gender) return false; return (v.language.split("-")[0] || "").toLowerCase() === base; }); } const mcpSvcs = computed(() => svcsByCats([CAT_MCP])); function svcCats(s) { return (s.categories || "").split(",").map(Number); } function svcsByCats(cats) { return allSvcs.value.filter((s) => s.enable && svcCats(s).some((c) => cats.includes(c))); } function isVisionSvc(s) { return svcCats(s).includes(CAT_LLM_VISION); } function svcName(id) { if (!id) return "未配置"; const s = allSvcs.value.find((x) => x.id === id); return s ? s.name : id; } function pipelineOf(a) { return slotsOfType(a.type).map((s) => ({ slot: s.slot, color: s.color, id: a[s.key] })); } return (_ctx, _push, _parent, _attrs) => { _push(`

Agent 配置

把已配置的第三方服务编排成可下发客户端的智能体。四种类型按需引用不同服务;通话翻译规则只能引用「翻译」与「端到端翻译」两类。

作用域
`); if (!agents2.value.length) { _push(`
🤖

当前作用域下还没有 Agent

先在「第三方服务配置」里配好服务,再来把它们组装成 Agent

`); } else { _push(``); } _push(``); ssrRenderList(grouped.value, (g) => { _push(`
${ssrInterpolate(g.icon)} ${ssrInterpolate(g.label)}${ssrInterpolate(g.hint)}·${ssrInterpolate(g.items.length)} 个
`); ssrRenderList(g.items, (a) => { _push(`
${ssrInterpolate(a.name || a.id)}
${ssrInterpolate(a.id)}
`); if (a.enable) { _push(`启用`); } else { _push(`停用`); } _push(`
`); if (a.description) { _push(`

${ssrInterpolate(a.description)}

`); } else { _push(``); } _push(`
`); ssrRenderList(pipelineOf(a), (s) => { _push(`${ssrInterpolate(s.slot)}: ${ssrInterpolate(svcName(s.id))}`); }); _push(`
`); if (a.support_langs) { _push(`
支持语言:${ssrInterpolate(a.support_langs)}
`); } else { _push(``); } _push(`
`); }); _push(`
`); }); _push(`

${ssrInterpolate(isEditing.value ? "编辑 Agent" : "新建 Agent")}

${ssrInterpolate(scopeApp.value || "全局默认")}
类型
`); ssrRenderList(AGENT_TYPES, (t) => { _push(``); }); _push(`
`); if (isEditing.value) { _push(`

类型创建后不可更改;需要换类型请新建一个 Agent。

`); } else { _push(``); } _push(`
基本信息
Agent ID *
名称 *
描述
头像 URL
排序(越大越靠前)
音色性别偏好
服务编排
`); ssrRenderList(slotsOfType(form.type), (s, i) => { _push(`
${ssrInterpolate(s.slot)}${ssrInterpolate(s.label)}
`); if (i < slotsOfType(form.type).length - 1) { _push(`→`); } else { _push(``); } _push(``); }); _push(`
语言与音色
支持语言(多选)`); _push(ssrRenderComponent(__nuxt_component_0, { modelValue: form.support_langs, "onUpdate:modelValue": ($event) => form.support_langs = $event, multiple: "" }, null, _parent)); _push(`
默认语言`); _push(ssrRenderComponent(__nuxt_component_0, { modelValue: form.default_lang, "onUpdate:modelValue": ($event) => form.default_lang = $event, options: supportedLangOptions.value }, null, _parent)); _push(`
音色(按语言+性别配,Agent 切语言时自动换音色)

`); if (!voiceSvcId.value) { _push(`先在上方选好语音服务,这里才能列出可用音色。`); } else if (voiceTableSupported.value) { _push(` 候选来自内置音色表(${ssrInterpolate(voiceProvider.value)});同一语言+性别有多个时默认第一个,可在下拉里换。没配到的语言走服务商默认音色。 `); } else { _push(`「${ssrInterpolate(voiceProvider.value || "该服务商")}」不在内置音色表里,请手填服务商的音色 id。`); } _push(`

`); if (!form.voice_map.length) { _push(`
未设置,全部走服务商默认音色
`); } else { _push(``); } _push(``); ssrRenderList(form.voice_map, (v, i) => { _push(`
`); if (voiceTableSupported.value && voiceOptions(v.language, v.gender).length) { _push(``); } else { _push(``); } _push(`
`); }); _push(`
`); if (isChatType.value) { _push(`
对话设定
系统提示词
`); if (form.greeting_enabled) { _push(``); } else { _push(``); } _push(`
`); } else { _push(``); } _push(`
MCP 服务(可选,给 Agent 挂工具)
`); if (!mcpSvcs.value.length) { _push(`

还没有启用的 MCP 服务,先去「第三方服务配置 → MCP 服务」添加。

`); } else { _push(`
`); ssrRenderList(mcpSvcs.value, (m) => { _push(``); }); _push(`
`); } _push(`
变量(提示词/开场白里用 {{key}} 占位)
`); if (!form.variables.length) { _push(`
未定义变量
`); } else { _push(``); } _push(``); ssrRenderList(form.variables, (v, i) => { _push(`
`); }); _push(`
`); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/agents.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; const agents = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-dcf87e76"]]); export { agents as default }; //# sourceMappingURL=agents-Bh_gLb1p.mjs.map