@sema-agent/core
Version:
Stateless, task-oriented AI agent core
17 lines (16 loc) • 1.03 kB
JavaScript
import { mintNamespacePrefix } from "../core/protocol-naming.js";
import { MCP_NAMESPACE } from "../core/protocol-table.js";
import { TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME } from "../core/tool-catalog-entries.js";
export const TEAM_TASK_LIST_TOOL_NAMES = Object.freeze([TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME]);
export function callerToolMembership(tools) {
const mounted = new Set(Array.isArray(tools) ? tools : []);
return (tool) => mounted.has(tool);
}
export function inheritedChildPool(surface, mountsCallerTool, anonymousBackground) {
if (mountsCallerTool === undefined)
return [];
return surface.filter((t) => mountsCallerTool(t) && !(anonymousBackground && TEAM_TASK_LIST_TOOL_NAMES.includes(t.name)));
}
export function inheritedMcpDeclarations(mounted, selector) {
return mounted.servers.filter((m) => selector.admitsPeer(mintNamespacePrefix(MCP_NAMESPACE, m.server.name))).map((m) => m.server);
}