@theokit/sdk 4.17.1 → 4.18.1
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 +84 -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 +84 -10
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +84 -10
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +84 -10
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +84 -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 +84 -10
- package/dist/index.js.map +1 -1
- package/dist/types/goal-events.d.ts +11 -3
- package/package.json +12 -13
package/dist/eval.cjs
CHANGED
|
@@ -6255,10 +6255,12 @@ __export(run_until_exports, {
|
|
|
6255
6255
|
async function* runUntilImpl(agent, goal, options, deps) {
|
|
6256
6256
|
const maxTurns = options?.maxTurns ?? 20;
|
|
6257
6257
|
const maxFails = options?.maxConsecutiveJudgeFailures ?? 3;
|
|
6258
|
+
const tokenBudget = options?.tokenBudget;
|
|
6258
6259
|
const signal = options?.signal;
|
|
6259
6260
|
const isAborted = () => signal !== void 0 && signal.aborted;
|
|
6260
6261
|
let turn = 0;
|
|
6261
6262
|
let consecutiveFailures = 0;
|
|
6263
|
+
let tokensUsed = 0;
|
|
6262
6264
|
let lastResponse = "";
|
|
6263
6265
|
if (isAborted()) {
|
|
6264
6266
|
yield {
|
|
@@ -6266,20 +6268,44 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6266
6268
|
status: "paused",
|
|
6267
6269
|
reason: "aborted via AbortSignal before first turn"
|
|
6268
6270
|
};
|
|
6269
|
-
return { status: "paused", turnsUsed: 0, finalResponse: void 0 };
|
|
6271
|
+
return { status: "paused", turnsUsed: 0, tokensUsed, finalResponse: void 0 };
|
|
6270
6272
|
}
|
|
6271
6273
|
yield { type: "status_change", status: "active", reason: "Goal started" };
|
|
6272
6274
|
while (turn < maxTurns) {
|
|
6273
6275
|
if (isAborted()) {
|
|
6274
6276
|
yield { type: "status_change", status: "paused", reason: "aborted via AbortSignal" };
|
|
6275
|
-
return {
|
|
6277
|
+
return {
|
|
6278
|
+
status: "paused",
|
|
6279
|
+
turnsUsed: turn,
|
|
6280
|
+
tokensUsed,
|
|
6281
|
+
finalResponse: lastResponse || void 0
|
|
6282
|
+
};
|
|
6276
6283
|
}
|
|
6277
6284
|
turn += 1;
|
|
6278
6285
|
yield { type: "turn_start", turn, goal };
|
|
6279
6286
|
const continuationPrompt = turn === 1 ? goal : composeContinuation(goal, lastResponse);
|
|
6280
6287
|
const run = await agent.send(continuationPrompt);
|
|
6288
|
+
const cancelOnAbort = () => {
|
|
6289
|
+
void run.cancel?.();
|
|
6290
|
+
};
|
|
6291
|
+
if (signal !== void 0) {
|
|
6292
|
+
if (signal.aborted) cancelOnAbort();
|
|
6293
|
+
else signal.addEventListener("abort", cancelOnAbort, { once: true });
|
|
6294
|
+
}
|
|
6281
6295
|
const result = await run.wait();
|
|
6296
|
+
if (signal !== void 0) signal.removeEventListener("abort", cancelOnAbort);
|
|
6282
6297
|
lastResponse = result.result ?? "";
|
|
6298
|
+
const turnTokens = result.usage?.totalTokens;
|
|
6299
|
+
if (typeof turnTokens === "number") tokensUsed += turnTokens;
|
|
6300
|
+
if (isAborted()) {
|
|
6301
|
+
yield { type: "status_change", status: "paused", reason: "aborted via AbortSignal" };
|
|
6302
|
+
return {
|
|
6303
|
+
status: "paused",
|
|
6304
|
+
turnsUsed: turn,
|
|
6305
|
+
tokensUsed,
|
|
6306
|
+
finalResponse: lastResponse || void 0
|
|
6307
|
+
};
|
|
6308
|
+
}
|
|
6283
6309
|
yield { type: "agent_response", turn, content: lastResponse };
|
|
6284
6310
|
const judgeOpts = {};
|
|
6285
6311
|
if (options?.judgeModel !== void 0) judgeOpts.judgeModel = options.judgeModel;
|
|
@@ -6305,6 +6331,7 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6305
6331
|
return {
|
|
6306
6332
|
status: "failed",
|
|
6307
6333
|
turnsUsed: turn,
|
|
6334
|
+
tokensUsed,
|
|
6308
6335
|
finalResponse: lastResponse || void 0
|
|
6309
6336
|
};
|
|
6310
6337
|
}
|
|
@@ -6313,7 +6340,12 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6313
6340
|
}
|
|
6314
6341
|
if (judgment.verdict === "done") {
|
|
6315
6342
|
yield { type: "status_change", status: "completed", reason: judgment.reason };
|
|
6316
|
-
return {
|
|
6343
|
+
return {
|
|
6344
|
+
status: "completed",
|
|
6345
|
+
turnsUsed: turn,
|
|
6346
|
+
tokensUsed,
|
|
6347
|
+
finalResponse: lastResponse || void 0
|
|
6348
|
+
};
|
|
6317
6349
|
}
|
|
6318
6350
|
if (judgment.verdict === "skipped") {
|
|
6319
6351
|
yield {
|
|
@@ -6321,7 +6353,25 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6321
6353
|
status: "completed",
|
|
6322
6354
|
reason: `skipped: ${judgment.reason}`
|
|
6323
6355
|
};
|
|
6324
|
-
return {
|
|
6356
|
+
return {
|
|
6357
|
+
status: "completed",
|
|
6358
|
+
turnsUsed: turn,
|
|
6359
|
+
tokensUsed,
|
|
6360
|
+
finalResponse: lastResponse || void 0
|
|
6361
|
+
};
|
|
6362
|
+
}
|
|
6363
|
+
if (tokenBudget !== void 0 && tokensUsed >= tokenBudget) {
|
|
6364
|
+
yield {
|
|
6365
|
+
type: "status_change",
|
|
6366
|
+
status: "budget_limited",
|
|
6367
|
+
reason: `token budget (${tokenBudget}) reached: ${tokensUsed} used`
|
|
6368
|
+
};
|
|
6369
|
+
return {
|
|
6370
|
+
status: "budget_limited",
|
|
6371
|
+
turnsUsed: turn,
|
|
6372
|
+
tokensUsed,
|
|
6373
|
+
finalResponse: lastResponse || void 0
|
|
6374
|
+
};
|
|
6325
6375
|
}
|
|
6326
6376
|
yield { type: "continuation", turn, prompt: continuationPrompt };
|
|
6327
6377
|
}
|
|
@@ -6330,13 +6380,37 @@ async function* runUntilImpl(agent, goal, options, deps) {
|
|
|
6330
6380
|
status: "failed",
|
|
6331
6381
|
reason: `max turns (${maxTurns}) exhausted`
|
|
6332
6382
|
};
|
|
6333
|
-
return {
|
|
6383
|
+
return {
|
|
6384
|
+
status: "failed",
|
|
6385
|
+
turnsUsed: turn,
|
|
6386
|
+
tokensUsed,
|
|
6387
|
+
finalResponse: lastResponse || void 0
|
|
6388
|
+
};
|
|
6334
6389
|
}
|
|
6335
6390
|
function composeContinuation(goal, lastResponse) {
|
|
6336
|
-
return
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6391
|
+
return [
|
|
6392
|
+
"Continue working toward the active goal.",
|
|
6393
|
+
"",
|
|
6394
|
+
`<objective>
|
|
6395
|
+
${goal}
|
|
6396
|
+
</objective>`,
|
|
6397
|
+
"",
|
|
6398
|
+
"Continuation behavior:",
|
|
6399
|
+
"- This goal persists across turns. Keep the full objective intact; if it cannot be finished now,",
|
|
6400
|
+
" make concrete progress toward the real requested end state and do not redefine success around a",
|
|
6401
|
+
" smaller or easier task.",
|
|
6402
|
+
"",
|
|
6403
|
+
"Work from evidence:",
|
|
6404
|
+
"- Use the current worktree and external state as authoritative. Inspect the current state before",
|
|
6405
|
+
" relying on it. Improve, replace, or remove existing work as needed to satisfy the actual objective.",
|
|
6406
|
+
"",
|
|
6407
|
+
"Completion audit:",
|
|
6408
|
+
"- Before deciding the goal is achieved, treat completion as unproven and verify it against the actual",
|
|
6409
|
+
" current state, requirement by requirement. Treat uncertain or indirect evidence as not achieved.",
|
|
6410
|
+
"",
|
|
6411
|
+
`Your last response was:
|
|
6412
|
+
${lastResponse.slice(0, 1e3)}`
|
|
6413
|
+
].join("\n");
|
|
6340
6414
|
}
|
|
6341
6415
|
var init_run_until = __esm({
|
|
6342
6416
|
"src/internal/runtime/lifecycle/run-until.ts"() {
|
|
@@ -18576,7 +18650,7 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
18576
18650
|
status: "paused",
|
|
18577
18651
|
reason: "runUntil() requires an explicit goal (durable objectives removed in v4.0)"
|
|
18578
18652
|
};
|
|
18579
|
-
return { status: "paused", turnsUsed: 0, finalResponse: void 0 };
|
|
18653
|
+
return { status: "paused", turnsUsed: 0, tokensUsed: 0, finalResponse: void 0 };
|
|
18580
18654
|
}
|
|
18581
18655
|
return yield* runUntilImpl2(agent, goal, options, await buildDeps());
|
|
18582
18656
|
}
|