@theokit/sdk 2.6.0 → 2.8.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 +22 -0
- package/dist/a2a/index.cjs +90 -10
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +90 -10
- package/dist/a2a/index.js.map +1 -1
- package/dist/compaction.cjs +213 -16
- package/dist/compaction.cjs.map +1 -1
- package/dist/compaction.d.cts +63 -19
- package/dist/compaction.d.ts +63 -19
- package/dist/compaction.js +213 -17
- package/dist/compaction.js.map +1 -1
- package/dist/{cron-B656C3iq.d.cts → cron-Bhp8rP8i.d.ts} +19 -1
- package/dist/{cron-CM2M9mhB.d.ts → cron-CRPY-aKq.d.cts} +19 -1
- package/dist/cron.cjs +90 -10
- 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 +90 -10
- package/dist/cron.js.map +1 -1
- package/dist/{errors-DG_7CAUg.d.ts → errors-C8EVGqje.d.ts} +1 -1
- package/dist/{errors-QDYUPABr.d.cts → errors-FKoM44Mj.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +90 -10
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +90 -10
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +90 -10
- 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 +90 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/lifecycle/stream-to-completion.d.ts +31 -0
- package/dist/{run-BPRYG1Id.d.cts → run-D22b53SU.d.cts} +11 -2
- package/dist/{run-BPRYG1Id.d.ts → run-D22b53SU.d.ts} +11 -2
- package/dist/types/agent.d.ts +18 -0
- package/dist/types/run.d.ts +10 -1
- package/package.json +14 -14
package/dist/a2a/index.js
CHANGED
|
@@ -3012,6 +3012,18 @@ var init_cloud_agent = __esm({
|
|
|
3012
3012
|
"runToCompletion"
|
|
3013
3013
|
);
|
|
3014
3014
|
}
|
|
3015
|
+
/**
|
|
3016
|
+
* Cloud agents do not expose the streaming continuation driver (V3-4);
|
|
3017
|
+
* the cloud runtime manages continuation server-side.
|
|
3018
|
+
*
|
|
3019
|
+
* @public
|
|
3020
|
+
*/
|
|
3021
|
+
streamToCompletion() {
|
|
3022
|
+
throw new UnsupportedRunOperationError(
|
|
3023
|
+
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
3024
|
+
"streamToCompletion"
|
|
3025
|
+
);
|
|
3026
|
+
}
|
|
3015
3027
|
/**
|
|
3016
3028
|
* Personality presets require consistent server-side enforcement that
|
|
3017
3029
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -14257,7 +14269,15 @@ var init_agent_factory_registry = __esm({
|
|
|
14257
14269
|
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
14258
14270
|
var run_to_completion_exports = {};
|
|
14259
14271
|
__export(run_to_completion_exports, {
|
|
14272
|
+
DEFAULT_CONTINUATION_PROMPT: () => DEFAULT_CONTINUATION_PROMPT,
|
|
14273
|
+
DEFAULT_MAX_ROUNDS: () => DEFAULT_MAX_ROUNDS,
|
|
14274
|
+
addUsage: () => addUsage,
|
|
14275
|
+
buildResult: () => buildResult,
|
|
14260
14276
|
classifyRound: () => classifyRound,
|
|
14277
|
+
continuationTail: () => continuationTail,
|
|
14278
|
+
isEmptyRound: () => isEmptyRound,
|
|
14279
|
+
promptForRound: () => promptForRound,
|
|
14280
|
+
resolveContinuation: () => resolveContinuation,
|
|
14261
14281
|
runToCompletionImpl: () => runToCompletionImpl
|
|
14262
14282
|
});
|
|
14263
14283
|
function isEmptyRound(result) {
|
|
@@ -14286,6 +14306,23 @@ function addUsage(acc, u) {
|
|
|
14286
14306
|
function buildResult(terminal, rounds, lastResult, usage) {
|
|
14287
14307
|
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
14288
14308
|
}
|
|
14309
|
+
async function continuationTail(round, lastResult, usage, onTruncated, signal) {
|
|
14310
|
+
await onTruncated?.({ round });
|
|
14311
|
+
return signal?.aborted === true ? buildResult("step_limit", round, lastResult, usage) : void 0;
|
|
14312
|
+
}
|
|
14313
|
+
function resolveContinuation(options) {
|
|
14314
|
+
return {
|
|
14315
|
+
maxRounds: options?.maxRounds ?? DEFAULT_MAX_ROUNDS,
|
|
14316
|
+
continuationPrompt: options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT,
|
|
14317
|
+
onTruncated: options?.onTruncated,
|
|
14318
|
+
signal: options?.signal,
|
|
14319
|
+
sendOptions: options?.sendOptions,
|
|
14320
|
+
state: { usage: void 0, emptyStreak: 0 }
|
|
14321
|
+
};
|
|
14322
|
+
}
|
|
14323
|
+
function promptForRound(round, message, continuationPrompt) {
|
|
14324
|
+
return round === 0 ? message : continuationPrompt;
|
|
14325
|
+
}
|
|
14289
14326
|
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
14290
14327
|
const run = await agent.send(prompt, sendOptions);
|
|
14291
14328
|
const result = await run.wait();
|
|
@@ -14296,19 +14333,21 @@ async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
|
14296
14333
|
return { next: { usage, emptyStreak }, lastResult: result };
|
|
14297
14334
|
}
|
|
14298
14335
|
async function runToCompletionImpl(agent, message, options) {
|
|
14299
|
-
const
|
|
14300
|
-
|
|
14301
|
-
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
14302
|
-
let state2 = { usage: void 0, emptyStreak: 0 };
|
|
14336
|
+
const cfg = resolveContinuation(options);
|
|
14337
|
+
let state2 = cfg.state;
|
|
14303
14338
|
for (let round = 0; ; round += 1) {
|
|
14304
|
-
const prompt = round
|
|
14305
|
-
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state2);
|
|
14339
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
14340
|
+
const outcome = await stepRound(agent, prompt, cfg.sendOptions, round, cfg.maxRounds, state2);
|
|
14306
14341
|
if ("terminal" in outcome) return outcome.terminal;
|
|
14307
14342
|
state2 = outcome.next;
|
|
14308
|
-
await
|
|
14309
|
-
|
|
14310
|
-
|
|
14311
|
-
|
|
14343
|
+
const aborted = await continuationTail(
|
|
14344
|
+
round,
|
|
14345
|
+
outcome.lastResult,
|
|
14346
|
+
state2.usage,
|
|
14347
|
+
cfg.onTruncated,
|
|
14348
|
+
cfg.signal
|
|
14349
|
+
);
|
|
14350
|
+
if (aborted !== void 0) return aborted;
|
|
14312
14351
|
}
|
|
14313
14352
|
}
|
|
14314
14353
|
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
@@ -14319,6 +14358,39 @@ var init_run_to_completion = __esm({
|
|
|
14319
14358
|
}
|
|
14320
14359
|
});
|
|
14321
14360
|
|
|
14361
|
+
// src/internal/runtime/lifecycle/stream-to-completion.ts
|
|
14362
|
+
var stream_to_completion_exports = {};
|
|
14363
|
+
__export(stream_to_completion_exports, {
|
|
14364
|
+
streamToCompletionImpl: () => streamToCompletionImpl
|
|
14365
|
+
});
|
|
14366
|
+
function decideRound(result, round, maxRounds, state2) {
|
|
14367
|
+
const usage = addUsage(state2.usage, result.usage);
|
|
14368
|
+
const decision = classifyRound(result, round, maxRounds, state2.emptyStreak);
|
|
14369
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
14370
|
+
const emptyStreak = isEmptyRound(result) ? state2.emptyStreak + 1 : 0;
|
|
14371
|
+
return { next: { usage, emptyStreak } };
|
|
14372
|
+
}
|
|
14373
|
+
async function* streamToCompletionImpl(agent, message, options) {
|
|
14374
|
+
const cfg = resolveContinuation(options);
|
|
14375
|
+
let state2 = cfg.state;
|
|
14376
|
+
for (let round = 0; ; round += 1) {
|
|
14377
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
14378
|
+
const run = await agent.send(prompt, cfg.sendOptions);
|
|
14379
|
+
yield* run.stream();
|
|
14380
|
+
const result = await run.wait();
|
|
14381
|
+
const decision = decideRound(result, round, cfg.maxRounds, state2);
|
|
14382
|
+
if ("terminal" in decision) return decision.terminal;
|
|
14383
|
+
state2 = decision.next;
|
|
14384
|
+
const aborted = await continuationTail(round, result, state2.usage, cfg.onTruncated, cfg.signal);
|
|
14385
|
+
if (aborted !== void 0) return aborted;
|
|
14386
|
+
}
|
|
14387
|
+
}
|
|
14388
|
+
var init_stream_to_completion = __esm({
|
|
14389
|
+
"src/internal/runtime/lifecycle/stream-to-completion.ts"() {
|
|
14390
|
+
init_run_to_completion();
|
|
14391
|
+
}
|
|
14392
|
+
});
|
|
14393
|
+
|
|
14322
14394
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
14323
14395
|
var fork_agent_exports = {};
|
|
14324
14396
|
__export(fork_agent_exports, {
|
|
@@ -14406,6 +14478,10 @@ function localAgentRunToCompletion(agent, message, options) {
|
|
|
14406
14478
|
}
|
|
14407
14479
|
return run();
|
|
14408
14480
|
}
|
|
14481
|
+
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
14482
|
+
const { streamToCompletionImpl: streamToCompletionImpl2 } = await Promise.resolve().then(() => (init_stream_to_completion(), stream_to_completion_exports));
|
|
14483
|
+
return yield* streamToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
14484
|
+
}
|
|
14409
14485
|
async function localAgentFork(parent, options) {
|
|
14410
14486
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
14411
14487
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -15544,6 +15620,10 @@ var init_local_agent = __esm({
|
|
|
15544
15620
|
runToCompletion(message, options) {
|
|
15545
15621
|
return localAgentRunToCompletion(this, message, options);
|
|
15546
15622
|
}
|
|
15623
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
15624
|
+
streamToCompletion(message, options) {
|
|
15625
|
+
return localAgentStreamToCompletion(this, message, options);
|
|
15626
|
+
}
|
|
15547
15627
|
};
|
|
15548
15628
|
}
|
|
15549
15629
|
});
|