@theokit/sdk 2.1.0 → 2.2.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/CHANGELOG.md +10 -0
- package/dist/a2a/index.cjs +29 -3
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +29 -3
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-CSTqNZp9.d.cts → cron-Aksw2Hy4.d.ts} +9 -1
- package/dist/{cron-Da6vF_2y.d.ts → cron-JSPSFczQ.d.cts} +9 -1
- package/dist/cron.cjs +31 -3
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +31 -3
- package/dist/cron.js.map +1 -1
- package/dist/{errors--VP2qrGc.d.ts → errors-Bcw_Pakm.d.ts} +1 -1
- package/dist/{errors-C9xkhNEF.d.cts → errors-Vhg6ZV4o.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +31 -3
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +31 -3
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +31 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +31 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/loop-types.d.ts +6 -0
- package/dist/internal/runtime/budget/budget-tracker.d.ts +8 -0
- package/dist/{run-DrwUpFxZ.d.cts → run-ekGKZlmg.d.cts} +20 -0
- package/dist/{run-DrwUpFxZ.d.ts → run-ekGKZlmg.d.ts} +20 -0
- package/dist/types/run.d.ts +20 -0
- package/package.json +1 -1
package/dist/a2a/index.js
CHANGED
|
@@ -2310,6 +2310,11 @@ function makeNotifier() {
|
|
|
2310
2310
|
});
|
|
2311
2311
|
return { promise, resolve: resolve3 };
|
|
2312
2312
|
}
|
|
2313
|
+
function applyScriptMetrics(base, script) {
|
|
2314
|
+
if (script.usage !== void 0) base.usage = script.usage;
|
|
2315
|
+
if (script.cost !== void 0) base.cost = script.cost;
|
|
2316
|
+
if (script.stoppedAtIterationLimit === true) base.stoppedAtIterationLimit = true;
|
|
2317
|
+
}
|
|
2313
2318
|
var FixtureRunBase;
|
|
2314
2319
|
var init_fixture_run_base = __esm({
|
|
2315
2320
|
"src/internal/runtime/fixtures/fixture-run-base.ts"() {
|
|
@@ -2416,8 +2421,7 @@ var init_fixture_run_base = __esm({
|
|
|
2416
2421
|
if (status === "error" && this.script.errorDetail !== void 0) {
|
|
2417
2422
|
base.error = this.script.errorDetail;
|
|
2418
2423
|
}
|
|
2419
|
-
|
|
2420
|
-
if (this.script.cost !== void 0) base.cost = this.script.cost;
|
|
2424
|
+
applyScriptMetrics(base, this.script);
|
|
2421
2425
|
return this.extendRunResult(applyExtraRunFields(base, this.script));
|
|
2422
2426
|
}
|
|
2423
2427
|
/** Subclasses override to attach runtime-specific fields (e.g. cloud git info). */
|
|
@@ -8005,6 +8009,7 @@ async function runAgentLoop(inputs) {
|
|
|
8005
8009
|
const ctx = await initLoopContext(inputs);
|
|
8006
8010
|
ctxRef = ctx;
|
|
8007
8011
|
const budget = inputs.budget ?? new IterationBudget({ maxIterations: inputs.maxIterations ?? 8 });
|
|
8012
|
+
let lastTurnDecision;
|
|
8008
8013
|
while (budget.shouldContinue()) {
|
|
8009
8014
|
if (inputs.budgetTracker !== void 0) {
|
|
8010
8015
|
const decision2 = evaluateBudgetGate(inputs.budgetTracker);
|
|
@@ -8013,18 +8018,26 @@ async function runAgentLoop(inputs) {
|
|
|
8013
8018
|
if (decision2.detail !== void 0) {
|
|
8014
8019
|
ctx.error = { message: decision2.detail, code: decision2.reason ?? "budget" };
|
|
8015
8020
|
}
|
|
8021
|
+
if (decision2.reason === "iteration_limit") {
|
|
8022
|
+
ctx.stoppedAtIterationLimit = true;
|
|
8023
|
+
}
|
|
8016
8024
|
break;
|
|
8017
8025
|
}
|
|
8018
8026
|
}
|
|
8019
8027
|
const usingGrace = budget.remaining <= 0 && !budget.graceCallUsed;
|
|
8020
8028
|
if (usingGrace) budget.useGraceCall();
|
|
8021
8029
|
const decision = await runIteration(inputs, ctx);
|
|
8030
|
+
lastTurnDecision = decision;
|
|
8022
8031
|
if (decision === "done") break;
|
|
8023
8032
|
if (decision === "error") {
|
|
8024
8033
|
ctx.finalStatus = "error";
|
|
8025
8034
|
break;
|
|
8026
8035
|
}
|
|
8027
8036
|
budget.consume();
|
|
8037
|
+
inputs.budgetTracker?.nextIteration?.();
|
|
8038
|
+
}
|
|
8039
|
+
if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
|
|
8040
|
+
ctx.stoppedAtIterationLimit = true;
|
|
8028
8041
|
}
|
|
8029
8042
|
if (budget.shouldContinue() === false && ctx.finalStatus === "finished" && ctx.finalText === "") {
|
|
8030
8043
|
ctx.finalStatus = "error";
|
|
@@ -8055,7 +8068,8 @@ async function runAgentLoop(inputs) {
|
|
|
8055
8068
|
conversation: ctx.conversation,
|
|
8056
8069
|
...usage !== void 0 ? { usage } : {},
|
|
8057
8070
|
...cost !== void 0 ? { cost } : {},
|
|
8058
|
-
...ctx.error !== void 0 ? { error: ctx.error } : {}
|
|
8071
|
+
...ctx.error !== void 0 ? { error: ctx.error } : {},
|
|
8072
|
+
...ctx.stoppedAtIterationLimit === true ? { stoppedAtIterationLimit: true } : {}
|
|
8059
8073
|
};
|
|
8060
8074
|
} finally {
|
|
8061
8075
|
if (ctxRef !== void 0 && ctxRef.memoryProviderHandle !== void 0 && inputs.memoryProvider !== void 0) {
|
|
@@ -11004,6 +11018,13 @@ function resolveRunProvider(options) {
|
|
|
11004
11018
|
return { primary, effectiveModelId };
|
|
11005
11019
|
}
|
|
11006
11020
|
function buildLoopInputs(options, runId, userText) {
|
|
11021
|
+
const maxIterations = options.sendOptions.maxIterations;
|
|
11022
|
+
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
11023
|
+
throw new ConfigurationError(
|
|
11024
|
+
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
11025
|
+
{ code: "invalid_max_iterations" }
|
|
11026
|
+
);
|
|
11027
|
+
}
|
|
11007
11028
|
const { primary, effectiveModelId } = resolveRunProvider(options);
|
|
11008
11029
|
const fallback = options.agentOptions.providers?.fallback;
|
|
11009
11030
|
const apiKeys = options.agentOptions.providers?.apiKeys;
|
|
@@ -11042,6 +11063,9 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11042
11063
|
// D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
|
|
11043
11064
|
// can attach it to the LLM `fetch({ signal })` call.
|
|
11044
11065
|
...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
|
|
11066
|
+
// M1-2: per-send iteration ceiling (validated above). The loop reads
|
|
11067
|
+
// inputs.maxIterations (default 8 when unset).
|
|
11068
|
+
...maxIterations !== void 0 ? { maxIterations } : {},
|
|
11045
11069
|
// D315-D317 — tool lifecycle hooks (cost tracking + audit + retry/alert)
|
|
11046
11070
|
...options.agentOptions.onToolStart !== void 0 ? { onToolStart: options.agentOptions.onToolStart } : {},
|
|
11047
11071
|
...options.agentOptions.onToolEnd !== void 0 ? { onToolEnd: options.agentOptions.onToolEnd } : {},
|
|
@@ -11101,6 +11125,7 @@ function buildMcpMap(options) {
|
|
|
11101
11125
|
var pluginProvidersAnnounced, RealLocalRun;
|
|
11102
11126
|
var init_real_local_run = __esm({
|
|
11103
11127
|
"src/internal/runtime/local-agent/real-local-run.ts"() {
|
|
11128
|
+
init_errors();
|
|
11104
11129
|
init_loop();
|
|
11105
11130
|
init_fallback_client();
|
|
11106
11131
|
init_model_identifier();
|
|
@@ -11188,6 +11213,7 @@ var init_real_local_run = __esm({
|
|
|
11188
11213
|
if (output.result.length > 0) this.script.result = output.result;
|
|
11189
11214
|
if (output.usage !== void 0) this.script.usage = output.usage;
|
|
11190
11215
|
if (output.cost !== void 0) this.script.cost = output.cost;
|
|
11216
|
+
if (output.stoppedAtIterationLimit === true) this.script.stoppedAtIterationLimit = true;
|
|
11191
11217
|
if (output.error !== void 0 && this.script.errorDetail === void 0) {
|
|
11192
11218
|
this.script.errorDetail = {
|
|
11193
11219
|
message: output.error.message,
|