@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/dist/cron.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './run-
|
|
2
|
-
export { I as Cron } from './cron-
|
|
1
|
+
import './run-D22b53SU.cjs';
|
|
2
|
+
export { I as Cron } from './cron-CRPY-aKq.cjs';
|
package/dist/cron.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './run-
|
|
2
|
-
export { I as Cron } from './cron-
|
|
1
|
+
import './run-D22b53SU.js';
|
|
2
|
+
export { I as Cron } from './cron-Bhp8rP8i.js';
|
package/dist/cron.js
CHANGED
|
@@ -1440,7 +1440,15 @@ var init_agent_factory_registry = __esm({
|
|
|
1440
1440
|
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
1441
1441
|
var run_to_completion_exports = {};
|
|
1442
1442
|
__export(run_to_completion_exports, {
|
|
1443
|
+
DEFAULT_CONTINUATION_PROMPT: () => DEFAULT_CONTINUATION_PROMPT,
|
|
1444
|
+
DEFAULT_MAX_ROUNDS: () => DEFAULT_MAX_ROUNDS,
|
|
1445
|
+
addUsage: () => addUsage,
|
|
1446
|
+
buildResult: () => buildResult,
|
|
1443
1447
|
classifyRound: () => classifyRound,
|
|
1448
|
+
continuationTail: () => continuationTail,
|
|
1449
|
+
isEmptyRound: () => isEmptyRound,
|
|
1450
|
+
promptForRound: () => promptForRound,
|
|
1451
|
+
resolveContinuation: () => resolveContinuation,
|
|
1444
1452
|
runToCompletionImpl: () => runToCompletionImpl
|
|
1445
1453
|
});
|
|
1446
1454
|
function isEmptyRound(result) {
|
|
@@ -1469,6 +1477,23 @@ function addUsage(acc, u) {
|
|
|
1469
1477
|
function buildResult(terminal, rounds, lastResult, usage) {
|
|
1470
1478
|
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
1471
1479
|
}
|
|
1480
|
+
async function continuationTail(round, lastResult, usage, onTruncated, signal) {
|
|
1481
|
+
await onTruncated?.({ round });
|
|
1482
|
+
return signal?.aborted === true ? buildResult("step_limit", round, lastResult, usage) : void 0;
|
|
1483
|
+
}
|
|
1484
|
+
function resolveContinuation(options) {
|
|
1485
|
+
return {
|
|
1486
|
+
maxRounds: options?.maxRounds ?? DEFAULT_MAX_ROUNDS,
|
|
1487
|
+
continuationPrompt: options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT,
|
|
1488
|
+
onTruncated: options?.onTruncated,
|
|
1489
|
+
signal: options?.signal,
|
|
1490
|
+
sendOptions: options?.sendOptions,
|
|
1491
|
+
state: { usage: void 0, emptyStreak: 0 }
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
function promptForRound(round, message, continuationPrompt) {
|
|
1495
|
+
return round === 0 ? message : continuationPrompt;
|
|
1496
|
+
}
|
|
1472
1497
|
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state3) {
|
|
1473
1498
|
const run = await agent.send(prompt, sendOptions);
|
|
1474
1499
|
const result = await run.wait();
|
|
@@ -1479,19 +1504,21 @@ async function stepRound(agent, prompt, sendOptions, round, maxRounds, state3) {
|
|
|
1479
1504
|
return { next: { usage, emptyStreak }, lastResult: result };
|
|
1480
1505
|
}
|
|
1481
1506
|
async function runToCompletionImpl(agent, message, options) {
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
1485
|
-
let state3 = { usage: void 0, emptyStreak: 0 };
|
|
1507
|
+
const cfg = resolveContinuation(options);
|
|
1508
|
+
let state3 = cfg.state;
|
|
1486
1509
|
for (let round = 0; ; round += 1) {
|
|
1487
|
-
const prompt = round
|
|
1488
|
-
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state3);
|
|
1510
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
1511
|
+
const outcome = await stepRound(agent, prompt, cfg.sendOptions, round, cfg.maxRounds, state3);
|
|
1489
1512
|
if ("terminal" in outcome) return outcome.terminal;
|
|
1490
1513
|
state3 = outcome.next;
|
|
1491
|
-
await
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1514
|
+
const aborted = await continuationTail(
|
|
1515
|
+
round,
|
|
1516
|
+
outcome.lastResult,
|
|
1517
|
+
state3.usage,
|
|
1518
|
+
cfg.onTruncated,
|
|
1519
|
+
cfg.signal
|
|
1520
|
+
);
|
|
1521
|
+
if (aborted !== void 0) return aborted;
|
|
1495
1522
|
}
|
|
1496
1523
|
}
|
|
1497
1524
|
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
@@ -1502,6 +1529,39 @@ var init_run_to_completion = __esm({
|
|
|
1502
1529
|
}
|
|
1503
1530
|
});
|
|
1504
1531
|
|
|
1532
|
+
// src/internal/runtime/lifecycle/stream-to-completion.ts
|
|
1533
|
+
var stream_to_completion_exports = {};
|
|
1534
|
+
__export(stream_to_completion_exports, {
|
|
1535
|
+
streamToCompletionImpl: () => streamToCompletionImpl
|
|
1536
|
+
});
|
|
1537
|
+
function decideRound(result, round, maxRounds, state3) {
|
|
1538
|
+
const usage = addUsage(state3.usage, result.usage);
|
|
1539
|
+
const decision = classifyRound(result, round, maxRounds, state3.emptyStreak);
|
|
1540
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
1541
|
+
const emptyStreak = isEmptyRound(result) ? state3.emptyStreak + 1 : 0;
|
|
1542
|
+
return { next: { usage, emptyStreak } };
|
|
1543
|
+
}
|
|
1544
|
+
async function* streamToCompletionImpl(agent, message, options) {
|
|
1545
|
+
const cfg = resolveContinuation(options);
|
|
1546
|
+
let state3 = cfg.state;
|
|
1547
|
+
for (let round = 0; ; round += 1) {
|
|
1548
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
1549
|
+
const run = await agent.send(prompt, cfg.sendOptions);
|
|
1550
|
+
yield* run.stream();
|
|
1551
|
+
const result = await run.wait();
|
|
1552
|
+
const decision = decideRound(result, round, cfg.maxRounds, state3);
|
|
1553
|
+
if ("terminal" in decision) return decision.terminal;
|
|
1554
|
+
state3 = decision.next;
|
|
1555
|
+
const aborted = await continuationTail(round, result, state3.usage, cfg.onTruncated, cfg.signal);
|
|
1556
|
+
if (aborted !== void 0) return aborted;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
var init_stream_to_completion = __esm({
|
|
1560
|
+
"src/internal/runtime/lifecycle/stream-to-completion.ts"() {
|
|
1561
|
+
init_run_to_completion();
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
|
|
1505
1565
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
1506
1566
|
var fork_agent_exports = {};
|
|
1507
1567
|
__export(fork_agent_exports, {
|
|
@@ -4941,6 +5001,18 @@ var CloudAgent = class {
|
|
|
4941
5001
|
"runToCompletion"
|
|
4942
5002
|
);
|
|
4943
5003
|
}
|
|
5004
|
+
/**
|
|
5005
|
+
* Cloud agents do not expose the streaming continuation driver (V3-4);
|
|
5006
|
+
* the cloud runtime manages continuation server-side.
|
|
5007
|
+
*
|
|
5008
|
+
* @public
|
|
5009
|
+
*/
|
|
5010
|
+
streamToCompletion() {
|
|
5011
|
+
throw new UnsupportedRunOperationError(
|
|
5012
|
+
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
5013
|
+
"streamToCompletion"
|
|
5014
|
+
);
|
|
5015
|
+
}
|
|
4944
5016
|
/**
|
|
4945
5017
|
* Personality presets require consistent server-side enforcement that
|
|
4946
5018
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -14475,6 +14547,10 @@ function localAgentRunToCompletion(agent, message, options) {
|
|
|
14475
14547
|
}
|
|
14476
14548
|
return run();
|
|
14477
14549
|
}
|
|
14550
|
+
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
14551
|
+
const { streamToCompletionImpl: streamToCompletionImpl2 } = await Promise.resolve().then(() => (init_stream_to_completion(), stream_to_completion_exports));
|
|
14552
|
+
return yield* streamToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
14553
|
+
}
|
|
14478
14554
|
async function localAgentFork(parent, options) {
|
|
14479
14555
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
14480
14556
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -15019,6 +15095,10 @@ var LocalAgent = class {
|
|
|
15019
15095
|
runToCompletion(message, options) {
|
|
15020
15096
|
return localAgentRunToCompletion(this, message, options);
|
|
15021
15097
|
}
|
|
15098
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
15099
|
+
streamToCompletion(message, options) {
|
|
15100
|
+
return localAgentStreamToCompletion(this, message, options);
|
|
15101
|
+
}
|
|
15022
15102
|
};
|
|
15023
15103
|
function resolveCwd(cwd) {
|
|
15024
15104
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|