blun-king-cli 9.1.430 → 9.1.432

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.
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ function buildNoninteractiveShellEnv(parentEnv, shellPath) {
4
+ return {
5
+ ...(parentEnv ?? {}),
6
+ NO_COLOR: '1',
7
+ TERM: 'dumb',
8
+ GIT_TERMINAL_PROMPT: '0',
9
+ GIT_ASKPASS: '',
10
+ SSH_ASKPASS: '',
11
+ SSH_ASKPASS_REQUIRE: 'never',
12
+ GCM_INTERACTIVE: 'Never',
13
+ SHELL: String(shellPath ?? ''),
14
+ };
15
+ }
16
+
17
+ module.exports = {
18
+ buildNoninteractiveShellEnv,
19
+ };
package/blun.mjs CHANGED
@@ -30353,6 +30353,7 @@ async function chatWithRetry(input) {
30353
30353
  nextAttempt: attempt + 1,
30354
30354
  maxAttempts,
30355
30355
  delayMs,
30356
+ outputMayHaveStarted: input.llm.didErrorEmitPartialOutput?.(error) === true,
30356
30357
  ...retryErrorFields(error)
30357
30358
  });
30358
30359
  await sleepForRetry(delayMs, input.params.signal);
@@ -244541,6 +244542,7 @@ async function chatWithLiveResponseRepetitionRecovery(deps) {
244541
244542
  nextAttempt: 2,
244542
244543
  maxAttempts: 2,
244543
244544
  delayMs: 0,
244545
+ outputMayHaveStarted: true,
244544
244546
  errorName: "LiveResponseRepetitionError",
244545
244547
  errorMessage: "Repeated assistant text detected during streaming"
244546
244548
  });
@@ -246082,6 +246084,7 @@ var init_events$1 = __esmMin((() => {
246082
246084
  nextAttempt: number$1(),
246083
246085
  maxAttempts: number$1(),
246084
246086
  delayMs: number$1(),
246087
+ outputMayHaveStarted: boolean$1().optional(),
246085
246088
  errorName: string(),
246086
246089
  errorMessage: string(),
246087
246090
  statusCode: number$1().optional()
@@ -261463,6 +261466,7 @@ function mapLoopEvent(event, turnId) {
261463
261466
  nextAttempt: event.nextAttempt,
261464
261467
  maxAttempts: event.maxAttempts,
261465
261468
  delayMs: event.delayMs,
261469
+ outputMayHaveStarted: event.outputMayHaveStarted,
261466
261470
  errorName: event.errorName,
261467
261471
  errorMessage: event.errorMessage,
261468
261472
  statusCode: event.statusCode
@@ -263225,7 +263229,7 @@ function windowsPathToPosixPath(path) {
263225
263229
  function rewriteWindowsNullRedirect(command) {
263226
263230
  return command.replace(WINDOWS_NUL_REDIRECT, "$1/dev/null");
263227
263231
  }
263228
- var MS_PER_SECOND, DEFAULT_TIMEOUT_S, MAX_TIMEOUT_S, DEFAULT_BACKGROUND_TIMEOUT_S, MAX_BACKGROUND_TIMEOUT_S, USER_INTERRUPT_REASON, BashInputSchema, SHELL_TIMEOUT_VARS, BashTool, WINDOWS_NUL_REDIRECT, broadRecursiveSearchRefusal, windowsBashDialectRefusal;
263232
+ var MS_PER_SECOND, DEFAULT_TIMEOUT_S, MAX_TIMEOUT_S, DEFAULT_BACKGROUND_TIMEOUT_S, MAX_BACKGROUND_TIMEOUT_S, USER_INTERRUPT_REASON, BashInputSchema, SHELL_TIMEOUT_VARS, BashTool, WINDOWS_NUL_REDIRECT, broadRecursiveSearchRefusal, windowsBashDialectRefusal, buildNoninteractiveShellEnv;
263229
263233
  var init_bash = __esmMin((() => {
263230
263234
  init_zod$1();
263231
263235
  init_background();
@@ -263236,6 +263240,7 @@ var init_bash = __esmMin((() => {
263236
263240
  init_bash$1();
263237
263241
  ({ broadRecursiveSearchRefusal } = createRequire(import.meta.url)("./bin/bash-search-scope-policy.cjs"));
263238
263242
  ({ windowsBashDialectRefusal } = createRequire(import.meta.url)("./bin/windows-bash-dialect-policy.cjs"));
263243
+ ({ buildNoninteractiveShellEnv } = createRequire(import.meta.url)("./bin/noninteractive-shell-env-policy.cjs"));
263239
263244
  MS_PER_SECOND = 1e3;
263240
263245
  DEFAULT_TIMEOUT_S = 60;
263241
263246
  MAX_TIMEOUT_S = 300;
@@ -263315,16 +263320,7 @@ var init_bash = __esmMin((() => {
263315
263320
  "-c",
263316
263321
  `cd ${shellQuote(shellCwd)} && ${command}`
263317
263322
  ];
263318
- const noninteractiveEnv = {
263319
- NO_COLOR: "1",
263320
- TERM: "dumb",
263321
- GIT_TERMINAL_PROMPT: process.env["GIT_TERMINAL_PROMPT"] ?? "0",
263322
- SHELL: this.kaos.osEnv.shellPath
263323
- };
263324
- const mergedEnv = {
263325
- ...process.env,
263326
- ...noninteractiveEnv
263327
- };
263323
+ const mergedEnv = buildNoninteractiveShellEnv(process.env, this.kaos.osEnv.shellPath);
263328
263324
  return this.kaos.execWithEnv(shellArgs, mergedEnv);
263329
263325
  }
263330
263326
  async execution(args, signal, onUpdate, onForegroundTaskStart) {
@@ -265068,9 +265064,13 @@ var init_fallback_llm = __esmMin((() => {
265068
265064
  }
265069
265065
  }
265070
265066
  isRetryableError(error) {
265071
- if (typeof error === "object" && error !== null && this.errorsAfterOutput.has(error) || isAccountQuotaExhausted(error) || isFallbackCandidateError(error) || error instanceof APIContextOverflowError || isUnavailableFallbackCandidate(error)) return false;
265067
+ const outputMayHaveStarted = this.didErrorEmitPartialOutput(error);
265068
+ if (isAccountQuotaExhausted(error) || !outputMayHaveStarted && isFallbackCandidateError(error) || error instanceof APIContextOverflowError || isUnavailableFallbackCandidate(error)) return false;
265072
265069
  return this.current.llm.isRetryableError?.(error) ?? false;
265073
265070
  }
265071
+ didErrorEmitPartialOutput(error) {
265072
+ return typeof error === "object" && error !== null && this.errorsAfterOutput.has(error);
265073
+ }
265074
265074
  get current() {
265075
265075
  return this.candidates[this.currentIndex];
265076
265076
  }
@@ -496404,6 +496404,7 @@ function runPromptTurn(session, prompt, outputFormat, stdout, stderr, model) {
496404
496404
  return;
496405
496405
  case "turn.step.retrying":
496406
496406
  outputWriter.discardAssistant();
496407
+ outputWriter.writeRetry?.(formatModelRetryProgress(event), event.outputMayHaveStarted === true);
496407
496408
  return;
496408
496409
  case "assistant.delta":
496409
496410
  outputWriter.writeAssistantDelta(event.delta);
@@ -496502,7 +496503,16 @@ var PromptTranscriptWriter = class {
496502
496503
  writeToolCallDelta() {}
496503
496504
  writeToolResult() {}
496504
496505
  flushAssistant() {}
496505
- discardAssistant() {}
496506
+ discardAssistant() {
496507
+ this.assistantFilter = new ThoughtTagFilter();
496508
+ this.thinkingWriter.finish();
496509
+ this.assistantWriter.finish();
496510
+ }
496511
+ writeRetry(hint, outputMayHaveStarted) {
496512
+ if (!outputMayHaveStarted) return;
496513
+ this.thinkingWriter.write(hint);
496514
+ this.thinkingWriter.finish();
496515
+ }
496506
496516
  finish() {
496507
496517
  const { visible, thought } = this.assistantFilter.flush();
496508
496518
  if (thought.length > 0) this.thinkingWriter.write(thought);
@@ -496588,6 +496598,7 @@ var PromptJsonStreamWriter = class {
496588
496598
  discardAssistant() {
496589
496599
  this.assistantText = "";
496590
496600
  this.toolCalls.length = 0;
496601
+ this.assistantFilter = new ThoughtTagFilter();
496591
496602
  }
496592
496603
  finish() {
496593
496604
  this.assistantText += this.assistantFilter.flush().visible;
@@ -496682,6 +496693,7 @@ var PromptJsonSingleWriter = class {
496682
496693
  discardAssistant() {
496683
496694
  this.assistantText = "";
496684
496695
  this.toolCalls.length = 0;
496696
+ this.assistantFilter = new ThoughtTagFilter();
496685
496697
  }
496686
496698
  setTurnEnded(reason) {
496687
496699
  this.turnEndReason = reason;
@@ -508130,6 +508142,19 @@ var SessionEventHandler = class {
508130
508142
  handleStepRetrying(event) {
508131
508143
  this.turnWatchdog.recordProgress();
508132
508144
  const hint = formatModelRetryProgress(event);
508145
+ if (event.outputMayHaveStarted === true) {
508146
+ const { streamingUI } = this.host;
508147
+ streamingUI.flushNow();
508148
+ streamingUI.discardUnfinishedToolUi();
508149
+ streamingUI.finalizeLiveTextBuffers("idle");
508150
+ this.host.appendTranscriptEntry({
508151
+ id: nextTranscriptId(),
508152
+ kind: "status",
508153
+ turnId: String(event.turnId),
508154
+ renderMode: "plain",
508155
+ content: uiText("sessionEvent.interrupted.reason", { reason: hint })
508156
+ });
508157
+ }
508133
508158
  this.modelRetryHint = hint;
508134
508159
  this.host.state.footer.setTransientHint(hint);
508135
508160
  this.host.state.ui.requestRender();
@@ -511630,6 +511655,15 @@ var StreamingUIController = class {
511630
511655
  this._pendingReadGroup = null;
511631
511656
  this.resetToolCallState();
511632
511657
  }
511658
+ discardUnfinishedToolUi() {
511659
+ const { state } = this.host;
511660
+ const components = [...this._pendingToolComponents.values()];
511661
+ const toolCallIds = /* @__PURE__ */ new Set(this._pendingToolComponents.keys());
511662
+ this.resetToolUi();
511663
+ for (const component of components) state.transcriptContainer.removeChild(component);
511664
+ if (toolCallIds.size > 0) state.transcriptEntries = state.transcriptEntries.filter((entry) => !toolCallIds.has(entry.toolCallData?.id));
511665
+ state.ui.requestRender();
511666
+ }
511633
511667
  resetToolCallState() {
511634
511668
  this._activeToolCalls.clear();
511635
511669
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.430",
3
+ "version": "9.1.432",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {