@thanh01.pmt/curriculum-kit 1.4.9 → 1.4.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.
- package/dist/index.cjs +35 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +35 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -21
- package/LICENSE +0 -21
package/dist/index.cjs
CHANGED
|
@@ -27302,13 +27302,13 @@ var DeterministicPipelineRunner = class {
|
|
|
27302
27302
|
|
|
27303
27303
|
// src/services/prefillService.ts
|
|
27304
27304
|
init_streamRunner();
|
|
27305
|
-
var DEFAULT_STREAM_IDLE_MS =
|
|
27305
|
+
var DEFAULT_STREAM_IDLE_MS = 18e4;
|
|
27306
27306
|
var DEFAULT_STREAM_TOTAL_MS = 48e4;
|
|
27307
27307
|
var LAYER_IDLE_BUDGET_MS = {
|
|
27308
|
-
1:
|
|
27309
|
-
2:
|
|
27308
|
+
1: 18e4,
|
|
27309
|
+
2: 18e4,
|
|
27310
27310
|
3: 18e4
|
|
27311
|
-
//
|
|
27311
|
+
// 3 minutes idle protection across all layers for free-tier reasoning models
|
|
27312
27312
|
};
|
|
27313
27313
|
var LAYER_TOTAL_BUDGET_MS = {
|
|
27314
27314
|
1: 48e4,
|
|
@@ -27369,10 +27369,20 @@ function extractStreamChunk(part) {
|
|
|
27369
27369
|
}
|
|
27370
27370
|
return {};
|
|
27371
27371
|
}
|
|
27372
|
-
function createStreamAbortSignal(budget) {
|
|
27372
|
+
function createStreamAbortSignal(budget, parentSignal) {
|
|
27373
27373
|
const controller = new AbortController();
|
|
27374
27374
|
let idleTimer = null;
|
|
27375
27375
|
let totalTimer = null;
|
|
27376
|
+
const onParentAbort = () => {
|
|
27377
|
+
controller.abort(parentSignal?.reason || new Error("Aborted by parent signal"));
|
|
27378
|
+
};
|
|
27379
|
+
if (parentSignal) {
|
|
27380
|
+
if (parentSignal.aborted) {
|
|
27381
|
+
controller.abort(parentSignal.reason || new Error("Parent signal already aborted"));
|
|
27382
|
+
} else {
|
|
27383
|
+
parentSignal.addEventListener("abort", onParentAbort, { once: true });
|
|
27384
|
+
}
|
|
27385
|
+
}
|
|
27376
27386
|
const armIdle = () => {
|
|
27377
27387
|
if (idleTimer) clearTimeout(idleTimer);
|
|
27378
27388
|
if (budget.idleMs > 0) {
|
|
@@ -27399,6 +27409,9 @@ function createStreamAbortSignal(budget) {
|
|
|
27399
27409
|
dispose: () => {
|
|
27400
27410
|
if (idleTimer) clearTimeout(idleTimer);
|
|
27401
27411
|
if (totalTimer) clearTimeout(totalTimer);
|
|
27412
|
+
if (parentSignal) {
|
|
27413
|
+
parentSignal.removeEventListener("abort", onParentAbort);
|
|
27414
|
+
}
|
|
27402
27415
|
idleTimer = null;
|
|
27403
27416
|
totalTimer = null;
|
|
27404
27417
|
}
|
|
@@ -27510,7 +27523,7 @@ function safeParseJson(rawText) {
|
|
|
27510
27523
|
}
|
|
27511
27524
|
return null;
|
|
27512
27525
|
}
|
|
27513
|
-
async function streamLLMWithFallback(systemPrompt, userPrompt, apiKeys = {}, onChunk, preferredModel, preferredProvider, budget) {
|
|
27526
|
+
async function streamLLMWithFallback(systemPrompt, userPrompt, apiKeys = {}, onChunk, preferredModel, preferredProvider, budget, signal) {
|
|
27514
27527
|
const alibabaKey = apiKeys.alibaba || apiKeys.dashscope || process.env.ALIBABA_API_KEY || process.env.DASHSCOPE_API_KEY;
|
|
27515
27528
|
const nvidiaKey = apiKeys.nvidia || process.env.NVIDIA_API_KEY;
|
|
27516
27529
|
const deepseekKey = apiKeys.deepseek || process.env.DEEPSEEK_API_KEY;
|
|
@@ -27542,7 +27555,6 @@ async function streamLLMWithFallback(systemPrompt, userPrompt, apiKeys = {}, onC
|
|
|
27542
27555
|
const nemotronModels = [
|
|
27543
27556
|
"nvidia/nemotron-3-ultra-550b-a55b",
|
|
27544
27557
|
"nvidia/nemotron-3.5-lightning-30b-a3b",
|
|
27545
|
-
"nvidia/nemotron-3-super-120b-a12b",
|
|
27546
27558
|
"nvidia/llama-3.1-nemotron-70b-instruct"
|
|
27547
27559
|
].filter((m) => isModelAllowed(m));
|
|
27548
27560
|
for (const m of nemotronModels) {
|
|
@@ -27593,8 +27605,12 @@ THINKING DIRECTIVE: Do ALL your reasoning internally BEFORE emitting output. Do
|
|
|
27593
27605
|
totalMs: budget?.totalMs ?? DEFAULT_STREAM_TOTAL_MS
|
|
27594
27606
|
};
|
|
27595
27607
|
for (const candidate of candidates) {
|
|
27608
|
+
if (signal?.aborted) {
|
|
27609
|
+
console.log(`[curriculum-kit:VercelAI] AbortSignal already aborted, cancelling candidate loop.`);
|
|
27610
|
+
break;
|
|
27611
|
+
}
|
|
27596
27612
|
const t0 = Date.now();
|
|
27597
|
-
const abort = createStreamAbortSignal(resolvedBudget);
|
|
27613
|
+
const abort = createStreamAbortSignal(resolvedBudget, signal);
|
|
27598
27614
|
try {
|
|
27599
27615
|
const modelInstance = getAIModel({
|
|
27600
27616
|
provider: candidate.provider,
|
|
@@ -27626,6 +27642,13 @@ THINKING DIRECTIVE: Do ALL your reasoning internally BEFORE emitting output. Do
|
|
|
27626
27642
|
}
|
|
27627
27643
|
} catch (e) {
|
|
27628
27644
|
console.warn(`[curriculum-kit:VercelAI] Candidate ${candidate.provider} (${candidate.model}) failed in ${Date.now() - t0}ms:`, e?.message || e);
|
|
27645
|
+
const isClientAborted = Boolean(
|
|
27646
|
+
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"))
|
|
27647
|
+
);
|
|
27648
|
+
if (isClientAborted) {
|
|
27649
|
+
console.log(`[curriculum-kit:VercelAI] Client aborted or stream closed, halting candidate fallback loop.`);
|
|
27650
|
+
break;
|
|
27651
|
+
}
|
|
27629
27652
|
} finally {
|
|
27630
27653
|
abort.dispose();
|
|
27631
27654
|
}
|
|
@@ -27677,7 +27700,8 @@ Return concise JSON matching:
|
|
|
27677
27700
|
totalMs: options.timeoutMs,
|
|
27678
27701
|
model: options.model,
|
|
27679
27702
|
provider: options.provider
|
|
27680
|
-
})
|
|
27703
|
+
}),
|
|
27704
|
+
options.signal
|
|
27681
27705
|
);
|
|
27682
27706
|
let parsedResearch = {
|
|
27683
27707
|
groundTruthSummary: `Verified ecosystem standards for ${projectName}`,
|
|
@@ -27887,7 +27911,8 @@ REQUIREMENT: Synthesize ALL parameters above \u2014 every single line in FULL AC
|
|
|
27887
27911
|
totalMs: options.timeoutMs,
|
|
27888
27912
|
model: options.model,
|
|
27889
27913
|
provider: options.provider
|
|
27890
|
-
})
|
|
27914
|
+
}),
|
|
27915
|
+
options.signal
|
|
27891
27916
|
);
|
|
27892
27917
|
const parsed = safeParseJson(rawContent);
|
|
27893
27918
|
return {
|