File size: 28,157 Bytes
fd069bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI System Message Generator</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .tag {
            transition: all 0.2s ease;
        }
        .tag:hover {
            transform: translateY(-1px);
        }
        .dynamic-item {
            transition: all 0.3s ease;
        }
        .dynamic-item:hover {
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        #preview-code {
            white-space: pre-wrap;
            word-break: break-word;
        }
        .nav-link.active {
            box-shadow: inset 3px 0 0 0 #3b82f6;
        }
        @media (max-width: 768px) {
            .nav-link.active {
                box-shadow: inset 0 -3px 0 0 #3b82f6;
            }
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen flex flex-col">
    <header class="bg-white shadow-sm py-4">
        <div class="container mx-auto px-4">
            <h1 class="text-2xl font-bold text-blue-600 flex items-center">
                <i class="fas fa-robot mr-2"></i> AI System Message Generator
            </h1>
        </div>
    </header>

    <main class="flex-1 container mx-auto px-4 py-6 flex flex-col lg:flex-row gap-6">
        <!-- Sidebar Navigation -->
        <aside class="lg:w-64 bg-white rounded-lg shadow-sm p-4 lg:sticky lg:top-6 lg:h-fit">
            <nav class="flex lg:flex-col overflow-x-auto lg:overflow-x-visible pb-2 lg:pb-0">
                <ul class="flex lg:flex-col gap-1 whitespace-nowrap">
                    <li>
                        <a href="#identity" class="nav-link active flex items-center px-4 py-2 text-gray-700 hover:bg-blue-50 rounded-lg transition">
                            <i class="fas fa-user-tag mr-3 text-blue-500 w-5"></i>
                            <span>Identity</span>
                        </a>
                    </li>
                    <li>
                        <a href="#goal" class="nav-link flex items-center px-4 py-2 text-gray-700 hover:bg-blue-50 rounded-lg transition">
                            <i class="fas fa-bullseye mr-3 text-blue-500 w-5"></i>
                            <span>Goal</span>
                        </a>
                    </li>
                    <li>
                        <a href="#mandate" class="nav-link flex items-center px-4 py-2 text-gray-700 hover:bg-blue-50 rounded-lg transition">
                            <i class="fas fa-gavel mr-3 text-blue-500 w-5"></i>
                            <span>Mandate</span>
                        </a>
                    </li>
                    <li>
                        <a href="#constraints" class="nav-link flex items-center px-4 py-2 text-gray-700 hover:bg-blue-50 rounded-lg transition">
                            <i class="fas fa-ban mr-3 text-blue-500 w-5"></i>
                            <span>Constraints</span>
                        </a>
                    </li>
                    <li>
                        <a href="#components" class="nav-link flex items-center px-4 py-2 text-gray-700 hover:bg-blue-50 rounded-lg transition">
                            <i class="fas fa-puzzle-piece mr-3 text-blue-500 w-5"></i>
                            <span>Components</span>
                        </a>
                    </li>
                    <li>
                        <a href="#interaction" class="nav-link flex items-center px-4 py-2 text-gray-700 hover:bg-blue-50 rounded-lg transition">
                            <i class="fas fa-exchange-alt mr-3 text-blue-500 w-5"></i>
                            <span>Interaction</span>
                        </a>
                    </li>
                </ul>
            </nav>
        </aside>

        <!-- Main Content -->
        <div class="flex-1 flex flex-col lg:flex-row gap-6">
            <!-- Form Section -->
            <section class="flex-1 bg-white rounded-lg shadow-sm p-6">
                <!-- Identity Section -->
                <div id="identity" class="section-content">
                    <h2 class="text-xl font-bold text-blue-600 mb-4 pb-2 border-b border-gray-200 flex items-center">
                        <i class="fas fa-user-tag mr-2"></i> Agent Identity
                    </h2>
                    <p class="text-gray-600 mb-6">Define your AI agent's name, persona, and key characteristics.</p>
                    
                    <div class="space-y-6">
                        <div>
                            <label for="agent-name" class="block text-sm font-medium text-gray-700 mb-1">Agent Name</label>
                            <input type="text" id="agent-name" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="e.g., CodeMaster">
                        </div>
                        
                        <div>
                            <label for="agent-persona" class="block text-sm font-medium text-gray-700 mb-1">Persona Description</label>
                            <textarea id="agent-persona" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="Describe the agent's personality and role"></textarea>
                        </div>
                        
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Key Attributes</label>
                            <div class="tags-input-container">
                                <input type="text" id="agent-attributes" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="e.g., helpful, concise, creative (press Enter to add)">
                                <div id="agent-attributes-tags" class="flex flex-wrap gap-2 mt-2"></div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Goal Section -->
                <div id="goal" class="section-content hidden">
                    <h2 class="text-xl font-bold text-blue-600 mb-4 pb-2 border-b border-gray-200 flex items-center">
                        <i class="fas fa-bullseye mr-2"></i> Agent Goal
                    </h2>
                    <p class="text-gray-600 mb-6">Define the primary objectives and success metrics for your agent.</p>
                    
                    <div class="space-y-6">
                        <div>
                            <label for="primary-objective" class="block text-sm font-medium text-gray-700 mb-1">Primary Objective</label>
                            <textarea id="primary-objective" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="The main purpose of the agent"></textarea>
                        </div>
                        
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Key Performance Indicators</label>
                            <div class="tags-input-container">
                                <input type="text" id="kpis" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="e.g., 95% accuracy (press Enter to add)">
                                <div id="kpis-tags" class="flex flex-wrap gap-2 mt-2"></div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Mandate Section -->
                <div id="mandate" class="section-content hidden">
                    <h2 class="text-xl font-bold text-blue-600 mb-4 pb-2 border-b border-gray-200 flex items-center">
                        <i class="fas fa-gavel mr-2"></i> Agent Mandate
                    </h2>
                    <p class="text-gray-600 mb-6">Define what actions the agent is authorized to perform.</p>
                    
                    <div class="space-y-6">
                        <div>
                            <label for="authorized-actions" class="block text-sm font-medium text-gray-700 mb-1">Authorized Actions</label>
                            <textarea id="authorized-actions" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="List one action per line"></textarea>
                        </div>
                        
                        <div>
                            <label for="scope-of-authority" class="block text-sm font-medium text-gray-700 mb-1">Scope of Authority</label>
                            <input type="text" id="scope-of-authority" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="e.g., Limited to provided context">
                        </div>
                        
                        <div>
                            <label for="responsibilities" class="block text-sm font-medium text-gray-700 mb-1">Responsibilities</label>
                            <textarea id="responsibilities" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="List one responsibility per line"></textarea>
                        </div>
                    </div>
                </div>

                <!-- Constraints Section -->
                <div id="constraints" class="section-content hidden">
                    <h2 class="text-xl font-bold text-blue-600 mb-4 pb-2 border-b border-gray-200 flex items-center">
                        <i class="fas fa-ban mr-2"></i> Agent Constraints
                    </h2>
                    <p class="text-gray-600 mb-6">Define limitations and boundaries for the agent.</p>
                    
                    <div class="space-y-6">
                        <div>
                            <label for="operational-boundaries" class="block text-sm font-medium text-gray-700 mb-1">Operational Boundaries</label>
                            <textarea id="operational-boundaries" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="List one boundary per line"></textarea>
                        </div>
                        
                        <div>
                            <label for="ethical-guidelines" class="block text-sm font-medium text-gray-700 mb-1">Ethical Guidelines</label>
                            <textarea id="ethical-guidelines" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="List one guideline per line"></textarea>
                        </div>
                        
                        <div>
                            <label for="resource-limitations" class="block text-sm font-medium text-gray-700 mb-1">Resource Limitations</label>
                            <textarea id="resource-limitations" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="List one limitation per line"></textarea>
                        </div>
                        
                        <div>
                            <label for="forbidden-actions" class="block text-sm font-medium text-gray-700 mb-1">Forbidden Actions</label>
                            <textarea id="forbidden-actions" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="List one action per line"></textarea>
                        </div>
                    </div>
                </div>

                <!-- Components Section -->
                <div id="components" class="section-content hidden">
                    <h2 class="text-xl font-bold text-blue-600 mb-4 pb-2 border-b border-gray-200 flex items-center">
                        <i class="fas fa-puzzle-piece mr-2"></i> Available Components
                    </h2>
                    <p class="text-gray-600 mb-6">Define the tools and modules available to your agent.</p>
                    
                    <div id="components-list" class="space-y-4"></div>
                    
                    <button onclick="addComponentItem()" class="mt-4 inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
                        <i class="fas fa-plus mr-2"></i> Add Component
                    </button>
                </div>

                <!-- Interaction Section -->
                <div id="interaction" class="section-content hidden">
                    <h2 class="text-xl font-bold text-blue-600 mb-4 pb-2 border-b border-gray-200 flex items-center">
                        <i class="fas fa-exchange-alt mr-2"></i> Interaction Protocols
                    </h2>
                    <p class="text-gray-600 mb-6">Define how the agent should interact with users.</p>
                    
                    <div class="space-y-6">
                        <div>
                            <label for="communication-style" class="block text-sm font-medium text-gray-700 mb-1">Communication Style</label>
                            <textarea id="communication-style" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="Describe the preferred communication approach"></textarea>
                        </div>
                        
                        <div>
                            <label for="error-handling" class="block text-sm font-medium text-gray-700 mb-1">Error Handling</label>
                            <textarea id="error-handling" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="Describe error handling procedures"></textarea>
                        </div>
                        
                        <div>
                            <label for="feedback-mechanism" class="block text-sm font-medium text-gray-700 mb-1">Feedback Mechanism</label>
                            <input type="text" id="feedback-mechanism" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="How users can provide feedback">
                        </div>
                    </div>
                </div>

                <!-- Action Buttons -->
                <div class="mt-8 flex flex-col sm:flex-row gap-3 justify-end">
                    <button onclick="saveDraft()" class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
                        <i class="fas fa-save mr-2"></i> Save Draft
                    </button>
                    <button onclick="generateSystemMessage()" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
                        <i class="fas fa-magic mr-2"></i> Generate Message
                    </button>
                </div>
            </section>

            <!-- Preview Section -->
            <section id="preview-section" class="lg:w-96 bg-gray-800 rounded-lg shadow-sm p-6 hidden lg:block lg:sticky lg:top-6 lg:h-fit">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-bold text-white flex items-center">
                        <i class="fas fa-eye mr-2"></i> Preview
                    </h2>
                    <button onclick="copyToClipboard()" class="text-gray-300 hover:text-white">
                        <i class="fas fa-copy"></i>
                    </button>
                </div>
                <div class="bg-gray-900 p-4 rounded-lg overflow-auto max-h-[calc(100vh-180px)]">
                    <pre><code id="preview-code" class="text-gray-300 text-sm"></code></pre>
                </div>
            </section>
        </div>
    </main>

    <script>
        // Initialize sections and navigation
        document.addEventListener('DOMContentLoaded', function() {
            setupNavigation();
            setupTagsInput('agent-attributes');
            setupTagsInput('kpis');
            setupDynamicList('components-list', 'component');
            
            // Show identity section by default
            document.getElementById('identity').classList.remove('hidden');
        });

        // Navigation setup
        function setupNavigation() {
            const navLinks = document.querySelectorAll('.nav-link');
            
            navLinks.forEach(link => {
                link.addEventListener('click', function(e) {
                    e.preventDefault();
                    
                    // Remove active class from all links
                    navLinks.forEach(nl => nl.classList.remove('active'));
                    
                    // Add active class to clicked link
                    this.classList.add('active');
                    
                    // Hide all sections
                    document.querySelectorAll('.section-content').forEach(section => {
                        section.classList.add('hidden');
                    });
                    
                    // Show target section
                    const targetId = this.getAttribute('href');
                    document.querySelector(targetId).classList.remove('hidden');
                });
            });
        }

        // Tags input setup
        function setupTagsInput(inputId) {
            const input = document.getElementById(inputId);
            const tagsContainer = document.getElementById(`${inputId}-tags`);
            
            if (!input || !tagsContainer) return;
            
            input.addEventListener('keypress', function(e) {
                if (e.key === 'Enter' || e.key === ',') {
                    e.preventDefault();
                    const value = this.value.trim();
                    
                    if (value) {
                        addTag(value, tagsContainer);
                        this.value = '';
                    }
                }
            });
            
            // Add tag when input loses focus if there's content
            input.addEventListener('blur', function() {
                const value = this.value.trim();
                if (value) {
                    addTag(value, tagsContainer);
                    this.value = '';
                }
            });
        }

        // Add tag to container
        function addTag(value, container) {
            const tag = document.createElement('div');
            tag.className = 'tag inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800';
            tag.innerHTML = `
                ${value}
                <button onclick="this.parentElement.remove()" class="ml-1.5 text-blue-600 hover:text-blue-900">
                    <i class="fas fa-times text-xs"></i>
                </button>
            `;
            container.appendChild(tag);
        }

        // Dynamic list setup
        function setupDynamicList(containerId, itemPrefix) {
            window.addComponentItem = function() {
                const container = document.getElementById(containerId);
                const itemCount = container.children.length + 1;
                
                const item = document.createElement('div');
                item.className = 'dynamic-item bg-gray-50 p-4 rounded-lg border border-gray-200 relative';
                item.innerHTML = `
                    <button onclick="this.parentElement.remove()" class="absolute top-2 right-2 text-gray-400 hover:text-gray-600">
                        <i class="fas fa-times"></i>
                    </button>
                    
                    <div class="mb-3">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Tool Name</label>
                        <input type="text" class="component-name w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="e.g., Web Search">
                    </div>
                    
                    <div class="mb-3">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Description</label>
                        <textarea class="component-description w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" rows="2" placeholder="What this tool does"></textarea>
                    </div>
                    
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Invocation Details</label>
                        <textarea class="component-invocation w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" rows="2" placeholder="How to use this tool"></textarea>
                    </div>
                `;
                
                container.appendChild(item);
            };
        }

        // Save draft function
        function saveDraft() {
            alert('Draft saved! (This is a demo)');
        }

        // Generate system message
        function generateSystemMessage() {
            // Collect data from all sections
            const data = {
                identity: {
                    name: document.getElementById('agent-name').value,
                    persona: document.getElementById('agent-persona').value,
                    attributes: Array.from(document.querySelectorAll('#agent-attributes-tags .tag'))
                        .map(tag => tag.textContent.trim().replace('×', '').trim())
                },
                goal: {
                    primary_objective: document.getElementById('primary-objective').value,
                    kpis: Array.from(document.querySelectorAll('#kpis-tags .tag'))
                        .map(tag => tag.textContent.trim().replace('×', '').trim())
                },
                mandate: {
                    authorized_actions: document.getElementById('authorized-actions').value.split('\n').filter(line => line.trim()),
                    scope: document.getElementById('scope-of-authority').value,
                    responsibilities: document.getElementById('responsibilities').value.split('\n').filter(line => line.trim())
                },
                constraints: {
                    boundaries: document.getElementById('operational-boundaries').value.split('\n').filter(line => line.trim()),
                    ethical_guidelines: document.getElementById('ethical-guidelines').value.split('\n').filter(line => line.trim()),
                    resource_limitations: document.getElementById('resource-limitations').value.split('\n').filter(line => line.trim()),
                    forbidden_actions: document.getElementById('forbidden-actions').value.split('\n').filter(line => line.trim())
                },
                components: Array.from(document.querySelectorAll('#components-list .dynamic-item')).map(item => ({
                    name: item.querySelector('.component-name').value,
                    description: item.querySelector('.component-description').value,
                    invocation: item.querySelector('.component-invocation').value
                })),
                interaction: {
                    communication_style: document.getElementById('communication-style').value,
                    error_handling: document.getElementById('error-handling').value,
                    feedback_mechanism: document.getElementById('feedback-mechanism').value
                }
            };

            // Generate the system message
            const template = `SYSTEM MESSAGE FOR AI AGENT

# IDENTITY
Name: ${data.identity.name || 'Unnamed Agent'}
Persona: ${data.identity.persona || 'No persona description'}
Attributes: ${data.identity.attributes.join(', ') || 'None specified'}

# GOAL
Primary Objective: ${data.goal.primary_objective || 'Not specified'}
KPIs: ${data.goal.kpis.join(', ') || 'None specified'}

# MANDATE
Authorized Actions:
${data.mandate.authorized_actions.map(a => `- ${a}`).join('\n') || 'None specified'}

Scope of Authority: ${data.mandate.scope || 'Not specified'}

Responsibilities:
${data.mandate.responsibilities.map(r => `- ${r}`).join('\n') || 'None specified'}

# CONSTRAINTS
Operational Boundaries:
${data.constraints.boundaries.map(b => `- ${b}`).join('\n') || 'None specified'}

Ethical Guidelines:
${data.constraints.ethical_guidelines.map(g => `- ${g}`).join('\n') || 'None specified'}

Resource Limitations:
${data.constraints.resource_limitations.map(l => `- ${l}`).join('\n') || 'None specified'}

Forbidden Actions:
${data.constraints.forbidden_actions.map(f => `- ${f}`).join('\n') || 'None specified'}

# COMPONENTS
${data.components.map(c => `## ${c.name || 'Unnamed Component'}
Description: ${c.description || 'No description'}
Invocation: ${c.invocation || 'No invocation details'}`).join('\n\n') || 'No components specified'}

# INTERACTION PROTOCOLS
Communication Style: ${data.interaction.communication_style || 'Not specified'}
Error Handling: ${data.interaction.error_handling || 'Not specified'}
Feedback Mechanism: ${data.interaction.feedback_mechanism || 'Not specified'}`;

            // Display the preview
            document.getElementById('preview-code').textContent = template;
            document.getElementById('preview-section').classList.remove('hidden');
        }

        // Copy to clipboard
        function copyToClipboard() {
            const preview = document.getElementById('preview-code');
            navigator.clipboard.writeText(preview.textContent)
                .then(() => {
                    const button = document.querySelector('#preview-section button');
                    const originalHtml = button.innerHTML;
                    button.innerHTML = '<i class="fas fa-check"></i>';
                    setTimeout(() => {
                        button.innerHTML = originalHtml;
                    }, 2000);
                });
        }
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=dokii/system-message-generator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>