120 lines
5.2 KiB
TypeScript
120 lines
5.2 KiB
TypeScript
'use server';
|
|
|
|
/**
|
|
* @fileOverview An AI agent that detects synchronization conflicts between platform-specific code and data,
|
|
* and suggests solutions to resolve them.
|
|
*
|
|
* - aiSuggestedSyncConflictResolution - A function that handles the conflict resolution process.
|
|
* - AISuggestedSyncConflictResolutionInput - The input type for the aiSuggestedSyncConflictResolution function.
|
|
* - AISuggestedSyncConflictResolutionOutput - The return type for the aiSuggestedSyncConflictResolution function.
|
|
*/
|
|
|
|
import {ai} from '@/ai/genkit';
|
|
import {z} from 'genkit';
|
|
|
|
const AISuggestedSyncConflictResolutionInputSchema = z.object({
|
|
robloxCode: z.string().describe('The Lua code for the Roblox platform.'),
|
|
webCode: z.string().describe('The JavaScript code for the web platform.'),
|
|
mobileCode: z.string().describe('The React Native code for the mobile platform.'),
|
|
sharedState: z.string().describe('The shared state data in JSON format.'),
|
|
});
|
|
export type AISuggestedSyncConflictResolutionInput = z.infer<typeof AISuggestedSyncConflictResolutionInputSchema>;
|
|
|
|
const AISuggestedSyncConflictResolutionOutputSchema = z.object({
|
|
conflictDetected: z.boolean().describe('Whether a synchronization conflict was detected.'),
|
|
suggestedSolutions: z.array(z.string()).describe('An array of suggested solutions to resolve the conflicts.'),
|
|
explanation: z.string().describe('Explanation of the detected conflicts and suggested solutions.'),
|
|
});
|
|
export type AISuggestedSyncConflictResolutionOutput = z.infer<typeof AISuggestedSyncConflictResolutionOutputSchema>;
|
|
|
|
export async function aiSuggestedSyncConflictResolution(input: AISuggestedSyncConflictResolutionInput): Promise<AISuggestedSyncConflictResolutionOutput> {
|
|
return aiSuggestedSyncConflictResolutionFlow(input);
|
|
}
|
|
|
|
const prompt = ai.definePrompt({
|
|
name: 'aiSuggestedSyncConflictResolutionPrompt',
|
|
input: {schema: AISuggestedSyncConflictResolutionInputSchema},
|
|
output: {schema: AISuggestedSyncConflictResolutionOutputSchema},
|
|
prompt: `You are an AI assistant specialized in detecting synchronization conflicts between different platform codebases and suggesting solutions.
|
|
|
|
You are given the code for Roblox (Lua), Web (JavaScript), and Mobile (React Native), as well as the shared state data in JSON format. Analyze the code and the shared state to identify any inconsistencies or conflicts.
|
|
|
|
Based on your analysis, determine if there are any conflicts, and suggest solutions to resolve them. Explain the conflicts and the suggested solutions in detail.
|
|
|
|
Roblox Code:
|
|
{{robloxCode}}
|
|
|
|
Web Code:
|
|
{{webCode}}
|
|
|
|
Mobile Code:
|
|
{{mobileCode}}
|
|
|
|
Shared State:
|
|
{{sharedState}}`,
|
|
});
|
|
|
|
const aiSuggestedSyncConflictResolutionFlow = ai.defineFlow(
|
|
{
|
|
name: 'aiSuggestedSyncConflictResolutionFlow',
|
|
inputSchema: AISuggestedSyncConflictResolutionInputSchema,
|
|
outputSchema: AISuggestedSyncConflictResolutionOutputSchema,
|
|
},
|
|
async input => {
|
|
const {output} = await prompt(input, {
|
|
config: {
|
|
safetySettings: [
|
|
{
|
|
category: 'HARM_CATEGORY_HATE_SPEECH',
|
|
threshold: 'BLOCK_ONLY_HIGH',
|
|
},
|
|
{
|
|
category: 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
|
threshold: 'BLOCK_NONE',
|
|
},
|
|
{
|
|
category: 'HARM_CATEGORY_HARASSMENT',
|
|
threshold: 'BLOCK_MEDIUM_AND_ABOVE',
|
|
},
|
|
{
|
|
category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
|
threshold: 'BLOCK_LOW_AND_ABOVE',
|
|
},
|
|
],
|
|
},
|
|
});
|
|
return output!;
|
|
}
|
|
);
|
|
'use server';
|
|
|
|
/**
|
|
* @fileOverview An AI agent that detects synchronization conflicts between platform-specific code and data,
|
|
* and suggests solutions to resolve them.
|
|
*
|
|
* - aiSuggestedSyncConflictResolution - A function that handles the conflict resolution process.
|
|
* - AISuggestedSyncConflictResolutionInput - The input type for the aiSuggestedSyncConflictResolution function.
|
|
* - AISuggestedSyncConflictResolutionOutput - The return type for the aiSuggestedSyncConflictResolution function.
|
|
*/
|
|
|
|
import {ai} from '@/ai/genkit';
|
|
import {z} from 'genkit';
|
|
|
|
const AISuggestedSyncConflictResolutionInputSchema = z.object({
|
|
robloxCode: z.string().describe('The Lua code for the Roblox platform.'),
|
|
webCode: z.string().describe('The JavaScript code for the web platform.'),
|
|
mobileCode: z.string().describe('The React Native code for the mobile platform.'),
|
|
sharedState: z.string().describe('The shared state data in JSON format.'),
|
|
});
|
|
export type AISuggestedSyncConflictResolutionInput = z.infer<typeof AISuggestedSyncConflictResolutionInputSchema>;
|
|
|
|
const AISuggestedSyncConflictResolutionOutputSchema = z.object({
|
|
conflictDetected: z.boolean().describe('Whether a synchronization conflict was detected.'),
|
|
suggestedSolutions: z.array(z.string()).describe('An array of suggested solutions to resolve the conflicts.'),
|
|
explanation: z.string().describe('Explanation of the detected conflicts and suggested solutions.'),
|
|
});
|
|
export type AISuggestedSyncConflictResolutionOutput = z.infer<typeof AISuggestedSyncConflictResolutionOutputSchema>;
|
|
|
|
export async function aiSuggestedSyncConflictResolution(input: AISuggestedSyncConflictResolutionInput): Promise<AISuggestedSyncConflictResolutionOutput> {
|
|
return aiSuggestedSyncConflictResolutionFlow(input);
|
|
}
|