MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / executeScriptApply

Function executeScriptApply

app/src/AI/ToolDispatcher.cpp:1322–1358  ·  view source on GitHub ↗

* @brief Validates a script with dryRun, then routes the apply to the right project mutation. */

Source from the content-addressed store, hash-verified

1320 * @brief Validates a script with dryRun, then routes the apply to the right project mutation.
1321 */
1322static QJsonObject executeScriptApply(const QJsonObject& args)
1323{
1324 const auto kind = args.value(QStringLiteral("kind")).toString();
1325 const int language =
1326 args.contains(QStringLiteral("language")) ? args.value(QStringLiteral("language")).toInt() : 1;
1327
1328 QJsonObject dryRun = executeScriptDryRun(args);
1329 if (!dryRunResultOk(dryRun)) {
1330 QJsonObject out;
1331 out[QStringLiteral("ok")] = false;
1332 out[QStringLiteral("error")] = QStringLiteral("dry_run_failed");
1333 out[QStringLiteral("dryRun")] = dryRun;
1334 out[QStringLiteral("repair")] =
1335 QStringLiteral("Fix the script using the returned dry-run error before applying.");
1336 return out;
1337 }
1338
1339 if (kind == QStringLiteral("frame_parser"))
1340 return applyFrameParserScript(args, dryRun, language);
1341
1342 if (kind == QStringLiteral("transform"))
1343 return applyTransformScript(args, dryRun, language);
1344
1345 if (kind == QStringLiteral("painter"))
1346 return applyPainterScript(args, dryRun);
1347
1348 QJsonObject out;
1349 out[QStringLiteral("ok")] = false;
1350 out[QStringLiteral("error")] = QStringLiteral("unsupported_apply_kind");
1351 out[QStringLiteral("hint")] =
1352 kind == QStringLiteral("output_widget")
1353 ? QStringLiteral("output_widget is dry-run only here: validate with "
1354 "assistant.script.dryRun{kind:'output_widget'}, then apply via "
1355 "project.outputWidget.update{groupId, widgetId, transmitFunction}.")
1356 : QStringLiteral("assistant.script.apply supports frame_parser, transform, and painter.");
1357 return out;
1358}
1359
1360/**
1361 * @brief Projects a per-op result blob onto just the identity/status fields the model needs.

Callers 1

executeAssistantToolFunction · 0.85

Calls 7

executeScriptDryRunFunction · 0.85
dryRunResultOkFunction · 0.85
applyFrameParserScriptFunction · 0.85
applyTransformScriptFunction · 0.85
applyPainterScriptFunction · 0.85
valueMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected