synthos 0.6.0 → 0.7.1
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.
- package/README.md +33 -1
- package/default-pages/app_builder.html +40 -0
- package/default-pages/app_builder.json +1 -0
- package/default-pages/json_tools.html +89 -159
- package/default-pages/json_tools.json +1 -0
- package/default-pages/my_notes.html +33 -0
- package/default-pages/my_notes.json +12 -0
- package/default-pages/neon_asteroids.html +77 -0
- package/default-pages/neon_asteroids.json +12 -0
- package/default-pages/sidebar_builder.html +49 -0
- package/default-pages/sidebar_builder.json +1 -0
- package/default-pages/solar_explorer.html +1956 -0
- package/default-pages/solar_explorer.json +12 -0
- package/default-pages/solar_tutorial.html +476 -0
- package/default-pages/solar_tutorial.json +1 -0
- package/default-pages/two-panel_builder.html +66 -0
- package/default-pages/two-panel_builder.json +1 -0
- package/default-themes/nebula-dawn.css +682 -0
- package/default-themes/nebula-dawn.json +19 -0
- package/default-themes/nebula-dusk.css +674 -0
- package/default-themes/nebula-dusk.json +19 -0
- package/dist/connectors/index.d.ts +3 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/index.js +6 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/registry.d.ts +3 -0
- package/dist/connectors/registry.d.ts.map +1 -0
- package/dist/connectors/registry.js +100 -0
- package/dist/connectors/registry.js.map +1 -0
- package/dist/connectors/types.d.ts +61 -0
- package/dist/connectors/types.d.ts.map +1 -0
- package/dist/connectors/types.js +3 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/files.d.ts +2 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +12 -1
- package/dist/files.js.map +1 -1
- package/dist/init.d.ts +8 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +155 -3
- package/dist/init.js.map +1 -1
- package/dist/migrations.d.ts +11 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +281 -0
- package/dist/migrations.js.map +1 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +10 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/providers.d.ts +7 -0
- package/dist/models/providers.d.ts.map +1 -0
- package/dist/models/providers.js +33 -0
- package/dist/models/providers.js.map +1 -0
- package/dist/models/types.d.ts +21 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/models/types.js +3 -0
- package/dist/models/types.js.map +1 -0
- package/dist/pages.d.ts +21 -2
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +202 -23
- package/dist/pages.js.map +1 -1
- package/dist/scripts.js +2 -2
- package/dist/scripts.js.map +1 -1
- package/dist/service/createCompletePrompt.d.ts +3 -2
- package/dist/service/createCompletePrompt.d.ts.map +1 -1
- package/dist/service/createCompletePrompt.js +11 -16
- package/dist/service/createCompletePrompt.js.map +1 -1
- package/dist/service/debugLog.d.ts +11 -0
- package/dist/service/debugLog.d.ts.map +1 -0
- package/dist/service/debugLog.js +26 -0
- package/dist/service/debugLog.js.map +1 -0
- package/dist/service/modelInstructions.d.ts +7 -0
- package/dist/service/modelInstructions.d.ts.map +1 -0
- package/dist/service/modelInstructions.js +16 -0
- package/dist/service/modelInstructions.js.map +1 -0
- package/dist/service/requiresSettings.d.ts +2 -2
- package/dist/service/requiresSettings.d.ts.map +1 -1
- package/dist/service/requiresSettings.js.map +1 -1
- package/dist/service/server.d.ts.map +1 -1
- package/dist/service/server.js +15 -0
- package/dist/service/server.js.map +1 -1
- package/dist/service/transformPage.d.ts +81 -2
- package/dist/service/transformPage.d.ts.map +1 -1
- package/dist/service/transformPage.js +672 -82
- package/dist/service/transformPage.js.map +1 -1
- package/dist/service/useApiRoutes.d.ts.map +1 -1
- package/dist/service/useApiRoutes.js +579 -13
- package/dist/service/useApiRoutes.js.map +1 -1
- package/dist/service/useConnectorRoutes.d.ts +4 -0
- package/dist/service/useConnectorRoutes.d.ts.map +1 -0
- package/dist/service/useConnectorRoutes.js +389 -0
- package/dist/service/useConnectorRoutes.js.map +1 -0
- package/dist/service/useDataRoutes.d.ts.map +1 -1
- package/dist/service/useDataRoutes.js +83 -70
- package/dist/service/useDataRoutes.js.map +1 -1
- package/dist/service/usePageRoutes.d.ts.map +1 -1
- package/dist/service/usePageRoutes.js +243 -38
- package/dist/service/usePageRoutes.js.map +1 -1
- package/dist/settings.d.ts +33 -4
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +108 -15
- package/dist/settings.js.map +1 -1
- package/dist/synthos-cli.d.ts.map +1 -1
- package/dist/synthos-cli.js +11 -1
- package/dist/synthos-cli.js.map +1 -1
- package/dist/themes.d.ts +9 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +64 -0
- package/dist/themes.js.map +1 -0
- package/package.json +6 -3
- package/required-pages/builder.html +74 -0
- package/required-pages/builder.json +1 -0
- package/required-pages/pages.html +169 -126
- package/required-pages/pages.json +1 -0
- package/required-pages/settings.html +812 -156
- package/required-pages/settings.json +1 -0
- package/required-pages/synthos_apis.html +272 -0
- package/required-pages/synthos_apis.json +1 -0
- package/required-pages/synthos_scripts.html +87 -0
- package/required-pages/synthos_scripts.json +1 -0
- package/src/connectors/index.ts +12 -0
- package/src/connectors/registry.ts +98 -0
- package/src/connectors/types.ts +68 -0
- package/src/files.ts +11 -0
- package/src/init.ts +151 -5
- package/src/migrations.ts +266 -0
- package/src/models/index.ts +2 -0
- package/src/models/providers.ts +33 -0
- package/src/models/types.ts +23 -0
- package/src/pages.ts +234 -26
- package/src/scripts.ts +2 -2
- package/src/service/createCompletePrompt.ts +14 -18
- package/src/service/debugLog.ts +17 -0
- package/src/service/modelInstructions.ts +14 -0
- package/src/service/requiresSettings.ts +3 -3
- package/src/service/server.ts +19 -2
- package/src/service/transformPage.ts +709 -88
- package/src/service/useApiRoutes.ts +632 -16
- package/src/service/useConnectorRoutes.ts +427 -0
- package/src/service/useDataRoutes.ts +87 -71
- package/src/service/usePageRoutes.ts +237 -44
- package/src/settings.ts +143 -20
- package/src/synthos-cli.ts +11 -1
- package/src/themes.ts +71 -0
- package/default-pages/[application].html +0 -95
- package/default-pages/[markdown].html +0 -271
- package/default-pages/[sidebar].html +0 -114
- package/default-pages/[split-application].html +0 -118
- package/default-pages/solar_system.html +0 -432
- package/default-pages/space_invaders.html +0 -617
- package/required-pages/apis.html +0 -362
- package/required-pages/home.html +0 -126
- package/required-pages/scripts.html +0 -350
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>SynthOS - Scripts</title>
|
|
7
|
-
<style>
|
|
8
|
-
/* Nebula Dusk Theme */
|
|
9
|
-
:root { --bg-primary: #1a1a2e; --bg-secondary: #16213e; --bg-tertiary: #0f0f23; --accent-primary: #667eea; --accent-secondary: #764ba2; --accent-tertiary: #f093fb; --accent-glow: rgba(138, 43, 226, 0.3); --text-primary: #e0e0e0; --text-secondary: #b794f6; --border-color: rgba(138, 43, 226, 0.3); }
|
|
10
|
-
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
11
|
-
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%); color: var(--text-primary); height: 100vh; display: flex; }
|
|
12
|
-
.chat-panel { width: 30%; background: linear-gradient(180deg, rgba(26, 26, 46, 0.95) 0%, rgba(22, 33, 62, 0.95) 100%); box-shadow: 0 0 30px var(--accent-glow), inset 0 0 60px rgba(75, 0, 130, 0.1); padding: 20px; display: flex; flex-direction: column; border-right: 1px solid var(--border-color); }
|
|
13
|
-
.chat-header { font-size: 24px; padding: 15px; background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 50%, var(--accent-tertiary) 100%); color: white; text-align: center; border-radius: 15px; box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); letter-spacing: 2px; }
|
|
14
|
-
.chat-messages { flex-grow: 1; overflow-y: auto; padding: 15px; margin-top: 15px; background: rgba(15, 15, 35, 0.6); border-radius: 15px; border: 1px solid var(--border-color); box-shadow: inset 0 0 30px rgba(75, 0, 130, 0.2); }
|
|
15
|
-
.chat-message { margin-bottom: 15px; padding: 12px 15px; background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%); border-radius: 15px; box-shadow: 0 2px 10px var(--accent-glow); border: 1px solid rgba(138, 43, 226, 0.1); backdrop-filter: blur(5px); }
|
|
16
|
-
.chat-message p { margin-bottom: 5px; line-height: 1.5; }
|
|
17
|
-
.chat-message p strong { font-weight: 600; background: linear-gradient(90deg, var(--accent-primary), var(--accent-tertiary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
|
|
18
|
-
.chat-message p code { background: rgba(138, 43, 226, 0.3); padding: 2px 6px; border-radius: 5px; font-family: 'Courier New', Courier, monospace; color: var(--accent-tertiary); border: 1px solid rgba(240, 147, 251, 0.3); }
|
|
19
|
-
.link-group { display: flex; justify-content: space-between; margin: 15px 0; padding: 10px; background: rgba(15, 15, 35, 0.4); border-radius: 10px; border: 1px solid var(--border-color); }
|
|
20
|
-
.link-group a { font-size: 14px; color: var(--text-secondary); text-decoration: none; padding: 8px 15px; border-radius: 8px; transition: all 0.3s ease; border: 1px solid transparent; }
|
|
21
|
-
.link-group a:hover { background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%); border-color: rgba(183, 148, 246, 0.5); box-shadow: 0 0 15px var(--accent-glow); color: var(--accent-tertiary); }
|
|
22
|
-
form { display: flex; flex-direction: row; width: 100%; gap: 10px; align-items: center; }
|
|
23
|
-
.chat-input { padding: 14px 18px; border: 1px solid var(--border-color); border-radius: 25px; flex-grow: 1; font-size: 14px; background: rgba(15, 15, 35, 0.8); color: var(--text-primary); box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 20px rgba(138, 43, 226, 0.1); transition: all 0.3s ease; }
|
|
24
|
-
.chat-input:focus { outline: none; border-color: rgba(183, 148, 246, 0.6); box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 25px var(--accent-glow); }
|
|
25
|
-
.chat-input::placeholder { color: rgba(183, 148, 246, 0.5); }
|
|
26
|
-
.chat-submit { padding: 14px 20px; border: none; border-radius: 25px; font-size: 14px; background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 50%, var(--accent-tertiary) 100%); color: white; cursor: pointer; transition: all 0.3s ease; font-weight: 600; letter-spacing: 1px; box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4); white-space: nowrap; }
|
|
27
|
-
.chat-submit:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6); }
|
|
28
|
-
.chat-submit:active { transform: translateY(0); }
|
|
29
|
-
.viewer-panel { width: 70%; padding: 25px; background: linear-gradient(135deg, rgba(22, 33, 62, 0.9) 0%, rgba(15, 15, 35, 0.95) 100%); display: flex; flex-direction: column; justify-content: flex-start; align-items: center; box-shadow: inset 0 0 60px rgba(75, 0, 130, 0.15); position: relative; overflow: hidden; }
|
|
30
|
-
.viewer-panel::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(ellipse at center, rgba(138, 43, 226, 0.05) 0%, transparent 70%); animation: nebula-pulse 8s ease-in-out infinite; pointer-events: none; }
|
|
31
|
-
@keyframes nebula-pulse { 0%, 100% { opacity: 0.5; transform: scale(1); } 50% { opacity: 1; transform: scale(1.1); } }
|
|
32
|
-
.loading-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 15, 35, 0.9); justify-content: center; align-items: center; z-index: 1000; }
|
|
33
|
-
.spinner { width: 50px; height: 50px; border: 4px solid var(--border-color); border-top-color: var(--accent-tertiary); border-radius: 50%; animation: spin 1s linear infinite; }
|
|
34
|
-
@keyframes spin { to { transform: rotate(360deg); } }
|
|
35
|
-
::-webkit-scrollbar { width: 10px; height: 10px; }
|
|
36
|
-
::-webkit-scrollbar-track { background: rgba(15, 15, 35, 0.6); border-radius: 10px; border: 1px solid var(--border-color); }
|
|
37
|
-
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--accent-primary) 0%, var(--accent-secondary) 50%, var(--accent-tertiary) 100%); border-radius: 10px; border: 2px solid rgba(15, 15, 35, 0.6); box-shadow: 0 0 10px var(--accent-glow); }
|
|
38
|
-
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, var(--accent-tertiary) 0%, var(--accent-secondary) 50%, var(--accent-primary) 100%); box-shadow: 0 0 15px rgba(240, 147, 251, 0.5); }
|
|
39
|
-
::-webkit-scrollbar-corner { background: rgba(15, 15, 35, 0.6); }
|
|
40
|
-
* { scrollbar-width: thin; scrollbar-color: var(--accent-secondary) rgba(15, 15, 35, 0.6); }
|
|
41
|
-
.application-title { font-size: 22px; font-weight: 700; padding: 14px 30px; background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)); color: white; text-align: center; border-radius: 12px; width: 100%; max-width: 800px; box-shadow: 0 6px 25px var(--accent-glow); position: relative; z-index: 1; }
|
|
42
|
-
.application-content { font-size: 14px; color: var(--text-secondary); padding: 15px 0; flex-grow: 1; width: 100%; max-width: 800px; position: relative; z-index: 1; overflow-y: auto; display: flex; gap: 20px; }
|
|
43
|
-
.script-list { width: 200px; flex-shrink: 0; }
|
|
44
|
-
.script-list ul { list-style: none; background: rgba(15, 15, 35, 0.6); border-radius: 10px; border: 1px solid var(--border-color); overflow: hidden; margin-bottom: 10px; max-height: 300px; overflow-y: auto; }
|
|
45
|
-
.script-list li { padding: 12px 15px; cursor: pointer; transition: all 0.3s; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); }
|
|
46
|
-
.script-list li:last-child { border-bottom: none; }
|
|
47
|
-
.script-list li:hover { background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%); color: var(--accent-tertiary); }
|
|
48
|
-
.script-list li.active { background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%); color: var(--accent-tertiary); box-shadow: inset 0 0 15px var(--accent-glow); }
|
|
49
|
-
.add-script-btn, .save-script-btn, .delete-script-btn { width: 100%; padding: 12px 18px; border: none; border-radius: 10px; background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%); color: white; cursor: pointer; transition: all 0.3s; font-weight: 500; font-size: 13px; box-shadow: 0 3px 15px var(--accent-glow); margin-bottom: 8px; }
|
|
50
|
-
.add-script-btn:hover, .save-script-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(102, 126, 234, 0.5); }
|
|
51
|
-
.delete-script-btn { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); box-shadow: 0 3px 15px rgba(231, 76, 60, 0.3); }
|
|
52
|
-
.delete-script-btn:hover { box-shadow: 0 5px 20px rgba(231, 76, 60, 0.5); transform: translateY(-2px); }
|
|
53
|
-
.script-detail { flex-grow: 1; background: rgba(15, 15, 35, 0.6); border-radius: 10px; border: 1px solid var(--border-color); padding: 20px; }
|
|
54
|
-
.script-detail input, .script-detail select { width: 100%; padding: 12px 15px; margin-bottom: 12px; border-radius: 8px; border: 1px solid var(--border-color); background: rgba(15, 15, 35, 0.8); color: var(--text-primary); font-size: 13px; transition: all 0.3s; }
|
|
55
|
-
.script-detail input:focus, .script-detail select:focus { outline: none; border-color: var(--text-secondary); box-shadow: 0 0 15px var(--accent-glow); }
|
|
56
|
-
.script-detail select { cursor: pointer; }
|
|
57
|
-
.script-detail select option { background: var(--bg-tertiary); color: var(--text-primary); }
|
|
58
|
-
.placeholder-message { color: var(--text-secondary); text-align: center; padding: 40px 20px; line-height: 1.6; }
|
|
59
|
-
.error-message { display: none; color: #e74c3c; font-size: 12px; margin-bottom: 12px; padding: 8px 12px; background: rgba(231, 76, 60, 0.1); border-radius: 6px; border: 1px solid rgba(231, 76, 60, 0.3); }
|
|
60
|
-
.instructions { margin-top: 20px; padding: 15px; background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%); border-radius: 10px; border: 1px solid var(--border-color); }
|
|
61
|
-
.instructions h3 { color: var(--accent-tertiary); margin: 15px 0 8px 0; font-size: 14px; }
|
|
62
|
-
.instructions h3:first-child { margin-top: 0; }
|
|
63
|
-
.instructions p { color: var(--text-secondary); font-size: 12px; line-height: 1.6; margin-bottom: 8px; }
|
|
64
|
-
.instructions code { background: rgba(138, 43, 226, 0.3); padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', Courier, monospace; color: var(--accent-tertiary); border: 1px solid rgba(240, 147, 251, 0.3); font-size: 11px; }
|
|
65
|
-
</style>
|
|
66
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js"></script>
|
|
67
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/14.1.1/marked.min.js"></script>
|
|
68
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/11.1.0/mermaid.min.js"></script>
|
|
69
|
-
</head>
|
|
70
|
-
<body>
|
|
71
|
-
<div class="chat-panel">
|
|
72
|
-
<div class="chat-header">SynthOS</div>
|
|
73
|
-
<div class="chat-messages" id="chatMessages">
|
|
74
|
-
<div class="chat-message"><p><strong>SynthOS:</strong> Add or modify scripts that can be executed using the <code>/api/scripts/:id</code> API.</p></div>
|
|
75
|
-
</div>
|
|
76
|
-
<div class="link-group">
|
|
77
|
-
<a href="#" id="saveLink">Save</a>
|
|
78
|
-
<a href="/pages" id="pagesLink">Pages</a>
|
|
79
|
-
<a href="#" id="resetLink">Reset</a>
|
|
80
|
-
</div>
|
|
81
|
-
<form action="/" method="POST" id="chatForm">
|
|
82
|
-
<input type="text" class="chat-input" id="chatInput" name="message" placeholder="Type a message...">
|
|
83
|
-
<button type="submit" class="chat-submit">Send</button>
|
|
84
|
-
</form>
|
|
85
|
-
</div>
|
|
86
|
-
<div class="viewer-panel" id="viewerPanel">
|
|
87
|
-
<div class="application-title">Script Editor</div>
|
|
88
|
-
<div class="application-content">
|
|
89
|
-
<div class="script-list">
|
|
90
|
-
<ul id="scriptList">
|
|
91
|
-
<!-- Scripts will be loaded here -->
|
|
92
|
-
</ul>
|
|
93
|
-
<button class="add-script-btn">Add New Script</button>
|
|
94
|
-
</div>
|
|
95
|
-
<div class="script-detail">
|
|
96
|
-
<div id="placeholderMessage" class="placeholder-message">
|
|
97
|
-
Select an existing script to edit or add a new one using the "Add New Script" button.
|
|
98
|
-
</div>
|
|
99
|
-
<input type="text" id="scriptId" placeholder="Script ID" value="" style="display: none;">
|
|
100
|
-
<select id="scriptType" style="display: none;">
|
|
101
|
-
<option value="command">Command</option>
|
|
102
|
-
</select>
|
|
103
|
-
<input type="text" id="scriptCommand" placeholder="Script Command" style="display: none;">
|
|
104
|
-
<input type="text" id="scriptDescription" placeholder="Usage Description (optional)" style="display: none;">
|
|
105
|
-
<input type="text" id="scriptVariables" placeholder="Variables (optional, e.g., { city: string })" style="display: none;">
|
|
106
|
-
<div id="commandError" class="error-message">Script Command is required.</div>
|
|
107
|
-
<button class="save-script-btn" style="display: none;">Save Changes</button>
|
|
108
|
-
<button class="delete-script-btn" style="display: none;">Delete Script</button>
|
|
109
|
-
<div class="instructions">
|
|
110
|
-
<h3>Understanding SynthOS Scripts</h3>
|
|
111
|
-
<p>Scripts in SynthOS are powerful tools that allow you to define custom terminal commands for various tasks. When SynthOS executes a script, it runs the command and captures the console output, which is then returned for further processing or analysis.</p>
|
|
112
|
-
|
|
113
|
-
<h3>Creating Effective Scripts</h3>
|
|
114
|
-
<p>When writing a script, you can use any valid terminal command. For added flexibility, you can include {{variable}} placeholders, which SynthOS will replace with actual values during execution.</p>
|
|
115
|
-
|
|
116
|
-
<h3>Example: Weather Forecast Script</h3>
|
|
117
|
-
<p>Here's an example of an interesting script that SynthOS could use:</p>
|
|
118
|
-
<p><code>curl wttr.in/{{city}}?format=3</code></p>
|
|
119
|
-
<p>This script fetches a concise weather forecast for a specified city. SynthOS can call this script with different city names to get up-to-date weather information.</p>
|
|
120
|
-
|
|
121
|
-
<h3>Tips for Script Writing</h3>
|
|
122
|
-
<p>1. Keep commands concise and focused on a single task.</p>
|
|
123
|
-
<p>2. Use variables for dynamic inputs to make scripts more versatile.</p>
|
|
124
|
-
<p>3. Consider potential errors and how to handle them.</p>
|
|
125
|
-
<p>4. Test your scripts thoroughly to ensure they work as expected.</p>
|
|
126
|
-
<p>5. Provide a clear and concise usage description to help others understand how to use your script.</p>
|
|
127
|
-
<p>6. Define the expected variables in the Variables field to document the script's requirements.</p>
|
|
128
|
-
|
|
129
|
-
<h3>Using the Description Field</h3>
|
|
130
|
-
<p>The Description field allows you to provide a brief explanation of what SynthOS can use your script for.</p>
|
|
131
|
-
|
|
132
|
-
<h3>Defining Variables</h3>
|
|
133
|
-
<p>Use the Variables field to specify any input parameters your script expects. Format it as a JSON object, e.g., { city: string, days?: number }. This helps SynthOS know what inputs it needs to provide when running your script.</p>
|
|
134
|
-
</div>
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
<div id="thoughts" style="display: none;">I've show the user a list of available scripts.</div>
|
|
139
|
-
<div id="loadingOverlay" class="loading-overlay"><div class="spinner"></div></div>
|
|
140
|
-
<script>
|
|
141
|
-
// Basic chat functionality
|
|
142
|
-
document.getElementById("chatInput").focus();
|
|
143
|
-
document.getElementById("chatForm").addEventListener('submit', () => {
|
|
144
|
-
document.getElementById("loadingOverlay").style.display = 'flex';
|
|
145
|
-
document.getElementById("chatForm").action = window.location.pathname;
|
|
146
|
-
});
|
|
147
|
-
document.getElementById("saveLink").addEventListener("click", function() {
|
|
148
|
-
const pageName = prompt("Enter the name of the page to save as:");
|
|
149
|
-
if (pageName) {
|
|
150
|
-
window.location.href = `${window.location.pathname}/save?name=${encodeURIComponent(pageName)}`;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
document.getElementById("resetLink").addEventListener("click", function() {
|
|
154
|
-
window.location.href = `${window.location.pathname}/reset`;
|
|
155
|
-
});
|
|
156
|
-
window.onload = function() {
|
|
157
|
-
const chatMessages = document.getElementById('chatMessages');
|
|
158
|
-
chatMessages.scrollTo({
|
|
159
|
-
top: chatMessages.scrollHeight,
|
|
160
|
-
behavior: 'smooth'
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// Script Editor Functionality
|
|
165
|
-
const scriptList = document.getElementById('scriptList');
|
|
166
|
-
const scriptId = document.getElementById('scriptId');
|
|
167
|
-
const scriptType = document.getElementById('scriptType');
|
|
168
|
-
const scriptCommand = document.getElementById('scriptCommand');
|
|
169
|
-
const scriptDescription = document.getElementById('scriptDescription');
|
|
170
|
-
const scriptVariables = document.getElementById('scriptVariables');
|
|
171
|
-
const addScriptBtn = document.querySelector('.add-script-btn');
|
|
172
|
-
const saveScriptBtn = document.querySelector('.save-script-btn');
|
|
173
|
-
const deleteScriptBtn = document.querySelector('.delete-script-btn');
|
|
174
|
-
const placeholderMessage = document.getElementById('placeholderMessage');
|
|
175
|
-
const commandError = document.getElementById('commandError');
|
|
176
|
-
|
|
177
|
-
let isNewScript = false;
|
|
178
|
-
|
|
179
|
-
function showScriptDetails() {
|
|
180
|
-
placeholderMessage.style.display = 'none';
|
|
181
|
-
scriptId.style.display = 'block';
|
|
182
|
-
scriptType.style.display = 'block';
|
|
183
|
-
scriptCommand.style.display = 'block';
|
|
184
|
-
scriptDescription.style.display = 'block';
|
|
185
|
-
scriptVariables.style.display = 'block';
|
|
186
|
-
saveScriptBtn.style.display = 'block';
|
|
187
|
-
deleteScriptBtn.style.display = isNewScript ? 'none' : 'block';
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function hideScriptDetails() {
|
|
191
|
-
placeholderMessage.style.display = 'block';
|
|
192
|
-
scriptId.style.display = 'none';
|
|
193
|
-
scriptType.style.display = 'none';
|
|
194
|
-
scriptCommand.style.display = 'none';
|
|
195
|
-
scriptDescription.style.display = 'none';
|
|
196
|
-
scriptVariables.style.display = 'none';
|
|
197
|
-
saveScriptBtn.style.display = 'none';
|
|
198
|
-
deleteScriptBtn.style.display = 'none';
|
|
199
|
-
commandError.style.display = 'none';
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function formatId(id) {
|
|
203
|
-
return id.toLowerCase().replace(/\s+/g, '-');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function loadScripts() {
|
|
207
|
-
fetch('/api/data/scripts')
|
|
208
|
-
.then(response => response.json())
|
|
209
|
-
.then(scripts => {
|
|
210
|
-
scriptList.innerHTML = '';
|
|
211
|
-
scripts.forEach(script => {
|
|
212
|
-
const li = document.createElement('li');
|
|
213
|
-
li.textContent = script.id;
|
|
214
|
-
li.dataset.id = script.id;
|
|
215
|
-
li.dataset.type = script.type;
|
|
216
|
-
li.dataset.command = script.command;
|
|
217
|
-
li.dataset.description = script.description || '';
|
|
218
|
-
li.dataset.variables = script.variables || '';
|
|
219
|
-
scriptList.appendChild(li);
|
|
220
|
-
});
|
|
221
|
-
})
|
|
222
|
-
.catch(error => console.error('Error loading scripts:', error));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function saveScript(script) {
|
|
226
|
-
fetch('/api/data/scripts')
|
|
227
|
-
.then(response => response.json())
|
|
228
|
-
.then(scripts => {
|
|
229
|
-
const existingScript = scripts.find(s => s.id === script.id);
|
|
230
|
-
if (existingScript && isNewScript) {
|
|
231
|
-
if (confirm('A script with this ID already exists. Do you want to overwrite it?')) {
|
|
232
|
-
performSave(script);
|
|
233
|
-
}
|
|
234
|
-
} else {
|
|
235
|
-
performSave(script);
|
|
236
|
-
}
|
|
237
|
-
})
|
|
238
|
-
.catch(error => console.error('Error checking existing scripts:', error));
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function performSave(script) {
|
|
242
|
-
fetch('/api/data/scripts', {
|
|
243
|
-
method: 'POST',
|
|
244
|
-
headers: {
|
|
245
|
-
'Content-Type': 'application/json',
|
|
246
|
-
},
|
|
247
|
-
body: JSON.stringify(script),
|
|
248
|
-
})
|
|
249
|
-
.then(response => response.json())
|
|
250
|
-
.then(savedScript => {
|
|
251
|
-
loadScripts();
|
|
252
|
-
isNewScript = false;
|
|
253
|
-
setTimeout(() => {
|
|
254
|
-
const newScriptElement = document.querySelector(`[data-id="${savedScript.id}"]`);
|
|
255
|
-
if (newScriptElement) {
|
|
256
|
-
newScriptElement.click();
|
|
257
|
-
}
|
|
258
|
-
}, 100);
|
|
259
|
-
})
|
|
260
|
-
.catch(error => console.error('Error saving script:', error));
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function deleteScript(id) {
|
|
264
|
-
if (confirm('Are you sure you want to delete this script?')) {
|
|
265
|
-
fetch(`/api/data/scripts/${id}`, {
|
|
266
|
-
method: 'DELETE',
|
|
267
|
-
})
|
|
268
|
-
.then(response => response.json())
|
|
269
|
-
.then(result => {
|
|
270
|
-
if (result.success) {
|
|
271
|
-
loadScripts();
|
|
272
|
-
hideScriptDetails();
|
|
273
|
-
} else {
|
|
274
|
-
console.error('Failed to delete script.');
|
|
275
|
-
}
|
|
276
|
-
})
|
|
277
|
-
.catch(error => console.error('Error deleting script:', error));
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
scriptList.addEventListener('click', (e) => {
|
|
282
|
-
if (e.target.tagName === 'LI') {
|
|
283
|
-
document.querySelectorAll('.script-list li').forEach(li => li.classList.remove('active'));
|
|
284
|
-
e.target.classList.add('active');
|
|
285
|
-
showScriptDetails();
|
|
286
|
-
scriptId.value = e.target.dataset.id;
|
|
287
|
-
scriptType.value = e.target.dataset.type || 'command';
|
|
288
|
-
scriptCommand.value = e.target.dataset.command || '';
|
|
289
|
-
scriptDescription.value = e.target.dataset.description || '';
|
|
290
|
-
scriptVariables.value = e.target.dataset.variables || '';
|
|
291
|
-
commandError.style.display = 'none';
|
|
292
|
-
isNewScript = false;
|
|
293
|
-
deleteScriptBtn.style.display = 'block';
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
addScriptBtn.addEventListener('click', () => {
|
|
298
|
-
const newId = formatId(`script-${Date.now()}`);
|
|
299
|
-
showScriptDetails();
|
|
300
|
-
scriptId.value = newId;
|
|
301
|
-
scriptType.value = 'command';
|
|
302
|
-
scriptCommand.value = '';
|
|
303
|
-
scriptDescription.value = '';
|
|
304
|
-
scriptVariables.value = '';
|
|
305
|
-
commandError.style.display = 'none';
|
|
306
|
-
document.querySelectorAll('.script-list li').forEach(li => li.classList.remove('active'));
|
|
307
|
-
isNewScript = true;
|
|
308
|
-
deleteScriptBtn.style.display = 'none';
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
saveScriptBtn.addEventListener('click', () => {
|
|
312
|
-
if (!scriptCommand.value.trim()) {
|
|
313
|
-
commandError.style.display = 'block';
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const script = {
|
|
318
|
-
id: formatId(scriptId.value),
|
|
319
|
-
type: scriptType.value,
|
|
320
|
-
command: scriptCommand.value,
|
|
321
|
-
description: scriptDescription.value.trim() || undefined,
|
|
322
|
-
variables: scriptVariables.value.trim() || undefined,
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
saveScript(script);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
deleteScriptBtn.addEventListener('click', () => {
|
|
329
|
-
const id = scriptId.value;
|
|
330
|
-
if (id) {
|
|
331
|
-
deleteScript(id);
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
scriptId.addEventListener('input', (e) => {
|
|
336
|
-
e.target.value = formatId(e.target.value);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
scriptCommand.addEventListener('input', () => {
|
|
340
|
-
commandError.style.display = 'none';
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
// Load scripts when the page loads
|
|
344
|
-
loadScripts();
|
|
345
|
-
|
|
346
|
-
// Initialize with empty fields and show placeholder
|
|
347
|
-
hideScriptDetails();
|
|
348
|
-
</script>
|
|
349
|
-
</body>
|
|
350
|
-
</html>
|