@cuylabs/agent-core 0.5.0 → 0.6.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.
@@ -8,7 +8,7 @@ import {
8
8
  buildReasoningOptionsSync
9
9
  } from "./chunk-X635CM2F.js";
10
10
 
11
- // src/runtime/observer.ts
11
+ // src/runtime/task/observer.ts
12
12
  function defaultAgentTaskCheckpointStrategy(input) {
13
13
  switch (input.event.type) {
14
14
  case "step-finish":
@@ -26,7 +26,7 @@ function defaultAgentTaskCheckpointStrategy(input) {
26
26
  }
27
27
  }
28
28
 
29
- // src/runtime/task-runner.ts
29
+ // src/runtime/task/runner.ts
30
30
  import { randomUUID } from "crypto";
31
31
 
32
32
  // src/runtime/turn-state.ts
@@ -197,7 +197,7 @@ function failAgentTurnState(state, error, updatedAt) {
197
197
  };
198
198
  }
199
199
 
200
- // src/runtime/task-runner.ts
200
+ // src/runtime/task/runner.ts
201
201
  function normalizeNonEmpty(value, label) {
202
202
  const normalized = value.trim();
203
203
  if (!normalized) {
@@ -604,6 +604,7 @@ function prepareModelStep(options) {
604
604
  modelMessages,
605
605
  llmInput: {
606
606
  sessionID: options.sessionId,
607
+ step: options.step,
607
608
  model: options.config.model,
608
609
  system: options.systemPrompts,
609
610
  messages: modelMessages,
@@ -959,6 +960,101 @@ function shouldRetry(error, attempt, maxAttempts = DEFAULT_RETRY_CONFIG.maxAttem
959
960
  var OUTPUT_TOKEN_MAX = 32e3;
960
961
 
961
962
  // src/execution/llm/stream.ts
963
+ function buildModelCallContext(input) {
964
+ return {
965
+ sessionID: input.sessionID,
966
+ step: input.step ?? 1,
967
+ cwd: input.cwd,
968
+ abort: input.abort,
969
+ model: input.model,
970
+ toolNames: Object.keys(input.tools),
971
+ mcpToolNames: Object.keys(input.mcpTools ?? {})
972
+ };
973
+ }
974
+ function buildModelCallInput(input) {
975
+ return {
976
+ model: input.model,
977
+ system: [...input.system],
978
+ messages: [...input.messages],
979
+ temperature: input.temperature,
980
+ topP: input.topP,
981
+ maxOutputTokens: input.maxOutputTokens,
982
+ maxSteps: input.maxSteps,
983
+ reasoningLevel: input.reasoningLevel,
984
+ telemetry: input.telemetry,
985
+ customStreamProvider: input.customStreamProvider,
986
+ toolExecutionMode: input.toolExecutionMode
987
+ };
988
+ }
989
+ function applyModelCallInput(target, modelCall) {
990
+ target.model = modelCall.model;
991
+ target.system = [...modelCall.system];
992
+ target.messages = [...modelCall.messages];
993
+ target.temperature = modelCall.temperature;
994
+ target.topP = modelCall.topP;
995
+ target.maxOutputTokens = modelCall.maxOutputTokens;
996
+ target.maxSteps = modelCall.maxSteps;
997
+ target.reasoningLevel = modelCall.reasoningLevel;
998
+ target.telemetry = modelCall.telemetry;
999
+ target.customStreamProvider = modelCall.customStreamProvider;
1000
+ target.toolExecutionMode = modelCall.toolExecutionMode;
1001
+ target.activeModelCall = modelCall;
1002
+ }
1003
+ function isBlockedModelCall(value) {
1004
+ return "block" in value && value.block === true;
1005
+ }
1006
+ async function resolveModelCallInput(input) {
1007
+ if (!input.middleware?.hasMiddleware) {
1008
+ const current = buildModelCallInput(input);
1009
+ input.activeModelCall = current;
1010
+ return current;
1011
+ }
1012
+ const next = await input.middleware.runModelInput(
1013
+ buildModelCallInput(input),
1014
+ buildModelCallContext(input)
1015
+ );
1016
+ if (isBlockedModelCall(next)) {
1017
+ return next;
1018
+ }
1019
+ applyModelCallInput(input, next);
1020
+ return next;
1021
+ }
1022
+ function wrapModelStream(stream2, input) {
1023
+ const normalizedText = Promise.resolve(stream2.text);
1024
+ const normalizedUsage = Promise.resolve(stream2.usage).then((usage) => ({
1025
+ inputTokens: usage.inputTokens ?? 0,
1026
+ outputTokens: usage.outputTokens ?? 0,
1027
+ totalTokens: usage.totalTokens ?? 0
1028
+ }));
1029
+ const normalizedFinishReason = Promise.resolve(stream2.finishReason).then(
1030
+ (reason) => String(reason)
1031
+ );
1032
+ if (!input.middleware?.hasMiddleware) {
1033
+ return {
1034
+ fullStream: stream2.fullStream,
1035
+ text: normalizedText,
1036
+ usage: normalizedUsage,
1037
+ finishReason: normalizedFinishReason
1038
+ };
1039
+ }
1040
+ return {
1041
+ fullStream: (async function* () {
1042
+ const ctx = buildModelCallContext(input);
1043
+ for await (const rawChunk of stream2.fullStream) {
1044
+ const chunk = await input.middleware.runModelChunk(
1045
+ rawChunk,
1046
+ ctx
1047
+ );
1048
+ if (chunk) {
1049
+ yield chunk;
1050
+ }
1051
+ }
1052
+ })(),
1053
+ text: normalizedText,
1054
+ usage: normalizedUsage,
1055
+ finishReason: normalizedFinishReason
1056
+ };
1057
+ }
962
1058
  async function createCustomStream(input) {
963
1059
  const system = input.system.filter(Boolean).join("\n");
964
1060
  return input.customStreamProvider({
@@ -1033,17 +1129,27 @@ async function callStreamTextWithOtelContext(options) {
1033
1129
  }
1034
1130
  async function stream(input) {
1035
1131
  const messageID = crypto.randomUUID();
1132
+ const resolvedInput = await resolveModelCallInput(input);
1133
+ const modelInfo = getModelInfo(input);
1134
+ if (isBlockedModelCall(resolvedInput)) {
1135
+ throw new LLMError({
1136
+ message: resolvedInput.reason,
1137
+ category: "invalid_request",
1138
+ provider: modelInfo.provider,
1139
+ model: modelInfo.model
1140
+ });
1141
+ }
1036
1142
  const system = input.system.filter(Boolean).join("\n");
1037
1143
  if (input.customStreamProvider) {
1038
1144
  const runCustomStream = async () => await createCustomStream(input);
1039
1145
  if (!input.retry || input.retry.maxAttempts === 0) {
1040
- return await runCustomStream();
1146
+ return wrapModelStream(await runCustomStream(), input);
1041
1147
  }
1042
- return await withRetry(
1148
+ return wrapModelStream(await withRetry(
1043
1149
  async () => await runCustomStream(),
1044
1150
  input.retry,
1045
1151
  input.abort
1046
- );
1152
+ ), input);
1047
1153
  }
1048
1154
  const toolSet = await buildToolSet({
1049
1155
  tools: input.tools,
@@ -1061,7 +1167,6 @@ async function stream(input) {
1061
1167
  ...input.mcpTools ?? {}
1062
1168
  };
1063
1169
  const providerOptions = input.reasoningLevel ? buildReasoningOptionsSync(input.model, input.reasoningLevel) : void 0;
1064
- const modelInfo = getModelInfo(input);
1065
1170
  const createStream = async () => {
1066
1171
  try {
1067
1172
  return await callStreamTextWithOtelContext({
@@ -1075,13 +1180,13 @@ async function stream(input) {
1075
1180
  }
1076
1181
  };
1077
1182
  if (!input.retry || input.retry.maxAttempts === 0) {
1078
- return await createStream();
1183
+ return wrapModelStream(await createStream(), input);
1079
1184
  }
1080
- return await withRetry(
1185
+ return wrapModelStream(await withRetry(
1081
1186
  async () => await createStream(),
1082
1187
  input.retry,
1083
1188
  input.abort
1084
- );
1189
+ ), input);
1085
1190
  }
1086
1191
  async function streamOnce(input) {
1087
1192
  return await stream({ ...input, retry: void 0 });
@@ -1381,6 +1486,18 @@ async function processStream(stream2, options) {
1381
1486
  }
1382
1487
 
1383
1488
  // src/runtime/turn-runner/stream-step.ts
1489
+ function buildModelCallContext2(options) {
1490
+ const input = options.preparedStep.llmInput;
1491
+ return {
1492
+ sessionID: input.sessionID,
1493
+ step: input.step ?? options.preparedStep.step,
1494
+ cwd: input.cwd,
1495
+ abort: input.abort,
1496
+ model: input.model,
1497
+ toolNames: Object.keys(input.tools),
1498
+ mcpToolNames: Object.keys(input.mcpTools ?? {})
1499
+ };
1500
+ }
1384
1501
  async function* runModelStep(options) {
1385
1502
  const { preparedStep, turnEngine, applyCommitBatch } = options;
1386
1503
  const stream2 = await LLM.streamStep(preparedStep.llmInput);
@@ -1468,6 +1585,19 @@ async function* runModelStep(options) {
1468
1585
  `Agent step ${preparedStep.step} produced no processor result`
1469
1586
  );
1470
1587
  }
1588
+ if (middleware?.hasMiddleware) {
1589
+ const revised = await middleware.runModelOutput(
1590
+ {
1591
+ text: result.text,
1592
+ usage: result.usage,
1593
+ finishReason: result.finishReason
1594
+ },
1595
+ buildModelCallContext2(options)
1596
+ );
1597
+ result.text = revised.text;
1598
+ result.usage = revised.usage;
1599
+ result.finishReason = revised.finishReason;
1600
+ }
1471
1601
  return result;
1472
1602
  }
1473
1603
 
@@ -1,4 +1,7 @@
1
1
  // src/middleware/runner.ts
2
+ function isBlockedModelCall(value) {
3
+ return "block" in value && value.block === true;
4
+ }
2
5
  var MiddlewareRunner = class {
3
6
  stack;
4
7
  constructor(middleware = []) {
@@ -17,6 +20,76 @@ var MiddlewareRunner = class {
17
20
  return this.stack;
18
21
  }
19
22
  // --------------------------------------------------------------------------
23
+ // model.input — array order, first block wins
24
+ // --------------------------------------------------------------------------
25
+ async runModelInput(input, ctx) {
26
+ let current = input;
27
+ for (const mw of this.stack) {
28
+ if (!mw.model?.input) continue;
29
+ try {
30
+ const next = await mw.model.input(current, ctx);
31
+ if (!next) continue;
32
+ if (isBlockedModelCall(next)) {
33
+ return next;
34
+ }
35
+ current = next;
36
+ } catch (err) {
37
+ return {
38
+ block: true,
39
+ reason: `Middleware "${mw.name}" model input error: ${err instanceof Error ? err.message : String(err)}`
40
+ };
41
+ }
42
+ }
43
+ return current;
44
+ }
45
+ // --------------------------------------------------------------------------
46
+ // model.chunk — array order, streamed transformation
47
+ // --------------------------------------------------------------------------
48
+ async runModelChunk(chunk, ctx) {
49
+ let current = chunk;
50
+ for (const mw of this.stack) {
51
+ if (!mw.model?.chunk || current === null) continue;
52
+ try {
53
+ const next = await mw.model.chunk(current, ctx);
54
+ if (next === null) {
55
+ current = null;
56
+ continue;
57
+ }
58
+ if (next !== void 0) {
59
+ current = next;
60
+ }
61
+ } catch (err) {
62
+ console.warn(
63
+ `[middleware] "${mw.name}" model.chunk error:`,
64
+ err instanceof Error ? err.message : String(err)
65
+ );
66
+ }
67
+ }
68
+ return current ?? void 0;
69
+ }
70
+ // --------------------------------------------------------------------------
71
+ // model.output — reverse order (innermost first)
72
+ // --------------------------------------------------------------------------
73
+ async runModelOutput(output, ctx) {
74
+ let current = output;
75
+ for (let i = this.stack.length - 1; i >= 0; i--) {
76
+ const mw = this.stack[i];
77
+ if (!mw.model?.output) continue;
78
+ try {
79
+ const next = await mw.model.output(current, ctx);
80
+ if (next) {
81
+ current = next;
82
+ }
83
+ } catch (err) {
84
+ console.warn(
85
+ `[middleware] "${mw.name}" model.output error:`,
86
+ err instanceof Error ? err.message : String(err)
87
+ );
88
+ }
89
+ }
90
+ return current;
91
+ }
92
+ // --------------------------------------------------------------------------
20
93
  // beforeToolCall — array order, first "deny" wins
21
94
  // --------------------------------------------------------------------------
22
95
  /**
@@ -1,14 +1,14 @@
1
1
  import { LanguageModel } from 'ai';
2
2
  import { R as ReasoningLevel } from './types-CQaXbRsS.js';
3
3
  import { T as Tool } from './tool-pFAnJc5Y.js';
4
- import { f as AgentMiddleware, P as PromptConfig, A as AgentEvent, M as MiddlewareRunner } from './runner-C7aMP_x3.js';
4
+ import { h as AgentMiddleware, e as StreamProvider, P as PromptConfig, A as AgentEvent, M as MiddlewareRunner } from './runner-G1wxEgac.js';
5
5
  import { g as SessionManager, c as SessionContext, f as SessionInfo } from './session-manager-Uawm2Le7.js';
6
6
  import { d as ToolHost } from './tool-DYp6-cC3.js';
7
7
  import { T as TokenUsage, M as Message } from './messages-BYWGn8TY.js';
8
8
  import { a as MCPManager } from './types-VQgymC1N.js';
9
9
  import { U as UndoResult, T as TurnChangeTracker } from './tracker-DClqYqTj.js';
10
- import { P as PromptBuilder } from './builder-RcTZuYnO.js';
11
- import { x as DoomLoopHandler, Z as StreamProvider, J as PendingIntervention, I as InterventionController, q as AgentTurnStepRuntimeConfig } from './types-MM1JoX5T.js';
10
+ import { P as PromptBuilder } from './builder-BKkipazh.js';
11
+ import { x as DoomLoopHandler, H as PendingIntervention, I as InterventionController, q as AgentTurnStepRuntimeConfig } from './types-BWo810L_.js';
12
12
 
13
13
  /**
14
14
  * Configuration for automatic context compaction.
@@ -1,4 +1,4 @@
1
- import { f as AgentMiddleware } from './runner-C7aMP_x3.js';
1
+ import { h as AgentMiddleware } from './runner-G1wxEgac.js';
2
2
  import { TelemetrySettings } from 'ai';
3
3
 
4
4
  /**
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { P as Preset, A as AppliedPreset, a as Agent } from './index-p0kOsVsE.js';
2
- export { b as AgentConfig, c as AgentProfile, C as CompactionConfig, D as DEFAULT_MAX_CONCURRENT, d as DEFAULT_MAX_SPAWN_DEPTH, e as DEFAULT_SESSION_TITLE_PREFIX, S as SubAgentCompletedResult, f as SubAgentHandle, g as SubAgentStatus, h as SubAgentToolConfig, i as SubAgentTracker, j as SubAgentUsage, T as TracingConfig, k as createAgent, l as createSubAgentTools } from './index-p0kOsVsE.js';
1
+ import { P as Preset, A as AppliedPreset, a as Agent } from './index-DZQJD_hp.js';
2
+ export { b as AgentConfig, c as AgentProfile, C as CompactionConfig, D as DEFAULT_MAX_CONCURRENT, d as DEFAULT_MAX_SPAWN_DEPTH, e as DEFAULT_SESSION_TITLE_PREFIX, S as SubAgentCompletedResult, f as SubAgentHandle, g as SubAgentStatus, h as SubAgentToolConfig, i as SubAgentTracker, j as SubAgentUsage, T as TracingConfig, k as createAgent, l as createSubAgentTools } from './index-DZQJD_hp.js';
3
3
  import { LanguageModel, ToolSet } from 'ai';
4
4
  import { R as ReasoningLevel } from './types-CQaXbRsS.js';
5
5
  export { a as ReasoningConfig } from './types-CQaXbRsS.js';
6
- import { E as ErrorCategory, T as ToolExecutionMode, L as LLMStreamInput, A as AnyStreamResult, P as ProcessorOptions, a as ProcessorOutput } from './types-MM1JoX5T.js';
7
- export { b as AgentTurnActiveToolCall, c as AgentTurnBoundaryMetadata, d as AgentTurnBoundarySnapshot, e as AgentTurnCommitApplier, f as AgentTurnCommitBatch, g as AgentTurnCommitOptions, h as AgentTurnEngine, i as AgentTurnEngineOptions, j as AgentTurnPhase, k as AgentTurnResolvedToolCall, l as AgentTurnState, m as AgentTurnStateAdvanceOptions, n as AgentTurnStepCommitSnapshot, o as AgentTurnStepCommitToolCall, p as AgentTurnStepCommitToolResult, q as AgentTurnStepRuntimeConfig, C as CommitOutputOptions, r as CommitStepOptions, s as CreateAgentTurnStateOptions, t as CreateAgentTurnStepCommitBatchOptions, u as CustomStreamProvider, v as CustomStreamResult, D as DEFAULT_RETRY_CONFIG, w as DoomLoopAction, x as DoomLoopHandler, y as DoomLoopRequest, z as EnhancedTools, I as InterventionController, B as LLMError, F as LLMErrorOptions, G as LLMStreamResult, O as OUTPUT_TOKEN_MAX, H as OnInterventionApplied, J as PendingIntervention, K as PrepareModelStepOptions, M as PreparedAgentModelStep, R as ResponseHeaders, N as RetryConfig, Q as RetryHandlerOptions, S as RetryState, U as RunModelStepOptions, V as RunToolBatchOptions, W as RunToolBatchResult, X as StepInfo, Y as StreamChunk, Z as StreamProvider, _ as StreamProviderConfig, $ as StreamProviderFactory, a0 as StreamProviderInput, a1 as StreamProviderResult, a2 as advanceAgentTurnState, a3 as calculateDelay, a4 as createAgentTurnEngine, a5 as createAgentTurnState, a6 as createRetryHandler, a7 as createRetryState, a8 as failAgentTurnState, a9 as shouldRetry, aa as sleep, ab as withRetry } from './types-MM1JoX5T.js';
8
- import { M as MiddlewareRunner } from './runner-C7aMP_x3.js';
9
- export { A as AgentEvent, f as AgentMiddleware, g as AgentStatus, e as AgentTurnBoundaryKind, h as ApprovalEvent, E as EnvironmentInfo, I as InstructionFile, c as ModelFamily, d as ProcessorResult, a as PromptBuildContext, P as PromptConfig, b as PromptSection, S as StreamInput, T as ToolCallDecision } from './runner-C7aMP_x3.js';
6
+ import { E as ErrorCategory, T as ToolExecutionMode, L as LLMStreamInput, A as AnyStreamResult, P as ProcessorOptions, a as ProcessorOutput } from './types-BWo810L_.js';
7
+ export { b as AgentTurnActiveToolCall, c as AgentTurnBoundaryMetadata, d as AgentTurnBoundarySnapshot, e as AgentTurnCommitApplier, f as AgentTurnCommitBatch, g as AgentTurnCommitOptions, h as AgentTurnEngine, i as AgentTurnEngineOptions, j as AgentTurnPhase, k as AgentTurnResolvedToolCall, l as AgentTurnState, m as AgentTurnStateAdvanceOptions, n as AgentTurnStepCommitSnapshot, o as AgentTurnStepCommitToolCall, p as AgentTurnStepCommitToolResult, q as AgentTurnStepRuntimeConfig, C as CommitOutputOptions, r as CommitStepOptions, s as CreateAgentTurnStateOptions, t as CreateAgentTurnStepCommitBatchOptions, u as CustomStreamProvider, v as CustomStreamResult, D as DEFAULT_RETRY_CONFIG, w as DoomLoopAction, x as DoomLoopHandler, y as DoomLoopRequest, I as InterventionController, z as LLMError, B as LLMErrorOptions, F as LLMStreamResult, O as OUTPUT_TOKEN_MAX, G as OnInterventionApplied, H as PendingIntervention, J as PrepareModelStepOptions, K as PreparedAgentModelStep, R as ResponseHeaders, M as RetryConfig, N as RetryHandlerOptions, Q as RetryState, S as RunModelStepOptions, U as RunToolBatchOptions, V as RunToolBatchResult, W as StepInfo, X as advanceAgentTurnState, Y as calculateDelay, Z as createAgentTurnEngine, _ as createAgentTurnState, $ as createRetryHandler, a0 as createRetryState, a1 as failAgentTurnState, a2 as shouldRetry, a3 as sleep, a4 as withRetry } from './types-BWo810L_.js';
8
+ import { M as MiddlewareRunner } from './runner-G1wxEgac.js';
9
+ export { A as AgentEvent, h as AgentMiddleware, i as AgentModelHooks, j as AgentStatus, g as AgentTurnBoundaryKind, k as ApprovalEvent, B as BlockedModelCall, E as EnhancedTools, l as EnvironmentInfo, I as InstructionFile, m as ModelCallContext, f as ModelCallInput, n as ModelCallOutput, c as ModelFamily, d as ProcessorResult, a as PromptBuildContext, P as PromptConfig, b as PromptSection, S as StreamChunk, o as StreamInput, e as StreamProvider, p as StreamProviderConfig, q as StreamProviderFactory, r as StreamProviderInput, s as StreamProviderResult, T as ToolCallDecision } from './runner-G1wxEgac.js';
10
10
  import { T as TokenUsage } from './messages-BYWGn8TY.js';
11
11
  export { A as AssistantMessage, M as Message, a as MessageBase, b as MessageError, c as MessageRole, S as Session, d as SystemMessage, e as ToolMessage, U as UserMessage } from './messages-BYWGn8TY.js';
12
12
  import { T as Tool } from './tool-pFAnJc5Y.js';
@@ -16,7 +16,7 @@ export { D as DirEntry, E as ExecOptions, f as ExecResult, F as FileOperationMet
16
16
  export { ContextLimits, ContextManager, DEFAULT_CONTEXT_LIMITS, PruneContextOptions, PruneResult, SummarizationOptions, estimateConversationTokens, estimateMessageTokens, estimateTokens, findCutPoint, generateSummary, isContextOverflowing, pruneContext, pruneToolResults, shouldPruneContext } from './context/index.js';
17
17
  export { F as FileBaseline, T as TurnChangeTracker, a as TurnFileChange, b as TurnSummary, c as TurnTrackerConfig, U as UndoResult, d as createTurnTracker } from './tracker-DClqYqTj.js';
18
18
  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';
19
- export { P as PromptBuilder, c as createPromptBuilder } from './builder-RcTZuYnO.js';
19
+ export { P as PromptBuilder, c as createPromptBuilder } from './builder-BKkipazh.js';
20
20
  export { c as ModelCapabilities, d as ModelCapabilityResolver, M as ModelEntry, N as NetworkStatus, P as ProviderCompatibility, R as ResolverOptions, g as configureResolver, h as getDefaultResolver } from './resolver-DOfZ-xuk.js';
21
21
  export { g as getModelId, a as getProviderId } from './identifiers-BLUxFqV_.js';
22
22
  export { g as getNetworkStatus } from './network-D76DS5ot.js';
@@ -24,8 +24,8 @@ export { b as buildReasoningOptions, a as buildReasoningOptionsSync, g as getRea
24
24
  export { B as BranchEntry, C as CompactionEntry, a as CreateSessionOptions, F as FileEntry, M as MessageEntry, b as MetadataEntry, S as STORAGE_VERSION, c as SessionContext, d as SessionEntry, e as SessionHeader, f as SessionInfo, g as SessionManager, h as SessionStorage } from './session-manager-Uawm2Le7.js';
25
25
  export { FileStorage, FileStorageOptions, MemoryStorage, buildMessagesFromEntries, configureDefaultSessionManager, deserializeMessage, generateEntryId, getDataDir, getDefaultSessionManager, getLeafId, getProjectSessionsDir, getSessionsDir, parseJSONL, serializeMessage, toJSONL } from './storage/index.js';
26
26
  export { AgentTaskChatAdapter, AgentTaskCheckpointReason, AgentTaskCheckpointStrategy, AgentTaskCheckpointStrategyInput, AgentTaskExecutionCheckpoint, AgentTaskExecutionContext, AgentTaskExecutionRun, AgentTaskExecutionSnapshot, AgentTaskObserver, AgentTaskPayload, AgentTaskResult, AgentTaskRunner, AgentTaskRunnerOptions, AgentWorkflowAssistantMessageSnapshot, AgentWorkflowCommitResult, AgentWorkflowMessageSnapshot, AgentWorkflowModelStepPlan, AgentWorkflowModelStepResult, AgentWorkflowOperationPlan, AgentWorkflowOutputCommitPlan, AgentWorkflowReplayDecision, AgentWorkflowStepCommitPlan, AgentWorkflowSystemMessageSnapshot, AgentWorkflowToolBatchResult, AgentWorkflowToolCallPlan, AgentWorkflowToolCallResult, AgentWorkflowToolCallSnapshot, AgentWorkflowToolMessageSnapshot, AgentWorkflowTurnPhase, AgentWorkflowTurnState, AgentWorkflowUserMessageSnapshot, CreateAgentWorkflowTurnStateOptions, applyAgentWorkflowCommitResult, applyAgentWorkflowModelStepResult, applyAgentWorkflowToolBatchResult, applyAgentWorkflowToolCallResult, cloneAgentWorkflowTurnState, commitOutput, commitStep, convertAgentMessagesToModelMessages, createAgentTaskRunner, createAgentTurnStepCommitBatch, createAgentWorkflowTurnState, defaultAgentTaskCheckpointStrategy, failAgentWorkflowTurnState, planNextAgentWorkflowOperation, prepareModelStep, recordAgentWorkflowReplayDecision, restoreAgentWorkflowMessage, restoreAgentWorkflowMessages, runModelStep, runToolBatch, snapshotAgentWorkflowMessage, snapshotAgentWorkflowMessages } from './runtime/index.js';
27
- import { R as RiskLevel, A as ApprovalConfig, a as ApprovalRule } from './index-tmhaADz5.js';
28
- export { b as ApprovalAction, c as ApprovalMiddlewareConfig, d as ApprovalRequest, O as OtelMiddlewareConfig, T as TelemetryConfig, e as TelemetryConfigResult, f as approvalMiddleware, g as createTelemetryConfig, o as otelMiddleware } from './index-tmhaADz5.js';
27
+ import { R as RiskLevel, A as ApprovalConfig, a as ApprovalRule } from './index-ipP3_ztp.js';
28
+ export { b as ApprovalAction, c as ApprovalMiddlewareConfig, d as ApprovalRequest, O as OtelMiddlewareConfig, T as TelemetryConfig, e as TelemetryConfigResult, f as approvalMiddleware, g as createTelemetryConfig, o as otelMiddleware } from './index-ipP3_ztp.js';
29
29
  export { ChangeSet, Checkpoint, CheckpointConfig, CheckpointManager, FileChange, TrackedToolMetadata, clearCheckpoints, createCheckpointManager, extractFilePathsFromArgs, shouldCaptureBaseline, withFileTracking } from './tracking/index.js';
30
30
  export { H as HttpTransportConfig, M as MCPConfig, a as MCPManager, b as MCPPrompt, c as MCPResource, d as MCPServerConfig, e as MCPServerStatus, S as SseTransportConfig, f as StdioTransportConfig } from './types-VQgymC1N.js';
31
31
  export { createMCPManager, defineServer, httpServer, sseServer, stdioServer } from './mcp/index.js';
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  snapshotAgentWorkflowMessage,
44
44
  snapshotAgentWorkflowMessages,
45
45
  withRetry
46
- } from "./chunk-IMGQOTU2.js";
46
+ } from "./chunk-3C4VKG4P.js";
47
47
  import {
48
48
  createSkillResourceTool,
49
49
  createSkillTool,
@@ -132,7 +132,7 @@ import {
132
132
  createTelemetryConfig,
133
133
  getToolRisk,
134
134
  otelMiddleware
135
- } from "./chunk-OTUGSCED.js";
135
+ } from "./chunk-O2ZCFQL6.js";
136
136
  import {
137
137
  createResolver
138
138
  } from "./chunk-6TDTQJ4P.js";
@@ -422,7 +422,11 @@ async function* runChatLoop(deps) {
422
422
  }
423
423
  chatUsage = accumulatedUsage;
424
424
  chatOutput = finalStepText || void 0;
425
- yield { type: "complete", usage: accumulatedUsage };
425
+ yield {
426
+ type: "complete",
427
+ usage: accumulatedUsage,
428
+ output: finalStepText || void 0
429
+ };
426
430
  } catch (error) {
427
431
  chatError = error instanceof Error ? error : new Error(String(error));
428
432
  throw error;
@@ -1819,6 +1823,7 @@ var Agent = class _Agent {
1819
1823
  break;
1820
1824
  case "complete":
1821
1825
  if (event.usage) usage = event.usage;
1826
+ if (event.output !== void 0) response = event.output;
1822
1827
  break;
1823
1828
  case "error":
1824
1829
  throw event.error;
@@ -1,7 +1,8 @@
1
- export { f as AgentMiddleware, M as MiddlewareRunner, T as ToolCallDecision } from '../runner-C7aMP_x3.js';
2
- export { c as ApprovalMiddlewareConfig, O as OtelMiddlewareConfig, T as TelemetryConfig, e as TelemetryConfigResult, f as approvalMiddleware, g as createTelemetryConfig, o as otelMiddleware } from '../index-tmhaADz5.js';
1
+ export { h as AgentMiddleware, i as AgentModelHooks, B as BlockedModelCall, M as MiddlewareRunner, m as ModelCallContext, f as ModelCallInput, n as ModelCallOutput, T as ToolCallDecision } from '../runner-G1wxEgac.js';
2
+ export { c as ApprovalMiddlewareConfig, O as OtelMiddlewareConfig, T as TelemetryConfig, e as TelemetryConfigResult, f as approvalMiddleware, g as createTelemetryConfig, o as otelMiddleware } from '../index-ipP3_ztp.js';
3
3
  import 'ai';
4
4
  import '../messages-BYWGn8TY.js';
5
5
  import '../tool-pFAnJc5Y.js';
6
6
  import 'zod';
7
7
  import '../tool-DYp6-cC3.js';
8
+ import '../types-CQaXbRsS.js';
@@ -3,7 +3,7 @@ import {
3
3
  approvalMiddleware,
4
4
  createTelemetryConfig,
5
5
  otelMiddleware
6
- } from "../chunk-OTUGSCED.js";
6
+ } from "../chunk-O2ZCFQL6.js";
7
7
  export {
8
8
  MiddlewareRunner,
9
9
  approvalMiddleware,
@@ -1,10 +1,11 @@
1
- import { c as ModelFamily, E as EnvironmentInfo, I as InstructionFile } from '../runner-C7aMP_x3.js';
2
- export { a as PromptBuildContext, P as PromptConfig, b as PromptSection } from '../runner-C7aMP_x3.js';
1
+ import { c as ModelFamily, l as EnvironmentInfo, I as InstructionFile } from '../runner-G1wxEgac.js';
2
+ export { a as PromptBuildContext, P as PromptConfig, b as PromptSection } from '../runner-G1wxEgac.js';
3
3
  import { LanguageModel } from 'ai';
4
- export { P as PromptBuilder, c as createPromptBuilder } from '../builder-RcTZuYnO.js';
4
+ export { P as PromptBuilder, c as createPromptBuilder } from '../builder-BKkipazh.js';
5
5
  export { d as SkillConfig } from '../tool-pFAnJc5Y.js';
6
6
  import '../messages-BYWGn8TY.js';
7
7
  import '../tool-DYp6-cC3.js';
8
+ import '../types-CQaXbRsS.js';
8
9
  import '../registry-CuRWWtcT.js';
9
10
  import 'zod';
10
11