mindroot 8.3.0__py3-none-any.whl → 8.5.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.

Potentially problematic release.


This version of mindroot might be problematic. Click here for more details.

@@ -83,17 +83,37 @@ class AgentEditor extends BaseEl {
83
83
  }
84
84
 
85
85
  handleNewAgent() {
86
- this.agent = {};
86
+ this.agent = {
87
+ commands: [],
88
+ preferred_providers: []
89
+ };
87
90
  this.newAgent = true;
88
91
  this.name = '';
89
92
  }
90
93
 
91
94
  handleAgentSaved(e) {
92
95
  this.importStatus = 'Agent saved successfully';
93
- this.newAgent = false;
94
96
 
95
- // Just update the current agent with saved data without refreshing the list
96
- this.agent = {...e.detail};
97
+ // Refresh the agents list to include newly saved agents
98
+ this.fetchAgents();
99
+
100
+ // Only change newAgent to false if we were actually creating a new agent
101
+ if (this.newAgent && e.detail.name) {
102
+ this.newAgent = false;
103
+ }
104
+
105
+ // Update the current agent with saved data while preserving form state
106
+ this.agent = {
107
+ ...this.agent, // Keep current state
108
+ ...e.detail,
109
+ commands: e.detail.commands || this.agent.commands || [],
110
+ preferred_providers: e.detail.preferred_providers || this.agent.preferred_providers || []
111
+ };
112
+
113
+ // Update the name if this was a new agent
114
+ if (e.detail.name) {
115
+ this.name = e.detail.name;
116
+ }
97
117
 
98
118
  setTimeout(() => {
99
119
  this.importStatus = '';
@@ -315,7 +315,8 @@ class AgentForm extends BaseEl {
315
315
  persona: '',
316
316
  recommended_plugins: []
317
317
  };
318
- this.showTechnicalInstructionsEditor = false;
318
+ this.showTechnicalInstructionsEditor = false;
319
+ this.newAgent = false;
319
320
  this.pendingPlugins = [];
320
321
  this.fetchPersonas();
321
322
  this.resetEditors();
@@ -346,6 +347,20 @@ class AgentForm extends BaseEl {
346
347
  }
347
348
 
348
349
  updated(changedProperties) {
350
+ // Handle newAgent property changes
351
+ if (changedProperties.has('newAgent')) {
352
+ console.log('newAgent changed to:', this.newAgent);
353
+ if (this.newAgent) {
354
+ // Initialize empty agent with defaults for new agent
355
+ this.agent = {
356
+ ...this.agent,
357
+ commands: this.agent.commands || [],
358
+ preferred_providers: this.agent.preferred_providers || [],
359
+ recommended_plugins: this.agent.recommended_plugins || []
360
+ };
361
+ }
362
+ }
363
+
349
364
  console.log('Updated with changes:', changedProperties);
350
365
  super.updated(changedProperties);
351
366
  if (changedProperties.has('agent')) {
@@ -569,15 +584,24 @@ class AgentForm extends BaseEl {
569
584
  }
570
585
 
571
586
  validateForm() {
572
- if (!this.agent.name?.trim()) {
587
+ // Get current form values to ensure we're validating the latest state
588
+ const nameInput = this.shadowRoot.querySelector('input[name="name"]');
589
+ const personaSelect = this.shadowRoot.querySelector('select[name="persona"]');
590
+ const instructionsTextarea = this.shadowRoot.querySelector('textarea[name="instructions"]');
591
+
592
+ const currentName = nameInput?.value || this.agent.name;
593
+ const currentPersona = personaSelect?.value || this.agent.persona;
594
+ const currentInstructions = instructionsTextarea?.value || this.agent.instructions;
595
+
596
+ if (!currentName?.trim()) {
573
597
  showNotification('error', 'Name is required');
574
598
  return false;
575
599
  }
576
- if (!this.agent.persona?.trim()) {
600
+ if (!currentPersona?.trim()) {
577
601
  showNotification('error', 'Persona is required');
578
602
  return false;
579
603
  }
580
- if (!this.agent.instructions?.trim()) {
604
+ if (!currentInstructions?.trim()) {
581
605
  showNotification('error', 'Instructions are required');
582
606
  return false;
583
607
  }
@@ -585,9 +609,42 @@ class AgentForm extends BaseEl {
585
609
  }
586
610
 
587
611
  async handleSubmit(event) { // Complete replacement of method
588
- event.preventDefault();
612
+ event?.preventDefault();
589
613
 
590
- if (!this.validateForm()) return;
614
+ // Check if this is a partial save (from instruction save buttons)
615
+ const isPartialSave = event?.submitter?.classList.contains('partial-save') ||
616
+ (event?.target?.classList.contains('icon-button') &&
617
+ (this.showInstructionsEditor || this.showTechnicalInstructionsEditor));
618
+
619
+ // Store current form state before any operations
620
+ const formState = {
621
+ name: this.agent.name,
622
+ persona: this.agent.persona,
623
+ instructions: this.agent.instructions,
624
+ technicalInstructions: this.agent.technicalInstructions,
625
+ commands: [...(this.agent.commands || [])],
626
+ recommended_plugins: [...(this.agent.recommended_plugins || [])],
627
+ preferred_providers: [...(this.agent.preferred_providers || [])]
628
+ };
629
+
630
+ // Skip full validation for partial saves
631
+ if (!isPartialSave && !this.validateForm()) {
632
+ // Restore form state on validation error
633
+ this.agent = {
634
+ ...this.agent,
635
+ ...formState
636
+ };
637
+ // Force update to refresh the form
638
+ this.requestUpdate();
639
+ return;
640
+ }
641
+
642
+ // For new agents, ensure we have default values
643
+ if (this.newAgent) {
644
+ this.agent.commands = this.agent.commands || [];
645
+ this.agent.preferred_providers = this.agent.preferred_providers || [];
646
+ this.agent.recommended_plugins = this.agent.recommended_plugins || [];
647
+ }
591
648
 
592
649
  try {
593
650
  this.loading = true;
@@ -655,17 +712,44 @@ class AgentForm extends BaseEl {
655
712
 
656
713
  // Get the saved agent data from response and update local state
657
714
  const savedAgent = await response.json();
658
- // Update our local agent with the server data
659
- this.agent = savedAgent;
660
715
 
661
- // Only reset editors when saving from the main save button
662
- const isMainSaveButton = event && event.target && event.target.type === 'submit';
663
- if (isMainSaveButton) this.resetEditors();
716
+ // Merge saved data with current form state to preserve unsaved changes in other fields
717
+ this.agent = {
718
+ ...this.agent, // Keep current form state
719
+ ...savedAgent, // Update with saved data
720
+ // But preserve any current form values that might not have been saved
721
+ name: this.shadowRoot.querySelector('input[name="name"]')?.value || savedAgent.name,
722
+ persona: this.shadowRoot.querySelector('select[name="persona"]')?.value || savedAgent.persona,
723
+ instructions: this.shadowRoot.querySelector('textarea[name="instructions"]')?.value || savedAgent.instructions,
724
+ technicalInstructions: this.shadowRoot.querySelector('textarea[name="technicalInstructions"]')?.value || savedAgent.technicalInstructions,
725
+ thinking_level: this.shadowRoot.querySelector('select[name="thinking_level"]')?.value || savedAgent.thinking_level
726
+ };
727
+
728
+ // Reset editors after partial save (from icon buttons)
729
+ if (isPartialSave) {
730
+ this.showInstructionsEditor = false;
731
+ this.showTechnicalInstructionsEditor = false;
732
+ }
664
733
 
665
734
  showNotification('success', `Agent ${this.agent.name} saved successfully`);
666
- this.dispatchEvent(new CustomEvent('agent-saved', { detail: savedAgent }));
735
+
736
+ // Dispatch event with merged data to preserve form state
737
+ this.dispatchEvent(new CustomEvent('agent-saved', {
738
+ detail: this.agent, // Send the merged agent data, not just savedAgent
739
+ bubbles: true,
740
+ composed: true
741
+ }));
667
742
  } catch (error) {
668
743
  showNotification('error', `Error saving agent: ${error.message}`);
744
+
745
+ // Restore form state on error
746
+ this.agent = {
747
+ ...this.agent,
748
+ ...formState
749
+ };
750
+
751
+ // Force update to refresh the form with restored data
752
+ this.requestUpdate();
669
753
  } finally {
670
754
  this.loading = false;
671
755
  }
@@ -883,7 +967,7 @@ renderServiceModels() {
883
967
  <label class="required">Instructions:</label>
884
968
  <div class="form-group-actions">
885
969
  ${this.showInstructionsEditor ? html`
886
- <button type="button" class="icon-button" @click=${(e) => { e.preventDefault(); this.handleSubmit(e); this.showInstructionsEditor = false; }}>
970
+ <button type="button" class="icon-button partial-save" @click=${async (e) => { e.preventDefault(); await this.handleSubmit(e); }}>
887
971
  <span class="material-icons">save</span>
888
972
  </button>
889
973
  ` : html`
@@ -909,7 +993,7 @@ renderServiceModels() {
909
993
  <label>Technical Instructions:</label>
910
994
  <div class="form-group-actions">
911
995
  ${this.showTechnicalInstructionsEditor ? html`
912
- <button type="button" class="icon-button" @click=${(e) => { e.preventDefault(); this.handleSubmit(e); this.showTechnicalInstructionsEditor = false; }}>
996
+ <button type="button" class="icon-button partial-save" @click=${async (e) => { e.preventDefault(); await this.handleSubmit(e); }}>
913
997
  <span class="material-icons">save</span>
914
998
  </button>
915
999
  ` : html`
@@ -267,19 +267,25 @@ async def send_message_to_agent(session_id: str, message: str | List[MessagePart
267
267
  parse_error = False
268
268
 
269
269
  results, full_cmds = await agent_.chat_commands(context.current_model, context, messages=context.chat_log.get_recent())
270
- for result in results:
271
- if result['cmd'] == 'UNKNOWN':
272
- consecutive_parse_errors += 1
273
- parse_error = True
270
+ if results is not None:
271
+ try:
272
+ for result in results:
273
+ if result['cmd'] == 'UNKNOWN':
274
+ consecutive_parse_errors += 1
275
+ parse_error = True
276
+ except Exception as e:
277
+ pass
274
278
 
275
279
  if not parse_error:
276
280
  consecutive_parse_errors = 0
281
+ else:
282
+ await asyncio.sleep(1)
277
283
 
278
284
  if consecutive_parse_errors > 6:
279
285
  raise Exception("Too many consecutive parse errors, stopping processing.")
280
286
 
281
287
  elif consecutive_parse_errors > 3:
282
- results.append({"cmd": "UNKNOWN", "args": { "SYSTEM WARNING: Issue valid command list or task processing will be halted. Simplify output."}})
288
+ results.append({"cmd": "UNKNOWN", "args": { "SYSTEM WARNING: Issue valid command list or task; processing will be halted. Simplify output."}})
283
289
 
284
290
  try:
285
291
  tmp_data3 = { "results": full_cmds }
@@ -340,6 +346,7 @@ async def send_message_to_agent(session_id: str, message: str | List[MessagePart
340
346
  continue_processing = False
341
347
  except Exception as e:
342
348
  continue_processing = False
349
+ await asyncio.sleep(1)
343
350
  trace = traceback.format_exc()
344
351
  msg = str(e)
345
352
  descr = msg + "\n\n" + trace
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mindroot
3
- Version: 8.3.0
3
+ Version: 8.5.0
4
4
  Summary: MindRoot AI Agent Framework
5
5
  Requires-Python: >=3.9
6
6
  License-File: LICENSE
@@ -37,8 +37,8 @@ mindroot/coreplugins/admin/static/favicon/favicon_io (1)/favicon-16x16.png,sha25
37
37
  mindroot/coreplugins/admin/static/favicon/favicon_io (1)/favicon-32x32.png,sha256=KTX1C9IlO3g3zgK-UlugpLhwwgVbl-q89m4_ZU-RAL8,1055
38
38
  mindroot/coreplugins/admin/static/favicon/favicon_io (1)/favicon.ico,sha256=5tNfs1TPDqu8ltrcvAKXw_n7tpkRNXP7rlpdtAqyitk,15406
39
39
  mindroot/coreplugins/admin/static/favicon/favicon_io (1)/site.webmanifest,sha256=ep4Hzh9zhmiZF2At3Fp1dQrYQuYF_3ZPZxc1KcGBvwQ,263
40
- mindroot/coreplugins/admin/static/js/agent-editor.js,sha256=Ny4YYpADVFInWQWjRGZYo_KWypuzio9VvTEYPKkEpDk,4094
41
- mindroot/coreplugins/admin/static/js/agent-form.js,sha256=BZ_DEHDiaWMu21XZKzLFDE6Zh-o2h2Er9oWQ2yndTAw,31111
40
+ mindroot/coreplugins/admin/static/js/agent-editor.js,sha256=n90lfoGT5bSMABJj5rCkthTyFl2kGXpkvOdJ7SUxTo0,4700
41
+ mindroot/coreplugins/admin/static/js/agent-form.js,sha256=LCUTRALBeNopEwj1aQ4aKeaO2dF_ueH2H-YSYZwVsd8,34713
42
42
  mindroot/coreplugins/admin/static/js/agent-list.js,sha256=86mqFyHspx9EnzJpgUDyeAgEq-jcqQ4v96CrgfUXoGM,2239
43
43
  mindroot/coreplugins/admin/static/js/base.js,sha256=xGCA6ngMapQ_jqMgHXg__CS3R46qprycOjkKTFDCMlA,1307
44
44
  mindroot/coreplugins/admin/static/js/github-import.js,sha256=iP-O2WrbKumyDetDjK7EQdi9yivFe6IlvHZLd2qo1dA,3658
@@ -450,7 +450,7 @@ mindroot/coreplugins/chat/format_result_msgs.py,sha256=daEdpEyAJIa8b2VkCqSKcw8Pa
450
450
  mindroot/coreplugins/chat/mod.py,sha256=Xydjv3feKJJRbwdiB7raqiQnWtaS_2GcdC9bXYQX3nE,425
451
451
  mindroot/coreplugins/chat/models.py,sha256=GRcRuDUAJFpyWERPMxkxUaZ21igNlWeeamriruEKiEQ,692
452
452
  mindroot/coreplugins/chat/router.py,sha256=ucSQ6_wztDq2PCUP0D4KHL5JaFUAaBtmCQy-4iI8e8c,9087
453
- mindroot/coreplugins/chat/services.py,sha256=IiUBjsRzKQZ0xw6TV8-dj6mehzTlA5XxcPPQYFQH6Kk,17561
453
+ mindroot/coreplugins/chat/services.py,sha256=Ngv_TceFeXn2EzlZbSbR8Iv1E4M7qL7o3q1L7tufFq4,17835
454
454
  mindroot/coreplugins/chat/utils.py,sha256=BiE14PpsAcQSO5vbU88klHGm8cAXJDXxgVgva-EXybU,155
455
455
  mindroot/coreplugins/chat/static/assistant.png,sha256=oAt1ctkFKLSPBoAZGNnSixooW9ANVIk1GwniauVWDXo,215190
456
456
  mindroot/coreplugins/chat/static/mindgen.png,sha256=fN3E3oOFvAGYjJq-Pvg2f75jIMv7kg5WRU0EeEbxCWg,235353
@@ -1817,9 +1817,9 @@ mindroot/protocols/services/stream_chat.py,sha256=fMnPfwaB5fdNMBLTEg8BXKAGvrELKH
1817
1817
  mindroot/registry/__init__.py,sha256=40Xy9bmPHsgdIrOzbtBGzf4XMqXVi9P8oZTJhn0r654,151
1818
1818
  mindroot/registry/component_manager.py,sha256=WZFNPg4SNvpqsM5NFiC2DpgmrJQCyR9cNhrCBpp30Qk,995
1819
1819
  mindroot/registry/data_access.py,sha256=NgNMamxIjaKeYxzxnVaQz1Y-Rm0AI51si3788_JHUTM,5316
1820
- mindroot-8.3.0.dist-info/licenses/LICENSE,sha256=8plAmZh8y9ccuuqFFz4kp7G-cO_qsPgAOoHNvabSB4U,1070
1821
- mindroot-8.3.0.dist-info/METADATA,sha256=MpV59VgsU5hOJzXKIwDWPeafYV7o0cQylnP_-pX9SYA,356
1822
- mindroot-8.3.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
1823
- mindroot-8.3.0.dist-info/entry_points.txt,sha256=0bpyjMccLttx6VcjDp6zfJPN0Kk0rffor6IdIbP0j4c,50
1824
- mindroot-8.3.0.dist-info/top_level.txt,sha256=gwKm7DmNjhdrCJTYCrxa9Szne4lLpCtrEBltfsX-Mm8,9
1825
- mindroot-8.3.0.dist-info/RECORD,,
1820
+ mindroot-8.5.0.dist-info/licenses/LICENSE,sha256=8plAmZh8y9ccuuqFFz4kp7G-cO_qsPgAOoHNvabSB4U,1070
1821
+ mindroot-8.5.0.dist-info/METADATA,sha256=sPWJGwi5iYookRNsthjvO6vTmBq37QCELIqeh2MuDCE,356
1822
+ mindroot-8.5.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
1823
+ mindroot-8.5.0.dist-info/entry_points.txt,sha256=0bpyjMccLttx6VcjDp6zfJPN0Kk0rffor6IdIbP0j4c,50
1824
+ mindroot-8.5.0.dist-info/top_level.txt,sha256=gwKm7DmNjhdrCJTYCrxa9Szne4lLpCtrEBltfsX-Mm8,9
1825
+ mindroot-8.5.0.dist-info/RECORD,,