@thanh01.pmt/curriculum-kit 1.0.8 → 1.0.10

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.
Files changed (42) hide show
  1. package/dist/ai/index.cjs +36 -10
  2. package/dist/ai/index.cjs.map +1 -1
  3. package/dist/ai/index.d.cts +5 -5
  4. package/dist/ai/index.d.ts +5 -5
  5. package/dist/ai/index.mjs +36 -10
  6. package/dist/ai/index.mjs.map +1 -1
  7. package/dist/{index-BfDHBO7f.d.ts → index-B8lOdFuz.d.ts} +1 -1
  8. package/dist/{index-BEicVaQ9.d.cts → index-DhxvfPoW.d.cts} +1 -1
  9. package/dist/index.cjs +43 -16
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +6 -6
  12. package/dist/index.d.ts +6 -6
  13. package/dist/index.mjs +43 -16
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/media/index.cjs +30 -4
  16. package/dist/media/index.cjs.map +1 -1
  17. package/dist/media/index.d.cts +1 -1
  18. package/dist/media/index.d.ts +1 -1
  19. package/dist/media/index.mjs +30 -4
  20. package/dist/media/index.mjs.map +1 -1
  21. package/dist/{milestoneBundleGenerator-CbXhs1CP.d.ts → milestoneBundleGenerator-Bkba8OPG.d.ts} +1 -1
  22. package/dist/{milestoneBundleGenerator-DrBtHzBO.d.cts → milestoneBundleGenerator-CzSOeAzU.d.cts} +1 -1
  23. package/dist/pipeline/index.cjs +5 -5
  24. package/dist/pipeline/index.cjs.map +1 -1
  25. package/dist/pipeline/index.d.cts +3 -3
  26. package/dist/pipeline/index.d.ts +3 -3
  27. package/dist/pipeline/index.mjs +5 -5
  28. package/dist/pipeline/index.mjs.map +1 -1
  29. package/dist/{provider-factory-DH3udYlN.d.ts → provider-factory-DxzOVEmh.d.cts} +1 -1
  30. package/dist/{provider-factory-DH3udYlN.d.cts → provider-factory-DxzOVEmh.d.ts} +1 -1
  31. package/dist/storage/index.d.cts +2 -2
  32. package/dist/storage/index.d.ts +2 -2
  33. package/dist/{streamRunner-C7j5LKon.d.cts → streamRunner-CcpmxOf1.d.cts} +20 -1
  34. package/dist/{streamRunner-C7j5LKon.d.ts → streamRunner-CcpmxOf1.d.ts} +20 -1
  35. package/dist/workflow/index.cjs +33 -7
  36. package/dist/workflow/index.cjs.map +1 -1
  37. package/dist/workflow/index.d.cts +2 -2
  38. package/dist/workflow/index.d.ts +2 -2
  39. package/dist/workflow/index.mjs +33 -7
  40. package/dist/workflow/index.mjs.map +1 -1
  41. package/package.json +22 -21
  42. package/LICENSE +0 -21
@@ -9,7 +9,7 @@ interface ModelResolutionOptions {
9
9
  }
10
10
  declare const NVIDIA_MODELS: {
11
11
  readonly codingFast: "nvidia/nemotron-3.5-lightning-30b-a3b";
12
- readonly reasoningUltra: "nvidia/nemotron-3-ultra-550b-a55b";
12
+ readonly reasoningUltra: "nvidia/nemotron-3-ultra-550b-a55b:free";
13
13
  readonly superMoE: "nvidia/nemotron-3-super-120b-a12b";
14
14
  readonly llamaNemotron: "nvidia/llama-3.1-nemotron-70b-instruct";
15
15
  readonly translation: "nvidia/riva-translate-4b-instruct-v2";
@@ -9,7 +9,7 @@ interface ModelResolutionOptions {
9
9
  }
10
10
  declare const NVIDIA_MODELS: {
11
11
  readonly codingFast: "nvidia/nemotron-3.5-lightning-30b-a3b";
12
- readonly reasoningUltra: "nvidia/nemotron-3-ultra-550b-a55b";
12
+ readonly reasoningUltra: "nvidia/nemotron-3-ultra-550b-a55b:free";
13
13
  readonly superMoE: "nvidia/nemotron-3-super-120b-a12b";
14
14
  readonly llamaNemotron: "nvidia/llama-3.1-nemotron-70b-instruct";
15
15
  readonly translation: "nvidia/riva-translate-4b-instruct-v2";
@@ -1,10 +1,10 @@
1
1
  import { I as ICurriculumStorage, a as SotDocument, L as LessonArtifactSummary, P as ProjectStatusReport, c as PipelineState, b as ArtifactLifecycleInfo } from '../types-BUJGYiep.cjs';
2
2
  export { A as ArtifactLifecycleState, Q as QualityAuditReport, R as ReviewRecord, S as SmartResumeContext, T as TaskLifecycleState } from '../types-BUJGYiep.cjs';
3
3
  import { SupabaseClient } from '@supabase/supabase-js';
4
- import { M as MilestoneCurriculumBundle } from '../milestoneBundleGenerator-DrBtHzBO.cjs';
4
+ import { M as MilestoneCurriculumBundle } from '../milestoneBundleGenerator-CzSOeAzU.cjs';
5
5
  import '../schemas/index.cjs';
6
6
  import 'zod';
7
- import '../provider-factory-DH3udYlN.cjs';
7
+ import '../provider-factory-DxzOVEmh.cjs';
8
8
  import 'ai';
9
9
 
10
10
  declare function computeContentHash(content: string): string;
@@ -1,10 +1,10 @@
1
1
  import { I as ICurriculumStorage, a as SotDocument, L as LessonArtifactSummary, P as ProjectStatusReport, c as PipelineState, b as ArtifactLifecycleInfo } from '../types-BUJGYiep.js';
2
2
  export { A as ArtifactLifecycleState, Q as QualityAuditReport, R as ReviewRecord, S as SmartResumeContext, T as TaskLifecycleState } from '../types-BUJGYiep.js';
3
3
  import { SupabaseClient } from '@supabase/supabase-js';
4
- import { M as MilestoneCurriculumBundle } from '../milestoneBundleGenerator-CbXhs1CP.js';
4
+ import { M as MilestoneCurriculumBundle } from '../milestoneBundleGenerator-Bkba8OPG.js';
5
5
  import '../schemas/index.js';
6
6
  import 'zod';
7
- import '../provider-factory-DH3udYlN.js';
7
+ import '../provider-factory-DxzOVEmh.js';
8
8
  import 'ai';
9
9
 
10
10
  declare function computeContentHash(content: string): string;
@@ -15,6 +15,25 @@ interface StreamRunnerOptions {
15
15
  maxTokens?: number;
16
16
  temperature?: number;
17
17
  reasoningEffort?: 'off' | 'low' | 'medium' | 'high' | 'max';
18
+ /**
19
+ * Host-provided inference override (Vercel AI SDK gateway, test stubs, …).
20
+ * When set, ALL built-in provider routes (raw-fetch NVIDIA/OpenRouter/
21
+ * DeepSeek/DashScope/Gemini + designated fallback chain) are bypassed and
22
+ * every inference call goes through this function instead. It receives the
23
+ * fully-formed system instruction (persona + project context + guidelines)
24
+ * and the user prompt, plus the same onChunk contract as the built-in
25
+ * routes: stream text deltas via ('content'|'thought'), and report token
26
+ * spend via onChunk(JSON.stringify({ promptTokens, completionTokens,
27
+ * totalTokens, reasoningTokens }), 'usage'). Return the full completion text.
28
+ */
29
+ customInference?: (request: {
30
+ systemInstruction: string;
31
+ userPrompt: string;
32
+ messages: ChatMessage[];
33
+ temperature: number;
34
+ maxTokens: number;
35
+ onChunk: (token: string, type: ChunkType) => void;
36
+ }) => Promise<string>;
18
37
  }
19
38
  /**
20
39
  * Checks if a specific AI provider is enabled via environment variables.
@@ -36,7 +55,7 @@ interface FallbackTarget {
36
55
  * Resolves the designated last-resort fallback chain from environment variables.
37
56
  * Comma-separated lists are parsed in left-to-right priority order:
38
57
  * - FALLBACK_AI_PROVIDER=nvidia,openrouter (Must be enabled / in ALLOWED_AI_PROVIDERS)
39
- * - FALLBACK_AI_MODEL=nvidia/nemotron-3-ultra-550b-a55b,@preset/coding-free,deepseek/deepseek-chat:free
58
+ * - FALLBACK_AI_MODEL=nvidia/nemotron-3-ultra-550b-a55b:free,@preset/coding-free,deepseek/deepseek-chat:free
40
59
  */
41
60
  declare function getDesignatedFallbackChain(): FallbackTarget[];
42
61
  declare function getDesignatedFallbackConfig(): FallbackTarget;
@@ -15,6 +15,25 @@ interface StreamRunnerOptions {
15
15
  maxTokens?: number;
16
16
  temperature?: number;
17
17
  reasoningEffort?: 'off' | 'low' | 'medium' | 'high' | 'max';
18
+ /**
19
+ * Host-provided inference override (Vercel AI SDK gateway, test stubs, …).
20
+ * When set, ALL built-in provider routes (raw-fetch NVIDIA/OpenRouter/
21
+ * DeepSeek/DashScope/Gemini + designated fallback chain) are bypassed and
22
+ * every inference call goes through this function instead. It receives the
23
+ * fully-formed system instruction (persona + project context + guidelines)
24
+ * and the user prompt, plus the same onChunk contract as the built-in
25
+ * routes: stream text deltas via ('content'|'thought'), and report token
26
+ * spend via onChunk(JSON.stringify({ promptTokens, completionTokens,
27
+ * totalTokens, reasoningTokens }), 'usage'). Return the full completion text.
28
+ */
29
+ customInference?: (request: {
30
+ systemInstruction: string;
31
+ userPrompt: string;
32
+ messages: ChatMessage[];
33
+ temperature: number;
34
+ maxTokens: number;
35
+ onChunk: (token: string, type: ChunkType) => void;
36
+ }) => Promise<string>;
18
37
  }
19
38
  /**
20
39
  * Checks if a specific AI provider is enabled via environment variables.
@@ -36,7 +55,7 @@ interface FallbackTarget {
36
55
  * Resolves the designated last-resort fallback chain from environment variables.
37
56
  * Comma-separated lists are parsed in left-to-right priority order:
38
57
  * - FALLBACK_AI_PROVIDER=nvidia,openrouter (Must be enabled / in ALLOWED_AI_PROVIDERS)
39
- * - FALLBACK_AI_MODEL=nvidia/nemotron-3-ultra-550b-a55b,@preset/coding-free,deepseek/deepseek-chat:free
58
+ * - FALLBACK_AI_MODEL=nvidia/nemotron-3-ultra-550b-a55b:free,@preset/coding-free,deepseek/deepseek-chat:free
40
59
  */
41
60
  declare function getDesignatedFallbackChain(): FallbackTarget[];
42
61
  declare function getDesignatedFallbackConfig(): FallbackTarget;
@@ -191,7 +191,7 @@ function isModelAllowed(model) {
191
191
  }
192
192
  function getDesignatedFallbackChain() {
193
193
  const rawProviders = resolveApiKey("FALLBACK_AI_PROVIDER") || resolveApiKey("FALLBACK_AI_PROVIDERS") || resolveApiKey("DEFAULT_AI_PROVIDER") || "nvidia,openrouter";
194
- const rawModels = resolveApiKey("FALLBACK_AI_MODEL") || resolveApiKey("FALLBACK_AI_MODELS") || resolveApiKey("DEFAULT_AI_MODEL") || "nvidia/nemotron-3-ultra-550b-a55b,@preset/coding-free,deepseek/deepseek-chat:free";
194
+ const rawModels = resolveApiKey("FALLBACK_AI_MODEL") || resolveApiKey("FALLBACK_AI_MODELS") || resolveApiKey("DEFAULT_AI_MODEL") || "nvidia/nemotron-3-ultra-550b-a55b:free,@preset/coding-free,deepseek/deepseek-chat:free";
195
195
  const providerList = rawProviders.split(",").map((p) => p.trim().toLowerCase()).filter((p) => p.length > 0 && isProviderEnabled(p));
196
196
  const modelList = rawModels.split(",").map((m) => m.trim()).filter((m) => m.length > 0 && isModelAllowed(m));
197
197
  const chain = [];
@@ -200,7 +200,7 @@ function getDesignatedFallbackChain() {
200
200
  if (provider === "nvidia") {
201
201
  providerModels = modelList.filter((m) => m.startsWith("nvidia/") || m.startsWith("meta/") || m.startsWith("mistralai/"));
202
202
  if (providerModels.length === 0) {
203
- providerModels = ["nvidia/nemotron-3-ultra-550b-a55b", "nvidia/nemotron-3.5-lightning-30b-a3b"];
203
+ providerModels = ["nvidia/nemotron-3-ultra-550b-a55b:free", "nvidia/nemotron-3.5-lightning-30b-a3b"];
204
204
  }
205
205
  } else if (provider === "openrouter") {
206
206
  providerModels = modelList.filter((m) => m.startsWith("@") || m.includes("/") || m.includes(":"));
@@ -236,7 +236,7 @@ function getDesignatedFallbackChain() {
236
236
  function getDesignatedFallbackConfig() {
237
237
  const chain = getDesignatedFallbackChain();
238
238
  if (chain.length > 0) return chain[0];
239
- return { provider: "nvidia", model: "nvidia/nemotron-3-ultra-550b-a55b" };
239
+ return { provider: "nvidia", model: "nvidia/nemotron-3-ultra-550b-a55b:free" };
240
240
  }
241
241
  function extractThoughtAndContent(rawText) {
242
242
  let text = rawText || "";
@@ -429,6 +429,32 @@ Guidelines:
429
429
  3. Keep technical terminology and official API symbols intact.
430
430
  4. Format output using clean Markdown, clear sections, bullet points, and code blocks where required.
431
431
  5. Do NOT use emojis in headings, tab titles, or UI navigation labels.`;
432
+ if (options.customInference) {
433
+ try {
434
+ const text = await options.customInference({
435
+ systemInstruction,
436
+ userPrompt: messages.map((m) => m.content).join("\n\n"),
437
+ messages,
438
+ temperature,
439
+ maxTokens,
440
+ onChunk: onChunk ?? (() => {
441
+ })
442
+ });
443
+ if (text && text.trim()) return text;
444
+ throw createAiInferenceError({
445
+ errorCode: "ERR_AI_ALL_PROVIDERS_FAILED",
446
+ message: "customInference returned empty output",
447
+ rawError: { customInference: "empty response" }
448
+ });
449
+ } catch (e) {
450
+ if (e?.errorCode || e?.name === "AiInferenceError") throw e;
451
+ throw createAiInferenceError({
452
+ errorCode: "ERR_AI_ALL_PROVIDERS_FAILED",
453
+ message: `customInference failed: ${e?.message || e}`,
454
+ rawError: { customInference: String(e?.message || e) }
455
+ });
456
+ }
457
+ }
432
458
  const formattedMessages = [
433
459
  { role: "system", content: systemInstruction },
434
460
  ...messages.map((m) => ({
@@ -441,8 +467,8 @@ Guidelines:
441
467
  const isNvidiaPreferred = requestedModel.startsWith("nvidia/") || Boolean(nvidiaKey && !openrouterKey) && isProviderEnabled("nvidia");
442
468
  if (nvidiaKey && isProviderEnabled("nvidia")) {
443
469
  const candidateNemotronModels = [
444
- requestedModel.startsWith("nvidia/") ? requestedModel : "nvidia/nemotron-3-ultra-550b-a55b",
445
- "nvidia/nemotron-3-ultra-550b-a55b",
470
+ requestedModel.startsWith("nvidia/") ? requestedModel : "nvidia/nemotron-3-ultra-550b-a55b:free",
471
+ "nvidia/nemotron-3-ultra-550b-a55b:free",
446
472
  "nvidia/nemotron-3.5-lightning-30b-a3b",
447
473
  "nvidia/nemotron-3-super-120b-a12b",
448
474
  "nvidia/llama-3.1-nemotron-70b-instruct"
@@ -804,7 +830,7 @@ var init_streamRunner = __esm({
804
830
  // src/ai/provider-factory.ts
805
831
  init_streamRunner();
806
832
  var DEFAULT_MODELS = {
807
- nvidia: "nvidia/nemotron-3-ultra-550b-a55b",
833
+ nvidia: "nvidia/nemotron-3-ultra-550b-a55b:free",
808
834
  openrouter: "@preset/coding-free",
809
835
  alibaba: "qwen3.7-plus",
810
836
  dashscope: "qwen3.7-plus",
@@ -832,7 +858,7 @@ function getAIModel(options = {}) {
832
858
  apiKey,
833
859
  baseURL: options.baseURL || "https://integrate.api.nvidia.com/v1"
834
860
  });
835
- return nvidia.chat(resolvedModelName || "nvidia/nemotron-3-ultra-550b-a55b");
861
+ return nvidia.chat(resolvedModelName || "nvidia/nemotron-3-ultra-550b-a55b:free");
836
862
  }
837
863
  if (provider === "openrouter") {
838
864
  const apiKey = options.apiKey || process.env.OPENROUTER_API_KEY || process.env.OPENAI_API_KEY || "";