mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
add community goal
This commit is contained in:
@@ -43,6 +43,7 @@ Rover context hints:
|
|||||||
- CHAT `rover_now` and SNAPSHOT FINAL include qualitative tags:
|
- CHAT `rover_now` and SNAPSHOT FINAL include qualitative tags:
|
||||||
- status, battery_low, docked, charging, wheels_off_ground, contact, hazard, mobility, activity_band, activity_trend
|
- status, battery_low, docked, charging, wheels_off_ground, contact, hazard, mobility, activity_band, activity_trend
|
||||||
- `activity_score` may be present for internal significance checks only.
|
- `activity_score` may be present for internal significance checks only.
|
||||||
|
- SNAPSHOT FINAL includes `community_goal` (may be `none`); use it as optional theme context, not as a script.
|
||||||
|
|
||||||
EVENT guidance:
|
EVENT guidance:
|
||||||
- EVENT messages are high-signal anchors (dock/undock, battery_low changes, wheels_off_ground changes).
|
- EVENT messages are high-signal anchors (dock/undock, battery_low changes, wheels_off_ground changes).
|
||||||
@@ -108,4 +109,4 @@ Style:
|
|||||||
Behavior framing:
|
Behavior framing:
|
||||||
- Treat rover activity as ongoing test-chamber behavior, but keep it light.
|
- Treat rover activity as ongoing test-chamber behavior, but keep it light.
|
||||||
- Be collaborative with chat, not a scolding safety announcer.
|
- Be collaborative with chat, not a scolding safety announcer.
|
||||||
- Only use hazard-like language when there is an immediate clear issue.
|
- Only use hazard-like language when there is an immediate clear issue.
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const roverManager = require('./roverManager');
|
|||||||
const { getActiveDrivers } = require('./turnService');
|
const { getActiveDrivers } = require('./turnService');
|
||||||
const { getNickname } = require('./nicknameService');
|
const { getNickname } = require('./nicknameService');
|
||||||
const { getRecentMessages, sendSystemMessage } = require('./chatService');
|
const { getRecentMessages, sendSystemMessage } = require('./chatService');
|
||||||
|
const { getCommunityGoal } = require('./communityGoalService');
|
||||||
|
|
||||||
const PROMPT_PATH = path.join(__dirname, '..', '..', 'prompts', 'commentary_system.txt');
|
const PROMPT_PATH = path.join(__dirname, '..', '..', 'prompts', 'commentary_system.txt');
|
||||||
const DEFAULT_FREQUENCY_MS = 0;
|
const DEFAULT_FREQUENCY_MS = 0;
|
||||||
@@ -26,6 +27,7 @@ const MAX_CONTEXT_EVENTS = 10;
|
|||||||
const MAX_RUN_HISTORY = 30;
|
const MAX_RUN_HISTORY = 30;
|
||||||
const MAX_ROVER_EVENTS = 400;
|
const MAX_ROVER_EVENTS = 400;
|
||||||
const POST_COOLDOWN_MS = 10000;
|
const POST_COOLDOWN_MS = 10000;
|
||||||
|
const MAX_GOAL_CONTEXT_CHARS = 220;
|
||||||
|
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
const commentaryConfig = config.llmCommentary || {};
|
const commentaryConfig = config.llmCommentary || {};
|
||||||
@@ -768,8 +770,13 @@ function buildSnapshot() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const goal = getCommunityGoal();
|
||||||
|
const goalTextRaw = goal?.text ? String(goal.text).trim() : '';
|
||||||
|
const goalText = goalTextRaw ? goalTextRaw.slice(0, MAX_GOAL_CONTEXT_CHARS) : null;
|
||||||
|
|
||||||
const currentSnapshot = {
|
const currentSnapshot = {
|
||||||
rovers,
|
rovers,
|
||||||
|
community_goal: goalText,
|
||||||
};
|
};
|
||||||
if (!hasRecentChat) {
|
if (!hasRecentChat) {
|
||||||
currentSnapshot.chat_recent = chatRecent;
|
currentSnapshot.chat_recent = chatRecent;
|
||||||
@@ -790,12 +797,16 @@ function buildSnapshot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function refreshFinalSnapshotForSend(snapshot) {
|
function refreshFinalSnapshotForSend(snapshot) {
|
||||||
|
const goal = getCommunityGoal();
|
||||||
|
const goalTextRaw = goal?.text ? String(goal.text).trim() : '';
|
||||||
|
const goalText = goalTextRaw ? goalTextRaw.slice(0, MAX_GOAL_CONTEXT_CHARS) : null;
|
||||||
const { rovers } = buildRoversNow(Date.now());
|
const { rovers } = buildRoversNow(Date.now());
|
||||||
return {
|
return {
|
||||||
...(snapshot || {}),
|
...(snapshot || {}),
|
||||||
current_snapshot: {
|
current_snapshot: {
|
||||||
...(snapshot?.current_snapshot || {}),
|
...(snapshot?.current_snapshot || {}),
|
||||||
rovers,
|
rovers,
|
||||||
|
community_goal: goalText,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -883,6 +894,10 @@ function formatSnapshotMessage(event) {
|
|||||||
function formatSnapshotFinalMessage(currentSnapshot = {}) {
|
function formatSnapshotFinalMessage(currentSnapshot = {}) {
|
||||||
const rovers = Array.isArray(currentSnapshot?.rovers) ? currentSnapshot.rovers : [];
|
const rovers = Array.isArray(currentSnapshot?.rovers) ? currentSnapshot.rovers : [];
|
||||||
const lines = ['SNAPSHOT FINAL'];
|
const lines = ['SNAPSHOT FINAL'];
|
||||||
|
const goalText = currentSnapshot?.community_goal
|
||||||
|
? String(currentSnapshot.community_goal).trim()
|
||||||
|
: '';
|
||||||
|
lines.push(`community_goal: ${goalText || 'none'}`);
|
||||||
rovers.forEach((rover) => {
|
rovers.forEach((rover) => {
|
||||||
lines.push(formatRoverSnapshotLine(rover));
|
lines.push(formatRoverSnapshotLine(rover));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user