-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcreate.html
More file actions
706 lines (653 loc) · 20 KB
/
create.html
File metadata and controls
706 lines (653 loc) · 20 KB
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
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Agent — Clawd Control</title>
<style>
/* Container */
.container {
max-width: 640px;
margin: 0 auto;
padding: 32px;
}
/* Title */
h1 {
font-size: 32px;
font-weight: 700;
margin-bottom: 8px;
letter-spacing: -0.5px;
color: var(--text-primary);
display: flex;
align-items: center;
gap: 12px;
}
.subtitle {
color: var(--text-secondary);
font-size: 15px;
margin-bottom: 48px;
}
/* Steps Progress */
.steps {
display: flex;
gap: 4px;
margin-bottom: 48px;
}
.step-dot {
flex: 1;
height: 4px;
border-radius: 2px;
background: var(--border-subtle);
transition: background 250ms cubic-bezier(0.4, 0, 0.2, 1);
}
.step-dot.active { background: var(--accent); }
.step-dot.done { background: var(--success); }
/* Sections */
.section {
display: none;
animation: fadeIn 250ms cubic-bezier(0.4, 0, 0.2, 1);
}
.section.active { display: block; }
@keyframes fadeIn {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
.section h2 {
font-size: 22px;
font-weight: 700;
margin-bottom: 6px;
color: var(--text-primary);
}
.section .hint {
color: var(--text-secondary);
font-size: 14px;
margin-bottom: 32px;
}
/* Form Fields */
.field {
margin-bottom: 24px;
}
.field label {
display: block;
font-size: 11px;
font-weight: 700;
color: var(--text-tertiary);
margin-bottom: 8px;
text-transform: uppercase;
letter-spacing: 0.8px;
}
.field input,
.field textarea,
.field select {
width: 100%;
padding: 12px 16px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 6px;
color: var(--text-primary);
font-size: 14px;
font-family: var(--font);
outline: none;
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
border-color: var(--accent);
background: var(--bg-secondary);
}
.field textarea {
resize: vertical;
min-height: 100px;
line-height: 1.6;
}
.field select {
appearance: none;
cursor: pointer;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a1a1aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 16px center;
padding-right: 44px;
}
.field .helper {
font-size: 12px;
color: var(--text-secondary);
margin-top: 6px;
line-height: 1.5;
}
.field.error input,
.field.error textarea {
border-color: var(--error);
}
.field .error-msg {
font-size: 12px;
color: var(--error);
margin-top: 6px;
display: none;
}
.field.error .error-msg { display: block; }
/* Emoji Picker */
.emoji-row {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.emoji-btn {
width: 52px;
height: 52px;
font-size: 24px;
background: var(--surface);
border: 2px solid var(--border);
border-radius: 10px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.emoji-btn:hover {
border-color: var(--accent);
transform: scale(1.05);
}
.emoji-btn.selected {
border-color: var(--accent);
background: rgba(201, 164, 74, 0.12);
box-shadow: 0 0 0 3px rgba(201, 164, 74, 0.1);
}
/* Instructions Panel */
.instructions {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 24px;
margin-bottom: 24px;
}
.instructions h3 {
font-size: 14px;
font-weight: 700;
margin-bottom: 16px;
color: var(--text-primary);
}
.instructions ol {
padding-left: 24px;
font-size: 13px;
color: var(--text-secondary);
}
.instructions li {
margin-bottom: 10px;
line-height: 1.6;
}
.instructions code {
background: var(--bg-primary);
padding: 2px 8px;
border-radius: 4px;
font-size: 12px;
color: var(--accent);
font-family: 'SF Mono', 'Consolas', monospace;
}
.instructions a {
color: var(--accent);
text-decoration: none;
font-weight: 500;
}
.instructions a:hover {
text-decoration: underline;
}
/* Skip Link */
.skip-link {
display: inline-block;
margin-top: 12px;
font-size: 13px;
color: var(--text-secondary);
cursor: pointer;
text-decoration: underline;
transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.skip-link:hover { color: var(--accent); }
/* Buttons */
.buttons {
display: flex;
gap: 12px;
margin-top: 40px;
}
.btn {
padding: 12px 24px;
border-radius: 6px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
border: none;
font-family: var(--font);
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
display: inline-flex;
align-items: center;
gap: 8px;
}
.btn-primary {
background: var(--accent);
color: #000;
flex: 1;
}
.btn-primary:hover {
background: var(--accent-hover);
transform: translateY(-1px);
}
.btn-primary:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}
.btn-secondary {
background: var(--surface);
color: var(--text-primary);
border: 1px solid var(--border);
}
.btn-secondary:hover {
background: var(--bg-secondary);
border-color: var(--text-tertiary);
}
/* Review Card */
.review-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 28px;
margin-bottom: 32px;
}
.review-row {
display: flex;
justify-content: space-between;
padding: 12px 0;
border-bottom: 1px solid var(--border-subtle);
font-size: 14px;
}
.review-row:last-child { border-bottom: none; }
.review-label {
color: var(--text-secondary);
font-weight: 500;
}
.review-value {
font-weight: 600;
color: var(--text-primary);
}
/* Result State */
.result {
text-align: center;
padding: 60px 0;
}
.result .icon {
font-size: 64px;
margin-bottom: 20px;
line-height: 1;
}
.result h2 {
font-size: 24px;
margin-bottom: 12px;
color: var(--text-primary);
}
.result p {
color: var(--text-secondary);
margin-bottom: 32px;
font-size: 14px;
line-height: 1.6;
}
.result .actions {
display: flex;
gap: 12px;
justify-content: center;
}
/* Creating State */
.creating-state {
text-align: center;
padding: 80px 0;
}
.creating-state .spinner {
width: 48px;
height: 48px;
border: 3px solid var(--border);
border-top-color: var(--accent);
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin: 0 auto 24px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.creating-state p {
color: var(--text-secondary);
font-size: 14px;
margin-bottom: 24px;
}
.creating-state .log {
margin-top: 24px;
text-align: left;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 20px;
font-family: 'SF Mono', 'Consolas', monospace;
font-size: 12px;
color: var(--success);
max-height: 280px;
overflow-y: auto;
}
.creating-state .log div {
margin-bottom: 6px;
line-height: 1.5;
}
.creating-state .log::-webkit-scrollbar { width: 6px; }
.creating-state .log::-webkit-scrollbar-track { background: var(--bg-primary); }
.creating-state .log::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 3px;
}
/* Lucide Icons */
.lucide, [data-lucide] {
width: 1em;
height: 1em;
display: inline-block;
vertical-align: -0.125em;
flex-shrink: 0;
}
.btn .lucide {
width: 16px;
height: 16px;
}
h1 .lucide {
width: 32px;
height: 32px;
}
/* Responsive */
@media (max-width: 640px) {
.container { padding: 24px 16px; }
h1 { font-size: 26px; }
.emoji-row { justify-content: center; }
.buttons { flex-direction: column; }
.btn-secondary { order: 2; }
}
</style>
</head>
<body>
<main class="main">
<div class="container">
<h1>
<i data-lucide="user-plus"></i>
Create New Agent
</h1>
<p class="subtitle">Spin up a new agent in a few steps.</p>
<div class="steps">
<div class="step-dot active" data-step="0"></div>
<div class="step-dot" data-step="1"></div>
<div class="step-dot" data-step="2"></div>
<div class="step-dot" data-step="3"></div>
</div>
<!-- Step 1: Identity -->
<div class="section active" id="step-0">
<h2>Identity</h2>
<p class="hint">Give your agent a name and personality.</p>
<div class="field" id="f-name">
<label>Name</label>
<input type="text" id="agent-name" placeholder="e.g. Sam, Frodo, Merry" autocomplete="off" maxlength="32">
<p class="error-msg">Name is required</p>
</div>
<div class="field">
<label>Emoji</label>
<div class="emoji-row">
<button class="emoji-btn" data-emoji="🗡️">🗡️</button>
<button class="emoji-btn" data-emoji="🛡️">🛡️</button>
<button class="emoji-btn" data-emoji="🍏">🍏</button>
<button class="emoji-btn" data-emoji="🌿">🌿</button>
<button class="emoji-btn" data-emoji="⚡">⚡</button>
<button class="emoji-btn" data-emoji="🔥">🔥</button>
<button class="emoji-btn" data-emoji="🌟">🌟</button>
<button class="emoji-btn" data-emoji="🦊">🦊</button>
<button class="emoji-btn" data-emoji="🤖">🤖</button>
<button class="emoji-btn" data-emoji="👁️">👁️</button>
</div>
<input type="text" id="agent-emoji-custom" placeholder="Or type your own emoji" style="margin-top:12px" maxlength="4">
</div>
<div class="field">
<label>Personality</label>
<textarea id="agent-soul" placeholder="e.g. Loyal, practical, action-oriented. Gets things done without overthinking. Speaks plainly and values results over theory."></textarea>
<p class="helper">This shapes the agent's SOUL.md — how it thinks and speaks.</p>
</div>
<div class="buttons">
<button class="btn btn-primary" onclick="nextStep()">Continue →</button>
</div>
</div>
<!-- Step 2: Model -->
<div class="section" id="step-1">
<h2>Model</h2>
<p class="hint">Pick the LLM that powers this agent.</p>
<div class="field">
<label>Model</label>
<select id="agent-model">
<option value="anthropic/claude-sonnet-4-5" selected>Claude Sonnet 4.5 — fast, capable, cost-efficient</option>
<option value="anthropic/claude-opus-4-5">Claude Opus 4.5 — most capable, higher cost</option>
</select>
<p class="helper">Sonnet is recommended for most agents. Use Opus for complex reasoning tasks.</p>
</div>
<div class="buttons">
<button class="btn btn-secondary" onclick="prevStep()">← Back</button>
<button class="btn btn-primary" onclick="nextStep()">Continue →</button>
</div>
</div>
<!-- Step 3: Channel -->
<div class="section" id="step-2">
<h2>Telegram Channel</h2>
<p class="hint">Give this agent its own Telegram bot so you can chat with it directly.</p>
<div class="instructions">
<h3>Create a Telegram Bot</h3>
<ol>
<li>Open Telegram and go to <a href="https://t.me/BotFather" target="_blank">@BotFather</a></li>
<li>Send <code>/newbot</code></li>
<li>Choose a display name (e.g. <strong id="botfather-name">Agent Name</strong>)</li>
<li>Choose a username ending in <code>bot</code> (e.g. <strong id="botfather-user">agentname_bot</strong>)</li>
<li>Copy the <strong>bot token</strong> BotFather gives you</li>
</ol>
</div>
<div class="field" id="f-token">
<label>Bot Token</label>
<input type="text" id="agent-token" placeholder="e.g. 1234567890:ABCdefGHIjklMNOpqrsTUVwxyz" autocomplete="off">
<p class="helper">Paste the token from BotFather. It looks like <code>123456:ABC-DEF...</code></p>
<p class="error-msg">Token format looks wrong — should be numbers:letters</p>
</div>
<div>
<span class="skip-link" onclick="skipChannel()">Skip — I'll set up a channel later</span>
</div>
<div class="buttons">
<button class="btn btn-secondary" onclick="prevStep()">← Back</button>
<button class="btn btn-primary" onclick="nextStep()">Continue →</button>
</div>
</div>
<!-- Step 4: Review -->
<div class="section" id="step-3">
<h2>Review & Create</h2>
<p class="hint">Everything look good?</p>
<div class="review-card" id="review-card"></div>
<div class="buttons">
<button class="btn btn-secondary" onclick="prevStep()">← Back</button>
<button class="btn btn-primary" id="create-btn" onclick="createAgent()">
<i data-lucide="rocket"></i> Create Agent
</button>
</div>
</div>
<!-- Creating state -->
<div class="section" id="step-creating">
<div class="creating-state">
<div class="spinner"></div>
<p>Creating your agent...</p>
<div class="log" id="create-log"></div>
</div>
</div>
<!-- Result -->
<div class="section" id="step-done">
<div class="result">
<div class="icon" id="result-icon">🎉</div>
<h2 id="result-title">Agent Created!</h2>
<p id="result-msg"></p>
<div class="actions">
<a href="/" class="btn btn-secondary">← Dashboard</a>
<button class="btn btn-primary" onclick="location.href='/create.html'">Create Another</button>
</div>
</div>
</div>
</div>
<script>
// All state and functions on window so they survive SPA navigation
// (the shared layout runs inline scripts via new Function(), which scopes locally)
window._createPage = window._createPage || {};
window._createPage.currentStep = 0;
window._createPage.selectedEmoji = '';
window._createPage.skipTelegram = false;
(function() {
const state = window._createPage;
// Emoji picker
document.querySelectorAll('.emoji-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.emoji-btn').forEach(b => b.classList.remove('selected'));
btn.classList.add('selected');
state.selectedEmoji = btn.dataset.emoji;
document.getElementById('agent-emoji-custom').value = '';
});
});
document.getElementById('agent-emoji-custom')?.addEventListener('input', (e) => {
if (e.target.value) {
document.querySelectorAll('.emoji-btn').forEach(b => b.classList.remove('selected'));
state.selectedEmoji = e.target.value;
}
});
// Update BotFather hints when name changes
document.getElementById('agent-name')?.addEventListener('input', (e) => {
const name = e.target.value.trim();
const el1 = document.getElementById('botfather-name');
const el2 = document.getElementById('botfather-user');
if (name) {
el1.textContent = name;
el2.textContent = name.toLowerCase().replace(/[^a-z0-9]/g, '') + '_bot';
}
});
function getEmoji() {
return state.selectedEmoji || document.getElementById('agent-emoji-custom')?.value || '🤖';
}
function getData() {
return {
name: document.getElementById('agent-name').value.trim(),
emoji: getEmoji(),
soul: document.getElementById('agent-soul').value.trim(),
model: document.getElementById('agent-model').value,
telegramToken: state.skipTelegram ? '' : document.getElementById('agent-token').value.trim(),
};
}
function validate(step) {
if (step === 0) {
const name = document.getElementById('agent-name').value.trim();
const field = document.getElementById('f-name');
if (!name) { field.classList.add('error'); return false; }
field.classList.remove('error');
return true;
}
if (step === 2 && !state.skipTelegram) {
const token = document.getElementById('agent-token').value.trim();
if (!token) return true;
const field = document.getElementById('f-token');
if (!/^\d+:[A-Za-z0-9_-]+$/.test(token)) { field.classList.add('error'); return false; }
field.classList.remove('error');
return true;
}
return true;
}
function showStep(n) {
document.querySelectorAll('.section').forEach(s => s.classList.remove('active'));
document.getElementById(`step-${n}`).classList.add('active');
document.querySelectorAll('.step-dot').forEach((d, i) => {
d.classList.remove('active', 'done');
if (i < n) d.classList.add('done');
if (i === n) d.classList.add('active');
});
}
function addLog(msg) {
const log = document.getElementById('create-log');
const div = document.createElement('div');
div.textContent = `> ${msg}`;
log.appendChild(div);
log.scrollTop = log.scrollHeight;
}
// Expose on window for onclick handlers
window.nextStep = function() {
if (!validate(state.currentStep)) return;
if (state.currentStep === 2 && !state.skipTelegram && !document.getElementById('agent-token').value.trim()) {
state.skipTelegram = true;
}
state.currentStep++;
if (state.currentStep === 3) buildReview();
showStep(state.currentStep);
};
window.prevStep = function() {
if (state.currentStep > 0) { state.currentStep--; state.skipTelegram = false; showStep(state.currentStep); }
};
window.skipChannel = function() {
state.skipTelegram = true;
window.nextStep();
};
function buildReview() {
const d = getData();
const card = document.getElementById('review-card');
card.innerHTML = `
<div class="review-row"><span class="review-label">Name</span><span class="review-value">${d.emoji} ${d.name}</span></div>
<div class="review-row"><span class="review-label">Personality</span><span class="review-value">${d.soul || '(default)'}</span></div>
<div class="review-row"><span class="review-label">Model</span><span class="review-value">${d.model.split('/')[1]}</span></div>
<div class="review-row"><span class="review-label">Telegram</span><span class="review-value">${d.telegramToken ? '✅ Connected' : '⏭️ Skipped'}</span></div>
<div class="review-row"><span class="review-label">Workspace</span><span class="review-value">~/clawd-agents/${d.name.toLowerCase()}</span></div>
`;
}
window.createAgent = async function() {
const d = getData();
const btn = document.getElementById('create-btn');
btn.disabled = true;
showStep('creating');
addLog(`Creating ${d.name}...`);
try {
const res = await fetch('/api/create-agent', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(d),
});
const result = await res.json();
if (result.steps) {
for (const step of result.steps) {
addLog(step);
await new Promise(r => setTimeout(r, 300));
}
}
if (result.ok) {
addLog('Done!');
await new Promise(r => setTimeout(r, 500));
document.getElementById('result-icon').textContent = d.emoji;
document.getElementById('result-title').textContent = `${d.name} is alive!`;
document.getElementById('result-msg').textContent = result.message || 'Your agent is ready. Head back to Clawd Control to see them.';
showStep('done');
} else {
addLog(`Error: ${result.error}`);
btn.disabled = false;
state.currentStep = 3;
}
} catch (err) {
addLog(`Error: ${err.message}`);
btn.disabled = false;
state.currentStep = 3;
}
};
// Reset state for fresh navigation
state.currentStep = 0;
state.selectedEmoji = '';
state.skipTelegram = false;
})();
</script>
</div>
</main>
<script src="/layout.js"></script>
<script src="/lucide.min.js"></script>
<script>lucide.createIcons();</script>
</body>
</html>