Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(agent-builder): add a custom connector from Talk by its app
trohitg834de0da4200
diff --git a/docs-internal/mcp_connectors.md b/docs-internal/mcp_connectors.mdindex 6b707a04..d970dbb3 100644--- a/docs-internal/mcp_connectors.md+++ b/docs-internal/mcp_connectors.md@@ -166,7 +166,11 @@ the connector's, and its one tool the node set to that connector.allowlist, `enabled_nodes`);- a saved connector counts as connected;- under Ask first the node stays, since each call waits for the owner per its- tool's setting.+ tool's setting;+- from Talk, the Agent Builder offers each connector as its own entry with+ its `app_id`, and `add_tool` adds the one named. An agent already has a+ connector only on a node naming it, so a second connector is a second+ node.The employee's card lists the connector its node names. The node declares`app_field = "mcp_connector"`, so the summaries read that parameter@@ -193,8 +197,6 @@ connector is no longer listed.## Known gaps-- The Agent Builder does not add a connector from Talk yet: an employee gets- one at hire, or in Dev mode with the Custom Connector node.- No OAuth sign-in.- A host's addresses are checked when connecting, not pinned for theconnection.diff --git a/docs-internal/node-logic-flows/ai_tools/agentBuilder.md b/docs-internal/node-logic-flows/ai_tools/agentBuilder.mdindex 211aa977..510d8c36 100644--- a/docs-internal/node-logic-flows/ai_tools/agentBuilder.md+++ b/docs-internal/node-logic-flows/ai_tools/agentBuilder.md@@ -62,6 +62,7 @@ The `AgentBuilderParams` model fields ARE the LLM-provided tool args.|------|------|---------|----------|---------------------|-------------|| `operation` | enum | `inspect_canvas` | no | - | `inspect_canvas`, `inspect_node`, `search_docs`, `read_doc`, `plan_update`, `apply_update`, `add_tool`, `add_skill`, `add_subagent`, `create_workflow` || `node_type` | string | `""` | no | `operation == add_tool` | Tool node type, from `available_tools` |+| `app_id` | string | `""` | no | `operation == add_tool` | The tool's app, when its `available_tools` entry names one: required for a type several apps share (each custom connector is its own app) || `target_member_id` | string | `""` | no | - | Employee member receiving the tool; defaults to the caller. Must belong to this employee, including legacy employees. || `skill_name` | string | `""` | no | `operation == add_skill` | Skill name (SKILL.md frontmatter `name`, or a library skill's name), from `available_skills` || `agent_type` | string | `""` | no | `operation == add_subagent` | Agent node type to add as a teammate (caller must be a team lead) |@@ -147,9 +148,13 @@ flowchart TDcaller.- **Hired employee**: tools go to one selected member, with no fanout toother workers or Talk. `check_tool` decides tools- (registry app tools and the tools every hire gets; nothing that sends or+ (the apps' tools, the registry's and the owner's own through+ `Connections.apps`, and the tools every hire gets; nothing that sends orspends while asking first, the browser read-only then; hire allowlist;- connected apps); the Clock gets the owner's `profile_timezone`.+ connected apps); the Clock gets the owner's `profile_timezone`. A type+ whose app a parameter names (`app_field`: the Custom Connector) is listed+ once per app with its `app_id`, needs it in `add_tool`, and counts as the+ target's tool only on a node naming the same app.`check_skill` refuses `skill` and `*-personality`; skills come from thelibrary (all of it, on or off for new hires) and the Discover folder(`server/skills/employee/`), text copied in. `add_subagent` is refused.diff --git a/docs-internal/normal_mode.md b/docs-internal/normal_mode.mdindex 074b7f27..da2cf854 100644--- a/docs-internal/normal_mode.md+++ b/docs-internal/normal_mode.md@@ -850,7 +850,11 @@ asks, within the rule Hire applies([policy.py](../server/services/employees/policy.py)):- **Tools**: the ones every hire gets (web search, checklist, clock, Memory,- Canvas) and the app registry's. A tool that sends or spends comes whole:+ Canvas) and the apps' (`Connections.apps`: the registry's and the owner's+ own). A type several apps share, the Custom Connector node, is offered+ once per app with its `app_id`, which `add_tool` takes; the agent already+ has it only on a node naming the same app (its `app_field` parameter).+ A tool that sends or spends comes whole:while "Ask me before sending anything" is on, each call waits for the owner(or is refused, or reads only), per call. Only one that cannot wait (noapproval spec) stays off, or comes in its `ask_first_params` form. Every@@ -1101,9 +1105,6 @@ chat's rollback), `lib/__tests__/workflowOps.test.ts` and- Billing has no plans, payment method or invoices: no billing account sitsbehind OpenCompany. A deleted employee's runs leave the month's count,because deleting a workflow deletes its run records.-- The Agent Builder does not add a custom (MCP) connector from Talk yet: an- employee gets one at hire, or in Dev mode with the Custom Connector node- (`mcpConnector`).- Skill library changes reach only new hires: an employee keeps the skills itwas hired with, and one hired before the library existed has none, untilthe owner asks them in Talk to add one. The library is shared across usersdiff --git a/server/nodes/tool/agent_builder/__init__.py b/server/nodes/tool/agent_builder/__init__.pyindex f98a6063..710a893c 100644--- a/server/nodes/tool/agent_builder/__init__.py+++ b/server/nodes/tool/agent_builder/__init__.py@@ -445,13 +445,42 @@ async def _catalogue_skills(database: Any, *, employee: bool) -> List[Dict[str,async def _connected_apps() -> List[str]:- """The app ids whose credentials are connected (config/employee_apps.json)."""+ """The app ids that are connected (services/employees/connections.py)."""from services.employees.connections import Connectionsfrom services.plugin.deps import get_auth_servicereturn await Connections(get_auth_service()).connected_app_ids()+async def _owner_apps() -> Mapping[str, Any]:+ """Every app an employee can use: config/employee_apps.json's, then the+ owner's own, such as custom connectors (``Connections.apps``)."""+ from services.employees.connections import Connections+ from services.plugin.deps import get_auth_service++ return await Connections(get_auth_service()).apps()+++def _app_field(node_type: str) -> Optional[str]:+ """The parameter naming a node's app, for a type whose app it does not+ say by itself (``BaseNode.app_field``: a custom connector)."""+ return getattr(get_node_class(node_type), "app_field", None)+++def _existing_tool(+ canvas: _Canvas, target: str, node_type: str, app: Optional[Tuple[str, str]], parameters: Mapping[str, Mapping[str, Any]]+) -> Optional[str]:+ """The ``node_type`` node on ``target``'s Tools. ``app`` (a parameter+ and the app's id) narrows it to the node naming that app in its saved+ ``parameters``, for a type several apps share."""+ for source in canvas.sources(target, TOOLS_INPUT):+ if (canvas.node(source) or {}).get("type") != node_type:+ continue+ if app is None or (parameters.get(source) or {}).get(app[0]) == app[1]:+ return source+ return None++async def _owner_timezone(database: Any) -> str:from services.employees.context import SETTINGS_USER_ID@@ -461,24 +490,30 @@ async def _owner_timezone(database: Any) -> str:async def _employee_tools(employee: _Employee) -> List[Dict[str, Any]]:"""What policy lets this employee be given: the tools every hire gets,- then the registry's app tools, each in the form it would be added."""- from services.employees.apps import get_apps+ then each app's tools (the registry's, then the owner's own), each in+ the form it would be added. A type several apps share (a custom+ connector) is listed once per app, with the ``app_id`` add_tool takes."""from services.employees.policy import BASE_TOOLS, check_toolconnected = set(await _connected_apps())- candidates = [(base.type, None) for base in BASE_TOOLS] + [(tool.type, app) for app in get_apps().values() for tool in app.tools]+ apps = await _owner_apps()+ candidates = [(base.type, None) for base in BASE_TOOLS] + [(tool.type, app) for app in apps.values() for tool in app.tools]catalogue: List[Dict[str, Any]] = []- seen: set[str] = set()+ seen: set = set()for node_type, app in candidates:- if node_type in seen:+ shared = app is not None and _app_field(node_type) is not None+ key = (node_type, app.id) if shared else node_type+ if key in seen:continuedecision = check_tool(node_type, employee=employee.row, connected=None, app=app)if not decision.allowed:continue- seen.add(node_type)+ seen.add(key)entry: Dict[str, Any] = {"type": node_type, "display_name": decision.label, "description": _description(get_node_class(node_type))}if app is not None:entry["app"] = app.name+ if shared:+ entry["app_id"] = app.identry["connected"] = app.id in connectedif decision.read_only:entry["read_only"] = True@@ -609,6 +644,12 @@ class AgentBuilderParams(BaseModel):description="For add_tool: the tool's node type, from inspect_canvas available_tools (e.g. 'httpRequest').",json_schema_extra={"displayOptions": {"show": {"operation": ["add_tool"]}}},)+ app_id: str = Field(+ default="",+ max_length=256,+ description="For add_tool: the tool's app_id, when its available_tools entry has one (each custom connector is its own app).",+ json_schema_extra={"displayOptions": {"show": {"operation": ["add_tool"]}}},+ )# add_skillskill_name: str = Field(@@ -919,7 +960,13 @@ class AgentBuilderNode(ToolNode):# Not a node type at all (a display name, say): a hint for# the agent, not a refusal to pass on.return _refused("add_tool", f"add_tool: '{node_type}' is not a node type. Use a type from inspect_canvas available_tools.")- decision = check_tool(node_type, employee=employee.row, connected=await _connected_apps())+ app = None+ if _app_field(node_type) is not None:+ # One type, many apps: the agent says which (its app_id).+ app = (await _owner_apps()).get(params.app_id) if params.app_id else None+ if app is None:+ return _refused("add_tool", f"add_tool: '{node_type}' needs the app_id of its entry in inspect_canvas available_tools.")+ decision = check_tool(node_type, employee=employee.row, connected=await _connected_apps(), app=app)if not decision.allowed:return _refused("add_tool", decision.reason)label, tool_params = decision.label, dict(decision.params)@@ -932,7 +979,17 @@ class AgentBuilderNode(ToolNode):problem = _unsaved(canvas, targets)if problem:return _refused("add_tool", problem)- expanded = [target for target in targets if canvas.source_of_type(target, TOOLS_INPUT, node_type) is None]+ # A type several apps share is the agent's tool only on the node+ # naming the same app.+ field_name = _app_field(node_type)+ named = (field_name, str(tool_params[field_name])) if field_name and tool_params.get(field_name) else None+ current: Dict[str, Dict[str, Any]] = {}+ if named is not None:+ for target in targets:+ for source in canvas.sources(target, TOOLS_INPUT):+ if (canvas.node(source) or {}).get("type") == node_type:+ current[source] = await database.get_node_parameters(source) or {}+ expanded = [target for target in targets if _existing_tool(canvas, target, node_type, named, current) is None]grant_ids: List[str] = []if employee is not None and expanded:permission = await _permission(database, ctx, params, node_type, expanded, {"parameters": tool_params}, grant_ids)@@ -970,7 +1027,7 @@ class AgentBuilderNode(ToolNode):if any(live.node(target) is None for target in targets):raise ValueError("The target agent was removed")target = targets[0]- existing = live.source_of_type(target, TOOLS_INPUT, node_type)+ existing = _existing_tool(live, target, node_type, named, saved_tool_parameters)owners = {str(edge.get("target")) for edge in live.edges if edge.get("source") == existing and(edge.get("targetHandle") or edge.get("target_handle")) == TOOLS_INPUT} if existing else set()if existing and owners == {target}:@@ -998,9 +1055,11 @@ class AgentBuilderNode(ToolNode):changed = bool(result.operations)removed = {op.get("edge_id") for op in result.operations if op.get("type") == "delete_edge"}run_types = {node.get("id"): node.get("type") for node in ctx.nodes or []}+ # Another node of a type several apps share names another app: its+ # tools have other names, so it is not replaced.replaces_bound_tool = caller in targets and any(edge.get("target") == caller and (edge.get("targetHandle") or edge.get("target_handle")) == TOOLS_INPUT and- (edge.get("id") in removed or (edge.get("source") != node_id and run_types.get(edge.get("source")) == node_type))+ (edge.get("id") in removed or (named is None and edge.get("source") != node_id and run_types.get(edge.get("source")) == node_type))for edge in ctx.edges or [])if replaces_bound_tool:diff --git a/server/skills/assistant/agent-builder-skill/SKILL.md b/server/skills/assistant/agent-builder-skill/SKILL.mdindex 75f534f0..b0f22f6f 100644--- a/server/skills/assistant/agent-builder-skill/SKILL.md+++ b/server/skills/assistant/agent-builder-skill/SKILL.md@@ -120,8 +120,9 @@ No other fields. Returns:### `add_tool`-Fields: `node_type`, optional `target_member_id` for a hired employee.-Wires a private tool instance to that member, defaulting to you. Another+Fields: `node_type`, `app_id` when its `available_tools` entry has one (each+custom connector is its own entry), optional `target_member_id` for a hired+employee. Wires a private tool instance to that member, defaulting to you. Anothermember's same-type node is never reused. An existing private binding isreused, so retries do not add duplicates. If an older graph shares yourbinding, Builder separates your connection and preserves its saved settingsdiff --git a/server/tests/nodes/test_agent_builder_employee.py b/server/tests/nodes/test_agent_builder_employee.pyindex 93097233..54b949be 100644--- a/server/tests/nodes/test_agent_builder_employee.py+++ b/server/tests/nodes/test_agent_builder_employee.py@@ -293,6 +293,50 @@ class TestTools:assert result.summary == "You already have Web search. Use it directly."+class TestConnectors:+ """Each custom connector is its own app (one node type, many apps): it is+ offered and added by its app_id."""++ @pytest.fixture+ def connectors(self, builder, monkeypatch):+ from nodes.mcp import mcp_connector+ from nodes.mcp._store import Connector++ saved_connectors = [Connector(ref="mcp:orders", slug="orders", meta={"name": "Orders"}), Connector(ref="mcp:crm", slug="crm", meta={"name": "CRM"})]++ async def list_connectors(**_scope):+ return saved_connectors++ monkeypatch.setattr(mcp_connector, "list_connectors", list_connectors)+ monkeypatch.setattr("services.employees.connections.source_apps", mcp_connector.connector_apps)+ builder.connected = ["mcp:orders", "mcp:crm"]++ async def test_each_is_offered_by_its_app_id(self, builder, database, connectors):+ await save_graph(database, employee_graph())+ await hire(database, ask_first=True)++ result = await call("inspect_canvas", talk())++ offered = [(entry["display_name"], entry["app_id"], entry["connected"]) for entry in result.available_tools if entry["type"] == "mcpConnector"]+ assert offered == [("Orders", "mcp:orders", True), ("CRM", "mcp:crm", True)]++ async def test_add_tool_adds_the_one_named(self, builder, database, connectors):+ await save_graph(database, employee_graph())+ await hire(database, ask_first=True)++ unnamed = await call("add_tool", talk(call="c1"), node_type="mcpConnector")+ assert unnamed.summary == "add_tool: 'mcpConnector' needs the app_id of its entry in inspect_canvas available_tools."+ orders = await call("add_tool", talk(call="c2"), node_type="mcpConnector", app_id="mcp:orders")+ assert orders.summary.startswith("Added Orders."), orders.summary+ # A second connector is a second tool, not the first one again.+ crm = await call("add_tool", talk(call="c3"), node_type="mcpConnector", app_id="mcp:crm")+ assert crm.summary.startswith("Added CRM."), crm.summary+ await call("add_tool", talk(call="c4"), node_type="mcpConnector", app_id="mcp:orders")++ tools = [edge["source"] for edge in edges_into(await saved(database), TALK, "input-tools") if edge["source"].startswith("7:mcpConnector")]+ assert [await database.get_node_parameters(tool) for tool in tools] == [{"mcp_connector": "mcp:orders"}, {"mcp_connector": "mcp:crm"}]++# ============================================================================# Skills# ============================================================================