@theokit/sdk 4.25.0 → 4.27.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.
Files changed (44) hide show
  1. package/dist/{judge-call-7CF7D334.cjs → chunk-4GTXATWK.cjs} +37 -3
  2. package/dist/chunk-4GTXATWK.cjs.map +1 -0
  3. package/dist/{chunk-F3XVLFLM.js → chunk-6M76Z3AI.js} +5 -5
  4. package/dist/{chunk-F3XVLFLM.js.map → chunk-6M76Z3AI.js.map} +1 -1
  5. package/dist/{judge-call-VIMNK5TA.js → chunk-CR3DGWUQ.js} +37 -4
  6. package/dist/chunk-CR3DGWUQ.js.map +1 -0
  7. package/dist/{chunk-4HKMQEPX.js → chunk-OX772BEW.js} +3 -3
  8. package/dist/{chunk-4HKMQEPX.js.map → chunk-OX772BEW.js.map} +1 -1
  9. package/dist/{chunk-CJ6YJ2L3.cjs → chunk-TMNS2LOS.cjs} +7 -7
  10. package/dist/{chunk-CJ6YJ2L3.cjs.map → chunk-TMNS2LOS.cjs.map} +1 -1
  11. package/dist/{chunk-7RMWOMDB.cjs → chunk-WBBYSW3Q.cjs} +5 -5
  12. package/dist/{chunk-7RMWOMDB.cjs.map → chunk-WBBYSW3Q.cjs.map} +1 -1
  13. package/dist/{cron-B_NkE_VM.d.ts → cron-DPUZzncH.d.ts} +35 -2
  14. package/dist/{cron-x3muPNgg.d.cts → cron-DzZ9TMa2.d.cts} +35 -2
  15. package/dist/cron.cjs +3 -3
  16. package/dist/cron.d.cts +1 -1
  17. package/dist/cron.d.ts +1 -1
  18. package/dist/cron.js +2 -2
  19. package/dist/eval.cjs +2 -2
  20. package/dist/eval.js +1 -1
  21. package/dist/index.cjs +27 -22
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +30 -36
  24. package/dist/index.d.ts +30 -36
  25. package/dist/index.js +6 -5
  26. package/dist/index.js.map +1 -1
  27. package/dist/internal/judge/judge-call.d.ts +32 -19
  28. package/dist/internal/runtime/lifecycle/run-until.d.ts +1 -2
  29. package/dist/internal/runtime/lifecycle/wrap-completion-check-run.d.ts +1 -1
  30. package/dist/judge-call-2FULQ6KL.cjs +22 -0
  31. package/dist/judge-call-2FULQ6KL.cjs.map +1 -0
  32. package/dist/judge-call-D7R3ZTZS.js +5 -0
  33. package/dist/judge-call-D7R3ZTZS.js.map +1 -0
  34. package/dist/{run-until-2PX4QBHZ.js → run-until-K7IO7ZPQ.js} +11 -2
  35. package/dist/run-until-K7IO7ZPQ.js.map +1 -0
  36. package/dist/{run-until-DB3LVGZS.cjs → run-until-ZD4PRLNJ.cjs} +11 -2
  37. package/dist/run-until-ZD4PRLNJ.cjs.map +1 -0
  38. package/dist/types/goal-events.d.ts +34 -1
  39. package/package.json +1 -1
  40. package/dist/internal/judge/types.d.ts +0 -17
  41. package/dist/judge-call-7CF7D334.cjs.map +0 -1
  42. package/dist/judge-call-VIMNK5TA.js.map +0 -1
  43. package/dist/run-until-2PX4QBHZ.js.map +0 -1
  44. package/dist/run-until-DB3LVGZS.cjs.map +0 -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-BdL-buYn.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-BdL-buYn.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, 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-x3muPNgg.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-x3muPNgg.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, m as ProviderProfile, I as InlineSkill, J as JudgeResult, 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-DzZ9TMa2.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, K as ContextManagerKind, N as ContextSnapshot, O as ContextSource, Q as ContextSourceStatus, R as CreateSkillSpec, T as Cron, U as CronCreateOptions, V as CronGetOptions, W as CronJob, X as CronJobStatus, Y as CronListOptions, Z as CronOperationOptions, _ as CronRunOptions, $ as CronRuntime, a0 as CronSchedulerStatus, a1 as CronStartOptions, a2 as HookName, a3 as InvalidateCacheOptions, a4 as MemoryAdapter, a5 as MemoryAdapterCapabilities, a6 as MemoryContext, a7 as MemoryFact, a8 as MemoryProviderHandle, a9 as MemoryProviderInitOptions, aa as MemoryRevision, ab as MemoryToolSchema, ac as MemoryTurnMessage, ad as PersonalityPreset, ae as PluginContext, af as PostAssistantReplyContext, ag as PreToolCallContext, ah as PreUserSendContext, ai as PreUserSendResult, aj as ProviderCapability, ak as ProviderRoute, al as ProviderTransform, am as ProviderTransformContext, an as RecordSessionSummaryArgs, ao as ResolvedProviderRoute, ap as RunUntilIterator, aq as SDKAgentPlugins, ar as SDKAgentSkillDetail, as as SDKAgentSkills, at as SDKArtifact, au as SDKContextManager, av as SDKPluginMetadata, aw as SDKProvidersManager, ax as SessionRecord, ay as SessionStore, az as SettingSource, aA as Skill, aB as SkillsResolver, aC as SkillsResolverContext, aD as SystemPromptContext, aE as SystemPromptMemoryFact, aF as SystemPromptSkillRef, aG as TelemetrySettings, aH as Verdict } from './cron-DzZ9TMa2.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-OJbGyweZ.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-OJbGyweZ.cjs';
7
7
  import * as zod from 'zod';
@@ -1163,24 +1163,6 @@ declare class EventBus<Events extends Record<string, unknown>> {
1163
1163
  once<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
1164
1164
  }
1165
1165
 
1166
- /**
1167
- * Judge call primitive (T2.2, ADRs D119-D121).
1168
- *
1169
- * Instantiates a short-lived auxiliary agent that evaluates whether a
1170
- * goal is satisfied. The auxiliary judge runs with `tools: []` and a
1171
- * cheap model (default `openai/gpt-4o-mini`) — see ADR D119. The judge
1172
- * model needs only API access; we read `OPENROUTER_API_KEY` directly
1173
- * from the environment (EC-A — single source of truth) and let the
1174
- * caller override via {@link JudgeOptions.apiKey} for Anthropic or
1175
- * direct-OpenAI environments.
1176
- *
1177
- * NOTE: judge aux agents created from inside a `forkAgent` context will
1178
- * inherit the parent fork's whitelist via AsyncLocalStorage (EC-J).
1179
- * `tools: []` keeps this benign today; future callers that add tools to
1180
- * a judge should be aware.
1181
- *
1182
- * @internal
1183
- */
1184
1166
  /** Inputs to the judge — pure data. */
1185
1167
  interface JudgeContext {
1186
1168
  goal: string;
@@ -1189,28 +1171,40 @@ interface JudgeContext {
1189
1171
  }
1190
1172
  /** Caller-supplied tuning knobs for the judge call. */
1191
1173
  interface JudgeOptions {
1192
- /** Judge model identifier. Default `"openai/gpt-4o-mini"` (ADR D119). */
1174
+ /**
1175
+ * Judge model identifier. Quando ausente, DERIVA de {@link agentModel} — e só cai no literal
1176
+ * `"openai/gpt-4o-mini"` se nem esse for informado.
1177
+ *
1178
+ * M80 — o default fixo era provider-cego: ele só resolve em OpenRouter. Com chave Anthropic dá
1179
+ * 404, com bearer OAuth dá 401, e em ambos o goal queimava 3 turnos inteiros antes de falhar com
1180
+ * razão enganosa. O agent-builder já contornava isso derivando por conta própria; o conhecimento
1181
+ * pertence aqui.
1182
+ */
1193
1183
  judgeModel?: string;
1184
+ /**
1185
+ * M80 — o modelo do agente CONDUZIDO. É a base da derivação: um judge que roda no mesmo modelo do
1186
+ * chat funciona onde o chat funciona.
1187
+ */
1188
+ agentModel?: string;
1194
1189
  /** Override env. Default `process.env.OPENROUTER_API_KEY` (EC-A). */
1195
1190
  apiKey?: string;
1196
1191
  }
1197
-
1198
1192
  /**
1199
- * Public types for the judge subsystem (T2.1, ADR D120).
1193
+ * M80 a credencial ou o modelo do judge não servem: 401/404.
1200
1194
  *
1201
- * @internal
1195
+ * Falha RÁPIDA por design. `rules/error-handling.md § 2` separa recuperável de irrecuperável, e um
1196
+ * modelo inexistente não passa a existir no retry — dobrar isso em `{parseFailed: true}` fazia o loop
1197
+ * tentar três vezes e reportar "failed" por limite de falhas consecutivas, escondendo que a causa era
1198
+ * credencial. Falha lenta e opaca trocada por rápida e clara.
1199
+ *
1200
+ * Falha de PARSE e erro de rede continuam dobrados: são recuperáveis, e o loop já decide por falhas
1201
+ * consecutivas.
1202
1202
  */
1203
- /** Outcome of {@link parseVerdict} / {@link judgeCallImpl}. */
1204
- interface JudgeResult {
1205
- verdict: Verdict;
1206
- reason: string;
1207
- /**
1208
- * `true` when the underlying text did not start with one of the three
1209
- * canonical prefixes. The verdict is set to `"continue"` (fail-safe,
1210
- * ADR D121) to avoid stopping prematurely; callers track consecutive
1211
- * failures and bail via `maxConsecutiveJudgeFailures`.
1212
- */
1213
- parseFailed: boolean;
1203
+ declare class JudgeCredentialError extends TheokitAgentError {
1204
+ readonly httpStatus: number;
1205
+ readonly judgeModel: string;
1206
+ readonly name = "JudgeCredentialError";
1207
+ constructor(httpStatus: number, judgeModel: string, cause: unknown);
1214
1208
  }
1215
1209
 
1216
1210
  /**
@@ -2315,4 +2309,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
2315
2309
  model?: string;
2316
2310
  }): ShareGptTrajectory | null;
2317
2311
 
2318
- 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 };
2312
+ 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, JudgeCredentialError, JudgeResult, 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-DHZtSNnj.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-DHZtSNnj.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, 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-B_NkE_VM.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-B_NkE_VM.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, m as ProviderProfile, I as InlineSkill, J as JudgeResult, 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-DPUZzncH.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, K as ContextManagerKind, N as ContextSnapshot, O as ContextSource, Q as ContextSourceStatus, R as CreateSkillSpec, T as Cron, U as CronCreateOptions, V as CronGetOptions, W as CronJob, X as CronJobStatus, Y as CronListOptions, Z as CronOperationOptions, _ as CronRunOptions, $ as CronRuntime, a0 as CronSchedulerStatus, a1 as CronStartOptions, a2 as HookName, a3 as InvalidateCacheOptions, a4 as MemoryAdapter, a5 as MemoryAdapterCapabilities, a6 as MemoryContext, a7 as MemoryFact, a8 as MemoryProviderHandle, a9 as MemoryProviderInitOptions, aa as MemoryRevision, ab as MemoryToolSchema, ac as MemoryTurnMessage, ad as PersonalityPreset, ae as PluginContext, af as PostAssistantReplyContext, ag as PreToolCallContext, ah as PreUserSendContext, ai as PreUserSendResult, aj as ProviderCapability, ak as ProviderRoute, al as ProviderTransform, am as ProviderTransformContext, an as RecordSessionSummaryArgs, ao as ResolvedProviderRoute, ap as RunUntilIterator, aq as SDKAgentPlugins, ar as SDKAgentSkillDetail, as as SDKAgentSkills, at as SDKArtifact, au as SDKContextManager, av as SDKPluginMetadata, aw as SDKProvidersManager, ax as SessionRecord, ay as SessionStore, az as SettingSource, aA as Skill, aB as SkillsResolver, aC as SkillsResolverContext, aD as SystemPromptContext, aE as SystemPromptMemoryFact, aF as SystemPromptSkillRef, aG as TelemetrySettings, aH as Verdict } from './cron-DPUZzncH.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-OJbGyweZ.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-OJbGyweZ.js';
7
7
  import * as zod from 'zod';
@@ -1163,24 +1163,6 @@ declare class EventBus<Events extends Record<string, unknown>> {
1163
1163
  once<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
1164
1164
  }
1165
1165
 
1166
- /**
1167
- * Judge call primitive (T2.2, ADRs D119-D121).
1168
- *
1169
- * Instantiates a short-lived auxiliary agent that evaluates whether a
1170
- * goal is satisfied. The auxiliary judge runs with `tools: []` and a
1171
- * cheap model (default `openai/gpt-4o-mini`) — see ADR D119. The judge
1172
- * model needs only API access; we read `OPENROUTER_API_KEY` directly
1173
- * from the environment (EC-A — single source of truth) and let the
1174
- * caller override via {@link JudgeOptions.apiKey} for Anthropic or
1175
- * direct-OpenAI environments.
1176
- *
1177
- * NOTE: judge aux agents created from inside a `forkAgent` context will
1178
- * inherit the parent fork's whitelist via AsyncLocalStorage (EC-J).
1179
- * `tools: []` keeps this benign today; future callers that add tools to
1180
- * a judge should be aware.
1181
- *
1182
- * @internal
1183
- */
1184
1166
  /** Inputs to the judge — pure data. */
1185
1167
  interface JudgeContext {
1186
1168
  goal: string;
@@ -1189,28 +1171,40 @@ interface JudgeContext {
1189
1171
  }
1190
1172
  /** Caller-supplied tuning knobs for the judge call. */
1191
1173
  interface JudgeOptions {
1192
- /** Judge model identifier. Default `"openai/gpt-4o-mini"` (ADR D119). */
1174
+ /**
1175
+ * Judge model identifier. Quando ausente, DERIVA de {@link agentModel} — e só cai no literal
1176
+ * `"openai/gpt-4o-mini"` se nem esse for informado.
1177
+ *
1178
+ * M80 — o default fixo era provider-cego: ele só resolve em OpenRouter. Com chave Anthropic dá
1179
+ * 404, com bearer OAuth dá 401, e em ambos o goal queimava 3 turnos inteiros antes de falhar com
1180
+ * razão enganosa. O agent-builder já contornava isso derivando por conta própria; o conhecimento
1181
+ * pertence aqui.
1182
+ */
1193
1183
  judgeModel?: string;
1184
+ /**
1185
+ * M80 — o modelo do agente CONDUZIDO. É a base da derivação: um judge que roda no mesmo modelo do
1186
+ * chat funciona onde o chat funciona.
1187
+ */
1188
+ agentModel?: string;
1194
1189
  /** Override env. Default `process.env.OPENROUTER_API_KEY` (EC-A). */
1195
1190
  apiKey?: string;
1196
1191
  }
1197
-
1198
1192
  /**
1199
- * Public types for the judge subsystem (T2.1, ADR D120).
1193
+ * M80 a credencial ou o modelo do judge não servem: 401/404.
1200
1194
  *
1201
- * @internal
1195
+ * Falha RÁPIDA por design. `rules/error-handling.md § 2` separa recuperável de irrecuperável, e um
1196
+ * modelo inexistente não passa a existir no retry — dobrar isso em `{parseFailed: true}` fazia o loop
1197
+ * tentar três vezes e reportar "failed" por limite de falhas consecutivas, escondendo que a causa era
1198
+ * credencial. Falha lenta e opaca trocada por rápida e clara.
1199
+ *
1200
+ * Falha de PARSE e erro de rede continuam dobrados: são recuperáveis, e o loop já decide por falhas
1201
+ * consecutivas.
1202
1202
  */
1203
- /** Outcome of {@link parseVerdict} / {@link judgeCallImpl}. */
1204
- interface JudgeResult {
1205
- verdict: Verdict;
1206
- reason: string;
1207
- /**
1208
- * `true` when the underlying text did not start with one of the three
1209
- * canonical prefixes. The verdict is set to `"continue"` (fail-safe,
1210
- * ADR D121) to avoid stopping prematurely; callers track consecutive
1211
- * failures and bail via `maxConsecutiveJudgeFailures`.
1212
- */
1213
- parseFailed: boolean;
1203
+ declare class JudgeCredentialError extends TheokitAgentError {
1204
+ readonly httpStatus: number;
1205
+ readonly judgeModel: string;
1206
+ readonly name = "JudgeCredentialError";
1207
+ constructor(httpStatus: number, judgeModel: string, cause: unknown);
1214
1208
  }
1215
1209
 
1216
1210
  /**
@@ -2315,4 +2309,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
2315
2309
  model?: string;
2316
2310
  }): ShareGptTrajectory | null;
2317
2311
 
2318
- 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 };
2312
+ 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, JudgeCredentialError, JudgeResult, 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
@@ -1,13 +1,14 @@
1
1
  export { StreamObjectError } from './chunk-S5RCBTSF.js';
2
2
  export { GOAL_CONTINUATION_MARKER } from './chunk-2ONFGMBV.js';
3
+ export { JudgeCredentialError } from './chunk-CR3DGWUQ.js';
3
4
  export { GenerateObjectError } from './chunk-TQKCU7CL.js';
4
5
  import './chunk-GJAGKFTR.js';
5
6
  import { Workflow, agentStep } from './chunk-BFWPZMG7.js';
6
7
  import './chunk-UVNG67DG.js';
7
8
  import './chunk-CAH3G4IS.js';
8
- export { Cron } from './chunk-4HKMQEPX.js';
9
- import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, shouldUseFixtureMode, isFixtureApiKey, httpRequest, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-F3XVLFLM.js';
10
- export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-F3XVLFLM.js';
9
+ export { Cron } from './chunk-OX772BEW.js';
10
+ import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, shouldUseFixtureMode, isFixtureApiKey, httpRequest, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-6M76Z3AI.js';
11
+ export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-6M76Z3AI.js';
11
12
  import { configure, submit, list, get, cancel, subscribe } from './chunk-HRA3CPGG.js';
12
13
  export { emitRunEvent } from './chunk-HRA3CPGG.js';
13
14
  import './chunk-SQLZ7ONU.js';
@@ -694,9 +695,9 @@ var EventBus = class {
694
695
  // src/goal-loop.ts
695
696
  function runGoalLoop(agent, goal, options, depsOverride) {
696
697
  async function* wrap() {
697
- const { runUntilImpl } = await import('./run-until-2PX4QBHZ.js');
698
+ const { runUntilImpl } = await import('./run-until-K7IO7ZPQ.js');
698
699
  const deps = depsOverride ?? await (async () => {
699
- const { judgeCallImpl } = await import('./judge-call-VIMNK5TA.js');
700
+ const { judgeCallImpl } = await import('./judge-call-D7R3ZTZS.js');
700
701
  const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
701
702
  const create = getAgentFacade().create;
702
703
  return {