@thanh01.pmt/curriculum-kit 1.4.31 → 1.4.32
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 +78 -0
- 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 +78 -0
- package/dist/ai/index.mjs.map +1 -1
- package/dist/index.cjs +80 -0
- 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 +80 -0
- 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.map +1 -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.map +1 -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
|
@@ -7925,6 +7925,8 @@ var LLMJudgeEngine = class {
|
|
|
7925
7925
|
};
|
|
7926
7926
|
|
|
7927
7927
|
// src/ai/chatToolLoop.ts
|
|
7928
|
+
init_streamRunner();
|
|
7929
|
+
init_errors();
|
|
7928
7930
|
var PROVIDER_ENDPOINTS = {
|
|
7929
7931
|
openrouter: "https://openrouter.ai/api/v1/chat/completions",
|
|
7930
7932
|
deepseek: "https://api.deepseek.com/chat/completions",
|
|
@@ -8058,6 +8060,16 @@ async function runTurn(endpoint, model, apiKey, messages, tools, idleTimeoutMs,
|
|
|
8058
8060
|
return { content: fullRaw, toolCalls };
|
|
8059
8061
|
}
|
|
8060
8062
|
async function streamCurriculumAIInferenceWithTools(messages, projectContext, options, loop, onChunk) {
|
|
8063
|
+
if (options.customToolInference) {
|
|
8064
|
+
return runToolLoopWithCustomInference(messages, projectContext, options, loop, onChunk);
|
|
8065
|
+
}
|
|
8066
|
+
if (resolveApiKey("CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE") === "1") {
|
|
8067
|
+
throw createAiInferenceError({
|
|
8068
|
+
errorCode: "ERR_CUSTOM_INFERENCE_REQUIRED",
|
|
8069
|
+
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.",
|
|
8070
|
+
rawError: { mandate: "CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE", hasCustomToolInference: false }
|
|
8071
|
+
});
|
|
8072
|
+
}
|
|
8061
8073
|
const route = resolveProviderRoute(options);
|
|
8062
8074
|
const maxTokens = options.maxTokens ?? 32768;
|
|
8063
8075
|
const maxRounds = loop.maxRounds ?? 4;
|
|
@@ -8122,6 +8134,74 @@ Guidelines:
|
|
|
8122
8134
|
}
|
|
8123
8135
|
return finalContent;
|
|
8124
8136
|
}
|
|
8137
|
+
async function runToolLoopWithCustomInference(messages, projectContext, options, loop, onChunk) {
|
|
8138
|
+
const infer = options.customToolInference;
|
|
8139
|
+
const maxTokens = options.maxTokens ?? 32768;
|
|
8140
|
+
const maxRounds = loop.maxRounds ?? 4;
|
|
8141
|
+
const systemInstruction = `${options.systemPersona || "You are Curriculum OS Assistant."}
|
|
8142
|
+
|
|
8143
|
+
Project Context:
|
|
8144
|
+
${projectContext}
|
|
8145
|
+
|
|
8146
|
+
Guidelines:
|
|
8147
|
+
1. Answer precisely using the provided tools when they help (project status, deep research, production declaration, gate approval).
|
|
8148
|
+
2. Keep Markdown formatting. Never invent tool results.`;
|
|
8149
|
+
const convo = [
|
|
8150
|
+
{ role: "system", content: systemInstruction },
|
|
8151
|
+
...messages.map((m) => ({ role: m.role === "assistant" || m.role === "model" ? "assistant" : "user", content: m.content }))
|
|
8152
|
+
];
|
|
8153
|
+
let finalContent = "";
|
|
8154
|
+
for (let round = 0; round < maxRounds; round++) {
|
|
8155
|
+
let turn;
|
|
8156
|
+
try {
|
|
8157
|
+
turn = await infer({ messages: convo, tools: loop.tools, temperature: options.temperature ?? 0.3, maxTokens, onChunk: onChunk ?? (() => {
|
|
8158
|
+
}) });
|
|
8159
|
+
} catch (err) {
|
|
8160
|
+
const msg = String(err?.message || err);
|
|
8161
|
+
if (/tool/i.test(msg) && /40[04]|400|not support|invalid/i.test(msg)) {
|
|
8162
|
+
console.warn("[toolLoop] custom gateway rejected tools \u2014 degrading to plain chat:", msg.slice(0, 120));
|
|
8163
|
+
const plain = await infer({ messages: convo, tools: [], temperature: options.temperature ?? 0.3, maxTokens, onChunk: onChunk ?? (() => {
|
|
8164
|
+
}) });
|
|
8165
|
+
finalContent = plain.content;
|
|
8166
|
+
break;
|
|
8167
|
+
}
|
|
8168
|
+
throw err;
|
|
8169
|
+
}
|
|
8170
|
+
const { content, toolCalls } = turn;
|
|
8171
|
+
if (toolCalls.length === 0) {
|
|
8172
|
+
finalContent = content;
|
|
8173
|
+
break;
|
|
8174
|
+
}
|
|
8175
|
+
if (content) finalContent = content;
|
|
8176
|
+
convo.push({ role: "assistant", content: content || null, tool_calls: toolCalls.map((t) => ({ id: t.id, type: "function", function: { name: t.name, arguments: t.arguments } })) });
|
|
8177
|
+
for (const call of toolCalls) {
|
|
8178
|
+
let parsedArgs = {};
|
|
8179
|
+
try {
|
|
8180
|
+
parsedArgs = JSON.parse(call.arguments || "{}");
|
|
8181
|
+
} catch {
|
|
8182
|
+
}
|
|
8183
|
+
loop.onToolStart?.(call.name, parsedArgs);
|
|
8184
|
+
let resultPayload;
|
|
8185
|
+
let isError = false;
|
|
8186
|
+
try {
|
|
8187
|
+
resultPayload = await loop.executor(call.name, parsedArgs);
|
|
8188
|
+
} catch (err) {
|
|
8189
|
+
isError = true;
|
|
8190
|
+
resultPayload = { error: err?.message || String(err) };
|
|
8191
|
+
loop.onToolError?.(call.name, err?.message || String(err));
|
|
8192
|
+
}
|
|
8193
|
+
const exec = { toolCallId: call.id, name: call.name, result: resultPayload, isError };
|
|
8194
|
+
loop.onToolResult?.(exec);
|
|
8195
|
+
convo.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(resultPayload).slice(0, 12e3) });
|
|
8196
|
+
}
|
|
8197
|
+
if (round === maxRounds - 1) {
|
|
8198
|
+
const last = await infer({ messages: convo, tools: [], temperature: options.temperature ?? 0.3, maxTokens, onChunk: onChunk ?? (() => {
|
|
8199
|
+
}) });
|
|
8200
|
+
finalContent = last.content;
|
|
8201
|
+
}
|
|
8202
|
+
}
|
|
8203
|
+
return finalContent;
|
|
8204
|
+
}
|
|
8125
8205
|
|
|
8126
8206
|
// src/pipeline/markdownSerializers.ts
|
|
8127
8207
|
function serializeLessonToMarkdown(lesson) {
|