daita-agents 0.2.0__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.
- daita/__init__.py +216 -0
- daita/agents/__init__.py +33 -0
- daita/agents/base.py +743 -0
- daita/agents/substrate.py +1141 -0
- daita/cli/__init__.py +145 -0
- daita/cli/__main__.py +7 -0
- daita/cli/ascii_art.py +44 -0
- daita/cli/core/__init__.py +0 -0
- daita/cli/core/create.py +254 -0
- daita/cli/core/deploy.py +473 -0
- daita/cli/core/deployments.py +309 -0
- daita/cli/core/import_detector.py +219 -0
- daita/cli/core/init.py +481 -0
- daita/cli/core/logs.py +239 -0
- daita/cli/core/managed_deploy.py +709 -0
- daita/cli/core/run.py +648 -0
- daita/cli/core/status.py +421 -0
- daita/cli/core/test.py +239 -0
- daita/cli/core/webhooks.py +172 -0
- daita/cli/main.py +588 -0
- daita/cli/utils.py +541 -0
- daita/config/__init__.py +62 -0
- daita/config/base.py +159 -0
- daita/config/settings.py +184 -0
- daita/core/__init__.py +262 -0
- daita/core/decision_tracing.py +701 -0
- daita/core/exceptions.py +480 -0
- daita/core/focus.py +251 -0
- daita/core/interfaces.py +76 -0
- daita/core/plugin_tracing.py +550 -0
- daita/core/relay.py +779 -0
- daita/core/reliability.py +381 -0
- daita/core/scaling.py +459 -0
- daita/core/tools.py +554 -0
- daita/core/tracing.py +770 -0
- daita/core/workflow.py +1144 -0
- daita/display/__init__.py +1 -0
- daita/display/console.py +160 -0
- daita/execution/__init__.py +58 -0
- daita/execution/client.py +856 -0
- daita/execution/exceptions.py +92 -0
- daita/execution/models.py +317 -0
- daita/llm/__init__.py +60 -0
- daita/llm/anthropic.py +291 -0
- daita/llm/base.py +530 -0
- daita/llm/factory.py +101 -0
- daita/llm/gemini.py +355 -0
- daita/llm/grok.py +219 -0
- daita/llm/mock.py +172 -0
- daita/llm/openai.py +220 -0
- daita/plugins/__init__.py +141 -0
- daita/plugins/base.py +37 -0
- daita/plugins/base_db.py +167 -0
- daita/plugins/elasticsearch.py +849 -0
- daita/plugins/mcp.py +481 -0
- daita/plugins/mongodb.py +520 -0
- daita/plugins/mysql.py +362 -0
- daita/plugins/postgresql.py +342 -0
- daita/plugins/redis_messaging.py +500 -0
- daita/plugins/rest.py +537 -0
- daita/plugins/s3.py +770 -0
- daita/plugins/slack.py +729 -0
- daita/utils/__init__.py +18 -0
- daita_agents-0.2.0.dist-info/METADATA +409 -0
- daita_agents-0.2.0.dist-info/RECORD +69 -0
- daita_agents-0.2.0.dist-info/WHEEL +5 -0
- daita_agents-0.2.0.dist-info/entry_points.txt +2 -0
- daita_agents-0.2.0.dist-info/licenses/LICENSE +56 -0
- daita_agents-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Webhook CLI commands for listing and managing webhook configurations.
|
|
3
|
+
|
|
4
|
+
Provides user-friendly access to webhook URLs and configurations
|
|
5
|
+
with organization-level security and optional API key filtering.
|
|
6
|
+
"""
|
|
7
|
+
import os
|
|
8
|
+
import asyncio
|
|
9
|
+
import aiohttp
|
|
10
|
+
import ssl
|
|
11
|
+
from typing import Dict, Any, Optional
|
|
12
|
+
from ...config.settings import settings
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_secure_api_endpoint() -> str:
|
|
16
|
+
"""Get validated API endpoint with security checks."""
|
|
17
|
+
# Use production API endpoint (can be overridden via environment)
|
|
18
|
+
endpoint = os.getenv("DAITA_API_ENDPOINT") or "https://ondk4sdyv0.execute-api.us-east-1.amazonaws.com"
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
return settings.validate_endpoint(endpoint)
|
|
22
|
+
except ValueError as e:
|
|
23
|
+
raise ValueError(f"Invalid API endpoint configuration: {e}")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
async def list_webhooks(api_key_only: bool = False, verbose: bool = False) -> bool:
|
|
27
|
+
"""
|
|
28
|
+
List all webhook URLs for the authenticated organization.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
api_key_only: If True, filter to webhooks created with current API key only
|
|
32
|
+
verbose: Enable verbose output
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
bool: True if successful, False otherwise
|
|
36
|
+
"""
|
|
37
|
+
# Check for DAITA_API_KEY
|
|
38
|
+
api_key = os.getenv("DAITA_API_KEY")
|
|
39
|
+
if not api_key:
|
|
40
|
+
print(" No DAITA_API_KEY found.")
|
|
41
|
+
print(" Get your API key at https://dashboard.daita-tech.io")
|
|
42
|
+
print(" Then: export DAITA_API_KEY='your-key-here'")
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
# Get secure API endpoint
|
|
47
|
+
api_endpoint = _get_secure_api_endpoint()
|
|
48
|
+
url = f"{api_endpoint}/api/v1/webhooks/list"
|
|
49
|
+
|
|
50
|
+
if api_key_only:
|
|
51
|
+
url += "?api_key_only=true"
|
|
52
|
+
|
|
53
|
+
headers = {
|
|
54
|
+
"Authorization": f"Bearer {api_key}",
|
|
55
|
+
"Content-Type": "application/json",
|
|
56
|
+
"User-Agent": "Daita-CLI/1.0.0"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Create secure SSL context
|
|
60
|
+
ssl_context = ssl.create_default_context()
|
|
61
|
+
ssl_context.check_hostname = True
|
|
62
|
+
ssl_context.verify_mode = ssl.CERT_REQUIRED
|
|
63
|
+
|
|
64
|
+
connector = aiohttp.TCPConnector(ssl=ssl_context)
|
|
65
|
+
|
|
66
|
+
async with aiohttp.ClientSession(connector=connector) as session:
|
|
67
|
+
if verbose:
|
|
68
|
+
print(f"📡 Fetching webhooks from {url}")
|
|
69
|
+
|
|
70
|
+
async with session.get(url, headers=headers, timeout=30) as response:
|
|
71
|
+
if response.status == 200:
|
|
72
|
+
data = await response.json()
|
|
73
|
+
await _display_webhooks(data, verbose)
|
|
74
|
+
return True
|
|
75
|
+
elif response.status == 401:
|
|
76
|
+
print(" Authentication failed - check your DAITA_API_KEY")
|
|
77
|
+
print(" Get a new API key at https://dashboard.daita-tech.io")
|
|
78
|
+
return False
|
|
79
|
+
elif response.status == 404:
|
|
80
|
+
print(" No webhook configurations found.")
|
|
81
|
+
print(" Deploy a project with webhook configurations using 'daita push'")
|
|
82
|
+
return True
|
|
83
|
+
else:
|
|
84
|
+
error_text = await response.text()
|
|
85
|
+
print(f" Failed to fetch webhooks (HTTP {response.status})")
|
|
86
|
+
if verbose:
|
|
87
|
+
print(f" Details: {error_text}")
|
|
88
|
+
return False
|
|
89
|
+
|
|
90
|
+
except aiohttp.ClientConnectorError:
|
|
91
|
+
print(" Cannot connect to Daita API")
|
|
92
|
+
print(" Check your internet connection and try again")
|
|
93
|
+
return False
|
|
94
|
+
except asyncio.TimeoutError:
|
|
95
|
+
print(" Request timed out")
|
|
96
|
+
print(" Try again or check your internet connection")
|
|
97
|
+
return False
|
|
98
|
+
except Exception as e:
|
|
99
|
+
print(f" Error fetching webhooks: {str(e)}")
|
|
100
|
+
if verbose:
|
|
101
|
+
import traceback
|
|
102
|
+
traceback.print_exc()
|
|
103
|
+
return False
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
async def _display_webhooks(data: Dict[str, Any], verbose: bool = False) -> None:
|
|
107
|
+
"""
|
|
108
|
+
Display webhook information in a user-friendly format.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
data: Response data from the webhook list API
|
|
112
|
+
verbose: Enable verbose output
|
|
113
|
+
"""
|
|
114
|
+
org_id = data.get("organization_id")
|
|
115
|
+
org_name = data.get("organization_name", f"Organization {org_id}")
|
|
116
|
+
total_webhooks = data.get("total_webhooks", 0)
|
|
117
|
+
agent_webhooks = data.get("agent_webhooks", {})
|
|
118
|
+
workflow_webhooks = data.get("workflow_webhooks", {})
|
|
119
|
+
|
|
120
|
+
if total_webhooks == 0:
|
|
121
|
+
print("")
|
|
122
|
+
print(" No webhook URLs found")
|
|
123
|
+
print("")
|
|
124
|
+
print("💡 To create webhooks:")
|
|
125
|
+
print(" 1. Add webhook configurations to your daita-project.yaml")
|
|
126
|
+
print(" 2. Deploy with 'daita push production'")
|
|
127
|
+
print("")
|
|
128
|
+
return
|
|
129
|
+
|
|
130
|
+
print("")
|
|
131
|
+
print(f" Webhook URLs (Organization: {org_name})")
|
|
132
|
+
print("")
|
|
133
|
+
|
|
134
|
+
# Display agent webhooks
|
|
135
|
+
if agent_webhooks:
|
|
136
|
+
print("Agent Webhooks:")
|
|
137
|
+
for agent_name, webhooks in agent_webhooks.items():
|
|
138
|
+
print(f" {agent_name}:")
|
|
139
|
+
for webhook in webhooks:
|
|
140
|
+
slug = webhook["webhook_slug"]
|
|
141
|
+
url = webhook["webhook_url"]
|
|
142
|
+
print(f" {slug:<20} → {url}")
|
|
143
|
+
|
|
144
|
+
if verbose and webhook.get("field_mapping"):
|
|
145
|
+
print(f" Field mapping: {webhook['field_mapping']}")
|
|
146
|
+
print("")
|
|
147
|
+
|
|
148
|
+
# Display workflow webhooks
|
|
149
|
+
if workflow_webhooks:
|
|
150
|
+
print("Workflow Webhooks:")
|
|
151
|
+
for workflow_name, webhooks in workflow_webhooks.items():
|
|
152
|
+
print(f" {workflow_name}:")
|
|
153
|
+
for webhook in webhooks:
|
|
154
|
+
slug = webhook["webhook_slug"]
|
|
155
|
+
url = webhook["webhook_url"]
|
|
156
|
+
print(f" {slug:<20} → {url}")
|
|
157
|
+
|
|
158
|
+
if verbose and webhook.get("field_mapping"):
|
|
159
|
+
print(f" Field mapping: {webhook['field_mapping']}")
|
|
160
|
+
print("")
|
|
161
|
+
|
|
162
|
+
# Add helpful usage information
|
|
163
|
+
print("💡 Usage:")
|
|
164
|
+
print(" • Copy webhook URLs to your external services (GitHub, Slack, etc.)")
|
|
165
|
+
print(" • Send HTTP POST requests with JSON payloads")
|
|
166
|
+
print(" • Field mapping will transform payloads automatically")
|
|
167
|
+
print("")
|
|
168
|
+
print("🔧 Example:")
|
|
169
|
+
print(" curl -X POST '<webhook-url>' \\")
|
|
170
|
+
print(" -H 'Content-Type: application/json' \\")
|
|
171
|
+
print(" -d '{\"your\": \"payload\"}'")
|
|
172
|
+
print("")
|