-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.ts
More file actions
171 lines (148 loc) · 7.91 KB
/
constants.ts
File metadata and controls
171 lines (148 loc) · 7.91 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
/**
* @license
* SPDX-License-Identifier: Apache-2.0
*/
/* tslint:disable */
import { AppDefinition, LLMConfig, StyleConfig } from './types';
import systemPromptText from './system_prompt.md?raw';
export const DESKTOP_APP_DEFINITION: AppDefinition = {
id: 'desktop_env',
name: 'Neural Desktop',
icon: '🖥️',
color: '#1a1a2e',
};
export const APP_DEFINITIONS_CONFIG: AppDefinition[] = [
{ id: 'documents', name: 'My Files', icon: 'DOC', color: '#f1f8e9' },
{ id: 'notepad_app', name: 'Notes', icon: 'TXT', color: '#fffde7' },
{ id: 'web_browser_app', name: 'Browser', icon: 'WEB', color: '#e0f7fa' },
{ id: 'gallery_app', name: 'Gallery', icon: 'IMG', color: '#fce4ec' },
{ id: 'videos_app', name: 'Videos', icon: 'VID', color: '#ede7f6' },
{ id: 'calculator_app', name: 'Calculator', icon: 'CALC', color: '#f3e5f5' },
{ id: 'calendar_app', name: 'Calendar', icon: 'DATE', color: '#fff3e0' },
{ id: 'gaming_app', name: 'Games', icon: 'PLAY', color: '#f3e5f5' },
{ id: 'trash_bin', name: 'Trash', icon: 'TRASH', color: '#ffebee' },
{ id: 'insights_app', name: 'Insights', icon: 'DATA', color: '#dbeafe' },
];
export const SETTINGS_APP_DEFINITION: AppDefinition = {
id: 'system_settings_page',
name: 'System Settings',
icon: 'SET',
color: '#e7f3ff',
};
export const ONBOARDING_APP_DEFINITION: AppDefinition = {
id: 'onboarding_app',
name: 'Onboarding',
icon: 'START',
color: '#e8f5e9',
};
export const DEFAULT_WORKSPACE_ROOT = './workspace';
export const DEFAULT_STYLE_CONFIG: StyleConfig = {
colorTheme: 'system',
loadingUiMode: 'code',
contextMemoryMode: 'compacted',
enableAnimations: true,
qualityAutoRetryEnabled: true,
customSystemPrompt: '',
workspaceRoot: DEFAULT_WORKSPACE_ROOT,
};
export const DEFAULT_LLM_CONFIG: LLMConfig = {
providerId: 'google',
modelId: 'gemini-3-flash-preview',
toolTier: 'standard',
};
export const SETTINGS_SKILL_ALLOWED_FIELD_KEYS = [
'colorTheme',
'loadingUiMode',
'contextMemoryMode',
'enableAnimations',
'qualityAutoRetryEnabled',
'customSystemPrompt',
'workspaceRoot',
'googleSearchApiKey',
'googleSearchCx',
'providerId',
'modelId',
'toolTier',
] as const;
export const DEFAULT_SYSTEM_PROMPT = systemPromptText;
export const MANDATORY_OUTPUT_RULES = `
**CRITICAL TECHNICAL REQUIREMENTS:**
- Publish user-visible UI through the \`emit_screen\` tool. This is the canonical output channel.
- Do not rely on plain text output for final rendering.
- For \`emit_screen\` \`op=replace\`, \`html\` must contain raw HTML content only. No markdown fences, no \`<html>\` or \`<body>\` wrappers.
- Prefer \`emit_screen\` patch ops (\`append_child\`, \`prepend_child\`, \`replace_node\`, \`remove_node\`, \`set_text\`, \`set_attr\`) for localized updates.
- Patch ops must include \`baseRevision\` from \`read_screen.meta.revision\` and \`targetId\` matching a stable \`data-ui-id\`.
- Use \`read_screen\` when modifying an existing rendered screen so edits are grounded in current UI state.
- For \`read_screen\`, use the lightest mode first (\`meta\`, then \`outline\`, then \`snippet\`).
- If continuity is unclear, you may inspect prior UI snapshots under \`.neural/ui-history/YYYY-MM-DD/\`; do not block immediate \`emit_screen\` output.
- You CAN and SHOULD use \`<style>\` tags for app-specific CSS.
- You CAN and SHOULD use \`<script>\` tags for interactive apps.
- Do NOT generate a main heading/title solely for window labeling — the window frame provides that.
- Include a metadata marker near the top of output: \`<!--WINDOW_TITLE: Short Screen Name-->\` (1-4 words).
- Use \`data-interaction-id\` on elements that should trigger navigation/actions.
- Add \`data-ui-id\` to stable containers that may be patched in later turns.
- Avoid emoji-first iconography unless explicitly requested by the user.
`;
export const getSystemPrompt = (styleConfig: StyleConfig, appContext?: string | null): string => {
if (styleConfig.customSystemPrompt && appContext !== 'system_settings_page') {
// Append mandatory rules to custom prompt to ensure app still functions
return `${styleConfig.customSystemPrompt}\n\n${MANDATORY_OUTPUT_RULES}`;
}
const { colorTheme } = styleConfig;
let directives = '';
if (colorTheme === 'dark') {
directives += `\n- **Dark Theme:** Use dark backgrounds (#1e1e1e, #2d2d2d) and light text (#e0e0e0) throughout. Apply via a <style> tag on body and all elements.`;
} else if (colorTheme === 'colorful') {
directives += `\n- **Colorful Theme:** Use vibrant accent colors, gradients, and color variety throughout the UI.`;
}
let contextInstructions = '';
if (appContext === 'system_settings_page') {
contextInstructions = `
**CRITICAL — SETTINGS PAGE INSTRUCTIONS:**
This page is controlled by a host-side settings skill.
Do NOT output arbitrary settings HTML. Focus on semantic configuration intent only.
Never generate fake hardware settings in this view.`;
} else if (appContext === 'desktop_env') {
contextInstructions = `
**CRITICAL — DESKTOP ENVIRONMENT INSTRUCTIONS:**
You are generating the main OS desktop. Keep it CLEAN, SIMPLE, and EFFICIENT while fully using the viewport.
1. **Layout:** Occupy the full window height with a wallpaper/background and a grid of launch icons.
2. **Coverage:** Do not leave large empty black regions. If using dark mode, still provide layered gradients or imagery.
3. **Icons:** Use concise text/symbol icons and readable labels. Avoid emoji-only icon grids unless requested.
4. **Interactivity:** Every launch tile must have \`data-interaction-id\`.
5. **Interactive Prompt:** Keep the top prompt/search control visible.
**CORE APPS (Launch via data-interaction-id):**
- documents, notepad_app, web_browser_app, gallery_app, videos_app, calculator_app, calendar_app, gaming_app, trash_bin, insights_app, system_settings_page.`;
} else if (appContext === 'web_browser_app') {
contextInstructions = `
**CRITICAL — BROWSER APP INSTRUCTIONS:**
You are generating a functional web browser.
1. **Interface:** Include an address bar (input type="text"), back/forward buttons, and a "home" button.
2. **Functionality:**
- When a user types a URL or query and presses enter, update the "content area" of your generated HTML to show the "website."
- DO NOT use real external iframes. Instead, simulate the website by changing the inner HTML of a container.
- For searches, use the 'google_search' tool to get real search results.
3. **Sites:** Create realistic simulated websites for common sites like news, social media, or productivity tools.
4. **JavaScript:** Ensure all JS is robust. Avoid complex arrow functions in event listeners.
5. **CRITICAL RESOURCE HANDLING:** Never put placeholder text into \`src\`, \`href\`, or \`url()\` attributes. This causes 404 errors. Only use real URLs from tools or placeholders like \`https://placehold.co/600x400?text=Web+Portal\`.`;
} else if (appContext === 'gallery_app') {
contextInstructions = `
**CRITICAL — GALLERY APP INSTRUCTIONS:**
Generate a high-fidelity, immersive media gallery.
1. **Visuals:** Use large, high-quality thumbnails. Implement a "Lightbox" view for images.
2. **Content:** The gallery showcases photos and images. Use placeholder images from placehold.co or unsplash.
3. **Tools:** Include a "Slide Show" mode and "Download" interactions.
4. **Search:** Allow the user to filter by categories (e.g., "Nature," "Architecture," "People").`;
} else if (appContext === 'onboarding_app') {
contextInstructions = `
**CRITICAL — ONBOARDING APP INSTRUCTIONS:**
You are guiding first-run setup.
1. Use tools/actions to complete onboarding checkpoints before attempting completion.
2. Keep screens concise and action-driven.
3. Use explicit \`data-interaction-id\` targets for each onboarding action.
4. Do not claim completion unless the host confirms it.`;
}
return `${DEFAULT_SYSTEM_PROMPT}
${directives}${contextInstructions}
**Interaction Memory:** Preserve continuity across turns using the memory context provided with each request.`;
};