signalwire-agents 0.1.0__tar.gz

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.
Files changed (55) hide show
  1. signalwire_agents-0.1.0/PKG-INFO +154 -0
  2. signalwire_agents-0.1.0/README.md +128 -0
  3. signalwire_agents-0.1.0/docs/agent_guide.md +565 -0
  4. signalwire_agents-0.1.0/docs/swml_service_guide.md +424 -0
  5. signalwire_agents-0.1.0/examples/auto_vivified_example.py +382 -0
  6. signalwire_agents-0.1.0/examples/basic_swml_service.py +392 -0
  7. signalwire_agents-0.1.0/examples/concierge_agent_example.py +154 -0
  8. signalwire_agents-0.1.0/examples/declarative_agent.py +186 -0
  9. signalwire_agents-0.1.0/examples/dynamic_swml_service.py +403 -0
  10. signalwire_agents-0.1.0/examples/env_auth_simple.py +27 -0
  11. signalwire_agents-0.1.0/examples/env_auth_test.py +69 -0
  12. signalwire_agents-0.1.0/examples/faq_bot_agent.py +120 -0
  13. signalwire_agents-0.1.0/examples/multi_agent_server.py +154 -0
  14. signalwire_agents-0.1.0/examples/simple_agent.py +358 -0
  15. signalwire_agents-0.1.0/examples/stateful_agent.py +286 -0
  16. signalwire_agents-0.1.0/examples/survey_agent_example.py +322 -0
  17. signalwire_agents-0.1.0/examples/swaig_features_agent.py +193 -0
  18. signalwire_agents-0.1.0/examples/swml_service_example.py +132 -0
  19. signalwire_agents-0.1.0/examples/test_swaig_function.py +86 -0
  20. signalwire_agents-0.1.0/pyproject.toml +47 -0
  21. signalwire_agents-0.1.0/schema.json +5611 -0
  22. signalwire_agents-0.1.0/setup.cfg +4 -0
  23. signalwire_agents-0.1.0/setup.py +15 -0
  24. signalwire_agents-0.1.0/signalwire_agents/__init__.py +17 -0
  25. signalwire_agents-0.1.0/signalwire_agents/agent_server.py +336 -0
  26. signalwire_agents-0.1.0/signalwire_agents/core/__init__.py +20 -0
  27. signalwire_agents-0.1.0/signalwire_agents/core/agent_base.py +2449 -0
  28. signalwire_agents-0.1.0/signalwire_agents/core/function_result.py +104 -0
  29. signalwire_agents-0.1.0/signalwire_agents/core/pom_builder.py +195 -0
  30. signalwire_agents-0.1.0/signalwire_agents/core/security/__init__.py +0 -0
  31. signalwire_agents-0.1.0/signalwire_agents/core/security/session_manager.py +170 -0
  32. signalwire_agents-0.1.0/signalwire_agents/core/state/__init__.py +8 -0
  33. signalwire_agents-0.1.0/signalwire_agents/core/state/file_state_manager.py +210 -0
  34. signalwire_agents-0.1.0/signalwire_agents/core/state/state_manager.py +92 -0
  35. signalwire_agents-0.1.0/signalwire_agents/core/swaig_function.py +163 -0
  36. signalwire_agents-0.1.0/signalwire_agents/core/swml_builder.py +205 -0
  37. signalwire_agents-0.1.0/signalwire_agents/core/swml_handler.py +218 -0
  38. signalwire_agents-0.1.0/signalwire_agents/core/swml_renderer.py +359 -0
  39. signalwire_agents-0.1.0/signalwire_agents/core/swml_service.py +1009 -0
  40. signalwire_agents-0.1.0/signalwire_agents/prefabs/__init__.py +15 -0
  41. signalwire_agents-0.1.0/signalwire_agents/prefabs/concierge.py +276 -0
  42. signalwire_agents-0.1.0/signalwire_agents/prefabs/faq_bot.py +314 -0
  43. signalwire_agents-0.1.0/signalwire_agents/prefabs/info_gatherer.py +253 -0
  44. signalwire_agents-0.1.0/signalwire_agents/prefabs/survey.py +387 -0
  45. signalwire_agents-0.1.0/signalwire_agents/schema.json +5611 -0
  46. signalwire_agents-0.1.0/signalwire_agents/utils/__init__.py +0 -0
  47. signalwire_agents-0.1.0/signalwire_agents/utils/pom_utils.py +0 -0
  48. signalwire_agents-0.1.0/signalwire_agents/utils/schema_utils.py +348 -0
  49. signalwire_agents-0.1.0/signalwire_agents/utils/token_generators.py +0 -0
  50. signalwire_agents-0.1.0/signalwire_agents/utils/validators.py +0 -0
  51. signalwire_agents-0.1.0/signalwire_agents.egg-info/PKG-INFO +154 -0
  52. signalwire_agents-0.1.0/signalwire_agents.egg-info/SOURCES.txt +53 -0
  53. signalwire_agents-0.1.0/signalwire_agents.egg-info/dependency_links.txt +1 -0
  54. signalwire_agents-0.1.0/signalwire_agents.egg-info/requires.txt +8 -0
  55. signalwire_agents-0.1.0/signalwire_agents.egg-info/top_level.txt +1 -0
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: signalwire_agents
3
+ Version: 0.1.0
4
+ Summary: SignalWire AI Agents SDK
5
+ Author-email: SignalWire Team <info@signalwire.com>
6
+ Project-URL: Homepage, https://github.com/signalwire/signalwire-ai-agents
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.7
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: fastapi==0.115.12
19
+ Requires-Dist: pydantic==2.11.4
20
+ Requires-Dist: PyYAML==6.0.2
21
+ Requires-Dist: Requests==2.32.3
22
+ Requires-Dist: setuptools==66.1.1
23
+ Requires-Dist: signalwire_pom==2.7.1
24
+ Requires-Dist: structlog==25.3.0
25
+ Requires-Dist: uvicorn==0.34.2
26
+
27
+ # SignalWire AI Agent SDK
28
+
29
+ A Python SDK for creating, hosting, and securing SignalWire AI agents as microservices with minimal boilerplate.
30
+
31
+ ## Features
32
+
33
+ - **Self-Contained Agents**: Each agent is both a web app and an AI persona
34
+ - **Prompt Object Model**: Structured prompt composition using POM
35
+ - **SWAIG Integration**: Easily define and handle AI tools/functions
36
+ - **Security Built-In**: Session management, per-call tokens, and basic auth
37
+ - **State Management**: Persistent conversation state with lifecycle hooks
38
+ - **Prefab Archetypes**: Ready-to-use agent types for common scenarios
39
+ - **Multi-Agent Support**: Host multiple agents on a single server
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ pip install signalwire-agents
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ```python
50
+ from signalwire_agents import AgentBase
51
+ from signalwire_agents.core.function_result import SwaigFunctionResult
52
+
53
+ class SimpleAgent(AgentBase):
54
+ def __init__(self):
55
+ super().__init__(name="simple", route="/simple")
56
+ self.set_personality("You are a helpful assistant.")
57
+ self.set_goal("Help users with basic questions.")
58
+ self.add_instruction("Be concise and clear.")
59
+
60
+ @AgentBase.tool(name="get_time", parameters={})
61
+ def get_time(self):
62
+ from datetime import datetime
63
+ now = datetime.now().strftime("%H:%M:%S")
64
+ return SwaigFunctionResult(f"The current time is {now}")
65
+
66
+ # Run the agent
67
+ if __name__ == "__main__":
68
+ agent = SimpleAgent()
69
+ agent.serve(host="0.0.0.0", port=8000)
70
+ ```
71
+
72
+ ## Using State Management
73
+
74
+ ```python
75
+ from signalwire_agents import AgentBase
76
+ from signalwire_agents.core.state import FileStateManager
77
+
78
+ class StatefulAgent(AgentBase):
79
+ def __init__(self):
80
+ # Configure state management
81
+ state_manager = FileStateManager(storage_dir="./state_data")
82
+
83
+ super().__init__(
84
+ name="stateful",
85
+ route="/stateful",
86
+ enable_state_tracking=True, # Enable state tracking
87
+ state_manager=state_manager # Use custom state manager
88
+ )
89
+
90
+ # These methods are automatically registered when enable_state_tracking=True
91
+ def startup_hook(self, args, raw_data):
92
+ """Called when a conversation starts"""
93
+ call_id = raw_data.get("call_id")
94
+ state = self.get_state(call_id) or {}
95
+ state["started_at"] = "2023-01-01T12:00:00Z"
96
+ self.update_state(call_id, state)
97
+ return "Call initialized"
98
+
99
+ def hangup_hook(self, args, raw_data):
100
+ """Called when a conversation ends"""
101
+ call_id = raw_data.get("call_id")
102
+ state = self.get_state(call_id)
103
+ return "Call completed"
104
+ ```
105
+
106
+ ## Using Prefab Agents
107
+
108
+ ```python
109
+ from signalwire_agents.prefabs import InfoGathererAgent
110
+
111
+ agent = InfoGathererAgent(
112
+ fields=[
113
+ {"name": "full_name", "prompt": "What is your full name?"},
114
+ {"name": "reason", "prompt": "How can I help you today?"}
115
+ ],
116
+ confirmation_template="Thanks {full_name}, I'll help you with {reason}."
117
+ )
118
+
119
+ agent.serve(host="0.0.0.0", port=8000, route="/support")
120
+ ```
121
+
122
+ ## Configuration
123
+
124
+ ### Environment Variables
125
+
126
+ The SDK supports the following environment variables:
127
+
128
+ - `SWML_BASIC_AUTH_USER`: Username for basic auth (default: auto-generated)
129
+ - `SWML_BASIC_AUTH_PASSWORD`: Password for basic auth (default: auto-generated)
130
+ - `SWML_PROXY_URL_BASE`: Base URL to use when behind a reverse proxy, used for constructing webhook URLs
131
+ - `SWML_SSL_ENABLED`: Enable HTTPS/SSL support (values: "true", "1", "yes")
132
+ - `SWML_SSL_CERT_PATH`: Path to SSL certificate file
133
+ - `SWML_SSL_KEY_PATH`: Path to SSL private key file
134
+ - `SWML_DOMAIN`: Domain name for SSL certificate and external URLs
135
+
136
+ When the auth environment variables are set, they will be used for all agents instead of generating random credentials. The proxy URL base is useful when your service is behind a reverse proxy or when you need external services to access your webhooks.
137
+
138
+ To enable HTTPS directly (without a reverse proxy), set `SWML_SSL_ENABLED` to "true", provide valid paths to your certificate and key files, and specify your domain name.
139
+
140
+ ## Documentation
141
+
142
+ See the [full documentation](https://docs.signalwire.com/ai-agents) for details on:
143
+
144
+ - Creating custom agents
145
+ - Using prefab agents
146
+ - SWAIG function definitions
147
+ - State management and persistence
148
+ - Security model
149
+ - Deployment options
150
+ - Multi-agent hosting
151
+
152
+ ## License
153
+
154
+ MIT
@@ -0,0 +1,128 @@
1
+ # SignalWire AI Agent SDK
2
+
3
+ A Python SDK for creating, hosting, and securing SignalWire AI agents as microservices with minimal boilerplate.
4
+
5
+ ## Features
6
+
7
+ - **Self-Contained Agents**: Each agent is both a web app and an AI persona
8
+ - **Prompt Object Model**: Structured prompt composition using POM
9
+ - **SWAIG Integration**: Easily define and handle AI tools/functions
10
+ - **Security Built-In**: Session management, per-call tokens, and basic auth
11
+ - **State Management**: Persistent conversation state with lifecycle hooks
12
+ - **Prefab Archetypes**: Ready-to-use agent types for common scenarios
13
+ - **Multi-Agent Support**: Host multiple agents on a single server
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install signalwire-agents
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```python
24
+ from signalwire_agents import AgentBase
25
+ from signalwire_agents.core.function_result import SwaigFunctionResult
26
+
27
+ class SimpleAgent(AgentBase):
28
+ def __init__(self):
29
+ super().__init__(name="simple", route="/simple")
30
+ self.set_personality("You are a helpful assistant.")
31
+ self.set_goal("Help users with basic questions.")
32
+ self.add_instruction("Be concise and clear.")
33
+
34
+ @AgentBase.tool(name="get_time", parameters={})
35
+ def get_time(self):
36
+ from datetime import datetime
37
+ now = datetime.now().strftime("%H:%M:%S")
38
+ return SwaigFunctionResult(f"The current time is {now}")
39
+
40
+ # Run the agent
41
+ if __name__ == "__main__":
42
+ agent = SimpleAgent()
43
+ agent.serve(host="0.0.0.0", port=8000)
44
+ ```
45
+
46
+ ## Using State Management
47
+
48
+ ```python
49
+ from signalwire_agents import AgentBase
50
+ from signalwire_agents.core.state import FileStateManager
51
+
52
+ class StatefulAgent(AgentBase):
53
+ def __init__(self):
54
+ # Configure state management
55
+ state_manager = FileStateManager(storage_dir="./state_data")
56
+
57
+ super().__init__(
58
+ name="stateful",
59
+ route="/stateful",
60
+ enable_state_tracking=True, # Enable state tracking
61
+ state_manager=state_manager # Use custom state manager
62
+ )
63
+
64
+ # These methods are automatically registered when enable_state_tracking=True
65
+ def startup_hook(self, args, raw_data):
66
+ """Called when a conversation starts"""
67
+ call_id = raw_data.get("call_id")
68
+ state = self.get_state(call_id) or {}
69
+ state["started_at"] = "2023-01-01T12:00:00Z"
70
+ self.update_state(call_id, state)
71
+ return "Call initialized"
72
+
73
+ def hangup_hook(self, args, raw_data):
74
+ """Called when a conversation ends"""
75
+ call_id = raw_data.get("call_id")
76
+ state = self.get_state(call_id)
77
+ return "Call completed"
78
+ ```
79
+
80
+ ## Using Prefab Agents
81
+
82
+ ```python
83
+ from signalwire_agents.prefabs import InfoGathererAgent
84
+
85
+ agent = InfoGathererAgent(
86
+ fields=[
87
+ {"name": "full_name", "prompt": "What is your full name?"},
88
+ {"name": "reason", "prompt": "How can I help you today?"}
89
+ ],
90
+ confirmation_template="Thanks {full_name}, I'll help you with {reason}."
91
+ )
92
+
93
+ agent.serve(host="0.0.0.0", port=8000, route="/support")
94
+ ```
95
+
96
+ ## Configuration
97
+
98
+ ### Environment Variables
99
+
100
+ The SDK supports the following environment variables:
101
+
102
+ - `SWML_BASIC_AUTH_USER`: Username for basic auth (default: auto-generated)
103
+ - `SWML_BASIC_AUTH_PASSWORD`: Password for basic auth (default: auto-generated)
104
+ - `SWML_PROXY_URL_BASE`: Base URL to use when behind a reverse proxy, used for constructing webhook URLs
105
+ - `SWML_SSL_ENABLED`: Enable HTTPS/SSL support (values: "true", "1", "yes")
106
+ - `SWML_SSL_CERT_PATH`: Path to SSL certificate file
107
+ - `SWML_SSL_KEY_PATH`: Path to SSL private key file
108
+ - `SWML_DOMAIN`: Domain name for SSL certificate and external URLs
109
+
110
+ When the auth environment variables are set, they will be used for all agents instead of generating random credentials. The proxy URL base is useful when your service is behind a reverse proxy or when you need external services to access your webhooks.
111
+
112
+ To enable HTTPS directly (without a reverse proxy), set `SWML_SSL_ENABLED` to "true", provide valid paths to your certificate and key files, and specify your domain name.
113
+
114
+ ## Documentation
115
+
116
+ See the [full documentation](https://docs.signalwire.com/ai-agents) for details on:
117
+
118
+ - Creating custom agents
119
+ - Using prefab agents
120
+ - SWAIG function definitions
121
+ - State management and persistence
122
+ - Security model
123
+ - Deployment options
124
+ - Multi-agent hosting
125
+
126
+ ## License
127
+
128
+ MIT