- 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]>
91 lines
3.2 KiB
TypeScript
91 lines
3.2 KiB
TypeScript
import type { ComponentProps } from "react";
|
|
import Link from "@moduletrace/twui/layout/Link";
|
|
import { ComputerViewModes, type ComputerViewMode } from "@/src/dict/computer-dict";
|
|
import {
|
|
BotRefHrefPrefix,
|
|
ComputerRefHrefPrefix,
|
|
FileRefHrefPrefix,
|
|
ProposalRefHrefPrefix,
|
|
TakeOverRefHrefPrefix,
|
|
WorkspaceRefHrefPrefix,
|
|
} from "@/src/utils/link-computer-refs";
|
|
import { parseFolderRefHref } from "@/src/utils/folder-ref";
|
|
import BotRefChip from "./bot-ref-chip";
|
|
import ComputerRefChip from "./computer-ref-chip";
|
|
import FileRefChip from "./file-ref-chip";
|
|
import FolderRefChip from "./folder-ref-chip";
|
|
import ProposalRefChip from "./proposal-ref-chip";
|
|
import TakeOverChip from "./take-over-chip";
|
|
import WorkspaceRefChip from "./workspace-ref-chip";
|
|
|
|
/**
|
|
* A link in a bot message. A computer the bot named (`linkComputerRefs`)
|
|
* becomes its switch button, a take-over request a button that opens the
|
|
* computer, a bot it named a link to that bot's conversation, a workspace
|
|
* a link to that workspace, a file it saved a chip that downloads it, a
|
|
* folder it named a chip that opens it in the files browser, an MCP server
|
|
* or tool it proposed a chip that opens the confirm card; anything else
|
|
* opens in a new tab.
|
|
*/
|
|
export default function MarkdownLink({ href, children }: ComponentProps<"a">) {
|
|
if (href?.startsWith(ComputerRefHrefPrefix)) {
|
|
const computer_id = Number(href.slice(ComputerRefHrefPrefix.length));
|
|
|
|
if (computer_id) return <ComputerRefChip computer_id={computer_id} />;
|
|
}
|
|
|
|
if (href?.startsWith(TakeOverRefHrefPrefix)) {
|
|
const [id, mode] = href.slice(TakeOverRefHrefPrefix.length).split("-");
|
|
const computer_id = Number(id);
|
|
const known = ComputerViewModes.some((m) => m.value == mode);
|
|
|
|
if (computer_id) {
|
|
return (
|
|
<TakeOverChip
|
|
computer_id={computer_id}
|
|
mode={(known ? mode : ComputerViewModes[0].value) as ComputerViewMode}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
if (href?.startsWith(BotRefHrefPrefix)) {
|
|
const bot_id = Number(href.slice(BotRefHrefPrefix.length));
|
|
|
|
if (bot_id) return <BotRefChip bot_id={bot_id} />;
|
|
}
|
|
|
|
if (href?.startsWith(WorkspaceRefHrefPrefix)) {
|
|
const workspace_id = Number(href.slice(WorkspaceRefHrefPrefix.length));
|
|
|
|
if (workspace_id) return <WorkspaceRefChip workspace_id={workspace_id} />;
|
|
}
|
|
|
|
if (href?.startsWith(FileRefHrefPrefix)) {
|
|
const file_id = Number(href.slice(FileRefHrefPrefix.length));
|
|
|
|
if (file_id) return <FileRefChip file_id={file_id} />;
|
|
}
|
|
|
|
if (href?.startsWith(ProposalRefHrefPrefix)) {
|
|
const proposal_id = Number(href.slice(ProposalRefHrefPrefix.length));
|
|
|
|
if (proposal_id) return <ProposalRefChip proposal_id={proposal_id} />;
|
|
}
|
|
|
|
const folder_ref = parseFolderRefHref({ href });
|
|
|
|
if (folder_ref) return <FolderRefChip spec={folder_ref.spec} path={folder_ref.path} />;
|
|
|
|
return (
|
|
<Link
|
|
href={href}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="text-ink underline underline-offset-2 hover:opacity-80 break-words"
|
|
>
|
|
{children}
|
|
</Link>
|
|
);
|
|
}
|