mindroot 8.6.0__py3-none-any.whl → 8.8.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.

@@ -0,0 +1,186 @@
1
+ import { LitElement, html, css } from './lit-core.min.js';
2
+ import { BaseEl } from './base.js';
3
+ import './agent-form.js';
4
+ import './agent-list.js';
5
+ import './indexed-agents.js';
6
+ import './github-import.js';
7
+ import './missing-commands.js';
8
+
9
+ class AgentEditor extends BaseEl {
10
+ static properties = {
11
+ agent: { type: Object, reflect: true },
12
+ name: { type: String, reflect: true },
13
+ agents: { type: Array, reflect: true },
14
+ newAgent: { type: Boolean, reflect: true},
15
+ loading: { type: Boolean, reflect: true },
16
+ errorMessage: { type: String, reflect: true },
17
+ importStatus: { type: String, reflect: true }
18
+ };
19
+
20
+ static styles = css`
21
+ :host {
22
+ display: block;
23
+ }
24
+ .loading {
25
+ opacity: 0.7;
26
+ pointer-events: none;
27
+ }
28
+ .error-message {
29
+ color: #e57373;
30
+ margin: 1rem 0;
31
+ padding: 0.75rem;
32
+ border: 1px solid rgba(244, 67, 54, 0.2);
33
+ border-radius: 4px;
34
+ background: rgba(244, 67, 54, 0.1);
35
+ }
36
+ .status-message {
37
+ margin: 1rem 0;
38
+ padding: 0.75rem;
39
+ border-radius: 4px;
40
+ }
41
+ .status-message.success {
42
+ color: #81c784;
43
+ border: 1px solid rgba(129, 199, 132, 0.2);
44
+ background: rgba(129, 199, 132, 0.1);
45
+ }
46
+ .status-message.error {
47
+ color: #e57373;
48
+ border: 1px solid rgba(244, 67, 54, 0.2);
49
+ background: rgba(244, 67, 54, 0.1);
50
+ }
51
+ `;
52
+
53
+ constructor() {
54
+ super();
55
+ this.agent = {};
56
+ this.agents = [];
57
+ this.attachShadow({ mode: 'open' });
58
+ this.newAgent = false;
59
+ this.loading = false;
60
+ this.errorMessage = '';
61
+ this.importStatus = '';
62
+ this.fetchAgents();
63
+ }
64
+
65
+ async fetchAgents() {
66
+ try {
67
+ this.loading = true;
68
+ const response = await fetch('/agents/local');
69
+ if (!response.ok) throw new Error('Failed to fetch agents');
70
+ this.agents = await response.json();
71
+ console.log({agents: this.agents})
72
+ } catch (error) {
73
+ this.errorMessage = `Error loading agents: ${error.message}`;
74
+ } finally {
75
+ this.loading = false;
76
+ }
77
+ }
78
+
79
+ handleAgentSelected(e) {
80
+ this.agent = e.detail;
81
+ this.newAgent = false;
82
+ this.name = e.detail.name;
83
+ }
84
+
85
+ handleNewAgent() {
86
+ this.agent = {
87
+ commands: [],
88
+ preferred_providers: []
89
+ };
90
+ this.newAgent = true;
91
+ this.name = '';
92
+ }
93
+
94
+ handleAgentSaved(e) {
95
+ this.importStatus = 'Agent saved successfully';
96
+
97
+ // Refresh the agents list to include newly saved agents
98
+ this.fetchAgents();
99
+
100
+ // Check if this is a partial save (from instruction edit buttons)
101
+ if (e.detail.isPartialSave) {
102
+ // Don't update local agent state for partial saves to avoid overwriting child component state
103
+ return;
104
+ }
105
+
106
+ // Only change newAgent to false if we were actually creating a new agent
107
+ if (this.newAgent && e.detail.name) {
108
+ this.newAgent = false;
109
+ }
110
+
111
+ // Update the current agent with saved data while preserving form state
112
+ this.agent = {
113
+ ...this.agent, // Keep current state
114
+ ...e.detail,
115
+ commands: e.detail.commands || this.agent.commands || [],
116
+ preferred_providers: e.detail.preferred_providers || this.agent.preferred_providers || []
117
+ };
118
+
119
+ // Update the name if this was a new agent
120
+ if (e.detail.name) {
121
+ this.name = e.detail.name;
122
+ }
123
+
124
+ setTimeout(() => {
125
+ this.importStatus = '';
126
+ }, 3000);
127
+ }
128
+
129
+ handleAgentInstalled(e) {
130
+ this.importStatus = `Successfully installed ${e.detail.name}`;
131
+ this.fetchAgents();
132
+ setTimeout(() => {
133
+ this.importStatus = '';
134
+ }, 3000);
135
+ }
136
+
137
+ handleError(e) {
138
+ this.errorMessage = e.detail;
139
+ }
140
+
141
+ _render() {
142
+ return html`
143
+ <div class="agent-editor ${this.loading ? 'loading' : ''}">
144
+ ${this.errorMessage ? html`
145
+ <div class="error-message">${this.errorMessage}</div>
146
+ ` : ''}
147
+
148
+ ${this.importStatus ? html`
149
+ <div class="status-message ${this.importStatus.startsWith('Success') ? 'success' : 'error'}">
150
+ ${this.importStatus}
151
+ </div>
152
+ ` : ''}
153
+
154
+ <indexed-agents
155
+ @agent-installed=${this.handleAgentInstalled}
156
+ @error=${this.handleError}>
157
+ </indexed-agents>
158
+
159
+ <agent-list
160
+ .agents=${this.agents}
161
+ .selectedAgent=${this.agent}
162
+ @agent-selected=${this.handleAgentSelected}
163
+ @new-agent=${this.handleNewAgent}>
164
+ </agent-list>
165
+
166
+ ${(true || this.newAgent || this.agent.name) ? html`
167
+ <agent-form
168
+ .agent=${this.agent}
169
+ .newAgent=${this.newAgent}
170
+ @agent-saved=${this.handleAgentSaved}
171
+ @error=${this.handleError}>
172
+ </agent-form>
173
+ ` : ''}
174
+
175
+ <github-import
176
+ @agent-installed=${this.handleAgentInstalled}
177
+ @error=${this.handleError}>
178
+ </github-import>
179
+
180
+
181
+ </div>
182
+ `;
183
+ }
184
+ }
185
+
186
+ customElements.define('agent-editor', AgentEditor);