@theokit/sdk 2.5.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 +12 -0
- package/README.md +4 -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/persistence.cjs +318 -0
- package/dist/persistence.cjs.map +1 -0
- package/dist/persistence.d.cts +24 -0
- package/dist/persistence.d.ts +24 -0
- package/dist/persistence.js +306 -0
- package/dist/persistence.js.map +1 -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 +11 -1
package/dist/index.cjs
CHANGED
|
@@ -2802,7 +2802,15 @@ var init_agent_factory_registry = __esm({
|
|
|
2802
2802
|
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
2803
2803
|
var run_to_completion_exports = {};
|
|
2804
2804
|
__export(run_to_completion_exports, {
|
|
2805
|
+
DEFAULT_CONTINUATION_PROMPT: () => DEFAULT_CONTINUATION_PROMPT,
|
|
2806
|
+
DEFAULT_MAX_ROUNDS: () => DEFAULT_MAX_ROUNDS,
|
|
2807
|
+
addUsage: () => addUsage,
|
|
2808
|
+
buildResult: () => buildResult,
|
|
2805
2809
|
classifyRound: () => classifyRound,
|
|
2810
|
+
continuationTail: () => continuationTail,
|
|
2811
|
+
isEmptyRound: () => isEmptyRound,
|
|
2812
|
+
promptForRound: () => promptForRound,
|
|
2813
|
+
resolveContinuation: () => resolveContinuation,
|
|
2806
2814
|
runToCompletionImpl: () => runToCompletionImpl
|
|
2807
2815
|
});
|
|
2808
2816
|
function isEmptyRound(result) {
|
|
@@ -2831,6 +2839,23 @@ function addUsage(acc, u) {
|
|
|
2831
2839
|
function buildResult(terminal, rounds, lastResult, usage) {
|
|
2832
2840
|
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
2833
2841
|
}
|
|
2842
|
+
async function continuationTail(round, lastResult, usage, onTruncated, signal) {
|
|
2843
|
+
await onTruncated?.({ round });
|
|
2844
|
+
return signal?.aborted === true ? buildResult("step_limit", round, lastResult, usage) : void 0;
|
|
2845
|
+
}
|
|
2846
|
+
function resolveContinuation(options) {
|
|
2847
|
+
return {
|
|
2848
|
+
maxRounds: options?.maxRounds ?? DEFAULT_MAX_ROUNDS,
|
|
2849
|
+
continuationPrompt: options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT,
|
|
2850
|
+
onTruncated: options?.onTruncated,
|
|
2851
|
+
signal: options?.signal,
|
|
2852
|
+
sendOptions: options?.sendOptions,
|
|
2853
|
+
state: { usage: void 0, emptyStreak: 0 }
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2856
|
+
function promptForRound(round, message, continuationPrompt) {
|
|
2857
|
+
return round === 0 ? message : continuationPrompt;
|
|
2858
|
+
}
|
|
2834
2859
|
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state4) {
|
|
2835
2860
|
const run = await agent.send(prompt, sendOptions);
|
|
2836
2861
|
const result = await run.wait();
|
|
@@ -2841,19 +2866,21 @@ async function stepRound(agent, prompt, sendOptions, round, maxRounds, state4) {
|
|
|
2841
2866
|
return { next: { usage, emptyStreak }, lastResult: result };
|
|
2842
2867
|
}
|
|
2843
2868
|
async function runToCompletionImpl(agent, message, options) {
|
|
2844
|
-
const
|
|
2845
|
-
|
|
2846
|
-
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
2847
|
-
let state4 = { usage: void 0, emptyStreak: 0 };
|
|
2869
|
+
const cfg = resolveContinuation(options);
|
|
2870
|
+
let state4 = cfg.state;
|
|
2848
2871
|
for (let round = 0; ; round += 1) {
|
|
2849
|
-
const prompt = round
|
|
2850
|
-
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state4);
|
|
2872
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
2873
|
+
const outcome = await stepRound(agent, prompt, cfg.sendOptions, round, cfg.maxRounds, state4);
|
|
2851
2874
|
if ("terminal" in outcome) return outcome.terminal;
|
|
2852
2875
|
state4 = outcome.next;
|
|
2853
|
-
await
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2876
|
+
const aborted = await continuationTail(
|
|
2877
|
+
round,
|
|
2878
|
+
outcome.lastResult,
|
|
2879
|
+
state4.usage,
|
|
2880
|
+
cfg.onTruncated,
|
|
2881
|
+
cfg.signal
|
|
2882
|
+
);
|
|
2883
|
+
if (aborted !== void 0) return aborted;
|
|
2857
2884
|
}
|
|
2858
2885
|
}
|
|
2859
2886
|
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
@@ -2864,6 +2891,39 @@ var init_run_to_completion = __esm({
|
|
|
2864
2891
|
}
|
|
2865
2892
|
});
|
|
2866
2893
|
|
|
2894
|
+
// src/internal/runtime/lifecycle/stream-to-completion.ts
|
|
2895
|
+
var stream_to_completion_exports = {};
|
|
2896
|
+
__export(stream_to_completion_exports, {
|
|
2897
|
+
streamToCompletionImpl: () => streamToCompletionImpl
|
|
2898
|
+
});
|
|
2899
|
+
function decideRound(result, round, maxRounds, state4) {
|
|
2900
|
+
const usage = addUsage(state4.usage, result.usage);
|
|
2901
|
+
const decision = classifyRound(result, round, maxRounds, state4.emptyStreak);
|
|
2902
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
2903
|
+
const emptyStreak = isEmptyRound(result) ? state4.emptyStreak + 1 : 0;
|
|
2904
|
+
return { next: { usage, emptyStreak } };
|
|
2905
|
+
}
|
|
2906
|
+
async function* streamToCompletionImpl(agent, message, options) {
|
|
2907
|
+
const cfg = resolveContinuation(options);
|
|
2908
|
+
let state4 = cfg.state;
|
|
2909
|
+
for (let round = 0; ; round += 1) {
|
|
2910
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
2911
|
+
const run = await agent.send(prompt, cfg.sendOptions);
|
|
2912
|
+
yield* run.stream();
|
|
2913
|
+
const result = await run.wait();
|
|
2914
|
+
const decision = decideRound(result, round, cfg.maxRounds, state4);
|
|
2915
|
+
if ("terminal" in decision) return decision.terminal;
|
|
2916
|
+
state4 = decision.next;
|
|
2917
|
+
const aborted = await continuationTail(round, result, state4.usage, cfg.onTruncated, cfg.signal);
|
|
2918
|
+
if (aborted !== void 0) return aborted;
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
var init_stream_to_completion = __esm({
|
|
2922
|
+
"src/internal/runtime/lifecycle/stream-to-completion.ts"() {
|
|
2923
|
+
init_run_to_completion();
|
|
2924
|
+
}
|
|
2925
|
+
});
|
|
2926
|
+
|
|
2867
2927
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
2868
2928
|
var fork_agent_exports = {};
|
|
2869
2929
|
__export(fork_agent_exports, {
|
|
@@ -7431,6 +7491,18 @@ var CloudAgent = class {
|
|
|
7431
7491
|
"runToCompletion"
|
|
7432
7492
|
);
|
|
7433
7493
|
}
|
|
7494
|
+
/**
|
|
7495
|
+
* Cloud agents do not expose the streaming continuation driver (V3-4);
|
|
7496
|
+
* the cloud runtime manages continuation server-side.
|
|
7497
|
+
*
|
|
7498
|
+
* @public
|
|
7499
|
+
*/
|
|
7500
|
+
streamToCompletion() {
|
|
7501
|
+
throw new exports.UnsupportedRunOperationError(
|
|
7502
|
+
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
7503
|
+
"streamToCompletion"
|
|
7504
|
+
);
|
|
7505
|
+
}
|
|
7434
7506
|
/**
|
|
7435
7507
|
* Personality presets require consistent server-side enforcement that
|
|
7436
7508
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -16003,6 +16075,10 @@ function localAgentRunToCompletion(agent, message, options) {
|
|
|
16003
16075
|
}
|
|
16004
16076
|
return run();
|
|
16005
16077
|
}
|
|
16078
|
+
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
16079
|
+
const { streamToCompletionImpl: streamToCompletionImpl2 } = await Promise.resolve().then(() => (init_stream_to_completion(), stream_to_completion_exports));
|
|
16080
|
+
return yield* streamToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
16081
|
+
}
|
|
16006
16082
|
async function localAgentFork(parent, options) {
|
|
16007
16083
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
16008
16084
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -16547,6 +16623,10 @@ var LocalAgent = class {
|
|
|
16547
16623
|
runToCompletion(message, options) {
|
|
16548
16624
|
return localAgentRunToCompletion(this, message, options);
|
|
16549
16625
|
}
|
|
16626
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
16627
|
+
streamToCompletion(message, options) {
|
|
16628
|
+
return localAgentStreamToCompletion(this, message, options);
|
|
16629
|
+
}
|
|
16550
16630
|
};
|
|
16551
16631
|
function resolveCwd(cwd) {
|
|
16552
16632
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|