@link-assistant/agent 0.26.13 → 0.26.14
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/README.md +3 -0
- package/package.json +1 -1
- package/src/cli/event-handler.js +5 -13
- package/src/json-standard/index.ts +11 -18
package/README.md
CHANGED
|
@@ -360,6 +360,9 @@ echo "hi" | agent --json-standard opencode
|
|
|
360
360
|
|
|
361
361
|
- **Format**: Pretty-printed JSON (human-readable with indentation)
|
|
362
362
|
- **Event Types**: `step_start`, `step_finish`, `text`, `tool_use`, `error`
|
|
363
|
+
(`error` only for failures that end the turn or session; a failed tool call
|
|
364
|
+
is reported on its `tool_use` event — see
|
|
365
|
+
[Error Events](../docs/stdin-mode.md#error-events))
|
|
363
366
|
- **Timestamps**: Unix milliseconds (number)
|
|
364
367
|
- **Session ID**: `sessionID` (camelCase)
|
|
365
368
|
|
package/package.json
CHANGED
package/src/cli/event-handler.js
CHANGED
|
@@ -82,25 +82,17 @@ export function outputBusEvent({
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (part.type === 'tool') {
|
|
85
|
+
// A failed tool call is reported only here, as `part.state.status:
|
|
86
|
+
// "error"`. It is a tool result the model sees and recovers from, not a
|
|
87
|
+
// session failure, so it must not also be emitted as a top-level
|
|
88
|
+
// `error` event: that type is reserved for errors that end the turn or
|
|
89
|
+
// the session, and consumers treat it as fatal (issue #332).
|
|
85
90
|
eventHandler.output({
|
|
86
91
|
type: 'tool_use',
|
|
87
92
|
timestamp: Date.now(),
|
|
88
93
|
sessionID,
|
|
89
94
|
part,
|
|
90
95
|
});
|
|
91
|
-
|
|
92
|
-
// If tool failed, also output an error event
|
|
93
|
-
if (part.state?.status === 'error') {
|
|
94
|
-
const stateError = part.state.error;
|
|
95
|
-
eventHandler.output({
|
|
96
|
-
type: 'error',
|
|
97
|
-
timestamp: Date.now(),
|
|
98
|
-
sessionID,
|
|
99
|
-
part,
|
|
100
|
-
message: errorText(stateError, 'Tool execution failed'),
|
|
101
|
-
error: stateError || 'Tool execution failed',
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
96
|
}
|
|
105
97
|
}
|
|
106
98
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import { EOL } from 'os';
|
|
13
13
|
import { config } from '../config/config';
|
|
14
|
+
import { errorText } from '../util/error-text';
|
|
14
15
|
|
|
15
16
|
export type JsonStandard = 'opencode' | 'claude';
|
|
16
17
|
|
|
@@ -143,10 +144,17 @@ export function convertOpenCodeToClaude(
|
|
|
143
144
|
};
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
//
|
|
147
|
-
//
|
|
147
|
+
// A failed tool call is a recoverable tool result, not a session
|
|
148
|
+
// error (issue #332): report it as an error-status terminal result.
|
|
148
149
|
if (status === 'error') {
|
|
149
|
-
return
|
|
150
|
+
return {
|
|
151
|
+
type: 'tool_result',
|
|
152
|
+
timestamp,
|
|
153
|
+
session_id,
|
|
154
|
+
tool_use_id: event.part.id as string,
|
|
155
|
+
output: errorText(state.error, 'Tool execution failed'),
|
|
156
|
+
status: 'error',
|
|
157
|
+
};
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
return {
|
|
@@ -177,21 +185,6 @@ export function convertOpenCodeToClaude(
|
|
|
177
185
|
};
|
|
178
186
|
|
|
179
187
|
case 'error':
|
|
180
|
-
if (event.part?.type === 'tool' && event.part.state) {
|
|
181
|
-
const state = event.part.state as Record<string, unknown>;
|
|
182
|
-
return {
|
|
183
|
-
type: 'tool_result',
|
|
184
|
-
timestamp,
|
|
185
|
-
session_id,
|
|
186
|
-
tool_use_id: event.part.id as string,
|
|
187
|
-
output:
|
|
188
|
-
event.message ||
|
|
189
|
-
(typeof state.error === 'string'
|
|
190
|
-
? state.error
|
|
191
|
-
: 'Tool execution failed'),
|
|
192
|
-
status: 'error',
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
188
|
return {
|
|
196
189
|
type: 'result',
|
|
197
190
|
timestamp,
|