dtSpark 1.0.4__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.
- dtSpark/__init__.py +0 -0
- dtSpark/_description.txt +1 -0
- dtSpark/_full_name.txt +1 -0
- dtSpark/_licence.txt +21 -0
- dtSpark/_metadata.yaml +6 -0
- dtSpark/_name.txt +1 -0
- dtSpark/_version.txt +1 -0
- dtSpark/aws/__init__.py +7 -0
- dtSpark/aws/authentication.py +296 -0
- dtSpark/aws/bedrock.py +578 -0
- dtSpark/aws/costs.py +318 -0
- dtSpark/aws/pricing.py +580 -0
- dtSpark/cli_interface.py +2645 -0
- dtSpark/conversation_manager.py +3050 -0
- dtSpark/core/__init__.py +12 -0
- dtSpark/core/application.py +3355 -0
- dtSpark/core/context_compaction.py +735 -0
- dtSpark/daemon/__init__.py +104 -0
- dtSpark/daemon/__main__.py +10 -0
- dtSpark/daemon/action_monitor.py +213 -0
- dtSpark/daemon/daemon_app.py +730 -0
- dtSpark/daemon/daemon_manager.py +289 -0
- dtSpark/daemon/execution_coordinator.py +194 -0
- dtSpark/daemon/pid_file.py +169 -0
- dtSpark/database/__init__.py +482 -0
- dtSpark/database/autonomous_actions.py +1191 -0
- dtSpark/database/backends.py +329 -0
- dtSpark/database/connection.py +122 -0
- dtSpark/database/conversations.py +520 -0
- dtSpark/database/credential_prompt.py +218 -0
- dtSpark/database/files.py +205 -0
- dtSpark/database/mcp_ops.py +355 -0
- dtSpark/database/messages.py +161 -0
- dtSpark/database/schema.py +673 -0
- dtSpark/database/tool_permissions.py +186 -0
- dtSpark/database/usage.py +167 -0
- dtSpark/files/__init__.py +4 -0
- dtSpark/files/manager.py +322 -0
- dtSpark/launch.py +39 -0
- dtSpark/limits/__init__.py +10 -0
- dtSpark/limits/costs.py +296 -0
- dtSpark/limits/tokens.py +342 -0
- dtSpark/llm/__init__.py +17 -0
- dtSpark/llm/anthropic_direct.py +446 -0
- dtSpark/llm/base.py +146 -0
- dtSpark/llm/context_limits.py +438 -0
- dtSpark/llm/manager.py +177 -0
- dtSpark/llm/ollama.py +578 -0
- dtSpark/mcp_integration/__init__.py +5 -0
- dtSpark/mcp_integration/manager.py +653 -0
- dtSpark/mcp_integration/tool_selector.py +225 -0
- dtSpark/resources/config.yaml.template +631 -0
- dtSpark/safety/__init__.py +22 -0
- dtSpark/safety/llm_service.py +111 -0
- dtSpark/safety/patterns.py +229 -0
- dtSpark/safety/prompt_inspector.py +442 -0
- dtSpark/safety/violation_logger.py +346 -0
- dtSpark/scheduler/__init__.py +20 -0
- dtSpark/scheduler/creation_tools.py +599 -0
- dtSpark/scheduler/execution_queue.py +159 -0
- dtSpark/scheduler/executor.py +1152 -0
- dtSpark/scheduler/manager.py +395 -0
- dtSpark/tools/__init__.py +4 -0
- dtSpark/tools/builtin.py +833 -0
- dtSpark/web/__init__.py +20 -0
- dtSpark/web/auth.py +152 -0
- dtSpark/web/dependencies.py +37 -0
- dtSpark/web/endpoints/__init__.py +17 -0
- dtSpark/web/endpoints/autonomous_actions.py +1125 -0
- dtSpark/web/endpoints/chat.py +621 -0
- dtSpark/web/endpoints/conversations.py +353 -0
- dtSpark/web/endpoints/main_menu.py +547 -0
- dtSpark/web/endpoints/streaming.py +421 -0
- dtSpark/web/server.py +578 -0
- dtSpark/web/session.py +167 -0
- dtSpark/web/ssl_utils.py +195 -0
- dtSpark/web/static/css/dark-theme.css +427 -0
- dtSpark/web/static/js/actions.js +1101 -0
- dtSpark/web/static/js/chat.js +614 -0
- dtSpark/web/static/js/main.js +496 -0
- dtSpark/web/static/js/sse-client.js +242 -0
- dtSpark/web/templates/actions.html +408 -0
- dtSpark/web/templates/base.html +93 -0
- dtSpark/web/templates/chat.html +814 -0
- dtSpark/web/templates/conversations.html +350 -0
- dtSpark/web/templates/goodbye.html +81 -0
- dtSpark/web/templates/login.html +90 -0
- dtSpark/web/templates/main_menu.html +983 -0
- dtSpark/web/templates/new_conversation.html +191 -0
- dtSpark/web/web_interface.py +137 -0
- dtspark-1.0.4.dist-info/METADATA +187 -0
- dtspark-1.0.4.dist-info/RECORD +96 -0
- dtspark-1.0.4.dist-info/WHEEL +5 -0
- dtspark-1.0.4.dist-info/entry_points.txt +3 -0
- dtspark-1.0.4.dist-info/licenses/LICENSE +21 -0
- dtspark-1.0.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
logging:
|
|
2
|
+
level: INFO
|
|
3
|
+
rotation_backup_count: 5
|
|
4
|
+
log_to_console: false
|
|
5
|
+
|
|
6
|
+
# Database Configuration
|
|
7
|
+
# Supports: SQLite (default), MySQL, MariaDB, PostgreSQL, Microsoft SQL Server
|
|
8
|
+
database:
|
|
9
|
+
type: sqlite # Database type: sqlite, mysql, mariadb, postgresql, mssql
|
|
10
|
+
|
|
11
|
+
# SQLite configuration (local file-based database)
|
|
12
|
+
sqlite:
|
|
13
|
+
path: "./data/conversations.db" # Path to SQLite database file
|
|
14
|
+
|
|
15
|
+
# MySQL/MariaDB configuration (remote database server)
|
|
16
|
+
mysql:
|
|
17
|
+
host: localhost
|
|
18
|
+
port: 3306
|
|
19
|
+
database: dtawsbedrockcli
|
|
20
|
+
username: null # Set to null to prompt on startup
|
|
21
|
+
password: null # Set to null to prompt on startup (recommended for security)
|
|
22
|
+
ssl: false # Use SSL/TLS connection
|
|
23
|
+
|
|
24
|
+
# PostgreSQL configuration (remote database server)
|
|
25
|
+
postgresql:
|
|
26
|
+
host: localhost
|
|
27
|
+
port: 5432
|
|
28
|
+
database: dtawsbedrockcli
|
|
29
|
+
username: null # Set to null to prompt on startup
|
|
30
|
+
password: null # Set to null to prompt on startup (recommended for security)
|
|
31
|
+
ssl: false # Use SSL/TLS connection
|
|
32
|
+
|
|
33
|
+
# Microsoft SQL Server configuration (remote database server)
|
|
34
|
+
mssql:
|
|
35
|
+
host: localhost
|
|
36
|
+
port: 1433
|
|
37
|
+
database: dtawsbedrockcli
|
|
38
|
+
username: null # Set to null to prompt on startup
|
|
39
|
+
password: null # Set to null to prompt on startup (recommended for security)
|
|
40
|
+
ssl: false # Use SSL/TLS connection
|
|
41
|
+
driver: "ODBC Driver 17 for SQL Server" # ODBC driver name
|
|
42
|
+
|
|
43
|
+
# Notes:
|
|
44
|
+
# - SQLite is the default and requires no additional configuration
|
|
45
|
+
# - For remote databases (MySQL, PostgreSQL, MSSQL):
|
|
46
|
+
# - Set credentials directly in config (less secure) OR
|
|
47
|
+
# - Leave credentials as null to be prompted on startup (more secure)
|
|
48
|
+
# - Ensure the required Python package is installed:
|
|
49
|
+
# - MySQL: pip install mysql-connector-python
|
|
50
|
+
# - PostgreSQL: pip install psycopg2-binary
|
|
51
|
+
# - MSSQL: pip install pyodbc
|
|
52
|
+
|
|
53
|
+
# Interface Configuration
|
|
54
|
+
interface:
|
|
55
|
+
type: cli # Interface type: 'cli' (command-line) or 'web' (web browser)
|
|
56
|
+
web:
|
|
57
|
+
host: 127.0.0.1 # Localhost only for security (do not change)
|
|
58
|
+
port: 0 # 0 = automatically select random available port, or specify a port number
|
|
59
|
+
session_timeout_minutes: 0 # 0 = never expires, or set to minutes of inactivity before session expires
|
|
60
|
+
dark_theme: true # Use dark theme for web interface
|
|
61
|
+
ssl:
|
|
62
|
+
enabled: true # Enable HTTPS with self-signed certificate
|
|
63
|
+
auto_generate_cert: true # Automatically generate self-signed certificate if not found
|
|
64
|
+
cert_file: certs/ssl_cert.pem # Path to SSL certificate file
|
|
65
|
+
key_file: certs/ssl_key.pem # Path to SSL private key file
|
|
66
|
+
auto_open_browser: true # Automatically open web browser when server starts
|
|
67
|
+
|
|
68
|
+
# LLM Provider Configuration
|
|
69
|
+
llm_providers:
|
|
70
|
+
# Mandatory Model - if set, forces this model for ALL conversations (cannot be changed by user)
|
|
71
|
+
# When set, model selection and changing is disabled, and any model specified in predefined conversations is ignored
|
|
72
|
+
# Example: mandatory_model: "claude-3-5-sonnet-20241022"
|
|
73
|
+
mandatory_model: null # Set to a model ID to force that model for all conversations, or null to allow user choice
|
|
74
|
+
|
|
75
|
+
# Mandatory Provider - if set, forces the use of a specific provider/access method for the mandatory model
|
|
76
|
+
# Valid values: "AWS Bedrock", "Ollama", "Anthropic Direct"
|
|
77
|
+
# If not set, the application will automatically search all enabled providers for the model
|
|
78
|
+
# Example: mandatory_provider: "Anthropic Direct"
|
|
79
|
+
mandatory_provider: null # Set to force a specific provider, or null to auto-detect
|
|
80
|
+
|
|
81
|
+
# AWS Bedrock Configuration
|
|
82
|
+
aws_bedrock:
|
|
83
|
+
enabled: true # Set to false to disable AWS Bedrock
|
|
84
|
+
region: us-east-1 # AWS region for Bedrock API
|
|
85
|
+
|
|
86
|
+
# Authentication method: Choose one of the following:
|
|
87
|
+
#
|
|
88
|
+
# 1. SSO Profile (recommended for interactive use)
|
|
89
|
+
sso_profile: default # AWS SSO profile name
|
|
90
|
+
#
|
|
91
|
+
# 2. API Keys (for programmatic access, CI/CD, or when SSO is not available)
|
|
92
|
+
# Uncomment and set these to use API keys instead of SSO:
|
|
93
|
+
# access_key_id: YOUR_ACCESS_KEY_ID
|
|
94
|
+
# secret_access_key: YOUR_SECRET_ACCESS_KEY
|
|
95
|
+
# session_token: YOUR_SESSION_TOKEN # Optional: for temporary credentials
|
|
96
|
+
#
|
|
97
|
+
# Note: API keys take precedence over SSO profile if both are configured
|
|
98
|
+
#
|
|
99
|
+
# Security Warning: Do NOT commit API keys to version control!
|
|
100
|
+
|
|
101
|
+
cost_tracking:
|
|
102
|
+
enabled: false # Set to true to enable AWS Bedrock cost gathering and display
|
|
103
|
+
|
|
104
|
+
# Ollama Configuration (local LLM server)
|
|
105
|
+
ollama:
|
|
106
|
+
enabled: false # Set to true to enable Ollama
|
|
107
|
+
base_url: "http://localhost:11434" # Ollama API URL
|
|
108
|
+
verify_ssl: true # Set to false to skip SSL certificate verification (for self-signed certs)
|
|
109
|
+
# Only disable if connecting to Ollama via HTTPS with a self-signed certificate
|
|
110
|
+
|
|
111
|
+
# Anthropic Direct API Configuration
|
|
112
|
+
anthropic:
|
|
113
|
+
enabled: false # Set to true to enable Anthropic direct API
|
|
114
|
+
api_key: null # Your Anthropic API key (or set via ANTHROPIC_API_KEY environment variable)
|
|
115
|
+
rate_limit_max_retries: 5 # Maximum retry attempts for rate limit errors (default: 5)
|
|
116
|
+
rate_limit_base_delay: 2.0 # Base delay in seconds for exponential backoff (default: 2.0)
|
|
117
|
+
# Rate limit handling uses exponential backoff: 2^0=1s, 2^1=2s, 2^2=4s, 2^3=8s, 2^4=16s
|
|
118
|
+
|
|
119
|
+
bedrock:
|
|
120
|
+
max_tokens: 8192 # Maximum tokens per response
|
|
121
|
+
temperature: 0.7
|
|
122
|
+
request_timeout: 300 # Timeout in seconds for model inference requests (default: 5 minutes)
|
|
123
|
+
# model_id: null # Optional: Lock to specific model (disables model selection/changing)
|
|
124
|
+
|
|
125
|
+
conversation:
|
|
126
|
+
# global_instructions_path: null # Optional: Path to file containing global instructions
|
|
127
|
+
rollup_threshold: 0.3 # Trigger compaction at 30% of context window (default for cost control)
|
|
128
|
+
# Lower values compact more aggressively, saving tokens but potentially losing context
|
|
129
|
+
# Higher values (e.g., 0.8) preserve more context but use more tokens
|
|
130
|
+
# Note: Per-conversation compaction_threshold can override this in the database
|
|
131
|
+
rollup_summary_ratio: 0.3 # Summarise to 30% of original length
|
|
132
|
+
max_tool_result_tokens: 10000 # Maximum tokens per tool result
|
|
133
|
+
max_tool_iterations: 25 # Maximum number of consecutive tool calls before stopping (default: 25)
|
|
134
|
+
max_tool_selections: 30 # Maximum number of tools to send with each request (reduces token usage)
|
|
135
|
+
emergency_rollup_threshold: 0.95 # Force rollup at 95% even during tool use to prevent max_tokens errors
|
|
136
|
+
|
|
137
|
+
# Model Context Window Limits
|
|
138
|
+
# Maps model ID patterns to context window sizes (in tokens)
|
|
139
|
+
# Used for intelligent context compaction when approaching model limits
|
|
140
|
+
# The system matches model IDs using partial matching (model ID contains pattern)
|
|
141
|
+
model_context_limits:
|
|
142
|
+
# Anthropic Claude Models (Direct API and Bedrock)
|
|
143
|
+
# These limits apply to models accessed via AWS Bedrock or Anthropic Direct API
|
|
144
|
+
anthropic:
|
|
145
|
+
# Claude 4 family
|
|
146
|
+
claude-opus-4:
|
|
147
|
+
context_window: 200000
|
|
148
|
+
max_output: 32000
|
|
149
|
+
claude-sonnet-4:
|
|
150
|
+
context_window: 200000
|
|
151
|
+
max_output: 64000
|
|
152
|
+
claude-opus-4.5:
|
|
153
|
+
context_window: 200000
|
|
154
|
+
max_output: 64000
|
|
155
|
+
claude-sonnet-4.5:
|
|
156
|
+
context_window: 200000
|
|
157
|
+
max_output: 64000
|
|
158
|
+
|
|
159
|
+
# Claude 3.5 family
|
|
160
|
+
claude-3-5-sonnet:
|
|
161
|
+
context_window: 200000
|
|
162
|
+
max_output: 8192
|
|
163
|
+
claude-3-5-haiku:
|
|
164
|
+
context_window: 200000
|
|
165
|
+
max_output: 8192
|
|
166
|
+
|
|
167
|
+
# Claude 3 family (legacy)
|
|
168
|
+
claude-3-opus:
|
|
169
|
+
context_window: 200000
|
|
170
|
+
max_output: 4096
|
|
171
|
+
claude-3-sonnet:
|
|
172
|
+
context_window: 200000
|
|
173
|
+
max_output: 4096
|
|
174
|
+
claude-3-haiku:
|
|
175
|
+
context_window: 200000
|
|
176
|
+
max_output: 4096
|
|
177
|
+
|
|
178
|
+
# Default for unknown Anthropic/Claude models
|
|
179
|
+
default:
|
|
180
|
+
context_window: 200000
|
|
181
|
+
max_output: 4096
|
|
182
|
+
|
|
183
|
+
# AWS Bedrock Models (non-Anthropic)
|
|
184
|
+
aws_bedrock:
|
|
185
|
+
# Amazon Titan Text
|
|
186
|
+
amazon.titan-text-express:
|
|
187
|
+
context_window: 8192
|
|
188
|
+
max_output: 8192
|
|
189
|
+
amazon.titan-text-lite:
|
|
190
|
+
context_window: 4096
|
|
191
|
+
max_output: 4096
|
|
192
|
+
amazon.titan-text-premier:
|
|
193
|
+
context_window: 32000
|
|
194
|
+
max_output: 8192
|
|
195
|
+
|
|
196
|
+
# Meta Llama (on Bedrock)
|
|
197
|
+
meta.llama3-8b:
|
|
198
|
+
context_window: 8192
|
|
199
|
+
max_output: 2048
|
|
200
|
+
meta.llama3-70b:
|
|
201
|
+
context_window: 8192
|
|
202
|
+
max_output: 2048
|
|
203
|
+
meta.llama3-1:
|
|
204
|
+
context_window: 128000
|
|
205
|
+
max_output: 8192
|
|
206
|
+
meta.llama3-2:
|
|
207
|
+
context_window: 128000
|
|
208
|
+
max_output: 8192
|
|
209
|
+
meta.llama3-3:
|
|
210
|
+
context_window: 128000
|
|
211
|
+
max_output: 8192
|
|
212
|
+
|
|
213
|
+
# Mistral (on Bedrock)
|
|
214
|
+
mistral.mistral-7b:
|
|
215
|
+
context_window: 32000
|
|
216
|
+
max_output: 8192
|
|
217
|
+
mistral.mixtral-8x7b:
|
|
218
|
+
context_window: 32000
|
|
219
|
+
max_output: 8192
|
|
220
|
+
mistral.mistral-large:
|
|
221
|
+
context_window: 128000
|
|
222
|
+
max_output: 8192
|
|
223
|
+
|
|
224
|
+
# Cohere
|
|
225
|
+
cohere.command-r:
|
|
226
|
+
context_window: 128000
|
|
227
|
+
max_output: 4096
|
|
228
|
+
cohere.command-r-plus:
|
|
229
|
+
context_window: 128000
|
|
230
|
+
max_output: 4096
|
|
231
|
+
|
|
232
|
+
# AI21 Labs
|
|
233
|
+
ai21.jamba:
|
|
234
|
+
context_window: 256000
|
|
235
|
+
max_output: 4096
|
|
236
|
+
ai21.j2:
|
|
237
|
+
context_window: 8192
|
|
238
|
+
max_output: 8192
|
|
239
|
+
|
|
240
|
+
# Default for unknown Bedrock models
|
|
241
|
+
default:
|
|
242
|
+
context_window: 8192
|
|
243
|
+
max_output: 4096
|
|
244
|
+
|
|
245
|
+
# Ollama Models (local)
|
|
246
|
+
ollama:
|
|
247
|
+
# Llama family
|
|
248
|
+
llama3:
|
|
249
|
+
context_window: 8192
|
|
250
|
+
max_output: 4096
|
|
251
|
+
llama3.1:
|
|
252
|
+
context_window: 128000
|
|
253
|
+
max_output: 8192
|
|
254
|
+
llama3.2:
|
|
255
|
+
context_window: 128000
|
|
256
|
+
max_output: 8192
|
|
257
|
+
llama3.3:
|
|
258
|
+
context_window: 128000
|
|
259
|
+
max_output: 8192
|
|
260
|
+
|
|
261
|
+
# Mistral family
|
|
262
|
+
mistral:
|
|
263
|
+
context_window: 32000
|
|
264
|
+
max_output: 8192
|
|
265
|
+
mistral-nemo:
|
|
266
|
+
context_window: 128000
|
|
267
|
+
max_output: 8192
|
|
268
|
+
mixtral:
|
|
269
|
+
context_window: 32000
|
|
270
|
+
max_output: 8192
|
|
271
|
+
|
|
272
|
+
# Qwen family
|
|
273
|
+
qwen:
|
|
274
|
+
context_window: 32000
|
|
275
|
+
max_output: 8192
|
|
276
|
+
qwen2:
|
|
277
|
+
context_window: 32000
|
|
278
|
+
max_output: 8192
|
|
279
|
+
qwen2.5:
|
|
280
|
+
context_window: 128000
|
|
281
|
+
max_output: 8192
|
|
282
|
+
qwen2.5-coder:
|
|
283
|
+
context_window: 128000
|
|
284
|
+
max_output: 8192
|
|
285
|
+
|
|
286
|
+
# Code models
|
|
287
|
+
codellama:
|
|
288
|
+
context_window: 16000
|
|
289
|
+
max_output: 4096
|
|
290
|
+
deepseek-coder:
|
|
291
|
+
context_window: 16000
|
|
292
|
+
max_output: 4096
|
|
293
|
+
starcoder:
|
|
294
|
+
context_window: 8192
|
|
295
|
+
max_output: 4096
|
|
296
|
+
|
|
297
|
+
# Other popular models
|
|
298
|
+
gemma:
|
|
299
|
+
context_window: 8192
|
|
300
|
+
max_output: 4096
|
|
301
|
+
gemma2:
|
|
302
|
+
context_window: 8192
|
|
303
|
+
max_output: 8192
|
|
304
|
+
phi3:
|
|
305
|
+
context_window: 128000
|
|
306
|
+
max_output: 4096
|
|
307
|
+
phi4:
|
|
308
|
+
context_window: 16000
|
|
309
|
+
max_output: 4096
|
|
310
|
+
command-r:
|
|
311
|
+
context_window: 128000
|
|
312
|
+
max_output: 4096
|
|
313
|
+
yi:
|
|
314
|
+
context_window: 200000
|
|
315
|
+
max_output: 4096
|
|
316
|
+
|
|
317
|
+
# Default for unknown Ollama models
|
|
318
|
+
default:
|
|
319
|
+
context_window: 4096
|
|
320
|
+
max_output: 2048
|
|
321
|
+
|
|
322
|
+
# Global default (fallback for any unmatched model/provider)
|
|
323
|
+
default:
|
|
324
|
+
context_window: 8192
|
|
325
|
+
max_output: 4096
|
|
326
|
+
|
|
327
|
+
token_management:
|
|
328
|
+
enabled: false # Set to true to enable token usage management and limits
|
|
329
|
+
max_input_tokens: 100000 # Maximum input tokens in the rolling window
|
|
330
|
+
max_output_tokens: 50000 # Maximum output tokens in the rolling window
|
|
331
|
+
period_hours: 24 # Tracking period in hours (rolling window)
|
|
332
|
+
allow_override: true # Allow user to override token limits at 100%
|
|
333
|
+
|
|
334
|
+
# Prompt Inspection (Cyber Security)
|
|
335
|
+
# Detects and mitigates security risks in user prompts
|
|
336
|
+
prompt_inspection:
|
|
337
|
+
enabled: false # Set to true to enable prompt inspection
|
|
338
|
+
inspection_level: basic # Inspection level: basic, standard, strict
|
|
339
|
+
# basic: Fast pattern matching only
|
|
340
|
+
# standard: Pattern matching + keyword analysis
|
|
341
|
+
# strict: Pattern matching + LLM semantic analysis
|
|
342
|
+
action: warn # Action when violations detected: block, warn, sanitise, log_only
|
|
343
|
+
# block: Reject prompt completely
|
|
344
|
+
# warn: Show warning and ask for confirmation
|
|
345
|
+
# sanitise: Attempt to clean the prompt (with confirmation)
|
|
346
|
+
# log_only: Log violation but allow prompt
|
|
347
|
+
|
|
348
|
+
# LLM-based inspection (for 'strict' level)
|
|
349
|
+
llm_inspection:
|
|
350
|
+
enabled: false # Set to true to enable LLM semantic analysis
|
|
351
|
+
model: anthropic.claude-3-haiku-20240307-v1:0 # Fast, cheap model for analysis
|
|
352
|
+
provider: AWS Bedrock # Provider: AWS Bedrock, Ollama, Anthropic Direct
|
|
353
|
+
max_tokens: 500 # Maximum tokens for analysis response
|
|
354
|
+
confidence_threshold: 0.7 # 0.0-1.0, higher = more strict
|
|
355
|
+
|
|
356
|
+
# Pattern-based detection
|
|
357
|
+
patterns:
|
|
358
|
+
check_prompt_injection: true # Detect attempts to override system instructions
|
|
359
|
+
check_jailbreak: true # Detect attempts to bypass safety guidelines
|
|
360
|
+
check_code_injection: true # Detect malicious code patterns
|
|
361
|
+
check_pii: false # Detect potential PII exposure
|
|
362
|
+
check_excessive_length: true # Detect unusually long prompts
|
|
363
|
+
max_prompt_length: 50000 # Maximum prompt length in characters
|
|
364
|
+
|
|
365
|
+
# Content moderation (optional)
|
|
366
|
+
content_moderation:
|
|
367
|
+
check_profanity: false # Check for profanity
|
|
368
|
+
check_toxicity: false # Check for toxic content (requires AWS Comprehend)
|
|
369
|
+
|
|
370
|
+
# Blocklist/Allowlist
|
|
371
|
+
custom_patterns_file: null # Optional: path to custom regex patterns file
|
|
372
|
+
whitelist_users: [] # User GUIDs exempt from inspection
|
|
373
|
+
|
|
374
|
+
# Logging and audit
|
|
375
|
+
log_violations: true # Log violations to database for audit trail
|
|
376
|
+
alert_on_repeated_violations: true # Alert when user exceeds threshold
|
|
377
|
+
violation_threshold: 5 # Alert after N violations in 24 hours
|
|
378
|
+
|
|
379
|
+
# AWS Comprehend (optional, for content moderation)
|
|
380
|
+
# Note: This service incurs additional AWS costs
|
|
381
|
+
aws_comprehend:
|
|
382
|
+
enabled: false # Set to true to enable AWS Comprehend integration
|
|
383
|
+
detect_pii: false # Detect personally identifiable information
|
|
384
|
+
detect_toxic_content: false # Detect toxic/offensive content
|
|
385
|
+
|
|
386
|
+
# Predefined Conversations
|
|
387
|
+
# Define conversations that are automatically created and synchronised on startup.
|
|
388
|
+
# These conversations are MANAGED BY CONFIGURATION and have the following protections:
|
|
389
|
+
# - Instructions CANNOT be changed by users
|
|
390
|
+
# - Model CANNOT be changed by users
|
|
391
|
+
# - Files CANNOT be deleted by users
|
|
392
|
+
# Configuration changes are automatically synchronised on application startup.
|
|
393
|
+
#
|
|
394
|
+
# Instructions and Files Loading:
|
|
395
|
+
# - Instructions can be:
|
|
396
|
+
# 1. Inline text (multi-line strings)
|
|
397
|
+
# 2. Path to file loaded via ResourceManager (package resources)
|
|
398
|
+
# 3. Direct file path (absolute or relative)
|
|
399
|
+
# - Files are loaded using:
|
|
400
|
+
# 1. ResourceManager (for package resources)
|
|
401
|
+
# 2. Direct file path (fallback if ResourceManager returns None)
|
|
402
|
+
#
|
|
403
|
+
# Model and Provider Selection:
|
|
404
|
+
# - If llm_providers.mandatory_model is set, it overrides conversation model settings
|
|
405
|
+
# - If provider is omitted or null, the system auto-detects the provider for the model
|
|
406
|
+
# - Provider options: "AWS Bedrock", "Ollama", or "Anthropic Direct"
|
|
407
|
+
#
|
|
408
|
+
predefined_conversations:
|
|
409
|
+
enabled: false # Set to true to enable predefined conversations
|
|
410
|
+
|
|
411
|
+
conversations:
|
|
412
|
+
# Example 1: Code Review Assistant with inline instructions
|
|
413
|
+
# - name: "Code Review Assistant"
|
|
414
|
+
# instructions: |
|
|
415
|
+
# You are a senior software engineer specialising in code review.
|
|
416
|
+
# Focus on code quality, security, performance, and maintainability.
|
|
417
|
+
# Provide constructive feedback with specific examples.
|
|
418
|
+
# files: [] # No files attached by default
|
|
419
|
+
# model: "claude-sonnet-4.5"
|
|
420
|
+
# provider: null # If null or omitted, will auto-detect the provider for this model
|
|
421
|
+
# enabled: true
|
|
422
|
+
#
|
|
423
|
+
# Example 2: Simple assistant with inline instructions and no files
|
|
424
|
+
# - name: "General Assistant"
|
|
425
|
+
# instructions: "You are a helpful assistant." # Short inline text (no file loading attempted)
|
|
426
|
+
# files: []
|
|
427
|
+
# model: "claude-sonnet-4"
|
|
428
|
+
# enabled: true
|
|
429
|
+
|
|
430
|
+
mcp_config:
|
|
431
|
+
enabled: false # Set to true to enable MCP integration
|
|
432
|
+
servers: []
|
|
433
|
+
# Example MCP server configurations:
|
|
434
|
+
#
|
|
435
|
+
# ============================================================================
|
|
436
|
+
# TRANSPORT TYPES
|
|
437
|
+
# ============================================================================
|
|
438
|
+
# - stdio: Local server process (command + args)
|
|
439
|
+
# - http: Remote Streamable HTTP server (url required)
|
|
440
|
+
# - sse: Remote Server-Sent Events server (url required)
|
|
441
|
+
#
|
|
442
|
+
# ============================================================================
|
|
443
|
+
# AUTHENTICATION OPTIONS (for http and sse transports)
|
|
444
|
+
# ============================================================================
|
|
445
|
+
# auth_type: none | bearer | api_key | basic | custom
|
|
446
|
+
#
|
|
447
|
+
# - none: No authentication (default)
|
|
448
|
+
# - bearer: Authorization: Bearer <token>
|
|
449
|
+
# - api_key: Custom header with API key (default: X-API-Key)
|
|
450
|
+
# - basic: HTTP Basic authentication (username + password)
|
|
451
|
+
# - custom: Use custom_headers dictionary for full control
|
|
452
|
+
#
|
|
453
|
+
# ============================================================================
|
|
454
|
+
# SSL/TLS OPTIONS (for http and sse transports)
|
|
455
|
+
# ============================================================================
|
|
456
|
+
# ssl_verify: true | false
|
|
457
|
+
#
|
|
458
|
+
# - true: Verify SSL certificates (default, recommended for production)
|
|
459
|
+
# - false: Skip SSL certificate verification (for self-signed certificates)
|
|
460
|
+
#
|
|
461
|
+
# WARNING: Disabling SSL verification reduces security. Only use this for:
|
|
462
|
+
# - Development/testing environments with self-signed certificates
|
|
463
|
+
# - Internal servers with custom certificate authorities
|
|
464
|
+
#
|
|
465
|
+
# ============================================================================
|
|
466
|
+
# EXAMPLES
|
|
467
|
+
# ============================================================================
|
|
468
|
+
#
|
|
469
|
+
# Test server (included with the project):
|
|
470
|
+
# - name: test-server
|
|
471
|
+
# transport: stdio
|
|
472
|
+
# command: python
|
|
473
|
+
# args:
|
|
474
|
+
# - ./tests/test_mcp_server.py
|
|
475
|
+
# enabled: true
|
|
476
|
+
#
|
|
477
|
+
# Stdio transport (local server process):
|
|
478
|
+
# - name: filesystem
|
|
479
|
+
# transport: stdio
|
|
480
|
+
# command: uvx
|
|
481
|
+
# args:
|
|
482
|
+
# - mcp-server-filesystem
|
|
483
|
+
# - /path/to/allowed/directory
|
|
484
|
+
# enabled: true
|
|
485
|
+
#
|
|
486
|
+
# Stdio transport with environment variables:
|
|
487
|
+
# - name: api-tools
|
|
488
|
+
# transport: stdio
|
|
489
|
+
# command: uvx
|
|
490
|
+
# args:
|
|
491
|
+
# - mcp-server-api-tools
|
|
492
|
+
# env:
|
|
493
|
+
# API_KEY: your-api-key-here
|
|
494
|
+
# API_ENDPOINT: https://api.example.com
|
|
495
|
+
# enabled: true
|
|
496
|
+
#
|
|
497
|
+
# HTTP transport (no authentication):
|
|
498
|
+
# - name: local-http
|
|
499
|
+
# transport: http
|
|
500
|
+
# url: http://localhost:8000/mcp
|
|
501
|
+
# timeout: 30
|
|
502
|
+
# enabled: true
|
|
503
|
+
#
|
|
504
|
+
# HTTP transport with Bearer token authentication:
|
|
505
|
+
# - name: remote-api
|
|
506
|
+
# transport: http
|
|
507
|
+
# url: https://api.example.com/mcp
|
|
508
|
+
# auth_type: bearer
|
|
509
|
+
# auth_token: your-bearer-token-here # Or use env var: ${REMOTE_API_TOKEN}
|
|
510
|
+
# timeout: 60
|
|
511
|
+
# enabled: true
|
|
512
|
+
#
|
|
513
|
+
# HTTP transport with API key authentication:
|
|
514
|
+
# - name: api-service
|
|
515
|
+
# transport: http
|
|
516
|
+
# url: https://service.example.com/mcp
|
|
517
|
+
# auth_type: api_key
|
|
518
|
+
# auth_token: your-api-key-here
|
|
519
|
+
# auth_header_name: X-API-Key # Default header name, can be customised
|
|
520
|
+
# enabled: true
|
|
521
|
+
#
|
|
522
|
+
# HTTP transport with Basic authentication:
|
|
523
|
+
# - name: internal-service
|
|
524
|
+
# transport: http
|
|
525
|
+
# url: https://internal.example.com/mcp
|
|
526
|
+
# auth_type: basic
|
|
527
|
+
# basic_username: service-user
|
|
528
|
+
# basic_password: service-password
|
|
529
|
+
# enabled: true
|
|
530
|
+
#
|
|
531
|
+
# HTTP transport with custom headers:
|
|
532
|
+
# - name: custom-auth-service
|
|
533
|
+
# transport: http
|
|
534
|
+
# url: https://custom.example.com/mcp
|
|
535
|
+
# auth_type: custom
|
|
536
|
+
# custom_headers:
|
|
537
|
+
# X-Tenant-ID: "my-tenant"
|
|
538
|
+
# X-Custom-Auth: "secret-value"
|
|
539
|
+
# X-Request-Source: "dt-spark"
|
|
540
|
+
# enabled: true
|
|
541
|
+
#
|
|
542
|
+
# SSE transport with Bearer token:
|
|
543
|
+
# - name: sse-events
|
|
544
|
+
# transport: sse
|
|
545
|
+
# url: https://events.example.com/mcp
|
|
546
|
+
# auth_type: bearer
|
|
547
|
+
# auth_token: your-sse-token-here
|
|
548
|
+
# timeout: 120 # SSE connections often need longer timeouts
|
|
549
|
+
# enabled: true
|
|
550
|
+
#
|
|
551
|
+
# SSE transport with API key:
|
|
552
|
+
# - name: sse-service
|
|
553
|
+
# transport: sse
|
|
554
|
+
# url: https://stream.example.com/mcp
|
|
555
|
+
# auth_type: api_key
|
|
556
|
+
# auth_token: your-api-key
|
|
557
|
+
# auth_header_name: Authorization # Some services use Authorization header for API keys
|
|
558
|
+
# enabled: true
|
|
559
|
+
#
|
|
560
|
+
# HTTP transport with self-signed certificate (SSL verification disabled):
|
|
561
|
+
# - name: internal-dev-server
|
|
562
|
+
# transport: http
|
|
563
|
+
# url: https://dev-internal.local:8443/mcp
|
|
564
|
+
# auth_type: api_key
|
|
565
|
+
# auth_token: dev-api-key
|
|
566
|
+
# ssl_verify: false # Skip SSL verification for self-signed certificates
|
|
567
|
+
# timeout: 30
|
|
568
|
+
# enabled: true
|
|
569
|
+
#
|
|
570
|
+
# SSE transport with self-signed certificate:
|
|
571
|
+
# - name: internal-sse-dev
|
|
572
|
+
# transport: sse
|
|
573
|
+
# url: https://dev-events.local:8443/mcp
|
|
574
|
+
# auth_type: bearer
|
|
575
|
+
# auth_token: dev-bearer-token
|
|
576
|
+
# ssl_verify: false # Skip SSL verification for self-signed certificates
|
|
577
|
+
# timeout: 120
|
|
578
|
+
# enabled: true
|
|
579
|
+
|
|
580
|
+
# Embedded Filesystem Tools
|
|
581
|
+
# Built-in tools for accessing local filesystem (alternative to MCP filesystem server)
|
|
582
|
+
embedded_tools:
|
|
583
|
+
filesystem:
|
|
584
|
+
enabled: false # Set to true to enable embedded filesystem tools
|
|
585
|
+
allowed_path: ./ # Root path that tools can access (absolute or relative)
|
|
586
|
+
# Tools cannot access files outside this directory
|
|
587
|
+
access_mode: read # Access mode: "read" (read-only) or "read_write" (read and write)
|
|
588
|
+
# read: Only list, search, and read operations
|
|
589
|
+
# read_write: Adds write and create directory operations
|
|
590
|
+
|
|
591
|
+
# Security Notes:
|
|
592
|
+
# - All file paths are validated to ensure they are within allowed_path
|
|
593
|
+
# - Attempting to access files outside allowed_path will be rejected
|
|
594
|
+
# - Use read-only mode when write operations are not needed
|
|
595
|
+
# - Consider using specific subdirectories rather than root paths
|
|
596
|
+
|
|
597
|
+
# Tool Permissions
|
|
598
|
+
# Controls how tool usage permissions are handled
|
|
599
|
+
tool_permissions:
|
|
600
|
+
auto_approve: false # Set to true to automatically approve all tool usage without prompting
|
|
601
|
+
# When true: Tools run without user confirmation (not stored in database)
|
|
602
|
+
# When false: User is prompted on first-time tool usage (choice is stored)
|
|
603
|
+
#
|
|
604
|
+
# Use Cases:
|
|
605
|
+
# - Development/testing: Set to true to avoid constant prompts
|
|
606
|
+
# - Trusted environments: Set to true when all tools are known to be safe
|
|
607
|
+
# - Production/security-conscious: Set to false to maintain user control
|
|
608
|
+
#
|
|
609
|
+
# Note: When reverted to false, users will be prompted again for tools
|
|
610
|
+
# that were auto-approved (since permissions weren't stored)
|
|
611
|
+
|
|
612
|
+
# Daemon Configuration
|
|
613
|
+
# Background process for executing autonomous actions independently
|
|
614
|
+
daemon:
|
|
615
|
+
poll_interval: 30 # Seconds between database polls for action changes
|
|
616
|
+
heartbeat_interval: 60 # Seconds between heartbeat updates to registry
|
|
617
|
+
lock_timeout: 300 # Seconds before stale execution locks are cleared
|
|
618
|
+
pid_file: "./daemon.pid" # PID file location for daemon process
|
|
619
|
+
|
|
620
|
+
# Usage:
|
|
621
|
+
# dtSpark daemon start # Start daemon in background
|
|
622
|
+
# dtSpark daemon start --foreground # Run in foreground (for debugging)
|
|
623
|
+
# dtSpark daemon status # Check if daemon is running
|
|
624
|
+
# dtSpark daemon stop # Stop the daemon gracefully
|
|
625
|
+
# dtSpark daemon restart # Restart the daemon
|
|
626
|
+
#
|
|
627
|
+
# The daemon:
|
|
628
|
+
# - Runs autonomous actions on their configured schedules
|
|
629
|
+
# - Detects changes to actions made via Web UI or CLI
|
|
630
|
+
# - Prevents duplicate execution when both daemon and UI try to run same action
|
|
631
|
+
# - Uses the same database and configuration as the main application
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Safety module for prompt inspection and security.
|
|
3
|
+
|
|
4
|
+
This module provides:
|
|
5
|
+
- Pattern-based prompt inspection
|
|
6
|
+
- LLM-based semantic analysis
|
|
7
|
+
- Cyber Security audit trail
|
|
8
|
+
- Multi-provider LLM support
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .prompt_inspector import PromptInspector, InspectionResult
|
|
14
|
+
from .violation_logger import ViolationLogger
|
|
15
|
+
from .patterns import PatternMatcher
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
'PromptInspector',
|
|
19
|
+
'InspectionResult',
|
|
20
|
+
'ViolationLogger',
|
|
21
|
+
'PatternMatcher',
|
|
22
|
+
]
|