dtSpark 1.1.0a2__py3-none-any.whl → 1.1.0a6__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.
Files changed (56) hide show
  1. dtSpark/_version.txt +1 -1
  2. dtSpark/aws/authentication.py +1 -1
  3. dtSpark/aws/bedrock.py +238 -239
  4. dtSpark/aws/costs.py +9 -5
  5. dtSpark/aws/pricing.py +25 -21
  6. dtSpark/cli_interface.py +69 -62
  7. dtSpark/conversation_manager.py +54 -47
  8. dtSpark/core/application.py +151 -111
  9. dtSpark/core/context_compaction.py +241 -226
  10. dtSpark/daemon/__init__.py +36 -22
  11. dtSpark/daemon/action_monitor.py +46 -17
  12. dtSpark/daemon/daemon_app.py +126 -104
  13. dtSpark/daemon/daemon_manager.py +59 -23
  14. dtSpark/daemon/pid_file.py +3 -2
  15. dtSpark/database/autonomous_actions.py +3 -0
  16. dtSpark/database/credential_prompt.py +52 -54
  17. dtSpark/files/manager.py +6 -12
  18. dtSpark/limits/__init__.py +1 -1
  19. dtSpark/limits/tokens.py +2 -2
  20. dtSpark/llm/anthropic_direct.py +246 -141
  21. dtSpark/llm/ollama.py +3 -1
  22. dtSpark/mcp_integration/manager.py +4 -4
  23. dtSpark/mcp_integration/tool_selector.py +83 -77
  24. dtSpark/resources/config.yaml.template +10 -0
  25. dtSpark/safety/patterns.py +45 -46
  26. dtSpark/safety/prompt_inspector.py +8 -1
  27. dtSpark/scheduler/creation_tools.py +273 -181
  28. dtSpark/scheduler/executor.py +503 -221
  29. dtSpark/tools/builtin.py +70 -53
  30. dtSpark/web/endpoints/autonomous_actions.py +12 -9
  31. dtSpark/web/endpoints/chat.py +18 -6
  32. dtSpark/web/endpoints/conversations.py +57 -17
  33. dtSpark/web/endpoints/main_menu.py +132 -105
  34. dtSpark/web/endpoints/streaming.py +2 -2
  35. dtSpark/web/server.py +65 -5
  36. dtSpark/web/ssl_utils.py +3 -3
  37. dtSpark/web/static/css/dark-theme.css +8 -29
  38. dtSpark/web/static/js/actions.js +2 -1
  39. dtSpark/web/static/js/chat.js +6 -8
  40. dtSpark/web/static/js/main.js +8 -8
  41. dtSpark/web/static/js/sse-client.js +130 -122
  42. dtSpark/web/templates/actions.html +5 -5
  43. dtSpark/web/templates/base.html +13 -0
  44. dtSpark/web/templates/chat.html +52 -50
  45. dtSpark/web/templates/conversations.html +50 -22
  46. dtSpark/web/templates/goodbye.html +2 -2
  47. dtSpark/web/templates/main_menu.html +17 -17
  48. dtSpark/web/templates/new_conversation.html +51 -20
  49. dtSpark/web/web_interface.py +2 -2
  50. {dtspark-1.1.0a2.dist-info → dtspark-1.1.0a6.dist-info}/METADATA +9 -2
  51. dtspark-1.1.0a6.dist-info/RECORD +96 -0
  52. dtspark-1.1.0a2.dist-info/RECORD +0 -96
  53. {dtspark-1.1.0a2.dist-info → dtspark-1.1.0a6.dist-info}/WHEEL +0 -0
  54. {dtspark-1.1.0a2.dist-info → dtspark-1.1.0a6.dist-info}/entry_points.txt +0 -0
  55. {dtspark-1.1.0a2.dist-info → dtspark-1.1.0a6.dist-info}/licenses/LICENSE +0 -0
  56. {dtspark-1.1.0a2.dist-info → dtspark-1.1.0a6.dist-info}/top_level.txt +0 -0
@@ -64,6 +64,10 @@ interface:
64
64
  cert_file: certs/ssl_cert.pem # Path to SSL certificate file
65
65
  key_file: certs/ssl_key.pem # Path to SSL private key file
66
66
  auto_open_browser: true # Automatically open web browser when server starts
67
+ browser_heartbeat:
68
+ enabled: true # Enable browser heartbeat monitoring (auto-shutdown when browser closes)
69
+ interval_seconds: 15 # How often browser sends heartbeat ping to server
70
+ timeout_seconds: 60 # Shutdown application after this many seconds without a heartbeat
67
71
 
68
72
  # LLM Provider Configuration
69
73
  llm_providers:
@@ -660,6 +664,12 @@ tool_permissions:
660
664
  # Note: When reverted to false, users will be prompted again for tools
661
665
  # that were auto-approved (since permissions weren't stored)
662
666
 
667
+ # Autonomous Actions Configuration
668
+ # Controls whether autonomous action creation and scheduling is available
669
+ autonomous_actions:
670
+ enabled: false # Set to true to enable autonomous action creation and scheduling
671
+ # When disabled, action-related menus and pages are hidden from both Web UI and CLI
672
+
663
673
  # Daemon Configuration
664
674
  # Background process for executing autonomous actions independently
665
675
  daemon:
@@ -176,54 +176,53 @@ class PatternMatcher:
176
176
  'detected_patterns': []
177
177
  }
178
178
 
179
- # Check prompt injection
180
- if config.get('check_prompt_injection', True):
181
- detected, pattern = self.check_prompt_injection(text)
182
- if detected:
183
- results['violations'].append('prompt_injection')
184
- results['detected_patterns'].append(pattern)
185
- results['severity'] = 'high'
186
-
187
- # Check jailbreak
188
- if config.get('check_jailbreak', True):
189
- detected, pattern = self.check_jailbreak(text)
190
- if detected:
191
- results['violations'].append('jailbreak')
192
- results['detected_patterns'].append(pattern)
193
- if results['severity'] == 'none':
194
- results['severity'] = 'high'
195
-
196
- # Check code injection
197
- if config.get('check_code_injection', True):
198
- detected, pattern = self.check_code_injection(text)
199
- if detected:
200
- results['violations'].append('code_injection')
201
- results['detected_patterns'].append(pattern)
202
- results['severity'] = 'critical'
203
-
204
- # Check PII
205
- if config.get('check_pii', False):
206
- detected, pattern = self.check_pii(text)
207
- if detected:
208
- results['violations'].append('pii_exposure')
209
- results['detected_patterns'].append(pattern)
210
- if results['severity'] in ['none', 'low']:
211
- results['severity'] = 'medium'
212
-
213
- # Check excessive length
214
- if config.get('check_excessive_length', True):
215
- max_length = config.get('max_prompt_length', 50000)
216
- if len(text) > max_length:
217
- results['violations'].append('excessive_length')
218
- results['detected_patterns'].append(f'Length: {len(text)} > {max_length}')
219
- if results['severity'] == 'none':
220
- results['severity'] = 'medium'
221
-
222
- # Check excessive repetition
179
+ self._scan_check(results, config, 'check_prompt_injection', True,
180
+ self.check_prompt_injection, text, 'prompt_injection', 'high')
181
+ self._scan_check(results, config, 'check_jailbreak', True,
182
+ self.check_jailbreak, text, 'jailbreak', 'high')
183
+ self._scan_check(results, config, 'check_code_injection', True,
184
+ self.check_code_injection, text, 'code_injection', 'critical')
185
+ self._scan_check(results, config, 'check_pii', False,
186
+ self.check_pii, text, 'pii_exposure', 'medium')
187
+ self._scan_check_excessive_length(results, config, text)
188
+ self._scan_check_repetition(results, text)
189
+
190
+ return results
191
+
192
+ @staticmethod
193
+ def _escalate_severity(current: str, proposed: str) -> str:
194
+ """Return the more severe of two severity levels."""
195
+ order = ['none', 'low', 'medium', 'high', 'critical']
196
+ return proposed if order.index(proposed) > order.index(current) else current
197
+
198
+ def _scan_check(self, results: Dict, config: Dict, config_key: str,
199
+ default_enabled: bool, check_fn, text: str,
200
+ violation_name: str, severity: str) -> None:
201
+ """Run a single pattern check and update results if a violation is detected."""
202
+ if not config.get(config_key, default_enabled):
203
+ return
204
+ detected, pattern = check_fn(text)
205
+ if detected:
206
+ results['violations'].append(violation_name)
207
+ results['detected_patterns'].append(pattern)
208
+ results['severity'] = self._escalate_severity(results['severity'], severity)
209
+
210
+ @staticmethod
211
+ def _scan_check_excessive_length(results: Dict, config: Dict, text: str) -> None:
212
+ """Check for excessive prompt length and update results."""
213
+ if not config.get('check_excessive_length', True):
214
+ return
215
+ max_length = config.get('max_prompt_length', 50000)
216
+ if len(text) > max_length:
217
+ results['violations'].append('excessive_length')
218
+ results['detected_patterns'].append(f'Length: {len(text)} > {max_length}')
219
+ if results['severity'] == 'none':
220
+ results['severity'] = 'medium'
221
+
222
+ def _scan_check_repetition(self, results: Dict, text: str) -> None:
223
+ """Check for excessive repetition and update results."""
223
224
  if self.check_excessive_repetition(text):
224
225
  results['violations'].append('excessive_repetition')
225
226
  results['detected_patterns'].append('Detected repetitive pattern')
226
227
  if results['severity'] == 'none':
227
228
  results['severity'] = 'low'
228
-
229
- return results
@@ -126,6 +126,13 @@ class PromptInspector:
126
126
 
127
127
  # Log violation if configured
128
128
  if self.violation_logger and result.violation_types:
129
+ if result.blocked:
130
+ action_taken = 'blocked'
131
+ elif result.needs_confirmation:
132
+ action_taken = 'warned'
133
+ else:
134
+ action_taken = 'logged'
135
+
129
136
  self.violation_logger.log_violation(
130
137
  user_guid=user_guid,
131
138
  conversation_id=conversation_id,
@@ -133,7 +140,7 @@ class PromptInspector:
133
140
  severity=result.severity,
134
141
  prompt_snippet=prompt[:500],
135
142
  detection_method=result.inspection_method,
136
- action_taken='blocked' if result.blocked else 'warned' if result.needs_confirmation else 'logged',
143
+ action_taken=action_taken,
137
144
  confidence_score=result.confidence
138
145
  )
139
146