codeep 1.2.41 → 1.2.42

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.
@@ -46,8 +46,10 @@ export async function runAgentSession(opts) {
46
46
  let toolCallCounter = 0;
47
47
  // Maps tool call key → ACP toolCallId so onToolResult can emit finished/error status
48
48
  const toolCallIdMap = new Map();
49
+ let chunksEmitted = 0;
49
50
  const result = await runAgent(opts.prompt, projectContext, {
50
51
  abortSignal: opts.abortSignal,
52
+ onChunk: (text) => { chunksEmitted++; opts.onChunk(text); },
51
53
  onIteration: (_iteration, _message) => {
52
54
  // Intentionally not forwarded — iteration count is internal detail
53
55
  },
@@ -111,8 +113,9 @@ export async function runAgentSession(opts) {
111
113
  }
112
114
  },
113
115
  });
114
- // Emit the final response text if present
115
- if (result.finalResponse) {
116
+ // result.finalResponse is already emitted via onChunk streaming above;
117
+ // only emit it here if nothing was streamed (e.g. non-streaming fallback path)
118
+ if (result.finalResponse && chunksEmitted === 0) {
116
119
  opts.onChunk(result.finalResponse);
117
120
  }
118
121
  // Surface errors as thrown exceptions so index.ts can handle them correctly
@@ -15,6 +15,7 @@ import { TaskPlan, SubTask } from './taskPlanner';
15
15
  export interface AgentOptions {
16
16
  maxIterations: number;
17
17
  maxDuration: number;
18
+ onChunk?: (text: string) => void;
18
19
  onToolCall?: (tool: ToolCall) => void;
19
20
  onToolResult?: (result: ToolResult, toolCall: ToolCall) => void;
20
21
  onIteration?: (iteration: number, message: string) => void;
@@ -165,7 +165,7 @@ export async function runAgent(prompt, projectContext, options = {}) {
165
165
  let retryCount = 0;
166
166
  while (true) {
167
167
  try {
168
- chatResponse = await agentChat(messages, systemPrompt, opts.onThinking, opts.abortSignal, dynamicTimeout * (1 + retryCount * 0.5) // Increase timeout on retry
168
+ chatResponse = await agentChat(messages, systemPrompt, opts.onChunk, opts.abortSignal, dynamicTimeout * (1 + retryCount * 0.5) // Increase timeout on retry
169
169
  );
170
170
  consecutiveTimeouts = 0; // Reset consecutive count on success
171
171
  break;
@@ -365,7 +365,7 @@ export async function runAgent(prompt, projectContext, options = {}) {
365
365
  }
366
366
  // Get AI response to fix errors
367
367
  try {
368
- const fixResponse = await agentChat(messages, systemPrompt, opts.onThinking, opts.abortSignal);
368
+ const fixResponse = await agentChat(messages, systemPrompt, opts.onChunk, opts.abortSignal);
369
369
  const { content: fixContent, toolCalls: fixToolCalls } = fixResponse;
370
370
  if (fixToolCalls.length === 0) {
371
371
  // Agent gave up or thinks it's fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.2.41",
3
+ "version": "1.2.42",
4
4
  "description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",