|
@@ -1,11 +1,12 @@
|
|
|
-import { For, Show, createMemo, createEffect, on, onCleanup } from "solid-js"
|
|
|
|
|
|
|
+import { For, Show, createMemo, createEffect, on, onCleanup, onMount } from "solid-js"
|
|
|
import { createStore, unwrap } from "solid-js/store"
|
|
import { createStore, unwrap } from "solid-js/store"
|
|
|
import { paasRecord, paasText, type PaasPlatform } from "@/paas"
|
|
import { paasRecord, paasText, type PaasPlatform } from "@/paas"
|
|
|
-import { toolExtensions, withToolExtension, type ToolExtension } from "./extensions"
|
|
|
|
|
|
|
+import { toolExtensions, withToolExtension, toolExtensionMode, type ToolExtension } from "./extensions"
|
|
|
import { ResearchIcon } from "./research-icon"
|
|
import { ResearchIcon } from "./research-icon"
|
|
|
import { resolveAgentProfile } from "./agent-profiles"
|
|
import { resolveAgentProfile } from "./agent-profiles"
|
|
|
|
|
|
|
|
export function PaasTools(props: {
|
|
export function PaasTools(props: {
|
|
|
|
|
+ scope?: string
|
|
|
api: PaasPlatform
|
|
api: PaasPlatform
|
|
|
agents: Record<string, unknown>[]
|
|
agents: Record<string, unknown>[]
|
|
|
canManage: boolean
|
|
canManage: boolean
|
|
@@ -21,23 +22,66 @@ export function PaasTools(props: {
|
|
|
error: "",
|
|
error: "",
|
|
|
notice: "",
|
|
notice: "",
|
|
|
adding: false,
|
|
adding: false,
|
|
|
|
|
+ editing: "",
|
|
|
|
|
+ draftEnabled: true,
|
|
|
|
|
+ retainSelection: false,
|
|
|
|
|
+ enableToolCalls: false,
|
|
|
name: "",
|
|
name: "",
|
|
|
url: "",
|
|
url: "",
|
|
|
bearerEnv: "",
|
|
bearerEnv: "",
|
|
|
tools: [] as Record<string, unknown>[],
|
|
tools: [] as Record<string, unknown>[],
|
|
|
chosen: [] as string[],
|
|
chosen: [] as string[],
|
|
|
|
|
+ toolQuery: "",
|
|
|
inspected: "",
|
|
inspected: "",
|
|
|
removal: "",
|
|
removal: "",
|
|
|
|
|
+ draftNotice: "",
|
|
|
})
|
|
})
|
|
|
const life = { active: true, version: 0 }
|
|
const life = { active: true, version: 0 }
|
|
|
|
|
+ const draft = () =>
|
|
|
|
|
+ structuredClone(
|
|
|
|
|
+ unwrap({
|
|
|
|
|
+ editing: state.editing,
|
|
|
|
|
+ draftEnabled: state.draftEnabled,
|
|
|
|
|
+ name: state.name,
|
|
|
|
|
+ url: state.url,
|
|
|
|
|
+ bearerEnv: state.bearerEnv,
|
|
|
|
|
+ chosen: state.chosen,
|
|
|
|
|
+ }),
|
|
|
|
|
+ )
|
|
|
|
|
+ const keepDraft = (value: unknown, id = state.agentID) =>
|
|
|
|
|
+ props.api.writeDraft?.("tool", id, value, props.scope || "").catch(() => {
|
|
|
|
|
+ if (life.active) setState("draftNotice", "草稿未能写入本机,请在离开前保存连接。")
|
|
|
|
|
+ })
|
|
|
|
|
+ onMount(() => {
|
|
|
|
|
+ void props.api
|
|
|
|
|
+ .readDraft?.("tool", "$selection", props.scope || "")
|
|
|
|
|
+ .then((id) => {
|
|
|
|
|
+ if (life.active && !state.agentID && typeof id === "string" && props.agents.some((agent) => agent.id === id))
|
|
|
|
|
+ setState("agentID", id)
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {})
|
|
|
|
|
+ })
|
|
|
|
|
+ createEffect(() => {
|
|
|
|
|
+ if (!state.agentID || state.loading || state.busy || !state.adding) return
|
|
|
|
|
+ void keepDraft(draft())
|
|
|
|
|
+ })
|
|
|
onCleanup(() => {
|
|
onCleanup(() => {
|
|
|
|
|
+ if (state.adding && state.agentID) void keepDraft(draft())
|
|
|
life.active = false
|
|
life.active = false
|
|
|
life.version++
|
|
life.version++
|
|
|
})
|
|
})
|
|
|
const config = () => paasRecord(state.detail?.config) || {}
|
|
const config = () => paasRecord(state.detail?.config) || {}
|
|
|
const entries = createMemo(() => toolExtensions(config()))
|
|
const entries = createMemo(() => toolExtensions(config()))
|
|
|
const signature = () => JSON.stringify([state.url.trim(), state.bearerEnv.trim()])
|
|
const signature = () => JSON.stringify([state.url.trim(), state.bearerEnv.trim()])
|
|
|
- const compatible = () => !config().pipeline && !config().researchWorkflow
|
|
|
|
|
|
|
+ const compatible = () => toolExtensionMode(config()) !== "nested"
|
|
|
|
|
+ const needsToolCalls = () => toolExtensionMode(config()) === "enable"
|
|
|
|
|
+ const visibleTools = createMemo(() =>
|
|
|
|
|
+ state.tools.filter((tool) =>
|
|
|
|
|
+ `${paasText(tool.name)} ${paasText(tool.description)}`
|
|
|
|
|
+ .toLowerCase()
|
|
|
|
|
+ .includes(state.toolQuery.trim().toLowerCase()),
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
const agents = () => props.agents.filter((agent) => resolveAgentProfile(agent).entryMode !== "workflow")
|
|
const agents = () => props.agents.filter((agent) => resolveAgentProfile(agent).entryMode !== "workflow")
|
|
|
async function reload(id = state.agentID, preserveDraft = false) {
|
|
async function reload(id = state.agentID, preserveDraft = false) {
|
|
|
const version = ++life.version
|
|
const version = ++life.version
|
|
@@ -46,13 +90,32 @@ export function PaasTools(props: {
|
|
|
loading: !!id,
|
|
loading: !!id,
|
|
|
error: "",
|
|
error: "",
|
|
|
notice: "",
|
|
notice: "",
|
|
|
- ...(preserveDraft ? {} : { adding: false, removal: "", tools: [], inspected: "" }),
|
|
|
|
|
|
|
+ ...(preserveDraft
|
|
|
|
|
+ ? {}
|
|
|
|
|
+ : { adding: false, editing: "", removal: "", tools: [], inspected: "", enableToolCalls: false }),
|
|
|
})
|
|
})
|
|
|
if (!id) return
|
|
if (!id) return
|
|
|
await props.api
|
|
await props.api
|
|
|
.request({ action: "agent", agentID: id })
|
|
.request({ action: "agent", agentID: id })
|
|
|
- .then((result) => {
|
|
|
|
|
- if (life.active && version === life.version) setState("detail", paasRecord(result))
|
|
|
|
|
|
|
+ .then(async (result) => {
|
|
|
|
|
+ if (!life.active || version !== life.version) return
|
|
|
|
|
+ setState("detail", paasRecord(result))
|
|
|
|
|
+ if (preserveDraft) return
|
|
|
|
|
+ const stored = paasRecord(await props.api.readDraft?.("tool", id, props.scope || "").catch(() => undefined))
|
|
|
|
|
+ if (!life.active || version !== life.version || !stored || typeof stored.name !== "string") return
|
|
|
|
|
+ setState({
|
|
|
|
|
+ adding: true,
|
|
|
|
|
+ retainSelection: true,
|
|
|
|
|
+ editing: paasText(stored.editing),
|
|
|
|
|
+ draftEnabled: stored.draftEnabled !== false,
|
|
|
|
|
+ name: stored.name,
|
|
|
|
|
+ url: paasText(stored.url),
|
|
|
|
|
+ bearerEnv: paasText(stored.bearerEnv),
|
|
|
|
|
+ chosen: Array.isArray(stored.chosen)
|
|
|
|
|
+ ? stored.chosen.filter((name): name is string => typeof name === "string")
|
|
|
|
|
+ : [],
|
|
|
|
|
+ notice: "已恢复连接草稿,请重新读取工具后保存。",
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
.catch((error: unknown) => {
|
|
.catch((error: unknown) => {
|
|
|
if (life.active && version === life.version)
|
|
if (life.active && version === life.version)
|
|
@@ -66,6 +129,7 @@ export function PaasTools(props: {
|
|
|
on(
|
|
on(
|
|
|
() => state.agentID,
|
|
() => state.agentID,
|
|
|
(id) => {
|
|
(id) => {
|
|
|
|
|
+ if (id) void props.api.writeDraft?.("tool", "$selection", id, props.scope || "").catch(() => {})
|
|
|
void reload(id)
|
|
void reload(id)
|
|
|
},
|
|
},
|
|
|
),
|
|
),
|
|
@@ -85,12 +149,14 @@ export function PaasTools(props: {
|
|
|
const id = state.agentID
|
|
const id = state.agentID
|
|
|
const updatedAt = paasText(state.detail?.updated_at)
|
|
const updatedAt = paasText(state.detail?.updated_at)
|
|
|
if (!updatedAt) throw new Error("配置缺少版本信息,请重新选择智能体后重试。")
|
|
if (!updatedAt) throw new Error("配置缺少版本信息,请重新选择智能体后重试。")
|
|
|
- const next = withToolExtension(unwrap(config()), extension, action)
|
|
|
|
|
|
|
+ if (!props.canManage) throw new Error("当前账号没有修改工具配置的权限。")
|
|
|
|
|
+ const next = withToolExtension(unwrap(config()), extension, action, state.enableToolCalls)
|
|
|
await props.api.request({
|
|
await props.api.request({
|
|
|
action: "update-agent",
|
|
action: "update-agent",
|
|
|
agentID: id,
|
|
agentID: id,
|
|
|
update: { config: next, expected_updated_at: updatedAt },
|
|
update: { config: next, expected_updated_at: updatedAt },
|
|
|
})
|
|
})
|
|
|
|
|
+ await keepDraft(undefined, id)
|
|
|
if (!life.active) return
|
|
if (!life.active) return
|
|
|
setState({
|
|
setState({
|
|
|
notice:
|
|
notice:
|
|
@@ -98,12 +164,19 @@ export function PaasTools(props: {
|
|
|
? "已移除工具连接,历史任务与成果保留。"
|
|
? "已移除工具连接,历史任务与成果保留。"
|
|
|
: "已保存,后续新任务将使用更新后的配置;正在运行的任务保持原配置。",
|
|
: "已保存,后续新任务将使用更新后的配置;正在运行的任务保持原配置。",
|
|
|
adding: false,
|
|
adding: false,
|
|
|
|
|
+ editing: "",
|
|
|
removal: "",
|
|
removal: "",
|
|
|
detail: undefined,
|
|
detail: undefined,
|
|
|
})
|
|
})
|
|
|
- const detail = paasRecord(await props.api.request({ action: "agent", agentID: id }))
|
|
|
|
|
- if (life.active) setState("detail", detail)
|
|
|
|
|
- await props.onChanged()
|
|
|
|
|
|
|
+ // A refresh failure must not turn a committed save into a retryable mutation.
|
|
|
|
|
+ await Promise.all([
|
|
|
|
|
+ props.api.request({ action: "agent", agentID: id }).then((result) => {
|
|
|
|
|
+ if (life.active) setState("detail", paasRecord(result))
|
|
|
|
|
+ }),
|
|
|
|
|
+ props.onChanged(),
|
|
|
|
|
+ ]).catch(() => {
|
|
|
|
|
+ if (life.active) setState("error", "配置已保存,但界面刷新未完成。请重新读取配置,无需重复保存。")
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
return (
|
|
return (
|
|
|
<section class="paas-extension-catalog" aria-label="工具扩展">
|
|
<section class="paas-extension-catalog" aria-label="工具扩展">
|
|
@@ -116,7 +189,7 @@ export function PaasTools(props: {
|
|
|
aria-label="工具配置对象"
|
|
aria-label="工具配置对象"
|
|
|
value={state.agentID}
|
|
value={state.agentID}
|
|
|
disabled={state.busy}
|
|
disabled={state.busy}
|
|
|
- onChange={(event) => setState("agentID", event.currentTarget.value)}
|
|
|
|
|
|
|
+ onChange={(event) => setState({ adding: false, agentID: event.currentTarget.value })}
|
|
|
>
|
|
>
|
|
|
<option value="">选择要扩展的智能体</option>
|
|
<option value="">选择要扩展的智能体</option>
|
|
|
<For each={agents()}>
|
|
<For each={agents()}>
|
|
@@ -137,6 +210,9 @@ export function PaasTools(props: {
|
|
|
</Show>
|
|
</Show>
|
|
|
</div>
|
|
</div>
|
|
|
</Show>
|
|
</Show>
|
|
|
|
|
+ <Show when={state.draftNotice}>
|
|
|
|
|
+ <p role="status">{state.draftNotice}</p>
|
|
|
|
|
+ </Show>
|
|
|
<Show when={state.notice}>
|
|
<Show when={state.notice}>
|
|
|
<p role="status">{state.notice}</p>
|
|
<p role="status">{state.notice}</p>
|
|
|
</Show>
|
|
</Show>
|
|
@@ -146,18 +222,45 @@ export function PaasTools(props: {
|
|
|
fallback={
|
|
fallback={
|
|
|
<div class="paas-extension-detail">
|
|
<div class="paas-extension-detail">
|
|
|
<p>
|
|
<p>
|
|
|
- 此应用使用专门的研究流程,工具需要配置到实际执行的智能体。你可以选择执行角色,或打开应用设置查看流程。
|
|
|
|
|
|
|
+ 此应用包含组合或科研流程,工具需要配置到实际执行的智能体。你可以选择执行角色,或打开应用设置查看流程。
|
|
|
</p>
|
|
</p>
|
|
|
<button onClick={() => props.onConfigure(state.agentID)}>应用设置</button>
|
|
<button onClick={() => props.onConfigure(state.agentID)}>应用设置</button>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
>
|
|
>
|
|
|
|
|
+ <Show when={needsToolCalls()}>
|
|
|
|
|
+ <div class="paas-extension-detail">
|
|
|
|
|
+ <p>
|
|
|
|
|
+ 此智能体尚未启用工具调用。启用后将根据任务调用工具,原有模型、提示词和资源配置会保留;模型需支持工具调用。
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <label class="paas-extension-checkbox">
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="checkbox"
|
|
|
|
|
+ checked={state.enableToolCalls}
|
|
|
|
|
+ disabled={state.busy}
|
|
|
|
|
+ onChange={(event) => setState("enableToolCalls", event.currentTarget.checked)}
|
|
|
|
|
+ />
|
|
|
|
|
+ 保存时启用工具调用
|
|
|
|
|
+ </label>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </Show>
|
|
|
<div class="paas-extension-actions">
|
|
<div class="paas-extension-actions">
|
|
|
<button
|
|
<button
|
|
|
class="paas-primary"
|
|
class="paas-primary"
|
|
|
disabled={state.busy || !props.canManage}
|
|
disabled={state.busy || !props.canManage}
|
|
|
onClick={() =>
|
|
onClick={() =>
|
|
|
- setState({ adding: true, name: "", url: "", bearerEnv: "", inspected: "", tools: [], chosen: [] })
|
|
|
|
|
|
|
+ setState({
|
|
|
|
|
+ adding: true,
|
|
|
|
|
+ editing: "",
|
|
|
|
|
+ retainSelection: false,
|
|
|
|
|
+ draftEnabled: true,
|
|
|
|
|
+ name: "",
|
|
|
|
|
+ url: "",
|
|
|
|
|
+ bearerEnv: "",
|
|
|
|
|
+ inspected: "",
|
|
|
|
|
+ tools: [],
|
|
|
|
|
+ chosen: [],
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
>
|
|
>
|
|
|
添加工具连接
|
|
添加工具连接
|
|
@@ -178,18 +281,21 @@ export function PaasTools(props: {
|
|
|
}
|
|
}
|
|
|
void perform(() =>
|
|
void perform(() =>
|
|
|
save({
|
|
save({
|
|
|
- id: `desktop_${crypto.randomUUID()}`,
|
|
|
|
|
|
|
+ id: state.editing || `desktop_${crypto.randomUUID()}`,
|
|
|
name: state.name.trim(),
|
|
name: state.name.trim(),
|
|
|
url: state.url.trim(),
|
|
url: state.url.trim(),
|
|
|
bearerEnv: state.bearerEnv.trim(),
|
|
bearerEnv: state.bearerEnv.trim(),
|
|
|
tools: [...state.chosen],
|
|
tools: [...state.chosen],
|
|
|
- enabled: true,
|
|
|
|
|
|
|
+ enabled: state.draftEnabled,
|
|
|
}),
|
|
}),
|
|
|
)
|
|
)
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
- <h2>连接外部工具</h2>
|
|
|
|
|
|
|
+ <h2>{state.editing ? "编辑工具连接" : "连接外部工具"}</h2>
|
|
|
<p>填写工具服务提供的 MCP HTTP 地址,读取能力清单后选择需要的工具。</p>
|
|
<p>填写工具服务提供的 MCP HTTP 地址,读取能力清单后选择需要的工具。</p>
|
|
|
|
|
+ <p class="paas-muted">
|
|
|
|
|
+ {props.api.writeDraft ? "连接草稿加密保存在本机,切换页面后可继续。" : "当前环境不支持跨窗口保存草稿。"}
|
|
|
|
|
+ </p>
|
|
|
<div class="paas-extension-fields">
|
|
<div class="paas-extension-fields">
|
|
|
<label>
|
|
<label>
|
|
|
连接名称
|
|
连接名称
|
|
@@ -223,7 +329,10 @@ export function PaasTools(props: {
|
|
|
onInput={(event) => setState("bearerEnv", event.currentTarget.value)}
|
|
onInput={(event) => setState("bearerEnv", event.currentTarget.value)}
|
|
|
/>
|
|
/>
|
|
|
</label>
|
|
</label>
|
|
|
- <p class="paas-muted">当前支持引用平台与执行服务中已有的 Bearer 凭证变量,不将密钥写入应用配置。</p>
|
|
|
|
|
|
|
+ <p class="paas-muted">
|
|
|
|
|
+ 公开服务可留空。需要 Bearer 凭证时,填写本机平台与执行服务中已配置的变量名;例如填写
|
|
|
|
|
+ PAPERS_API_KEY,而不是密钥本身。读取工具会检查该连接是否可用,未通过时保留草稿供修改。
|
|
|
|
|
+ </p>
|
|
|
</details>
|
|
</details>
|
|
|
<button
|
|
<button
|
|
|
type="button"
|
|
type="button"
|
|
@@ -231,6 +340,8 @@ export function PaasTools(props: {
|
|
|
onClick={() =>
|
|
onClick={() =>
|
|
|
void perform(async () => {
|
|
void perform(async () => {
|
|
|
const checked = signature()
|
|
const checked = signature()
|
|
|
|
|
+ const selected = [...state.chosen]
|
|
|
|
|
+ setState({ inspected: "", tools: [] })
|
|
|
const result = paasRecord(
|
|
const result = paasRecord(
|
|
|
await props.api.request({
|
|
await props.api.request({
|
|
|
action: "inspect-tool",
|
|
action: "inspect-tool",
|
|
@@ -247,7 +358,11 @@ export function PaasTools(props: {
|
|
|
setState({
|
|
setState({
|
|
|
inspected: checked,
|
|
inspected: checked,
|
|
|
tools,
|
|
tools,
|
|
|
- chosen: tools.map((tool) => paasText(tool.name)).filter(Boolean),
|
|
|
|
|
|
|
+ chosen: tools
|
|
|
|
|
+ .map((tool) => paasText(tool.name))
|
|
|
|
|
+ .filter(
|
|
|
|
|
+ (name) => !!name && ((!state.editing && !state.retainSelection) || selected.includes(name)),
|
|
|
|
|
+ ),
|
|
|
notice: tools.length
|
|
notice: tools.length
|
|
|
? `已读取 ${tools.length} 个工具,尚未执行实际业务操作。${Array.isArray(result.unavailable_tools) && result.unavailable_tools.length ? `另有 ${result.unavailable_tools.length} 个工具暂不可用,其余工具可正常选择。` : ""}`
|
|
? `已读取 ${tools.length} 个工具,尚未执行实际业务操作。${Array.isArray(result.unavailable_tools) && result.unavailable_tools.length ? `另有 ${result.unavailable_tools.length} 个工具暂不可用,其余工具可正常选择。` : ""}`
|
|
|
: "服务没有提供可用工具,请检查地址。",
|
|
: "服务没有提供可用工具,请检查地址。",
|
|
@@ -259,8 +374,40 @@ export function PaasTools(props: {
|
|
|
</button>
|
|
</button>
|
|
|
<Show when={state.inspected === signature() && state.tools.length}>
|
|
<Show when={state.inspected === signature() && state.tools.length}>
|
|
|
<fieldset class="paas-extension-tool-list">
|
|
<fieldset class="paas-extension-tool-list">
|
|
|
- <legend>选择需要的工具</legend>
|
|
|
|
|
- <For each={state.tools}>
|
|
|
|
|
|
|
+ <legend>
|
|
|
|
|
+ 选择需要的工具 · 已选 {state.chosen.length} / {state.tools.length}
|
|
|
|
|
+ </legend>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="search"
|
|
|
|
|
+ aria-label="搜索连接内工具"
|
|
|
|
|
+ placeholder="搜索工具名称或用途"
|
|
|
|
|
+ value={state.toolQuery}
|
|
|
|
|
+ onInput={(event) => setState("toolQuery", event.currentTarget.value)}
|
|
|
|
|
+ />
|
|
|
|
|
+ <div class="paas-extension-actions">
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ disabled={state.busy || !visibleTools().length}
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ setState("chosen", [
|
|
|
|
|
+ ...new Set([...state.chosen, ...visibleTools().map((tool) => paasText(tool.name))]),
|
|
|
|
|
+ ])
|
|
|
|
|
+ }
|
|
|
|
|
+ >
|
|
|
|
|
+ 选择筛选结果
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ disabled={state.busy || !state.chosen.length}
|
|
|
|
|
+ onClick={() => setState("chosen", [])}
|
|
|
|
|
+ >
|
|
|
|
|
+ 清除选择
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <Show when={!visibleTools().length}>
|
|
|
|
|
+ <p>没有匹配的工具,换一个关键词试试。</p>
|
|
|
|
|
+ </Show>
|
|
|
|
|
+ <For each={visibleTools()}>
|
|
|
{(tool) => (
|
|
{(tool) => (
|
|
|
<label class="paas-extension-checkbox">
|
|
<label class="paas-extension-checkbox">
|
|
|
<input
|
|
<input
|
|
@@ -286,12 +433,25 @@ export function PaasTools(props: {
|
|
|
</fieldset>
|
|
</fieldset>
|
|
|
</Show>
|
|
</Show>
|
|
|
<div class="paas-extension-actions">
|
|
<div class="paas-extension-actions">
|
|
|
- <button type="button" disabled={state.busy} onClick={() => setState("adding", false)}>
|
|
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ disabled={state.busy}
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ setState("adding", false)
|
|
|
|
|
+ void keepDraft(undefined)
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
取消
|
|
取消
|
|
|
</button>
|
|
</button>
|
|
|
<button
|
|
<button
|
|
|
class="paas-primary"
|
|
class="paas-primary"
|
|
|
- disabled={state.busy || !state.name.trim() || !state.chosen.length || state.inspected !== signature()}
|
|
|
|
|
|
|
+ disabled={
|
|
|
|
|
+ state.busy ||
|
|
|
|
|
+ !state.name.trim() ||
|
|
|
|
|
+ !state.chosen.length ||
|
|
|
|
|
+ state.inspected !== signature() ||
|
|
|
|
|
+ (state.draftEnabled && needsToolCalls() && !state.enableToolCalls)
|
|
|
|
|
+ }
|
|
|
>
|
|
>
|
|
|
保存连接
|
|
保存连接
|
|
|
</button>
|
|
</button>
|
|
@@ -322,11 +482,34 @@ export function PaasTools(props: {
|
|
|
</details>
|
|
</details>
|
|
|
<div class="paas-extension-actions">
|
|
<div class="paas-extension-actions">
|
|
|
<button
|
|
<button
|
|
|
- disabled={state.busy || !props.canManage}
|
|
|
|
|
|
|
+ disabled={
|
|
|
|
|
+ state.busy || !props.canManage || (!entry.enabled && needsToolCalls() && !state.enableToolCalls)
|
|
|
|
|
+ }
|
|
|
onClick={() => void perform(() => save({ ...entry, enabled: !entry.enabled }))}
|
|
onClick={() => void perform(() => save({ ...entry, enabled: !entry.enabled }))}
|
|
|
>
|
|
>
|
|
|
{entry.enabled ? "停用" : "启用"}
|
|
{entry.enabled ? "停用" : "启用"}
|
|
|
</button>
|
|
</button>
|
|
|
|
|
+ <button
|
|
|
|
|
+ disabled={state.busy || !props.canManage}
|
|
|
|
|
+ onClick={() =>
|
|
|
|
|
+ setState({
|
|
|
|
|
+ adding: true,
|
|
|
|
|
+ editing: entry.id,
|
|
|
|
|
+ draftEnabled: entry.enabled,
|
|
|
|
|
+ name: entry.name,
|
|
|
|
|
+ url: entry.url,
|
|
|
|
|
+ bearerEnv: entry.bearerEnv,
|
|
|
|
|
+ chosen: [...entry.tools],
|
|
|
|
|
+ tools: [],
|
|
|
|
|
+ inspected: "",
|
|
|
|
|
+ removal: "",
|
|
|
|
|
+ error: "",
|
|
|
|
|
+ notice: "",
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ >
|
|
|
|
|
+ 编辑连接
|
|
|
|
|
+ </button>
|
|
|
<button disabled={state.busy || !props.canManage} onClick={() => setState("removal", entry.id)}>
|
|
<button disabled={state.busy || !props.canManage} onClick={() => setState("removal", entry.id)}>
|
|
|
移除
|
|
移除
|
|
|
</button>
|
|
</button>
|