flock-core 0.4.527__py3-none-any.whl → 0.5.0b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flock-core might be problematic. Click here for more details.

Files changed (130) hide show
  1. flock/cli/execute_flock.py +1 -1
  2. flock/cli/manage_agents.py +6 -6
  3. flock/components/__init__.py +30 -0
  4. flock/components/evaluation/__init__.py +9 -0
  5. flock/components/evaluation/declarative_evaluation_component.py +222 -0
  6. flock/components/routing/__init__.py +15 -0
  7. flock/{routers/conditional/conditional_router.py → components/routing/conditional_routing_component.py} +61 -53
  8. flock/components/routing/default_routing_component.py +103 -0
  9. flock/components/routing/llm_routing_component.py +206 -0
  10. flock/components/utility/__init__.py +15 -0
  11. flock/{modules/enterprise_memory/enterprise_memory_module.py → components/utility/memory_utility_component.py} +195 -173
  12. flock/{modules/performance/metrics_module.py → components/utility/metrics_utility_component.py} +110 -95
  13. flock/{modules/output/output_module.py → components/utility/output_utility_component.py} +47 -45
  14. flock/core/__init__.py +26 -18
  15. flock/core/agent/__init__.py +16 -0
  16. flock/core/agent/flock_agent_components.py +104 -0
  17. flock/core/agent/flock_agent_execution.py +101 -0
  18. flock/core/agent/flock_agent_integration.py +206 -0
  19. flock/core/agent/flock_agent_lifecycle.py +177 -0
  20. flock/core/agent/flock_agent_serialization.py +381 -0
  21. flock/core/api/endpoints.py +2 -2
  22. flock/core/api/service.py +2 -2
  23. flock/core/component/__init__.py +15 -0
  24. flock/core/{flock_module.py → component/agent_component_base.py} +136 -34
  25. flock/core/component/evaluation_component.py +56 -0
  26. flock/core/component/routing_component.py +74 -0
  27. flock/core/component/utility_component.py +69 -0
  28. flock/core/config/flock_agent_config.py +49 -2
  29. flock/core/evaluation/utils.py +3 -2
  30. flock/core/execution/batch_executor.py +1 -1
  31. flock/core/execution/evaluation_executor.py +2 -2
  32. flock/core/execution/opik_executor.py +1 -1
  33. flock/core/flock.py +147 -493
  34. flock/core/flock_agent.py +195 -1032
  35. flock/core/flock_factory.py +114 -90
  36. flock/core/flock_scheduler.py +1 -1
  37. flock/core/flock_server_manager.py +8 -8
  38. flock/core/logging/logging.py +1 -0
  39. flock/core/mcp/flock_mcp_server.py +53 -48
  40. flock/core/mcp/{flock_mcp_tool_base.py → flock_mcp_tool.py} +2 -2
  41. flock/core/mcp/mcp_client.py +9 -9
  42. flock/core/mcp/mcp_client_manager.py +9 -9
  43. flock/core/mcp/mcp_config.py +24 -24
  44. flock/core/mixin/dspy_integration.py +5 -5
  45. flock/core/orchestration/__init__.py +18 -0
  46. flock/core/orchestration/flock_batch_processor.py +94 -0
  47. flock/core/orchestration/flock_evaluator.py +113 -0
  48. flock/core/orchestration/flock_execution.py +288 -0
  49. flock/core/orchestration/flock_initialization.py +125 -0
  50. flock/core/orchestration/flock_server_manager.py +67 -0
  51. flock/core/orchestration/flock_web_server.py +117 -0
  52. flock/core/registry/__init__.py +45 -0
  53. flock/core/registry/agent_registry.py +69 -0
  54. flock/core/registry/callable_registry.py +139 -0
  55. flock/core/registry/component_discovery.py +142 -0
  56. flock/core/registry/component_registry.py +64 -0
  57. flock/core/registry/config_mapping.py +64 -0
  58. flock/core/registry/decorators.py +137 -0
  59. flock/core/registry/registry_hub.py +205 -0
  60. flock/core/registry/server_registry.py +57 -0
  61. flock/core/registry/type_registry.py +86 -0
  62. flock/core/serialization/flock_serializer.py +36 -32
  63. flock/core/serialization/serialization_utils.py +28 -25
  64. flock/core/util/hydrator.py +1 -1
  65. flock/core/util/input_resolver.py +29 -2
  66. flock/mcp/servers/sse/flock_sse_server.py +10 -10
  67. flock/mcp/servers/stdio/flock_stdio_server.py +10 -10
  68. flock/mcp/servers/streamable_http/flock_streamable_http_server.py +10 -10
  69. flock/mcp/servers/websockets/flock_websocket_server.py +10 -10
  70. flock/platform/docker_tools.py +3 -3
  71. flock/webapp/app/chat.py +1 -1
  72. flock/webapp/app/main.py +9 -5
  73. flock/webapp/app/services/flock_service.py +1 -1
  74. flock/webapp/app/services/sharing_store.py +1 -0
  75. flock/workflow/activities.py +67 -92
  76. flock/workflow/agent_execution_activity.py +6 -6
  77. flock/workflow/flock_workflow.py +1 -1
  78. flock_core-0.5.0b0.dist-info/METADATA +272 -0
  79. {flock_core-0.4.527.dist-info → flock_core-0.5.0b0.dist-info}/RECORD +82 -95
  80. flock/core/flock_evaluator.py +0 -60
  81. flock/core/flock_registry.py +0 -702
  82. flock/core/flock_router.py +0 -83
  83. flock/evaluators/__init__.py +0 -1
  84. flock/evaluators/declarative/__init__.py +0 -1
  85. flock/evaluators/declarative/declarative_evaluator.py +0 -217
  86. flock/evaluators/memory/memory_evaluator.py +0 -90
  87. flock/evaluators/test/test_case_evaluator.py +0 -38
  88. flock/evaluators/zep/zep_evaluator.py +0 -59
  89. flock/modules/__init__.py +0 -1
  90. flock/modules/assertion/__init__.py +0 -1
  91. flock/modules/assertion/assertion_module.py +0 -286
  92. flock/modules/callback/__init__.py +0 -1
  93. flock/modules/callback/callback_module.py +0 -91
  94. flock/modules/enterprise_memory/README.md +0 -99
  95. flock/modules/mem0/__init__.py +0 -1
  96. flock/modules/mem0/mem0_module.py +0 -126
  97. flock/modules/mem0_async/__init__.py +0 -1
  98. flock/modules/mem0_async/async_mem0_module.py +0 -126
  99. flock/modules/memory/__init__.py +0 -1
  100. flock/modules/memory/memory_module.py +0 -429
  101. flock/modules/memory/memory_parser.py +0 -125
  102. flock/modules/memory/memory_storage.py +0 -736
  103. flock/modules/output/__init__.py +0 -1
  104. flock/modules/performance/__init__.py +0 -1
  105. flock/modules/zep/__init__.py +0 -1
  106. flock/modules/zep/zep_module.py +0 -192
  107. flock/routers/__init__.py +0 -1
  108. flock/routers/agent/__init__.py +0 -1
  109. flock/routers/agent/agent_router.py +0 -236
  110. flock/routers/agent/handoff_agent.py +0 -58
  111. flock/routers/default/__init__.py +0 -1
  112. flock/routers/default/default_router.py +0 -80
  113. flock/routers/feedback/feedback_router.py +0 -114
  114. flock/routers/list_generator/list_generator_router.py +0 -166
  115. flock/routers/llm/__init__.py +0 -1
  116. flock/routers/llm/llm_router.py +0 -365
  117. flock/tools/__init__.py +0 -0
  118. flock/tools/azure_tools.py +0 -781
  119. flock/tools/code_tools.py +0 -167
  120. flock/tools/file_tools.py +0 -149
  121. flock/tools/github_tools.py +0 -157
  122. flock/tools/markdown_tools.py +0 -205
  123. flock/tools/system_tools.py +0 -9
  124. flock/tools/text_tools.py +0 -810
  125. flock/tools/web_tools.py +0 -90
  126. flock/tools/zendesk_tools.py +0 -147
  127. flock_core-0.4.527.dist-info/METADATA +0 -674
  128. {flock_core-0.4.527.dist-info → flock_core-0.5.0b0.dist-info}/WHEEL +0 -0
  129. {flock_core-0.4.527.dist-info → flock_core-0.5.0b0.dist-info}/entry_points.txt +0 -0
  130. {flock_core-0.4.527.dist-info → flock_core-0.5.0b0.dist-info}/licenses/LICENSE +0 -0
flock/tools/web_tools.py DELETED
@@ -1,90 +0,0 @@
1
-
2
- import importlib
3
- import os
4
- from typing import Literal
5
-
6
- from flock.core.logging.trace_and_logged import traced_and_logged
7
-
8
-
9
- @traced_and_logged
10
- def web_search_tavily(query: str):
11
- if importlib.util.find_spec("tavily") is not None:
12
- from tavily import TavilyClient
13
-
14
- client = TavilyClient(api_key=os.getenv("TAVILY_API_KEY"))
15
- try:
16
- response = client.search(query, include_answer=True) # type: ignore
17
- return response
18
- except Exception:
19
- raise
20
- else:
21
- raise ImportError(
22
- "Optional tool dependencies not installed. Install with 'pip install flock-core[tools]'."
23
- )
24
-
25
-
26
- @traced_and_logged
27
- def web_search_duckduckgo(
28
- keywords: str, search_type: Literal["news", "web"] = "web"
29
- ):
30
- try:
31
- if importlib.util.find_spec("duckduckgo_search") is not None:
32
- from duckduckgo_search import DDGS
33
-
34
- if search_type == "news":
35
- response = DDGS().news(keywords)
36
- else:
37
- response = DDGS().text(keywords)
38
-
39
- return response
40
- else:
41
- raise ImportError(
42
- "Optional tool dependencies not installed. Install with 'pip install flock-core[tools]'."
43
- )
44
- except Exception:
45
- raise
46
-
47
-
48
- @traced_and_logged
49
- def web_search_bing(keywords: str):
50
- try:
51
- import httpx
52
-
53
- subscription_key = os.environ["BING_SEARCH_V7_SUBSCRIPTION_KEY"]
54
- endpoint = "https://api.bing.microsoft.com/v7.0/search"
55
-
56
- # Query term(s) to search for.
57
- query = keywords
58
-
59
- # Construct a request
60
- mkt = "en-US"
61
- params = {"q": query, "mkt": mkt}
62
- headers = {"Ocp-Apim-Subscription-Key": subscription_key}
63
-
64
- response = httpx.get(endpoint, headers=headers, params=params)
65
- response.raise_for_status()
66
- search_results = response.json()
67
- return search_results["webPages"]
68
- except Exception:
69
- raise
70
-
71
- @traced_and_logged
72
- def web_content_as_markdown(url: str) -> str:
73
- if (
74
- importlib.util.find_spec("httpx") is not None
75
- and importlib.util.find_spec("markdownify") is not None
76
- ):
77
- import httpx
78
- from markdownify import markdownify as md
79
-
80
- try:
81
- response = httpx.get(url)
82
- response.raise_for_status()
83
- markdown = md(response.text)
84
- return markdown
85
- except Exception:
86
- raise
87
- else:
88
- raise ImportError(
89
- "Optional tool dependencies not installed. Install with 'pip install flock-core[tools]'."
90
- )
@@ -1,147 +0,0 @@
1
- """Tools for interacting with Zendesk."""
2
-
3
- import os
4
-
5
- import httpx
6
- from mcp.server.fastmcp import FastMCP
7
-
8
- mcp = FastMCP("ZendeskTools")
9
-
10
-
11
- ZENDESK_BEARER_TOKEN = os.getenv("ZENDESK_BEARER_TOKEN")
12
-
13
- HEADERS = {
14
- "Authorization": f"Bearer {ZENDESK_BEARER_TOKEN}",
15
- "Accept": "application/json",
16
- }
17
-
18
-
19
- @mcp.tool()
20
- def zendesk_get_tickets(number_of_tickets: int = 10) -> list[dict]:
21
- """Get all tickets."""
22
- ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_TICKET")
23
- BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
24
- url = f"{BASE_URL}/api/v2/tickets.json"
25
- all_tickets = []
26
- with httpx.Client(headers=HEADERS, timeout=30.0) as client:
27
- while url and len(all_tickets) < number_of_tickets:
28
- response = client.get(url)
29
- response.raise_for_status()
30
-
31
- data = response.json()
32
- tickets = data.get("tickets", [])
33
- all_tickets.extend(tickets)
34
-
35
- url = data.get("next_page")
36
- return all_tickets
37
-
38
- @mcp.tool()
39
- def zendesk_get_ticket_by_id(ticket_id: str) -> dict:
40
- """Get a ticket by ID."""
41
- ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_TICKET")
42
- BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
43
- url = f"{BASE_URL}/api/v2/tickets/{ticket_id}"
44
- with httpx.Client(headers=HEADERS, timeout=30.0) as client:
45
- response = client.get(url)
46
- response.raise_for_status()
47
- return response.json()["ticket"]
48
-
49
- @mcp.tool()
50
- def zendesk_get_comments_by_ticket_id(ticket_id: str) -> list[dict]:
51
- """Get all comments for a ticket."""
52
- ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_TICKET")
53
- BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
54
- url = f"{BASE_URL}/api/v2/tickets/{ticket_id}/comments"
55
- with httpx.Client(headers=HEADERS, timeout=30.0) as client:
56
- response = client.get(url)
57
- response.raise_for_status()
58
- return response.json()["comments"]
59
-
60
- @mcp.tool()
61
- def zendesk_get_article_by_id(article_id: str) -> dict:
62
- """Get an article by ID."""
63
- ZENDESK_LOCALE = os.getenv("ZENDESK_ARTICLE_LOCALE")
64
- ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_ARTICLE")
65
- BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
66
- url = (
67
- f"{BASE_URL}/api/v2/help_center/{ZENDESK_LOCALE}/articles/{article_id}"
68
- )
69
- with httpx.Client(headers=HEADERS, timeout=30.0) as client:
70
- response = client.get(url)
71
- response.raise_for_status()
72
- return response.json()["article"]
73
-
74
- @mcp.tool()
75
- def zendesk_get_articles() -> list[dict]:
76
- """Get all articles."""
77
- ZENDESK_LOCALE = os.getenv("ZENDESK_ARTICLE_LOCALE")
78
- ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_ARTICLE")
79
- BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
80
- url = f"{BASE_URL}/api/v2/help_center/{ZENDESK_LOCALE}/articles.json"
81
- with httpx.Client(headers=HEADERS, timeout=30.0) as client:
82
- response = client.get(url)
83
- response.raise_for_status()
84
- return response.json()["articles"]
85
-
86
- @mcp.tool()
87
- def zendesk_get_articles_count() -> int:
88
- """
89
- Count every Help-Center article in the configured locale.
90
-
91
- Uses cursor pagination (page[size]=100) because it’s faster and
92
- has no 10 000-record ceiling. Falls back to offset pagination
93
- if the account hasn’t been migrated yet.
94
- """
95
- ZENDESK_LOCALE = os.getenv("ZENDESK_ARTICLE_LOCALE") # e.g. "en-us"
96
- ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_ARTICLE")
97
- BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
98
- url = (
99
- f"{BASE_URL}/api/v2/help_center/{ZENDESK_LOCALE}/articles.json"
100
- "?page[size]=100" # max page size for HC APIs
101
- )
102
-
103
- total = 0
104
- with httpx.Client(headers=HEADERS, timeout=30.0) as client:
105
- while url:
106
- resp = client.get(url)
107
- resp.raise_for_status()
108
- data = resp.json()
109
-
110
- total += len(data.get("articles", []))
111
- print(f"Locale: {ZENDESK_LOCALE}")
112
- print(f"Number of articles: {total}")
113
-
114
- # Cursor pagination (preferred)
115
- if data.get("meta", {}).get("has_more"):
116
- url = data.get("links", {}).get("next")
117
- continue
118
-
119
- # Offset pagination fallback
120
- url = data.get("next_page")
121
-
122
- return total
123
-
124
- @mcp.tool()
125
- def zendesk_search_articles(query: str) -> list[dict]:
126
- """Search Zendesk Help Center articles using a query string."""
127
- ZENDESK_LOCALE = os.getenv("ZENDESK_ARTICLE_LOCALE") # e.g., "en-us"
128
- ZENDESK_SUBDOMAIN = os.getenv("ZENDESK_SUBDOMAIN_ARTICLE")
129
- BASE_URL = f"https://{ZENDESK_SUBDOMAIN}.zendesk.com"
130
- url = f"{BASE_URL}/api/v2/help_center/articles/search.json"
131
-
132
- params = {
133
- "query": query,
134
- "locale": ZENDESK_LOCALE,
135
- "sort_by": "updated_at",
136
- "sort_order": "desc",
137
- }
138
-
139
- with httpx.Client(headers=HEADERS, timeout=30.0) as client:
140
- response = client.get(url, params=params)
141
- response.raise_for_status()
142
- return response.json().get("results", [])
143
-
144
-
145
- if __name__ == "__main__":
146
- transport = os.getenv("ZENDESK_MCP_TRANSPORT", "stdio")
147
- mcp.run(transport=transport)