@surfishs/dsh-prompt-enhance 0.0.2 → 0.0.3

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/lib/index.js CHANGED
@@ -556,7 +556,13 @@ async function enhanceText(llm, options) {
556
556
  const rejected = isEffortRejectionFinish(attempt.assembler.finish);
557
557
  if (!rejected) {
558
558
  const detail = finishToDetail(attempt.assembler.finish);
559
- return detail === void 0 ? { ok: true, blocks: attempt.assembler.blocks(), usage: attempt.assembler.usage } : { ok: false, detail };
559
+ if (detail === void 0) {
560
+ return { ok: true, blocks: attempt.assembler.blocks(), usage: attempt.assembler.usage, truncated: false };
561
+ }
562
+ if (attempt.assembler.finish.kind === "max-tokens") {
563
+ return { ok: true, blocks: attempt.assembler.blocks(), usage: attempt.assembler.usage, truncated: true };
564
+ }
565
+ return { ok: false, detail };
560
566
  }
561
567
  if (requestedEffort === "inherit" || retriedWithoutEffort) {
562
568
  const detail = finishToDetail(attempt.assembler.finish) ?? { code: "upstream", params: { reason: "effort-unsupported" } };
@@ -594,7 +600,8 @@ async function enhanceText(llm, options) {
594
600
  provider: options.route.provider,
595
601
  model: options.route.model,
596
602
  elapsedMs: Date.now() - started,
597
- ...reportedUsage === void 0 ? {} : { usage: reportedUsage }
603
+ ...reportedUsage === void 0 ? {} : { usage: reportedUsage },
604
+ ...outcome.truncated ? { truncated: true } : {}
598
605
  };
599
606
  } catch (error) {
600
607
  if (error instanceof EnhanceFailure) throw error;