@thanh01.pmt/curriculum-kit 1.0.17 → 1.0.19

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.cjs CHANGED
@@ -13562,6 +13562,31 @@ function resolveStreamBudget(layer, opts) {
13562
13562
  totalMs: opts?.totalMs ?? (Number.isFinite(envTotal) && envTotal > 0 ? envTotal : layerTotal ?? DEFAULT_STREAM_TOTAL_MS)
13563
13563
  };
13564
13564
  }
13565
+ function createStreamChunkExtractor() {
13566
+ let thoughtSource = null;
13567
+ return (part) => {
13568
+ if (!part || typeof part !== "object") return {};
13569
+ if (part.type === "reasoning-delta" || part.type === "reasoning") {
13570
+ if (thoughtSource === null) thoughtSource = "mapped";
13571
+ if (thoughtSource !== "mapped") return {};
13572
+ const thought = part.text ?? part.delta ?? part.reasoning ?? "";
13573
+ return thought ? { thought } : {};
13574
+ }
13575
+ if (part.type === "text-delta") {
13576
+ const content = part.text ?? part.delta ?? "";
13577
+ return content ? { content } : {};
13578
+ }
13579
+ if (part.type === "raw") {
13580
+ if (thoughtSource === null) thoughtSource = "raw";
13581
+ if (thoughtSource !== "raw") return {};
13582
+ const raw = part.rawValue ?? part.raw ?? {};
13583
+ const delta = raw?.choices?.[0]?.delta ?? {};
13584
+ const reasoning = delta.reasoning_content ?? delta.reasoning ?? delta.thought ?? "";
13585
+ return reasoning ? { thought: reasoning } : {};
13586
+ }
13587
+ return {};
13588
+ };
13589
+ }
13565
13590
  function extractStreamChunk(part) {
13566
13591
  if (!part || typeof part !== "object") return {};
13567
13592
  if (part.type === "reasoning-delta" || part.type === "reasoning") {
@@ -13815,9 +13840,10 @@ THINKING DIRECTIVE: Keep reasoning concise, structured, and focused strictly on
13815
13840
  abortSignal: abort.signal
13816
13841
  });
13817
13842
  let fullContent = "";
13843
+ const extract = createStreamChunkExtractor();
13818
13844
  for await (const part of streamResult.fullStream) {
13819
13845
  abort.kick();
13820
- const extracted = extractStreamChunk(part);
13846
+ const extracted = extract(part);
13821
13847
  if (extracted.thought) onChunk?.(extracted.thought, "thought");
13822
13848
  if (extracted.content) {
13823
13849
  fullContent += extracted.content;
@@ -16900,6 +16926,7 @@ exports.createCurriculumStorage = createCurriculumStorage;
16900
16926
  exports.createIdleAbortController = createIdleAbortController;
16901
16927
  exports.createStreamAbortController = createStreamAbortController;
16902
16928
  exports.createStreamAbortSignal = createStreamAbortSignal;
16929
+ exports.createStreamChunkExtractor = createStreamChunkExtractor;
16903
16930
  exports.curateMediaLedger = curateMediaLedger;
16904
16931
  exports.designerTools = designerTools;
16905
16932
  exports.detectProjectPedagogy = detectProjectPedagogy;