MCPcopy Create free account
hub / github.com/MiniMax-AI/OpenRoom / loadEntriesFromCard

Function loadEntriesFromCard

apps/webuiapps/src/lib/cardExtractor.ts:264–291  ·  view source on GitHub ↗
(
  card: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

262// ── Card entry conversion ──────────────────────────────────────────
263
264function loadEntriesFromCard(
265 card: Record<string, unknown>,
266): { entry: InternalEntry; index: number }[] {
267 const data = (card['data'] || {}) as Record<string, unknown>;
268 const charBook = (data['character_book'] || null) as Record<string, unknown> | null;
269 if (!charBook) return [];
270
271 let rawEntries = charBook['entries'] as unknown[] | Record<string, unknown>;
272 if (rawEntries && !Array.isArray(rawEntries)) {
273 rawEntries = Object.values(rawEntries);
274 }
275 if (!rawEntries) return [];
276
277 return (rawEntries as Record<string, unknown>[]).map((entry, i) => ({
278 index: (entry['id'] as number) ?? i,
279 entry: {
280 key: (entry['keys'] as string[]) || [],
281 keysecondary: (entry['secondary_keys'] as string[]) || [],
282 comment: (entry['comment'] as string) || (entry['name'] as string) || '',
283 content: (entry['content'] as string) || '',
284 constant: (entry['constant'] as boolean) || false,
285 selective: entry['selective'] !== undefined ? (entry['selective'] as boolean) : true,
286 disable: !(entry['enabled'] !== undefined ? (entry['enabled'] as boolean) : true),
287 order: (entry['insertion_order'] as number) || 100,
288 position: ((entry['extensions'] as Record<string, unknown>)?.['position'] as number) || 0,
289 },
290 }));
291}
292
293function loadRegexScriptsFromCard(card: Record<string, unknown>): InternalScript[] {
294 const data = (card['data'] || {}) as Record<string, unknown>;

Callers 1

extractCardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected