@cuylabs/agent-core 1.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.
- package/dist/chunk-O2WCYSXQ.js +0 -0
- package/dist/dispatch/index.d.ts +2 -2
- package/dist/execution/index.d.ts +3 -3
- package/dist/index.d.ts +5 -4
- package/dist/index.js +171 -34
- package/dist/inference/index.d.ts +3 -3
- package/dist/{instance-DpAn37V_.d.ts → instance-7RluLpIT.d.ts} +82 -1
- package/dist/middleware/index.d.ts +2 -2
- package/dist/{model-messages-BDTy2LY_.d.ts → model-messages-CvIEjaIJ.d.ts} +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/profiles/index.d.ts +1 -1
- package/dist/prompt/index.d.ts +2 -2
- package/dist/safety/index.d.ts +2 -2
- package/dist/skill/index.d.ts +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/subagents/index.d.ts +1 -1
- package/dist/team/index.d.ts +2 -2
- package/dist/tool/index.d.ts +2 -2
- package/dist/turn-tools/index.d.ts +12 -0
- package/dist/turn-tools/index.js +1 -0
- package/package.json +8 -3
|
File without changes
|
package/dist/dispatch/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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,
|
|
2
|
-
export {
|
|
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-
|
|
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,
|
|
2
|
-
export {
|
|
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-
|
|
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
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1119
|
-
|
|
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(
|
|
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
|
-
|
|
1392
|
+
rethrowError = error;
|
|
1283
1393
|
} finally {
|
|
1284
|
-
|
|
1394
|
+
if (streamingStateStarted) {
|
|
1395
|
+
setIsStreaming(false);
|
|
1396
|
+
}
|
|
1285
1397
|
interventionCtrl.onApplied = prevOnApplied;
|
|
1286
1398
|
if (middlewareRunner.hasMiddleware) {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
{
|
|
1290
|
-
usage: chatUsage,
|
|
1291
|
-
error: chatError,
|
|
1292
|
-
output: chatOutput
|
|
1293
|
-
},
|
|
1294
|
-
{
|
|
1399
|
+
try {
|
|
1400
|
+
await middlewareRunner.runChatEnd(
|
|
1295
1401
|
sessionId,
|
|
1296
|
-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
|
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 {
|
|
2
|
-
export {
|
|
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';
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Tool,
|
|
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';
|
package/dist/profiles/index.d.ts
CHANGED
package/dist/prompt/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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';
|
package/dist/safety/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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';
|
package/dist/skill/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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';
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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 {
|
|
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';
|
package/dist/team/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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';
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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": "
|
|
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/",
|