Let the coordinator manage skills, MCP servers and tools, behind a confirm card
- Coordinator tools in its own chat (super admin only): list_extensions,
set_extension_access, delete_extension, and update_skill /
update_mcp_server / update_custom_tool for what can't change where
anything is sent (on/off, names, arguments, left-out tools)
- Adding a skill, MCP server or tool, or changing a skill's words, a
server's URL or headers or a tool's kind or config, goes through
propose_skill / propose_mcp_server / propose_custom_tool: stored in
extension_proposals with the bot's background check, shown as a
[proposal:ID] chip that opens a card with Confirm and Reject
- The card's facts are worked out by the app from what Confirm saves: the
host, every {{env.KEY}} and whether it's saved, the config; for a skill
its links, hosts, tool names, mentions of secrets and a diff against
the saved runbook
- Confirming decides once and checks again; a server or tool missing a key
is saved switched off, and the outcome is posted to the bot in chat
- Never from a bot: stdio servers, a URL whose host a template decides,
envs in a prompt tool, a key's value
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import fetchApi from "@moduletrace/twui/utils/fetch/fetchApi";
|
||||
import type { APIResponseObject } from "@moduletrace/bunext/types";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import type { ExtensionProposalView } from "@/src/types";
|
||||
|
||||
type Params = {
|
||||
proposal_id: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Proposals already read, by id, so a thread naming one twice (or a
|
||||
* re-render) asks once. A decision replaces its entry.
|
||||
*/
|
||||
const loaded = new Map<number, Promise<ExtensionProposalView | null>>();
|
||||
|
||||
function loadProposal({ proposal_id }: Params) {
|
||||
const cached = loaded.get(proposal_id);
|
||||
|
||||
if (cached) return cached;
|
||||
|
||||
const pending = fetchApi<{}, APIResponseObject<ExtensionProposalView>>(
|
||||
`/api/admin/extension-proposals/get-proposal?proposal_id=${proposal_id}`,
|
||||
{ method: "GET" },
|
||||
)
|
||||
.then((res) => (res?.success && res.singleRes ? res.singleRes : null))
|
||||
.catch(() => null);
|
||||
|
||||
loaded.set(proposal_id, pending);
|
||||
|
||||
return pending;
|
||||
}
|
||||
|
||||
/**
|
||||
* An MCP server or tool the coordinator proposed (`[proposal:ID]`), for
|
||||
* its chip and confirm card: read when the chip renders, so it shows
|
||||
* whether it's still waiting. Only the super admin it was proposed to can
|
||||
* read it; anyone else gets null.
|
||||
*/
|
||||
export default function useExtensionProposal({ proposal_id }: Params) {
|
||||
const [view, setViewState] = useState<ExtensionProposalView | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
let live = true;
|
||||
|
||||
loadProposal({ proposal_id }).then((result) => {
|
||||
if (!live) return;
|
||||
setViewState(result);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
return () => {
|
||||
live = false;
|
||||
};
|
||||
}, [proposal_id]);
|
||||
|
||||
const setView = useCallback(
|
||||
(next: ExtensionProposalView) => {
|
||||
loaded.set(proposal_id, Promise.resolve(next));
|
||||
setViewState(next);
|
||||
},
|
||||
[proposal_id],
|
||||
);
|
||||
|
||||
return { view, loading, setView };
|
||||
}
|
||||
Reference in New Issue
Block a user