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

Function parseStandardActions

apps/webuiapps/src/lib/appRegistry.ts:268–324  ·  view source on GitHub ↗
(lines: string[], actions: AppActionDef[])

Source from the content-addressed store, hash-verified

266}
267
268function parseStandardActions(lines: string[], actions: AppActionDef[]): void {
269 let i = 0;
270 while (i < lines.length) {
271 const line = lines[i];
272 // Stop parsing the actions block when encountering a non-indented non-empty line (top-level key)
273 if (line.match(/^\S/) && line.trim() !== '') break;
274
275 const typeMatch = line.match(/^\s+-\s+type:\s+(\S+)/);
276 if (typeMatch) {
277 const action: AppActionDef = { name: typeMatch[1], description: '', params: [] };
278 i++;
279 // Parse this action's properties
280 while (i < lines.length) {
281 const l = lines[i];
282 if (l.match(/^\s+-\s+type:\s/) || (l.match(/^\S/) && l.trim() !== '')) break;
283
284 const descMatch = l.match(/^\s+description:\s*>?\s*$/);
285 if (descMatch) {
286 // Multi-line description
287 i++;
288 const descLines: string[] = [];
289 while (i < lines.length && lines[i].match(/^\s{6,}/) && !lines[i].match(/^\s+\w+:/)) {
290 descLines.push(lines[i].trim());
291 i++;
292 }
293 action.description = descLines.join(' ');
294 continue;
295 }
296 const descInlineMatch = l.match(/^\s+description:\s+(.+)$/);
297 if (descInlineMatch) {
298 action.description = descInlineMatch[1].trim();
299 i++;
300 continue;
301 }
302
303 const paramsMatch = l.match(/^\s+params:\s*$/);
304 if (paramsMatch) {
305 i++;
306 parseParamsList(lines, i, action.params, (newI) => {
307 i = newI;
308 });
309 continue;
310 }
311 // params: [] (empty)
312 if (l.match(/^\s+params:\s*\[\]\s*$/)) {
313 i++;
314 continue;
315 }
316
317 i++;
318 }
319 actions.push(action);
320 } else {
321 i++;
322 }
323 }
324}
325

Callers 1

parseMetaYamlActionsFunction · 0.85

Calls 1

parseParamsListFunction · 0.85

Tested by

no test coverage detected