@cuylabs/agent-core 2.0.0 → 3.0.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.
File without changes
@@ -1,5 +1,5 @@
1
- import { br as LocalDispatchRuntimeOptions, aU as DispatchRuntime, T as Tool, d0 as TaskExecutorInput, c$ as TaskExecutor, aR as DispatchRecord, aY as DispatchTargetInspection, aX as DispatchTarget, dh as TeamTask, bx as MemberRuntime, a_ as DispatchTargetStartResult, a$ as DispatchTargetSummary, b7 as ExternalTaskControl } from '../instance-DpAn37V_.js';
2
- export { aI as DEFAULT_DISPATCH_TOOL_IDS, aJ as DEFAULT_LOCAL_DISPATCH_CONCURRENCY, aK as DEFAULT_LOCAL_DISPATCH_DEPTH, aL as DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX, aO as DISPATCH_STATES, aP as DispatchCheckOptions, aQ as DispatchListOptions, aS as DispatchResult, aT as DispatchRole, aV as DispatchStartInput, aW as DispatchState, aZ as DispatchTargetStartInput, b0 as DispatchUsage } from '../instance-DpAn37V_.js';
1
+ import { bu as LocalDispatchRuntimeOptions, aX as DispatchRuntime, T as Tool, d3 as TaskExecutorInput, d2 as TaskExecutor, aU as DispatchRecord, a$ as DispatchTargetInspection, a_ as DispatchTarget, dk as TeamTask, bA as MemberRuntime, b1 as DispatchTargetStartResult, b2 as DispatchTargetSummary, ba as ExternalTaskControl } from '../instance-7RluLpIT.js';
2
+ export { aL as DEFAULT_DISPATCH_TOOL_IDS, aM as DEFAULT_LOCAL_DISPATCH_CONCURRENCY, aN as DEFAULT_LOCAL_DISPATCH_DEPTH, aO as DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX, aR as DISPATCH_STATES, aS as DispatchCheckOptions, aT as DispatchListOptions, aV as DispatchResult, aW as DispatchRole, aY as DispatchStartInput, aZ as DispatchState, b0 as DispatchTargetStartInput, b3 as DispatchUsage } from '../instance-7RluLpIT.js';
3
3
  import '../types-C_LCeYNg.js';
4
4
  import 'ai';
5
5
  import '../types-RSCv7nQ4.js';
@@ -1,7 +1,7 @@
1
- import { e as AnyInferenceResult, cF as StepProcessingOptions, cG as StepProcessingOutput, a6 as AgentTurnStepCommitSnapshot, aF as CreateAgentTurnStepCommitBatchOptions, _ as AgentTurnCommitBatch, c0 as PrepareModelStepOptions, c1 as PreparedAgentModelStep, cd as RunModelStepOptions, A as AgentEvent, ce as RunToolBatchOptions, cf as RunToolBatchResult, av as CommitOutputOptions, aw as CommitStepOptions, dk as TokenUsage, v as ScopeSnapshot, a4 as AgentTurnState, ds as ToolMetadata, a8 as AgentTurnStepCommitToolResult, a7 as AgentTurnStepCommitToolCall, M as Message, dz as UserMessage, ar as AssistantMessage, dr as ToolMessage, cQ as SystemMessage } from '../instance-DpAn37V_.js';
2
- export { Q as AgentTurnActiveToolCall, X as AgentTurnBoundaryMetadata, Y as AgentTurnBoundarySnapshot, Z as AgentTurnCommitApplier, $ as AgentTurnCommitOptions, a0 as AgentTurnEngine, a1 as AgentTurnEngineOptions, a2 as AgentTurnPhase, a3 as AgentTurnResolvedToolCall, a5 as AgentTurnStateAdvanceOptions, a9 as AgentTurnStepRuntimeConfig, aE as CreateAgentTurnStateOptions, dC as advanceAgentTurnState, dG as createAgentTurnEngine, dH as createAgentTurnState, dO as failAgentTurnState } from '../instance-DpAn37V_.js';
1
+ import { e as AnyInferenceResult, cI as StepProcessingOptions, cJ as StepProcessingOutput, a7 as AgentTurnStepCommitSnapshot, aI as CreateAgentTurnStepCommitBatchOptions, $ as AgentTurnCommitBatch, c3 as PrepareModelStepOptions, c4 as PreparedAgentModelStep, cg as RunModelStepOptions, A as AgentEvent, ch as RunToolBatchOptions, ci as RunToolBatchResult, ay as CommitOutputOptions, az as CommitStepOptions, dn as TokenUsage, x as ScopeSnapshot, a5 as AgentTurnState, dv as ToolMetadata, a9 as AgentTurnStepCommitToolResult, a8 as AgentTurnStepCommitToolCall, M as Message, dC as UserMessage, au as AssistantMessage, du as ToolMessage, cT as SystemMessage } from '../instance-7RluLpIT.js';
2
+ export { V as AgentTurnActiveToolCall, Y as AgentTurnBoundaryMetadata, Z as AgentTurnBoundarySnapshot, _ as AgentTurnCommitApplier, a0 as AgentTurnCommitOptions, a1 as AgentTurnEngine, a2 as AgentTurnEngineOptions, a3 as AgentTurnPhase, a4 as AgentTurnResolvedToolCall, a6 as AgentTurnStateAdvanceOptions, aa as AgentTurnStepRuntimeConfig, aH as CreateAgentTurnStateOptions, dF as advanceAgentTurnState, dJ as createAgentTurnEngine, dK as createAgentTurnState, dR as failAgentTurnState } from '../instance-7RluLpIT.js';
3
3
  import { L as Logger } from '../types-RSCv7nQ4.js';
4
- export { c as convertAgentMessagesToModelMessages } from '../model-messages-BDTy2LY_.js';
4
+ export { c as convertAgentMessagesToModelMessages } from '../model-messages-CvIEjaIJ.js';
5
5
  import '../types-C_LCeYNg.js';
6
6
  import 'ai';
7
7
  import 'zod';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as HumanInputController, p as HumanInputConfig, T as Tool, M as Message, S as SessionManager, E as EffectiveAgentConfig, q as TurnChangeTracker, r as InterventionController, b as MiddlewareRunner, P as PromptBuilder, c as ToolExecutionMode, A as AgentEvent, t as StreamProvider, u as Scope, v as ScopeSnapshot, x as ScopeOptions, F as FileOperationMeta, y as AgentSignal, z as TypedHandler, U as Unsubscribe, W as WildcardHandler } from './instance-DpAn37V_.js';
2
- export { B as Agent, C as AgentConfig, G as AgentDefaults, J as AgentDefaultsContext, K as AgentDefaultsProvider, L as AgentMiddleware, N as AgentModelHooks, O as AgentStatus, Q as AgentTurnActiveToolCall, V as AgentTurnBoundaryKind, X as AgentTurnBoundaryMetadata, Y as AgentTurnBoundarySnapshot, Z as AgentTurnCommitApplier, _ as AgentTurnCommitBatch, $ as AgentTurnCommitOptions, a0 as AgentTurnEngine, a1 as AgentTurnEngineOptions, a2 as AgentTurnPhase, a3 as AgentTurnResolvedToolCall, a4 as AgentTurnState, a5 as AgentTurnStateAdvanceOptions, a6 as AgentTurnStepCommitSnapshot, a7 as AgentTurnStepCommitToolCall, a8 as AgentTurnStepCommitToolResult, a9 as AgentTurnStepRuntimeConfig, e as AnyInferenceResult, aa as AppliedProfile, ab as ApprovalAction, ac as ApprovalAgentMiddleware, ad as ApprovalCascadeMode, ae as ApprovalCascadePolicy, af as ApprovalConfig, ag as ApprovalCorrection, ah as ApprovalDecision, ai as ApprovalEvaluation, aj as ApprovalEvent, ak as ApprovalHandler, al as ApprovalMiddlewareConfig, am as ApprovalRememberScope, an as ApprovalRequest, ao as ApprovalResolution, ap as ApprovalRule, aq as ApprovalRuleContext, ar as AssistantMessage, as as BlockedModelCall, at as BranchEntry, au as ChatLifecycleContext, av as CommitOutputOptions, aw as CommitStepOptions, ax as CompactionConfig, ay as CompactionEntry, az as CompatibleSchema, aA as ConfigChangeEntry, aB as CoordinatorNotification, aC as CoordinatorNotificationKind, aD as CoordinatorRoundEvent, aE as CreateAgentTurnStateOptions, aF as CreateAgentTurnStepCommitBatchOptions, aG as CreateSessionOptions, aH as DEFAULT_AGENT_NAME, aI as DEFAULT_DISPATCH_TOOL_IDS, aJ as DEFAULT_LOCAL_DISPATCH_CONCURRENCY, aK as DEFAULT_LOCAL_DISPATCH_DEPTH, aL as DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX, D as DEFAULT_MAX_OUTPUT_TOKENS, aM as DEFAULT_MAX_STEPS, D as DEFAULT_MAX_TOKENS, f as DEFAULT_RETRY_CONFIG, aN as DEFAULT_SYSTEM_PROMPT, aO as DISPATCH_STATES, aP as DispatchCheckOptions, aQ as DispatchListOptions, aR as DispatchRecord, aS as DispatchResult, aT as DispatchRole, aU as DispatchRuntime, aV as DispatchStartInput, aW as DispatchState, aX as DispatchTarget, aY as DispatchTargetInspection, aZ as DispatchTargetStartInput, a_ as DispatchTargetStartResult, a$ as DispatchTargetSummary, b0 as DispatchUsage, b1 as DoomLoopAction, b2 as DoomLoopHandler, b3 as DoomLoopRequest, b4 as EnhancedTools, b5 as EntryBase, b6 as EnvironmentInfo, b7 as ExternalTaskControl, b8 as FileEntry, b9 as GuidancePayload, ba as HumanInputEventContext, bb as HumanInputOption, bc as HumanInputRequest, bd as HumanInputRequestKind, be as HumanInputRequestListOptions, bf as HumanInputRequestRecord, bg as HumanInputRequestStatus, bh as HumanInputResponse, bi as HumanInputTimeoutError, bj as HumanInputToolArgs, bk as HumanInputUnavailableError, bl as IdleNotificationPayload, bm as InMemoryMailboxStore, bn as InMemoryTaskBoardStore, bo as InferSchemaOutput, g as InferenceCustomResult, h as InferenceStepInfo, I as InferenceStreamInput, i as InferenceStreamResult, bp as InputCheckResult, bq as InstructionFile, br as LocalDispatchRuntimeOptions, bs as LocalSessionTurnLock, bt as Mailbox, bu as MailboxStore, bv as MailboxSubscriber, bw as MemberRegisteredEvent, bx as MemberRuntime, by as MemberStats, bz as MemberStatus, bA as MemberStatusChangedEvent, bB as MessageBase, bC as MessageEntry, bD as MessageError, bE as MessageInput, bF as MessageKind, bG as MessageListFilter, bH as MessagePayload, bI as MessageRole, bJ as MessageSentEvent, bK as MetadataEntry, d as ModelCallContext, bL as ModelCallInput, bM as ModelCallOutput, bN as ModelFamily, bO as NormalizedToolReplayPolicy, bP as NotificationPriority, bQ as OnFollowUpQueued, bR as OnInterventionApplied, bS as OtelMiddlewareConfig, bT as PRUNE_PROTECTED_TOOLS, bU as PendingIntervention, bV as PermissionForwardedEvent, bW as PermissionHandler, bX as PermissionRequestPayload, bY as PermissionResolvedEvent, bZ as PermissionResponsePayload, b_ as PlanCreatedEvent, b$ as PlannedTask, c0 as PrepareModelStepOptions, c1 as PreparedAgentModelStep, c2 as PreparedExternalTask, c3 as Profile, c4 as PromptBuildContext, c5 as PromptConfig, c6 as PromptSection, c7 as QueueTaskInput, c8 as ReleaseSessionTurnLock, c9 as RemoteSkillEntry, ca as RemoteSkillIndex, R as RetryConfig, j as RetryHandlerOptions, k as RetryState, cb as RiskLevel, cc as RuleSource, cd as RunModelStepOptions, ce as RunToolBatchOptions, cf as RunToolBatchResult, cg as STORAGE_VERSION, ch as SerializedMessage, ci as Session, cj as SessionContext, ck as SessionEntry, cl as SessionHeader, cm as SessionInfo, cn as SessionStorage, co as SessionTurnLock, cp as SessionTurnLockAcquireOptions, cq as ShutdownRequestPayload, cr as ShutdownRequestedEvent, cs as ShutdownResolvedEvent, ct as ShutdownResponsePayload, cu as SkillConfig, cv as SkillContent, cw as SkillDiscoveryError, cx as SkillDiscoveryResult, cy as SkillMetadata, cz as SkillRegistry, cA as SkillResource, cB as SkillResourceType, cC as SkillScope, cD as SkillSource, cE as SkillSourceType, cF as StepProcessingOptions, cG as StepProcessingOutput, cH as StepProcessingResult, cI as StreamChunk, cJ as StreamInput, cK as StreamProviderConfig, cL as StreamProviderFactory, cM as StreamProviderInput, cN as StreamProviderResult, cO as SynthesisCompleteEvent, cP as SynthesisResult, cQ as SystemMessage, cR as TERMINAL_STATUSES, cS as TaskAbortedEvent, cT as TaskBoard, cU as TaskBoardStore, cV as TaskCompletedEvent, cW as TaskCompletion, cX as TaskConflictError, cY as TaskCreateInput, cZ as TaskCreatedEvent, c_ as TaskDispatchMode, c$ as TaskExecutor, d0 as TaskExecutorInput, d1 as TaskFailedEvent, d2 as TaskListFilter, d3 as TaskResult, d4 as TaskStatus, d5 as TaskTransition, d6 as TaskTransitionEvent, d7 as TaskTransitionReason, d8 as TeamCoordinatorConfig, d9 as TeamEvent, da as TeamMember, db as TeamMessage, dc as TeamNotificationEvent, dd as TeamPlan, de as TeamSnapshot, df as TeamStartedEvent, dg as TeamStoppedEvent, dh as TeamTask, di as TelemetryConfig, dj as TelemetryConfigResult, dk as TokenUsage, dl as ToolCallDecision, dm as ToolCallOutput, dn as ToolCapabilities, dp as ToolContext, dq as ToolHostRequirements, dr as ToolMessage, ds as ToolMetadata, dt as ToolReplayMode, du as ToolReplayPolicy, dv as ToolResult, dw as ToolSideEffectLevel, dx as TracingConfig, a as TurnTrackerContext, dy as UndoResult, dz as UserMessage, dA as WorkerReportPayload, dB as accumulateUsage, dC as advanceAgentTurnState, dD as approvalMiddleware, dE as buildCoordinatorNotificationEvent, l as calculateDelay, dF as createAgent, dG as createAgentTurnEngine, dH as createAgentTurnState, dI as createApprovalHandler, dJ as createHumanInputController, dK as createPromptBuilder, m as createRetryHandler, n as createRetryState, dL as createSkillRegistry, dM as createTurnTracker, dN as emptySkillRegistry, dO as failAgentTurnState, dP as getRequiredToolHost, dQ as isApprovalMiddleware, dR as isBlockedModelCall, dS as isHumanInputController, dT as requiresToolHost, dU as resolveAgentDefaults, dV as resolveCapability, dW as sandboxDefaultsProvider, s as shouldRetry, w as withRetry } from './instance-DpAn37V_.js';
1
+ import { H as HumanInputController, p as HumanInputConfig, T as Tool, M as Message, S as SessionManager, E as EffectiveAgentConfig, q as TurnChangeTracker, r as InterventionController, b as MiddlewareRunner, P as PromptBuilder, t as AgentTurnToolProvider, c as ToolExecutionMode, A as AgentEvent, u as StreamProvider, v as Scope, x as ScopeSnapshot, y as ScopeOptions, F as FileOperationMeta, z as AgentSignal, B as TypedHandler, U as Unsubscribe, W as WildcardHandler } from './instance-7RluLpIT.js';
2
+ export { C as Agent, G as AgentConfig, J as AgentDefaults, K as AgentDefaultsContext, L as AgentDefaultsProvider, N as AgentMiddleware, O as AgentModelHooks, Q as AgentStatus, V as AgentTurnActiveToolCall, X as AgentTurnBoundaryKind, Y as AgentTurnBoundaryMetadata, Z as AgentTurnBoundarySnapshot, _ as AgentTurnCommitApplier, $ as AgentTurnCommitBatch, a0 as AgentTurnCommitOptions, a1 as AgentTurnEngine, a2 as AgentTurnEngineOptions, a3 as AgentTurnPhase, a4 as AgentTurnResolvedToolCall, a5 as AgentTurnState, a6 as AgentTurnStateAdvanceOptions, a7 as AgentTurnStepCommitSnapshot, a8 as AgentTurnStepCommitToolCall, a9 as AgentTurnStepCommitToolResult, aa as AgentTurnStepRuntimeConfig, ab as AgentTurnToolContext, ac as AgentTurnToolProviderResult, e as AnyInferenceResult, ad as AppliedProfile, ae as ApprovalAction, af as ApprovalAgentMiddleware, ag as ApprovalCascadeMode, ah as ApprovalCascadePolicy, ai as ApprovalConfig, aj as ApprovalCorrection, ak as ApprovalDecision, al as ApprovalEvaluation, am as ApprovalEvent, an as ApprovalHandler, ao as ApprovalMiddlewareConfig, ap as ApprovalRememberScope, aq as ApprovalRequest, ar as ApprovalResolution, as as ApprovalRule, at as ApprovalRuleContext, au as AssistantMessage, av as BlockedModelCall, aw as BranchEntry, ax as ChatLifecycleContext, ay as CommitOutputOptions, az as CommitStepOptions, aA as CompactionConfig, aB as CompactionEntry, aC as CompatibleSchema, aD as ConfigChangeEntry, aE as CoordinatorNotification, aF as CoordinatorNotificationKind, aG as CoordinatorRoundEvent, aH as CreateAgentTurnStateOptions, aI as CreateAgentTurnStepCommitBatchOptions, aJ as CreateSessionOptions, aK as DEFAULT_AGENT_NAME, aL as DEFAULT_DISPATCH_TOOL_IDS, aM as DEFAULT_LOCAL_DISPATCH_CONCURRENCY, aN as DEFAULT_LOCAL_DISPATCH_DEPTH, aO as DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX, D as DEFAULT_MAX_OUTPUT_TOKENS, aP as DEFAULT_MAX_STEPS, D as DEFAULT_MAX_TOKENS, f as DEFAULT_RETRY_CONFIG, aQ as DEFAULT_SYSTEM_PROMPT, aR as DISPATCH_STATES, aS as DispatchCheckOptions, aT as DispatchListOptions, aU as DispatchRecord, aV as DispatchResult, aW as DispatchRole, aX as DispatchRuntime, aY as DispatchStartInput, aZ as DispatchState, a_ as DispatchTarget, a$ as DispatchTargetInspection, b0 as DispatchTargetStartInput, b1 as DispatchTargetStartResult, b2 as DispatchTargetSummary, b3 as DispatchUsage, b4 as DoomLoopAction, b5 as DoomLoopHandler, b6 as DoomLoopRequest, b7 as EnhancedTools, b8 as EntryBase, b9 as EnvironmentInfo, ba as ExternalTaskControl, bb as FileEntry, bc as GuidancePayload, bd as HumanInputEventContext, be as HumanInputOption, bf as HumanInputRequest, bg as HumanInputRequestKind, bh as HumanInputRequestListOptions, bi as HumanInputRequestRecord, bj as HumanInputRequestStatus, bk as HumanInputResponse, bl as HumanInputTimeoutError, bm as HumanInputToolArgs, bn as HumanInputUnavailableError, bo as IdleNotificationPayload, bp as InMemoryMailboxStore, bq as InMemoryTaskBoardStore, br as InferSchemaOutput, g as InferenceCustomResult, h as InferenceStepInfo, I as InferenceStreamInput, i as InferenceStreamResult, bs as InputCheckResult, bt as InstructionFile, bu as LocalDispatchRuntimeOptions, bv as LocalSessionTurnLock, bw as Mailbox, bx as MailboxStore, by as MailboxSubscriber, bz as MemberRegisteredEvent, bA as MemberRuntime, bB as MemberStats, bC as MemberStatus, bD as MemberStatusChangedEvent, bE as MessageBase, bF as MessageEntry, bG as MessageError, bH as MessageInput, bI as MessageKind, bJ as MessageListFilter, bK as MessagePayload, bL as MessageRole, bM as MessageSentEvent, bN as MetadataEntry, d as ModelCallContext, bO as ModelCallInput, bP as ModelCallOutput, bQ as ModelFamily, bR as NormalizedToolReplayPolicy, bS as NotificationPriority, bT as OnFollowUpQueued, bU as OnInterventionApplied, bV as OtelMiddlewareConfig, bW as PRUNE_PROTECTED_TOOLS, bX as PendingIntervention, bY as PermissionForwardedEvent, bZ as PermissionHandler, b_ as PermissionRequestPayload, b$ as PermissionResolvedEvent, c0 as PermissionResponsePayload, c1 as PlanCreatedEvent, c2 as PlannedTask, c3 as PrepareModelStepOptions, c4 as PreparedAgentModelStep, c5 as PreparedExternalTask, c6 as Profile, c7 as PromptBuildContext, c8 as PromptConfig, c9 as PromptSection, ca as QueueTaskInput, cb as ReleaseSessionTurnLock, cc as RemoteSkillEntry, cd as RemoteSkillIndex, R as RetryConfig, j as RetryHandlerOptions, k as RetryState, ce as RiskLevel, cf as RuleSource, cg as RunModelStepOptions, ch as RunToolBatchOptions, ci as RunToolBatchResult, cj as STORAGE_VERSION, ck as SerializedMessage, cl as Session, cm as SessionContext, cn as SessionEntry, co as SessionHeader, cp as SessionInfo, cq as SessionStorage, cr as SessionTurnLock, cs as SessionTurnLockAcquireOptions, ct as ShutdownRequestPayload, cu as ShutdownRequestedEvent, cv as ShutdownResolvedEvent, cw as ShutdownResponsePayload, cx as SkillConfig, cy as SkillContent, cz as SkillDiscoveryError, cA as SkillDiscoveryResult, cB as SkillMetadata, cC as SkillRegistry, cD as SkillResource, cE as SkillResourceType, cF as SkillScope, cG as SkillSource, cH as SkillSourceType, cI as StepProcessingOptions, cJ as StepProcessingOutput, cK as StepProcessingResult, cL as StreamChunk, cM as StreamInput, cN as StreamProviderConfig, cO as StreamProviderFactory, cP as StreamProviderInput, cQ as StreamProviderResult, cR as SynthesisCompleteEvent, cS as SynthesisResult, cT as SystemMessage, cU as TERMINAL_STATUSES, cV as TaskAbortedEvent, cW as TaskBoard, cX as TaskBoardStore, cY as TaskCompletedEvent, cZ as TaskCompletion, c_ as TaskConflictError, c$ as TaskCreateInput, d0 as TaskCreatedEvent, d1 as TaskDispatchMode, d2 as TaskExecutor, d3 as TaskExecutorInput, d4 as TaskFailedEvent, d5 as TaskListFilter, d6 as TaskResult, d7 as TaskStatus, d8 as TaskTransition, d9 as TaskTransitionEvent, da as TaskTransitionReason, db as TeamCoordinatorConfig, dc as TeamEvent, dd as TeamMember, de as TeamMessage, df as TeamNotificationEvent, dg as TeamPlan, dh as TeamSnapshot, di as TeamStartedEvent, dj as TeamStoppedEvent, dk as TeamTask, dl as TelemetryConfig, dm as TelemetryConfigResult, dn as TokenUsage, dp as ToolCallDecision, dq as ToolCallOutput, dr as ToolCapabilities, ds as ToolContext, dt as ToolHostRequirements, du as ToolMessage, dv as ToolMetadata, dw as ToolReplayMode, dx as ToolReplayPolicy, dy as ToolResult, dz as ToolSideEffectLevel, dA as TracingConfig, a as TurnTrackerContext, dB as UndoResult, dC as UserMessage, dD as WorkerReportPayload, dE as accumulateUsage, dF as advanceAgentTurnState, dG as approvalMiddleware, dH as buildCoordinatorNotificationEvent, l as calculateDelay, dI as createAgent, dJ as createAgentTurnEngine, dK as createAgentTurnState, dL as createApprovalHandler, dM as createHumanInputController, dN as createPromptBuilder, m as createRetryHandler, n as createRetryState, dO as createSkillRegistry, dP as createTurnTracker, dQ as emptySkillRegistry, dR as failAgentTurnState, dS as getRequiredToolHost, dT as isApprovalMiddleware, dU as isBlockedModelCall, dV as isHumanInputController, dW as requiresToolHost, dX as resolveAgentDefaults, dY as resolveCapability, dZ as sandboxDefaultsProvider, s as shouldRetry, w as withRetry } from './instance-7RluLpIT.js';
3
3
  import { LanguageModel, ModelMessage, Tool as Tool$1, TelemetryOptions } from 'ai';
4
4
  import { T as ToolHost } from './types-C_LCeYNg.js';
5
5
  export { D as DirEntry, E as ExecOptions, a as ExecResult, F as FileStat } from './types-C_LCeYNg.js';
@@ -14,7 +14,7 @@ export { C as CapabilitySource, D as DEFAULT_RESOLVER_OPTIONS, I as InputModalit
14
14
  export { H as HttpTransportConfig, M as MCPConfig, a as MCPManager, b as MCPPromptInfo, c as MCPResourceInfo, d as MCPResourceTemplateInfo, e as MCPServerConfig, f as MCPServerStatus, R as RemoteTransportConfig, S as SseTransportConfig, g as StdioTransportConfig } from './types-DMjoFKKv.js';
15
15
  export { ClientCredentialsOptions, ClientCredentialsProvider, createMCPManager, httpServer, serviceAccountServer, sseServer, stdioServer } from './mcp/index.js';
16
16
  export { AgentTaskChatAdapter, AgentTaskCheckpointReason, AgentTaskCheckpointStrategy, AgentTaskCheckpointStrategyInput, AgentTaskExecutionCheckpoint, AgentTaskExecutionContext, AgentTaskExecutionRun, AgentTaskExecutionSnapshot, AgentTaskObserver, AgentTaskPayload, AgentTaskResult, AgentTaskResumeSnapshot, AgentTaskRunner, AgentTaskRunnerOptions, AgentWorkflowAssistantMessageSnapshot, AgentWorkflowCommitResult, AgentWorkflowInputCommitPlan, AgentWorkflowInterventionSnapshot, AgentWorkflowMessageSnapshot, AgentWorkflowModelStepPlan, AgentWorkflowModelStepResult, AgentWorkflowOperationPlan, AgentWorkflowOutputCommitPlan, AgentWorkflowReplayDecision, AgentWorkflowStepCommitPlan, AgentWorkflowSystemMessageSnapshot, AgentWorkflowToolBatchPlan, AgentWorkflowToolBatchResult, AgentWorkflowToolCallPlan, AgentWorkflowToolCallResult, AgentWorkflowToolCallSnapshot, AgentWorkflowToolMessageSnapshot, AgentWorkflowTurnPhase, AgentWorkflowTurnState, AgentWorkflowUserMessageSnapshot, ContextOverflowError, CreateAgentWorkflowTurnStateOptions, DoomLoopError, applyAgentWorkflowCommitResult, applyAgentWorkflowModelStepResult, applyAgentWorkflowToolBatchResult, applyAgentWorkflowToolCallResult, applyWorkflowInterventions, cloneAgentWorkflowTurnState, commitOutput, commitStep, createAgentTaskRunner, createAgentTurnStepCommitBatch, createAgentWorkflowTurnState, defaultAgentTaskCheckpointStrategy, drainWorkflowInterventions, failAgentWorkflowTurnState, planNextAgentWorkflowOperation, prepareModelStep, processStepStream, queueWorkflowFollowUps, recordAgentWorkflowReplayDecision, restoreAgentWorkflowMessage, restoreAgentWorkflowMessages, runModelStep, runToolBatch, snapshotAgentWorkflowMessage, snapshotAgentWorkflowMessages } from './execution/index.js';
17
- export { c as convertAgentMessagesToModelMessages } from './model-messages-BDTy2LY_.js';
17
+ export { c as convertAgentMessagesToModelMessages } from './model-messages-CvIEjaIJ.js';
18
18
  export { CacheTTL, PromptCacheConfig, createTelemetryConfig, otelMiddleware, promptCacheMiddleware } from './middleware/index.js';
19
19
  export { DEFAULT_INSTRUCTION_PATTERNS, DEFAULT_MAX_DEPTH, DEFAULT_MAX_FILE_SIZE, PRIORITY_BASE, PRIORITY_CUSTOM, PRIORITY_ENVIRONMENT, PRIORITY_INSTRUCTIONS, PRIORITY_OVERRIDE, PRIORITY_SKILLS, detectModelFamily, discoverInstructions, formatEnvironment, formatInstructions, gatherEnvironment, getAvailableFamilies, getTemplate, loadGlobalInstructions, summarizeEnvironment } from './prompt/index.js';
20
20
  export { Profiles, applyProfile, careful, code, createProfile, explore, filterTools, mergeProfiles, plan, quick, review, watch } from './profiles/index.js';
@@ -288,6 +288,7 @@ interface ChatLoopDeps {
288
288
  host: ToolHost;
289
289
  humanInputController?: HumanInputController;
290
290
  mcpTools: Record<string, Tool$1>;
291
+ turnToolProviders: AgentTurnToolProvider[];
291
292
  telemetrySettings?: TelemetryOptions;
292
293
  toModelMessages: (messages: Message[]) => ModelMessage[];
293
294
  setIsStreaming: (value: boolean) => void;
@@ -564,4 +565,4 @@ declare class LocalSignal implements AgentSignal {
564
565
  clear(): void;
565
566
  }
566
567
 
567
- export { AgentEvent, AgentSignal, type AgentState, type ChatLoopDeps, type ContextLimits, ContextManager, type CreateHumanInputToolOptions, DEFAULT_CONTEXT_LIMITS, EffectiveAgentConfig, type EventPrinterOptions, FileOperationMeta, type FollowUpDecisionAction, type FollowUpMode, type FollowUpPolicy, type FollowUpRequest, type FollowUpResponse, type FollowUpStatus, HumanInputConfig, HumanInputController, type HumanInputHandler, InterventionController, LocalSignal, Logger, Message, MiddlewareRunner, PromptBuilder, type QueuedFollowUpRecord, ReasoningLevel, ScopeSnapshot, SessionManager, type SteeringRequest, type SteeringResponse, StreamProvider, Tool, ToolExecutionMode, ToolHost, TurnChangeTracker, autoDetectStreamProvider, canSeedQueuedFollowUp, createEventPrinter, createHumanInputHandler, createHumanInputTool, createHumanInputToolWithController, createHumanInputToolWithHandler, createQueuedFollowUpRecord, currentScope, ensureSessionLoaded, estimateConversationTokens, estimateMessageTokens, estimateTokens, extractFilePathsFromArgs, findCutPoint, getUsableTokenLimit, markQueuedFollowUpApplied, normalizeFollowUpMode, resolveQueuedFollowUp, restoreScope, runChatLoop, shouldCaptureBaseline, sleep, snapshotScope, withinScope };
568
+ export { AgentEvent, AgentSignal, type AgentState, AgentTurnToolProvider, type ChatLoopDeps, type ContextLimits, ContextManager, type CreateHumanInputToolOptions, DEFAULT_CONTEXT_LIMITS, EffectiveAgentConfig, type EventPrinterOptions, FileOperationMeta, type FollowUpDecisionAction, type FollowUpMode, type FollowUpPolicy, type FollowUpRequest, type FollowUpResponse, type FollowUpStatus, HumanInputConfig, HumanInputController, type HumanInputHandler, InterventionController, LocalSignal, Logger, Message, MiddlewareRunner, PromptBuilder, type QueuedFollowUpRecord, ReasoningLevel, ScopeSnapshot, SessionManager, type SteeringRequest, type SteeringResponse, StreamProvider, Tool, ToolExecutionMode, ToolHost, TurnChangeTracker, autoDetectStreamProvider, canSeedQueuedFollowUp, createEventPrinter, createHumanInputHandler, createHumanInputTool, createHumanInputToolWithController, createHumanInputToolWithHandler, createQueuedFollowUpRecord, currentScope, ensureSessionLoaded, estimateConversationTokens, estimateMessageTokens, estimateTokens, extractFilePathsFromArgs, findCutPoint, getUsableTokenLimit, markQueuedFollowUpApplied, normalizeFollowUpMode, resolveQueuedFollowUp, restoreScope, runChatLoop, shouldCaptureBaseline, sleep, snapshotScope, withinScope };
package/dist/index.js CHANGED
@@ -59,6 +59,7 @@ import {
59
59
  createToolSearchTool,
60
60
  defaultRegistry
61
61
  } from "./chunk-KYLPMBHD.js";
62
+ import "./chunk-O2WCYSXQ.js";
62
63
  import {
63
64
  ToolHostRegistry,
64
65
  defaultToolHostRegistry,
@@ -1068,6 +1069,76 @@ async function buildChatSystemPrompts(params) {
1068
1069
  });
1069
1070
  }
1070
1071
 
1072
+ // src/agent/chat-loop/turn-tools.ts
1073
+ async function resolveTurnTools(options) {
1074
+ const tools = /* @__PURE__ */ new Map();
1075
+ const mcpTools = {};
1076
+ const cleanup = [];
1077
+ try {
1078
+ for (const provider of options.providers) {
1079
+ const resolved = await provider.resolveTools(options.context);
1080
+ if (resolved.cleanup) {
1081
+ cleanup.push(resolved.cleanup);
1082
+ }
1083
+ for (const tool of resolved.tools ?? []) {
1084
+ if (options.baseTools.has(tool.id) || tools.has(tool.id)) {
1085
+ throw new Error(
1086
+ `Turn tool provider "${provider.name}" returned duplicate tool "${tool.id}"`
1087
+ );
1088
+ }
1089
+ tools.set(tool.id, tool);
1090
+ }
1091
+ for (const [name, tool] of Object.entries(resolved.mcpTools ?? {})) {
1092
+ if (options.baseMcpTools[name] || mcpTools[name]) {
1093
+ throw new Error(
1094
+ `Turn tool provider "${provider.name}" returned duplicate MCP tool "${name}"`
1095
+ );
1096
+ }
1097
+ mcpTools[name] = tool;
1098
+ }
1099
+ }
1100
+ } catch (error) {
1101
+ try {
1102
+ await cleanupTurnTools(cleanup);
1103
+ } catch {
1104
+ }
1105
+ throw error;
1106
+ }
1107
+ return { tools, mcpTools, cleanup };
1108
+ }
1109
+ function mergeTurnTools(baseTools, turnTools) {
1110
+ if (turnTools.size === 0) {
1111
+ return baseTools;
1112
+ }
1113
+ const merged = new Map(baseTools);
1114
+ for (const [id, tool] of turnTools) {
1115
+ if (merged.has(id)) {
1116
+ throw new Error(`Turn-scoped tool "${id}" conflicts with an agent tool`);
1117
+ }
1118
+ merged.set(id, tool);
1119
+ }
1120
+ return merged;
1121
+ }
1122
+ async function cleanupTurnTools(cleanup) {
1123
+ const errors = [];
1124
+ for (const cleanupFn of [...cleanup].reverse()) {
1125
+ try {
1126
+ await cleanupFn();
1127
+ } catch (error) {
1128
+ errors.push(error);
1129
+ }
1130
+ }
1131
+ if (errors.length === 1) {
1132
+ throw errors[0];
1133
+ }
1134
+ if (errors.length > 1) {
1135
+ throw new AggregateError(
1136
+ errors,
1137
+ "Multiple turn tool cleanup callbacks failed"
1138
+ );
1139
+ }
1140
+ }
1141
+
1071
1142
  // src/agent/chat-loop/loop.ts
1072
1143
  async function* runChatLoop(deps) {
1073
1144
  yield* streamWithinScope(
@@ -1099,31 +1170,68 @@ async function* runChatLoop(deps) {
1099
1170
  toModelMessages,
1100
1171
  setIsStreaming
1101
1172
  } = deps;
1102
- let toolRecord = createAgentToolRecord(liveTools);
1103
- const isPlanMode = deps.toolExecutionMode === "plan";
1104
- const turnEngine = createAgentTurnEngine({
1105
- sessionId,
1106
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1107
- getToolReplayPolicy: (toolName) => toolRecord[toolName] ? normalizeToolReplayPolicy(toolRecord[toolName].replayPolicy) : void 0
1108
- });
1109
- const applyCommitBatch = createChatLoopCommitBatchApplier({
1110
- turnEngine,
1111
- sessions,
1112
- middlewareRunner
1113
- });
1114
- yield* applyCommitBatch(
1115
- turnEngine.createInputCommit({
1116
- content: message,
1117
- system: systemOverride
1118
- }),
1119
- { emitMessages: true }
1173
+ let resolvedTurnTools;
1174
+ try {
1175
+ resolvedTurnTools = await resolveTurnTools({
1176
+ providers: deps.turnToolProviders,
1177
+ context: {
1178
+ sessionId,
1179
+ turnId,
1180
+ message,
1181
+ cwd: config.cwd,
1182
+ abort
1183
+ },
1184
+ baseTools: liveTools,
1185
+ baseMcpTools: mcpTools
1186
+ });
1187
+ } catch (error) {
1188
+ const errorInstance = error instanceof Error ? error : new Error(String(error));
1189
+ const statusEvent = { type: "status", status: "error" };
1190
+ middlewareRunner.emitEvent(statusEvent);
1191
+ yield statusEvent;
1192
+ const errorEvent = {
1193
+ type: "error",
1194
+ error: errorInstance
1195
+ };
1196
+ middlewareRunner.emitEvent(errorEvent);
1197
+ yield errorEvent;
1198
+ throw errorInstance;
1199
+ }
1200
+ const turnMcpTools = {
1201
+ ...mcpTools,
1202
+ ...resolvedTurnTools.mcpTools
1203
+ };
1204
+ let toolRecord = createAgentToolRecord(
1205
+ mergeTurnTools(liveTools, resolvedTurnTools.tools)
1120
1206
  );
1121
- setIsStreaming(true);
1122
1207
  const prevOnApplied = interventionCtrl.onApplied;
1208
+ let streamingStateStarted = false;
1123
1209
  let chatUsage;
1124
1210
  let chatError;
1125
1211
  let chatOutput;
1212
+ let chatEndError;
1213
+ let rethrowError;
1126
1214
  try {
1215
+ const isPlanMode = deps.toolExecutionMode === "plan";
1216
+ const turnEngine = createAgentTurnEngine({
1217
+ sessionId,
1218
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1219
+ getToolReplayPolicy: (toolName) => toolRecord[toolName] ? normalizeToolReplayPolicy(toolRecord[toolName].replayPolicy) : void 0
1220
+ });
1221
+ const applyCommitBatch = createChatLoopCommitBatchApplier({
1222
+ turnEngine,
1223
+ sessions,
1224
+ middlewareRunner
1225
+ });
1226
+ yield* applyCommitBatch(
1227
+ turnEngine.createInputCommit({
1228
+ content: message,
1229
+ system: systemOverride
1230
+ }),
1231
+ { emitMessages: true }
1232
+ );
1233
+ setIsStreaming(true);
1234
+ streamingStateStarted = true;
1127
1235
  if (middlewareRunner.hasMiddleware) {
1128
1236
  await middlewareRunner.runChatStart(sessionId, message, {
1129
1237
  sessionId,
@@ -1134,7 +1242,9 @@ async function* runChatLoop(deps) {
1134
1242
  let finalStepText = "";
1135
1243
  let accumulatedUsage;
1136
1244
  while (step <= config.maxSteps) {
1137
- toolRecord = createAgentToolRecord(liveTools);
1245
+ toolRecord = createAgentToolRecord(
1246
+ mergeTurnTools(liveTools, resolvedTurnTools.tools)
1247
+ );
1138
1248
  const systemPrompts = await buildChatSystemPrompts({
1139
1249
  promptBuilder,
1140
1250
  middlewareRunner,
@@ -1151,7 +1261,7 @@ async function* runChatLoop(deps) {
1151
1261
  toModelMessages,
1152
1262
  abort,
1153
1263
  tools: toolRecord,
1154
- mcpTools,
1264
+ mcpTools: turnMcpTools,
1155
1265
  config,
1156
1266
  host,
1157
1267
  humanInputController,
@@ -1279,25 +1389,47 @@ async function* runChatLoop(deps) {
1279
1389
  const errorEvent = { type: "error", error: chatError };
1280
1390
  middlewareRunner.emitEvent(errorEvent);
1281
1391
  yield errorEvent;
1282
- throw error;
1392
+ rethrowError = error;
1283
1393
  } finally {
1284
- setIsStreaming(false);
1394
+ if (streamingStateStarted) {
1395
+ setIsStreaming(false);
1396
+ }
1285
1397
  interventionCtrl.onApplied = prevOnApplied;
1286
1398
  if (middlewareRunner.hasMiddleware) {
1287
- await middlewareRunner.runChatEnd(
1288
- sessionId,
1289
- {
1290
- usage: chatUsage,
1291
- error: chatError,
1292
- output: chatOutput
1293
- },
1294
- {
1399
+ try {
1400
+ await middlewareRunner.runChatEnd(
1295
1401
  sessionId,
1296
- turnId
1297
- }
1298
- );
1402
+ {
1403
+ usage: chatUsage,
1404
+ error: chatError,
1405
+ output: chatOutput
1406
+ },
1407
+ {
1408
+ sessionId,
1409
+ turnId
1410
+ }
1411
+ );
1412
+ } catch (error) {
1413
+ chatEndError = error;
1414
+ }
1415
+ }
1416
+ try {
1417
+ await cleanupTurnTools(resolvedTurnTools.cleanup);
1418
+ } catch (error) {
1419
+ const errorInstance = error instanceof Error ? error : new Error(String(error));
1420
+ deps.logger?.warn("Turn tool provider cleanup failed", {
1421
+ error: errorInstance,
1422
+ message: errorInstance.message,
1423
+ stack: errorInstance.stack
1424
+ });
1299
1425
  }
1300
1426
  }
1427
+ if (chatEndError) {
1428
+ throw chatEndError;
1429
+ }
1430
+ if (rethrowError) {
1431
+ throw rethrowError;
1432
+ }
1301
1433
  })()
1302
1434
  );
1303
1435
  }
@@ -1380,6 +1512,7 @@ function createForkedAgentConfig(options) {
1380
1512
  compaction: parentConfig.compaction,
1381
1513
  contextWindow: parentConfig.contextWindow,
1382
1514
  mcp: mcpManager,
1515
+ turnToolProviders: forkOptions.turnToolProviders ?? parentConfig.turnToolProviders,
1383
1516
  middleware: resolveForkMiddleware(forkOptions, middlewareRunner)
1384
1517
  };
1385
1518
  }
@@ -2028,6 +2161,7 @@ function createAgentSetup(input) {
2028
2161
  contextManager: createAgentContextManager(config),
2029
2162
  turnTracker: createTurnTracker({ cwd: config.cwd }, logger),
2030
2163
  ...input.mcp ? { mcpManager: input.mcp } : {},
2164
+ turnToolProviders: [...input.turnToolProviders ?? []],
2031
2165
  ...promptBuilder ? { promptBuilder } : {},
2032
2166
  interventionCtrl: new InterventionController(),
2033
2167
  ...humanInputSetup,
@@ -2059,6 +2193,7 @@ var Agent = class _Agent {
2059
2193
  turnCounter = 0;
2060
2194
  /** MCP manager for external tool servers */
2061
2195
  mcpManager;
2196
+ turnToolProviders;
2062
2197
  /** Whether MCP has been connected (lazy init) */
2063
2198
  mcpConnected = false;
2064
2199
  /** Whether skill tools have been resolved (lazy init) */
@@ -2101,6 +2236,7 @@ var Agent = class _Agent {
2101
2236
  this.contextManager = setup.contextManager;
2102
2237
  this.turnTracker = setup.turnTracker;
2103
2238
  this.mcpManager = setup.mcpManager;
2239
+ this.turnToolProviders = setup.turnToolProviders;
2104
2240
  this.promptBuilder = setup.promptBuilder;
2105
2241
  this.interventionCtrl = setup.interventionCtrl;
2106
2242
  this.host = setup.host;
@@ -2335,6 +2471,7 @@ var Agent = class _Agent {
2335
2471
  host: this.host,
2336
2472
  humanInputController: this.humanInputController,
2337
2473
  mcpTools,
2474
+ turnToolProviders: this.turnToolProviders,
2338
2475
  telemetrySettings: this.telemetrySettings,
2339
2476
  toModelMessages: convertAgentMessagesToModelMessages,
2340
2477
  setIsStreaming: (value) => {
@@ -1,8 +1,8 @@
1
1
  import { ToolSet } from 'ai';
2
- import { T as Tool, a as TurnTrackerContext, H as HumanInputController, b as MiddlewareRunner, A as AgentEvent, c as ToolExecutionMode, I as InferenceStreamInput, d as ModelCallContext, e as AnyInferenceResult } from '../instance-DpAn37V_.js';
3
- export { D as DEFAULT_MAX_OUTPUT_TOKENS, f as DEFAULT_RETRY_CONFIG, g as InferenceCustomResult, h as InferenceStepInfo, i as InferenceStreamResult, R as RetryConfig, j as RetryHandlerOptions, k as RetryState, l as calculateDelay, m as createRetryHandler, n as createRetryState, s as shouldRetry, o as sleep, w as withRetry } from '../instance-DpAn37V_.js';
2
+ import { T as Tool, a as TurnTrackerContext, H as HumanInputController, b as MiddlewareRunner, A as AgentEvent, c as ToolExecutionMode, I as InferenceStreamInput, d as ModelCallContext, e as AnyInferenceResult } from '../instance-7RluLpIT.js';
3
+ export { D as DEFAULT_MAX_OUTPUT_TOKENS, f as DEFAULT_RETRY_CONFIG, g as InferenceCustomResult, h as InferenceStepInfo, i as InferenceStreamResult, R as RetryConfig, j as RetryHandlerOptions, k as RetryState, l as calculateDelay, m as createRetryHandler, n as createRetryState, s as shouldRetry, o as sleep, w as withRetry } from '../instance-7RluLpIT.js';
4
4
  import { T as ToolHost } from '../types-C_LCeYNg.js';
5
- export { c as convertAgentMessagesToModelMessages } from '../model-messages-BDTy2LY_.js';
5
+ export { c as convertAgentMessagesToModelMessages } from '../model-messages-CvIEjaIJ.js';
6
6
  export { E as ErrorCategory, L as LLMError, a as LLMErrorOptions, R as ResponseHeaders } from '../llm-error-D93FNNLY.js';
7
7
  export { getErrorCategory, getRetryDelay, isRetryable, isRetryableCategory, parseRetryDelay } from './errors/index.js';
8
8
  import '../types-RSCv7nQ4.js';
@@ -2014,6 +2014,9 @@ interface AgentMiddleware {
2014
2014
  * Runs in array order, awaited sequentially. Always called, even
2015
2015
  * if the stream errored.
2016
2016
  *
2017
+ * Turn-scoped tool cleanup runs after `onChatEnd`, so middleware can still
2018
+ * inspect the just-resolved turn tool objects during this hook.
2019
+ *
2017
2020
  * @param sessionId - Session identifier
2018
2021
  * @param result - Completion info (usage stats and optional error)
2019
2022
  */
@@ -4597,6 +4600,75 @@ interface InferenceStepInfo {
4597
4600
  finishReason?: string;
4598
4601
  }
4599
4602
 
4603
+ /**
4604
+ * Context provided to turn-scoped tool providers.
4605
+ *
4606
+ * This is intentionally platform-neutral. Channel packages can expose richer
4607
+ * ambient context through their own AsyncLocalStorage helpers while the core
4608
+ * package stays independent of Teams, Slack, M365, or Agent365 SDK types.
4609
+ *
4610
+ * Providers that need platform state such as a Microsoft `TurnContext`,
4611
+ * authorization object, Slack client, tenant metadata, or request-scoped
4612
+ * tokens should read that state from their channel package's ambient context at
4613
+ * `resolveTools()` time. Do not close over per-request platform objects when
4614
+ * constructing a provider, because providers may be inherited by forked agents.
4615
+ */
4616
+ interface AgentTurnToolContext {
4617
+ sessionId: string;
4618
+ turnId: string;
4619
+ /**
4620
+ * Current user message. Use this only for local tool selection/gating. Avoid
4621
+ * forwarding it to external services unless the provider explicitly owns that
4622
+ * data flow.
4623
+ */
4624
+ message: string;
4625
+ cwd: string;
4626
+ /**
4627
+ * Providers should observe this signal when doing network or token-exchange
4628
+ * work. Agent-core passes the signal through but does not forcibly cancel
4629
+ * provider code.
4630
+ */
4631
+ abort: AbortSignal;
4632
+ }
4633
+ interface AgentTurnToolProviderResult {
4634
+ /**
4635
+ * Framework tools available only for the active turn.
4636
+ */
4637
+ tools?: Tool.AnyInfo[];
4638
+ /**
4639
+ * AI SDK-compatible MCP tools available only for the active turn.
4640
+ */
4641
+ mcpTools?: ToolSet;
4642
+ /**
4643
+ * Called after the turn completes or errors.
4644
+ *
4645
+ * Use this to close per-turn MCP clients, revoke short-lived resources, or
4646
+ * clean up temporary transport state. Cleanup callbacks run in reverse
4647
+ * provider resolution order, matching stack semantics. If provider B depends
4648
+ * on resources from provider A, register B after A so B is cleaned up first.
4649
+ */
4650
+ cleanup?: () => void | Promise<void>;
4651
+ }
4652
+ interface AgentTurnToolProvider {
4653
+ name: string;
4654
+ /**
4655
+ * Resolve tools for the active chat turn only.
4656
+ *
4657
+ * Returned tools are not added to the agent's global tool registry and are
4658
+ * cleaned up after the turn completes or fails.
4659
+ *
4660
+ * Resolution happens before chat lifecycle middleware starts. If resolution
4661
+ * fails, agent-core emits structured `status: "error"` and `error` events,
4662
+ * then rejects the turn; chat lifecycle middleware is not called for that
4663
+ * failed resolution. Subscribe to `AgentEvent`s for full failure coverage.
4664
+ *
4665
+ * `resolveTools()` may be called concurrently for different sessions. Provider
4666
+ * implementations must be reentrant or key mutable state by `sessionId` and
4667
+ * `turnId`.
4668
+ */
4669
+ resolveTools(context: AgentTurnToolContext): AgentTurnToolProviderResult | Promise<AgentTurnToolProviderResult>;
4670
+ }
4671
+
4600
4672
  type SpanAttributeValue = string | number | boolean | string[] | number[] | boolean[];
4601
4673
  /**
4602
4674
  * Configuration for the OpenTelemetry middleware.
@@ -4821,6 +4893,13 @@ interface AgentConfig {
4821
4893
  * MCP manager for external tool servers.
4822
4894
  */
4823
4895
  mcp?: MCPManager;
4896
+ /**
4897
+ * Tool providers resolved for each chat turn.
4898
+ *
4899
+ * Use this for user-scoped or tenant-scoped tools that should not be added to
4900
+ * the agent globally, such as MCP tools discovered with per-request tokens.
4901
+ */
4902
+ turnToolProviders?: AgentTurnToolProvider[];
4824
4903
  /**
4825
4904
  * Layered prompt pipeline configuration.
4826
4905
  */
@@ -5222,6 +5301,7 @@ interface AgentForkOptions {
5222
5301
  profile?: Profile;
5223
5302
  middleware?: AgentMiddleware[];
5224
5303
  additionalMiddleware?: AgentMiddleware[];
5304
+ turnToolProviders?: AgentTurnToolProvider[];
5225
5305
  }
5226
5306
 
5227
5307
  /**
@@ -5275,6 +5355,7 @@ declare class Agent {
5275
5355
  private turnCounter;
5276
5356
  /** MCP manager for external tool servers */
5277
5357
  private mcpManager?;
5358
+ private turnToolProviders;
5278
5359
  /** Whether MCP has been connected (lazy init) */
5279
5360
  private mcpConnected;
5280
5361
  /** Whether skill tools have been resolved (lazy init) */
@@ -5821,4 +5902,4 @@ declare class Agent {
5821
5902
  close(): Promise<void>;
5822
5903
  }
5823
5904
 
5824
- export { type AgentTurnCommitOptions as $, type AgentEvent as A, Agent as B, type AgentConfig as C, DEFAULT_MAX_TOKENS as D, type EffectiveAgentConfig as E, type FileOperationMeta as F, type AgentDefaults as G, type HumanInputController as H, type InferenceStreamInput as I, type AgentDefaultsContext as J, type AgentDefaultsProvider as K, type AgentMiddleware as L, type Message as M, type AgentModelHooks as N, type AgentStatus as O, PromptBuilder as P, type AgentTurnActiveToolCall as Q, type RetryConfig as R, SessionManager as S, Tool as T, type Unsubscribe as U, type AgentTurnBoundaryKind as V, type WildcardHandler as W, type AgentTurnBoundaryMetadata as X, type AgentTurnBoundarySnapshot as Y, type AgentTurnCommitApplier as Z, type AgentTurnCommitBatch as _, type TurnTrackerContext as a, type DispatchTargetSummary as a$, AgentTurnEngine as a0, type AgentTurnEngineOptions as a1, type AgentTurnPhase as a2, type AgentTurnResolvedToolCall as a3, type AgentTurnState as a4, type AgentTurnStateAdvanceOptions as a5, type AgentTurnStepCommitSnapshot as a6, type AgentTurnStepCommitToolCall as a7, type AgentTurnStepCommitToolResult as a8, type AgentTurnStepRuntimeConfig as a9, type ConfigChangeEntry as aA, type CoordinatorNotification as aB, type CoordinatorNotificationKind as aC, type CoordinatorRoundEvent as aD, type CreateAgentTurnStateOptions as aE, type CreateAgentTurnStepCommitBatchOptions as aF, type CreateSessionOptions as aG, DEFAULT_AGENT_NAME as aH, DEFAULT_DISPATCH_TOOL_IDS as aI, DEFAULT_LOCAL_DISPATCH_CONCURRENCY as aJ, DEFAULT_LOCAL_DISPATCH_DEPTH as aK, DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX as aL, DEFAULT_MAX_STEPS as aM, DEFAULT_SYSTEM_PROMPT as aN, DISPATCH_STATES as aO, type DispatchCheckOptions as aP, type DispatchListOptions as aQ, type DispatchRecord as aR, type DispatchResult as aS, type DispatchRole as aT, type DispatchRuntime as aU, type DispatchStartInput as aV, type DispatchState as aW, type DispatchTarget as aX, type DispatchTargetInspection as aY, type DispatchTargetStartInput as aZ, type DispatchTargetStartResult as a_, type AppliedProfile as aa, type ApprovalAction as ab, type ApprovalAgentMiddleware as ac, type ApprovalCascadeMode as ad, type ApprovalCascadePolicy as ae, type ApprovalConfig as af, type ApprovalCorrection as ag, type ApprovalDecision as ah, type ApprovalEvaluation as ai, type ApprovalEvent as aj, type ApprovalHandler as ak, type ApprovalMiddlewareConfig as al, type ApprovalRememberScope as am, type ApprovalRequest as an, type ApprovalResolution as ao, type ApprovalRule as ap, type ApprovalRuleContext as aq, type AssistantMessage as ar, type BlockedModelCall as as, type BranchEntry as at, type ChatLifecycleContext as au, type CommitOutputOptions as av, type CommitStepOptions as aw, type CompactionConfig as ax, type CompactionEntry as ay, type CompatibleSchema as az, MiddlewareRunner as b, type PlannedTask as b$, type DispatchUsage as b0, type DoomLoopAction as b1, type DoomLoopHandler as b2, type DoomLoopRequest as b3, type EnhancedTools as b4, type EntryBase as b5, type EnvironmentInfo as b6, type ExternalTaskControl as b7, type FileEntry as b8, type GuidancePayload as b9, type MemberStatusChangedEvent as bA, type MessageBase as bB, type MessageEntry as bC, type MessageError as bD, type MessageInput as bE, type MessageKind as bF, type MessageListFilter as bG, type MessagePayload as bH, type MessageRole as bI, type MessageSentEvent as bJ, type MetadataEntry as bK, type ModelCallInput as bL, type ModelCallOutput as bM, type ModelFamily as bN, type NormalizedToolReplayPolicy as bO, type NotificationPriority as bP, type OnFollowUpQueued as bQ, type OnInterventionApplied as bR, type OtelMiddlewareConfig as bS, PRUNE_PROTECTED_TOOLS as bT, type PendingIntervention as bU, type PermissionForwardedEvent as bV, type PermissionHandler as bW, type PermissionRequestPayload as bX, type PermissionResolvedEvent as bY, type PermissionResponsePayload as bZ, type PlanCreatedEvent as b_, type HumanInputEventContext as ba, type HumanInputOption as bb, type HumanInputRequest as bc, type HumanInputRequestKind as bd, type HumanInputRequestListOptions as be, type HumanInputRequestRecord as bf, type HumanInputRequestStatus as bg, type HumanInputResponse as bh, HumanInputTimeoutError as bi, type HumanInputToolArgs as bj, HumanInputUnavailableError as bk, type IdleNotificationPayload as bl, InMemoryMailboxStore as bm, InMemoryTaskBoardStore as bn, type InferSchemaOutput as bo, type InputCheckResult as bp, type InstructionFile as bq, type LocalDispatchRuntimeOptions as br, LocalSessionTurnLock as bs, Mailbox as bt, type MailboxStore as bu, type MailboxSubscriber as bv, type MemberRegisteredEvent as bw, type MemberRuntime as bx, type MemberStats as by, type MemberStatus as bz, type ToolExecutionMode as c, type TaskExecutor as c$, type PrepareModelStepOptions as c0, type PreparedAgentModelStep as c1, type PreparedExternalTask as c2, type Profile as c3, type PromptBuildContext as c4, type PromptConfig as c5, type PromptSection as c6, type QueueTaskInput as c7, type ReleaseSessionTurnLock as c8, type RemoteSkillEntry as c9, type SkillResource as cA, type SkillResourceType as cB, type SkillScope as cC, type SkillSource as cD, type SkillSourceType as cE, type StepProcessingOptions as cF, type StepProcessingOutput as cG, type StepProcessingResult as cH, type StreamChunk as cI, type StreamInput as cJ, type StreamProviderConfig as cK, type StreamProviderFactory as cL, type StreamProviderInput as cM, type StreamProviderResult as cN, type SynthesisCompleteEvent as cO, type SynthesisResult as cP, type SystemMessage as cQ, TERMINAL_STATUSES as cR, type TaskAbortedEvent as cS, TaskBoard as cT, type TaskBoardStore as cU, type TaskCompletedEvent as cV, type TaskCompletion as cW, TaskConflictError as cX, type TaskCreateInput as cY, type TaskCreatedEvent as cZ, type TaskDispatchMode as c_, type RemoteSkillIndex as ca, type RiskLevel as cb, type RuleSource as cc, type RunModelStepOptions as cd, type RunToolBatchOptions as ce, type RunToolBatchResult as cf, STORAGE_VERSION as cg, type SerializedMessage as ch, type Session as ci, type SessionContext as cj, type SessionEntry as ck, type SessionHeader as cl, type SessionInfo as cm, type SessionStorage as cn, type SessionTurnLock as co, type SessionTurnLockAcquireOptions as cp, type ShutdownRequestPayload as cq, type ShutdownRequestedEvent as cr, type ShutdownResolvedEvent as cs, type ShutdownResponsePayload as ct, type SkillConfig as cu, type SkillContent as cv, type SkillDiscoveryError as cw, type SkillDiscoveryResult as cx, type SkillMetadata as cy, SkillRegistry as cz, type ModelCallContext as d, type TaskExecutorInput as d0, type TaskFailedEvent as d1, type TaskListFilter as d2, type TaskResult as d3, type TaskStatus as d4, type TaskTransition as d5, type TaskTransitionEvent as d6, type TaskTransitionReason as d7, type TeamCoordinatorConfig as d8, type TeamEvent as d9, type WorkerReportPayload as dA, accumulateUsage as dB, advanceAgentTurnState as dC, approvalMiddleware as dD, buildCoordinatorNotificationEvent as dE, createAgent as dF, createAgentTurnEngine as dG, createAgentTurnState as dH, createApprovalHandler as dI, createHumanInputController as dJ, createPromptBuilder as dK, createSkillRegistry as dL, createTurnTracker as dM, emptySkillRegistry as dN, failAgentTurnState as dO, getRequiredToolHost as dP, isApprovalMiddleware as dQ, isBlockedModelCall as dR, isHumanInputController as dS, requiresToolHost as dT, resolveAgentDefaults as dU, resolveCapability as dV, sandboxDefaultsProvider as dW, type CoordinatorCtx as dX, type TeamMember as da, type TeamMessage as db, type TeamNotificationEvent as dc, type TeamPlan as dd, type TeamSnapshot as de, type TeamStartedEvent as df, type TeamStoppedEvent as dg, type TeamTask as dh, type TelemetryConfig as di, type TelemetryConfigResult as dj, type TokenUsage as dk, type ToolCallDecision as dl, type ToolCallOutput as dm, type ToolCapabilities as dn, type ToolContext as dp, type ToolHostRequirements as dq, type ToolMessage as dr, type ToolMetadata as ds, type ToolReplayMode as dt, type ToolReplayPolicy as du, type ToolResult as dv, type ToolSideEffectLevel as dw, type TracingConfig as dx, type UndoResult as dy, type UserMessage as dz, type AnyInferenceResult as e, DEFAULT_RETRY_CONFIG as f, type InferenceCustomResult as g, type InferenceStepInfo as h, type InferenceStreamResult as i, type RetryHandlerOptions as j, type RetryState as k, calculateDelay as l, createRetryHandler as m, createRetryState as n, sleep as o, type HumanInputConfig as p, TurnChangeTracker as q, InterventionController as r, shouldRetry as s, type StreamProvider as t, type Scope as u, type ScopeSnapshot as v, withRetry as w, type ScopeOptions as x, type AgentSignal as y, type TypedHandler as z };
5905
+ export { type AgentTurnCommitBatch as $, type AgentEvent as A, type TypedHandler as B, Agent as C, DEFAULT_MAX_TOKENS as D, type EffectiveAgentConfig as E, type FileOperationMeta as F, type AgentConfig as G, type HumanInputController as H, type InferenceStreamInput as I, type AgentDefaults as J, type AgentDefaultsContext as K, type AgentDefaultsProvider as L, type Message as M, type AgentMiddleware as N, type AgentModelHooks as O, PromptBuilder as P, type AgentStatus as Q, type RetryConfig as R, SessionManager as S, Tool as T, type Unsubscribe as U, type AgentTurnActiveToolCall as V, type WildcardHandler as W, type AgentTurnBoundaryKind as X, type AgentTurnBoundaryMetadata as Y, type AgentTurnBoundarySnapshot as Z, type AgentTurnCommitApplier as _, type TurnTrackerContext as a, type DispatchTargetInspection as a$, type AgentTurnCommitOptions as a0, AgentTurnEngine as a1, type AgentTurnEngineOptions as a2, type AgentTurnPhase as a3, type AgentTurnResolvedToolCall as a4, type AgentTurnState as a5, type AgentTurnStateAdvanceOptions as a6, type AgentTurnStepCommitSnapshot as a7, type AgentTurnStepCommitToolCall as a8, type AgentTurnStepCommitToolResult as a9, type CompactionConfig as aA, type CompactionEntry as aB, type CompatibleSchema as aC, type ConfigChangeEntry as aD, type CoordinatorNotification as aE, type CoordinatorNotificationKind as aF, type CoordinatorRoundEvent as aG, type CreateAgentTurnStateOptions as aH, type CreateAgentTurnStepCommitBatchOptions as aI, type CreateSessionOptions as aJ, DEFAULT_AGENT_NAME as aK, DEFAULT_DISPATCH_TOOL_IDS as aL, DEFAULT_LOCAL_DISPATCH_CONCURRENCY as aM, DEFAULT_LOCAL_DISPATCH_DEPTH as aN, DEFAULT_LOCAL_DISPATCH_TITLE_PREFIX as aO, DEFAULT_MAX_STEPS as aP, DEFAULT_SYSTEM_PROMPT as aQ, DISPATCH_STATES as aR, type DispatchCheckOptions as aS, type DispatchListOptions as aT, type DispatchRecord as aU, type DispatchResult as aV, type DispatchRole as aW, type DispatchRuntime as aX, type DispatchStartInput as aY, type DispatchState as aZ, type DispatchTarget as a_, type AgentTurnStepRuntimeConfig as aa, type AgentTurnToolContext as ab, type AgentTurnToolProviderResult as ac, type AppliedProfile as ad, type ApprovalAction as ae, type ApprovalAgentMiddleware as af, type ApprovalCascadeMode as ag, type ApprovalCascadePolicy as ah, type ApprovalConfig as ai, type ApprovalCorrection as aj, type ApprovalDecision as ak, type ApprovalEvaluation as al, type ApprovalEvent as am, type ApprovalHandler as an, type ApprovalMiddlewareConfig as ao, type ApprovalRememberScope as ap, type ApprovalRequest as aq, type ApprovalResolution as ar, type ApprovalRule as as, type ApprovalRuleContext as at, type AssistantMessage as au, type BlockedModelCall as av, type BranchEntry as aw, type ChatLifecycleContext as ax, type CommitOutputOptions as ay, type CommitStepOptions as az, MiddlewareRunner as b, type PermissionResolvedEvent as b$, type DispatchTargetStartInput as b0, type DispatchTargetStartResult as b1, type DispatchTargetSummary as b2, type DispatchUsage as b3, type DoomLoopAction as b4, type DoomLoopHandler as b5, type DoomLoopRequest as b6, type EnhancedTools as b7, type EntryBase as b8, type EnvironmentInfo as b9, type MemberRuntime as bA, type MemberStats as bB, type MemberStatus as bC, type MemberStatusChangedEvent as bD, type MessageBase as bE, type MessageEntry as bF, type MessageError as bG, type MessageInput as bH, type MessageKind as bI, type MessageListFilter as bJ, type MessagePayload as bK, type MessageRole as bL, type MessageSentEvent as bM, type MetadataEntry as bN, type ModelCallInput as bO, type ModelCallOutput as bP, type ModelFamily as bQ, type NormalizedToolReplayPolicy as bR, type NotificationPriority as bS, type OnFollowUpQueued as bT, type OnInterventionApplied as bU, type OtelMiddlewareConfig as bV, PRUNE_PROTECTED_TOOLS as bW, type PendingIntervention as bX, type PermissionForwardedEvent as bY, type PermissionHandler as bZ, type PermissionRequestPayload as b_, type ExternalTaskControl as ba, type FileEntry as bb, type GuidancePayload as bc, type HumanInputEventContext as bd, type HumanInputOption as be, type HumanInputRequest as bf, type HumanInputRequestKind as bg, type HumanInputRequestListOptions as bh, type HumanInputRequestRecord as bi, type HumanInputRequestStatus as bj, type HumanInputResponse as bk, HumanInputTimeoutError as bl, type HumanInputToolArgs as bm, HumanInputUnavailableError as bn, type IdleNotificationPayload as bo, InMemoryMailboxStore as bp, InMemoryTaskBoardStore as bq, type InferSchemaOutput as br, type InputCheckResult as bs, type InstructionFile as bt, type LocalDispatchRuntimeOptions as bu, LocalSessionTurnLock as bv, Mailbox as bw, type MailboxStore as bx, type MailboxSubscriber as by, type MemberRegisteredEvent as bz, type ToolExecutionMode as c, type TaskCreateInput as c$, type PermissionResponsePayload as c0, type PlanCreatedEvent as c1, type PlannedTask as c2, type PrepareModelStepOptions as c3, type PreparedAgentModelStep as c4, type PreparedExternalTask as c5, type Profile as c6, type PromptBuildContext as c7, type PromptConfig as c8, type PromptSection as c9, type SkillDiscoveryResult as cA, type SkillMetadata as cB, SkillRegistry as cC, type SkillResource as cD, type SkillResourceType as cE, type SkillScope as cF, type SkillSource as cG, type SkillSourceType as cH, type StepProcessingOptions as cI, type StepProcessingOutput as cJ, type StepProcessingResult as cK, type StreamChunk as cL, type StreamInput as cM, type StreamProviderConfig as cN, type StreamProviderFactory as cO, type StreamProviderInput as cP, type StreamProviderResult as cQ, type SynthesisCompleteEvent as cR, type SynthesisResult as cS, type SystemMessage as cT, TERMINAL_STATUSES as cU, type TaskAbortedEvent as cV, TaskBoard as cW, type TaskBoardStore as cX, type TaskCompletedEvent as cY, type TaskCompletion as cZ, TaskConflictError as c_, type QueueTaskInput as ca, type ReleaseSessionTurnLock as cb, type RemoteSkillEntry as cc, type RemoteSkillIndex as cd, type RiskLevel as ce, type RuleSource as cf, type RunModelStepOptions as cg, type RunToolBatchOptions as ch, type RunToolBatchResult as ci, STORAGE_VERSION as cj, type SerializedMessage as ck, type Session as cl, type SessionContext as cm, type SessionEntry as cn, type SessionHeader as co, type SessionInfo as cp, type SessionStorage as cq, type SessionTurnLock as cr, type SessionTurnLockAcquireOptions as cs, type ShutdownRequestPayload as ct, type ShutdownRequestedEvent as cu, type ShutdownResolvedEvent as cv, type ShutdownResponsePayload as cw, type SkillConfig as cx, type SkillContent as cy, type SkillDiscoveryError as cz, type ModelCallContext as d, type TaskCreatedEvent as d0, type TaskDispatchMode as d1, type TaskExecutor as d2, type TaskExecutorInput as d3, type TaskFailedEvent as d4, type TaskListFilter as d5, type TaskResult as d6, type TaskStatus as d7, type TaskTransition as d8, type TaskTransitionEvent as d9, type TracingConfig as dA, type UndoResult as dB, type UserMessage as dC, type WorkerReportPayload as dD, accumulateUsage as dE, advanceAgentTurnState as dF, approvalMiddleware as dG, buildCoordinatorNotificationEvent as dH, createAgent as dI, createAgentTurnEngine as dJ, createAgentTurnState as dK, createApprovalHandler as dL, createHumanInputController as dM, createPromptBuilder as dN, createSkillRegistry as dO, createTurnTracker as dP, emptySkillRegistry as dQ, failAgentTurnState as dR, getRequiredToolHost as dS, isApprovalMiddleware as dT, isBlockedModelCall as dU, isHumanInputController as dV, requiresToolHost as dW, resolveAgentDefaults as dX, resolveCapability as dY, sandboxDefaultsProvider as dZ, type CoordinatorCtx as d_, type TaskTransitionReason as da, type TeamCoordinatorConfig as db, type TeamEvent as dc, type TeamMember as dd, type TeamMessage as de, type TeamNotificationEvent as df, type TeamPlan as dg, type TeamSnapshot as dh, type TeamStartedEvent as di, type TeamStoppedEvent as dj, type TeamTask as dk, type TelemetryConfig as dl, type TelemetryConfigResult as dm, type TokenUsage as dn, type ToolCallDecision as dp, type ToolCallOutput as dq, type ToolCapabilities as dr, type ToolContext as ds, type ToolHostRequirements as dt, type ToolMessage as du, type ToolMetadata as dv, type ToolReplayMode as dw, type ToolReplayPolicy as dx, type ToolResult as dy, type ToolSideEffectLevel as dz, type AnyInferenceResult as e, DEFAULT_RETRY_CONFIG as f, type InferenceCustomResult as g, type InferenceStepInfo as h, type InferenceStreamResult as i, type RetryHandlerOptions as j, type RetryState as k, calculateDelay as l, createRetryHandler as m, createRetryState as n, sleep as o, type HumanInputConfig as p, TurnChangeTracker as q, InterventionController as r, shouldRetry as s, type AgentTurnToolProvider as t, type StreamProvider as u, type Scope as v, withRetry as w, type ScopeSnapshot as x, type ScopeOptions as y, type AgentSignal as z };
@@ -1,5 +1,5 @@
1
- import { bS as OtelMiddlewareConfig, L as AgentMiddleware, di as TelemetryConfig, dj as TelemetryConfigResult } from '../instance-DpAn37V_.js';
2
- export { N as AgentModelHooks, ac as ApprovalAgentMiddleware, al as ApprovalMiddlewareConfig, as as BlockedModelCall, au as ChatLifecycleContext, b as MiddlewareRunner, d as ModelCallContext, bL as ModelCallInput, bM as ModelCallOutput, dl as ToolCallDecision, dm as ToolCallOutput, dD as approvalMiddleware, dQ as isApprovalMiddleware, dR as isBlockedModelCall } from '../instance-DpAn37V_.js';
1
+ import { bV as OtelMiddlewareConfig, N as AgentMiddleware, dl as TelemetryConfig, dm as TelemetryConfigResult } from '../instance-7RluLpIT.js';
2
+ export { O as AgentModelHooks, af as ApprovalAgentMiddleware, ao as ApprovalMiddlewareConfig, av as BlockedModelCall, ax as ChatLifecycleContext, b as MiddlewareRunner, d as ModelCallContext, bO as ModelCallInput, bP as ModelCallOutput, dp as ToolCallDecision, dq as ToolCallOutput, dG as approvalMiddleware, dT as isApprovalMiddleware, dU as isBlockedModelCall } from '../instance-7RluLpIT.js';
3
3
  import '../types-C_LCeYNg.js';
4
4
  import 'ai';
5
5
  import '../types-RSCv7nQ4.js';
@@ -1,5 +1,5 @@
1
1
  import { ModelMessage } from 'ai';
2
- import { M as Message } from './instance-DpAn37V_.js';
2
+ import { M as Message } from './instance-7RluLpIT.js';
3
3
 
4
4
  /**
5
5
  * Convert framework messages into Vercel AI SDK model messages.
@@ -1,4 +1,4 @@
1
- import { T as Tool, L as AgentMiddleware, c6 as PromptSection } from '../instance-DpAn37V_.js';
1
+ import { T as Tool, N as AgentMiddleware, c9 as PromptSection } from '../instance-7RluLpIT.js';
2
2
  import { ZodType } from 'zod';
3
3
  import { Jiti } from 'jiti';
4
4
  import '../types-C_LCeYNg.js';
@@ -1,4 +1,4 @@
1
- import { T as Tool, c3 as Profile, aa as AppliedProfile } from '../instance-DpAn37V_.js';
1
+ import { T as Tool, c6 as Profile, ad as AppliedProfile } from '../instance-7RluLpIT.js';
2
2
  import '../types-C_LCeYNg.js';
3
3
  import 'ai';
4
4
  import '../types-RSCv7nQ4.js';
@@ -1,5 +1,5 @@
1
- import { bN as ModelFamily, b6 as EnvironmentInfo, bq as InstructionFile } from '../instance-DpAn37V_.js';
2
- export { c4 as PromptBuildContext, P as PromptBuilder, c5 as PromptConfig, c6 as PromptSection, cu as SkillConfig, dK as createPromptBuilder } from '../instance-DpAn37V_.js';
1
+ import { bQ as ModelFamily, b9 as EnvironmentInfo, bt as InstructionFile } from '../instance-7RluLpIT.js';
2
+ export { c7 as PromptBuildContext, P as PromptBuilder, c8 as PromptConfig, c9 as PromptSection, cx as SkillConfig, dN as createPromptBuilder } from '../instance-7RluLpIT.js';
3
3
  import { LanguageModel } from 'ai';
4
4
  import '../types-C_LCeYNg.js';
5
5
  import '../types-RSCv7nQ4.js';
@@ -1,5 +1,5 @@
1
- import { cb as RiskLevel, ap as ApprovalRule, an as ApprovalRequest, aq as ApprovalRuleContext, cc as RuleSource, ae as ApprovalCascadePolicy, am as ApprovalRememberScope, ah as ApprovalDecision, af as ApprovalConfig } from '../instance-DpAn37V_.js';
2
- export { ab as ApprovalAction, ad as ApprovalCascadeMode, ag as ApprovalCorrection, ai as ApprovalEvaluation, ak as ApprovalHandler, ao as ApprovalResolution, dI as createApprovalHandler } from '../instance-DpAn37V_.js';
1
+ import { ce as RiskLevel, as as ApprovalRule, aq as ApprovalRequest, at as ApprovalRuleContext, cf as RuleSource, ah as ApprovalCascadePolicy, ap as ApprovalRememberScope, ak as ApprovalDecision, ai as ApprovalConfig } from '../instance-7RluLpIT.js';
2
+ export { ae as ApprovalAction, ag as ApprovalCascadeMode, aj as ApprovalCorrection, al as ApprovalEvaluation, an as ApprovalHandler, ar as ApprovalResolution, dL as createApprovalHandler } from '../instance-7RluLpIT.js';
3
3
  import '../types-C_LCeYNg.js';
4
4
  import 'ai';
5
5
  import '../types-RSCv7nQ4.js';
@@ -1,5 +1,5 @@
1
- import { cC as SkillScope, cD as SkillSource, cy as SkillMetadata, cB as SkillResourceType, cA as SkillResource, cv as SkillContent, cu as SkillConfig, cx as SkillDiscoveryResult, cz as SkillRegistry, T as Tool } from '../instance-DpAn37V_.js';
2
- export { c9 as RemoteSkillEntry, ca as RemoteSkillIndex, cw as SkillDiscoveryError, cE as SkillSourceType, dL as createSkillRegistry, dN as emptySkillRegistry } from '../instance-DpAn37V_.js';
1
+ import { cF as SkillScope, cG as SkillSource, cB as SkillMetadata, cE as SkillResourceType, cD as SkillResource, cy as SkillContent, cx as SkillConfig, cA as SkillDiscoveryResult, cC as SkillRegistry, T as Tool } from '../instance-7RluLpIT.js';
2
+ export { cc as RemoteSkillEntry, cd as RemoteSkillIndex, cz as SkillDiscoveryError, cH as SkillSourceType, dO as createSkillRegistry, dQ as emptySkillRegistry } from '../instance-7RluLpIT.js';
3
3
  import '../types-C_LCeYNg.js';
4
4
  import 'ai';
5
5
  import '../types-RSCv7nQ4.js';
@@ -1,5 +1,5 @@
1
- import { b8 as FileEntry, ck as SessionEntry, M as Message, bC as MessageEntry, bK as MetadataEntry, ch as SerializedMessage, cm as SessionInfo, cn as SessionStorage, cl as SessionHeader, S as SessionManager } from '../instance-DpAn37V_.js';
2
- export { at as BranchEntry, ay as CompactionEntry, aA as ConfigChangeEntry, aG as CreateSessionOptions, b5 as EntryBase, bs as LocalSessionTurnLock, c8 as ReleaseSessionTurnLock, cg as STORAGE_VERSION, cj as SessionContext, co as SessionTurnLock, cp as SessionTurnLockAcquireOptions } from '../instance-DpAn37V_.js';
1
+ import { bb as FileEntry, cn as SessionEntry, M as Message, bF as MessageEntry, bN as MetadataEntry, ck as SerializedMessage, cp as SessionInfo, cq as SessionStorage, co as SessionHeader, S as SessionManager } from '../instance-7RluLpIT.js';
2
+ export { aw as BranchEntry, aB as CompactionEntry, aD as ConfigChangeEntry, aJ as CreateSessionOptions, b8 as EntryBase, bv as LocalSessionTurnLock, cb as ReleaseSessionTurnLock, cj as STORAGE_VERSION, cm as SessionContext, cr as SessionTurnLock, cs as SessionTurnLockAcquireOptions } from '../instance-7RluLpIT.js';
3
3
  import { L as Logger } from '../types-RSCv7nQ4.js';
4
4
  import '../types-C_LCeYNg.js';
5
5
  import 'ai';
@@ -1,4 +1,4 @@
1
- import { aT as DispatchRole, aS as DispatchResult, br as LocalDispatchRuntimeOptions, B as Agent, T as Tool, aU as DispatchRuntime, c3 as Profile } from '../instance-DpAn37V_.js';
1
+ import { aW as DispatchRole, aV as DispatchResult, bu as LocalDispatchRuntimeOptions, C as Agent, T as Tool, aX as DispatchRuntime, c6 as Profile } from '../instance-7RluLpIT.js';
2
2
  import '../types-C_LCeYNg.js';
3
3
  import 'ai';
4
4
  import '../types-RSCv7nQ4.js';
@@ -1,5 +1,5 @@
1
- import { aB as CoordinatorNotification, cW as TaskCompletion, dk as TokenUsage, A as AgentEvent, dX as CoordinatorCtx, B as Agent, bx as MemberRuntime, cT as TaskBoard, bt as Mailbox, c_ as TaskDispatchMode, bW as PermissionHandler, d8 as TeamCoordinatorConfig, c$ as TaskExecutor, d9 as TeamEvent, da as TeamMember, c7 as QueueTaskInput, dh as TeamTask, db as TeamMessage, dd as TeamPlan, cP as SynthesisResult, de as TeamSnapshot, d2 as TaskListFilter, bG as MessageListFilter, c2 as PreparedExternalTask, d3 as TaskResult, d5 as TaskTransition, by as MemberStats, bz as MemberStatus, L as AgentMiddleware, dl as ToolCallDecision } from '../instance-DpAn37V_.js';
2
- export { aC as CoordinatorNotificationKind, aD as CoordinatorRoundEvent, b7 as ExternalTaskControl, b9 as GuidancePayload, bl as IdleNotificationPayload, bm as InMemoryMailboxStore, bn as InMemoryTaskBoardStore, bu as MailboxStore, bv as MailboxSubscriber, bw as MemberRegisteredEvent, bA as MemberStatusChangedEvent, bE as MessageInput, bF as MessageKind, bH as MessagePayload, bJ as MessageSentEvent, bP as NotificationPriority, bV as PermissionForwardedEvent, bX as PermissionRequestPayload, bY as PermissionResolvedEvent, bZ as PermissionResponsePayload, b_ as PlanCreatedEvent, b$ as PlannedTask, cq as ShutdownRequestPayload, cr as ShutdownRequestedEvent, cs as ShutdownResolvedEvent, ct as ShutdownResponsePayload, cO as SynthesisCompleteEvent, cR as TERMINAL_STATUSES, cS as TaskAbortedEvent, cU as TaskBoardStore, cV as TaskCompletedEvent, cX as TaskConflictError, cY as TaskCreateInput, cZ as TaskCreatedEvent, d0 as TaskExecutorInput, d1 as TaskFailedEvent, d4 as TaskStatus, d6 as TaskTransitionEvent, d7 as TaskTransitionReason, dc as TeamNotificationEvent, df as TeamStartedEvent, dg as TeamStoppedEvent, dA as WorkerReportPayload, dE as buildCoordinatorNotificationEvent } from '../instance-DpAn37V_.js';
1
+ import { aE as CoordinatorNotification, cZ as TaskCompletion, dn as TokenUsage, A as AgentEvent, d_ as CoordinatorCtx, C as Agent, bA as MemberRuntime, cW as TaskBoard, bw as Mailbox, d1 as TaskDispatchMode, bZ as PermissionHandler, db as TeamCoordinatorConfig, d2 as TaskExecutor, dc as TeamEvent, dd as TeamMember, ca as QueueTaskInput, dk as TeamTask, de as TeamMessage, dg as TeamPlan, cS as SynthesisResult, dh as TeamSnapshot, d5 as TaskListFilter, bJ as MessageListFilter, c5 as PreparedExternalTask, d6 as TaskResult, d8 as TaskTransition, bB as MemberStats, bC as MemberStatus, N as AgentMiddleware, dp as ToolCallDecision } from '../instance-7RluLpIT.js';
2
+ export { aF as CoordinatorNotificationKind, aG as CoordinatorRoundEvent, ba as ExternalTaskControl, bc as GuidancePayload, bo as IdleNotificationPayload, bp as InMemoryMailboxStore, bq as InMemoryTaskBoardStore, bx as MailboxStore, by as MailboxSubscriber, bz as MemberRegisteredEvent, bD as MemberStatusChangedEvent, bH as MessageInput, bI as MessageKind, bK as MessagePayload, bM as MessageSentEvent, bS as NotificationPriority, bY as PermissionForwardedEvent, b_ as PermissionRequestPayload, b$ as PermissionResolvedEvent, c0 as PermissionResponsePayload, c1 as PlanCreatedEvent, c2 as PlannedTask, ct as ShutdownRequestPayload, cu as ShutdownRequestedEvent, cv as ShutdownResolvedEvent, cw as ShutdownResponsePayload, cR as SynthesisCompleteEvent, cU as TERMINAL_STATUSES, cV as TaskAbortedEvent, cX as TaskBoardStore, cY as TaskCompletedEvent, c_ as TaskConflictError, c$ as TaskCreateInput, d0 as TaskCreatedEvent, d3 as TaskExecutorInput, d4 as TaskFailedEvent, d7 as TaskStatus, d9 as TaskTransitionEvent, da as TaskTransitionReason, df as TeamNotificationEvent, di as TeamStartedEvent, dj as TeamStoppedEvent, dD as WorkerReportPayload, dH as buildCoordinatorNotificationEvent } from '../instance-7RluLpIT.js';
3
3
  import { R as ReasoningLevel } from '../types-CQaXbRsS.js';
4
4
  import '../types-C_LCeYNg.js';
5
5
  import 'ai';
@@ -1,5 +1,5 @@
1
- import { du as ToolReplayPolicy, F as FileOperationMeta, bO as NormalizedToolReplayPolicy, T as Tool, H as HumanInputController, a as TurnTrackerContext, b as MiddlewareRunner, A as AgentEvent, ds as ToolMetadata, dn as ToolCapabilities } from '../instance-DpAn37V_.js';
2
- export { az as CompatibleSchema, bo as InferSchemaOutput, bp as InputCheckResult, dP as getRequiredToolHost, dV as resolveCapability } from '../instance-DpAn37V_.js';
1
+ import { dx as ToolReplayPolicy, F as FileOperationMeta, bR as NormalizedToolReplayPolicy, T as Tool, H as HumanInputController, a as TurnTrackerContext, b as MiddlewareRunner, A as AgentEvent, dv as ToolMetadata, dr as ToolCapabilities } from '../instance-7RluLpIT.js';
2
+ export { aC as CompatibleSchema, br as InferSchemaOutput, bs as InputCheckResult, dS as getRequiredToolHost, dY as resolveCapability } from '../instance-7RluLpIT.js';
3
3
  import { T as ToolHost } from '../types-C_LCeYNg.js';
4
4
  export { D as DirEntry, E as ExecOptions, a as ExecResult, F as FileStat } from '../types-C_LCeYNg.js';
5
5
  export { ToolHostProvider, ToolHostProviderSummary, ToolHostRegistry, defaultToolHostRegistry, localHost } from './host/index.js';
@@ -0,0 +1,12 @@
1
+ import 'ai';
2
+ export { ab as AgentTurnToolContext, t as AgentTurnToolProvider, ac as AgentTurnToolProviderResult } from '../instance-7RluLpIT.js';
3
+ import '../types-C_LCeYNg.js';
4
+ import '../types-RSCv7nQ4.js';
5
+ import 'zod';
6
+ import '../types-CQaXbRsS.js';
7
+ import '../types-DMjoFKKv.js';
8
+ import '@modelcontextprotocol/sdk/client/auth.js';
9
+ import '@modelcontextprotocol/sdk/types.js';
10
+ import '@ai-sdk/provider-utils';
11
+ import '../sandbox/index.js';
12
+ import '../llm-error-D93FNNLY.js';
@@ -0,0 +1 @@
1
+ import "../chunk-O2WCYSXQ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuylabs/agent-core",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "Embeddable AI agent infrastructure — execution, sessions, tools, skills, dispatch, tracing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,6 +16,11 @@
16
16
  "import": "./dist/tool/index.js",
17
17
  "default": "./dist/tool/index.js"
18
18
  },
19
+ "./turn-tools": {
20
+ "types": "./dist/turn-tools/index.d.ts",
21
+ "import": "./dist/turn-tools/index.js",
22
+ "default": "./dist/turn-tools/index.js"
23
+ },
19
24
  "./execution": {
20
25
  "types": "./dist/execution/index.d.ts",
21
26
  "import": "./dist/execution/index.js",
@@ -241,8 +246,8 @@
241
246
  "access": "public"
242
247
  },
243
248
  "scripts": {
244
- "build": "tsup src/index.ts src/tool/index.ts src/tool/host/index.ts src/sandbox/index.ts src/execution/index.ts src/inference/index.ts src/inference/errors/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/dispatch/index.ts src/subagents/index.ts src/storage/index.ts src/models/index.ts src/models/reasoning/index.ts src/mcp/index.ts src/profiles/index.ts src/safety/index.ts src/plugin/index.ts src/events/index.ts src/team/index.ts src/logger/index.ts --format esm --dts --clean",
245
- "dev": "tsup src/index.ts src/tool/index.ts src/tool/host/index.ts src/sandbox/index.ts src/execution/index.ts src/inference/index.ts src/inference/errors/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/dispatch/index.ts src/subagents/index.ts src/storage/index.ts src/models/index.ts src/models/reasoning/index.ts src/mcp/index.ts src/profiles/index.ts src/safety/index.ts src/plugin/index.ts src/events/index.ts src/team/index.ts src/logger/index.ts --format esm --dts --watch",
249
+ "build": "tsup src/index.ts src/tool/index.ts src/turn-tools/index.ts src/tool/host/index.ts src/sandbox/index.ts src/execution/index.ts src/inference/index.ts src/inference/errors/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/dispatch/index.ts src/subagents/index.ts src/storage/index.ts src/models/index.ts src/models/reasoning/index.ts src/mcp/index.ts src/profiles/index.ts src/safety/index.ts src/plugin/index.ts src/events/index.ts src/team/index.ts src/logger/index.ts --format esm --dts --clean",
250
+ "dev": "tsup src/index.ts src/tool/index.ts src/turn-tools/index.ts src/tool/host/index.ts src/sandbox/index.ts src/execution/index.ts src/inference/index.ts src/inference/errors/index.ts src/middleware/index.ts src/prompt/index.ts src/skill/index.ts src/dispatch/index.ts src/subagents/index.ts src/storage/index.ts src/models/index.ts src/models/reasoning/index.ts src/mcp/index.ts src/profiles/index.ts src/safety/index.ts src/plugin/index.ts src/events/index.ts src/team/index.ts src/logger/index.ts --format esm --dts --watch",
246
251
  "test": "vitest run",
247
252
  "test:watch": "vitest",
248
253
  "lint": "eslint src/",