@theokit/sdk 2.2.0 → 2.3.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 +25 -0
- package/dist/a2a/index.cjs +88 -0
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +88 -0
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-JSPSFczQ.d.cts → cron-B_H8rn-j.d.cts} +20 -2
- package/dist/{cron-Aksw2Hy4.d.ts → cron-DX6HbHxd.d.ts} +20 -2
- package/dist/cron.cjs +88 -0
- 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 +88 -0
- package/dist/cron.js.map +1 -1
- package/dist/{errors-Bcw_Pakm.d.ts → errors-DG_7CAUg.d.ts} +1 -1
- package/dist/{errors-Vhg6ZV4o.d.cts → errors-QDYUPABr.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +88 -0
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +88 -0
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +171 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -7
- package/dist/index.d.ts +50 -7
- package/dist/index.js +171 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/lifecycle/run-to-completion.d.ts +22 -0
- package/dist/{run-ekGKZlmg.d.cts → run-BPRYG1Id.d.cts} +55 -2
- package/dist/{run-ekGKZlmg.d.ts → run-BPRYG1Id.d.ts} +55 -2
- package/dist/types/agent.d.ts +14 -0
- package/dist/types/conversation-storage.d.ts +5 -1
- package/dist/types/run.d.ts +54 -1
- package/package.json +3 -3
package/dist/a2a/index.js
CHANGED
|
@@ -3000,6 +3000,18 @@ var init_cloud_agent = __esm({
|
|
|
3000
3000
|
"fork"
|
|
3001
3001
|
);
|
|
3002
3002
|
}
|
|
3003
|
+
/**
|
|
3004
|
+
* The continuation driver re-sends against a stateful local session; the
|
|
3005
|
+
* cloud runtime manages its own continuation policy server-side (M1 Phase 3).
|
|
3006
|
+
*
|
|
3007
|
+
* @public
|
|
3008
|
+
*/
|
|
3009
|
+
runToCompletion() {
|
|
3010
|
+
throw new UnsupportedRunOperationError(
|
|
3011
|
+
"Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
3012
|
+
"runToCompletion"
|
|
3013
|
+
);
|
|
3014
|
+
}
|
|
3003
3015
|
/**
|
|
3004
3016
|
* Personality presets require consistent server-side enforcement that
|
|
3005
3017
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -14187,6 +14199,71 @@ var init_agent_factory_registry = __esm({
|
|
|
14187
14199
|
}
|
|
14188
14200
|
});
|
|
14189
14201
|
|
|
14202
|
+
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
14203
|
+
var run_to_completion_exports = {};
|
|
14204
|
+
__export(run_to_completion_exports, {
|
|
14205
|
+
classifyRound: () => classifyRound,
|
|
14206
|
+
runToCompletionImpl: () => runToCompletionImpl
|
|
14207
|
+
});
|
|
14208
|
+
function isEmptyRound(result) {
|
|
14209
|
+
return (result.result ?? "").trim() === "";
|
|
14210
|
+
}
|
|
14211
|
+
function classifyRound(result, round, maxRounds, emptyStreak) {
|
|
14212
|
+
if (result.stoppedAtIterationLimit !== true) return "done";
|
|
14213
|
+
if (isEmptyRound(result) && emptyStreak >= 1) return "no_progress";
|
|
14214
|
+
if (round >= maxRounds) return "step_limit";
|
|
14215
|
+
return "continue";
|
|
14216
|
+
}
|
|
14217
|
+
function addUsage(acc, u) {
|
|
14218
|
+
if (u === void 0) return acc;
|
|
14219
|
+
const inputTokens = (acc?.inputTokens ?? 0) + u.inputTokens;
|
|
14220
|
+
const outputTokens = (acc?.outputTokens ?? 0) + u.outputTokens;
|
|
14221
|
+
const sumOpt = (a, b) => a === void 0 && b === void 0 ? void 0 : (a ?? 0) + (b ?? 0);
|
|
14222
|
+
return {
|
|
14223
|
+
inputTokens,
|
|
14224
|
+
outputTokens,
|
|
14225
|
+
totalTokens: inputTokens + outputTokens,
|
|
14226
|
+
cacheReadTokens: sumOpt(acc?.cacheReadTokens, u.cacheReadTokens),
|
|
14227
|
+
cacheWriteTokens: sumOpt(acc?.cacheWriteTokens, u.cacheWriteTokens),
|
|
14228
|
+
reasoningTokens: sumOpt(acc?.reasoningTokens, u.reasoningTokens)
|
|
14229
|
+
};
|
|
14230
|
+
}
|
|
14231
|
+
function buildResult(terminal, rounds, lastResult, usage) {
|
|
14232
|
+
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
14233
|
+
}
|
|
14234
|
+
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
14235
|
+
const run = await agent.send(prompt, sendOptions);
|
|
14236
|
+
const result = await run.wait();
|
|
14237
|
+
const usage = addUsage(state2.usage, result.usage);
|
|
14238
|
+
const decision = classifyRound(result, round, maxRounds, state2.emptyStreak);
|
|
14239
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
14240
|
+
const emptyStreak = isEmptyRound(result) ? state2.emptyStreak + 1 : 0;
|
|
14241
|
+
return { next: { usage, emptyStreak }, lastResult: result };
|
|
14242
|
+
}
|
|
14243
|
+
async function runToCompletionImpl(agent, message, options) {
|
|
14244
|
+
const maxRounds = options?.maxRounds ?? DEFAULT_MAX_ROUNDS;
|
|
14245
|
+
const continuationPrompt = options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT;
|
|
14246
|
+
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
14247
|
+
let state2 = { usage: void 0, emptyStreak: 0 };
|
|
14248
|
+
for (let round = 0; ; round += 1) {
|
|
14249
|
+
const prompt = round === 0 ? message : continuationPrompt;
|
|
14250
|
+
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state2);
|
|
14251
|
+
if ("terminal" in outcome) return outcome.terminal;
|
|
14252
|
+
state2 = outcome.next;
|
|
14253
|
+
await onTruncated?.({ round });
|
|
14254
|
+
if (signal?.aborted === true) {
|
|
14255
|
+
return buildResult("step_limit", round, outcome.lastResult, state2.usage);
|
|
14256
|
+
}
|
|
14257
|
+
}
|
|
14258
|
+
}
|
|
14259
|
+
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
14260
|
+
var init_run_to_completion = __esm({
|
|
14261
|
+
"src/internal/runtime/lifecycle/run-to-completion.ts"() {
|
|
14262
|
+
DEFAULT_MAX_ROUNDS = 5;
|
|
14263
|
+
DEFAULT_CONTINUATION_PROMPT = "Continue from where you left off and finish the task. If it is already complete, give the final answer.";
|
|
14264
|
+
}
|
|
14265
|
+
});
|
|
14266
|
+
|
|
14190
14267
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
14191
14268
|
var fork_agent_exports = {};
|
|
14192
14269
|
__export(fork_agent_exports, {
|
|
@@ -14267,6 +14344,13 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
14267
14344
|
}
|
|
14268
14345
|
return wrap();
|
|
14269
14346
|
}
|
|
14347
|
+
function localAgentRunToCompletion(agent, message, options) {
|
|
14348
|
+
async function run() {
|
|
14349
|
+
const { runToCompletionImpl: runToCompletionImpl2 } = await Promise.resolve().then(() => (init_run_to_completion(), run_to_completion_exports));
|
|
14350
|
+
return runToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
14351
|
+
}
|
|
14352
|
+
return run();
|
|
14353
|
+
}
|
|
14270
14354
|
async function localAgentFork(parent, options) {
|
|
14271
14355
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
14272
14356
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -15401,6 +15485,10 @@ var init_local_agent = __esm({
|
|
|
15401
15485
|
fork(options) {
|
|
15402
15486
|
return localAgentFork({ agentId: this.agentId, options: this.options, personalitySlugSnapshot: this.personalityStore.active(this.agentId) }, options);
|
|
15403
15487
|
}
|
|
15488
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
15489
|
+
runToCompletion(message, options) {
|
|
15490
|
+
return localAgentRunToCompletion(this, message, options);
|
|
15491
|
+
}
|
|
15404
15492
|
};
|
|
15405
15493
|
}
|
|
15406
15494
|
});
|