-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Website: add configuration profile generator (#26244)
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.
- Loading branch information
Showing
16 changed files
with
30,613 additions
and
1 deletion.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
website/api/controllers/get-llm-generated-configuration-profile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
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 | ||
}; | ||
|
||
} | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
|
||
|
||
friendlyName: 'View os settings', | ||
|
||
|
||
description: 'Display "Os settings" page.', | ||
|
||
|
||
exits: { | ||
|
||
success: { | ||
viewTemplatePath: 'pages/os-settings' | ||
} | ||
|
||
}, | ||
|
||
|
||
fn: async function () { | ||
|
||
// Respond with view. | ||
return {}; | ||
|
||
} | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.