@theokit/sdk 4.18.1 → 4.19.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/dist/{cron-DOW3f-Xu.d.ts → cron-BoMsrUs1.d.ts} +1 -1
- package/dist/{cron-DvP-E6Xx.d.cts → cron-DWc1r8m8.d.cts} +1 -1
- package/dist/cron.d.cts +1 -1
- package/dist/cron.d.ts +1 -1
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -3
- package/dist/index.d.ts +103 -3
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- 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 Plugin$1,
|
|
4
|
-
export {
|
|
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 GoalOptions, m as GoalEvent, n as GoalResult, o as Plugin$1, p as ProviderProfile, I as InlineSkill, B as BudgetTracker, q as MemoryProvider, r as MemoryId, s as PreToolCallDecision, t as StepResult, u as SDKProvider } from './cron-DWc1r8m8.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-DWc1r8m8.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,6 +955,106 @@ 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
|
+
|
|
958
1058
|
/**
|
|
959
1059
|
* Plugin contract — RUNTIME value + type re-exports (T1.1, ADRs D97-D101).
|
|
960
1060
|
*
|
|
@@ -2200,4 +2300,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2200
2300
|
model?: string;
|
|
2201
2301
|
}): ShareGptTrajectory | null;
|
|
2202
2302
|
|
|
2203
|
-
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, 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, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
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 };
|
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 Plugin$1,
|
|
4
|
-
export {
|
|
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 GoalOptions, m as GoalEvent, n as GoalResult, o as Plugin$1, p as ProviderProfile, I as InlineSkill, B as BudgetTracker, q as MemoryProvider, r as MemoryId, s as PreToolCallDecision, t as StepResult, u as SDKProvider } from './cron-BoMsrUs1.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-BoMsrUs1.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,6 +955,106 @@ 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
|
+
|
|
958
1058
|
/**
|
|
959
1059
|
* Plugin contract — RUNTIME value + type re-exports (T1.1, ADRs D97-D101).
|
|
960
1060
|
*
|
|
@@ -2200,4 +2300,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
|
2200
2300
|
model?: string;
|
|
2201
2301
|
}): ShareGptTrajectory | null;
|
|
2202
2302
|
|
|
2203
|
-
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, 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, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -22667,6 +22667,23 @@ async function updateJobStatus(jobId, enabled) {
|
|
|
22667
22667
|
return updated;
|
|
22668
22668
|
}
|
|
22669
22669
|
|
|
22670
|
+
// src/goal-loop.ts
|
|
22671
|
+
function runGoalLoop(agent, goal, options, depsOverride) {
|
|
22672
|
+
async function* wrap() {
|
|
22673
|
+
const { runUntilImpl: runUntilImpl2 } = await Promise.resolve().then(() => (init_run_until(), run_until_exports));
|
|
22674
|
+
const deps = depsOverride ?? await (async () => {
|
|
22675
|
+
const { judgeCallImpl: judgeCallImpl2 } = await Promise.resolve().then(() => (init_judge_call(), judge_call_exports));
|
|
22676
|
+
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
22677
|
+
const create = getAgentFacade2().create;
|
|
22678
|
+
return {
|
|
22679
|
+
judge: (ctx, opts) => judgeCallImpl2(ctx, opts, { create })
|
|
22680
|
+
};
|
|
22681
|
+
})();
|
|
22682
|
+
return yield* runUntilImpl2(agent, goal, options, deps);
|
|
22683
|
+
}
|
|
22684
|
+
return wrap();
|
|
22685
|
+
}
|
|
22686
|
+
|
|
22670
22687
|
// src/define-provider.ts
|
|
22671
22688
|
init_builtin();
|
|
22672
22689
|
init_registry();
|
|
@@ -24502,6 +24519,6 @@ function safeStringify2(v) {
|
|
|
24502
24519
|
// src/index.ts
|
|
24503
24520
|
init_run_events();
|
|
24504
24521
|
|
|
24505
|
-
export { Agent, AgentBuilder, AgentDisposedError, AgentFactory, AgentRunError, AuthenticationError, Budget, BudgetExceededError, ConfigurationError, Cron, EventBus, GenerateObjectError, IntegrationNotConnectedError, InvalidTaskIdError, JobQueue, Memory, MemoryAdapterError, NetworkError, NoopMemoryProvider, PermissionEngine, PermissionPlugin, Plugin, Provider, RateLimitError, Security, Skill, SkillReadTool, Squad, StreamObjectError, Task, TaskNotFoundError, Theokit, TheokitAgentError, TokenLimiter, Tool, ToolError, UnicodeNormalizer, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, applyMode, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, emitRunEvent, estimateTokens2 as estimateTokens, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
24522
|
+
export { Agent, AgentBuilder, AgentDisposedError, AgentFactory, AgentRunError, AuthenticationError, Budget, BudgetExceededError, ConfigurationError, Cron, EventBus, GenerateObjectError, IntegrationNotConnectedError, InvalidTaskIdError, JobQueue, Memory, MemoryAdapterError, NetworkError, NoopMemoryProvider, PermissionEngine, PermissionPlugin, Plugin, Provider, RateLimitError, Security, Skill, SkillReadTool, Squad, StreamObjectError, Task, TaskNotFoundError, Theokit, TheokitAgentError, TokenLimiter, Tool, ToolError, UnicodeNormalizer, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, UsageAccumulator, applyMode, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, emitRunEvent, estimateTokens2 as estimateTokens, extractRawId, getPricingEntry, inferApiMode, isTransientError, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, withCwdMutex };
|
|
24506
24523
|
//# sourceMappingURL=index.js.map
|
|
24507
24524
|
//# sourceMappingURL=index.js.map
|