openmaic-custom/lib/constants/agent-defaults.ts
Yizuki_Ame 95b5c2bf55
fix: persist agent configs in server-generated classrooms (#336)
* fix: persist agent configs in server-generated classrooms (#316)

Server-generated classrooms via /api/generate-classroom silently skip all discussion actions because agent configurations are never embedded in the persisted Stage object.

Changes:

- Add optional generatedAgentConfigs field to Stage interface

- Inject agent configs (with avatar/color/priority) into Stage during server-side generation

- Hydrate agents into IndexedDB/registry when loading from server storage on client

Closes #316

* fix: extract shared agent constants and fix avatar paths

- Extract AGENT_COLOR_PALETTE and AGENT_DEFAULT_AVATARS into
  lib/constants/agent-defaults.ts to eliminate duplication
- Fix invalid avatar paths (student.png -> assist.png, etc.)
  to match actual files in public/avatars/
- Remove duplicated inline constants from classroom-generation.ts
  and agent-profiles/route.ts

Addresses reviewer feedback on #336

---------
2026-04-02 16:23:16 +08:00

41 lines
928 B
TypeScript

/**
* Shared constants for agent profile generation.
*
* Used by both the client-side agent-profiles API route and the
* server-side classroom-generation pipeline to keep colors / avatars in sync.
*/
/** Color palette cycled for generated agents */
export const AGENT_COLOR_PALETTE = [
'#3b82f6',
'#10b981',
'#f59e0b',
'#ec4899',
'#06b6d4',
'#8b5cf6',
'#f97316',
'#14b8a6',
'#e11d48',
'#6366f1',
'#84cc16',
'#a855f7',
] as const;
/**
* Default avatar paths cycled for generated agents.
*
* Every entry MUST correspond to a file that exists under `public/avatars/`.
*/
export const AGENT_DEFAULT_AVATARS = [
'/avatars/teacher.png',
'/avatars/assist.png',
'/avatars/curious.png',
'/avatars/thinker.png',
'/avatars/note-taker.png',
'/avatars/teacher-2.png',
'/avatars/assist-2.png',
'/avatars/curious-2.png',
'/avatars/thinker-2.png',
'/avatars/note-taker-2.png',
] as const;