feat: merge language navigation into persona controller
This commit is contained in:
parent
7d85d79e61
commit
5452dec915
4 changed files with 158 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
|||
import http from "node:http";
|
||||
import { ControllerEngine, bootEvent } from "./controller-engine.mjs";
|
||||
import { DeepSeekJsonClient } from "./model-client.mjs";
|
||||
import { MachineNavigation } from "./machine-navigation.mjs";
|
||||
|
||||
const HOST = "127.0.0.1";
|
||||
const PORT = Number(process.env.BS_TCS_CONTROLLER_PORT || 3930);
|
||||
|
|
@ -25,6 +26,7 @@ const engine = new ControllerEngine({
|
|||
modelClient: new DeepSeekJsonClient({ model: MODEL }),
|
||||
modelName: MODEL,
|
||||
});
|
||||
const navigation = new MachineNavigation();
|
||||
|
||||
function send(response, status, body) {
|
||||
const payload = JSON.stringify(body);
|
||||
|
|
@ -55,6 +57,7 @@ function health() {
|
|||
persona_brain_runtime_exists: existence.persona_brain_runtime_exists || 0,
|
||||
living_ai_system_controller_running:
|
||||
existence.living_ai_system_controller_running || 0,
|
||||
...navigation.health(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -124,6 +127,33 @@ const server = http.createServer(async (request, response) => {
|
|||
receipt_id: runtime.receipt?.receipt_id || null,
|
||||
});
|
||||
}
|
||||
if (request.method === "GET" && url.pathname === "/v1/navigation") {
|
||||
return send(response, 200, {
|
||||
ok: true,
|
||||
...navigation.health(),
|
||||
language_world_entry:
|
||||
navigation.boundary.machine_gate.required_event_envelope,
|
||||
});
|
||||
}
|
||||
if (request.method === "GET" && url.pathname === "/v1/resolve") {
|
||||
const resolved = navigation.resolve(url.searchParams.get("id") || "");
|
||||
return send(
|
||||
response,
|
||||
resolved ? 200 : 404,
|
||||
resolved || { status: "UNRESOLVED", error: "unknown_route" },
|
||||
);
|
||||
}
|
||||
if (request.method === "GET" && url.pathname === "/v1/navigate") {
|
||||
const route = navigation.navigate(
|
||||
url.searchParams.get("subject") || "",
|
||||
url.searchParams.get("intent") || "",
|
||||
);
|
||||
return send(
|
||||
response,
|
||||
route ? 200 : 404,
|
||||
route || { status: "UNRESOLVED", error: "unknown_subject_or_intent" },
|
||||
);
|
||||
}
|
||||
if (request.method === "POST" && url.pathname === "/v1/events") {
|
||||
const input = await readBody(request);
|
||||
const job = eventQueue.then(() => handleEvent(input));
|
||||
|
|
|
|||
Loading…
Reference in a new issue