@karowanorg/orc-harness-claude 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -205,6 +205,7 @@ async function* invokeSdk(req, ctx) {
205
205
  // from the first frame; refine `model` to the SDK's resolved id when it arrives.
206
206
  yield { kind: "model", model: req.model, reasoningEffort: req.reasoningEffort };
207
207
  let reportedModel = req.model;
208
+ let syntheticFailure;
208
209
  try {
209
210
  for await (const message of query({ prompt: req.prompt, options })) {
210
211
  const m = message.message?.model ??
@@ -213,6 +214,16 @@ async function* invokeSdk(req, ctx) {
213
214
  reportedModel = m;
214
215
  yield { kind: "model", model: m, reasoningEffort: req.reasoningEffort };
215
216
  }
217
+ if (m === "<synthetic>") {
218
+ syntheticFailure = assistantText(message) || "Claude Code returned a synthetic local failure";
219
+ yield { kind: "error", message: `claude unavailable: ${syntheticFailure}` };
220
+ continue;
221
+ }
222
+ // Claude Code emits a nominal success result after local auth/quota
223
+ // failures. Do not turn that status prose into `{text: ...}` and then
224
+ // misreport it as an output-schema defect.
225
+ if (syntheticFailure && message.type === "result")
226
+ continue;
216
227
  for (const ev of mapSdkMessage(message))
217
228
  yield ev;
218
229
  }
@@ -229,6 +240,17 @@ async function* invokeSdk(req, ctx) {
229
240
  ctx.signal.removeEventListener("abort", onAbort);
230
241
  }
231
242
  }
243
+ function assistantText(message) {
244
+ if (message.type !== "assistant")
245
+ return "";
246
+ return (message.message.content ?? [])
247
+ .flatMap((block) => {
248
+ const candidate = block;
249
+ return candidate.type === "text" && typeof candidate.text === "string" ? [candidate.text] : [];
250
+ })
251
+ .join("\n")
252
+ .trim();
253
+ }
232
254
  function* mapSdkMessage(message) {
233
255
  const now = Date.now();
234
256
  if (message.type === "system" && message.subtype === "init") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karowanorg/orc-harness-claude",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "license": "0BSD",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",