@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/errors.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, g as BudgetExceededError, C as ConfigurationError, u as CredentialPoolExhaustedError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, K as KnownAgentRunErrorCode, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, T as TheokitAgentError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-
|
|
2
|
-
import './run-
|
|
1
|
+
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, g as BudgetExceededError, C as ConfigurationError, u as CredentialPoolExhaustedError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, K as KnownAgentRunErrorCode, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, T as TheokitAgentError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-FKoM44Mj.cjs';
|
|
2
|
+
import './run-D22b53SU.cjs';
|
package/dist/eval.cjs
CHANGED
|
@@ -1442,7 +1442,15 @@ var init_agent_factory_registry = __esm({
|
|
|
1442
1442
|
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
1443
1443
|
var run_to_completion_exports = {};
|
|
1444
1444
|
__export(run_to_completion_exports, {
|
|
1445
|
+
DEFAULT_CONTINUATION_PROMPT: () => DEFAULT_CONTINUATION_PROMPT,
|
|
1446
|
+
DEFAULT_MAX_ROUNDS: () => DEFAULT_MAX_ROUNDS,
|
|
1447
|
+
addUsage: () => addUsage,
|
|
1448
|
+
buildResult: () => buildResult,
|
|
1445
1449
|
classifyRound: () => classifyRound,
|
|
1450
|
+
continuationTail: () => continuationTail,
|
|
1451
|
+
isEmptyRound: () => isEmptyRound,
|
|
1452
|
+
promptForRound: () => promptForRound,
|
|
1453
|
+
resolveContinuation: () => resolveContinuation,
|
|
1446
1454
|
runToCompletionImpl: () => runToCompletionImpl
|
|
1447
1455
|
});
|
|
1448
1456
|
function isEmptyRound(result) {
|
|
@@ -1471,6 +1479,23 @@ function addUsage(acc, u) {
|
|
|
1471
1479
|
function buildResult(terminal, rounds, lastResult, usage) {
|
|
1472
1480
|
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
1473
1481
|
}
|
|
1482
|
+
async function continuationTail(round, lastResult, usage, onTruncated, signal) {
|
|
1483
|
+
await onTruncated?.({ round });
|
|
1484
|
+
return signal?.aborted === true ? buildResult("step_limit", round, lastResult, usage) : void 0;
|
|
1485
|
+
}
|
|
1486
|
+
function resolveContinuation(options) {
|
|
1487
|
+
return {
|
|
1488
|
+
maxRounds: options?.maxRounds ?? DEFAULT_MAX_ROUNDS,
|
|
1489
|
+
continuationPrompt: options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT,
|
|
1490
|
+
onTruncated: options?.onTruncated,
|
|
1491
|
+
signal: options?.signal,
|
|
1492
|
+
sendOptions: options?.sendOptions,
|
|
1493
|
+
state: { usage: void 0, emptyStreak: 0 }
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
function promptForRound(round, message, continuationPrompt) {
|
|
1497
|
+
return round === 0 ? message : continuationPrompt;
|
|
1498
|
+
}
|
|
1474
1499
|
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
1475
1500
|
const run = await agent.send(prompt, sendOptions);
|
|
1476
1501
|
const result = await run.wait();
|
|
@@ -1481,19 +1506,21 @@ async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
|
1481
1506
|
return { next: { usage, emptyStreak }, lastResult: result };
|
|
1482
1507
|
}
|
|
1483
1508
|
async function runToCompletionImpl(agent, message, options) {
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1486
|
-
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
1487
|
-
let state2 = { usage: void 0, emptyStreak: 0 };
|
|
1509
|
+
const cfg = resolveContinuation(options);
|
|
1510
|
+
let state2 = cfg.state;
|
|
1488
1511
|
for (let round = 0; ; round += 1) {
|
|
1489
|
-
const prompt = round
|
|
1490
|
-
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state2);
|
|
1512
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
1513
|
+
const outcome = await stepRound(agent, prompt, cfg.sendOptions, round, cfg.maxRounds, state2);
|
|
1491
1514
|
if ("terminal" in outcome) return outcome.terminal;
|
|
1492
1515
|
state2 = outcome.next;
|
|
1493
|
-
await
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1516
|
+
const aborted = await continuationTail(
|
|
1517
|
+
round,
|
|
1518
|
+
outcome.lastResult,
|
|
1519
|
+
state2.usage,
|
|
1520
|
+
cfg.onTruncated,
|
|
1521
|
+
cfg.signal
|
|
1522
|
+
);
|
|
1523
|
+
if (aborted !== void 0) return aborted;
|
|
1497
1524
|
}
|
|
1498
1525
|
}
|
|
1499
1526
|
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
@@ -1504,6 +1531,39 @@ var init_run_to_completion = __esm({
|
|
|
1504
1531
|
}
|
|
1505
1532
|
});
|
|
1506
1533
|
|
|
1534
|
+
// src/internal/runtime/lifecycle/stream-to-completion.ts
|
|
1535
|
+
var stream_to_completion_exports = {};
|
|
1536
|
+
__export(stream_to_completion_exports, {
|
|
1537
|
+
streamToCompletionImpl: () => streamToCompletionImpl
|
|
1538
|
+
});
|
|
1539
|
+
function decideRound(result, round, maxRounds, state2) {
|
|
1540
|
+
const usage = addUsage(state2.usage, result.usage);
|
|
1541
|
+
const decision = classifyRound(result, round, maxRounds, state2.emptyStreak);
|
|
1542
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
1543
|
+
const emptyStreak = isEmptyRound(result) ? state2.emptyStreak + 1 : 0;
|
|
1544
|
+
return { next: { usage, emptyStreak } };
|
|
1545
|
+
}
|
|
1546
|
+
async function* streamToCompletionImpl(agent, message, options) {
|
|
1547
|
+
const cfg = resolveContinuation(options);
|
|
1548
|
+
let state2 = cfg.state;
|
|
1549
|
+
for (let round = 0; ; round += 1) {
|
|
1550
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
1551
|
+
const run = await agent.send(prompt, cfg.sendOptions);
|
|
1552
|
+
yield* run.stream();
|
|
1553
|
+
const result = await run.wait();
|
|
1554
|
+
const decision = decideRound(result, round, cfg.maxRounds, state2);
|
|
1555
|
+
if ("terminal" in decision) return decision.terminal;
|
|
1556
|
+
state2 = decision.next;
|
|
1557
|
+
const aborted = await continuationTail(round, result, state2.usage, cfg.onTruncated, cfg.signal);
|
|
1558
|
+
if (aborted !== void 0) return aborted;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
var init_stream_to_completion = __esm({
|
|
1562
|
+
"src/internal/runtime/lifecycle/stream-to-completion.ts"() {
|
|
1563
|
+
init_run_to_completion();
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1507
1567
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
1508
1568
|
var fork_agent_exports = {};
|
|
1509
1569
|
__export(fork_agent_exports, {
|
|
@@ -4939,6 +4999,18 @@ var CloudAgent = class {
|
|
|
4939
4999
|
"runToCompletion"
|
|
4940
5000
|
);
|
|
4941
5001
|
}
|
|
5002
|
+
/**
|
|
5003
|
+
* Cloud agents do not expose the streaming continuation driver (V3-4);
|
|
5004
|
+
* the cloud runtime manages continuation server-side.
|
|
5005
|
+
*
|
|
5006
|
+
* @public
|
|
5007
|
+
*/
|
|
5008
|
+
streamToCompletion() {
|
|
5009
|
+
throw new UnsupportedRunOperationError(
|
|
5010
|
+
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
5011
|
+
"streamToCompletion"
|
|
5012
|
+
);
|
|
5013
|
+
}
|
|
4942
5014
|
/**
|
|
4943
5015
|
* Personality presets require consistent server-side enforcement that
|
|
4944
5016
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -14473,6 +14545,10 @@ function localAgentRunToCompletion(agent, message, options) {
|
|
|
14473
14545
|
}
|
|
14474
14546
|
return run();
|
|
14475
14547
|
}
|
|
14548
|
+
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
14549
|
+
const { streamToCompletionImpl: streamToCompletionImpl2 } = await Promise.resolve().then(() => (init_stream_to_completion(), stream_to_completion_exports));
|
|
14550
|
+
return yield* streamToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
14551
|
+
}
|
|
14476
14552
|
async function localAgentFork(parent, options) {
|
|
14477
14553
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
14478
14554
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -15017,6 +15093,10 @@ var LocalAgent = class {
|
|
|
15017
15093
|
runToCompletion(message, options) {
|
|
15018
15094
|
return localAgentRunToCompletion(this, message, options);
|
|
15019
15095
|
}
|
|
15096
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
15097
|
+
streamToCompletion(message, options) {
|
|
15098
|
+
return localAgentStreamToCompletion(this, message, options);
|
|
15099
|
+
}
|
|
15020
15100
|
};
|
|
15021
15101
|
function resolveCwd(cwd) {
|
|
15022
15102
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|