@juspay/neurolink 9.0.1 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/core/baseProvider.d.ts +24 -0
  3. package/dist/core/baseProvider.js +128 -7
  4. package/dist/features/ppt/constants.d.ts +32 -3
  5. package/dist/features/ppt/constants.js +454 -221
  6. package/dist/features/ppt/contentPlanner.js +193 -10
  7. package/dist/features/ppt/index.d.ts +12 -3
  8. package/dist/features/ppt/index.js +15 -2
  9. package/dist/features/ppt/presentationOrchestrator.d.ts +37 -0
  10. package/dist/features/ppt/presentationOrchestrator.js +209 -0
  11. package/dist/features/ppt/slideGenerator.d.ts +10 -49
  12. package/dist/features/ppt/slideGenerator.js +156 -17
  13. package/dist/features/ppt/slideRenderers.d.ts +169 -4
  14. package/dist/features/ppt/slideRenderers.js +1577 -188
  15. package/dist/features/ppt/slideTypeInference.d.ts +91 -0
  16. package/dist/features/ppt/slideTypeInference.js +403 -0
  17. package/dist/features/ppt/types.d.ts +3 -1
  18. package/dist/features/ppt/types.js +5 -3
  19. package/dist/features/ppt/utils.d.ts +103 -0
  20. package/dist/features/ppt/utils.js +444 -0
  21. package/dist/lib/core/baseProvider.d.ts +24 -0
  22. package/dist/lib/core/baseProvider.js +128 -7
  23. package/dist/lib/features/ppt/constants.d.ts +32 -3
  24. package/dist/lib/features/ppt/constants.js +454 -221
  25. package/dist/lib/features/ppt/contentPlanner.js +193 -10
  26. package/dist/lib/features/ppt/index.d.ts +12 -3
  27. package/dist/lib/features/ppt/index.js +15 -2
  28. package/dist/lib/features/ppt/presentationOrchestrator.d.ts +37 -0
  29. package/dist/lib/features/ppt/presentationOrchestrator.js +210 -0
  30. package/dist/lib/features/ppt/slideGenerator.d.ts +10 -49
  31. package/dist/lib/features/ppt/slideGenerator.js +156 -17
  32. package/dist/lib/features/ppt/slideRenderers.d.ts +169 -4
  33. package/dist/lib/features/ppt/slideRenderers.js +1577 -188
  34. package/dist/lib/features/ppt/slideTypeInference.d.ts +91 -0
  35. package/dist/lib/features/ppt/slideTypeInference.js +404 -0
  36. package/dist/lib/features/ppt/types.d.ts +3 -1
  37. package/dist/lib/features/ppt/types.js +5 -3
  38. package/dist/lib/features/ppt/utils.d.ts +103 -0
  39. package/dist/lib/features/ppt/utils.js +445 -0
  40. package/dist/lib/neurolink.js +3 -0
  41. package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
  42. package/dist/lib/types/pptTypes.d.ts +380 -363
  43. package/dist/lib/types/pptTypes.js +0 -76
  44. package/dist/lib/utils/parameterValidation.d.ts +14 -0
  45. package/dist/lib/utils/parameterValidation.js +47 -29
  46. package/dist/neurolink.js +3 -0
  47. package/dist/server/utils/validation.d.ts +2 -2
  48. package/dist/types/pptTypes.d.ts +380 -363
  49. package/dist/types/pptTypes.js +0 -76
  50. package/dist/utils/parameterValidation.d.ts +14 -0
  51. package/dist/utils/parameterValidation.js +47 -29
  52. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [9.1.0](https://github.com/juspay/neurolink/compare/v9.0.1...v9.1.0) (2026-02-05)
2
+
3
+ ### Features
4
+
5
+ - **(ppt):** Implement Orchestration and Assembly layer For PPT Gen ([7e53846](https://github.com/juspay/neurolink/commit/7e53846815a14e6b4793e31048efe121bbc84ef5))
6
+
1
7
  ## [9.0.1](https://github.com/juspay/neurolink/compare/v9.0.0...v9.0.1) (2026-02-03)
2
8
 
3
9
  ### Bug Fixes
@@ -256,6 +256,30 @@ export declare abstract class BaseProvider implements AIProvider {
256
256
  * ```
257
257
  */
258
258
  private handleVideoGeneration;
259
+ /**
260
+ * Handle PPT generation mode
261
+ *
262
+ * Generates a complete PowerPoint presentation using AI content planning
263
+ * and slide generation. This method orchestrates:
264
+ * 1. Input validation
265
+ * 2. Content planning via AI
266
+ * 3. Individual slide generation (with optional images)
267
+ * 4. PPTX assembly and file output
268
+ *
269
+ * @param options - Text generation options with PPT config
270
+ * @param startTime - Generation start timestamp for metrics
271
+ * @returns Enhanced result with PPT data
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * const result = await provider.generate({
276
+ * input: { text: "Introducing Our New Product" },
277
+ * output: { mode: "ppt", ppt: { pages: 10, theme: "modern" } }
278
+ * });
279
+ * // result.ppt contains the generated presentation info
280
+ * ```
281
+ */
282
+ private handlePPTGeneration;
259
283
  /**
260
284
  * Create analytics - delegated to TelemetryHandler
261
285
  */
@@ -346,9 +346,15 @@ export class BaseProvider {
346
346
  try {
347
347
  // ===== VIDEO GENERATION MODE =====
348
348
  // Generate video from image + prompt using Veo 3.1
349
- if (options.output?.mode === "video") {
349
+ if (options.output?.mode === "video" || options.output?.video) {
350
350
  return await this.handleVideoGeneration(options, startTime);
351
351
  }
352
+ // ===== PPT GENERATION MODE =====
353
+ // Generate PowerPoint presentation from topic using AI content planning
354
+ // Triggered by mode="ppt" OR presence of ppt config block
355
+ if (options.output?.mode === "ppt" || options.output?.ppt) {
356
+ return await this.handlePPTGeneration(options, startTime);
357
+ }
352
358
  // ===== IMAGE GENERATION MODE =====
353
359
  // Route to executeImageGeneration for image generation models
354
360
  const isImageModel = IMAGE_GENERATION_MODELS.some((m) => this.modelName.includes(m));
@@ -682,14 +688,21 @@ export class BaseProvider {
682
688
  }
683
689
  async enhanceResult(result, options, startTime) {
684
690
  const responseTime = Date.now() - startTime;
685
- // CRITICAL FIX: Store imageOutput separately to ensure it's preserved
686
691
  const imageOutput = result.imageOutput;
692
+ const ppt = result.ppt;
693
+ const video = result.video;
687
694
  let enhancedResult = { ...result };
688
695
  if (options.enableAnalytics) {
689
696
  try {
690
697
  const analytics = await this.createAnalytics(result, responseTime, options);
691
- // Preserve ALL fields including imageOutput when adding analytics
692
- enhancedResult = { ...enhancedResult, analytics, imageOutput };
698
+ // Preserve ALL fields when adding analytics
699
+ enhancedResult = {
700
+ ...enhancedResult,
701
+ analytics,
702
+ imageOutput,
703
+ ppt,
704
+ video,
705
+ };
693
706
  }
694
707
  catch (error) {
695
708
  logger.warn(`Analytics creation failed for ${this.providerName}:`, error);
@@ -698,17 +711,28 @@ export class BaseProvider {
698
711
  if (options.enableEvaluation) {
699
712
  try {
700
713
  const evaluation = await this.createEvaluation(result, options);
701
- // Preserve ALL fields including imageOutput when adding evaluation
702
- enhancedResult = { ...enhancedResult, evaluation, imageOutput };
714
+ // Preserve ALL fields when adding evaluation
715
+ enhancedResult = {
716
+ ...enhancedResult,
717
+ evaluation,
718
+ imageOutput,
719
+ ppt,
720
+ video,
721
+ };
703
722
  }
704
723
  catch (error) {
705
724
  logger.warn(`Evaluation creation failed for ${this.providerName}:`, error);
706
725
  }
707
726
  }
708
- // CRITICAL FIX: Always restore imageOutput if it existed in the original result
709
727
  if (imageOutput) {
710
728
  enhancedResult.imageOutput = imageOutput;
711
729
  }
730
+ if (ppt) {
731
+ enhancedResult.ppt = ppt;
732
+ }
733
+ if (video) {
734
+ enhancedResult.video = video;
735
+ }
712
736
  return enhancedResult;
713
737
  }
714
738
  /**
@@ -880,6 +904,103 @@ export class BaseProvider {
880
904
  };
881
905
  return await this.enhanceResult(baseResult, options, startTime);
882
906
  }
907
+ /**
908
+ * Handle PPT generation mode
909
+ *
910
+ * Generates a complete PowerPoint presentation using AI content planning
911
+ * and slide generation. This method orchestrates:
912
+ * 1. Input validation
913
+ * 2. Content planning via AI
914
+ * 3. Individual slide generation (with optional images)
915
+ * 4. PPTX assembly and file output
916
+ *
917
+ * @param options - Text generation options with PPT config
918
+ * @param startTime - Generation start timestamp for metrics
919
+ * @returns Enhanced result with PPT data
920
+ *
921
+ * @example
922
+ * ```typescript
923
+ * const result = await provider.generate({
924
+ * input: { text: "Introducing Our New Product" },
925
+ * output: { mode: "ppt", ppt: { pages: 10, theme: "modern" } }
926
+ * });
927
+ * // result.ppt contains the generated presentation info
928
+ * ```
929
+ */
930
+ async handlePPTGeneration(options, startTime) {
931
+ // Dynamic imports to avoid loading PPT dependencies unless needed
932
+ const { generatePresentation } = await import("../features/ppt/presentationOrchestrator.js");
933
+ const { PPT_GENERATION_TIMEOUT_MS } = await import("../features/ppt/constants.js");
934
+ const { validatePPTGenerationInput } = await import("../utils/parameterValidation.js");
935
+ const { ErrorFactory, withTimeout } = await import("../utils/errorHandling.js");
936
+ const { extractPPTContext, getEffectivePPTProvider } = await import("../features/ppt/utils.js");
937
+ // Get effective PPT provider (handles validation and auto-selection)
938
+ const effective = await getEffectivePPTProvider(this, this.providerName, this.modelName, this.neurolink);
939
+ // Build input from prompt or input.text (preserve images for logo)
940
+ const inputText = options.input?.text || options.prompt || "";
941
+ const generateOptions = {
942
+ input: {
943
+ text: inputText,
944
+ images: options.input?.images, // Pass through images for logo
945
+ },
946
+ output: options.output,
947
+ provider: effective.providerName,
948
+ model: options.model,
949
+ };
950
+ // Validate PPT generation input
951
+ const validation = validatePPTGenerationInput(generateOptions);
952
+ if (!validation.isValid) {
953
+ const errorMessages = validation.errors.map((e) => e.message).join("; ");
954
+ throw ErrorFactory.invalidParameters("ppt-generation", new Error(errorMessages), { errors: validation.errors });
955
+ }
956
+ // Log warnings
957
+ for (const warning of validation.warnings) {
958
+ logger.warn(`PPT generation warning: ${warning}`);
959
+ }
960
+ // Extract context with all PPT options (including images for logo)
961
+ const context = extractPPTContext({
962
+ input: {
963
+ text: inputText,
964
+ images: options.input?.images, // Pass through images for logo
965
+ },
966
+ output: generateOptions.output,
967
+ provider: effective.providerName,
968
+ model: effective.modelName,
969
+ });
970
+ logger.info("Starting PPT generation", {
971
+ provider: effective.providerName,
972
+ model: effective.modelName,
973
+ topic: context.topic.substring(0, 100),
974
+ pages: context.pages,
975
+ theme: context.theme,
976
+ generateAIImages: context.generateAIImages,
977
+ });
978
+ // Generate presentation using orchestrator (with timeout)
979
+ const pptResult = await withTimeout(generatePresentation({
980
+ context,
981
+ provider: effective.provider,
982
+ providerName: effective.providerName,
983
+ modelName: effective.modelName,
984
+ neurolink: this.neurolink,
985
+ imageProvider: effective.providerName,
986
+ imageModel: effective.modelName,
987
+ }), PPT_GENERATION_TIMEOUT_MS, ErrorFactory.toolTimeout("pptGeneration", PPT_GENERATION_TIMEOUT_MS));
988
+ logger.info("PPT generation complete", {
989
+ filePath: pptResult.filePath,
990
+ totalSlides: pptResult.totalSlides,
991
+ processingTime: Date.now() - startTime,
992
+ });
993
+ // Ensure we always have model name - fallback to this provider's modelName or default
994
+ const finalModelName = effective.modelName || this.modelName || this.getDefaultModel();
995
+ // Build result
996
+ return await this.enhanceResult({
997
+ content: context.topic,
998
+ provider: effective.providerName,
999
+ model: finalModelName,
1000
+ usage: { input: 0, output: 0, total: 0 },
1001
+ ppt: pptResult,
1002
+ }, options, startTime);
1003
+ }
883
1004
  /**
884
1005
  * Create analytics - delegated to TelemetryHandler
885
1006
  */
@@ -4,7 +4,7 @@
4
4
  * Contains theme definitions, layout configs, and AI prompt templates
5
5
  * for presentation generation.
6
6
  */
7
- import type { PresentationTheme, SlideType, SlideLayout } from "./types.js";
7
+ import type { PromptTier, PPTModelInfo, BuildContentPlanningPromptOptions, BulletStyle, SlideFormattingConfig, PresentationTheme, SlideType, SlideLayout } from "./types.js";
8
8
  /**
9
9
  * Built-in theme registry
10
10
  * Each theme defines colors, fonts, and styling for the presentation
@@ -54,6 +54,10 @@ export declare function isDiagramSlideType(type: SlideType): boolean;
54
54
  * Check if a slide type benefits from AI image generation
55
55
  */
56
56
  export declare function isImageSlideType(type: SlideType): boolean;
57
+ /**
58
+ * Theme-specific design guidelines for the AI
59
+ */
60
+ export declare const THEME_GUIDELINES: Record<string, string>;
57
61
  /**
58
62
  * Audience-specific content guidelines for the AI
59
63
  */
@@ -62,14 +66,19 @@ export declare const AUDIENCE_GUIDELINES: Record<string, string>;
62
66
  * Tone-specific writing guidelines for the AI
63
67
  */
64
68
  export declare const TONE_GUIDELINES: Record<string, string>;
69
+ /**
70
+ * Detect prompt tier based on model name
71
+ */
72
+ export declare function getPromptTier(modelInfo: PPTModelInfo): PromptTier;
65
73
  /**
66
74
  * System prompt for content planning AI
67
75
  */
68
- export declare const CONTENT_PLANNING_SYSTEM_PROMPT = "You are an expert presentation designer and content strategist. Your task is to create a detailed, structured content plan for a presentation based on the given topic and requirements.\n\nYou must output ONLY valid JSON with no additional text, markdown formatting, or explanation.\n\nCRITICAL RULES:\n1. Each slide MUST have a clear, specific title (not generic like \"Slide 2\")\n2. Content bullets should be concise (max 10 words each)\n3. Maximum 5-6 bullets per slide for readability\n4. Image prompts should describe VISUAL scenes without any text in the image\n5. Speaker notes should provide detailed talking points for the presenter\n6. First slide is always type \"title\", last slide is always type \"thank-you\" or \"closing\"\n7. Include an \"agenda\" slide as slide 2 for presentations with 8+ slides\n8. Create visual variety: mix content, data, quote, and image slides\n9. For data slides, provide realistic sample data that matches the topic\n10. Use statistics slides for key metrics, chart slides for trends/comparisons\n11. Include at least one quote or highlight slide for impact\n12. Use section-header slides to break up long presentations (15+ slides)";
76
+ export declare const CONTENT_PLANNING_SYSTEM_PROMPT = "You are an expert presentation designer and content strategist. Your task is to create a detailed, structured content plan for a presentation based on the given topic and requirements.\n\nYou must output ONLY valid JSON with no additional text, markdown formatting, or explanation.\n\nCRITICAL RULES:\n1. Each slide MUST have a clear, specific title (not generic like \"Slide 2\")\n2. Content bullets should be concise (max 10 words each)\n3. Maximum 5-6 bullets per slide for readability\n4. Image prompts should describe VISUAL scenes without any text in the image\n5. Speaker notes should provide detailed talking points for the presenter\n6. First slide is always type \"title\", last slide is always type \"closing\"\n7. Include an \"agenda\" slide as slide 2 for presentations with 8+ slides\n8. Create visual variety: mix content, data, quote, and image slides\n9. For data slides, provide realistic sample data that matches the topic\n10. Use statistics slides for key metrics, chart slides for trends/comparisons\n11. Include at least one quote slide for impact\n12. Use section-header slides to break up long presentations (15+ slides)\n13. Title and closing slides should be clean and simple";
69
77
  /**
70
78
  * Build the user prompt for content planning
79
+ * Modular design: each section is a separate constant for easy debugging/changes
71
80
  */
72
- export declare function buildContentPlanningPrompt(topic: string, pages: number, audience: string, tone: string, theme: string, includeImages: boolean): string;
81
+ export declare function buildContentPlanningPrompt(options: BuildContentPlanningPromptOptions): string;
73
82
  /**
74
83
  * Enhance an image prompt for better AI image generation
75
84
  */
@@ -82,6 +91,26 @@ export declare const VALID_THEMES: string[];
82
91
  export declare const VALID_AUDIENCES: string[];
83
92
  export declare const VALID_TONES: string[];
84
93
  export declare const VALID_ASPECT_RATIOS: string[];
94
+ /**
95
+ * Default formatting config per slide type
96
+ * AI can override these by specifying formatting in content
97
+ */
98
+ export declare const SLIDE_TYPE_FORMATTING: Record<string, SlideFormattingConfig & {
99
+ bulletStyle: BulletStyle;
100
+ }>;
101
+ /**
102
+ * Get formatting config for a slide type
103
+ */
104
+ export declare function getSlideTypeFormatting(slideType: string): SlideFormattingConfig & {
105
+ bulletStyle: BulletStyle;
106
+ };
107
+ /**
108
+ * Map BulletStyle to pptxgenjs bullet options
109
+ */
110
+ export declare function getBulletOptions(style: BulletStyle): {
111
+ type?: "bullet" | "number";
112
+ code?: string;
113
+ } | boolean;
85
114
  /** Timeout for content planning AI call (60 seconds) */
86
115
  export declare const CONTENT_PLANNING_TIMEOUT_MS = 60000;
87
116
  /** Timeout for image generation per slide (30 seconds) */