Compare commits

...
2 Commits
Author SHA1 Message Date
Gitea Actions 5354132489 Release 0.1.31 [auto-version-bump] 2026-10-15 10:46:29 +02:00
Ein Anderssono 0005bb1c83 Support NPC-led conversation flow
Build and publish frontend / publish (push) Successful in 38s
2026-10-15 10:45:33 +02:00
5 changed files with 21 additions and 6 deletions
+2
View File
@@ -6,6 +6,8 @@ After login, character creation and play use one dialogue history and one text i
During play the UI has no persistent location, task, inventory, economy, status, or purchase panels. The player asks for information or writes an action in the same input. Rust validates state changes; the AI can only propose a typed intent. A direct request to travel may establish a new place and an encounter when Rust commits that movement. During play the UI has no persistent location, task, inventory, economy, status, or purchase panels. The player asks for information or writes an action in the same input. Rust validates state changes; the AI can only propose a typed intent. A direct request to travel may establish a new place and an encounter when Rust commits that movement.
If the player asks to find or approach someone and no NPC is present, the direct dialogue scene may propose one person and an opening line. Rust creates that NPC only for the explicit request and commits the first exchange idempotently; a later turn continues the saved conversation. Clear requests about the current location are answered from its saved facts without asking the player to restate what they want to inspect.
The separate `/admin` route provides an authenticated, read-only operations view for player search/profile/trace, YAML prompt assets, generated Luau rules with validation results, and the append-only audit log. All privileged data comes from the Rust `/api/admin/...` API; the browser never connects directly to PostgreSQL. Backend endpoints require `accounts.is_admin=true`. The separate `/admin` route provides an authenticated, read-only operations view for player search/profile/trace, YAML prompt assets, generated Luau rules with validation results, and the append-only audit log. All privileged data comes from the Rust `/api/admin/...` API; the browser never connects directly to PostgreSQL. Backend endpoints require `accounts.is_admin=true`.
The game is text- and dialogue-based and uses no images. Place descriptions include sound, smell, air/temperature, touch/surface, and spatial-orientation cues. Visible details may also be described in words, but are never required to understand the scene or play. The transcript is screen-reader announced, and Enter submits the input while Shift+Enter inserts a newline; no separate send button is required. The game is text- and dialogue-based and uses no images. Place descriptions include sound, smell, air/temperature, touch/surface, and spatial-orientation cues. Visible details may also be described in words, but are never required to understand the scene or play. The transcript is screen-reader announced, and Enter submits the input while Shift+Enter inserts a newline; no separate send button is required.
+1 -1
View File
@@ -1 +1 @@
0.1.30 0.1.31
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: ai-spel-frontend name: ai-spel-frontend
description: Static web frontend for the Swedish life simulator description: Static web frontend for the Swedish life simulator
type: application type: application
version: 0.1.30 version: 0.1.31
appVersion: "0.1.30" appVersion: "0.1.31"
+14 -3
View File
@@ -115,6 +115,17 @@
} }
return line; return line;
} }
function explainDialogueError(error) {
const code = String(error?.message || '');
const known = {
dialogue_temporarily_unavailable: 'Berättartjänsten svarar inte just nu. Vänta en stund och försök igen.',
world_version_conflict: 'Världen hann ändras medan du skrev. Jag har uppdaterat läget; skicka meddelandet igen.',
world_not_available: 'Världen är inte tillgänglig just nu. Försök igen om en liten stund.',
};
return known[code] || (/^[a-z0-9_]+$/.test(code)
? 'Jag kunde inte behandla det just nu. Försök igen om en liten stund.'
: code || 'Ett tillfälligt fel uppstod. Försök igen om en liten stund.');
}
function setVoiceStatus(message = '') { document.querySelector('#voice-status').textContent = message; } function setVoiceStatus(message = '') { document.querySelector('#voice-status').textContent = message; }
function refreshMicrophone() { function refreshMicrophone() {
const button = document.querySelector('#microphone'); const button = document.querySelector('#microphone');
@@ -534,19 +545,19 @@
gameState.world.version = result.world_version; gameState.world.version = result.world_version;
gameState.world.world_time = result.world_time; gameState.world.world_time = result.world_time;
pendingDialogue = null; pendingDialogue = null;
if (result.intent === 'move') { if (result.intent === 'move' || result.intent === 'meet') {
try { try {
const refreshed = await request('/api/world'); const refreshed = await request('/api/world');
if (refreshed.world) gameState = refreshed; if (refreshed.world) gameState = refreshed;
} catch (_) { /* The committed dialogue stays successful if this optional view refresh fails. */ } } catch (_) { /* The committed dialogue stays successful if this optional view refresh fails. */ }
} }
const speakingNpc = result.intent === 'speak' ? gameState.world.npc : null; const speakingNpc = ['speak', 'meet'].includes(result.intent) ? gameState.world.npc : null;
appendLine('assistant', result.reply, speakingNpc appendLine('assistant', result.reply, speakingNpc
? {speaker: speakingNpc.name, voice: {characterId: speakingNpc.id, voiceIdentity: speakingNpc.voice_identity}} ? {speaker: speakingNpc.name, voice: {characterId: speakingNpc.id, voiceIdentity: speakingNpc.voice_identity}}
: {speaker: 'Berättelsen', voice: {role: 'narrator', voiceIdentity: 'neutral'}}); : {speaker: 'Berättelsen', voice: {role: 'narrator', voiceIdentity: 'neutral'}});
} catch (error) { } catch (error) {
messageField.value = message; messageField.value = message;
appendLine('assistant', `Meddelandet kunde inte behandlas: ${error.message}. Texten ligger kvar i inmatningen; skicka igen för att försöka på nytt.`); appendLine('assistant', `${explainDialogueError(error)} Ditt meddelande ligger kvar i inmatningen.`);
} }
messageField.disabled = false; messageField.disabled = false;
messageField.focus(); messageField.focus();
+2
View File
@@ -26,6 +26,8 @@ grep -q "event.key === 'Enter' && !event.shiftKey" index.html
grep -q "request('/api/character/draft'" index.html grep -q "request('/api/character/draft'" index.html
grep -q "request('/api/world/draft'" index.html grep -q "request('/api/world/draft'" index.html
grep -q "request('/api/dialogue'" index.html grep -q "request('/api/dialogue'" index.html
grep -q "result.intent === 'move' || result.intent === 'meet'" index.html
grep -q 'dialogue_temporarily_unavailable:' index.html
grep -q 'id="admin-view"' index.html grep -q 'id="admin-view"' index.html
grep -q '/api/admin/players?' index.html grep -q '/api/admin/players?' index.html
grep -q "request('/api/admin/prompts'" index.html grep -q "request('/api/admin/prompts'" index.html