@thanh01.pmt/curriculum-kit 1.4.32 → 1.4.34
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 +48 -1
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.d.cts +2 -2
- package/dist/ai/index.d.ts +2 -2
- package/dist/ai/index.mjs +48 -1
- package/dist/ai/index.mjs.map +1 -1
- package/dist/index.cjs +118 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -4
- package/dist/index.d.ts +36 -4
- package/dist/index.mjs +118 -26
- package/dist/index.mjs.map +1 -1
- package/dist/media/index.d.cts +1 -1
- package/dist/media/index.d.ts +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-B0Z1nAG5.d.cts → streamRunner-BzlJrAGZ.d.cts} +1 -1
- package/dist/{streamRunner-B0Z1nAG5.d.ts → streamRunner-BzlJrAGZ.d.ts} +1 -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
|
@@ -3,8 +3,8 @@ export { ActiveLearningWorkflow, ActiveLearningWorkflowSchema, ActivityLabSchema
|
|
|
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
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-
|
|
7
|
-
export { A as AggregatedToolCall,
|
|
6
|
+
import { S as StreamRunnerOptions, C as ChunkType } from './streamRunner-BzlJrAGZ.cjs';
|
|
7
|
+
export { A as AggregatedToolCall, a as ChatMessage, 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, c as getDesignatedFallbackConfig, b as isModelAllowed, i as isProviderEnabled, r as resolveApiKey, k as runCurriculumAIInference, s as streamCurriculumAIInference } from './streamRunner-BzlJrAGZ.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';
|
|
@@ -431,6 +431,17 @@ declare class DeterministicPipelineRunner {
|
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/** Lifecycle event for one cascade candidate — hosts forward it to the UI so a
|
|
435
|
+
* silent model switch (idle-timeout failover) is never invisible again. */
|
|
436
|
+
interface PrefillProviderEvent {
|
|
437
|
+
type: 'candidate-start' | 'candidate-failed' | 'candidate-success';
|
|
438
|
+
provider: string;
|
|
439
|
+
model: string;
|
|
440
|
+
attempt: number;
|
|
441
|
+
total: number;
|
|
442
|
+
elapsedMs: number;
|
|
443
|
+
error?: string;
|
|
444
|
+
}
|
|
434
445
|
interface LayerPrefillOptions {
|
|
435
446
|
action?: 'prefill' | 'research';
|
|
436
447
|
targetLayer?: number;
|
|
@@ -448,6 +459,27 @@ interface LayerPrefillOptions {
|
|
|
448
459
|
idleTimeoutMs?: number;
|
|
449
460
|
/** Optional parent abort signal (e.g. from HTTP request) to stop immediately on client disconnect. */
|
|
450
461
|
signal?: AbortSignal;
|
|
462
|
+
/**
|
|
463
|
+
* Host-provided inference override (Vercel AI SDK tiered gateway, test stubs).
|
|
464
|
+
* Same contract as StreamRunnerOptions['customInference']. When set it is the
|
|
465
|
+
* SOLE inference path: the built-in cascade (streamLLMWithFallback) never runs,
|
|
466
|
+
* so host apps that mandate one auditable gateway (Langfuse tracing, raw-wire
|
|
467
|
+
* idle kicks, reasoning_content extraction) get exactly that engine here too.
|
|
468
|
+
* Mirrors the unified-tracing mandate already enforced in lesson/chat/slide paths.
|
|
469
|
+
*/
|
|
470
|
+
customInference?: (request: {
|
|
471
|
+
systemInstruction: string;
|
|
472
|
+
userPrompt: string;
|
|
473
|
+
messages: Array<{
|
|
474
|
+
role: 'user' | 'assistant' | 'system' | 'model';
|
|
475
|
+
content: string;
|
|
476
|
+
}>;
|
|
477
|
+
temperature: number;
|
|
478
|
+
maxTokens: number;
|
|
479
|
+
onChunk: (token: string, type: ChunkType) => void;
|
|
480
|
+
}) => Promise<string>;
|
|
481
|
+
/** Observe cascade candidate transitions (start/fail/success) for UI status. */
|
|
482
|
+
onProviderEvent?: (event: PrefillProviderEvent) => void;
|
|
451
483
|
}
|
|
452
484
|
interface PreliminaryResearchResult {
|
|
453
485
|
groundTruthSummary: string;
|
|
@@ -568,7 +600,7 @@ declare function safeParseJson<T = any>(rawText: string | null): T | null;
|
|
|
568
600
|
/**
|
|
569
601
|
* Multi-tiered resilient streaming inference helper using 100% Vercel AI SDK.
|
|
570
602
|
*/
|
|
571
|
-
declare function streamLLMWithFallback(systemPrompt: string, userPrompt: string, apiKeys?: Record<string, string>, onChunk?: LayerChunkCallback, preferredModel?: string, preferredProvider?: AIProviderName, budget?: StreamBudget, signal?: AbortSignal): Promise<string | null>;
|
|
603
|
+
declare function streamLLMWithFallback(systemPrompt: string, userPrompt: string, apiKeys?: Record<string, string>, onChunk?: LayerChunkCallback, preferredModel?: string, preferredProvider?: AIProviderName, budget?: StreamBudget, signal?: AbortSignal, onEvent?: (event: PrefillProviderEvent) => void): Promise<string | null>;
|
|
572
604
|
/**
|
|
573
605
|
* Conducts preliminary ecosystem research for a course project.
|
|
574
606
|
*/
|
|
@@ -1437,4 +1469,4 @@ declare function getSlideLayoutPresetById(id: string): SlideLayoutPreset | undef
|
|
|
1437
1469
|
*/
|
|
1438
1470
|
declare function getSlideLayoutPresetsByCategory(category: SlideLayoutCategory): SlideLayoutPreset[];
|
|
1439
1471
|
|
|
1440
|
-
export { ACT_TEMPLATE, AIProviderName, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, type AcademicAuditFinding, AcademicAuditor, type AcademicDimension, ActivityLab, type ArtifactDependencyRule, type ArtifactProductionSpec, type AuditBundleInput, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BloomTaxonomyEvaluator, type BuildContextOptions, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, CodeHardwareFeasibilityEvaluator, CodeLab, type ComprehensiveAcademicReport, ConstructiveAlignmentEvaluator, type ContextInjectionMeta, type ContextSourceKey, CoverageGateReport, CrossArtifactDriftEvaluator, CurriculumError, type CurriculumErrorCode, type CurriculumErrorDetail, CurriculumPlan, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DEFAULT_VIETNAMESE_SECTION_HEADINGS, DependencyEdge, type DependencyValidationResult, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuiz, DiagnosticQuizInput, type DimensionScore, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, type ExcerptOptions, type ExcerptResult, type ExecuteCommandResult, ExpositionApprovalError, type ExpositionLlmFn, type ExpositionResult, type ExpositionStorage, type ExtractedJson, type ExtractedStreamChunk, type FindingSeverity, FiveEInstructionalEvaluator, type FrameworkLintFinding, type FrameworkLintReport, FrameworkPack, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, type GenerateExpositionOptions, GeneratedSlideArraySchema, GeneratedSlideSchema, HANDOUT_TEMPLATE, HybridBlueprintArraySchema, HybridBlueprintItemSchema, HybridDeckSlideArraySchema, HybridDeckSlideSchema, HybridPipelineError, ICurriculumStorage, LAYER_IDLE_BUDGET_MS, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, type LayerChunkCallback, type LayerPrefillOptions, type LayerPrefillResult, type LayoutBoxConfig, LessonPlan, MisconceptionEvaluator, ModelResolutionOptions, PROJECT_INSTRUCTION_TEMPLATE, type PackingSpec, type PedagogicalModel, type PipelineExecutionProgress, PlanConstraints, type PlanOptions, type PlanResult, type PlannerLlmFn, PlanningGraph, PlanningNode, type PreliminaryResearchResult, type ProduceLessonOptions, type ProduceLessonResult, type ProjectBriefingData, type ProjectClarification, type ProjectCreationPayload, type ProjectIntentAnalysisResult, ProjectStatusReport, type ProjectionMeta, QUIZ_TEMPLATE, QualityAuditReport, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, ResolvedGateSettings, SATELLITE_LESSON_PRIORITIES, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STATION_ROTATION_TEMPLATE, type SlashCommandDefinition, SlideBlueprintArraySchema, SlideBlueprintItemSchema, SlideDeck, type SlideEngine, type SlideLayoutCategory, type SlideLayoutData, type SlideLayoutPreset, type SlideProductionWorkflowOptions, type SlideProductionWorkflowResult, SmartResumeContext, type StreamAbortHandle, type StreamBudget, type StreamChunkExtractor, StreamRunnerOptions, type SymbolLedgerResult, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TranslationPolicy, type TranslationTarget, type TranslationTrigger, type ValidationOptions, WORKSHEET_TEMPLATE, analyzeProjectCreationIntent, assertAcyclic, auditQualityReport, buildCurriculumContext, buildCurriculumPlan, buildDomainLexiconGuardrail, buildExpositionContext, buildExpositionExcerpt, buildHeadingDirective, buildLanguageDirective, buildLessonExcerpt, buildSectionAwareExcerpt, buildSessionSliceContext, closeTruncatedJson, computePackingSpec, conductPreliminaryResearch, createAiInferenceError, createContextMissingError, createStreamAbortSignal, createStreamChunkExtractor, detectProjectPedagogy, emitUsage, ensureExpositionForLesson, ensureKnowledgeExposition, executeCurriculumCommand, executeSlideProductionWorkflow, expositionCacheKey, extractJsonArray, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, extractSymbolLedger, generatePhase1SotArtifacts, generatePhase2SotArtifacts, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, ingestProjectGraphIntoProject, initializeProjectInStorage, isExpositionFresh, isTranslationDue, lintCurriculumFramework, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, renderFrameworkFromPlan, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, safeParseJson, slugifyProjectName, streamLLMWithFallback, streamLayerPrefillWithFallback, stripLlmJsonWrappers, targetLanguageDisplayName, topoSort, validateArtifactDependencies, validateHybridDeckSlides };
|
|
1472
|
+
export { ACT_TEMPLATE, AIProviderName, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, type AcademicAuditFinding, AcademicAuditor, type AcademicDimension, ActivityLab, type ArtifactDependencyRule, type ArtifactProductionSpec, type AuditBundleInput, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BloomTaxonomyEvaluator, type BuildContextOptions, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, ChunkType, CodeHardwareFeasibilityEvaluator, CodeLab, type ComprehensiveAcademicReport, ConstructiveAlignmentEvaluator, type ContextInjectionMeta, type ContextSourceKey, CoverageGateReport, CrossArtifactDriftEvaluator, CurriculumError, type CurriculumErrorCode, type CurriculumErrorDetail, CurriculumPlan, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DEFAULT_VIETNAMESE_SECTION_HEADINGS, DependencyEdge, type DependencyValidationResult, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuiz, DiagnosticQuizInput, type DimensionScore, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, type ExcerptOptions, type ExcerptResult, type ExecuteCommandResult, ExpositionApprovalError, type ExpositionLlmFn, type ExpositionResult, type ExpositionStorage, type ExtractedJson, type ExtractedStreamChunk, type FindingSeverity, FiveEInstructionalEvaluator, type FrameworkLintFinding, type FrameworkLintReport, FrameworkPack, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, type GenerateExpositionOptions, GeneratedSlideArraySchema, GeneratedSlideSchema, HANDOUT_TEMPLATE, HybridBlueprintArraySchema, HybridBlueprintItemSchema, HybridDeckSlideArraySchema, HybridDeckSlideSchema, HybridPipelineError, ICurriculumStorage, LAYER_IDLE_BUDGET_MS, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, type LayerChunkCallback, type LayerPrefillOptions, type LayerPrefillResult, type LayoutBoxConfig, LessonPlan, MisconceptionEvaluator, ModelResolutionOptions, PROJECT_INSTRUCTION_TEMPLATE, type PackingSpec, type PedagogicalModel, type PipelineExecutionProgress, PlanConstraints, type PlanOptions, type PlanResult, type PlannerLlmFn, PlanningGraph, PlanningNode, type PrefillProviderEvent, type PreliminaryResearchResult, type ProduceLessonOptions, type ProduceLessonResult, type ProjectBriefingData, type ProjectClarification, type ProjectCreationPayload, type ProjectIntentAnalysisResult, ProjectStatusReport, type ProjectionMeta, QUIZ_TEMPLATE, QualityAuditReport, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, ResolvedGateSettings, SATELLITE_LESSON_PRIORITIES, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STATION_ROTATION_TEMPLATE, type SlashCommandDefinition, SlideBlueprintArraySchema, SlideBlueprintItemSchema, SlideDeck, type SlideEngine, type SlideLayoutCategory, type SlideLayoutData, type SlideLayoutPreset, type SlideProductionWorkflowOptions, type SlideProductionWorkflowResult, SmartResumeContext, type StreamAbortHandle, type StreamBudget, type StreamChunkExtractor, StreamRunnerOptions, type SymbolLedgerResult, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TranslationPolicy, type TranslationTarget, type TranslationTrigger, type ValidationOptions, WORKSHEET_TEMPLATE, analyzeProjectCreationIntent, assertAcyclic, auditQualityReport, buildCurriculumContext, buildCurriculumPlan, buildDomainLexiconGuardrail, buildExpositionContext, buildExpositionExcerpt, buildHeadingDirective, buildLanguageDirective, buildLessonExcerpt, buildSectionAwareExcerpt, buildSessionSliceContext, closeTruncatedJson, computePackingSpec, conductPreliminaryResearch, createAiInferenceError, createContextMissingError, createStreamAbortSignal, createStreamChunkExtractor, detectProjectPedagogy, emitUsage, ensureExpositionForLesson, ensureKnowledgeExposition, executeCurriculumCommand, executeSlideProductionWorkflow, expositionCacheKey, extractJsonArray, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, extractSymbolLedger, generatePhase1SotArtifacts, generatePhase2SotArtifacts, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, ingestProjectGraphIntoProject, initializeProjectInStorage, isExpositionFresh, isTranslationDue, lintCurriculumFramework, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, renderFrameworkFromPlan, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, safeParseJson, slugifyProjectName, streamLLMWithFallback, streamLayerPrefillWithFallback, stripLlmJsonWrappers, targetLanguageDisplayName, topoSort, validateArtifactDependencies, validateHybridDeckSlides };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { ActiveLearningWorkflow, ActiveLearningWorkflowSchema, ActivityLabSchema
|
|
|
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
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-
|
|
7
|
-
export { A as AggregatedToolCall,
|
|
6
|
+
import { S as StreamRunnerOptions, C as ChunkType } from './streamRunner-BzlJrAGZ.js';
|
|
7
|
+
export { A as AggregatedToolCall, a as ChatMessage, 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, c as getDesignatedFallbackConfig, b as isModelAllowed, i as isProviderEnabled, r as resolveApiKey, k as runCurriculumAIInference, s as streamCurriculumAIInference } from './streamRunner-BzlJrAGZ.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';
|
|
@@ -431,6 +431,17 @@ declare class DeterministicPipelineRunner {
|
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/** Lifecycle event for one cascade candidate — hosts forward it to the UI so a
|
|
435
|
+
* silent model switch (idle-timeout failover) is never invisible again. */
|
|
436
|
+
interface PrefillProviderEvent {
|
|
437
|
+
type: 'candidate-start' | 'candidate-failed' | 'candidate-success';
|
|
438
|
+
provider: string;
|
|
439
|
+
model: string;
|
|
440
|
+
attempt: number;
|
|
441
|
+
total: number;
|
|
442
|
+
elapsedMs: number;
|
|
443
|
+
error?: string;
|
|
444
|
+
}
|
|
434
445
|
interface LayerPrefillOptions {
|
|
435
446
|
action?: 'prefill' | 'research';
|
|
436
447
|
targetLayer?: number;
|
|
@@ -448,6 +459,27 @@ interface LayerPrefillOptions {
|
|
|
448
459
|
idleTimeoutMs?: number;
|
|
449
460
|
/** Optional parent abort signal (e.g. from HTTP request) to stop immediately on client disconnect. */
|
|
450
461
|
signal?: AbortSignal;
|
|
462
|
+
/**
|
|
463
|
+
* Host-provided inference override (Vercel AI SDK tiered gateway, test stubs).
|
|
464
|
+
* Same contract as StreamRunnerOptions['customInference']. When set it is the
|
|
465
|
+
* SOLE inference path: the built-in cascade (streamLLMWithFallback) never runs,
|
|
466
|
+
* so host apps that mandate one auditable gateway (Langfuse tracing, raw-wire
|
|
467
|
+
* idle kicks, reasoning_content extraction) get exactly that engine here too.
|
|
468
|
+
* Mirrors the unified-tracing mandate already enforced in lesson/chat/slide paths.
|
|
469
|
+
*/
|
|
470
|
+
customInference?: (request: {
|
|
471
|
+
systemInstruction: string;
|
|
472
|
+
userPrompt: string;
|
|
473
|
+
messages: Array<{
|
|
474
|
+
role: 'user' | 'assistant' | 'system' | 'model';
|
|
475
|
+
content: string;
|
|
476
|
+
}>;
|
|
477
|
+
temperature: number;
|
|
478
|
+
maxTokens: number;
|
|
479
|
+
onChunk: (token: string, type: ChunkType) => void;
|
|
480
|
+
}) => Promise<string>;
|
|
481
|
+
/** Observe cascade candidate transitions (start/fail/success) for UI status. */
|
|
482
|
+
onProviderEvent?: (event: PrefillProviderEvent) => void;
|
|
451
483
|
}
|
|
452
484
|
interface PreliminaryResearchResult {
|
|
453
485
|
groundTruthSummary: string;
|
|
@@ -568,7 +600,7 @@ declare function safeParseJson<T = any>(rawText: string | null): T | null;
|
|
|
568
600
|
/**
|
|
569
601
|
* Multi-tiered resilient streaming inference helper using 100% Vercel AI SDK.
|
|
570
602
|
*/
|
|
571
|
-
declare function streamLLMWithFallback(systemPrompt: string, userPrompt: string, apiKeys?: Record<string, string>, onChunk?: LayerChunkCallback, preferredModel?: string, preferredProvider?: AIProviderName, budget?: StreamBudget, signal?: AbortSignal): Promise<string | null>;
|
|
603
|
+
declare function streamLLMWithFallback(systemPrompt: string, userPrompt: string, apiKeys?: Record<string, string>, onChunk?: LayerChunkCallback, preferredModel?: string, preferredProvider?: AIProviderName, budget?: StreamBudget, signal?: AbortSignal, onEvent?: (event: PrefillProviderEvent) => void): Promise<string | null>;
|
|
572
604
|
/**
|
|
573
605
|
* Conducts preliminary ecosystem research for a course project.
|
|
574
606
|
*/
|
|
@@ -1437,4 +1469,4 @@ declare function getSlideLayoutPresetById(id: string): SlideLayoutPreset | undef
|
|
|
1437
1469
|
*/
|
|
1438
1470
|
declare function getSlideLayoutPresetsByCategory(category: SlideLayoutCategory): SlideLayoutPreset[];
|
|
1439
1471
|
|
|
1440
|
-
export { ACT_TEMPLATE, AIProviderName, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, type AcademicAuditFinding, AcademicAuditor, type AcademicDimension, ActivityLab, type ArtifactDependencyRule, type ArtifactProductionSpec, type AuditBundleInput, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BloomTaxonomyEvaluator, type BuildContextOptions, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, CodeHardwareFeasibilityEvaluator, CodeLab, type ComprehensiveAcademicReport, ConstructiveAlignmentEvaluator, type ContextInjectionMeta, type ContextSourceKey, CoverageGateReport, CrossArtifactDriftEvaluator, CurriculumError, type CurriculumErrorCode, type CurriculumErrorDetail, CurriculumPlan, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DEFAULT_VIETNAMESE_SECTION_HEADINGS, DependencyEdge, type DependencyValidationResult, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuiz, DiagnosticQuizInput, type DimensionScore, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, type ExcerptOptions, type ExcerptResult, type ExecuteCommandResult, ExpositionApprovalError, type ExpositionLlmFn, type ExpositionResult, type ExpositionStorage, type ExtractedJson, type ExtractedStreamChunk, type FindingSeverity, FiveEInstructionalEvaluator, type FrameworkLintFinding, type FrameworkLintReport, FrameworkPack, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, type GenerateExpositionOptions, GeneratedSlideArraySchema, GeneratedSlideSchema, HANDOUT_TEMPLATE, HybridBlueprintArraySchema, HybridBlueprintItemSchema, HybridDeckSlideArraySchema, HybridDeckSlideSchema, HybridPipelineError, ICurriculumStorage, LAYER_IDLE_BUDGET_MS, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, type LayerChunkCallback, type LayerPrefillOptions, type LayerPrefillResult, type LayoutBoxConfig, LessonPlan, MisconceptionEvaluator, ModelResolutionOptions, PROJECT_INSTRUCTION_TEMPLATE, type PackingSpec, type PedagogicalModel, type PipelineExecutionProgress, PlanConstraints, type PlanOptions, type PlanResult, type PlannerLlmFn, PlanningGraph, PlanningNode, type PreliminaryResearchResult, type ProduceLessonOptions, type ProduceLessonResult, type ProjectBriefingData, type ProjectClarification, type ProjectCreationPayload, type ProjectIntentAnalysisResult, ProjectStatusReport, type ProjectionMeta, QUIZ_TEMPLATE, QualityAuditReport, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, ResolvedGateSettings, SATELLITE_LESSON_PRIORITIES, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STATION_ROTATION_TEMPLATE, type SlashCommandDefinition, SlideBlueprintArraySchema, SlideBlueprintItemSchema, SlideDeck, type SlideEngine, type SlideLayoutCategory, type SlideLayoutData, type SlideLayoutPreset, type SlideProductionWorkflowOptions, type SlideProductionWorkflowResult, SmartResumeContext, type StreamAbortHandle, type StreamBudget, type StreamChunkExtractor, StreamRunnerOptions, type SymbolLedgerResult, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TranslationPolicy, type TranslationTarget, type TranslationTrigger, type ValidationOptions, WORKSHEET_TEMPLATE, analyzeProjectCreationIntent, assertAcyclic, auditQualityReport, buildCurriculumContext, buildCurriculumPlan, buildDomainLexiconGuardrail, buildExpositionContext, buildExpositionExcerpt, buildHeadingDirective, buildLanguageDirective, buildLessonExcerpt, buildSectionAwareExcerpt, buildSessionSliceContext, closeTruncatedJson, computePackingSpec, conductPreliminaryResearch, createAiInferenceError, createContextMissingError, createStreamAbortSignal, createStreamChunkExtractor, detectProjectPedagogy, emitUsage, ensureExpositionForLesson, ensureKnowledgeExposition, executeCurriculumCommand, executeSlideProductionWorkflow, expositionCacheKey, extractJsonArray, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, extractSymbolLedger, generatePhase1SotArtifacts, generatePhase2SotArtifacts, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, ingestProjectGraphIntoProject, initializeProjectInStorage, isExpositionFresh, isTranslationDue, lintCurriculumFramework, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, renderFrameworkFromPlan, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, safeParseJson, slugifyProjectName, streamLLMWithFallback, streamLayerPrefillWithFallback, stripLlmJsonWrappers, targetLanguageDisplayName, topoSort, validateArtifactDependencies, validateHybridDeckSlides };
|
|
1472
|
+
export { ACT_TEMPLATE, AIProviderName, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, type AcademicAuditFinding, AcademicAuditor, type AcademicDimension, ActivityLab, type ArtifactDependencyRule, type ArtifactProductionSpec, type AuditBundleInput, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BloomTaxonomyEvaluator, type BuildContextOptions, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, ChunkType, CodeHardwareFeasibilityEvaluator, CodeLab, type ComprehensiveAcademicReport, ConstructiveAlignmentEvaluator, type ContextInjectionMeta, type ContextSourceKey, CoverageGateReport, CrossArtifactDriftEvaluator, CurriculumError, type CurriculumErrorCode, type CurriculumErrorDetail, CurriculumPlan, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DEFAULT_VIETNAMESE_SECTION_HEADINGS, DependencyEdge, type DependencyValidationResult, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuiz, DiagnosticQuizInput, type DimensionScore, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, type ExcerptOptions, type ExcerptResult, type ExecuteCommandResult, ExpositionApprovalError, type ExpositionLlmFn, type ExpositionResult, type ExpositionStorage, type ExtractedJson, type ExtractedStreamChunk, type FindingSeverity, FiveEInstructionalEvaluator, type FrameworkLintFinding, type FrameworkLintReport, FrameworkPack, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, type GenerateExpositionOptions, GeneratedSlideArraySchema, GeneratedSlideSchema, HANDOUT_TEMPLATE, HybridBlueprintArraySchema, HybridBlueprintItemSchema, HybridDeckSlideArraySchema, HybridDeckSlideSchema, HybridPipelineError, ICurriculumStorage, LAYER_IDLE_BUDGET_MS, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, type LayerChunkCallback, type LayerPrefillOptions, type LayerPrefillResult, type LayoutBoxConfig, LessonPlan, MisconceptionEvaluator, ModelResolutionOptions, PROJECT_INSTRUCTION_TEMPLATE, type PackingSpec, type PedagogicalModel, type PipelineExecutionProgress, PlanConstraints, type PlanOptions, type PlanResult, type PlannerLlmFn, PlanningGraph, PlanningNode, type PrefillProviderEvent, type PreliminaryResearchResult, type ProduceLessonOptions, type ProduceLessonResult, type ProjectBriefingData, type ProjectClarification, type ProjectCreationPayload, type ProjectIntentAnalysisResult, ProjectStatusReport, type ProjectionMeta, QUIZ_TEMPLATE, QualityAuditReport, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, ResolvedGateSettings, SATELLITE_LESSON_PRIORITIES, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STATION_ROTATION_TEMPLATE, type SlashCommandDefinition, SlideBlueprintArraySchema, SlideBlueprintItemSchema, SlideDeck, type SlideEngine, type SlideLayoutCategory, type SlideLayoutData, type SlideLayoutPreset, type SlideProductionWorkflowOptions, type SlideProductionWorkflowResult, SmartResumeContext, type StreamAbortHandle, type StreamBudget, type StreamChunkExtractor, StreamRunnerOptions, type SymbolLedgerResult, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TranslationPolicy, type TranslationTarget, type TranslationTrigger, type ValidationOptions, WORKSHEET_TEMPLATE, analyzeProjectCreationIntent, assertAcyclic, auditQualityReport, buildCurriculumContext, buildCurriculumPlan, buildDomainLexiconGuardrail, buildExpositionContext, buildExpositionExcerpt, buildHeadingDirective, buildLanguageDirective, buildLessonExcerpt, buildSectionAwareExcerpt, buildSessionSliceContext, closeTruncatedJson, computePackingSpec, conductPreliminaryResearch, createAiInferenceError, createContextMissingError, createStreamAbortSignal, createStreamChunkExtractor, detectProjectPedagogy, emitUsage, ensureExpositionForLesson, ensureKnowledgeExposition, executeCurriculumCommand, executeSlideProductionWorkflow, expositionCacheKey, extractJsonArray, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, extractSymbolLedger, generatePhase1SotArtifacts, generatePhase2SotArtifacts, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, ingestProjectGraphIntoProject, initializeProjectInStorage, isExpositionFresh, isTranslationDue, lintCurriculumFramework, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, renderFrameworkFromPlan, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, safeParseJson, slugifyProjectName, streamLLMWithFallback, streamLayerPrefillWithFallback, stripLlmJsonWrappers, targetLanguageDisplayName, topoSort, validateArtifactDependencies, validateHybridDeckSlides };
|
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
|
}
|
|
@@ -29460,7 +29507,7 @@ function safeParseJson(rawText) {
|
|
|
29460
29507
|
}
|
|
29461
29508
|
return null;
|
|
29462
29509
|
}
|
|
29463
|
-
async function streamLLMWithFallback(systemPrompt, userPrompt, apiKeys = {}, onChunk, preferredModel, preferredProvider, budget, signal) {
|
|
29510
|
+
async function streamLLMWithFallback(systemPrompt, userPrompt, apiKeys = {}, onChunk, preferredModel, preferredProvider, budget, signal, onEvent) {
|
|
29464
29511
|
const alibabaKey = apiKeys.alibaba || apiKeys.dashscope || process.env.ALIBABA_API_KEY || process.env.DASHSCOPE_API_KEY;
|
|
29465
29512
|
const nvidiaKey = apiKeys.nvidia || process.env.NVIDIA_API_KEY;
|
|
29466
29513
|
const deepseekKey = apiKeys.deepseek || process.env.DEEPSEEK_API_KEY;
|
|
@@ -29541,12 +29588,14 @@ THINKING DIRECTIVE: Do ALL your reasoning internally BEFORE emitting output. Do
|
|
|
29541
29588
|
idleMs: budget?.idleMs ?? DEFAULT_STREAM_IDLE_MS,
|
|
29542
29589
|
totalMs: budget?.totalMs ?? DEFAULT_STREAM_TOTAL_MS
|
|
29543
29590
|
};
|
|
29544
|
-
for (const candidate of candidates) {
|
|
29591
|
+
for (const [candidateIdx, candidate] of candidates.entries()) {
|
|
29545
29592
|
if (signal?.aborted) {
|
|
29546
29593
|
console.log(`[curriculum-kit:VercelAI] AbortSignal already aborted, cancelling candidate loop.`);
|
|
29547
29594
|
break;
|
|
29548
29595
|
}
|
|
29549
29596
|
const t0 = Date.now();
|
|
29597
|
+
const attempt = candidateIdx + 1;
|
|
29598
|
+
onEvent?.({ type: "candidate-start", provider: candidate.provider, model: candidate.model, attempt, total: candidates.length, elapsedMs: 0 });
|
|
29550
29599
|
const abort = createStreamAbortSignal(resolvedBudget, signal);
|
|
29551
29600
|
try {
|
|
29552
29601
|
const modelInstance = getAIModel({
|
|
@@ -29554,18 +29603,35 @@ THINKING DIRECTIVE: Do ALL your reasoning internally BEFORE emitting output. Do
|
|
|
29554
29603
|
modelName: candidate.model,
|
|
29555
29604
|
apiKey: candidate.apiKey
|
|
29556
29605
|
});
|
|
29606
|
+
const wireFetch = (input, init) => fetch(input, init).then((res) => {
|
|
29607
|
+
if (!res.body) return res;
|
|
29608
|
+
const kicked = res.body.pipeThrough(
|
|
29609
|
+
new TransformStream({
|
|
29610
|
+
transform(chunk, ctrl) {
|
|
29611
|
+
abort.kick();
|
|
29612
|
+
ctrl.enqueue(chunk);
|
|
29613
|
+
}
|
|
29614
|
+
})
|
|
29615
|
+
);
|
|
29616
|
+
return new Response(kicked, res);
|
|
29617
|
+
});
|
|
29557
29618
|
const streamResult = streamText({
|
|
29558
29619
|
model: modelInstance,
|
|
29559
29620
|
system: systemInstructions,
|
|
29560
29621
|
prompt: userPrompt,
|
|
29561
29622
|
temperature: 0.2,
|
|
29562
29623
|
includeRawChunks: true,
|
|
29563
|
-
abortSignal: abort.signal
|
|
29624
|
+
abortSignal: abort.signal,
|
|
29625
|
+
fetch: wireFetch
|
|
29564
29626
|
});
|
|
29565
29627
|
let fullContent = "";
|
|
29566
29628
|
const extract = createStreamChunkExtractor();
|
|
29567
29629
|
for await (const part of streamResult.fullStream) {
|
|
29568
29630
|
abort.kick();
|
|
29631
|
+
if (part?.type === "error") {
|
|
29632
|
+
const errText = part.errorText ?? String(part.error ?? "unknown stream error");
|
|
29633
|
+
throw new Error(`[${candidate.provider}] stream error part: ${errText}`);
|
|
29634
|
+
}
|
|
29569
29635
|
const extracted = extract(part);
|
|
29570
29636
|
if (extracted.thought) onChunk?.(extracted.thought, "thought");
|
|
29571
29637
|
if (extracted.content) {
|
|
@@ -29575,10 +29641,14 @@ THINKING DIRECTIVE: Do ALL your reasoning internally BEFORE emitting output. Do
|
|
|
29575
29641
|
}
|
|
29576
29642
|
if (fullContent.trim()) {
|
|
29577
29643
|
console.log(`[curriculum-kit:VercelAI] \u2705 ${candidate.provider} (${candidate.model}) streamed in ${Date.now() - t0}ms`);
|
|
29644
|
+
onEvent?.({ type: "candidate-success", provider: candidate.provider, model: candidate.model, attempt, total: candidates.length, elapsedMs: Date.now() - t0 });
|
|
29578
29645
|
return fullContent.trim();
|
|
29579
29646
|
}
|
|
29647
|
+
console.warn(`[curriculum-kit:VercelAI] Candidate ${candidate.provider} (${candidate.model}) returned EMPTY content in ${Date.now() - t0}ms \u2192 trying next candidate.`);
|
|
29648
|
+
onEvent?.({ type: "candidate-failed", provider: candidate.provider, model: candidate.model, attempt, total: candidates.length, elapsedMs: Date.now() - t0, error: "empty content" });
|
|
29580
29649
|
} catch (e) {
|
|
29581
29650
|
console.warn(`[curriculum-kit:VercelAI] Candidate ${candidate.provider} (${candidate.model}) failed in ${Date.now() - t0}ms:`, e?.message || e);
|
|
29651
|
+
onEvent?.({ type: "candidate-failed", provider: candidate.provider, model: candidate.model, attempt, total: candidates.length, elapsedMs: Date.now() - t0, error: e?.message || String(e) });
|
|
29582
29652
|
const isClientAborted = Boolean(
|
|
29583
29653
|
signal?.aborted || e?.name === "AbortError" && signal?.aborted || e?.message && (e.message.includes("Controller is already closed") || e.message.includes("The operation was aborted") || e.message.includes("Aborted by parent signal"))
|
|
29584
29654
|
);
|
|
@@ -29638,7 +29708,8 @@ Return concise JSON matching:
|
|
|
29638
29708
|
model: options.model,
|
|
29639
29709
|
provider: options.provider
|
|
29640
29710
|
}),
|
|
29641
|
-
options.signal
|
|
29711
|
+
options.signal,
|
|
29712
|
+
options.onProviderEvent
|
|
29642
29713
|
);
|
|
29643
29714
|
let parsedResearch = {
|
|
29644
29715
|
groundTruthSummary: `Verified ecosystem standards for ${projectName}`,
|
|
@@ -29720,6 +29791,23 @@ async function streamLayerPrefillWithFallback(options, onChunk) {
|
|
|
29720
29791
|
const research = await conductPreliminaryResearch(options, onChunk);
|
|
29721
29792
|
return { success: true, research };
|
|
29722
29793
|
}
|
|
29794
|
+
const runWithCustomInference = async (systemInstruction, userPrompt2) => {
|
|
29795
|
+
if (!options.customInference) return "";
|
|
29796
|
+
return options.customInference({
|
|
29797
|
+
systemInstruction,
|
|
29798
|
+
userPrompt: userPrompt2,
|
|
29799
|
+
messages: [{ role: "user", content: userPrompt2 }],
|
|
29800
|
+
temperature: 0.2,
|
|
29801
|
+
// Layer 3 synthesizes full context — give reasoning models the same
|
|
29802
|
+
// generous ceiling the artifact paths use (32k) so JSON is never truncated.
|
|
29803
|
+
maxTokens: 32768,
|
|
29804
|
+
onChunk: (token, type) => {
|
|
29805
|
+
if (type === "content") rawContent += token;
|
|
29806
|
+
if (type === "content" || type === "thought") onChunk?.(token, type);
|
|
29807
|
+
}
|
|
29808
|
+
});
|
|
29809
|
+
};
|
|
29810
|
+
let rawContent = "";
|
|
29723
29811
|
const {
|
|
29724
29812
|
projectName = "Curriculum Course",
|
|
29725
29813
|
projectCode = "curriculum-course",
|
|
@@ -29831,27 +29919,31 @@ FULL ACCUMULATED CONTEXT (ALL CONFIRMED PARAMETERS FROM EVERY PREVIOUS STEP \u20
|
|
|
29831
29919
|
${buildRemainingContextBlock(accumulatedData) || "(no additional context)"}
|
|
29832
29920
|
|
|
29833
29921
|
REQUIREMENT: Synthesize ALL parameters above \u2014 every single line in FULL ACCUMULATED CONTEXT is a confirmed user decision or system constraint and MUST influence the generated configuration. Produce the high-fidelity pre-fill configuration for LAYER ${targetLayer}.`;
|
|
29834
|
-
|
|
29835
|
-
|
|
29836
|
-
|
|
29837
|
-
|
|
29838
|
-
|
|
29839
|
-
|
|
29840
|
-
|
|
29841
|
-
|
|
29842
|
-
|
|
29843
|
-
|
|
29844
|
-
|
|
29845
|
-
|
|
29846
|
-
|
|
29847
|
-
|
|
29848
|
-
|
|
29849
|
-
|
|
29850
|
-
|
|
29851
|
-
|
|
29852
|
-
|
|
29853
|
-
|
|
29854
|
-
|
|
29922
|
+
if (options.customInference) {
|
|
29923
|
+
rawContent = await runWithCustomInference(systemPrompt, userPrompt) || "";
|
|
29924
|
+
} else {
|
|
29925
|
+
await streamLLMWithFallback(
|
|
29926
|
+
systemPrompt,
|
|
29927
|
+
userPrompt,
|
|
29928
|
+
apiKeys,
|
|
29929
|
+
(chunk, type) => {
|
|
29930
|
+
if (type === "content") rawContent += chunk;
|
|
29931
|
+
onChunk?.(chunk, type);
|
|
29932
|
+
},
|
|
29933
|
+
options.model,
|
|
29934
|
+
options.provider,
|
|
29935
|
+
// RC-W1: layer-aware budget — Layer 3 synthesizes full context and free-tier
|
|
29936
|
+
// models (especially NVIDIA NIM) may think/stream for minutes. Idle window still catches hangs.
|
|
29937
|
+
resolveStreamBudget(targetLayer, {
|
|
29938
|
+
idleMs: options.idleTimeoutMs,
|
|
29939
|
+
totalMs: options.timeoutMs,
|
|
29940
|
+
model: options.model,
|
|
29941
|
+
provider: options.provider
|
|
29942
|
+
}),
|
|
29943
|
+
options.signal,
|
|
29944
|
+
options.onProviderEvent
|
|
29945
|
+
);
|
|
29946
|
+
}
|
|
29855
29947
|
const parsed = safeParseJson(rawContent);
|
|
29856
29948
|
return {
|
|
29857
29949
|
success: !!parsed,
|