@theokit/sdk 2.6.0 → 2.7.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 +6 -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/{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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 96a507f: V3-4 — add `agent.streamToCompletion(message, options?)`, the STREAMING twin of `runToCompletion`. It returns an `AsyncGenerator<SDKMessage, StreamToCompletionResult>` that yields each continuation round's messages LIVE (so a UI can render tool calls + text as they happen across rounds), reusing the exact same terminal policy as the M1 driver — `classifyRound` (`done`/`step_limit`/`no_progress`) + bounded re-prompt + usage aggregation (no new policy; the only difference from `runToCompletion` is surfacing events over `Run.stream()` instead of `Run.wait()`). Local agents only; cloud agents throw `UnsupportedRunOperationError`. Stateful like `runToCompletion`; the STATELESS+streaming combination reconstructs history with `buildReplayHistory` into a fresh session first. The `StreamToCompletionResult` is the generator's return value (read via a manual `next()` loop — a plain `for await...of` discards it). Closes the V3-4 (a) streaming gap; (b) stateless and (c) terminals were already covered by `buildReplayHistory` + `runToCompletion`. Zero new dependency.
|
|
8
|
+
|
|
3
9
|
## 2.6.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/a2a/index.cjs
CHANGED
|
@@ -3015,6 +3015,18 @@ var init_cloud_agent = __esm({
|
|
|
3015
3015
|
"runToCompletion"
|
|
3016
3016
|
);
|
|
3017
3017
|
}
|
|
3018
|
+
/**
|
|
3019
|
+
* Cloud agents do not expose the streaming continuation driver (V3-4);
|
|
3020
|
+
* the cloud runtime manages continuation server-side.
|
|
3021
|
+
*
|
|
3022
|
+
* @public
|
|
3023
|
+
*/
|
|
3024
|
+
streamToCompletion() {
|
|
3025
|
+
throw new UnsupportedRunOperationError(
|
|
3026
|
+
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
3027
|
+
"streamToCompletion"
|
|
3028
|
+
);
|
|
3029
|
+
}
|
|
3018
3030
|
/**
|
|
3019
3031
|
* Personality presets require consistent server-side enforcement that
|
|
3020
3032
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -14260,7 +14272,15 @@ var init_agent_factory_registry = __esm({
|
|
|
14260
14272
|
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
14261
14273
|
var run_to_completion_exports = {};
|
|
14262
14274
|
__export(run_to_completion_exports, {
|
|
14275
|
+
DEFAULT_CONTINUATION_PROMPT: () => DEFAULT_CONTINUATION_PROMPT,
|
|
14276
|
+
DEFAULT_MAX_ROUNDS: () => DEFAULT_MAX_ROUNDS,
|
|
14277
|
+
addUsage: () => addUsage,
|
|
14278
|
+
buildResult: () => buildResult,
|
|
14263
14279
|
classifyRound: () => classifyRound,
|
|
14280
|
+
continuationTail: () => continuationTail,
|
|
14281
|
+
isEmptyRound: () => isEmptyRound,
|
|
14282
|
+
promptForRound: () => promptForRound,
|
|
14283
|
+
resolveContinuation: () => resolveContinuation,
|
|
14264
14284
|
runToCompletionImpl: () => runToCompletionImpl
|
|
14265
14285
|
});
|
|
14266
14286
|
function isEmptyRound(result) {
|
|
@@ -14289,6 +14309,23 @@ function addUsage(acc, u) {
|
|
|
14289
14309
|
function buildResult(terminal, rounds, lastResult, usage) {
|
|
14290
14310
|
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
14291
14311
|
}
|
|
14312
|
+
async function continuationTail(round, lastResult, usage, onTruncated, signal) {
|
|
14313
|
+
await onTruncated?.({ round });
|
|
14314
|
+
return signal?.aborted === true ? buildResult("step_limit", round, lastResult, usage) : void 0;
|
|
14315
|
+
}
|
|
14316
|
+
function resolveContinuation(options) {
|
|
14317
|
+
return {
|
|
14318
|
+
maxRounds: options?.maxRounds ?? DEFAULT_MAX_ROUNDS,
|
|
14319
|
+
continuationPrompt: options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT,
|
|
14320
|
+
onTruncated: options?.onTruncated,
|
|
14321
|
+
signal: options?.signal,
|
|
14322
|
+
sendOptions: options?.sendOptions,
|
|
14323
|
+
state: { usage: void 0, emptyStreak: 0 }
|
|
14324
|
+
};
|
|
14325
|
+
}
|
|
14326
|
+
function promptForRound(round, message, continuationPrompt) {
|
|
14327
|
+
return round === 0 ? message : continuationPrompt;
|
|
14328
|
+
}
|
|
14292
14329
|
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
14293
14330
|
const run = await agent.send(prompt, sendOptions);
|
|
14294
14331
|
const result = await run.wait();
|
|
@@ -14299,19 +14336,21 @@ async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
|
14299
14336
|
return { next: { usage, emptyStreak }, lastResult: result };
|
|
14300
14337
|
}
|
|
14301
14338
|
async function runToCompletionImpl(agent, message, options) {
|
|
14302
|
-
const
|
|
14303
|
-
|
|
14304
|
-
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
14305
|
-
let state2 = { usage: void 0, emptyStreak: 0 };
|
|
14339
|
+
const cfg = resolveContinuation(options);
|
|
14340
|
+
let state2 = cfg.state;
|
|
14306
14341
|
for (let round = 0; ; round += 1) {
|
|
14307
|
-
const prompt = round
|
|
14308
|
-
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state2);
|
|
14342
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
14343
|
+
const outcome = await stepRound(agent, prompt, cfg.sendOptions, round, cfg.maxRounds, state2);
|
|
14309
14344
|
if ("terminal" in outcome) return outcome.terminal;
|
|
14310
14345
|
state2 = outcome.next;
|
|
14311
|
-
await
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14346
|
+
const aborted = await continuationTail(
|
|
14347
|
+
round,
|
|
14348
|
+
outcome.lastResult,
|
|
14349
|
+
state2.usage,
|
|
14350
|
+
cfg.onTruncated,
|
|
14351
|
+
cfg.signal
|
|
14352
|
+
);
|
|
14353
|
+
if (aborted !== void 0) return aborted;
|
|
14315
14354
|
}
|
|
14316
14355
|
}
|
|
14317
14356
|
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
@@ -14322,6 +14361,39 @@ var init_run_to_completion = __esm({
|
|
|
14322
14361
|
}
|
|
14323
14362
|
});
|
|
14324
14363
|
|
|
14364
|
+
// src/internal/runtime/lifecycle/stream-to-completion.ts
|
|
14365
|
+
var stream_to_completion_exports = {};
|
|
14366
|
+
__export(stream_to_completion_exports, {
|
|
14367
|
+
streamToCompletionImpl: () => streamToCompletionImpl
|
|
14368
|
+
});
|
|
14369
|
+
function decideRound(result, round, maxRounds, state2) {
|
|
14370
|
+
const usage = addUsage(state2.usage, result.usage);
|
|
14371
|
+
const decision = classifyRound(result, round, maxRounds, state2.emptyStreak);
|
|
14372
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
14373
|
+
const emptyStreak = isEmptyRound(result) ? state2.emptyStreak + 1 : 0;
|
|
14374
|
+
return { next: { usage, emptyStreak } };
|
|
14375
|
+
}
|
|
14376
|
+
async function* streamToCompletionImpl(agent, message, options) {
|
|
14377
|
+
const cfg = resolveContinuation(options);
|
|
14378
|
+
let state2 = cfg.state;
|
|
14379
|
+
for (let round = 0; ; round += 1) {
|
|
14380
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
14381
|
+
const run = await agent.send(prompt, cfg.sendOptions);
|
|
14382
|
+
yield* run.stream();
|
|
14383
|
+
const result = await run.wait();
|
|
14384
|
+
const decision = decideRound(result, round, cfg.maxRounds, state2);
|
|
14385
|
+
if ("terminal" in decision) return decision.terminal;
|
|
14386
|
+
state2 = decision.next;
|
|
14387
|
+
const aborted = await continuationTail(round, result, state2.usage, cfg.onTruncated, cfg.signal);
|
|
14388
|
+
if (aborted !== void 0) return aborted;
|
|
14389
|
+
}
|
|
14390
|
+
}
|
|
14391
|
+
var init_stream_to_completion = __esm({
|
|
14392
|
+
"src/internal/runtime/lifecycle/stream-to-completion.ts"() {
|
|
14393
|
+
init_run_to_completion();
|
|
14394
|
+
}
|
|
14395
|
+
});
|
|
14396
|
+
|
|
14325
14397
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
14326
14398
|
var fork_agent_exports = {};
|
|
14327
14399
|
__export(fork_agent_exports, {
|
|
@@ -14409,6 +14481,10 @@ function localAgentRunToCompletion(agent, message, options) {
|
|
|
14409
14481
|
}
|
|
14410
14482
|
return run();
|
|
14411
14483
|
}
|
|
14484
|
+
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
14485
|
+
const { streamToCompletionImpl: streamToCompletionImpl2 } = await Promise.resolve().then(() => (init_stream_to_completion(), stream_to_completion_exports));
|
|
14486
|
+
return yield* streamToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
14487
|
+
}
|
|
14412
14488
|
async function localAgentFork(parent, options) {
|
|
14413
14489
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
14414
14490
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -15547,6 +15623,10 @@ var init_local_agent = __esm({
|
|
|
15547
15623
|
runToCompletion(message, options) {
|
|
15548
15624
|
return localAgentRunToCompletion(this, message, options);
|
|
15549
15625
|
}
|
|
15626
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
15627
|
+
streamToCompletion(message, options) {
|
|
15628
|
+
return localAgentStreamToCompletion(this, message, options);
|
|
15629
|
+
}
|
|
15550
15630
|
};
|
|
15551
15631
|
}
|
|
15552
15632
|
});
|