mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
feat: add Feishu document comment intelligent reply with 3-tier access control
- Full comment handler: parse drive.notice.comment_add_v1 events, build timeline, run agent, deliver reply with chunking support. - 5 tools: feishu_doc_read, feishu_drive_list_comments, feishu_drive_list_comment_replies, feishu_drive_reply_comment, feishu_drive_add_comment. - 3-tier access control rules (exact doc > wildcard "*" > top-level > defaults) with per-field fallback. Config via ~/.hermes/feishu_comment_rules.json, mtime-cached hot-reload. - Self-reply filter using generalized self_open_id (supports future user-identity subscriptions). Receiver check: only process events where the bot is the @mentioned target. - Smart timeline selection, long text chunking, semantic text extraction, session sharing per document, wiki link resolution. Change-Id: I31e82fd6355173dbcc400b8934b6d9799e3137b9
This commit is contained in:
parent
9b14b76eb3
commit
85cdb04bd4
9 changed files with 3059 additions and 0 deletions
62
tests/tools/test_feishu_tools.py
Normal file
62
tests/tools/test_feishu_tools.py
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
"""Tests for feishu_doc_tool and feishu_drive_tool — registration and schema validation."""
|
||||
|
||||
import importlib
|
||||
import unittest
|
||||
|
||||
from tools.registry import registry
|
||||
|
||||
# Trigger tool discovery so feishu tools get registered
|
||||
importlib.import_module("tools.feishu_doc_tool")
|
||||
importlib.import_module("tools.feishu_drive_tool")
|
||||
|
||||
|
||||
class TestFeishuToolRegistration(unittest.TestCase):
|
||||
"""Verify feishu tools are registered and have valid schemas."""
|
||||
|
||||
EXPECTED_TOOLS = {
|
||||
"feishu_doc_read": "feishu_doc",
|
||||
"feishu_drive_list_comments": "feishu_drive",
|
||||
"feishu_drive_list_comment_replies": "feishu_drive",
|
||||
"feishu_drive_reply_comment": "feishu_drive",
|
||||
"feishu_drive_add_comment": "feishu_drive",
|
||||
}
|
||||
|
||||
def test_all_tools_registered(self):
|
||||
for tool_name, toolset in self.EXPECTED_TOOLS.items():
|
||||
entry = registry.get_entry(tool_name)
|
||||
self.assertIsNotNone(entry, f"{tool_name} not registered")
|
||||
self.assertEqual(entry.toolset, toolset)
|
||||
|
||||
def test_schemas_have_required_fields(self):
|
||||
for tool_name in self.EXPECTED_TOOLS:
|
||||
entry = registry.get_entry(tool_name)
|
||||
schema = entry.schema
|
||||
self.assertIn("name", schema)
|
||||
self.assertEqual(schema["name"], tool_name)
|
||||
self.assertIn("description", schema)
|
||||
self.assertIn("parameters", schema)
|
||||
self.assertIn("type", schema["parameters"])
|
||||
self.assertEqual(schema["parameters"]["type"], "object")
|
||||
|
||||
def test_handlers_are_callable(self):
|
||||
for tool_name in self.EXPECTED_TOOLS:
|
||||
entry = registry.get_entry(tool_name)
|
||||
self.assertTrue(callable(entry.handler))
|
||||
|
||||
def test_doc_read_schema_params(self):
|
||||
entry = registry.get_entry("feishu_doc_read")
|
||||
props = entry.schema["parameters"].get("properties", {})
|
||||
self.assertIn("doc_token", props)
|
||||
|
||||
def test_drive_tools_require_file_token(self):
|
||||
for tool_name in self.EXPECTED_TOOLS:
|
||||
if tool_name == "feishu_doc_read":
|
||||
continue
|
||||
entry = registry.get_entry(tool_name)
|
||||
props = entry.schema["parameters"].get("properties", {})
|
||||
self.assertIn("file_token", props, f"{tool_name} missing file_token param")
|
||||
self.assertIn("file_type", props, f"{tool_name} missing file_type param")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue