@thanh01.pmt/curriculum-kit 1.4.31 → 1.4.33
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/dist/ai/index.cjs +126 -1
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.d.cts +10 -46
- package/dist/ai/index.d.ts +10 -46
- package/dist/ai/index.mjs +126 -1
- package/dist/ai/index.mjs.map +1 -1
- package/dist/index.cjs +128 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +128 -1
- package/dist/index.mjs.map +1 -1
- package/dist/media/index.cjs.map +1 -1
- package/dist/media/index.d.cts +1 -1
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.mjs.map +1 -1
- package/dist/pipeline/index.cjs +48 -1
- package/dist/pipeline/index.cjs.map +1 -1
- package/dist/pipeline/index.mjs +48 -1
- package/dist/pipeline/index.mjs.map +1 -1
- package/dist/{streamRunner-DYHFhNUr.d.cts → streamRunner-B0Z1nAG5.d.cts} +76 -1
- package/dist/{streamRunner-DYHFhNUr.d.ts → streamRunner-B0Z1nAG5.d.ts} +76 -1
- package/dist/workflow/index.cjs +48 -1
- package/dist/workflow/index.cjs.map +1 -1
- package/dist/workflow/index.mjs +48 -1
- package/dist/workflow/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,9 +2,9 @@ import { PlanConstraints, TranslationPolicy, CurriculumPlan, PlanningGraph, Plan
|
|
|
2
2
|
export { ActiveLearningWorkflow, ActiveLearningWorkflowSchema, ActivityLabSchema, ActivitySeqRow, ActivitySeqRowSchema, ActivityStepSchema, ArtifactContractRowSchema, AssessmentMapRowSchema, AssessmentObjective, AssessmentObjectiveSchema, BellRinger, BellRingerDay, BellRingerDaySchema, BellRingerInput, BellRingerSchema, BloomLevel, BloomLevelSchema, BronzeTier, BronzeTierSchema, CERConclusion, CERConclusionSchema, CardTierEnum, ChoiceBoard, ChoiceBoardInput, ChoiceBoardRubricRowSchema, ChoiceBoardSchema, ChoiceRuleSchema, ChoiceSquare, ChoiceSquareSchema, CodeLabSchema, CodeSnippet, CodeSnippetSchema, CompetencyRubricRow, CompetencyRubricRowSchema, ComputationalThinking, ComputationalThinkingSchema, CoreConcept, CoreConceptSchema, CourseObjective, CourseObjectiveSchema, CoverageReport, CoverageReportSchema, CurriculumArtifact, CurriculumArtifactSchema, CurriculumPlanSchema, CurriculumQualityReport, CurriculumQualityReportSchema, DependencyEdgeSchema, DepthAssignment, DepthAssignmentSchema, DepthLevel, DepthLevelSchema, DiagnosticQuestion, DiagnosticQuestionInput, DiagnosticQuestionSchema, DiagnosticQuizSchema, EDPPhaseEnum, EntryLevelSchema, ExitTicket, ExitTicketBugHunt, ExitTicketBugHuntSchema, ExitTicketMetacognitionSchema, ExitTicketQuickItemSchema, ExitTicketRecallPromptSchema, ExitTicketSchema, ExperimentalDesignSchema, Extension, ExtensionChallengeSchema, ExtensionSchema, FiveEFlowPhaseSchema, FiveEPhaseEnum, Glossary, GlossaryInput, GlossaryQuickRefRowSchema, GlossarySchema, GlossaryTerm, GlossaryTermSchema, GoldTier, GoldTierSchema, GraphicOrganizer, GraphicOrganizerInput, GraphicOrganizerItem, GraphicOrganizerItemSchema, GraphicOrganizerSchema, Handout, HandoutSchema, HandoutSection, HandoutSectionSchema, InstructionSection, InstructionSectionSchema, InstructionStep, InstructionStepSchema, JudgeCriterionSchema, LabTierTask, LabTierTaskSchema, LearningObjectiveInput, LearningObjectiveInputSchema, LearningObjectiveRow, LearningObjectiveRowSchema, LessonFlowPhase, LessonFlowPhaseSchema, LessonPlan5E, LessonPlan5ESchema, LessonPlanEDP, LessonPlanEDPSchema, LessonPlanSchema, LessonSectionSchema, MarpSlide, MarpSlideSchema, MentorCheatsheetSchema, MilestoneInput, MilestoneInputSchema, Misconception, MisconceptionSchema, NodeKindSchema, OrganizerTypeEnum, PhaseInput, PhaseInputSchema, PlanConstraintsSchema, PlannerInput, PlannerInputSchema, PlanningGraphSchema, PlanningNodeSchema, PlanningPhase, PrerequisiteDecision, PrerequisiteDecisionEntry, PrerequisiteDecisionEntrySchema, PrerequisiteDecisionSchema, ProductGoalSchema, ProgressiveHints, ProgressiveHintsSchema, ProjectGraph, ProjectGraphSchema, ProjectInstruction, ProjectInstructionSchema, ProjectProfile, ProjectProfileSchema, ProjectRoadmap, QualityAuditVerdictSchema, QuizOption, QuizOptionSchema, ResourceMapRowSchema, ReviewGame, ReviewGameExportRowSchema, ReviewGameInput, ReviewGameQuestion, ReviewGameQuestionSchema, ReviewGameSchema, RoadmapInput, RoadmapInputSchema, RotationStation, RotationStationSchema, Rubric, RubricCriteria, RubricCriteriaSchema, RubricSchema, ScaffoldDecision, ScaffoldDecisionEntry, ScaffoldDecisionEntrySchema, ScaffoldDecisionSchema, ScienceLab, ScienceLabInput, ScienceLabSchema, ScoringRubricRowSchema, SelfLab, SelfLabSchema, SelfPacedBundle, SelfPacedBundleSchema, SelfPacedChallenge, SelfPacedChallengeSchema, SessionPlan, SessionPlanSchema, SilverTier, SilverTierSchema, SlideDeckSchema, StandardizedTermRowSchema, StationRecordRowSchema, StationRotation, StationRotationInput, StationRotationSchema, StationTypeEnum, TaskCard, TaskCardSchema, TaskCards, TaskCardsInput, TaskCardsSchema, TeacherGuide, TeacherGuideSchema, TeachingScriptPhase, TeachingScriptPhaseSchema, TierLevelEnum, TierObjectiveSchema, TieredPractice, TieredPracticeSchema, TranslationPolicySchema, TroubleshootingEntry, TroubleshootingEntrySchema, TroubleshootingRow, TroubleshootingRowSchema, UnitPlan, UnitPlanSchema, UserJourneySchema, Worksheet, WorksheetItem, WorksheetItemSchema, WorksheetItemTypeEnum, WorksheetPart, WorksheetPartSchema, WorksheetSchema, validateCurriculumPlan } from './schemas/index.cjs';
|
|
3
3
|
import { A as AIProviderName, M as ModelResolutionOptions } from './provider-factory-Bv-eIkhg.cjs';
|
|
4
4
|
export { N as NVIDIA_MODELS, g as getAIModel } from './provider-factory-Bv-eIkhg.cjs';
|
|
5
|
-
export { ActivityPromptInput,
|
|
6
|
-
import { S as StreamRunnerOptions } from './streamRunner-
|
|
7
|
-
export { C as ChatMessage, c as ChunkType, D as DEFAULT_ARTIFACT_STREAM_IDLE_MS, d as DEFAULT_ARTIFACT_STREAM_TOTAL_MS, F as FallbackTarget, I as IdleAbort, f as StreamAbortController, j as createIdleAbortController, h as createStreamAbortController, e as extractThoughtAndContent, g as getDesignatedFallbackChain, b as getDesignatedFallbackConfig, a as isModelAllowed, i as isProviderEnabled, r as resolveApiKey, k as runCurriculumAIInference, s as streamCurriculumAIInference } from './streamRunner-
|
|
5
|
+
export { ActivityPromptInput, AsyncLLMJudgeInput, AuditCurriculumQualityInput, CodeLabPromptInput, DEFAULT_ENABLED_PROVIDERS, DiagnosticQuizPromptInput, ExtensionPromptInput, GenerateActivityInput, GenerateCodeLabInput, GenerateDiagnosticQuizInput, GenerateExtensionInput, GenerateHandoutInput, GenerateLessonMasterInput, GenerateProjectInstructionInput, GenerateSelfLabInput, GenerateSlidesInput, GenerateTeacherGuideInput, GenerateWorksheetInput, HandoutPromptInput, HtmlDeckSlidePromptInput, JudgeEvaluationResult, JudgePromptInput, LLMJudgeEngine, LessonPromptInput, MarpMarkdownSlidePromptInput, ModelPolicyResolution, ModelPolicyResolver, ModelProviderKey, MultiProviderPolicyResolution, ProjectInstructionPromptInput, SLIDE_CANONICAL_METHODOLOGY, SelfLabPromptInput, SlidesPromptInput, StreamDiagnosticQuizInput, StreamLessonMasterInput, StreamSelfLabInput, TeacherGuidePromptInput, WorksheetPromptInput, activityTools, analystTools, assessorTools, auditCurriculumQualityFlow, buildActivityPrompt, buildCodeLabPrompt, buildDiagnosticQuizPrompt, buildExtensionPrompt, buildHandoutPrompt, buildHtmlDeckSlidePrompt, buildJudgePrompt, buildLessonMasterPrompt, buildMarpMarkdownSlidePrompt, buildProjectInstructionPrompt, buildSelfLabPrompt, buildSlidesPrompt, buildTeacherGuidePrompt, buildWorksheetPrompt, contentTools, designerTools, generateActivityFlow, generateCodeLabFlow, generateDiagnosticQuizFlow, generateExtensionFlow, generateHandoutFlow, generateLessonMasterFlow, generateProjectInstructionFlow, generateSelfLabFlow, generateSlidesFlow, generateTeacherGuideFlow, generateWorksheetFlow, illustratorTools, packagerTools, researcherTools, reviewerTools, streamCurriculumAIInferenceWithTools, streamDiagnosticQuizFlow, streamLessonMasterFlow, streamSelfLabFlow, techSmeTools } from './ai/index.cjs';
|
|
6
|
+
import { S as StreamRunnerOptions } from './streamRunner-B0Z1nAG5.cjs';
|
|
7
|
+
export { A as AggregatedToolCall, C as ChatMessage, c as ChunkType, D as DEFAULT_ARTIFACT_STREAM_IDLE_MS, d as DEFAULT_ARTIFACT_STREAM_TOTAL_MS, F as FallbackTarget, I as IdleAbort, f as StreamAbortController, T as ToolDefinition, l as ToolExecutionResult, m as ToolExecutor, n as ToolLoopConfig, j as createIdleAbortController, h as createStreamAbortController, e as extractThoughtAndContent, g as getDesignatedFallbackChain, b as getDesignatedFallbackConfig, a as isModelAllowed, i as isProviderEnabled, r as resolveApiKey, k as runCurriculumAIInference, s as streamCurriculumAIInference } from './streamRunner-B0Z1nAG5.cjs';
|
|
8
8
|
export { ArtifactLintReport, ConvertedSotBundle, GenerateProjectInstructionOptions, GenerateRoadmapCurriculumOptions, GenerateSelfPacedBundleInput, LintIssue, ProjectInstructionResult, RoadmapCurriculumOutput, SelfPacedBundleOutput, convertRoadmapToFoundationSot, generateProjectInstruction, generateRoadmapCurriculum, generateSelfPacedBundle, importRoadmapToProject, lintAndSanitizeArtifact, serializeActivityToMarkdown, serializeCodeLabToMarkdown, serializeDiagnosticQuizToMarkdown, serializeHandoutToMarkdown, serializeLessonToMarkdown, serializeProjectInstructionToMarkdown, serializeSelfLabToMarkdown, validateMarkdownTables, validateMermaidSyntax } from './pipeline/index.cjs';
|
|
9
9
|
export { A as AutoRepairOptions, a as AutoRepairResult, B as BundleTier, G as GenerateMilestoneBundleOptions, M as MilestoneCurriculumBundle, g as generateMilestoneCurriculumBundle, w as withAutoRepair } from './milestoneBundleGenerator-CN6F1zPs.cjs';
|
|
10
10
|
import { I as ICurriculumStorage, P as ProjectStatusReport, S as SmartResumeContext, Q as QualityAuditReport } from './types-Bgk-C4K2.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { PlanConstraints, TranslationPolicy, CurriculumPlan, PlanningGraph, Plan
|
|
|
2
2
|
export { ActiveLearningWorkflow, ActiveLearningWorkflowSchema, ActivityLabSchema, ActivitySeqRow, ActivitySeqRowSchema, ActivityStepSchema, ArtifactContractRowSchema, AssessmentMapRowSchema, AssessmentObjective, AssessmentObjectiveSchema, BellRinger, BellRingerDay, BellRingerDaySchema, BellRingerInput, BellRingerSchema, BloomLevel, BloomLevelSchema, BronzeTier, BronzeTierSchema, CERConclusion, CERConclusionSchema, CardTierEnum, ChoiceBoard, ChoiceBoardInput, ChoiceBoardRubricRowSchema, ChoiceBoardSchema, ChoiceRuleSchema, ChoiceSquare, ChoiceSquareSchema, CodeLabSchema, CodeSnippet, CodeSnippetSchema, CompetencyRubricRow, CompetencyRubricRowSchema, ComputationalThinking, ComputationalThinkingSchema, CoreConcept, CoreConceptSchema, CourseObjective, CourseObjectiveSchema, CoverageReport, CoverageReportSchema, CurriculumArtifact, CurriculumArtifactSchema, CurriculumPlanSchema, CurriculumQualityReport, CurriculumQualityReportSchema, DependencyEdgeSchema, DepthAssignment, DepthAssignmentSchema, DepthLevel, DepthLevelSchema, DiagnosticQuestion, DiagnosticQuestionInput, DiagnosticQuestionSchema, DiagnosticQuizSchema, EDPPhaseEnum, EntryLevelSchema, ExitTicket, ExitTicketBugHunt, ExitTicketBugHuntSchema, ExitTicketMetacognitionSchema, ExitTicketQuickItemSchema, ExitTicketRecallPromptSchema, ExitTicketSchema, ExperimentalDesignSchema, Extension, ExtensionChallengeSchema, ExtensionSchema, FiveEFlowPhaseSchema, FiveEPhaseEnum, Glossary, GlossaryInput, GlossaryQuickRefRowSchema, GlossarySchema, GlossaryTerm, GlossaryTermSchema, GoldTier, GoldTierSchema, GraphicOrganizer, GraphicOrganizerInput, GraphicOrganizerItem, GraphicOrganizerItemSchema, GraphicOrganizerSchema, Handout, HandoutSchema, HandoutSection, HandoutSectionSchema, InstructionSection, InstructionSectionSchema, InstructionStep, InstructionStepSchema, JudgeCriterionSchema, LabTierTask, LabTierTaskSchema, LearningObjectiveInput, LearningObjectiveInputSchema, LearningObjectiveRow, LearningObjectiveRowSchema, LessonFlowPhase, LessonFlowPhaseSchema, LessonPlan5E, LessonPlan5ESchema, LessonPlanEDP, LessonPlanEDPSchema, LessonPlanSchema, LessonSectionSchema, MarpSlide, MarpSlideSchema, MentorCheatsheetSchema, MilestoneInput, MilestoneInputSchema, Misconception, MisconceptionSchema, NodeKindSchema, OrganizerTypeEnum, PhaseInput, PhaseInputSchema, PlanConstraintsSchema, PlannerInput, PlannerInputSchema, PlanningGraphSchema, PlanningNodeSchema, PlanningPhase, PrerequisiteDecision, PrerequisiteDecisionEntry, PrerequisiteDecisionEntrySchema, PrerequisiteDecisionSchema, ProductGoalSchema, ProgressiveHints, ProgressiveHintsSchema, ProjectGraph, ProjectGraphSchema, ProjectInstruction, ProjectInstructionSchema, ProjectProfile, ProjectProfileSchema, ProjectRoadmap, QualityAuditVerdictSchema, QuizOption, QuizOptionSchema, ResourceMapRowSchema, ReviewGame, ReviewGameExportRowSchema, ReviewGameInput, ReviewGameQuestion, ReviewGameQuestionSchema, ReviewGameSchema, RoadmapInput, RoadmapInputSchema, RotationStation, RotationStationSchema, Rubric, RubricCriteria, RubricCriteriaSchema, RubricSchema, ScaffoldDecision, ScaffoldDecisionEntry, ScaffoldDecisionEntrySchema, ScaffoldDecisionSchema, ScienceLab, ScienceLabInput, ScienceLabSchema, ScoringRubricRowSchema, SelfLab, SelfLabSchema, SelfPacedBundle, SelfPacedBundleSchema, SelfPacedChallenge, SelfPacedChallengeSchema, SessionPlan, SessionPlanSchema, SilverTier, SilverTierSchema, SlideDeckSchema, StandardizedTermRowSchema, StationRecordRowSchema, StationRotation, StationRotationInput, StationRotationSchema, StationTypeEnum, TaskCard, TaskCardSchema, TaskCards, TaskCardsInput, TaskCardsSchema, TeacherGuide, TeacherGuideSchema, TeachingScriptPhase, TeachingScriptPhaseSchema, TierLevelEnum, TierObjectiveSchema, TieredPractice, TieredPracticeSchema, TranslationPolicySchema, TroubleshootingEntry, TroubleshootingEntrySchema, TroubleshootingRow, TroubleshootingRowSchema, UnitPlan, UnitPlanSchema, UserJourneySchema, Worksheet, WorksheetItem, WorksheetItemSchema, WorksheetItemTypeEnum, WorksheetPart, WorksheetPartSchema, WorksheetSchema, validateCurriculumPlan } from './schemas/index.js';
|
|
3
3
|
import { A as AIProviderName, M as ModelResolutionOptions } from './provider-factory-Bv-eIkhg.js';
|
|
4
4
|
export { N as NVIDIA_MODELS, g as getAIModel } from './provider-factory-Bv-eIkhg.js';
|
|
5
|
-
export { ActivityPromptInput,
|
|
6
|
-
import { S as StreamRunnerOptions } from './streamRunner-
|
|
7
|
-
export { C as ChatMessage, c as ChunkType, D as DEFAULT_ARTIFACT_STREAM_IDLE_MS, d as DEFAULT_ARTIFACT_STREAM_TOTAL_MS, F as FallbackTarget, I as IdleAbort, f as StreamAbortController, j as createIdleAbortController, h as createStreamAbortController, e as extractThoughtAndContent, g as getDesignatedFallbackChain, b as getDesignatedFallbackConfig, a as isModelAllowed, i as isProviderEnabled, r as resolveApiKey, k as runCurriculumAIInference, s as streamCurriculumAIInference } from './streamRunner-
|
|
5
|
+
export { ActivityPromptInput, AsyncLLMJudgeInput, AuditCurriculumQualityInput, CodeLabPromptInput, DEFAULT_ENABLED_PROVIDERS, DiagnosticQuizPromptInput, ExtensionPromptInput, GenerateActivityInput, GenerateCodeLabInput, GenerateDiagnosticQuizInput, GenerateExtensionInput, GenerateHandoutInput, GenerateLessonMasterInput, GenerateProjectInstructionInput, GenerateSelfLabInput, GenerateSlidesInput, GenerateTeacherGuideInput, GenerateWorksheetInput, HandoutPromptInput, HtmlDeckSlidePromptInput, JudgeEvaluationResult, JudgePromptInput, LLMJudgeEngine, LessonPromptInput, MarpMarkdownSlidePromptInput, ModelPolicyResolution, ModelPolicyResolver, ModelProviderKey, MultiProviderPolicyResolution, ProjectInstructionPromptInput, SLIDE_CANONICAL_METHODOLOGY, SelfLabPromptInput, SlidesPromptInput, StreamDiagnosticQuizInput, StreamLessonMasterInput, StreamSelfLabInput, TeacherGuidePromptInput, WorksheetPromptInput, activityTools, analystTools, assessorTools, auditCurriculumQualityFlow, buildActivityPrompt, buildCodeLabPrompt, buildDiagnosticQuizPrompt, buildExtensionPrompt, buildHandoutPrompt, buildHtmlDeckSlidePrompt, buildJudgePrompt, buildLessonMasterPrompt, buildMarpMarkdownSlidePrompt, buildProjectInstructionPrompt, buildSelfLabPrompt, buildSlidesPrompt, buildTeacherGuidePrompt, buildWorksheetPrompt, contentTools, designerTools, generateActivityFlow, generateCodeLabFlow, generateDiagnosticQuizFlow, generateExtensionFlow, generateHandoutFlow, generateLessonMasterFlow, generateProjectInstructionFlow, generateSelfLabFlow, generateSlidesFlow, generateTeacherGuideFlow, generateWorksheetFlow, illustratorTools, packagerTools, researcherTools, reviewerTools, streamCurriculumAIInferenceWithTools, streamDiagnosticQuizFlow, streamLessonMasterFlow, streamSelfLabFlow, techSmeTools } from './ai/index.js';
|
|
6
|
+
import { S as StreamRunnerOptions } from './streamRunner-B0Z1nAG5.js';
|
|
7
|
+
export { A as AggregatedToolCall, C as ChatMessage, c as ChunkType, D as DEFAULT_ARTIFACT_STREAM_IDLE_MS, d as DEFAULT_ARTIFACT_STREAM_TOTAL_MS, F as FallbackTarget, I as IdleAbort, f as StreamAbortController, T as ToolDefinition, l as ToolExecutionResult, m as ToolExecutor, n as ToolLoopConfig, j as createIdleAbortController, h as createStreamAbortController, e as extractThoughtAndContent, g as getDesignatedFallbackChain, b as getDesignatedFallbackConfig, a as isModelAllowed, i as isProviderEnabled, r as resolveApiKey, k as runCurriculumAIInference, s as streamCurriculumAIInference } from './streamRunner-B0Z1nAG5.js';
|
|
8
8
|
export { ArtifactLintReport, ConvertedSotBundle, GenerateProjectInstructionOptions, GenerateRoadmapCurriculumOptions, GenerateSelfPacedBundleInput, LintIssue, ProjectInstructionResult, RoadmapCurriculumOutput, SelfPacedBundleOutput, convertRoadmapToFoundationSot, generateProjectInstruction, generateRoadmapCurriculum, generateSelfPacedBundle, importRoadmapToProject, lintAndSanitizeArtifact, serializeActivityToMarkdown, serializeCodeLabToMarkdown, serializeDiagnosticQuizToMarkdown, serializeHandoutToMarkdown, serializeLessonToMarkdown, serializeProjectInstructionToMarkdown, serializeSelfLabToMarkdown, validateMarkdownTables, validateMermaidSyntax } from './pipeline/index.js';
|
|
9
9
|
export { A as AutoRepairOptions, a as AutoRepairResult, B as BundleTier, G as GenerateMilestoneBundleOptions, M as MilestoneCurriculumBundle, g as generateMilestoneCurriculumBundle, w as withAutoRepair } from './milestoneBundleGenerator-DTiJ5gIh.js';
|
|
10
10
|
import { I as ICurriculumStorage, P as ProjectStatusReport, S as SmartResumeContext, Q as QualityAuditReport } from './types-Bgk-C4K2.js';
|
package/dist/index.mjs
CHANGED
|
@@ -979,6 +979,52 @@ var init_streamRunner = __esm({
|
|
|
979
979
|
DEFAULT_ARTIFACT_STREAM_TOTAL_MS = 48e4;
|
|
980
980
|
}
|
|
981
981
|
});
|
|
982
|
+
function cleanNonStreamingFetch() {
|
|
983
|
+
return async (input, init) => {
|
|
984
|
+
const res = await fetch(input, init);
|
|
985
|
+
let wantsStream = false;
|
|
986
|
+
try {
|
|
987
|
+
const body = init?.body;
|
|
988
|
+
if (typeof body === "string") wantsStream = /"stream"\s*:\s*true/.test(body);
|
|
989
|
+
} catch {
|
|
990
|
+
}
|
|
991
|
+
if (wantsStream) return res;
|
|
992
|
+
const contentType = res.headers.get("content-type") || "";
|
|
993
|
+
if (!contentType.includes("text/event-stream") && !contentType.includes("application/json")) return res;
|
|
994
|
+
const text = await res.text();
|
|
995
|
+
const trimmed = text.trim();
|
|
996
|
+
if (trimmed.startsWith("data:")) {
|
|
997
|
+
let content = "";
|
|
998
|
+
let lastChunk = null;
|
|
999
|
+
for (const line of trimmed.split("\n")) {
|
|
1000
|
+
const l = line.trim();
|
|
1001
|
+
if (!l || !l.startsWith("data:")) continue;
|
|
1002
|
+
const jsonStr = l.slice(5).trim();
|
|
1003
|
+
if (jsonStr === "[DONE]") continue;
|
|
1004
|
+
try {
|
|
1005
|
+
const chunk = JSON.parse(jsonStr);
|
|
1006
|
+
lastChunk = chunk;
|
|
1007
|
+
content += chunk.choices?.[0]?.delta?.content || "";
|
|
1008
|
+
} catch {
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
const assembled = {
|
|
1012
|
+
id: lastChunk?.id || "chatcmpl-" + Date.now(),
|
|
1013
|
+
object: "chat.completion",
|
|
1014
|
+
created: lastChunk?.created || Math.floor(Date.now() / 1e3),
|
|
1015
|
+
model: lastChunk?.model || "9router",
|
|
1016
|
+
choices: [{ index: 0, message: { role: "assistant", content }, finish_reason: "stop" }],
|
|
1017
|
+
usage: lastChunk?.usage || void 0
|
|
1018
|
+
};
|
|
1019
|
+
const headers = new Headers(res.headers);
|
|
1020
|
+
headers.set("content-type", "application/json");
|
|
1021
|
+
return new Response(JSON.stringify(assembled), { status: res.status, statusText: res.statusText, headers });
|
|
1022
|
+
}
|
|
1023
|
+
const doneIndex = text.indexOf("data: [DONE]");
|
|
1024
|
+
if (doneIndex === -1) return res;
|
|
1025
|
+
return new Response(text.slice(0, doneIndex).trim(), { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
982
1028
|
function getAIModel(options = {}) {
|
|
983
1029
|
const designated = getDesignatedFallbackConfig();
|
|
984
1030
|
const defaultProvider = process.env.DEFAULT_AI_PROVIDER || process.env.LLM_PROVIDER || detectDefaultProvider();
|
|
@@ -997,7 +1043,8 @@ function getAIModel(options = {}) {
|
|
|
997
1043
|
const rawUrl = options.baseURL || resolveApiKey("NINEROUTER_BASE_URL") || resolveApiKey("NINE_ROUTER_BASE_URL") || "https://ai-router.orchable.app/v1";
|
|
998
1044
|
const ninerouter = createOpenAI({
|
|
999
1045
|
apiKey,
|
|
1000
|
-
baseURL: rawUrl.replace(/^["']|["']$/g, "").trim()
|
|
1046
|
+
baseURL: rawUrl.replace(/^["']|["']$/g, "").trim(),
|
|
1047
|
+
fetch: cleanNonStreamingFetch()
|
|
1001
1048
|
});
|
|
1002
1049
|
return ninerouter.chat(resolvedModelName || "fast-reasoning");
|
|
1003
1050
|
}
|
|
@@ -7925,6 +7972,8 @@ var LLMJudgeEngine = class {
|
|
|
7925
7972
|
};
|
|
7926
7973
|
|
|
7927
7974
|
// src/ai/chatToolLoop.ts
|
|
7975
|
+
init_streamRunner();
|
|
7976
|
+
init_errors();
|
|
7928
7977
|
var PROVIDER_ENDPOINTS = {
|
|
7929
7978
|
openrouter: "https://openrouter.ai/api/v1/chat/completions",
|
|
7930
7979
|
deepseek: "https://api.deepseek.com/chat/completions",
|
|
@@ -8058,6 +8107,16 @@ async function runTurn(endpoint, model, apiKey, messages, tools, idleTimeoutMs,
|
|
|
8058
8107
|
return { content: fullRaw, toolCalls };
|
|
8059
8108
|
}
|
|
8060
8109
|
async function streamCurriculumAIInferenceWithTools(messages, projectContext, options, loop, onChunk) {
|
|
8110
|
+
if (options.customToolInference) {
|
|
8111
|
+
return runToolLoopWithCustomInference(messages, projectContext, options, loop, onChunk);
|
|
8112
|
+
}
|
|
8113
|
+
if (resolveApiKey("CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE") === "1") {
|
|
8114
|
+
throw createAiInferenceError({
|
|
8115
|
+
errorCode: "ERR_CUSTOM_INFERENCE_REQUIRED",
|
|
8116
|
+
message: "customToolInference is REQUIRED (CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE=1): pass buildKitToolInference(...) so tool-calling turns flow through the host AI SDK gateway and its unified Langfuse tracing. Raw-fetch tool-loop provider routes are disabled by mandate.",
|
|
8117
|
+
rawError: { mandate: "CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE", hasCustomToolInference: false }
|
|
8118
|
+
});
|
|
8119
|
+
}
|
|
8061
8120
|
const route = resolveProviderRoute(options);
|
|
8062
8121
|
const maxTokens = options.maxTokens ?? 32768;
|
|
8063
8122
|
const maxRounds = loop.maxRounds ?? 4;
|
|
@@ -8122,6 +8181,74 @@ Guidelines:
|
|
|
8122
8181
|
}
|
|
8123
8182
|
return finalContent;
|
|
8124
8183
|
}
|
|
8184
|
+
async function runToolLoopWithCustomInference(messages, projectContext, options, loop, onChunk) {
|
|
8185
|
+
const infer = options.customToolInference;
|
|
8186
|
+
const maxTokens = options.maxTokens ?? 32768;
|
|
8187
|
+
const maxRounds = loop.maxRounds ?? 4;
|
|
8188
|
+
const systemInstruction = `${options.systemPersona || "You are Curriculum OS Assistant."}
|
|
8189
|
+
|
|
8190
|
+
Project Context:
|
|
8191
|
+
${projectContext}
|
|
8192
|
+
|
|
8193
|
+
Guidelines:
|
|
8194
|
+
1. Answer precisely using the provided tools when they help (project status, deep research, production declaration, gate approval).
|
|
8195
|
+
2. Keep Markdown formatting. Never invent tool results.`;
|
|
8196
|
+
const convo = [
|
|
8197
|
+
{ role: "system", content: systemInstruction },
|
|
8198
|
+
...messages.map((m) => ({ role: m.role === "assistant" || m.role === "model" ? "assistant" : "user", content: m.content }))
|
|
8199
|
+
];
|
|
8200
|
+
let finalContent = "";
|
|
8201
|
+
for (let round = 0; round < maxRounds; round++) {
|
|
8202
|
+
let turn;
|
|
8203
|
+
try {
|
|
8204
|
+
turn = await infer({ messages: convo, tools: loop.tools, temperature: options.temperature ?? 0.3, maxTokens, onChunk: onChunk ?? (() => {
|
|
8205
|
+
}) });
|
|
8206
|
+
} catch (err) {
|
|
8207
|
+
const msg = String(err?.message || err);
|
|
8208
|
+
if (/tool/i.test(msg) && /40[04]|400|not support|invalid/i.test(msg)) {
|
|
8209
|
+
console.warn("[toolLoop] custom gateway rejected tools \u2014 degrading to plain chat:", msg.slice(0, 120));
|
|
8210
|
+
const plain = await infer({ messages: convo, tools: [], temperature: options.temperature ?? 0.3, maxTokens, onChunk: onChunk ?? (() => {
|
|
8211
|
+
}) });
|
|
8212
|
+
finalContent = plain.content;
|
|
8213
|
+
break;
|
|
8214
|
+
}
|
|
8215
|
+
throw err;
|
|
8216
|
+
}
|
|
8217
|
+
const { content, toolCalls } = turn;
|
|
8218
|
+
if (toolCalls.length === 0) {
|
|
8219
|
+
finalContent = content;
|
|
8220
|
+
break;
|
|
8221
|
+
}
|
|
8222
|
+
if (content) finalContent = content;
|
|
8223
|
+
convo.push({ role: "assistant", content: content || null, tool_calls: toolCalls.map((t) => ({ id: t.id, type: "function", function: { name: t.name, arguments: t.arguments } })) });
|
|
8224
|
+
for (const call of toolCalls) {
|
|
8225
|
+
let parsedArgs = {};
|
|
8226
|
+
try {
|
|
8227
|
+
parsedArgs = JSON.parse(call.arguments || "{}");
|
|
8228
|
+
} catch {
|
|
8229
|
+
}
|
|
8230
|
+
loop.onToolStart?.(call.name, parsedArgs);
|
|
8231
|
+
let resultPayload;
|
|
8232
|
+
let isError = false;
|
|
8233
|
+
try {
|
|
8234
|
+
resultPayload = await loop.executor(call.name, parsedArgs);
|
|
8235
|
+
} catch (err) {
|
|
8236
|
+
isError = true;
|
|
8237
|
+
resultPayload = { error: err?.message || String(err) };
|
|
8238
|
+
loop.onToolError?.(call.name, err?.message || String(err));
|
|
8239
|
+
}
|
|
8240
|
+
const exec = { toolCallId: call.id, name: call.name, result: resultPayload, isError };
|
|
8241
|
+
loop.onToolResult?.(exec);
|
|
8242
|
+
convo.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(resultPayload).slice(0, 12e3) });
|
|
8243
|
+
}
|
|
8244
|
+
if (round === maxRounds - 1) {
|
|
8245
|
+
const last = await infer({ messages: convo, tools: [], temperature: options.temperature ?? 0.3, maxTokens, onChunk: onChunk ?? (() => {
|
|
8246
|
+
}) });
|
|
8247
|
+
finalContent = last.content;
|
|
8248
|
+
}
|
|
8249
|
+
}
|
|
8250
|
+
return finalContent;
|
|
8251
|
+
}
|
|
8125
8252
|
|
|
8126
8253
|
// src/pipeline/markdownSerializers.ts
|
|
8127
8254
|
function serializeLessonToMarkdown(lesson) {
|