@learnpack/learnpack 5.0.293 → 5.0.295
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.
- package/lib/commands/serve.js +132 -0
- package/lib/creatorDist/assets/index-CwOHnpZp.js +74438 -0
- package/lib/creatorDist/assets/{index-CacFtcN8.css → index-DTjdV1LF.css} +0 -8
- package/lib/creatorDist/index.html +2 -2
- package/lib/utils/rigoActions.d.ts +5 -0
- package/lib/utils/rigoActions.js +22 -1
- package/package.json +1 -1
- package/src/commands/serve.ts +184 -0
- package/src/creator/package-lock.json +10 -0
- package/src/creator/package.json +1 -0
- package/src/creator/src/components/Icon.tsx +18 -0
- package/src/creator/src/components/LessonItem.tsx +7 -10
- package/src/creatorDist/assets/index-CwOHnpZp.js +74438 -0
- package/src/creatorDist/assets/{index-CacFtcN8.css → index-DTjdV1LF.css} +0 -8
- package/src/creatorDist/index.html +2 -2
- package/src/ui/_app/app.css +1 -1
- package/src/ui/_app/app.js +8677 -458
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/rigoActions.ts +33 -0
- package/lib/creatorDist/assets/index-DOEfLGDQ.js +0 -39343
- package/src/creatorDist/assets/index-DOEfLGDQ.js +0 -39343
package/lib/commands/serve.js
CHANGED
@@ -625,6 +625,79 @@ class ServeCommand extends SessionCommand_1.default {
|
|
625
625
|
res.status(500).json({ error: error.message });
|
626
626
|
}
|
627
627
|
});
|
628
|
+
app.post("/webhooks/:courseSlug/:exercisePosition/process-coding-challege/", async (req, res) => {
|
629
|
+
const { courseSlug, exercisePosition } = req.params;
|
630
|
+
const body = req.body;
|
631
|
+
console.log("RECEIVING CODING CHALLENGE WEBHOOK for course:", courseSlug, "exercise position:", exercisePosition);
|
632
|
+
console.log("Webhook body:", JSON.stringify(body, null, 2));
|
633
|
+
try {
|
634
|
+
if (body.status === "ERROR") {
|
635
|
+
console.error("❌ Error in coding challenge generation:", body.error);
|
636
|
+
return res.json({ status: "ERROR" });
|
637
|
+
}
|
638
|
+
// Parse the RigoBot response
|
639
|
+
if (body.parsed) {
|
640
|
+
const { files, reasoning } = body.parsed;
|
641
|
+
console.log("📋 Reasoning:", reasoning);
|
642
|
+
console.log("📁 Files received:", files);
|
643
|
+
if (files && Array.isArray(files)) {
|
644
|
+
console.log("✅ Processing files for coding challenge...");
|
645
|
+
// Get the current exercise info to determine the exercise directory
|
646
|
+
const syllabus = await getSyllabus(courseSlug, bucket);
|
647
|
+
const exercise = syllabus.lessons[parseInt(exercisePosition)];
|
648
|
+
if (!exercise) {
|
649
|
+
console.error(`❌ Exercise not found at position ${exercisePosition}`);
|
650
|
+
return res.status(404).json({ error: "Exercise not found" });
|
651
|
+
}
|
652
|
+
const exSlug = (0, creatorUtilities_2.slugify)(exercise.id + "-" + exercise.title);
|
653
|
+
const exerciseDir = `courses/${courseSlug}/exercises/${exSlug}`;
|
654
|
+
for (const fileStr of files) {
|
655
|
+
try {
|
656
|
+
const fileObj = JSON.parse(fileStr);
|
657
|
+
console.log(`📄 Processing file: ${fileObj.name}`);
|
658
|
+
// Save the main file with content
|
659
|
+
if (fileObj.name && fileObj.content) {
|
660
|
+
const filePath = `${exerciseDir}/${fileObj.name}`;
|
661
|
+
// eslint-disable-next-line no-await-in-loop
|
662
|
+
await uploadFileToBucket(bucket, fileObj.content, filePath);
|
663
|
+
console.log(`✅ Saved file: ${filePath}`);
|
664
|
+
}
|
665
|
+
// Save the solution file if it exists
|
666
|
+
if (fileObj.name && fileObj.solution) {
|
667
|
+
const nameParts = fileObj.name.split(".");
|
668
|
+
if (nameParts.length > 1) {
|
669
|
+
const extension = nameParts.pop();
|
670
|
+
const baseName = nameParts.join(".");
|
671
|
+
const solutionFileName = `${baseName}.solution.hide.${extension}`;
|
672
|
+
const solutionFilePath = `${exerciseDir}/${solutionFileName}`;
|
673
|
+
// eslint-disable-next-line no-await-in-loop
|
674
|
+
await uploadFileToBucket(bucket, fileObj.solution, solutionFilePath);
|
675
|
+
console.log(`✅ Saved solution file: ${solutionFilePath}`);
|
676
|
+
}
|
677
|
+
else {
|
678
|
+
// If no extension, just add .solution.hide
|
679
|
+
const solutionFileName = `${fileObj.name}.solution.hide`;
|
680
|
+
const solutionFilePath = `${exerciseDir}/${solutionFileName}`;
|
681
|
+
// eslint-disable-next-line no-await-in-loop
|
682
|
+
await uploadFileToBucket(bucket, fileObj.solution, solutionFilePath);
|
683
|
+
console.log(`✅ Saved solution file: ${solutionFilePath}`);
|
684
|
+
}
|
685
|
+
}
|
686
|
+
}
|
687
|
+
catch (parseError) {
|
688
|
+
console.error(`❌ Error parsing file:`, parseError);
|
689
|
+
}
|
690
|
+
}
|
691
|
+
console.log("✅ All coding challenge files saved successfully");
|
692
|
+
}
|
693
|
+
}
|
694
|
+
res.json({ status: "SUCCESS" });
|
695
|
+
}
|
696
|
+
catch (error) {
|
697
|
+
console.error("❌ Error processing coding challenge webhook:", error);
|
698
|
+
res.status(500).json({ error: error.message });
|
699
|
+
}
|
700
|
+
});
|
628
701
|
app.post("/actions/continue-generating/:courseSlug/:position", async (req, res) => {
|
629
702
|
const { courseSlug, position } = req.params;
|
630
703
|
const { feedback, mode } = req.body;
|
@@ -695,6 +768,65 @@ class ServeCommand extends SessionCommand_1.default {
|
|
695
768
|
await (0, exports.processImage)(image.url, image.alt, rigoToken, courseSlug);
|
696
769
|
res.json({ status: "QUEUED" });
|
697
770
|
});
|
771
|
+
app.post("/actions/generate-code-challenge", async (req, res) => {
|
772
|
+
const rigoToken = req.header("x-rigo-token");
|
773
|
+
const { code_challenge, lesson_content, exercise_position, course_slug } = req.body;
|
774
|
+
if (!rigoToken) {
|
775
|
+
return res.status(400).json({
|
776
|
+
error: "Rigo token is required. x-rigo-token header is missing",
|
777
|
+
});
|
778
|
+
}
|
779
|
+
if (!code_challenge) {
|
780
|
+
return res.status(400).json({
|
781
|
+
error: "code_challenge is required",
|
782
|
+
});
|
783
|
+
}
|
784
|
+
if (!lesson_content) {
|
785
|
+
return res.status(400).json({
|
786
|
+
error: "lesson_content is required",
|
787
|
+
});
|
788
|
+
}
|
789
|
+
if (!course_slug) {
|
790
|
+
return res.status(400).json({
|
791
|
+
error: "course_slug is required",
|
792
|
+
});
|
793
|
+
}
|
794
|
+
if (exercise_position === undefined || exercise_position === null) {
|
795
|
+
return res.status(400).json({
|
796
|
+
error: "exercise_position is required",
|
797
|
+
});
|
798
|
+
}
|
799
|
+
if (typeof exercise_position !== "number" || exercise_position < 0) {
|
800
|
+
return res.status(400).json({
|
801
|
+
error: "exercise_position must be a valid number >= 0",
|
802
|
+
});
|
803
|
+
}
|
804
|
+
try {
|
805
|
+
const webhookUrl = `${process.env.HOST}/webhooks/${course_slug}/${exercise_position}/process-coding-challege/`;
|
806
|
+
const result = await (0, rigoActions_1.generateCodeChallenge)(rigoToken, {
|
807
|
+
lesson_content,
|
808
|
+
challenge_proposal: code_challenge,
|
809
|
+
}, webhookUrl);
|
810
|
+
if (!result) {
|
811
|
+
return res.status(500).json({
|
812
|
+
error: "Failed to generate code challenge",
|
813
|
+
});
|
814
|
+
}
|
815
|
+
console.log("Code challenge generation started:", result);
|
816
|
+
res.json({
|
817
|
+
status: "QUEUED",
|
818
|
+
id: result.id,
|
819
|
+
message: "Code challenge generation started",
|
820
|
+
});
|
821
|
+
}
|
822
|
+
catch (error) {
|
823
|
+
console.error("Error generating code challenge:", error);
|
824
|
+
res.status(500).json({
|
825
|
+
error: "Failed to start code challenge generation",
|
826
|
+
details: error.message,
|
827
|
+
});
|
828
|
+
}
|
829
|
+
});
|
698
830
|
app.post("/webhooks/:courseSlug/exercise-processor/:lessonID/:rigoToken", async (req, res) => {
|
699
831
|
// console.log("Receiving a webhook to exercise processor")
|
700
832
|
const { courseSlug, lessonID, rigoToken } = req.params;
|