@rulvar/core 1.213.0 → 1.215.0
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.js +62 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12623,6 +12623,7 @@ async function runAgent(options) {
|
|
|
12623
12623
|
kind: "budget",
|
|
12624
12624
|
retryable: false
|
|
12625
12625
|
};
|
|
12626
|
+
errorMessage = thrown instanceof Error ? thrown.message : String(thrown);
|
|
12626
12627
|
break;
|
|
12627
12628
|
}
|
|
12628
12629
|
turns += 1;
|
|
@@ -12834,12 +12835,13 @@ async function runAgent(options) {
|
|
|
12834
12835
|
});
|
|
12835
12836
|
try {
|
|
12836
12837
|
options.budget?.beforeTurn();
|
|
12837
|
-
} catch {
|
|
12838
|
+
} catch (thrown) {
|
|
12838
12839
|
status = "error";
|
|
12839
12840
|
agentError = {
|
|
12840
12841
|
kind: "budget",
|
|
12841
12842
|
retryable: false
|
|
12842
12843
|
};
|
|
12844
|
+
errorMessage = thrown instanceof Error ? thrown.message : String(thrown);
|
|
12843
12845
|
endPhase(summarizePhase, "error");
|
|
12844
12846
|
break;
|
|
12845
12847
|
}
|
|
@@ -13006,11 +13008,12 @@ async function runAgent(options) {
|
|
|
13006
13008
|
let proceed = true;
|
|
13007
13009
|
try {
|
|
13008
13010
|
options.budget?.beforeTurn();
|
|
13009
|
-
} catch {
|
|
13011
|
+
} catch (thrown) {
|
|
13010
13012
|
events?.emit({
|
|
13011
13013
|
type: "log",
|
|
13012
13014
|
level: "warn",
|
|
13013
|
-
msg: "the finalization reserve turn was skipped: the budget blocks further turns"
|
|
13015
|
+
msg: "the finalization reserve turn was skipped: the budget blocks further turns",
|
|
13016
|
+
data: { reason: thrown instanceof Error ? thrown.message : String(thrown) }
|
|
13014
13017
|
});
|
|
13015
13018
|
proceed = false;
|
|
13016
13019
|
}
|
|
@@ -13114,12 +13117,13 @@ async function runAgent(options) {
|
|
|
13114
13117
|
let proceed = true;
|
|
13115
13118
|
try {
|
|
13116
13119
|
options.budget?.beforeTurn();
|
|
13117
|
-
} catch {
|
|
13120
|
+
} catch (thrown) {
|
|
13118
13121
|
status = "error";
|
|
13119
13122
|
agentError = {
|
|
13120
13123
|
kind: "budget",
|
|
13121
13124
|
retryable: false
|
|
13122
13125
|
};
|
|
13126
|
+
errorMessage = thrown instanceof Error ? thrown.message : String(thrown);
|
|
13123
13127
|
proceed = false;
|
|
13124
13128
|
}
|
|
13125
13129
|
if (proceed) {
|
|
@@ -13266,12 +13270,13 @@ async function runAgent(options) {
|
|
|
13266
13270
|
while (status === "ok") {
|
|
13267
13271
|
try {
|
|
13268
13272
|
options.budget?.beforeTurn();
|
|
13269
|
-
} catch {
|
|
13273
|
+
} catch (thrown) {
|
|
13270
13274
|
status = "error";
|
|
13271
13275
|
agentError = {
|
|
13272
13276
|
kind: "budget",
|
|
13273
13277
|
retryable: false
|
|
13274
13278
|
};
|
|
13279
|
+
errorMessage = thrown instanceof Error ? thrown.message : String(thrown);
|
|
13275
13280
|
break;
|
|
13276
13281
|
}
|
|
13277
13282
|
turns += 1;
|
|
@@ -23931,13 +23936,40 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23931
23936
|
const stragglers = [...byOrdinal.values()].filter((record) => record.settled === void 0);
|
|
23932
23937
|
for (const record of stragglers) record.abort();
|
|
23933
23938
|
await Promise.all(stragglers.map((record) => record.result));
|
|
23934
|
-
|
|
23939
|
+
const synthesisTerminalOf = (declined) => {
|
|
23940
|
+
if (!(declined instanceof BudgetExhaustedError)) return;
|
|
23941
|
+
const entryRef = declined.data?.entryRef;
|
|
23942
|
+
if (typeof entryRef !== "number") return;
|
|
23943
|
+
return internals.replayer.snapshot().find((entry) => entry.seq === entryRef);
|
|
23944
|
+
};
|
|
23945
|
+
let synthesisTransportRetried = false;
|
|
23946
|
+
for (;;) try {
|
|
23935
23947
|
const synthesized = await runSynthesis(void 0);
|
|
23936
23948
|
return {
|
|
23937
23949
|
...foldEnvelope(),
|
|
23938
23950
|
result: synthesized
|
|
23939
23951
|
};
|
|
23940
23952
|
} catch (declined) {
|
|
23953
|
+
const terminal = synthesisTerminalOf(declined);
|
|
23954
|
+
if (!synthesisTransportRetried && terminal !== void 0 && terminal.error !== void 0 && terminal.error.data?.kind === "transport" && terminal.error.retryable === true) {
|
|
23955
|
+
synthesisTransportRetried = true;
|
|
23956
|
+
const retryKey = deriverV2.deriveKey({ kind: "orchestrator-synthesis-redemption-retry" });
|
|
23957
|
+
if (!internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.key === retryKey)) await internals.replayer.appendSinglePhase({
|
|
23958
|
+
scope: callingState.scope,
|
|
23959
|
+
key: retryKey,
|
|
23960
|
+
kind: "decision",
|
|
23961
|
+
status: "ok",
|
|
23962
|
+
spanId: internals.spans.mint(callingState.spanId),
|
|
23963
|
+
site: "orchestrator-budget",
|
|
23964
|
+
value: {
|
|
23965
|
+
decisionType: "orchestrator_synthesis_redemption_retry",
|
|
23966
|
+
reason: terminal.error.message.slice(0, 300),
|
|
23967
|
+
terminalRef: terminal.seq,
|
|
23968
|
+
remainingUsd: internals.budget.remainingUsd() ?? null
|
|
23969
|
+
}
|
|
23970
|
+
});
|
|
23971
|
+
continue;
|
|
23972
|
+
}
|
|
23941
23973
|
const declineKey = deriverV2.deriveKey({ kind: "orchestrator-synthesis-redemption-declined" });
|
|
23942
23974
|
if (!internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.key === declineKey)) await internals.replayer.appendSinglePhase({
|
|
23943
23975
|
scope: callingState.scope,
|
|
@@ -23948,9 +23980,11 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
23948
23980
|
site: "orchestrator-budget",
|
|
23949
23981
|
value: {
|
|
23950
23982
|
decisionType: "orchestrator_synthesis_redemption_declined",
|
|
23951
|
-
reason: declined instanceof Error ? declined.message
|
|
23983
|
+
reason: (terminal?.error?.message ?? (declined instanceof Error ? declined.message : String(declined))).slice(0, 300),
|
|
23984
|
+
...terminal === void 0 ? {} : { terminalRef: terminal.seq },
|
|
23952
23985
|
remainingUsd: internals.budget.remainingUsd() ?? null,
|
|
23953
|
-
stragglersDrained: stragglers.length
|
|
23986
|
+
stragglersDrained: stragglers.length,
|
|
23987
|
+
transportRetries: synthesisTransportRetried ? 1 : 0
|
|
23954
23988
|
}
|
|
23955
23989
|
});
|
|
23956
23990
|
return foldEnvelope();
|
|
@@ -24895,6 +24929,26 @@ function preflightEstimate(input) {
|
|
|
24895
24929
|
});
|
|
24896
24930
|
}
|
|
24897
24931
|
}
|
|
24932
|
+
{
|
|
24933
|
+
const pricing = pricingOf(servedBy);
|
|
24934
|
+
const declared = input.orchestrator?.budget?.synthesisReserveUsd;
|
|
24935
|
+
if (pricing !== void 0 && outputBound !== void 0 && declared !== void 0 && declared > 0) {
|
|
24936
|
+
const compositionUsd = priceUsdOf(pricing, {
|
|
24937
|
+
inputTokens: synthesis.estInputTokens ?? 0,
|
|
24938
|
+
outputTokens: outputBound,
|
|
24939
|
+
cacheReadTokens: 0,
|
|
24940
|
+
cacheWriteTokens: 0
|
|
24941
|
+
});
|
|
24942
|
+
const repairTurns = finishRepairReserve > 0 ? 1 : 0;
|
|
24943
|
+
const requiredUsd = compositionUsd * (1 + repairTurns);
|
|
24944
|
+
if (declared < requiredUsd) say({
|
|
24945
|
+
severity: "warning",
|
|
24946
|
+
code: "synthesis-reserve-below-cap-composition",
|
|
24947
|
+
message: `a synthesis turn writing to its ${String(outputBound)} token output allowance over the declared ${String(synthesis.estInputTokens ?? 0)} input floor prices about ${compositionUsd.toFixed(4)} USD at the rates of '${servedBy}'` + (repairTurns > 0 ? `, and the declared repair reserve prices one more such turn (about ${requiredUsd.toFixed(4)} USD total)` : "") + `; the committed synthesis reserve holds only ${declared.toFixed(4)} USD, so a composition cut at the allowance can fail its validators with no money left for the granted repair; hold the reserve at the cap arithmetic or lower maxOutputTokensPerTurn`,
|
|
24948
|
+
spawn: "synthesis"
|
|
24949
|
+
});
|
|
24950
|
+
}
|
|
24951
|
+
}
|
|
24898
24952
|
const projected = projectedProviderTurnsOf(merged, overallExecutedCeiling(merged, toolCeilingsOf(merged))) + finishRepairReserve;
|
|
24899
24953
|
if (orchestratorEcho !== void 0) orchestratorEcho.synthesis = {
|
|
24900
24954
|
projectedProviderTurns: projected,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.215.0",
|
|
4
4
|
"description": "Rulvar core: L0 contracts, journal kernel, ctx primitives, agent runtime, model router, tool system, dynamic orchestrator, InMemory and JSONL stores, event stream.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|