@theokit/sdk 4.19.0 → 4.19.2
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/dist/{cron-BoMsrUs1.d.ts → cron-Bhdyjl0B.d.ts} +1 -1
- package/dist/{cron-DWc1r8m8.d.cts → cron-M2Xz7lq2.d.cts} +1 -1
- package/dist/cron.cjs +43 -19
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +1 -1
- package/dist/cron.d.ts +1 -1
- package/dist/cron.js +43 -19
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +43 -19
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +43 -19
- package/dist/eval.js.map +1 -1
- package/dist/goal-loop.d.ts +35 -0
- package/dist/index.cjs +163 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -103
- package/dist/index.d.ts +109 -103
- package/dist/index.js +164 -141
- package/dist/index.js.map +1 -1
- package/dist/internal/persistence/index.cjs +3 -1
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +3 -1
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/runtime/lifecycle/run-until.d.ts +1 -0
- package/dist/persistence.cjs +3 -1
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +3 -1
- package/dist/persistence.js.map +1 -1
- package/dist/provider-catalog.json +144 -469
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-gE8612p9.cjs';
|
|
2
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, m as ErrorCode, 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-gE8612p9.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
|
|
4
|
-
export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentMemory, y as BudgetCheck, z as BudgetTotal, D as BudgetUsageEvent, E as CloudEnv, F as CloudRepo, H as ContextBudget, J as ContextManagerKind, K as ContextSnapshot, N as ContextSource, O as ContextSourceStatus, Q as CreateSkillSpec, R as Cron, T as CronCreateOptions, U as CronGetOptions, V as CronJob, W as CronJobStatus, X as CronListOptions, Y as CronOperationOptions, Z as CronRunOptions, _ as CronRuntime, $ as CronSchedulerStatus, a0 as CronStartOptions, a1 as HookName, a2 as InvalidateCacheOptions, a3 as MemoryAdapter, a4 as MemoryAdapterCapabilities, a5 as MemoryContext, a6 as MemoryFact, a7 as MemoryProviderHandle, a8 as MemoryProviderInitOptions, a9 as MemoryRevision, aa as MemoryToolSchema, ab as MemoryTurnMessage, ac as PersonalityPreset, ad as PluginContext, ae as PostAssistantReplyContext, af as PreToolCallContext, ag as PreUserSendContext, ah as PreUserSendResult, ai as ProviderCapability, aj as ProviderRoute, ak as ProviderTransform, al as ProviderTransformContext, am as RecordSessionSummaryArgs, an as ResolvedProviderRoute, ao as RunUntilIterator, ap as SDKAgentPlugins, aq as SDKAgentSkillDetail, ar as SDKAgentSkills, as as SDKArtifact, at as SDKContextManager, au as SDKPluginMetadata, av as SDKProvidersManager, aw as SessionRecord, ax as SessionStore, ay as SettingSource, az as Skill, aA as SkillsResolver, aB as SkillsResolverContext, aC as SystemPromptContext, aD as SystemPromptMemoryFact, aE as SystemPromptSkillRef, aF as TelemetrySettings } from './cron-
|
|
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 Plugin$1, m as ProviderProfile, I as InlineSkill, n as GoalOptions, o as GoalEvent, p as GoalResult, B as BudgetTracker, q as MemoryProvider, r as MemoryId, s as PreToolCallDecision, t as StepResult, u as SDKProvider } from './cron-M2Xz7lq2.cjs';
|
|
4
|
+
export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentMemory, y as BudgetCheck, z as BudgetTotal, D as BudgetUsageEvent, E as CloudEnv, F as CloudRepo, H as ContextBudget, J as ContextManagerKind, K as ContextSnapshot, N as ContextSource, O as ContextSourceStatus, Q as CreateSkillSpec, R as Cron, T as CronCreateOptions, U as CronGetOptions, V as CronJob, W as CronJobStatus, X as CronListOptions, Y as CronOperationOptions, Z as CronRunOptions, _ as CronRuntime, $ as CronSchedulerStatus, a0 as CronStartOptions, a1 as HookName, a2 as InvalidateCacheOptions, a3 as MemoryAdapter, a4 as MemoryAdapterCapabilities, a5 as MemoryContext, a6 as MemoryFact, a7 as MemoryProviderHandle, a8 as MemoryProviderInitOptions, a9 as MemoryRevision, aa as MemoryToolSchema, ab as MemoryTurnMessage, ac as PersonalityPreset, ad as PluginContext, ae as PostAssistantReplyContext, af as PreToolCallContext, ag as PreUserSendContext, ah as PreUserSendResult, ai as ProviderCapability, aj as ProviderRoute, ak as ProviderTransform, al as ProviderTransformContext, am as RecordSessionSummaryArgs, an as ResolvedProviderRoute, ao as RunUntilIterator, ap as SDKAgentPlugins, aq as SDKAgentSkillDetail, ar as SDKAgentSkills, as as SDKArtifact, at as SDKContextManager, au as SDKPluginMetadata, av as SDKProvidersManager, aw as SessionRecord, ax as SessionStore, ay as SettingSource, az as Skill, aA as SkillsResolver, aB as SkillsResolverContext, aC as SystemPromptContext, aD as SystemPromptMemoryFact, aE as SystemPromptSkillRef, aF as TelemetrySettings } from './cron-M2Xz7lq2.cjs';
|
|
5
5
|
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, P as Processor, T as ToolResultContentBlock, c as PermissionMode, d as PermissionEngine, e as RunEventSink, S as SDKMessage } from './run-DFM1H2jW.cjs';
|
|
6
6
|
export { A as AgentConversationTurn, f as AssistantMessage, g as CompletionCheck, h as CompletionCheckResult, i as ConversationStep, j as ConversationTurn, k as CostBreakdown, l as CostSource, m as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, n as GenerateRunResult, I as ImageBlock, o as InputProcessorContext, p as InteractionUpdate, q as McpAuthConfig, r as McpHttpServerConfig, s as McpOAuthConfig, t as McpStdioServerConfig, u as MessageOrigin, v as ModelParameterValue, O as OutputProcessorContext, w as PartialToolCallUpdate, x as PermissionAction, y as PermissionEngineOptions, z as PermissionRule, B as ProcessorControls, E as ProcessorTripwire, F as ProcessorViolation, H as RunCompactBoundaryEvent, J as RunCompletionCheckEvent, K as RunErrorDetail, L as RunEvent, N as RunGitInfo, Q as RunOperation, U as RunPermissionDeniedEvent, V as RunRateLimitEvent, W as RunStatus, X as RunTaskCompletedEvent, Y as RunTaskStartedEvent, Z as RunTaskUpdatedEvent, _ as RunToCompletionOptions, $ as RunToCompletionResult, a0 as RunToolProgressEvent, a1 as RunTripwireEvent, a2 as SDKAssistantMessage, a3 as SDKImage, a4 as SDKImageDimension, a5 as SDKObjectDelta, a6 as SDKRequestMessage, a7 as SDKStatusMessage, a8 as SDKSystemMessage, a9 as SDKTaskMessage, aa as SDKThinkingMessage, ab as SDKToolUseMessage, ac as SDKUserMessage, ad as SDKUserMessageEvent, ae as SendOptions, af as ShellCommand, ag as ShellConversationTurn, ah as ShellOutput, ai as ShellOutputDeltaUpdate, aj as StepCompletedUpdate, ak as StepStartedUpdate, al as StreamToCompletionResult, am as SummaryCompletedUpdate, an as SummaryStartedUpdate, ao as SummaryUpdate, ap as TextBlock, aq as TextDeltaUpdate, ar as ThinkingCompletedUpdate, as as ThinkingDeltaUpdate, at as ThinkingMessage, au as TokenDeltaUpdate, av as TokenUsage, aw as ToolCall, ax as ToolCallCompletedUpdate, ay as ToolCallStartedUpdate, az as ToolContextMessage, aA as ToolResult, aB as ToolResultGuardOptions, aC as ToolUseBlock, aD as TurnEndedUpdate, aE as UserMessage, aF as UserMessageAppendedUpdate, aG as applyMode, aH as emitRunEvent } from './run-DFM1H2jW.cjs';
|
|
7
7
|
import * as zod from 'zod';
|
|
@@ -955,106 +955,6 @@ declare class UnicodeNormalizer {
|
|
|
955
955
|
static create(opts?: UnicodeNormalizerOptions): Processor;
|
|
956
956
|
}
|
|
957
957
|
|
|
958
|
-
/**
|
|
959
|
-
* Judge call primitive (T2.2, ADRs D119-D121).
|
|
960
|
-
*
|
|
961
|
-
* Instantiates a short-lived auxiliary agent that evaluates whether a
|
|
962
|
-
* goal is satisfied. The auxiliary judge runs with `tools: []` and a
|
|
963
|
-
* cheap model (default `openai/gpt-4o-mini`) — see ADR D119. The judge
|
|
964
|
-
* model needs only API access; we read `OPENROUTER_API_KEY` directly
|
|
965
|
-
* from the environment (EC-A — single source of truth) and let the
|
|
966
|
-
* caller override via {@link JudgeOptions.apiKey} for Anthropic or
|
|
967
|
-
* direct-OpenAI environments.
|
|
968
|
-
*
|
|
969
|
-
* NOTE: judge aux agents created from inside a `forkAgent` context will
|
|
970
|
-
* inherit the parent fork's whitelist via AsyncLocalStorage (EC-J).
|
|
971
|
-
* `tools: []` keeps this benign today; future callers that add tools to
|
|
972
|
-
* a judge should be aware.
|
|
973
|
-
*
|
|
974
|
-
* @internal
|
|
975
|
-
*/
|
|
976
|
-
/** Inputs to the judge — pure data. */
|
|
977
|
-
interface JudgeContext {
|
|
978
|
-
goal: string;
|
|
979
|
-
lastResponse: string;
|
|
980
|
-
subgoals?: string[];
|
|
981
|
-
}
|
|
982
|
-
/** Caller-supplied tuning knobs for the judge call. */
|
|
983
|
-
interface JudgeOptions {
|
|
984
|
-
/** Judge model identifier. Default `"openai/gpt-4o-mini"` (ADR D119). */
|
|
985
|
-
judgeModel?: string;
|
|
986
|
-
/** Override env. Default `process.env.OPENROUTER_API_KEY` (EC-A). */
|
|
987
|
-
apiKey?: string;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
* Public types for the judge subsystem (T2.1, ADR D120).
|
|
992
|
-
*
|
|
993
|
-
* @internal
|
|
994
|
-
*/
|
|
995
|
-
/** Outcome of {@link parseVerdict} / {@link judgeCallImpl}. */
|
|
996
|
-
interface JudgeResult {
|
|
997
|
-
verdict: Verdict;
|
|
998
|
-
reason: string;
|
|
999
|
-
/**
|
|
1000
|
-
* `true` when the underlying text did not start with one of the three
|
|
1001
|
-
* canonical prefixes. The verdict is set to `"continue"` (fail-safe,
|
|
1002
|
-
* ADR D121) to avoid stopping prematurely; callers track consecutive
|
|
1003
|
-
* failures and bail via `maxConsecutiveJudgeFailures`.
|
|
1004
|
-
*/
|
|
1005
|
-
parseFailed: boolean;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* Goal-driven Ralph loop (T3.2, ADRs D115-D121).
|
|
1010
|
-
*
|
|
1011
|
-
* `runUntilImpl` is an `AsyncGenerator<GoalEvent, GoalResult, void>`:
|
|
1012
|
-
* yields events as the loop progresses, returns the final result when
|
|
1013
|
-
* the goal completes, fails, or is paused. The auxiliary judge model is
|
|
1014
|
-
* injected via `deps.judge` so the generator stays free of the `Agent`
|
|
1015
|
-
* façade import.
|
|
1016
|
-
*
|
|
1017
|
-
* EC-C fix: pre-aborted signals emit only `[paused]`, not `[active, paused]`.
|
|
1018
|
-
* EC-D: `maxTurns: 0` is supported (vacuous yield active → failed).
|
|
1019
|
-
*
|
|
1020
|
-
* @internal
|
|
1021
|
-
*/
|
|
1022
|
-
|
|
1023
|
-
/** DI contract: the judge is the only external touchpoint. */
|
|
1024
|
-
interface RunUntilDeps {
|
|
1025
|
-
judge: (ctx: JudgeContext, opts?: JudgeOptions) => Promise<JudgeResult>;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* M56 (agent-builder goal transparency) — PUBLIC goal-loop driver for CUSTOM agent surfaces.
|
|
1030
|
-
*
|
|
1031
|
-
* `LocalAgent.runUntil` binds the goal loop to a registered local agent. Surfaces that route turns
|
|
1032
|
-
* through their OWN transport (e.g. a TUI store facade, so every goal turn renders in the same
|
|
1033
|
-
* timeline as a manual turn) need the SAME loop over a minimal `send → wait` shape. This export
|
|
1034
|
-
* gives them exactly that: the canonical `runUntilImpl` (judge + continuation + token budget +
|
|
1035
|
-
* Codex states) with the default judge wired from the DI registry.
|
|
1036
|
-
*
|
|
1037
|
-
* @public
|
|
1038
|
-
*/
|
|
1039
|
-
|
|
1040
|
-
/** The minimal surface the goal loop drives — anything that can send a prompt and wait for it. */
|
|
1041
|
-
interface GoalLoopAgent {
|
|
1042
|
-
send(prompt: string): Promise<{
|
|
1043
|
-
wait(): Promise<{
|
|
1044
|
-
result?: string;
|
|
1045
|
-
usage?: {
|
|
1046
|
-
totalTokens?: number;
|
|
1047
|
-
};
|
|
1048
|
-
}>;
|
|
1049
|
-
}>;
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Run the goal-driven loop (`send → judge → continuation`) over ANY `send → wait` surface.
|
|
1053
|
-
* Identical semantics to `Agent.runUntil` (ADRs D115-D121 + M55 token budget / states).
|
|
1054
|
-
* `depsOverride` is a test seam for injecting a fake judge.
|
|
1055
|
-
*/
|
|
1056
|
-
declare function runGoalLoop(agent: GoalLoopAgent, goal: string, options?: GoalOptions, depsOverride?: RunUntilDeps): AsyncGenerator<GoalEvent, GoalResult, void>;
|
|
1057
|
-
|
|
1058
958
|
/**
|
|
1059
959
|
* Plugin contract — RUNTIME value + type re-exports (T1.1, ADRs D97-D101).
|
|
1060
960
|
*
|
|
@@ -1262,6 +1162,112 @@ declare class EventBus<Events extends Record<string, unknown>> {
|
|
|
1262
1162
|
once<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
|
|
1263
1163
|
}
|
|
1264
1164
|
|
|
1165
|
+
/**
|
|
1166
|
+
* Judge call primitive (T2.2, ADRs D119-D121).
|
|
1167
|
+
*
|
|
1168
|
+
* Instantiates a short-lived auxiliary agent that evaluates whether a
|
|
1169
|
+
* goal is satisfied. The auxiliary judge runs with `tools: []` and a
|
|
1170
|
+
* cheap model (default `openai/gpt-4o-mini`) — see ADR D119. The judge
|
|
1171
|
+
* model needs only API access; we read `OPENROUTER_API_KEY` directly
|
|
1172
|
+
* from the environment (EC-A — single source of truth) and let the
|
|
1173
|
+
* caller override via {@link JudgeOptions.apiKey} for Anthropic or
|
|
1174
|
+
* direct-OpenAI environments.
|
|
1175
|
+
*
|
|
1176
|
+
* NOTE: judge aux agents created from inside a `forkAgent` context will
|
|
1177
|
+
* inherit the parent fork's whitelist via AsyncLocalStorage (EC-J).
|
|
1178
|
+
* `tools: []` keeps this benign today; future callers that add tools to
|
|
1179
|
+
* a judge should be aware.
|
|
1180
|
+
*
|
|
1181
|
+
* @internal
|
|
1182
|
+
*/
|
|
1183
|
+
/** Inputs to the judge — pure data. */
|
|
1184
|
+
interface JudgeContext {
|
|
1185
|
+
goal: string;
|
|
1186
|
+
lastResponse: string;
|
|
1187
|
+
subgoals?: string[];
|
|
1188
|
+
}
|
|
1189
|
+
/** Caller-supplied tuning knobs for the judge call. */
|
|
1190
|
+
interface JudgeOptions {
|
|
1191
|
+
/** Judge model identifier. Default `"openai/gpt-4o-mini"` (ADR D119). */
|
|
1192
|
+
judgeModel?: string;
|
|
1193
|
+
/** Override env. Default `process.env.OPENROUTER_API_KEY` (EC-A). */
|
|
1194
|
+
apiKey?: string;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Public types for the judge subsystem (T2.1, ADR D120).
|
|
1199
|
+
*
|
|
1200
|
+
* @internal
|
|
1201
|
+
*/
|
|
1202
|
+
/** Outcome of {@link parseVerdict} / {@link judgeCallImpl}. */
|
|
1203
|
+
interface JudgeResult {
|
|
1204
|
+
verdict: Verdict;
|
|
1205
|
+
reason: string;
|
|
1206
|
+
/**
|
|
1207
|
+
* `true` when the underlying text did not start with one of the three
|
|
1208
|
+
* canonical prefixes. The verdict is set to `"continue"` (fail-safe,
|
|
1209
|
+
* ADR D121) to avoid stopping prematurely; callers track consecutive
|
|
1210
|
+
* failures and bail via `maxConsecutiveJudgeFailures`.
|
|
1211
|
+
*/
|
|
1212
|
+
parseFailed: boolean;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* Goal-driven Ralph loop (T3.2, ADRs D115-D121).
|
|
1217
|
+
*
|
|
1218
|
+
* `runUntilImpl` is an `AsyncGenerator<GoalEvent, GoalResult, void>`:
|
|
1219
|
+
* yields events as the loop progresses, returns the final result when
|
|
1220
|
+
* the goal completes, fails, or is paused. The auxiliary judge model is
|
|
1221
|
+
* injected via `deps.judge` so the generator stays free of the `Agent`
|
|
1222
|
+
* façade import.
|
|
1223
|
+
*
|
|
1224
|
+
* EC-C fix: pre-aborted signals emit only `[paused]`, not `[active, paused]`.
|
|
1225
|
+
* EC-D: `maxTurns: 0` is supported (vacuous yield active → failed).
|
|
1226
|
+
*
|
|
1227
|
+
* @internal
|
|
1228
|
+
*/
|
|
1229
|
+
|
|
1230
|
+
/** DI contract: the judge is the only external touchpoint. */
|
|
1231
|
+
interface RunUntilDeps {
|
|
1232
|
+
judge: (ctx: JudgeContext, opts?: JudgeOptions) => Promise<JudgeResult>;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* M56 (agent-builder goal transparency) — PUBLIC goal-loop driver for CUSTOM agent surfaces.
|
|
1237
|
+
*
|
|
1238
|
+
* `LocalAgent.runUntil` binds the goal loop to a registered local agent. Surfaces that route turns
|
|
1239
|
+
* through their OWN transport (e.g. a TUI store facade, so every goal turn renders in the same
|
|
1240
|
+
* timeline as a manual turn) need the SAME loop over a minimal `send → wait` shape. This export
|
|
1241
|
+
* gives them exactly that: the canonical `runUntilImpl` (judge + continuation + token budget +
|
|
1242
|
+
* Codex states) with the default judge wired from the DI registry.
|
|
1243
|
+
*
|
|
1244
|
+
* @public
|
|
1245
|
+
*/
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* Stable marker on the FIRST LINE of every goal-continuation prompt. Surfaces detect it to render the
|
|
1249
|
+
* turn collapsed, exclude it from backtrack windows, and skip it in compaction preservation.
|
|
1250
|
+
*/
|
|
1251
|
+
declare const GOAL_CONTINUATION_MARKER = "[[theokit:goal-continuation]]";
|
|
1252
|
+
|
|
1253
|
+
/** The minimal surface the goal loop drives — anything that can send a prompt and wait for it. */
|
|
1254
|
+
interface GoalLoopAgent {
|
|
1255
|
+
send(prompt: string): Promise<{
|
|
1256
|
+
wait(): Promise<{
|
|
1257
|
+
result?: string;
|
|
1258
|
+
usage?: {
|
|
1259
|
+
totalTokens?: number;
|
|
1260
|
+
};
|
|
1261
|
+
}>;
|
|
1262
|
+
}>;
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Run the goal-driven loop (`send → judge → continuation`) over ANY `send → wait` surface.
|
|
1266
|
+
* Identical semantics to `Agent.runUntil` (ADRs D115-D121 + M55 token budget / states).
|
|
1267
|
+
* `depsOverride` is a test seam for injecting a fake judge.
|
|
1268
|
+
*/
|
|
1269
|
+
declare function runGoalLoop(agent: GoalLoopAgent, goal: string, options?: GoalOptions, depsOverride?: RunUntilDeps): AsyncGenerator<GoalEvent, GoalResult, void>;
|
|
1270
|
+
|
|
1265
1271
|
/**
|
|
1266
1272
|
* Reference `BudgetTracker` impl — pure token + iteration counter
|
|
1267
1273
|
* (SDK 2.0 Phase 2 / T2.1 — ADR D1 reference implementation).
|
|
@@ -2300,4 +2306,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2300
2306
|
model?: string;
|
|
2301
2307
|
}): ShareGptTrajectory | null;
|
|
2302
2308
|
|
|
2303
|
-
export { Agent, AgentBuilder, AgentDefinition, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, ErrorMetadata, EventBus, type EvictReason, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
2309
|
+
export { Agent, AgentBuilder, AgentDefinition, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, ErrorMetadata, EventBus, type EvictReason, GOAL_CONTINUATION_MARKER, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot, E as ErrorMetadata } from './errors-CG2RpeW-.js';
|
|
2
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, m as ErrorCode, 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-CG2RpeW-.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
|
|
4
|
-
export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentMemory, y as BudgetCheck, z as BudgetTotal, D as BudgetUsageEvent, E as CloudEnv, F as CloudRepo, H as ContextBudget, J as ContextManagerKind, K as ContextSnapshot, N as ContextSource, O as ContextSourceStatus, Q as CreateSkillSpec, R as Cron, T as CronCreateOptions, U as CronGetOptions, V as CronJob, W as CronJobStatus, X as CronListOptions, Y as CronOperationOptions, Z as CronRunOptions, _ as CronRuntime, $ as CronSchedulerStatus, a0 as CronStartOptions, a1 as HookName, a2 as InvalidateCacheOptions, a3 as MemoryAdapter, a4 as MemoryAdapterCapabilities, a5 as MemoryContext, a6 as MemoryFact, a7 as MemoryProviderHandle, a8 as MemoryProviderInitOptions, a9 as MemoryRevision, aa as MemoryToolSchema, ab as MemoryTurnMessage, ac as PersonalityPreset, ad as PluginContext, ae as PostAssistantReplyContext, af as PreToolCallContext, ag as PreUserSendContext, ah as PreUserSendResult, ai as ProviderCapability, aj as ProviderRoute, ak as ProviderTransform, al as ProviderTransformContext, am as RecordSessionSummaryArgs, an as ResolvedProviderRoute, ao as RunUntilIterator, ap as SDKAgentPlugins, aq as SDKAgentSkillDetail, ar as SDKAgentSkills, as as SDKArtifact, at as SDKContextManager, au as SDKPluginMetadata, av as SDKProvidersManager, aw as SessionRecord, ax as SessionStore, ay as SettingSource, az as Skill, aA as SkillsResolver, aB as SkillsResolverContext, aC as SystemPromptContext, aD as SystemPromptMemoryFact, aE as SystemPromptSkillRef, aF as TelemetrySettings } from './cron-
|
|
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 Plugin$1, m as ProviderProfile, I as InlineSkill, n as GoalOptions, o as GoalEvent, p as GoalResult, B as BudgetTracker, q as MemoryProvider, r as MemoryId, s as PreToolCallDecision, t as StepResult, u as SDKProvider } from './cron-Bhdyjl0B.js';
|
|
4
|
+
export { v as ActiveMemoryPassArgs, w as ActiveMemoryPassResult, x as AgentMemory, y as BudgetCheck, z as BudgetTotal, D as BudgetUsageEvent, E as CloudEnv, F as CloudRepo, H as ContextBudget, J as ContextManagerKind, K as ContextSnapshot, N as ContextSource, O as ContextSourceStatus, Q as CreateSkillSpec, R as Cron, T as CronCreateOptions, U as CronGetOptions, V as CronJob, W as CronJobStatus, X as CronListOptions, Y as CronOperationOptions, Z as CronRunOptions, _ as CronRuntime, $ as CronSchedulerStatus, a0 as CronStartOptions, a1 as HookName, a2 as InvalidateCacheOptions, a3 as MemoryAdapter, a4 as MemoryAdapterCapabilities, a5 as MemoryContext, a6 as MemoryFact, a7 as MemoryProviderHandle, a8 as MemoryProviderInitOptions, a9 as MemoryRevision, aa as MemoryToolSchema, ab as MemoryTurnMessage, ac as PersonalityPreset, ad as PluginContext, ae as PostAssistantReplyContext, af as PreToolCallContext, ag as PreUserSendContext, ah as PreUserSendResult, ai as ProviderCapability, aj as ProviderRoute, ak as ProviderTransform, al as ProviderTransformContext, am as RecordSessionSummaryArgs, an as ResolvedProviderRoute, ao as RunUntilIterator, ap as SDKAgentPlugins, aq as SDKAgentSkillDetail, ar as SDKAgentSkills, as as SDKArtifact, at as SDKContextManager, au as SDKPluginMetadata, av as SDKProvidersManager, aw as SessionRecord, ax as SessionStore, ay as SettingSource, az as Skill, aA as SkillsResolver, aB as SkillsResolverContext, aC as SystemPromptContext, aD as SystemPromptMemoryFact, aE as SystemPromptSkillRef, aF as TelemetrySettings } from './cron-Bhdyjl0B.js';
|
|
5
5
|
import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, P as Processor, T as ToolResultContentBlock, c as PermissionMode, d as PermissionEngine, e as RunEventSink, S as SDKMessage } from './run-DFM1H2jW.js';
|
|
6
6
|
export { A as AgentConversationTurn, f as AssistantMessage, g as CompletionCheck, h as CompletionCheckResult, i as ConversationStep, j as ConversationTurn, k as CostBreakdown, l as CostSource, m as CostStatus, D as DoomLoopThresholds, G as GenerateOptions, n as GenerateRunResult, I as ImageBlock, o as InputProcessorContext, p as InteractionUpdate, q as McpAuthConfig, r as McpHttpServerConfig, s as McpOAuthConfig, t as McpStdioServerConfig, u as MessageOrigin, v as ModelParameterValue, O as OutputProcessorContext, w as PartialToolCallUpdate, x as PermissionAction, y as PermissionEngineOptions, z as PermissionRule, B as ProcessorControls, E as ProcessorTripwire, F as ProcessorViolation, H as RunCompactBoundaryEvent, J as RunCompletionCheckEvent, K as RunErrorDetail, L as RunEvent, N as RunGitInfo, Q as RunOperation, U as RunPermissionDeniedEvent, V as RunRateLimitEvent, W as RunStatus, X as RunTaskCompletedEvent, Y as RunTaskStartedEvent, Z as RunTaskUpdatedEvent, _ as RunToCompletionOptions, $ as RunToCompletionResult, a0 as RunToolProgressEvent, a1 as RunTripwireEvent, a2 as SDKAssistantMessage, a3 as SDKImage, a4 as SDKImageDimension, a5 as SDKObjectDelta, a6 as SDKRequestMessage, a7 as SDKStatusMessage, a8 as SDKSystemMessage, a9 as SDKTaskMessage, aa as SDKThinkingMessage, ab as SDKToolUseMessage, ac as SDKUserMessage, ad as SDKUserMessageEvent, ae as SendOptions, af as ShellCommand, ag as ShellConversationTurn, ah as ShellOutput, ai as ShellOutputDeltaUpdate, aj as StepCompletedUpdate, ak as StepStartedUpdate, al as StreamToCompletionResult, am as SummaryCompletedUpdate, an as SummaryStartedUpdate, ao as SummaryUpdate, ap as TextBlock, aq as TextDeltaUpdate, ar as ThinkingCompletedUpdate, as as ThinkingDeltaUpdate, at as ThinkingMessage, au as TokenDeltaUpdate, av as TokenUsage, aw as ToolCall, ax as ToolCallCompletedUpdate, ay as ToolCallStartedUpdate, az as ToolContextMessage, aA as ToolResult, aB as ToolResultGuardOptions, aC as ToolUseBlock, aD as TurnEndedUpdate, aE as UserMessage, aF as UserMessageAppendedUpdate, aG as applyMode, aH as emitRunEvent } from './run-DFM1H2jW.js';
|
|
7
7
|
import * as zod from 'zod';
|
|
@@ -955,106 +955,6 @@ declare class UnicodeNormalizer {
|
|
|
955
955
|
static create(opts?: UnicodeNormalizerOptions): Processor;
|
|
956
956
|
}
|
|
957
957
|
|
|
958
|
-
/**
|
|
959
|
-
* Judge call primitive (T2.2, ADRs D119-D121).
|
|
960
|
-
*
|
|
961
|
-
* Instantiates a short-lived auxiliary agent that evaluates whether a
|
|
962
|
-
* goal is satisfied. The auxiliary judge runs with `tools: []` and a
|
|
963
|
-
* cheap model (default `openai/gpt-4o-mini`) — see ADR D119. The judge
|
|
964
|
-
* model needs only API access; we read `OPENROUTER_API_KEY` directly
|
|
965
|
-
* from the environment (EC-A — single source of truth) and let the
|
|
966
|
-
* caller override via {@link JudgeOptions.apiKey} for Anthropic or
|
|
967
|
-
* direct-OpenAI environments.
|
|
968
|
-
*
|
|
969
|
-
* NOTE: judge aux agents created from inside a `forkAgent` context will
|
|
970
|
-
* inherit the parent fork's whitelist via AsyncLocalStorage (EC-J).
|
|
971
|
-
* `tools: []` keeps this benign today; future callers that add tools to
|
|
972
|
-
* a judge should be aware.
|
|
973
|
-
*
|
|
974
|
-
* @internal
|
|
975
|
-
*/
|
|
976
|
-
/** Inputs to the judge — pure data. */
|
|
977
|
-
interface JudgeContext {
|
|
978
|
-
goal: string;
|
|
979
|
-
lastResponse: string;
|
|
980
|
-
subgoals?: string[];
|
|
981
|
-
}
|
|
982
|
-
/** Caller-supplied tuning knobs for the judge call. */
|
|
983
|
-
interface JudgeOptions {
|
|
984
|
-
/** Judge model identifier. Default `"openai/gpt-4o-mini"` (ADR D119). */
|
|
985
|
-
judgeModel?: string;
|
|
986
|
-
/** Override env. Default `process.env.OPENROUTER_API_KEY` (EC-A). */
|
|
987
|
-
apiKey?: string;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
* Public types for the judge subsystem (T2.1, ADR D120).
|
|
992
|
-
*
|
|
993
|
-
* @internal
|
|
994
|
-
*/
|
|
995
|
-
/** Outcome of {@link parseVerdict} / {@link judgeCallImpl}. */
|
|
996
|
-
interface JudgeResult {
|
|
997
|
-
verdict: Verdict;
|
|
998
|
-
reason: string;
|
|
999
|
-
/**
|
|
1000
|
-
* `true` when the underlying text did not start with one of the three
|
|
1001
|
-
* canonical prefixes. The verdict is set to `"continue"` (fail-safe,
|
|
1002
|
-
* ADR D121) to avoid stopping prematurely; callers track consecutive
|
|
1003
|
-
* failures and bail via `maxConsecutiveJudgeFailures`.
|
|
1004
|
-
*/
|
|
1005
|
-
parseFailed: boolean;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* Goal-driven Ralph loop (T3.2, ADRs D115-D121).
|
|
1010
|
-
*
|
|
1011
|
-
* `runUntilImpl` is an `AsyncGenerator<GoalEvent, GoalResult, void>`:
|
|
1012
|
-
* yields events as the loop progresses, returns the final result when
|
|
1013
|
-
* the goal completes, fails, or is paused. The auxiliary judge model is
|
|
1014
|
-
* injected via `deps.judge` so the generator stays free of the `Agent`
|
|
1015
|
-
* façade import.
|
|
1016
|
-
*
|
|
1017
|
-
* EC-C fix: pre-aborted signals emit only `[paused]`, not `[active, paused]`.
|
|
1018
|
-
* EC-D: `maxTurns: 0` is supported (vacuous yield active → failed).
|
|
1019
|
-
*
|
|
1020
|
-
* @internal
|
|
1021
|
-
*/
|
|
1022
|
-
|
|
1023
|
-
/** DI contract: the judge is the only external touchpoint. */
|
|
1024
|
-
interface RunUntilDeps {
|
|
1025
|
-
judge: (ctx: JudgeContext, opts?: JudgeOptions) => Promise<JudgeResult>;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* M56 (agent-builder goal transparency) — PUBLIC goal-loop driver for CUSTOM agent surfaces.
|
|
1030
|
-
*
|
|
1031
|
-
* `LocalAgent.runUntil` binds the goal loop to a registered local agent. Surfaces that route turns
|
|
1032
|
-
* through their OWN transport (e.g. a TUI store facade, so every goal turn renders in the same
|
|
1033
|
-
* timeline as a manual turn) need the SAME loop over a minimal `send → wait` shape. This export
|
|
1034
|
-
* gives them exactly that: the canonical `runUntilImpl` (judge + continuation + token budget +
|
|
1035
|
-
* Codex states) with the default judge wired from the DI registry.
|
|
1036
|
-
*
|
|
1037
|
-
* @public
|
|
1038
|
-
*/
|
|
1039
|
-
|
|
1040
|
-
/** The minimal surface the goal loop drives — anything that can send a prompt and wait for it. */
|
|
1041
|
-
interface GoalLoopAgent {
|
|
1042
|
-
send(prompt: string): Promise<{
|
|
1043
|
-
wait(): Promise<{
|
|
1044
|
-
result?: string;
|
|
1045
|
-
usage?: {
|
|
1046
|
-
totalTokens?: number;
|
|
1047
|
-
};
|
|
1048
|
-
}>;
|
|
1049
|
-
}>;
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Run the goal-driven loop (`send → judge → continuation`) over ANY `send → wait` surface.
|
|
1053
|
-
* Identical semantics to `Agent.runUntil` (ADRs D115-D121 + M55 token budget / states).
|
|
1054
|
-
* `depsOverride` is a test seam for injecting a fake judge.
|
|
1055
|
-
*/
|
|
1056
|
-
declare function runGoalLoop(agent: GoalLoopAgent, goal: string, options?: GoalOptions, depsOverride?: RunUntilDeps): AsyncGenerator<GoalEvent, GoalResult, void>;
|
|
1057
|
-
|
|
1058
958
|
/**
|
|
1059
959
|
* Plugin contract — RUNTIME value + type re-exports (T1.1, ADRs D97-D101).
|
|
1060
960
|
*
|
|
@@ -1262,6 +1162,112 @@ declare class EventBus<Events extends Record<string, unknown>> {
|
|
|
1262
1162
|
once<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
|
|
1263
1163
|
}
|
|
1264
1164
|
|
|
1165
|
+
/**
|
|
1166
|
+
* Judge call primitive (T2.2, ADRs D119-D121).
|
|
1167
|
+
*
|
|
1168
|
+
* Instantiates a short-lived auxiliary agent that evaluates whether a
|
|
1169
|
+
* goal is satisfied. The auxiliary judge runs with `tools: []` and a
|
|
1170
|
+
* cheap model (default `openai/gpt-4o-mini`) — see ADR D119. The judge
|
|
1171
|
+
* model needs only API access; we read `OPENROUTER_API_KEY` directly
|
|
1172
|
+
* from the environment (EC-A — single source of truth) and let the
|
|
1173
|
+
* caller override via {@link JudgeOptions.apiKey} for Anthropic or
|
|
1174
|
+
* direct-OpenAI environments.
|
|
1175
|
+
*
|
|
1176
|
+
* NOTE: judge aux agents created from inside a `forkAgent` context will
|
|
1177
|
+
* inherit the parent fork's whitelist via AsyncLocalStorage (EC-J).
|
|
1178
|
+
* `tools: []` keeps this benign today; future callers that add tools to
|
|
1179
|
+
* a judge should be aware.
|
|
1180
|
+
*
|
|
1181
|
+
* @internal
|
|
1182
|
+
*/
|
|
1183
|
+
/** Inputs to the judge — pure data. */
|
|
1184
|
+
interface JudgeContext {
|
|
1185
|
+
goal: string;
|
|
1186
|
+
lastResponse: string;
|
|
1187
|
+
subgoals?: string[];
|
|
1188
|
+
}
|
|
1189
|
+
/** Caller-supplied tuning knobs for the judge call. */
|
|
1190
|
+
interface JudgeOptions {
|
|
1191
|
+
/** Judge model identifier. Default `"openai/gpt-4o-mini"` (ADR D119). */
|
|
1192
|
+
judgeModel?: string;
|
|
1193
|
+
/** Override env. Default `process.env.OPENROUTER_API_KEY` (EC-A). */
|
|
1194
|
+
apiKey?: string;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Public types for the judge subsystem (T2.1, ADR D120).
|
|
1199
|
+
*
|
|
1200
|
+
* @internal
|
|
1201
|
+
*/
|
|
1202
|
+
/** Outcome of {@link parseVerdict} / {@link judgeCallImpl}. */
|
|
1203
|
+
interface JudgeResult {
|
|
1204
|
+
verdict: Verdict;
|
|
1205
|
+
reason: string;
|
|
1206
|
+
/**
|
|
1207
|
+
* `true` when the underlying text did not start with one of the three
|
|
1208
|
+
* canonical prefixes. The verdict is set to `"continue"` (fail-safe,
|
|
1209
|
+
* ADR D121) to avoid stopping prematurely; callers track consecutive
|
|
1210
|
+
* failures and bail via `maxConsecutiveJudgeFailures`.
|
|
1211
|
+
*/
|
|
1212
|
+
parseFailed: boolean;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* Goal-driven Ralph loop (T3.2, ADRs D115-D121).
|
|
1217
|
+
*
|
|
1218
|
+
* `runUntilImpl` is an `AsyncGenerator<GoalEvent, GoalResult, void>`:
|
|
1219
|
+
* yields events as the loop progresses, returns the final result when
|
|
1220
|
+
* the goal completes, fails, or is paused. The auxiliary judge model is
|
|
1221
|
+
* injected via `deps.judge` so the generator stays free of the `Agent`
|
|
1222
|
+
* façade import.
|
|
1223
|
+
*
|
|
1224
|
+
* EC-C fix: pre-aborted signals emit only `[paused]`, not `[active, paused]`.
|
|
1225
|
+
* EC-D: `maxTurns: 0` is supported (vacuous yield active → failed).
|
|
1226
|
+
*
|
|
1227
|
+
* @internal
|
|
1228
|
+
*/
|
|
1229
|
+
|
|
1230
|
+
/** DI contract: the judge is the only external touchpoint. */
|
|
1231
|
+
interface RunUntilDeps {
|
|
1232
|
+
judge: (ctx: JudgeContext, opts?: JudgeOptions) => Promise<JudgeResult>;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* M56 (agent-builder goal transparency) — PUBLIC goal-loop driver for CUSTOM agent surfaces.
|
|
1237
|
+
*
|
|
1238
|
+
* `LocalAgent.runUntil` binds the goal loop to a registered local agent. Surfaces that route turns
|
|
1239
|
+
* through their OWN transport (e.g. a TUI store facade, so every goal turn renders in the same
|
|
1240
|
+
* timeline as a manual turn) need the SAME loop over a minimal `send → wait` shape. This export
|
|
1241
|
+
* gives them exactly that: the canonical `runUntilImpl` (judge + continuation + token budget +
|
|
1242
|
+
* Codex states) with the default judge wired from the DI registry.
|
|
1243
|
+
*
|
|
1244
|
+
* @public
|
|
1245
|
+
*/
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* Stable marker on the FIRST LINE of every goal-continuation prompt. Surfaces detect it to render the
|
|
1249
|
+
* turn collapsed, exclude it from backtrack windows, and skip it in compaction preservation.
|
|
1250
|
+
*/
|
|
1251
|
+
declare const GOAL_CONTINUATION_MARKER = "[[theokit:goal-continuation]]";
|
|
1252
|
+
|
|
1253
|
+
/** The minimal surface the goal loop drives — anything that can send a prompt and wait for it. */
|
|
1254
|
+
interface GoalLoopAgent {
|
|
1255
|
+
send(prompt: string): Promise<{
|
|
1256
|
+
wait(): Promise<{
|
|
1257
|
+
result?: string;
|
|
1258
|
+
usage?: {
|
|
1259
|
+
totalTokens?: number;
|
|
1260
|
+
};
|
|
1261
|
+
}>;
|
|
1262
|
+
}>;
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Run the goal-driven loop (`send → judge → continuation`) over ANY `send → wait` surface.
|
|
1266
|
+
* Identical semantics to `Agent.runUntil` (ADRs D115-D121 + M55 token budget / states).
|
|
1267
|
+
* `depsOverride` is a test seam for injecting a fake judge.
|
|
1268
|
+
*/
|
|
1269
|
+
declare function runGoalLoop(agent: GoalLoopAgent, goal: string, options?: GoalOptions, depsOverride?: RunUntilDeps): AsyncGenerator<GoalEvent, GoalResult, void>;
|
|
1270
|
+
|
|
1265
1271
|
/**
|
|
1266
1272
|
* Reference `BudgetTracker` impl — pure token + iteration counter
|
|
1267
1273
|
* (SDK 2.0 Phase 2 / T2.1 — ADR D1 reference implementation).
|
|
@@ -2300,4 +2306,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2300
2306
|
model?: string;
|
|
2301
2307
|
}): ShareGptTrajectory | null;
|
|
2302
2308
|
|
|
2303
|
-
export { Agent, AgentBuilder, AgentDefinition, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, ErrorMetadata, EventBus, type EvictReason, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
2309
|
+
export { Agent, AgentBuilder, AgentDefinition, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, ErrorMetadata, EventBus, type EvictReason, GOAL_CONTINUATION_MARKER, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|