@zhijiewang/openharness 2.27.0 → 2.29.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.
@@ -133,7 +133,7 @@ export function renderToolCallsSection(state, grid, r, limit, opts) {
133
133
  const MAX_DEPTH = 3;
134
134
  const renderSingleCall = (callId, tc, depth) => {
135
135
  const colOffset = depth * 4;
136
- const isAgent = tc.isAgent || tc.toolName === "Agent" || tc.toolName === "ParallelAgents";
136
+ const isAgent = tc.isAgent || tc.toolName === "Agent" || tc.toolName === "ParallelAgents" || tc.toolName === "Task";
137
137
  const icon = isAgent
138
138
  ? tc.status === "running"
139
139
  ? "⊕"
package/dist/repl.js CHANGED
@@ -934,7 +934,7 @@ export async function startREPL(config) {
934
934
  break;
935
935
  case "tool_call_start": {
936
936
  callIdToToolName.set(event.callId, event.toolName);
937
- const isAgentTool = event.toolName === "Agent" || event.toolName === "ParallelAgents";
937
+ const isAgentTool = event.toolName === "Agent" || event.toolName === "ParallelAgents" || event.toolName === "Task";
938
938
  renderer.setToolCall(event.callId, {
939
939
  toolName: event.toolName,
940
940
  status: "running",
@@ -947,7 +947,7 @@ export async function startREPL(config) {
947
947
  case "tool_call_complete": {
948
948
  const tcToolName = callIdToToolName.get(event.callId) ?? "";
949
949
  const existingTc = renderer.getToolCall(event.callId);
950
- const isAgentCall = tcToolName === "Agent" || tcToolName === "ParallelAgents";
950
+ const isAgentCall = tcToolName === "Agent" || tcToolName === "ParallelAgents" || tcToolName === "Task";
951
951
  const agentDesc = isAgentCall
952
952
  ? event.arguments.description
953
953
  : undefined;
@@ -128,6 +128,25 @@ export class AgentDispatcher {
128
128
  const cwd = this.workingDir ?? process.cwd();
129
129
  const useWorktree = isGitRepo(cwd);
130
130
  let worktreePath = null;
131
+ let result;
132
+ const taskCallId = `task-${task.id}-${Date.now().toString(36)}`;
133
+ const taskDescription = task.description ?? task.id;
134
+ const synthEnabled = !!this.emitChildEvent && !!this.parentCallId;
135
+ if (synthEnabled) {
136
+ this.emitChildEvent({
137
+ type: "tool_call_start",
138
+ toolName: "Task",
139
+ callId: taskCallId,
140
+ parentCallId: this.parentCallId,
141
+ });
142
+ this.emitChildEvent({
143
+ type: "tool_call_complete",
144
+ toolName: "Task",
145
+ callId: taskCallId,
146
+ arguments: { description: taskDescription },
147
+ parentCallId: this.parentCallId,
148
+ });
149
+ }
131
150
  if (useWorktree) {
132
151
  worktreePath = createWorktree(cwd);
133
152
  }
@@ -175,14 +194,16 @@ export class AgentDispatcher {
175
194
  }
176
195
  }
177
196
  let output = "";
197
+ let errorMessage = null;
178
198
  try {
179
199
  for await (const event of query(promptWithContext, config)) {
180
200
  if (event.type === "text_delta")
181
201
  output += event.content;
182
202
  if (event.type === "error") {
183
- return { id: task.id, output: `Error: ${event.message}`, isError: true, durationMs: Date.now() - start };
203
+ errorMessage = event.message;
204
+ break;
184
205
  }
185
- forwardChildEvent(event, this.parentCallId, this.emitChildEvent);
206
+ forwardChildEvent(event, taskCallId, this.emitChildEvent);
186
207
  }
187
208
  }
188
209
  finally {
@@ -195,10 +216,15 @@ export class AgentDispatcher {
195
216
  }
196
217
  }
197
218
  }
198
- return { id: task.id, output: output || "(no output)", isError: false, durationMs: Date.now() - start };
219
+ if (errorMessage !== null) {
220
+ result = { id: task.id, output: `Error: ${errorMessage}`, isError: true, durationMs: Date.now() - start };
221
+ }
222
+ else {
223
+ result = { id: task.id, output: output || "(no output)", isError: false, durationMs: Date.now() - start };
224
+ }
199
225
  }
200
226
  catch (err) {
201
- return {
227
+ result = {
202
228
  id: task.id,
203
229
  output: `Failed: ${err instanceof Error ? err.message : String(err)}`,
204
230
  isError: true,
@@ -209,7 +235,17 @@ export class AgentDispatcher {
209
235
  if (worktreePath) {
210
236
  removeWorktree(worktreePath, cwd);
211
237
  }
238
+ if (synthEnabled) {
239
+ this.emitChildEvent({
240
+ type: "tool_call_end",
241
+ callId: taskCallId,
242
+ output: result.output,
243
+ isError: result.isError,
244
+ parentCallId: this.parentCallId,
245
+ });
246
+ }
212
247
  }
248
+ return result;
213
249
  }
214
250
  }
215
251
  //# sourceMappingURL=AgentDispatcher.js.map
@@ -165,10 +165,10 @@ export const AgentTool = {
165
165
  }
166
166
  else if (event.type === "tool_output_delta") {
167
167
  outputChunks.push(event.chunk);
168
- if (context.onOutputChunk && context.callId) {
168
+ const forwarded = forwardInnerEvent(event, context);
169
+ if (!forwarded && context.onOutputChunk && context.callId) {
169
170
  context.onOutputChunk(context.callId, event.chunk);
170
171
  }
171
- forwardInnerEvent(event, context);
172
172
  }
173
173
  else if (event.type === "tool_call_start" ||
174
174
  event.type === "tool_call_complete" ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhijiewang/openharness",
3
- "version": "2.27.0",
3
+ "version": "2.29.0",
4
4
  "description": "Open-source terminal coding agent. Works with any LLM.",
5
5
  "type": "module",
6
6
  "bin": {