@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/cron.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './run-
|
|
2
|
-
export { I as Cron } from './cron-
|
|
1
|
+
import './run-ekGKZlmg.cjs';
|
|
2
|
+
export { I as Cron } from './cron-JSPSFczQ.cjs';
|
package/dist/cron.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './run-
|
|
2
|
-
export { I as Cron } from './cron-
|
|
1
|
+
import './run-ekGKZlmg.js';
|
|
2
|
+
export { I as Cron } from './cron-Aksw2Hy4.js';
|
package/dist/cron.js
CHANGED
|
@@ -4317,8 +4317,7 @@ var FixtureRunBase = class {
|
|
|
4317
4317
|
if (status === "error" && this.script.errorDetail !== void 0) {
|
|
4318
4318
|
base.error = this.script.errorDetail;
|
|
4319
4319
|
}
|
|
4320
|
-
|
|
4321
|
-
if (this.script.cost !== void 0) base.cost = this.script.cost;
|
|
4320
|
+
applyScriptMetrics(base, this.script);
|
|
4322
4321
|
return this.extendRunResult(applyExtraRunFields(base, this.script));
|
|
4323
4322
|
}
|
|
4324
4323
|
/** Subclasses override to attach runtime-specific fields (e.g. cloud git info). */
|
|
@@ -4352,6 +4351,11 @@ function makeNotifier() {
|
|
|
4352
4351
|
});
|
|
4353
4352
|
return { promise, resolve: resolve3 };
|
|
4354
4353
|
}
|
|
4354
|
+
function applyScriptMetrics(base, script) {
|
|
4355
|
+
if (script.usage !== void 0) base.usage = script.usage;
|
|
4356
|
+
if (script.cost !== void 0) base.cost = script.cost;
|
|
4357
|
+
if (script.stoppedAtIterationLimit === true) base.stoppedAtIterationLimit = true;
|
|
4358
|
+
}
|
|
4355
4359
|
|
|
4356
4360
|
// src/internal/runtime/cloud/cloud-run.ts
|
|
4357
4361
|
function createCloudRun(options) {
|
|
@@ -7984,6 +7988,9 @@ var LocalRun = class extends FixtureRunBase {
|
|
|
7984
7988
|
}
|
|
7985
7989
|
};
|
|
7986
7990
|
|
|
7991
|
+
// src/internal/runtime/local-agent/real-local-run.ts
|
|
7992
|
+
init_errors();
|
|
7993
|
+
|
|
7987
7994
|
// src/internal/runtime/budget/budget.ts
|
|
7988
7995
|
var IterationBudget = class {
|
|
7989
7996
|
#remaining;
|
|
@@ -9208,6 +9215,7 @@ async function runAgentLoop(inputs) {
|
|
|
9208
9215
|
const ctx = await initLoopContext(inputs);
|
|
9209
9216
|
ctxRef = ctx;
|
|
9210
9217
|
const budget = inputs.budget ?? new IterationBudget({ maxIterations: inputs.maxIterations ?? 8 });
|
|
9218
|
+
let lastTurnDecision;
|
|
9211
9219
|
while (budget.shouldContinue()) {
|
|
9212
9220
|
if (inputs.budgetTracker !== void 0) {
|
|
9213
9221
|
const decision2 = evaluateBudgetGate(inputs.budgetTracker);
|
|
@@ -9216,18 +9224,26 @@ async function runAgentLoop(inputs) {
|
|
|
9216
9224
|
if (decision2.detail !== void 0) {
|
|
9217
9225
|
ctx.error = { message: decision2.detail, code: decision2.reason ?? "budget" };
|
|
9218
9226
|
}
|
|
9227
|
+
if (decision2.reason === "iteration_limit") {
|
|
9228
|
+
ctx.stoppedAtIterationLimit = true;
|
|
9229
|
+
}
|
|
9219
9230
|
break;
|
|
9220
9231
|
}
|
|
9221
9232
|
}
|
|
9222
9233
|
const usingGrace = budget.remaining <= 0 && !budget.graceCallUsed;
|
|
9223
9234
|
if (usingGrace) budget.useGraceCall();
|
|
9224
9235
|
const decision = await runIteration(inputs, ctx);
|
|
9236
|
+
lastTurnDecision = decision;
|
|
9225
9237
|
if (decision === "done") break;
|
|
9226
9238
|
if (decision === "error") {
|
|
9227
9239
|
ctx.finalStatus = "error";
|
|
9228
9240
|
break;
|
|
9229
9241
|
}
|
|
9230
9242
|
budget.consume();
|
|
9243
|
+
inputs.budgetTracker?.nextIteration?.();
|
|
9244
|
+
}
|
|
9245
|
+
if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
|
|
9246
|
+
ctx.stoppedAtIterationLimit = true;
|
|
9231
9247
|
}
|
|
9232
9248
|
if (budget.shouldContinue() === false && ctx.finalStatus === "finished" && ctx.finalText === "") {
|
|
9233
9249
|
ctx.finalStatus = "error";
|
|
@@ -9258,7 +9274,8 @@ async function runAgentLoop(inputs) {
|
|
|
9258
9274
|
conversation: ctx.conversation,
|
|
9259
9275
|
...usage !== void 0 ? { usage } : {},
|
|
9260
9276
|
...cost !== void 0 ? { cost } : {},
|
|
9261
|
-
...ctx.error !== void 0 ? { error: ctx.error } : {}
|
|
9277
|
+
...ctx.error !== void 0 ? { error: ctx.error } : {},
|
|
9278
|
+
...ctx.stoppedAtIterationLimit === true ? { stoppedAtIterationLimit: true } : {}
|
|
9262
9279
|
};
|
|
9263
9280
|
} finally {
|
|
9264
9281
|
if (ctxRef !== void 0 && ctxRef.memoryProviderHandle !== void 0 && inputs.memoryProvider !== void 0) {
|
|
@@ -11677,6 +11694,13 @@ function resolveRunProvider(options) {
|
|
|
11677
11694
|
return { primary, effectiveModelId };
|
|
11678
11695
|
}
|
|
11679
11696
|
function buildLoopInputs(options, runId, userText) {
|
|
11697
|
+
const maxIterations = options.sendOptions.maxIterations;
|
|
11698
|
+
if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
|
|
11699
|
+
throw new ConfigurationError(
|
|
11700
|
+
`SendOptions.maxIterations must be a positive integer, got ${maxIterations}`,
|
|
11701
|
+
{ code: "invalid_max_iterations" }
|
|
11702
|
+
);
|
|
11703
|
+
}
|
|
11680
11704
|
const { primary, effectiveModelId } = resolveRunProvider(options);
|
|
11681
11705
|
const fallback = options.agentOptions.providers?.fallback;
|
|
11682
11706
|
const apiKeys = options.agentOptions.providers?.apiKeys;
|
|
@@ -11715,6 +11739,9 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11715
11739
|
// D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
|
|
11716
11740
|
// can attach it to the LLM `fetch({ signal })` call.
|
|
11717
11741
|
...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
|
|
11742
|
+
// M1-2: per-send iteration ceiling (validated above). The loop reads
|
|
11743
|
+
// inputs.maxIterations (default 8 when unset).
|
|
11744
|
+
...maxIterations !== void 0 ? { maxIterations } : {},
|
|
11718
11745
|
// D315-D317 — tool lifecycle hooks (cost tracking + audit + retry/alert)
|
|
11719
11746
|
...options.agentOptions.onToolStart !== void 0 ? { onToolStart: options.agentOptions.onToolStart } : {},
|
|
11720
11747
|
...options.agentOptions.onToolEnd !== void 0 ? { onToolEnd: options.agentOptions.onToolEnd } : {},
|
|
@@ -11846,6 +11873,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
11846
11873
|
if (output.result.length > 0) this.script.result = output.result;
|
|
11847
11874
|
if (output.usage !== void 0) this.script.usage = output.usage;
|
|
11848
11875
|
if (output.cost !== void 0) this.script.cost = output.cost;
|
|
11876
|
+
if (output.stoppedAtIterationLimit === true) this.script.stoppedAtIterationLimit = true;
|
|
11849
11877
|
if (output.error !== void 0 && this.script.errorDetail === void 0) {
|
|
11850
11878
|
this.script.errorDetail = {
|
|
11851
11879
|
message: output.error.message,
|