@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/eval.js
CHANGED
|
@@ -1439,7 +1439,15 @@ var init_agent_factory_registry = __esm({
|
|
|
1439
1439
|
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
1440
1440
|
var run_to_completion_exports = {};
|
|
1441
1441
|
__export(run_to_completion_exports, {
|
|
1442
|
+
DEFAULT_CONTINUATION_PROMPT: () => DEFAULT_CONTINUATION_PROMPT,
|
|
1443
|
+
DEFAULT_MAX_ROUNDS: () => DEFAULT_MAX_ROUNDS,
|
|
1444
|
+
addUsage: () => addUsage,
|
|
1445
|
+
buildResult: () => buildResult,
|
|
1442
1446
|
classifyRound: () => classifyRound,
|
|
1447
|
+
continuationTail: () => continuationTail,
|
|
1448
|
+
isEmptyRound: () => isEmptyRound,
|
|
1449
|
+
promptForRound: () => promptForRound,
|
|
1450
|
+
resolveContinuation: () => resolveContinuation,
|
|
1443
1451
|
runToCompletionImpl: () => runToCompletionImpl
|
|
1444
1452
|
});
|
|
1445
1453
|
function isEmptyRound(result) {
|
|
@@ -1468,6 +1476,23 @@ function addUsage(acc, u) {
|
|
|
1468
1476
|
function buildResult(terminal, rounds, lastResult, usage) {
|
|
1469
1477
|
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
1470
1478
|
}
|
|
1479
|
+
async function continuationTail(round, lastResult, usage, onTruncated, signal) {
|
|
1480
|
+
await onTruncated?.({ round });
|
|
1481
|
+
return signal?.aborted === true ? buildResult("step_limit", round, lastResult, usage) : void 0;
|
|
1482
|
+
}
|
|
1483
|
+
function resolveContinuation(options) {
|
|
1484
|
+
return {
|
|
1485
|
+
maxRounds: options?.maxRounds ?? DEFAULT_MAX_ROUNDS,
|
|
1486
|
+
continuationPrompt: options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT,
|
|
1487
|
+
onTruncated: options?.onTruncated,
|
|
1488
|
+
signal: options?.signal,
|
|
1489
|
+
sendOptions: options?.sendOptions,
|
|
1490
|
+
state: { usage: void 0, emptyStreak: 0 }
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
function promptForRound(round, message, continuationPrompt) {
|
|
1494
|
+
return round === 0 ? message : continuationPrompt;
|
|
1495
|
+
}
|
|
1471
1496
|
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
1472
1497
|
const run = await agent.send(prompt, sendOptions);
|
|
1473
1498
|
const result = await run.wait();
|
|
@@ -1478,19 +1503,21 @@ async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
|
1478
1503
|
return { next: { usage, emptyStreak }, lastResult: result };
|
|
1479
1504
|
}
|
|
1480
1505
|
async function runToCompletionImpl(agent, message, options) {
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1483
|
-
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
1484
|
-
let state2 = { usage: void 0, emptyStreak: 0 };
|
|
1506
|
+
const cfg = resolveContinuation(options);
|
|
1507
|
+
let state2 = cfg.state;
|
|
1485
1508
|
for (let round = 0; ; round += 1) {
|
|
1486
|
-
const prompt = round
|
|
1487
|
-
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state2);
|
|
1509
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
1510
|
+
const outcome = await stepRound(agent, prompt, cfg.sendOptions, round, cfg.maxRounds, state2);
|
|
1488
1511
|
if ("terminal" in outcome) return outcome.terminal;
|
|
1489
1512
|
state2 = outcome.next;
|
|
1490
|
-
await
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1513
|
+
const aborted = await continuationTail(
|
|
1514
|
+
round,
|
|
1515
|
+
outcome.lastResult,
|
|
1516
|
+
state2.usage,
|
|
1517
|
+
cfg.onTruncated,
|
|
1518
|
+
cfg.signal
|
|
1519
|
+
);
|
|
1520
|
+
if (aborted !== void 0) return aborted;
|
|
1494
1521
|
}
|
|
1495
1522
|
}
|
|
1496
1523
|
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
@@ -1501,6 +1528,39 @@ var init_run_to_completion = __esm({
|
|
|
1501
1528
|
}
|
|
1502
1529
|
});
|
|
1503
1530
|
|
|
1531
|
+
// src/internal/runtime/lifecycle/stream-to-completion.ts
|
|
1532
|
+
var stream_to_completion_exports = {};
|
|
1533
|
+
__export(stream_to_completion_exports, {
|
|
1534
|
+
streamToCompletionImpl: () => streamToCompletionImpl
|
|
1535
|
+
});
|
|
1536
|
+
function decideRound(result, round, maxRounds, state2) {
|
|
1537
|
+
const usage = addUsage(state2.usage, result.usage);
|
|
1538
|
+
const decision = classifyRound(result, round, maxRounds, state2.emptyStreak);
|
|
1539
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
1540
|
+
const emptyStreak = isEmptyRound(result) ? state2.emptyStreak + 1 : 0;
|
|
1541
|
+
return { next: { usage, emptyStreak } };
|
|
1542
|
+
}
|
|
1543
|
+
async function* streamToCompletionImpl(agent, message, options) {
|
|
1544
|
+
const cfg = resolveContinuation(options);
|
|
1545
|
+
let state2 = cfg.state;
|
|
1546
|
+
for (let round = 0; ; round += 1) {
|
|
1547
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
1548
|
+
const run = await agent.send(prompt, cfg.sendOptions);
|
|
1549
|
+
yield* run.stream();
|
|
1550
|
+
const result = await run.wait();
|
|
1551
|
+
const decision = decideRound(result, round, cfg.maxRounds, state2);
|
|
1552
|
+
if ("terminal" in decision) return decision.terminal;
|
|
1553
|
+
state2 = decision.next;
|
|
1554
|
+
const aborted = await continuationTail(round, result, state2.usage, cfg.onTruncated, cfg.signal);
|
|
1555
|
+
if (aborted !== void 0) return aborted;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
var init_stream_to_completion = __esm({
|
|
1559
|
+
"src/internal/runtime/lifecycle/stream-to-completion.ts"() {
|
|
1560
|
+
init_run_to_completion();
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1504
1564
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
1505
1565
|
var fork_agent_exports = {};
|
|
1506
1566
|
__export(fork_agent_exports, {
|
|
@@ -4936,6 +4996,18 @@ var CloudAgent = class {
|
|
|
4936
4996
|
"runToCompletion"
|
|
4937
4997
|
);
|
|
4938
4998
|
}
|
|
4999
|
+
/**
|
|
5000
|
+
* Cloud agents do not expose the streaming continuation driver (V3-4);
|
|
5001
|
+
* the cloud runtime manages continuation server-side.
|
|
5002
|
+
*
|
|
5003
|
+
* @public
|
|
5004
|
+
*/
|
|
5005
|
+
streamToCompletion() {
|
|
5006
|
+
throw new UnsupportedRunOperationError(
|
|
5007
|
+
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
5008
|
+
"streamToCompletion"
|
|
5009
|
+
);
|
|
5010
|
+
}
|
|
4939
5011
|
/**
|
|
4940
5012
|
* Personality presets require consistent server-side enforcement that
|
|
4941
5013
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -14470,6 +14542,10 @@ function localAgentRunToCompletion(agent, message, options) {
|
|
|
14470
14542
|
}
|
|
14471
14543
|
return run();
|
|
14472
14544
|
}
|
|
14545
|
+
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
14546
|
+
const { streamToCompletionImpl: streamToCompletionImpl2 } = await Promise.resolve().then(() => (init_stream_to_completion(), stream_to_completion_exports));
|
|
14547
|
+
return yield* streamToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
14548
|
+
}
|
|
14473
14549
|
async function localAgentFork(parent, options) {
|
|
14474
14550
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
14475
14551
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -15014,6 +15090,10 @@ var LocalAgent = class {
|
|
|
15014
15090
|
runToCompletion(message, options) {
|
|
15015
15091
|
return localAgentRunToCompletion(this, message, options);
|
|
15016
15092
|
}
|
|
15093
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
15094
|
+
streamToCompletion(message, options) {
|
|
15095
|
+
return localAgentStreamToCompletion(this, message, options);
|
|
15096
|
+
}
|
|
15017
15097
|
};
|
|
15018
15098
|
function resolveCwd(cwd) {
|
|
15019
15099
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|