mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
Changes: - Added /os-settings, a page where users can generate configuration profiles - Updated the docs navigation component to have a link to the os settings page - Added a new action: `get-llm-generated-configuration-profile` that generates a configuration profile in either .mobileconfig, DDM, or CSP formats. - Added a new website dependency: ace editor.
103 lines
2.9 KiB
JavaScript
Vendored
103 lines
2.9 KiB
JavaScript
Vendored
module.exports = {
|
|
|
|
|
|
friendlyName: 'Get llm generated configuration profile',
|
|
|
|
|
|
description: '',
|
|
|
|
|
|
inputs: {
|
|
profileType: {
|
|
type: 'string',
|
|
isIn: [
|
|
'mobileconfig',
|
|
'csp',
|
|
'ddm',
|
|
],
|
|
required: true
|
|
},
|
|
naturalLanguageInstructions: {
|
|
type: 'string',
|
|
required: true
|
|
}
|
|
},
|
|
|
|
|
|
exits: {
|
|
success: {
|
|
description: 'A configuration profile was successfully generated for a user.',
|
|
},
|
|
couldNotGenerateProfile: {
|
|
description: 'A configuration profile could not be generated for a user using the provided instructions.',
|
|
responseType: 'badRequest'
|
|
}
|
|
},
|
|
|
|
|
|
fn: async function ({profileType, naturalLanguageInstructions}) {
|
|
|
|
let promptStringByProfileType = {
|
|
'csp': 'CSP XML profile that enforces OS settings on Windows devices',
|
|
'mobileconfig': 'XML .mobileconfig profile that enforces OS settings on macOS devices',
|
|
'ddm': 'Apple DDM MDM profile in XML format that enforces OS settings on macOS devices',
|
|
};
|
|
|
|
let configurationProfilePrompt = `Given this question from an IT admin, generate a ${promptStringByProfileType[profileType]}.
|
|
|
|
Here are the instructions:
|
|
\`\`\`
|
|
${naturalLanguageInstructions}
|
|
\`\`\`
|
|
|
|
|
|
Please give me all of the above in JSON, with this data shape:
|
|
|
|
{
|
|
"configurationProfile": "TODO"
|
|
"profileFilename": "TODO"
|
|
"settingsEnforced": [// For each setting enforced by the configuration profile.
|
|
{
|
|
// The name (key) of the settings that is enforced. e.g., LoginwindowText
|
|
name: "TODO",
|
|
// The value of the setting that is enforced
|
|
value: "TODO",
|
|
},
|
|
{...}
|
|
]
|
|
}
|
|
|
|
If a configuration profile cannot be generated from the provided instructions do not return the datashape above and instead return this JSON in this exact data shape:
|
|
|
|
{
|
|
"couldNotGenerateProfile": true
|
|
}
|
|
`;
|
|
|
|
// console.log(configurationProfilePrompt);
|
|
let configurationProfileGenerationResult = await sails.helpers.ai.prompt.with({
|
|
prompt: configurationProfilePrompt,
|
|
baseModel: 'o3-mini-2025-01-31',
|
|
// expectJson: true
|
|
}).intercept((err)=>{
|
|
return new Error(`When trying generate a configuration profile for a user, an error occurred. Full error: ${require('util').inspect(err, {depth: 2})}`);
|
|
});
|
|
let jsonResult = JSON.parse(configurationProfileGenerationResult);
|
|
// console.log(configurationProfileGenerationResult);
|
|
// All done.
|
|
if(jsonResult.couldNotGenerateProfile) {
|
|
throw 'couldNotGenerateProfile';
|
|
}
|
|
if(!jsonResult.configurationProfile || !jsonResult.profileFilename || !jsonResult.settingsEnforced){
|
|
throw 'couldNotGenerateProfile';
|
|
}
|
|
return {
|
|
profile: jsonResult.configurationProfile,
|
|
profileFilename: jsonResult.profileFilename,
|
|
items: jsonResult.settingsEnforced
|
|
};
|
|
|
|
}
|
|
|
|
|
|
};
|