sky-meilin commited on
Commit
e052d2d
·
verified ·
1 Parent(s): 97ee6cb

Update core/system_bus.js

Browse files
Files changed (1) hide show
  1. core/system_bus.js +17 -39
core/system_bus.js CHANGED
@@ -1,49 +1,27 @@
1
- // core/system_bus.js
 
 
2
 
3
- export function emit(eventType, payload) {
4
- return route(eventType, payload);
5
- }
6
 
7
- function route(eventType, payload) {
8
 
9
- switch(eventType) {
10
 
11
- case "USER_INPUT":
12
- return handleUserInput(payload);
13
 
14
- case "CLASSIFIED_INTENT":
15
- return handleIntent(payload);
 
 
 
16
 
17
- case "DECISION":
18
- return handleDecision(payload);
19
-
20
- default:
21
- return {
22
- status: "unknown_event",
23
- payload
24
- };
25
  }
26
- }
27
-
28
- // PLACEHOLDERS (werden später verbunden)
29
- function handleUserInput(data) {
30
- return { next: "AI_CLASSIFICATION", data };
31
- }
32
-
33
- function handleIntent(data) {
34
- return { next: "CORE_DECISION", data };
35
- }
36
 
37
- function handleDecision(data) {
38
- return { next: "MEMORY_WRITE", data };
39
- }
40
- function normalize(eventType) {
41
-
42
- const map = {
43
- "FLOW": "system_flow",
44
- "flow": "system_flow",
45
- "Flow": "system_flow"
46
  };
47
-
48
- return map[eventType] || "unknown";
49
  }
 
1
+ import { classify } from "../ai/classifier.js";
2
+ import { decide } from "./decision_engine.js";
3
+ import { saveEvent } from "./memory.js";
4
 
5
+ export async function emit(eventType, payload) {
 
 
6
 
7
+ if (eventType === "USER_INPUT") {
8
 
9
+ const classification = classify(payload.text);
10
 
11
+ const decision = decide(classification);
 
12
 
13
+ saveEvent({
14
+ input: payload.text,
15
+ classification,
16
+ decision
17
+ });
18
 
19
+ return {
20
+ message: decision.message
21
+ };
 
 
 
 
 
22
  }
 
 
 
 
 
 
 
 
 
 
23
 
24
+ return {
25
+ message: "Unknown event"
 
 
 
 
 
 
 
26
  };
 
 
27
  }