Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(approvals): the approval class table (RFC-0007 AP.1)
trohitga9a85fdeb325
diff --git a/RFC-0007-APPROVALS-ON-TEMPORAL.md b/RFC-0007-APPROVALS-ON-TEMPORAL.mdindex a2f67a44..12647397 100644--- a/RFC-0007-APPROVALS-ON-TEMPORAL.md+++ b/RFC-0007-APPROVALS-ON-TEMPORAL.md@@ -168,9 +168,12 @@ The table has the same shape as `repeats.py`:**The rules of the table:**- **The safe default.** An unlisted node type is `send`, and so is a value that a mapped field does not list. A new plugin then asks under the default mode and needs no edit. A test checks that every Literal value of a mapped field is listed.-- **Which data it reads.** `class_of` reads the tool's own input when the tool has a separate input model (`tool_input_model()` is not `Params`), and the merged node data otherwise. A Browser call without an `operation` runs `snapshot`, not the saved `navigate`.+- **Which data it reads.** `class_of` judges the tool's own input when the tool has a separate input model (`tool_input_model()` is not `Params`), and the merged node data otherwise; its caller passes that data. A Browser call without an `operation` runs `snapshot`, not the saved `navigate`.- **Lists.** A list value takes its worst member's class (montyExecutor's `capabilities`).-- **Calls a spec says do not send.** When a spec reports that a call does not send (`spec.sends(data)` is False), the call's class is `write` at most. This covers calendar changes without invites and a Dodo `call` on a GET endpoint. Under the default mode these run, as they do today with Ask first on.+- **Calls a spec says reach no one.** When a call's spec covers it and its `when` says the call reaches no one, a `send` call is `write`.+ - This covers calendar changes without invites: under the default mode they run, as they do today with Ask first on.+ - It never lowers `money`. A calendar delete without notices stays a delete; Hire's calendar app turns notices off, so lowering it would let every hired employee delete events unasked, even under "Only money and deletes".+ - So a Dodo `call` asks in every mode, a GET endpoint included: the table cannot see the endpoint. This is a false positive in the safe direction.- **The class decides; the spec renders.** A plugin's `ApprovalSpec` renders the card: recipient, body, subject, details, Edit fields and outcome labels.- The Browser keeps `restrict_while_asking` (§4.3).- In v1 the service holds Stripe instead of honouring `refuse_while_asking` (D8). v0 keeps the refusal.@@ -213,7 +216,7 @@ The table has the same shape as `repeats.py`:- the Browser's observations and `request_user`.- **write**- **The employee's own work:**- - agentBuilder's changes, canvas, employeeJob, fileModify, writeTodos, textToSpeech;+ - agentBuilder's changes, and `plan_update`, which counts as the change it plans; canvas, employeeJob, fileModify, writeTodos, textToSpeech;- simpleMemory `remember`/`update`/`forget`;- vectorStore `store`/`delete`;- dataSource `write`/`append`/`copy_to_workspace`;@@ -246,7 +249,7 @@ The table has the same shape as `repeats.py`:- **money**- **Money:**- stripeAction, every command;- - Dodo `create_refund`/`cancel_subscription`/`change_subscription_plan`/`call` (a `call` on a GET endpoint is `write`, above);+ - Dodo `create_refund`/`cancel_subscription`/`change_subscription_plan`/`call` (any endpoint: the table cannot see which);- apifyActor, a paid run.- **Deletes:**- Calendar, Contacts, Tasks and emailRead `delete`;diff --git a/server/services/approvals/classes.py b/server/services/approvals/classes.pynew file mode 100644index 00000000..b697de04--- /dev/null+++ b/server/services/approvals/classes.py@@ -0,0 +1,512 @@+"""What a node call may do, on Hire's ladder (``SIDE_EFFECTS`` in+services/employees/apps.py). The workflow's mode says which classes ask+(RFC-0007 §4.1, §4.2):++- ``read`` looks things up, and never asks;+- ``write`` works on the employee's own files, notes, team or the owner's+ phone;+- ``send`` reaches people or services: messages, posts, invites, deploys,+ cloud changes, commands on the computer, and fetching a URL;+- ``money`` spends money or deletes something.++An unlisted node type is ``send``, and so is a value a listed field does not+name: a new plugin asks under the default mode and needs no edit. A call its+approval spec says reaches no one (a calendar change without invites) is+``write``, not ``send``; the spec never lowers ``money``, so a delete stays a+delete.++The list lives here, not on the plugins. ``repeats.py`` answers another+question: whether a broken-off attempt may run again. Never imports+``nodes/``.+"""++from __future__ import annotations++from typing import Any, Dict, Mapping, Tuple++from services.approvals.repeats import _default++READ, WRITE, SEND, MONEY = "read", "write", "send", "money"+#: Mildest first.+LADDER: Tuple[str, ...] = (READ, WRITE, SEND, MONEY)+DEFAULT = SEND++#: Every call of these has this class.+CLASSES: Dict[str, str] = {+ # Triggers: they only wait, and are never an agent's tool call.+ "chatTrigger": READ,+ "discordInteraction": READ,+ "discordReceive": READ,+ "dodoPaymentsReceive": READ,+ "emailReceive": READ,+ "googleGmailReceive": READ,+ "msMailReceive": READ,+ "stripeReceive": READ,+ "taskTrigger": READ,+ "telegramReceive": READ,+ "twitterReceive": READ,+ "webhookTrigger": READ,+ "whatsappBusinessReceive": READ,+ "whatsappBusinessStatus": READ,+ "whatsappReceive": READ,+ # Chat models.+ "anthropicChatModel": READ,+ "cerebrasChatModel": READ,+ "deepseekChatModel": READ,+ "geminiChatModel": READ,+ "groqChatModel": READ,+ "kimiChatModel": READ,+ "lmstudioChatModel": READ,+ "mistralChatModel": READ,+ "ollamaChatModel": READ,+ "openaiChatModel": READ,+ "openaiCompatibleChatModel": READ,+ "openrouterChatModel": READ,+ "sarvamChatModel": READ,+ # Android monitors.+ "appList": READ,+ "batteryMonitor": READ,+ "environmentalSensors": READ,+ "location": READ,+ "motionDetection": READ,+ "networkMonitor": READ,+ "systemInfo": READ,+ # Search and provider reads (a search through a search provider is not a+ # URL fetch, D11).+ "braveSearch": READ,+ "detectLanguage": READ,+ "duckduckgoSearch": READ,+ "embeddingGenerator": READ,+ "gmaps_create": READ,+ "gmaps_locations": READ,+ "gmaps_nearby_places": READ,+ "perplexitySearch": READ,+ "serperSearch": READ,+ "speechToText": READ,+ "textGenerator": READ,+ "translateText": READ,+ "transliterateText": READ,+ "twitterSearch": READ,+ "twitterUser": READ,+ "visionAnalyze": READ,+ # Local reads and computation.+ "calculatorTool": READ,+ "chatHistory": READ,+ "console": READ,+ "context": READ,+ "currentTimeTool": READ,+ "documentParser": READ,+ "employeeJobSource": READ,+ "fileHandler": READ,+ "fileRead": READ,+ "fsSearch": READ,+ "gallery": READ,+ "masterSkill": READ,+ "proxyStatus": READ,+ "socialReceive": READ,+ "start": READ,+ "teamMonitor": READ,+ "textChunker": READ,+ # Waits, and the ask itself.+ "approvalGate": READ,+ "cronScheduler": READ,+ "timer": READ,+ # Answers to the owner, or to the request that started the run.+ "chatReply": READ,+ "chatUi": READ,+ "webhookResponse": READ,+ # The employee's team: a held assignment would reach the loop as "not+ # sent yet". Each teammate's own calls are checked.+ "taskManager": READ,+ # Agents: handing work to one asks nothing; each of its own tool calls is+ # checked.+ "aiAgent": READ,+ "chatAgent": READ,+ "ai_employee": READ,+ "android_agent": READ,+ "autonomous_agent": READ,+ "browser_agent": READ,+ "coding_agent": READ,+ "consumer_agent": READ,+ "orchestrator_agent": READ,+ "payments_agent": READ,+ "productivity_agent": READ,+ "social_agent": READ,+ "task_agent": READ,+ "tool_agent": READ,+ "travel_agent": READ,+ "web_agent": READ,+ # The employee's own work: its board, job, files, checklist and audio.+ "canvas": WRITE,+ "employeeJob": WRITE,+ "fileModify": WRITE,+ "textToSpeech": WRITE,+ "writeTodos": WRITE,+ # The owner's own phone.+ "airplaneModeControl": WRITE,+ "appLauncher": WRITE,+ "audioAutomation": WRITE,+ "bluetoothAutomation": WRITE,+ "cameraControl": WRITE,+ "deviceStateAutomation": WRITE,+ "mediaControl": WRITE,+ "screenControlAutomation": WRITE,+ "wifiAutomation": WRITE,+ # Sends (also the default; listed so the decision is visible).+ "chatSend": SEND,+ "discordSend": SEND,+ "emailSend": SEND,+ "socialSend": SEND,+ "telegramSend": SEND,+ "whatsappSend": SEND,+ # Commands on the computer (the code tools' sandboxes are weak, D16),+ # tools that drive apps, CLI agents, custom connectors.+ "shell": SEND,+ "javascriptExecutor": SEND,+ "pythonExecutor": SEND,+ "typescriptExecutor": SEND,+ "android_tool": SEND,+ "mobile_use_agent": SEND,+ "claude_code_agent": SEND,+ "codex_agent": SEND,+ "rlm_agent": SEND,+ "mcpConnector": SEND,+ # URL fetches (D11).+ "crawleeScraper": SEND,+ "fileDownloader": SEND,+ "httpScraper": SEND,+ # Money: every Stripe command, every paid Apify run.+ "apifyActor": MONEY,+ "stripeAction": MONEY,+}++#: These have the class their field's value names; any other value is+#: ``send``, and a list takes its worst member's class.+CLASSES_WHEN: Dict[str, Tuple[str, Dict[str, str]]] = {+ # Its lookups read; a plan counts as the change it plans.+ "agentBuilder": (+ "operation",+ {+ "inspect_canvas": READ,+ "inspect_node": READ,+ "search_docs": READ,+ "read_doc": READ,+ "plan_update": WRITE,+ "apply_update": WRITE,+ "add_tool": WRITE,+ "add_skill": WRITE,+ "add_subagent": WRITE,+ "create_workflow": WRITE,+ },+ ),+ "awsAction": (+ "operation",+ {+ "whoami": READ,+ "ec2_instances_list": READ,+ "ec2_instance_describe": READ,+ "s3_list": READ,+ "s3_download": READ,+ "list_operations": READ,+ "ec2_instance_start": SEND,+ "ec2_instance_stop": SEND,+ "s3_upload": SEND,+ "s3_delete": MONEY,+ "call": MONEY, # any operation of any service+ },+ ),+ # Observations and the owner's turn read; navigation fetches a URL (D11).+ # Site actions are send: while the mode asks, the spec's+ # restrict_while_asking runs them read-only instead of holding them.+ "browser": (+ "operation",+ {+ "snapshot": READ,+ "page_text": READ,+ "page_info": READ,+ "screenshot": READ,+ "diagnose": READ,+ "webmcp_list": READ,+ "wait": READ,+ "credential_bindings": READ,+ "request_user": READ,+ "close": WRITE, # node-only+ "navigate": SEND,+ "tabs": SEND, # one field: list, switch and close too+ "click": SEND,+ "hover": SEND,+ "type": SEND,+ "press": SEND,+ "select": SEND,+ "scroll": SEND,+ "back": SEND,+ "forward": SEND,+ "reload": SEND,+ "webmcp_call": SEND,+ "credential_fill": SEND,+ "evaluate": SEND, # node-only+ "run_python": SEND, # node-only+ },+ ),+ "cloudflareAction": (+ "operation",+ {+ "whoami": READ,+ "search_commands": READ,+ "zones_list": READ,+ "dns_records_list": READ,+ "graphql_query": READ,+ "dns_record_create": SEND,+ "dns_record_edit": SEND,+ "dns_record_delete": MONEY,+ "custom": MONEY,+ },+ ),+ "dataSource": (+ "operation",+ {+ "list": READ,+ "read": READ,+ "search": READ,+ "metadata": READ,+ "write": WRITE,+ "append": WRITE,+ "copy_to_workspace": WRITE,+ },+ ),+ "discordAction": (+ "operation",+ {+ "list_guilds": READ,+ "list_channels": READ,+ "get_channel": READ,+ "list_messages": READ,+ "get_message": READ,+ "download_attachments": READ,+ "create_thread": SEND,+ "edit_message": SEND,+ "add_reaction": SEND,+ "pin_message": SEND,+ "interaction_respond": SEND,+ "execute_webhook": SEND,+ "delete_message": MONEY,+ "custom": MONEY, # any route, any method+ },+ ),+ "dodoPaymentsAction": (+ "operation",+ {+ "list_payments": READ,+ "get_payment": READ,+ "list_subscriptions": READ,+ "get_subscription": READ,+ "list_customers": READ,+ "get_customer": READ,+ "list_products": READ,+ "get_product": READ,+ "list_refunds": READ,+ "list_disputes": READ,+ "list_operations": READ,+ "create_checkout_session": SEND,+ "create_customer": SEND,+ "create_customer_portal_link": SEND,+ "create_refund": MONEY,+ "cancel_subscription": MONEY,+ "change_subscription_plan": MONEY,+ "call": MONEY, # any endpoint, read or write+ },+ ),+ # A "Deleted" flag marks a message for deletion.+ "emailRead": (+ "operation",+ {"list": READ, "search": READ, "read": READ, "folders": READ, "move": SEND, "flag": MONEY, "delete": MONEY},+ ),+ "gcloudAction": (+ "operation",+ {+ "auth_list": READ,+ "config_list": READ,+ "projects_list": READ,+ "compute_instances_list": READ,+ "compute_instance_describe": READ,+ "run_services_list": READ,+ "run_service_describe": READ,+ "storage_ls": READ,+ "set_project": WRITE,+ "compute_instance_start": SEND,+ "compute_instance_stop": SEND,+ "run_deploy": SEND,+ "storage_cp": SEND,+ "storage_rm": MONEY,+ "custom": MONEY,+ },+ ),+ "githubAction": (+ "operation",+ {+ "pr_list": READ,+ "issue_list": READ,+ "repo_clone": WRITE,+ "pr_create": SEND,+ "pr_merge": SEND,+ "issue_create": SEND,+ "custom": MONEY,+ },+ ),+ "googleCalendar": ("operation", {"list": READ, "create": SEND, "update": SEND, "delete": MONEY}),+ "googleContacts": (+ "operation",+ {"list": READ, "search": READ, "get": READ, "create": SEND, "update": SEND, "delete": MONEY},+ ),+ "googleDrive": ("operation", {"download": READ, "list": READ, "upload": SEND, "share": SEND}),+ "googleGmail": ("operation", {"search": READ, "read": READ, "send": SEND}),+ "googleSheets": ("operation", {"read": READ, "write": SEND, "append": SEND}),+ "googleTasks": (+ "operation",+ {"list": READ, "create": SEND, "complete": SEND, "update": SEND, "delete": MONEY},+ ),+ # A URL fetch whatever the method (D11); DELETE deletes.+ "httpRequest": ("method", {"GET": SEND, "POST": SEND, "PUT": SEND, "PATCH": SEND, "DELETE": MONEY}),+ # Pure computation, unless the call takes a capability.+ "montyExecutor": ("capabilities", {"workspace_read": READ, "workspace_write": WRITE, "http_get": SEND}),+ "msCalendar": ("operation", {"list": READ, "create": SEND, "update": SEND, "delete": MONEY}),+ "msMail": (+ "operation",+ {+ "read": READ,+ "search": READ,+ "list_attachments": READ,+ "download_attachments": READ,+ "send": SEND,+ "reply": SEND,+ },+ ),+ "processManager": (+ "operation",+ {"list": READ, "get_output": READ, "stop": WRITE, "restart": WRITE, "start": SEND, "send_input": SEND},+ ),+ # OpenCompany's proxy settings: install-wide, and a provider's host is the+ # model's choice.+ "proxyConfig": (+ "operation",+ {+ "list_providers": READ,+ "get_stats": READ,+ "list_routing_rules": READ,+ "test_provider": READ, # a fixed test URL through the named provider+ "add_provider": SEND,+ "update_provider": SEND,+ "remove_provider": SEND,+ "set_credentials": SEND,+ "add_routing_rule": SEND,+ "remove_routing_rule": SEND,+ },+ ),+ "proxyRequest": ("method", {"GET": SEND, "POST": SEND, "PUT": SEND, "PATCH": SEND, "DELETE": MONEY}),+ "simpleMemory": (+ "operation",+ {"recall": READ, "list": READ, "get": READ, "remember": WRITE, "update": WRITE, "forget": WRITE},+ ),+ "tikhubAction": ("operation", {"list_endpoints": READ, "account": READ, "fetch_url": SEND, "call": SEND}),+ "twitterSend": (+ "action",+ {+ "tweet": SEND,+ "reply": SEND,+ "retweet": SEND,+ "quote": SEND,+ "like": SEND,+ "unlike": SEND,+ "delete": MONEY,+ },+ ),+ "vectorStore": ("operation", {"query": READ, "store": WRITE, "delete": WRITE}),+ "vercelAction": ("operation", {"inspect": READ, "list": READ, "deploy": SEND, "custom": MONEY}),+ "whatsappBusinessMedia": ("operation", {"get_url": READ, "download": READ, "upload": SEND, "delete": MONEY}),+ "whatsappBusinessSend": (+ "operation",+ {+ "list_templates": READ,+ "send_text": SEND,+ "send_media": SEND,+ "send_template": SEND,+ "send_buttons": SEND,+ "send_list": SEND,+ "send_cta_url": SEND,+ "send_reaction": SEND,+ "send_location": SEND,+ "send_contacts": SEND,+ },+ ),+ "whatsappDb": (+ "operation",+ {+ "chat_history": READ,+ "search_groups": READ,+ "get_group_info": READ,+ "get_contact_info": READ,+ "list_contacts": READ,+ "check_contacts": READ,+ "list_channels": READ,+ "get_channel_info": READ,+ "channel_messages": READ,+ "channel_stats": READ,+ "contact_profile_pic": READ,+ "newsletter_live_updates": READ, # subscribes this session to view counts+ "channel_follow": SEND,+ "channel_unfollow": SEND,+ "channel_create": SEND,+ "channel_mute": SEND,+ "channel_mark_viewed": SEND,+ "newsletter_react": SEND,+ },+ ),+}+++def class_of(node_cls: Any, data: Mapping[str, Any], *, tool_call: bool = False) -> str:+ """The class of this call of ``node_cls`` with ``data``.++ ``data`` is what the call runs with: the tool's own arguments when the+ tool has an input model of its own (a Browser call without an+ ``operation`` takes a snapshot, whatever the node's settings say), else+ the call's arguments over the node's settings. A field the call leaves+ unset takes the default of the model it validates against: the tool's+ input on an LLM tool call, else the node's ``Params``."""+ node_type = getattr(node_cls, "type", "")+ klass = CLASSES.get(node_type)+ rule = CLASSES_WHEN.get(node_type)+ if klass is None and rule is not None:+ field, values = rule+ value = data.get(field)+ if value is None:+ value = _default(node_cls, field, tool_call)+ data = {**data, field: value}+ klass = _value_class(values, value)+ klass = klass or DEFAULT+ if klass == SEND and _reaches_no_one(node_cls, data):+ return WRITE+ return klass+++def _value_class(values: Mapping[str, str], value: Any) -> str:+ if isinstance(value, (list, tuple)):+ # The worst member's class; an empty list asks for nothing.+ return max((_value_class(values, item) for item in value), key=LADDER.index, default=READ)+ return values.get(value, DEFAULT) if isinstance(value, str) else DEFAULT+++def _reaches_no_one(node_cls: Any, data: Mapping[str, Any]) -> bool:+ """Whether the node's approval spec covers this call and its ``when``+ says the call reaches no one."""+ from services.plugin.approval import approval_spec++ spec = approval_spec(node_cls)+ if spec is None or spec.when is None:+ return False+ if spec.operations is not None and str(data.get(spec.operation_field) or "") not in spec.operations:+ return False+ return not spec.sends(data)+++__all__ = ["CLASSES", "CLASSES_WHEN", "DEFAULT", "LADDER", "MONEY", "READ", "SEND", "WRITE", "class_of"]diff --git a/server/tests/services/approvals/test_classes.py b/server/tests/services/approvals/test_classes.pynew file mode 100644index 00000000..02bdfc9d--- /dev/null+++ b/server/tests/services/approvals/test_classes.py@@ -0,0 +1,151 @@+"""Which calls may run unasked (services/approvals/classes.py): the table+names real node types and values their field accepts, every value a mapped+field accepts has a class, an unlisted type is send, a field the call leaves+unset takes the default of the model the call validates against, and a spec+that says a call reaches no one makes a send a write."""++from __future__ import annotations++import types+import typing++import pytest++import nodes # noqa: F401 -- populate plugin registry+from services.approvals.classes import CLASSES, CLASSES_WHEN, LADDER, class_of+from services.approvals.repeats import REPEATABLE, repeatable+from services.employees.apps import SIDE_EFFECTS+from services.node_registry import get_node_class, registered_node_classes+from services.plugin.approval import approval_spec+from services.plugin.trigger import TriggerNode+++def _values(annotation) -> set:+ if typing.get_origin(annotation) is typing.Literal:+ return set(typing.get_args(annotation))+ return set().union(*(_values(arg) for arg in typing.get_args(annotation)))+++def _accepted(node_type: str, field: str) -> set:+ """The values the field accepts: its Literal values, or the+ ``enum_values`` its schema lists (montyExecutor's capabilities)."""+ cls = get_node_class(node_type)+ models = [cls.Params] + ([cls.tool_input_model()] if hasattr(cls, "tool_input_model") else [])+ accepted: set = set()+ for model in models:+ info = model.model_fields.get(field)+ if info is not None:+ extra = info.json_schema_extra if isinstance(info.json_schema_extra, dict) else {}+ accepted |= _values(info.annotation) | set(extra.get("enum_values") or ())+ return accepted+++def test_the_table_names_registered_node_types():+ assert sorted((set(CLASSES) | set(CLASSES_WHEN)) - set(registered_node_classes())) == []+ assert sorted(set(CLASSES) & set(CLASSES_WHEN)) == []+++def test_each_class_is_on_the_hire_ladder():+ assert LADDER == tuple(SIDE_EFFECTS)+ used = set(CLASSES.values()) | {klass for _, values in CLASSES_WHEN.values() for klass in values.values()}+ assert used <= set(LADDER)++[email protected]("node_type", sorted(CLASSES_WHEN))+def test_each_listed_value_is_one_the_field_accepts(node_type):+ field, values = CLASSES_WHEN[node_type]+ assert set(values) <= _accepted(node_type, field), sorted(set(values) - _accepted(node_type, field))++[email protected]("node_type", sorted(CLASSES_WHEN))+def test_every_value_the_field_accepts_has_a_class(node_type):+ # Otherwise a new operation would be send, and run unasked under "Only+ # money and deletes" though it spends or deletes.+ field, values = CLASSES_WHEN[node_type]+ assert _accepted(node_type, field) <= set(values), sorted(_accepted(node_type, field) - set(values))+++def test_a_read_may_run_again():+ # Triggers never run as a tool call, and a second run of an agent repeats+ # every tool call it made, so neither is in REPEATABLE.+ classes = registered_node_classes()+ exempt = {name for name, cls in classes.items() if issubclass(cls, TriggerNode) or cls.component_kind == "agent"}+ reads = {name for name, klass in CLASSES.items() if klass == "read"}+ assert sorted(reads - exempt - REPEATABLE) == []+ for node_type, (field, values) in CLASSES_WHEN.items():+ for value, klass in values.items():+ if klass == "read":+ assert repeatable(get_node_class(node_type), {field: value}), (node_type, value)+++def test_what_a_spec_holds_today_asks():+ # Every call a spec holds today asks under the default mode. The browser+ # restricts instead of holding; its classes are checked below.+ for node_type, cls in registered_node_classes().items():+ spec = approval_spec(cls)+ if spec is None or spec.restrict_while_asking:+ continue+ if node_type in CLASSES:+ assert CLASSES[node_type] in ("send", "money"), node_type+ continue+ rule = CLASSES_WHEN.get(node_type)+ if rule is None:+ continue # unlisted: send+ field, values = rule+ assert field == spec.operation_field, node_type+ for value in spec.operations or values:+ assert values.get(value, "send") in ("send", "money"), (node_type, value)+++ ("node_type", "data", "tool_call", "expected"),+ [+ ("googleGmail", {}, False, "send"), # its default operation sends+ ("googleGmail", {"operation": "search"}, False, "read"),+ ("googleGmail", {"operation": ["search", "send"]}, False, "send"), # a list: its worst member+ ("googleGmail", {"operation": "forward"}, False, "send"), # not a value it lists+ ("httpRequest", {}, False, "send"), # a GET fetches a URL (D11)+ ("httpRequest", {"method": "DELETE"}, False, "money"),+ ("browser", {}, True, "read"), # a model's call starts with a snapshot+ ("browser", {}, False, "send"), # the node navigates+ ("browser", {"operation": "request_user"}, True, "read"),+ ("browser", {"operation": "click"}, True, "send"), # restricted while asking, not held+ ("googleCalendar", {"operation": "create", "attendees": "[email protected]"}, False, "send"),+ ("googleCalendar", {"operation": "create", "attendees": "[email protected]", "send_updates": "none"}, False, "write"),+ ("googleCalendar", {"operation": "delete", "send_updates": "none"}, False, "money"), # a delete stays a delete+ ("msCalendar", {"operation": "create"}, False, "write"), # no attendees, no invites+ ("dodoPaymentsAction", {}, False, "read"), # list_payments+ ("dodoPaymentsAction", {"operation": "call", "endpoint": "payments.list"}, False, "money"), # any endpoint+ ("awsAction", {"operation": "call", "api_operation": "describe_vpcs"}, False, "money"),+ ("stripeAction", {"command": "customers list"}, False, "money"),+ ("twitterSend", {}, False, "send"), # a tweet+ ("twitterSend", {"action": "delete"}, False, "money"),+ ("emailRead", {"operation": "flag"}, False, "money"), # "Deleted" deletes+ ("whatsappBusinessMedia", {"operation": "delete"}, True, "money"),+ ("montyExecutor", {"code": "1"}, True, "read"),+ ("montyExecutor", {"capabilities": ["workspace_read", "workspace_write"]}, True, "write"),+ ("montyExecutor", {"capabilities": ["workspace_read", "http_get"]}, True, "send"), # it may fetch a URL+ ("pythonExecutor", {"code": "1"}, True, "send"), # D16+ ("simpleMemory", {"operation": "recall"}, True, "read"),+ ("simpleMemory", {"operation": "remember", "content": "x"}, True, "write"),+ ("agentBuilder", {}, True, "read"), # inspect_canvas+ ("agentBuilder", {"operation": "add_tool"}, True, "write"),+ ("taskManager", {}, True, "read"),+ ("proxyConfig", {"operation": "add_provider"}, True, "send"),+ ("fileModify", {"operation": "edit"}, False, "write"),+ ("vectorStore", {}, False, "write"), # store+ ("dataSource", {"operation": "write"}, True, "write"),+ ("mcpConnector", {}, True, "send"),+ ("mcpConnector", {"mcp_ask": False}, True, "write"), # its Ask first is off+ ("approvalGate", {}, False, "read"),+ ("chatTrigger", {}, False, "read"),+ ("aiAgent", {"prompt": "x"}, True, "read"),+ ("whatsappSend", {"message": "hi"}, True, "send"),+ ],+)+def test_a_call_has_its_class(node_type, data, tool_call, expected):+ assert class_of(get_node_class(node_type), data, tool_call=tool_call) == expected+++def test_an_unlisted_type_is_send():+ assert class_of(types.SimpleNamespace(type="brandNewNode"), {}, tool_call=True) == "send"