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