From 10cae457f9badf5afcaaa818a25bcde616ba2c04 Mon Sep 17 00:00:00 2001 From: Remi <73385395+itsrubberduck@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:16:33 +0200 Subject: [PATCH 1/7] Enable flow-aware decision routing --- app/pages/editor/index.vue | 608 +++++++++++++++--- app/pages/pm.vue | 74 ++- server/api/atc/ptt.post.ts | 5 +- server/api/decision-flows/runtime.get.ts | 6 + server/api/editor/flows/[slug]/nodes.post.ts | 50 +- .../flows/[slug]/nodes/[stateId]/index.put.ts | 51 +- server/middleware/auth.global.ts | 3 + server/models/DecisionNode.ts | 35 + server/services/decisionFlowService.ts | 68 +- server/services/decisionImportService.ts | 182 +----- server/utils/decisionSanitizer.ts | 182 ++++-- server/utils/openai.ts | 336 ++++++++++ shared/data/atcDecisionTree.ts | 585 ----------------- shared/types/decision.ts | 40 ++ shared/types/llm.ts | 5 +- shared/utils/communicationsEngine.ts | 390 ++++++++--- 16 files changed, 1622 insertions(+), 998 deletions(-) create mode 100644 server/api/decision-flows/runtime.get.ts delete mode 100644 shared/data/atcDecisionTree.ts diff --git a/app/pages/editor/index.vue b/app/pages/editor/index.vue index 7070c81..651f823 100644 --- a/app/pages/editor/index.vue +++ b/app/pages/editor/index.vue @@ -325,7 +325,7 @@
Dieser Flow enthält noch keine Nodes.
++ Keine Trigger definiert. +
++ Dieser Trigger wird genutzt, wenn kein anderer vorher greift. +
++ Keine Bedingungen definiert. +
+OpenSquawk
Alpha Build • Decision Tree • VATSIM
{{ entry.message }}
Loading radio logs…
-{{ entry.text }}
-- Normalized: {{ entry.normalized }} -
-LLM Decision Summary
-Next State
-{{ entry.metadata.decision.next_state || '—' }}
-Controller
-{{ entry.metadata.decision.controller_say_tpl || '—' }}
-LLM usage
-{{ usage.method }}
-{{ usage.reason }}
-State context snapshot
-- {{ entry.metadata.context.stateId || 'Unknown state' }} -
-- {{ entry.metadata.context.state?.name }} -
-State Say Template
-{{ entry.metadata.context.state?.say_tpl }}
-Next transitions
-—
-OK transitions
-—
-Bad transitions
-—
-Candidates
-- {{ candidate.state?.name }} -
-- {{ candidate.state?.say_tpl }} -
-Variables snapshot
-{{ formatJson(entry.metadata.context.variables) }}
- Flags snapshot
-{{ formatJson(entry.metadata.context.flags) }}
- OpenAI Decision Calls
-Request
-{{ formatJson(call.request) }}
- Response
-{{ formatJson(call.response) }}
- Raw Response
-{{ call.rawResponseText }}
- Fallback activated
-- Reason: {{ entry.metadata.decisionTrace.fallback.reason || 'unknown' }} - - · Path: {{ entry.metadata.decisionTrace.fallback.selected }} - -
-OpenAI Decision Calls
-No OpenAI call was recorded for this transmission.
-{{ usage.reason }}
-Say endpoint invocation
-Voice
-{{ entry.metadata?.voice || '—' }}
-Signal level
-{{ entry.metadata?.level ?? '—' }}
-Speech speed
-{{ entry.metadata?.speed ?? '—' }}
-Radio quality
-{{ entry.metadata?.radioQuality || '—' }}
-TTS provider
-{{ entry.metadata?.tts?.provider || '—' }}
-Model
-{{ entry.metadata?.tts?.model || '—' }}
-Format
-- {{ entry.metadata?.tts?.format || '—' }} - - ({{ entry.metadata?.tts?.extension }}) - -
-Tag
-{{ entry.metadata?.tag }}
-Metadata
-{{ formatJson(entry.metadata) }}
- No transmissions found.
- -{{ sessionPagination.total }} conversations
Session {{ session.sessionId }}
++ {{ session.lastMessage.role.toUpperCase() }} · {{ session.lastMessage.text }} +
++ No sessions recorded yet. +
+Session
+{{ sessionDetails.sessionId }}
+Callsign: {{ sessionDetails.callsign || 'Unknown' }}
+{{ entry.text }}
+{{ entry.normalized }}
+Decision trace
+{{ step.label }}
+{{ step.stage }}
+{{ step.note }}
+{{ candidate.summary }}
+Eliminated
+{{ elim.reason }}
+{{ describeElimination(elim) }}
+No candidate timeline recorded.
++ No messages recorded for this session. +
+Select a session to view its transcript.
Alpha Build • Decision Tree • VATSIM
+ {{ activeFlowInfo.description }} +
Current node
{{ debugState?.id || '—' }}
@@ -668,6 +676,57 @@No further decisions available.
Decision timeline
+{{ step.label }}
+{{ step.stage }}
+{{ step.note }}
+{{ candidate.summary }}
+Eliminated
+{{ elim.reason }}
+{{ describeElimination(elim) }}
+No decision timeline available yet.
+{{ flowDetail.flow.slug }}
+{{ currentFlowModeDescription }}
+