@theokit/sdk 4.17.1 → 4.18.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/{cron-B_vVYc-_.d.ts → cron-DOW3f-Xu.d.ts} +11 -3
- package/dist/{cron-Dj8FAU5V.d.cts → cron-DvP-E6Xx.d.cts} +11 -3
- package/dist/cron.cjs +42 -10
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +1 -1
- package/dist/cron.d.ts +1 -1
- package/dist/cron.js +42 -10
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +42 -10
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +42 -10
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +42 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +42 -10
- package/dist/index.js.map +1 -1
- package/dist/types/goal-events.d.ts +11 -3
- package/package.json +12 -13
package/dist/cron.d.cts
CHANGED
package/dist/cron.d.ts
CHANGED
package/dist/cron.js
CHANGED
|
@@ -6253,10 +6253,12 @@ __export(run_until_exports, {
|
|
|
6253
6253
|
async function* runUntilImpl(agent, goal, options, deps) {
|
|
6254
6254
|
const maxTurns = options?.maxTurns ?? 20;
|
|
6255
6255
|
const maxFails = options?.maxConsecutiveJudgeFailures ?? 3;
|
|
6256
|
+
const tokenBudget = options?.tokenBudget;
|
|
6256
6257
|
const signal = options?.signal;
|
|
6257
6258
|
const isAborted = () => signal !== void 0 && signal.aborted;
|
|
6258
6259
|
let turn = 0;
|
|
6259
6260
|
let consecutiveFailures = 0;
|
|
6261
|
+
let tokensUsed = 0;
|
|
6260
6262
|
let lastResponse = "";
|
|
6261
6263
|
if (isAborted()) {
|
|
6262
6264
|
yield {
|
|
@@ -6264,13 +6266,13 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6264
6266
|
status: "paused",
|
|
6265
6267
|
reason: "aborted via AbortSignal before first turn"
|
|
6266
6268
|
};
|
|
6267
|
-
return { status: "paused", turnsUsed: 0, finalResponse: void 0 };
|
|
6269
|
+
return { status: "paused", turnsUsed: 0, tokensUsed, finalResponse: void 0 };
|
|
6268
6270
|
}
|
|
6269
6271
|
yield { type: "status_change", status: "active", reason: "Goal started" };
|
|
6270
6272
|
while (turn < maxTurns) {
|
|
6271
6273
|
if (isAborted()) {
|
|
6272
6274
|
yield { type: "status_change", status: "paused", reason: "aborted via AbortSignal" };
|
|
6273
|
-
return { status: "paused", turnsUsed: turn, finalResponse: lastResponse || void 0 };
|
|
6275
|
+
return { status: "paused", turnsUsed: turn, tokensUsed, finalResponse: lastResponse || void 0 };
|
|
6274
6276
|
}
|
|
6275
6277
|
turn += 1;
|
|
6276
6278
|
yield { type: "turn_start", turn, goal };
|
|
@@ -6278,6 +6280,8 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6278
6280
|
const run = await agent.send(continuationPrompt);
|
|
6279
6281
|
const result = await run.wait();
|
|
6280
6282
|
lastResponse = result.result ?? "";
|
|
6283
|
+
const turnTokens = result.usage?.totalTokens;
|
|
6284
|
+
if (typeof turnTokens === "number") tokensUsed += turnTokens;
|
|
6281
6285
|
yield { type: "agent_response", turn, content: lastResponse };
|
|
6282
6286
|
const judgeOpts = {};
|
|
6283
6287
|
if (options?.judgeModel !== void 0) judgeOpts.judgeModel = options.judgeModel;
|
|
@@ -6303,6 +6307,7 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6303
6307
|
return {
|
|
6304
6308
|
status: "failed",
|
|
6305
6309
|
turnsUsed: turn,
|
|
6310
|
+
tokensUsed,
|
|
6306
6311
|
finalResponse: lastResponse || void 0
|
|
6307
6312
|
};
|
|
6308
6313
|
}
|
|
@@ -6311,7 +6316,7 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6311
6316
|
}
|
|
6312
6317
|
if (judgment.verdict === "done") {
|
|
6313
6318
|
yield { type: "status_change", status: "completed", reason: judgment.reason };
|
|
6314
|
-
return { status: "completed", turnsUsed: turn, finalResponse: lastResponse || void 0 };
|
|
6319
|
+
return { status: "completed", turnsUsed: turn, tokensUsed, finalResponse: lastResponse || void 0 };
|
|
6315
6320
|
}
|
|
6316
6321
|
if (judgment.verdict === "skipped") {
|
|
6317
6322
|
yield {
|
|
@@ -6319,7 +6324,15 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6319
6324
|
status: "completed",
|
|
6320
6325
|
reason: `skipped: ${judgment.reason}`
|
|
6321
6326
|
};
|
|
6322
|
-
return { status: "completed", turnsUsed: turn, finalResponse: lastResponse || void 0 };
|
|
6327
|
+
return { status: "completed", turnsUsed: turn, tokensUsed, finalResponse: lastResponse || void 0 };
|
|
6328
|
+
}
|
|
6329
|
+
if (tokenBudget !== void 0 && tokensUsed >= tokenBudget) {
|
|
6330
|
+
yield {
|
|
6331
|
+
type: "status_change",
|
|
6332
|
+
status: "budget_limited",
|
|
6333
|
+
reason: `token budget (${tokenBudget}) reached: ${tokensUsed} used`
|
|
6334
|
+
};
|
|
6335
|
+
return { status: "budget_limited", turnsUsed: turn, tokensUsed, finalResponse: lastResponse || void 0 };
|
|
6323
6336
|
}
|
|
6324
6337
|
yield { type: "continuation", turn, prompt: continuationPrompt };
|
|
6325
6338
|
}
|
|
@@ -6328,13 +6341,32 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6328
6341
|
status: "failed",
|
|
6329
6342
|
reason: `max turns (${maxTurns}) exhausted`
|
|
6330
6343
|
};
|
|
6331
|
-
return { status: "failed", turnsUsed: turn, finalResponse: lastResponse || void 0 };
|
|
6344
|
+
return { status: "failed", turnsUsed: turn, tokensUsed, finalResponse: lastResponse || void 0 };
|
|
6332
6345
|
}
|
|
6333
6346
|
function composeContinuation(goal, lastResponse) {
|
|
6334
|
-
return
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6347
|
+
return [
|
|
6348
|
+
"Continue working toward the active goal.",
|
|
6349
|
+
"",
|
|
6350
|
+
`<objective>
|
|
6351
|
+
${goal}
|
|
6352
|
+
</objective>`,
|
|
6353
|
+
"",
|
|
6354
|
+
"Continuation behavior:",
|
|
6355
|
+
"- This goal persists across turns. Keep the full objective intact; if it cannot be finished now,",
|
|
6356
|
+
" make concrete progress toward the real requested end state and do not redefine success around a",
|
|
6357
|
+
" smaller or easier task.",
|
|
6358
|
+
"",
|
|
6359
|
+
"Work from evidence:",
|
|
6360
|
+
"- Use the current worktree and external state as authoritative. Inspect the current state before",
|
|
6361
|
+
" relying on it. Improve, replace, or remove existing work as needed to satisfy the actual objective.",
|
|
6362
|
+
"",
|
|
6363
|
+
"Completion audit:",
|
|
6364
|
+
"- Before deciding the goal is achieved, treat completion as unproven and verify it against the actual",
|
|
6365
|
+
" current state, requirement by requirement. Treat uncertain or indirect evidence as not achieved.",
|
|
6366
|
+
"",
|
|
6367
|
+
`Your last response was:
|
|
6368
|
+
${lastResponse.slice(0, 1e3)}`
|
|
6369
|
+
].join("\n");
|
|
6338
6370
|
}
|
|
6339
6371
|
var init_run_until = __esm({
|
|
6340
6372
|
"src/internal/runtime/lifecycle/run-until.ts"() {
|
|
@@ -18578,7 +18610,7 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
18578
18610
|
status: "paused",
|
|
18579
18611
|
reason: "runUntil() requires an explicit goal (durable objectives removed in v4.0)"
|
|
18580
18612
|
};
|
|
18581
|
-
return { status: "paused", turnsUsed: 0, finalResponse: void 0 };
|
|
18613
|
+
return { status: "paused", turnsUsed: 0, tokensUsed: 0, finalResponse: void 0 };
|
|
18582
18614
|
}
|
|
18583
18615
|
return yield* runUntilImpl2(agent, goal, options, await buildDeps());
|
|
18584
18616
|
}
|