@thanh01.pmt/curriculum-kit 1.4.29 → 1.4.31

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/index.d.cts CHANGED
@@ -765,7 +765,7 @@ declare function buildHeadingDirective(artifactType: string, slcMarkdown?: Recor
765
765
  * Provides typed, structured, and traceable error codes for all pipeline failures,
766
766
  * API exceptions, safeguard blocks, and contract violations.
767
767
  */
768
- type CurriculumErrorCode = 'ERR_AI_NO_API_KEY' | 'ERR_AI_RATE_LIMIT' | 'ERR_AI_AUTH_FAILED' | 'ERR_AI_NETWORK_TIMEOUT' | 'ERR_AI_RESPONSE_MALFORMED' | 'ERR_AI_ALL_PROVIDERS_FAILED' | 'ERR_SOT_MISSING' | 'ERR_SOT_INVALID_SCHEMA' | 'ERR_TASK_GATE_BLOCKED' | 'ERR_METERED_LIMIT_EXCEEDED' | 'ERR_SCHEMA_CONTRACT_VIOLATION' | 'ERR_STORAGE_IO_FAILED' | 'ERR_LESSON_NOT_IN_SOT' | 'ERR_CONTEXT_MISSING';
768
+ type CurriculumErrorCode = 'ERR_AI_NO_API_KEY' | 'ERR_AI_RATE_LIMIT' | 'ERR_AI_AUTH_FAILED' | 'ERR_AI_NETWORK_TIMEOUT' | 'ERR_AI_RESPONSE_MALFORMED' | 'ERR_AI_ALL_PROVIDERS_FAILED' | 'ERR_CUSTOM_INFERENCE_REQUIRED' | 'ERR_SOT_MISSING' | 'ERR_SOT_INVALID_SCHEMA' | 'ERR_TASK_GATE_BLOCKED' | 'ERR_METERED_LIMIT_EXCEEDED' | 'ERR_SCHEMA_CONTRACT_VIOLATION' | 'ERR_STORAGE_IO_FAILED' | 'ERR_LESSON_NOT_IN_SOT' | 'ERR_CONTEXT_MISSING';
769
769
  interface CurriculumErrorDetail {
770
770
  errorCode: CurriculumErrorCode;
771
771
  agent?: string;
@@ -1089,7 +1089,12 @@ interface SlideProductionWorkflowOptions {
1089
1089
  maxRetries?: number;
1090
1090
  /** Max output tokens for hybrid generateText calls. Default 65536. */
1091
1091
  maxOutputTokens?: number;
1092
- /** When true (default), falls back to the legacy raw-fetch runner if generateObject fails. */
1092
+ /** When true, ALSO allows the legacy raw-fetch runner as a structured-output
1093
+ * fallback after generateObject fails. Default FALSE (telemetry mandate,
1094
+ * 2026-09-14): the raw path is invisible to the unified OpenTelemetry →
1095
+ * Langfuse trace, so it must never run unless explicitly opted in. When
1096
+ * enabled, pass runnerOptions.customInference so the fallback stays traced
1097
+ * (and satisfies CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE=1). */
1093
1098
  allowLegacyFallback?: boolean;
1094
1099
  runnerOptions?: any;
1095
1100
  onProgress?: (agent: string, message: string, meta?: any) => void;
package/dist/index.d.ts CHANGED
@@ -765,7 +765,7 @@ declare function buildHeadingDirective(artifactType: string, slcMarkdown?: Recor
765
765
  * Provides typed, structured, and traceable error codes for all pipeline failures,
766
766
  * API exceptions, safeguard blocks, and contract violations.
767
767
  */
768
- type CurriculumErrorCode = 'ERR_AI_NO_API_KEY' | 'ERR_AI_RATE_LIMIT' | 'ERR_AI_AUTH_FAILED' | 'ERR_AI_NETWORK_TIMEOUT' | 'ERR_AI_RESPONSE_MALFORMED' | 'ERR_AI_ALL_PROVIDERS_FAILED' | 'ERR_SOT_MISSING' | 'ERR_SOT_INVALID_SCHEMA' | 'ERR_TASK_GATE_BLOCKED' | 'ERR_METERED_LIMIT_EXCEEDED' | 'ERR_SCHEMA_CONTRACT_VIOLATION' | 'ERR_STORAGE_IO_FAILED' | 'ERR_LESSON_NOT_IN_SOT' | 'ERR_CONTEXT_MISSING';
768
+ type CurriculumErrorCode = 'ERR_AI_NO_API_KEY' | 'ERR_AI_RATE_LIMIT' | 'ERR_AI_AUTH_FAILED' | 'ERR_AI_NETWORK_TIMEOUT' | 'ERR_AI_RESPONSE_MALFORMED' | 'ERR_AI_ALL_PROVIDERS_FAILED' | 'ERR_CUSTOM_INFERENCE_REQUIRED' | 'ERR_SOT_MISSING' | 'ERR_SOT_INVALID_SCHEMA' | 'ERR_TASK_GATE_BLOCKED' | 'ERR_METERED_LIMIT_EXCEEDED' | 'ERR_SCHEMA_CONTRACT_VIOLATION' | 'ERR_STORAGE_IO_FAILED' | 'ERR_LESSON_NOT_IN_SOT' | 'ERR_CONTEXT_MISSING';
769
769
  interface CurriculumErrorDetail {
770
770
  errorCode: CurriculumErrorCode;
771
771
  agent?: string;
@@ -1089,7 +1089,12 @@ interface SlideProductionWorkflowOptions {
1089
1089
  maxRetries?: number;
1090
1090
  /** Max output tokens for hybrid generateText calls. Default 65536. */
1091
1091
  maxOutputTokens?: number;
1092
- /** When true (default), falls back to the legacy raw-fetch runner if generateObject fails. */
1092
+ /** When true, ALSO allows the legacy raw-fetch runner as a structured-output
1093
+ * fallback after generateObject fails. Default FALSE (telemetry mandate,
1094
+ * 2026-09-14): the raw path is invisible to the unified OpenTelemetry →
1095
+ * Langfuse trace, so it must never run unless explicitly opted in. When
1096
+ * enabled, pass runnerOptions.customInference so the fallback stays traced
1097
+ * (and satisfies CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE=1). */
1093
1098
  allowLegacyFallback?: boolean;
1094
1099
  runnerOptions?: any;
1095
1100
  onProgress?: (agent: string, message: string, meta?: any) => void;
package/dist/index.mjs CHANGED
@@ -504,6 +504,13 @@ Guidelines:
504
504
  });
505
505
  }
506
506
  }
507
+ if (!options.customInference && resolveApiKey("CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE") === "1") {
508
+ throw createAiInferenceError({
509
+ errorCode: "ERR_CUSTOM_INFERENCE_REQUIRED",
510
+ message: "customInference is REQUIRED (CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE=1): pass buildKitCustomInference(...) so every LLM call flows through the host AI SDK gateway and its unified Langfuse tracing. Raw-fetch provider routes are disabled by mandate.",
511
+ rawError: { mandate: "CURRICULUM_KIT_REQUIRE_CUSTOM_INFERENCE", hasCustomInference: false }
512
+ });
513
+ }
507
514
  const formattedMessages = [
508
515
  { role: "system", content: systemInstruction },
509
516
  ...messages.map((m) => ({
@@ -1820,7 +1827,7 @@ async function inferStructured(schema, systemPrompt, userPrompt, options, label)
1820
1827
  } catch (aiSdkErr) {
1821
1828
  console.warn(`[SlideProductionWorkflow] AI SDK generateObject failed for ${label}:`, aiSdkErr?.message || aiSdkErr);
1822
1829
  }
1823
- if (options.allowLegacyFallback === false) return null;
1830
+ if (options.allowLegacyFallback !== true) return null;
1824
1831
  try {
1825
1832
  const messages = [
1826
1833
  { role: "user", content: [systemPrompt, userPrompt].filter(Boolean).join("\n\n") }