clanka 0.12.1 → 0.12.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.
package/dist/bin/cli.mjs CHANGED
@@ -32007,13 +32007,23 @@ ${capOutput(turn.output ?? "").output}
32007
32007
  onStart: onCompactionStart
32008
32008
  }).pipe(timeout(turnTimeout))).pipe(catchTag("TimeoutError", (error) => logWarning("Compaction timed out, continuing with the uncompacted prompt", error)));
32009
32009
  let response = empty$4();
32010
+ let hadToolCall = false;
32011
+ let finished = false;
32012
+ let failure;
32010
32013
  const discardAttempt = () => {
32011
32014
  response = [];
32012
32015
  pendingImages.length = 0;
32016
+ hadToolCall = false;
32017
+ finished = false;
32018
+ failure = void 0;
32013
32019
  };
32014
32020
  let reasoningStarted = false;
32015
32021
  let hadReasoningDelta = false;
32016
- let hadToolCall = false;
32022
+ const checkResponse = () => {
32023
+ if (failure !== void 0 && !hadToolCall) return fail$1(incompleteResponseError(`The model response failed: ${failure}`));
32024
+ if (!(conversationMode && !hadToolCall && mailbox.messages.size === 0 && runningChildren().length === 0 && !hasUndelivered()) || responseToSummary(response).trim() !== "") return void_;
32025
+ return fail$1(incompleteResponseError(finished ? "The model response had no text and no tool call" : "The model response ended before it finished"));
32026
+ };
32017
32027
  let retries = 0;
32018
32028
  let exhaustedBy;
32019
32029
  const retryOrExhaust = (error) => {
@@ -32071,6 +32081,8 @@ ${capOutput(turn.output ?? "").output}
32071
32081
  }
32072
32082
  break;
32073
32083
  case "finish":
32084
+ finished = true;
32085
+ if (part.reason === "error") failure ??= "finish reason error";
32074
32086
  const usage = part.usage;
32075
32087
  if (usage.outputTokens.total !== void 0) outputTokens += usage.outputTokens.total;
32076
32088
  if (usage.inputTokens.cacheRead !== void 0) cacheRead += usage.inputTokens.cacheRead;
@@ -32090,10 +32102,13 @@ ${capOutput(turn.output ?? "").output}
32090
32102
  });
32091
32103
  }
32092
32104
  break;
32093
- case "tool-call": hadToolCall = true;
32105
+ case "tool-call":
32106
+ hadToolCall = true;
32107
+ break;
32108
+ case "error": failure ??= errorMessage(part.error);
32094
32109
  }
32095
32110
  return void_;
32096
- }), modelConfig.systemPromptTransform ? (effect) => modelConfig.systemPromptTransform(system, effect) : identity);
32111
+ }), andThen(checkResponse), modelConfig.systemPromptTransform ? (effect) => modelConfig.systemPromptTransform(system, effect) : identity);
32097
32112
  const attempt = pipe$1(runModel, raceFirst(turnTimeoutEffect), retry({
32098
32113
  while(err) {
32099
32114
  if (err._tag === "TimeoutError") {
@@ -32221,6 +32236,11 @@ const turnTimeoutError = make$18({
32221
32236
  method: "send",
32222
32237
  reason: new UnknownError({ description: "TurnTimeout was reached" })
32223
32238
  });
32239
+ const incompleteResponseError = (description) => make$18({
32240
+ module: "clanka/Agent",
32241
+ method: "send",
32242
+ reason: new InternalProviderError({ description })
32243
+ });
32224
32244
  const retryPolicy = min([exponential(100, 1.5), spaced(5e3)]).pipe(jittered);
32225
32245
  const environmentUpdateOpen = "<environment-update>";
32226
32246
  const environmentUpdateMessage = (text) => make$21([{
@@ -41118,7 +41138,7 @@ const expandEntry = fnUntraced(function* (raw) {
41118
41138
  const LogToStderr = LogToStderr$1;
41119
41139
  //#endregion
41120
41140
  //#region package.json
41121
- var version$1 = "0.12.1";
41141
+ var version$1 = "0.12.2";
41122
41142
  //#endregion
41123
41143
  //#region src/cli.ts
41124
41144
  const version = version$1;