@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/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-
|
|
2
|
-
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-
|
|
3
|
-
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-
|
|
4
|
-
export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-
|
|
5
|
-
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-
|
|
6
|
-
export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, D as SDKThinkingMessage, E as SDKToolUseMessage, F as SDKUserMessage, G as SDKUserMessageEvent, H as SendOptions, J as ShellCommand, K as ShellConversationTurn, L as ShellOutput, N as ShellOutputDeltaUpdate, O as StepCompletedUpdate, Q as StepStartedUpdate, T as
|
|
1
|
+
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-FKoM44Mj.cjs';
|
|
2
|
+
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-FKoM44Mj.cjs';
|
|
3
|
+
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-CRPY-aKq.cjs';
|
|
4
|
+
export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-CRPY-aKq.cjs';
|
|
5
|
+
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-D22b53SU.cjs';
|
|
6
|
+
export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, D as SDKThinkingMessage, E as SDKToolUseMessage, F as SDKUserMessage, G as SDKUserMessageEvent, H as SendOptions, J as ShellCommand, K as ShellConversationTurn, L as ShellOutput, N as ShellOutputDeltaUpdate, O as StepCompletedUpdate, Q as StepStartedUpdate, T as StreamToCompletionResult, U as SummaryCompletedUpdate, V as SummaryStartedUpdate, W as SummaryUpdate, X as TextBlock, Y as TextDeltaUpdate, Z as ThinkingCompletedUpdate, _ as ThinkingDeltaUpdate, $ as ThinkingMessage, a0 as TokenDeltaUpdate, a1 as TokenUsage, a2 as ToolCall, a3 as ToolCallCompletedUpdate, a4 as ToolCallStartedUpdate, a5 as ToolResult, a6 as ToolUseBlock, a7 as TurnEndedUpdate, a8 as UserMessage, a9 as UserMessageAppendedUpdate } from './run-D22b53SU.cjs';
|
|
7
7
|
import * as zod from 'zod';
|
|
8
8
|
import { ZodType, z } from 'zod';
|
|
9
9
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-
|
|
2
|
-
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-
|
|
3
|
-
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-
|
|
4
|
-
export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-
|
|
5
|
-
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-
|
|
6
|
-
export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, D as SDKThinkingMessage, E as SDKToolUseMessage, F as SDKUserMessage, G as SDKUserMessageEvent, H as SendOptions, J as ShellCommand, K as ShellConversationTurn, L as ShellOutput, N as ShellOutputDeltaUpdate, O as StepCompletedUpdate, Q as StepStartedUpdate, T as
|
|
1
|
+
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-C8EVGqje.js';
|
|
2
|
+
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-C8EVGqje.js';
|
|
3
|
+
import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as MemoryContext, m as ConversationStorageAdapter, n as StoredMessage, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Bhp8rP8i.js';
|
|
4
|
+
export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Bhp8rP8i.js';
|
|
5
|
+
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-D22b53SU.js';
|
|
6
|
+
export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as RunToCompletionOptions, s as RunToCompletionResult, t as SDKAssistantMessage, u as SDKImage, v as SDKImageDimension, w as SDKObjectDelta, x as SDKRequestMessage, y as SDKStatusMessage, z as SDKSystemMessage, B as SDKTaskMessage, D as SDKThinkingMessage, E as SDKToolUseMessage, F as SDKUserMessage, G as SDKUserMessageEvent, H as SendOptions, J as ShellCommand, K as ShellConversationTurn, L as ShellOutput, N as ShellOutputDeltaUpdate, O as StepCompletedUpdate, Q as StepStartedUpdate, T as StreamToCompletionResult, U as SummaryCompletedUpdate, V as SummaryStartedUpdate, W as SummaryUpdate, X as TextBlock, Y as TextDeltaUpdate, Z as ThinkingCompletedUpdate, _ as ThinkingDeltaUpdate, $ as ThinkingMessage, a0 as TokenDeltaUpdate, a1 as TokenUsage, a2 as ToolCall, a3 as ToolCallCompletedUpdate, a4 as ToolCallStartedUpdate, a5 as ToolResult, a6 as ToolUseBlock, a7 as TurnEndedUpdate, a8 as UserMessage, a9 as UserMessageAppendedUpdate } from './run-D22b53SU.js';
|
|
7
7
|
import * as zod from 'zod';
|
|
8
8
|
import { ZodType, z } from 'zod';
|
|
9
9
|
|
package/dist/index.js
CHANGED
|
@@ -2799,7 +2799,15 @@ var init_agent_factory_registry = __esm({
|
|
|
2799
2799
|
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
2800
2800
|
var run_to_completion_exports = {};
|
|
2801
2801
|
__export(run_to_completion_exports, {
|
|
2802
|
+
DEFAULT_CONTINUATION_PROMPT: () => DEFAULT_CONTINUATION_PROMPT,
|
|
2803
|
+
DEFAULT_MAX_ROUNDS: () => DEFAULT_MAX_ROUNDS,
|
|
2804
|
+
addUsage: () => addUsage,
|
|
2805
|
+
buildResult: () => buildResult,
|
|
2802
2806
|
classifyRound: () => classifyRound,
|
|
2807
|
+
continuationTail: () => continuationTail,
|
|
2808
|
+
isEmptyRound: () => isEmptyRound,
|
|
2809
|
+
promptForRound: () => promptForRound,
|
|
2810
|
+
resolveContinuation: () => resolveContinuation,
|
|
2803
2811
|
runToCompletionImpl: () => runToCompletionImpl
|
|
2804
2812
|
});
|
|
2805
2813
|
function isEmptyRound(result) {
|
|
@@ -2828,6 +2836,23 @@ function addUsage(acc, u) {
|
|
|
2828
2836
|
function buildResult(terminal, rounds, lastResult, usage) {
|
|
2829
2837
|
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
2830
2838
|
}
|
|
2839
|
+
async function continuationTail(round, lastResult, usage, onTruncated, signal) {
|
|
2840
|
+
await onTruncated?.({ round });
|
|
2841
|
+
return signal?.aborted === true ? buildResult("step_limit", round, lastResult, usage) : void 0;
|
|
2842
|
+
}
|
|
2843
|
+
function resolveContinuation(options) {
|
|
2844
|
+
return {
|
|
2845
|
+
maxRounds: options?.maxRounds ?? DEFAULT_MAX_ROUNDS,
|
|
2846
|
+
continuationPrompt: options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT,
|
|
2847
|
+
onTruncated: options?.onTruncated,
|
|
2848
|
+
signal: options?.signal,
|
|
2849
|
+
sendOptions: options?.sendOptions,
|
|
2850
|
+
state: { usage: void 0, emptyStreak: 0 }
|
|
2851
|
+
};
|
|
2852
|
+
}
|
|
2853
|
+
function promptForRound(round, message, continuationPrompt) {
|
|
2854
|
+
return round === 0 ? message : continuationPrompt;
|
|
2855
|
+
}
|
|
2831
2856
|
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state4) {
|
|
2832
2857
|
const run = await agent.send(prompt, sendOptions);
|
|
2833
2858
|
const result = await run.wait();
|
|
@@ -2838,19 +2863,21 @@ async function stepRound(agent, prompt, sendOptions, round, maxRounds, state4) {
|
|
|
2838
2863
|
return { next: { usage, emptyStreak }, lastResult: result };
|
|
2839
2864
|
}
|
|
2840
2865
|
async function runToCompletionImpl(agent, message, options) {
|
|
2841
|
-
const
|
|
2842
|
-
|
|
2843
|
-
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
2844
|
-
let state4 = { usage: void 0, emptyStreak: 0 };
|
|
2866
|
+
const cfg = resolveContinuation(options);
|
|
2867
|
+
let state4 = cfg.state;
|
|
2845
2868
|
for (let round = 0; ; round += 1) {
|
|
2846
|
-
const prompt = round
|
|
2847
|
-
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state4);
|
|
2869
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
2870
|
+
const outcome = await stepRound(agent, prompt, cfg.sendOptions, round, cfg.maxRounds, state4);
|
|
2848
2871
|
if ("terminal" in outcome) return outcome.terminal;
|
|
2849
2872
|
state4 = outcome.next;
|
|
2850
|
-
await
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2873
|
+
const aborted = await continuationTail(
|
|
2874
|
+
round,
|
|
2875
|
+
outcome.lastResult,
|
|
2876
|
+
state4.usage,
|
|
2877
|
+
cfg.onTruncated,
|
|
2878
|
+
cfg.signal
|
|
2879
|
+
);
|
|
2880
|
+
if (aborted !== void 0) return aborted;
|
|
2854
2881
|
}
|
|
2855
2882
|
}
|
|
2856
2883
|
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
@@ -2861,6 +2888,39 @@ var init_run_to_completion = __esm({
|
|
|
2861
2888
|
}
|
|
2862
2889
|
});
|
|
2863
2890
|
|
|
2891
|
+
// src/internal/runtime/lifecycle/stream-to-completion.ts
|
|
2892
|
+
var stream_to_completion_exports = {};
|
|
2893
|
+
__export(stream_to_completion_exports, {
|
|
2894
|
+
streamToCompletionImpl: () => streamToCompletionImpl
|
|
2895
|
+
});
|
|
2896
|
+
function decideRound(result, round, maxRounds, state4) {
|
|
2897
|
+
const usage = addUsage(state4.usage, result.usage);
|
|
2898
|
+
const decision = classifyRound(result, round, maxRounds, state4.emptyStreak);
|
|
2899
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
2900
|
+
const emptyStreak = isEmptyRound(result) ? state4.emptyStreak + 1 : 0;
|
|
2901
|
+
return { next: { usage, emptyStreak } };
|
|
2902
|
+
}
|
|
2903
|
+
async function* streamToCompletionImpl(agent, message, options) {
|
|
2904
|
+
const cfg = resolveContinuation(options);
|
|
2905
|
+
let state4 = cfg.state;
|
|
2906
|
+
for (let round = 0; ; round += 1) {
|
|
2907
|
+
const prompt = promptForRound(round, message, cfg.continuationPrompt);
|
|
2908
|
+
const run = await agent.send(prompt, cfg.sendOptions);
|
|
2909
|
+
yield* run.stream();
|
|
2910
|
+
const result = await run.wait();
|
|
2911
|
+
const decision = decideRound(result, round, cfg.maxRounds, state4);
|
|
2912
|
+
if ("terminal" in decision) return decision.terminal;
|
|
2913
|
+
state4 = decision.next;
|
|
2914
|
+
const aborted = await continuationTail(round, result, state4.usage, cfg.onTruncated, cfg.signal);
|
|
2915
|
+
if (aborted !== void 0) return aborted;
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
var init_stream_to_completion = __esm({
|
|
2919
|
+
"src/internal/runtime/lifecycle/stream-to-completion.ts"() {
|
|
2920
|
+
init_run_to_completion();
|
|
2921
|
+
}
|
|
2922
|
+
});
|
|
2923
|
+
|
|
2864
2924
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
2865
2925
|
var fork_agent_exports = {};
|
|
2866
2926
|
__export(fork_agent_exports, {
|
|
@@ -7428,6 +7488,18 @@ var CloudAgent = class {
|
|
|
7428
7488
|
"runToCompletion"
|
|
7429
7489
|
);
|
|
7430
7490
|
}
|
|
7491
|
+
/**
|
|
7492
|
+
* Cloud agents do not expose the streaming continuation driver (V3-4);
|
|
7493
|
+
* the cloud runtime manages continuation server-side.
|
|
7494
|
+
*
|
|
7495
|
+
* @public
|
|
7496
|
+
*/
|
|
7497
|
+
streamToCompletion() {
|
|
7498
|
+
throw new UnsupportedRunOperationError(
|
|
7499
|
+
"Agent.streamToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
7500
|
+
"streamToCompletion"
|
|
7501
|
+
);
|
|
7502
|
+
}
|
|
7431
7503
|
/**
|
|
7432
7504
|
* Personality presets require consistent server-side enforcement that
|
|
7433
7505
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -16000,6 +16072,10 @@ function localAgentRunToCompletion(agent, message, options) {
|
|
|
16000
16072
|
}
|
|
16001
16073
|
return run();
|
|
16002
16074
|
}
|
|
16075
|
+
async function* localAgentStreamToCompletion(agent, message, options) {
|
|
16076
|
+
const { streamToCompletionImpl: streamToCompletionImpl2 } = await Promise.resolve().then(() => (init_stream_to_completion(), stream_to_completion_exports));
|
|
16077
|
+
return yield* streamToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
16078
|
+
}
|
|
16003
16079
|
async function localAgentFork(parent, options) {
|
|
16004
16080
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
16005
16081
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -16544,6 +16620,10 @@ var LocalAgent = class {
|
|
|
16544
16620
|
runToCompletion(message, options) {
|
|
16545
16621
|
return localAgentRunToCompletion(this, message, options);
|
|
16546
16622
|
}
|
|
16623
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
16624
|
+
streamToCompletion(message, options) {
|
|
16625
|
+
return localAgentStreamToCompletion(this, message, options);
|
|
16626
|
+
}
|
|
16547
16627
|
};
|
|
16548
16628
|
function resolveCwd(cwd) {
|
|
16549
16629
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|