@cydm/pie 1.0.32 → 1.0.34

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.
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createAskUserCapability
4
- } from "../../../chunks/chunk-MPZSDREV.js";
4
+ } from "../../../chunks/chunk-MGZHZSHB.js";
5
5
  import "../../../chunks/chunk-4B42ZU4B.js";
6
6
  import "../../../chunks/chunk-64XJIKVK.js";
7
7
  import "../../../chunks/chunk-TG2EQLX2.js";
@@ -7,7 +7,7 @@ import {
7
7
  isPlanModeSafeCommand,
8
8
  markCompletedPlanSteps,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-MPZSDREV.js";
10
+ } from "../../../chunks/chunk-MGZHZSHB.js";
11
11
  import "../../../chunks/chunk-4B42ZU4B.js";
12
12
  import "../../../chunks/chunk-64XJIKVK.js";
13
13
  import "../../../chunks/chunk-TG2EQLX2.js";
@@ -1,11 +1,11 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createCliHostCapabilities
4
- } from "../../../chunks/chunk-PJWPGKQK.js";
4
+ } from "../../../chunks/chunk-QXTAEPLR.js";
5
5
  import {
6
6
  createSharedFileSystemTools,
7
7
  createSubagentCapability
8
- } from "../../../chunks/chunk-MPZSDREV.js";
8
+ } from "../../../chunks/chunk-MGZHZSHB.js";
9
9
  import "../../../chunks/chunk-4B42ZU4B.js";
10
10
  import "../../../chunks/chunk-64XJIKVK.js";
11
11
  import "../../../chunks/chunk-TG2EQLX2.js";
@@ -7,7 +7,7 @@ import {
7
7
  executeManageTodoList,
8
8
  executionStateToTodos,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-MPZSDREV.js";
10
+ } from "../../../chunks/chunk-MGZHZSHB.js";
11
11
  import "../../../chunks/chunk-4B42ZU4B.js";
12
12
  import "../../../chunks/chunk-64XJIKVK.js";
13
13
  import "../../../chunks/chunk-TG2EQLX2.js";
@@ -4387,8 +4387,18 @@ function summarizeToolFailureSignature(result) {
4387
4387
  }
4388
4388
  return summary.slice(-TOOL_FAILURE_SIGNATURE_CHARS);
4389
4389
  }
4390
+ function toolOutcomeKind(event) {
4391
+ const result = event.result && typeof event.result === "object" ? event.result : void 0;
4392
+ const kind = result?.details?.outcome?.kind;
4393
+ return typeof kind === "string" ? kind : void 0;
4394
+ }
4395
+ function isCommandNonzero(event) {
4396
+ return event.toolName === "bash" && toolOutcomeKind(event) === "command_nonzero";
4397
+ }
4390
4398
  function isStateChangingSuccess(event) {
4391
4399
  if (event.isError) return false;
4400
+ const outcomeKind = toolOutcomeKind(event);
4401
+ if (outcomeKind === "command_nonzero" || outcomeKind === "timeout" || outcomeKind === "signal") return false;
4392
4402
  if (event.toolName === "edit_file" || event.toolName === "write_file") return true;
4393
4403
  const details = event.result && typeof event.result === "object" ? event.result.details : void 0;
4394
4404
  return event.toolName === "bash" && details?.commandClass === "filesystem_write";
@@ -4448,7 +4458,8 @@ var AgentSessionRuntimeGuard = class {
4448
4458
  }
4449
4459
  }
4450
4460
  recordToolExecutionEnd(event) {
4451
- if (!event.isError) {
4461
+ const commandNonzero = isCommandNonzero(event);
4462
+ if (!event.isError && !commandNonzero) {
4452
4463
  if (isStateChangingSuccess(event)) {
4453
4464
  this.repeatedToolFailures.clear();
4454
4465
  return;
@@ -4462,14 +4473,15 @@ var AgentSessionRuntimeGuard = class {
4462
4473
  return;
4463
4474
  }
4464
4475
  const resultSummary = summarizeToolFailureSignature(event.result);
4465
- const key = `${event.toolName}:${stableStringify(event.args)}:${resultSummary}`;
4476
+ const reason = commandNonzero ? "repeated_command_nonzero" : "repeated_tool_error";
4477
+ const key = `${event.toolName}:${reason}:${stableStringify(event.args)}:${resultSummary}`;
4466
4478
  const repeatCount = (this.repeatedToolFailures.get(key) ?? 0) + 1;
4467
4479
  this.repeatedToolFailures.set(key, repeatCount);
4468
4480
  if (repeatCount < 3 || this.isTriggered) {
4469
4481
  return;
4470
4482
  }
4471
4483
  this.isTriggered = true;
4472
- this.trigger(event.toolName, repeatCount, "repeated_tool_error");
4484
+ this.trigger(event.toolName, repeatCount, reason);
4473
4485
  }
4474
4486
  };
4475
4487
 
@@ -10768,7 +10780,8 @@ function summarizeToolResultDetails(result) {
10768
10780
  "costEstimate",
10769
10781
  "browserReadSummary",
10770
10782
  "guardFindings",
10771
- "timedOut"
10783
+ "timedOut",
10784
+ "outcome"
10772
10785
  ];
10773
10786
  const summary = {};
10774
10787
  for (const key of keys) {
@@ -11355,6 +11368,7 @@ var SessionTraceController = class {
11355
11368
  target.status = isError ? "failed" : "completed";
11356
11369
  target.endedAt = Date.now();
11357
11370
  target.resultSummary = summarizeToolResult(result);
11371
+ target.outcome = isRecord3(result) && isRecord3(result.details) ? result.details.outcome : void 0;
11358
11372
  if (!existing) {
11359
11373
  this.trace.activeTurn.toolCalls.push(target);
11360
11374
  }
@@ -8,7 +8,7 @@ import {
8
8
  createSharedWebSearchTool,
9
9
  interpretShellExit,
10
10
  requestInteraction
11
- } from "./chunk-MPZSDREV.js";
11
+ } from "./chunk-MGZHZSHB.js";
12
12
  import {
13
13
  Type
14
14
  } from "./chunk-64XJIKVK.js";
@@ -462,6 +462,45 @@ function buildBashRecoveryHint(command, output) {
462
462
  }
463
463
  return void 0;
464
464
  }
465
+ function classifyBashOutcome(params) {
466
+ if (params.timedOut) {
467
+ return {
468
+ kind: "timeout",
469
+ toolFailure: true,
470
+ summary: "command timed out"
471
+ };
472
+ }
473
+ if (params.exitCode === 0) {
474
+ return {
475
+ kind: "success",
476
+ toolFailure: false,
477
+ summary: "command succeeded"
478
+ };
479
+ }
480
+ if (params.exitCode !== null) {
481
+ if (!params.semanticIsError) {
482
+ return {
483
+ kind: "semantic_non_error",
484
+ toolFailure: false,
485
+ summary: params.semanticExitMeaning ?? `command exited with code ${params.exitCode}`
486
+ };
487
+ }
488
+ return {
489
+ kind: "command_nonzero",
490
+ toolFailure: false,
491
+ summary: params.semanticExitMeaning ?? `command exited with code ${params.exitCode}`
492
+ };
493
+ }
494
+ return {
495
+ kind: "signal",
496
+ toolFailure: true,
497
+ summary: params.signal ? `command terminated by signal ${params.signal}` : "command exited without a numeric status"
498
+ };
499
+ }
500
+ function formatCommandNonzeroHint(outcome) {
501
+ if (outcome.kind !== "command_nonzero") return void 0;
502
+ return `[Command outcome: ${outcome.summary}. The shell tool ran correctly; inspect this as command/test output, not as a tool malfunction.]`;
503
+ }
465
504
  function killProcessTree(pid) {
466
505
  if (process.platform === "win32") {
467
506
  try {
@@ -726,9 +765,23 @@ ${fullOutput}`;
726
765
  if (resolvedShell === "powershell" && code === 0 && /^\s*(?:diff|Compare-Object)\b/i.test(effectiveCommand) && /\bSideIndicator\b/.test(fullOutput)) {
727
766
  details.semanticExitMeaning = "files differ";
728
767
  }
768
+ const outcome = classifyBashOutcome({
769
+ exitCode: code,
770
+ signal: sig?.toString() ?? null,
771
+ timedOut,
772
+ semanticIsError: semantic.isError,
773
+ semanticExitMeaning: details.semanticExitMeaning
774
+ });
775
+ details.outcome = outcome;
729
776
  if (semantic.isError && !timedOut && fullOutput.trim().length === 0) {
730
777
  outputText += "\n\n[Empty failure hint: command exited non-zero without output. If this was a chained diagnostic, an earlier command may be missing; split the check or print explicit fallback output.]";
731
778
  }
779
+ const commandNonzeroHint = formatCommandNonzeroHint(outcome);
780
+ if (commandNonzeroHint) {
781
+ outputText += `
782
+
783
+ ${commandNonzeroHint}`;
784
+ }
732
785
  if (truncation.truncated) {
733
786
  details.truncation = {
734
787
  truncated: true,
@@ -774,7 +827,7 @@ ${fullOutput}`;
774
827
  }
775
828
  const content = [{ type: "text", text: outputText }];
776
829
  settled = true;
777
- resolve3({ content, details, isError: timedOut || semantic.isError });
830
+ resolve3({ content, details, isError: outcome.toolFailure });
778
831
  } catch (error) {
779
832
  discardOutputArtifact(tempFilePath, tempFileStream);
780
833
  settled = true;
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  getThemesDir,
20
20
  migrateConfigFromAgentDir,
21
21
  truncateHeadTail
22
- } from "./chunks/chunk-PJWPGKQK.js";
22
+ } from "./chunks/chunk-QXTAEPLR.js";
23
23
  import {
24
24
  AGENTS_CONTEXT_FILE_NAME,
25
25
  AgentSessionController,
@@ -69,7 +69,7 @@ import {
69
69
  setExtensionEnabledInSettings,
70
70
  shouldPreserveExecutionStateForUserText,
71
71
  supersedeExecutionState
72
- } from "./chunks/chunk-MPZSDREV.js";
72
+ } from "./chunks/chunk-MGZHZSHB.js";
73
73
  import "./chunks/chunk-4B42ZU4B.js";
74
74
  import {
75
75
  Deref,
@@ -54844,7 +54844,8 @@ var DEFAULT_APP_KEYBINDINGS = {
54844
54844
  toggleThinking: "ctrl+t",
54845
54845
  toggleSessionNamedFilter: "ctrl+n",
54846
54846
  externalEditor: "ctrl+g",
54847
- followUp: ["alt+enter", "ctrl+shift+enter"],
54847
+ steer: "alt+enter",
54848
+ followUp: [],
54848
54849
  dequeue: ["alt+up", "ctrl+shift+up"],
54849
54850
  pasteImage: "ctrl+v",
54850
54851
  newSession: [],
@@ -54869,6 +54870,7 @@ var APP_ACTIONS = [
54869
54870
  "toggleThinking",
54870
54871
  "toggleSessionNamedFilter",
54871
54872
  "externalEditor",
54873
+ "steer",
54872
54874
  "followUp",
54873
54875
  "dequeue",
54874
54876
  "pasteImage",
@@ -63849,7 +63851,7 @@ function handleHotkeysCommand(host) {
63849
63851
  theme.fg("muted", "Editor shortcuts:"),
63850
63852
  " Enter Submit message",
63851
63853
  " Shift+Enter New line",
63852
- ` ${theme.fg("dim", kb.getKeys("followUp").join(" / "))} ${theme.fg("muted", "Queue follow-up message")}`,
63854
+ ` ${theme.fg("dim", kb.getKeys("steer").join(" / "))} ${theme.fg("muted", "Queue steering message for the active turn")}`,
63853
63855
  ` ${theme.fg("dim", kb.getKeys("dequeue").join(" / "))} ${theme.fg("muted", "Restore queued messages")}`,
63854
63856
  " / Show slash commands",
63855
63857
  " Esc Cancel autocomplete",
@@ -66772,6 +66774,10 @@ function setupInteractiveKeybindings(host) {
66772
66774
  host.dequeueMessages();
66773
66775
  return { consume: true };
66774
66776
  }
66777
+ if (host.keybindings.matches(data, "steer")) {
66778
+ host.handleSteer();
66779
+ return { consume: true };
66780
+ }
66775
66781
  if (host.keybindings.matches(data, "followUp")) {
66776
66782
  host.handleFollowUp();
66777
66783
  return { consume: true };
@@ -66872,6 +66878,19 @@ function handleFollowUp(host) {
66872
66878
  void host.editor.onSubmit(text);
66873
66879
  }
66874
66880
  }
66881
+ function handleSteer(host) {
66882
+ const text = host.editor.getText().trim();
66883
+ if (!text) return;
66884
+ if (isCommandLikeInput(text)) {
66885
+ host.editor.onSubmit?.(text);
66886
+ return;
66887
+ }
66888
+ if (host.submitLock || (host.agentSessionController?.hasQueuedMessages ?? false)) {
66889
+ queueMessage(host, text, "steer");
66890
+ } else if (host.editor.onSubmit) {
66891
+ void host.editor.onSubmit(text);
66892
+ }
66893
+ }
66875
66894
  function truncate(text, maxLength) {
66876
66895
  if (text.length <= maxLength) return text;
66877
66896
  return text.slice(0, maxLength) + "...";
@@ -69558,6 +69577,9 @@ var InteractiveMode = class {
69558
69577
  handleFollowUp() {
69559
69578
  handleFollowUp(this);
69560
69579
  }
69580
+ handleSteer() {
69581
+ handleSteer(this);
69582
+ }
69561
69583
  restoreEditor() {
69562
69584
  return restoreEditor(this.uiHelperHost);
69563
69585
  }
@@ -70174,12 +70196,17 @@ function parseInput(line) {
70174
70196
  reason: typeof parsed.reason === "string" ? parsed.reason : void 0
70175
70197
  };
70176
70198
  }
70177
- if (parsed.type === "turn.request" && typeof parsed.turnId === "string" && typeof parsed.prompt === "string") {
70199
+ if ((parsed.type === "turn.request" || parsed.type === "turn.input") && typeof parsed.turnId === "string" && typeof parsed.prompt === "string") {
70200
+ const streamingBehavior = parsed.streamingBehavior;
70201
+ if (streamingBehavior !== void 0 && streamingBehavior !== "steer" && streamingBehavior !== "followUp") {
70202
+ return null;
70203
+ }
70178
70204
  return {
70179
70205
  type: "turn.request",
70180
70206
  sessionId: typeof parsed.sessionId === "string" ? parsed.sessionId : void 0,
70181
70207
  turnId: parsed.turnId,
70182
70208
  prompt: parsed.prompt,
70209
+ streamingBehavior,
70183
70210
  cwd: typeof parsed.cwd === "string" ? parsed.cwd : void 0,
70184
70211
  metadata: isRecord4(parsed.metadata) ? parsed.metadata : void 0
70185
70212
  };
@@ -70343,6 +70370,13 @@ async function runJsonEventsMode(params) {
70343
70370
  function delay(ms) {
70344
70371
  return new Promise((resolve5) => setTimeout(resolve5, Math.max(0, ms)));
70345
70372
  }
70373
+ async function waitForActiveController(timeoutMs = 1e3) {
70374
+ const deadline = Date.now() + timeoutMs;
70375
+ while (!controller && activeTurn && !activeTurn.finalized && Date.now() < deadline) {
70376
+ await delay(5);
70377
+ }
70378
+ return controller;
70379
+ }
70346
70380
  function touch() {
70347
70381
  if (activeTurn) {
70348
70382
  activeTurn.lastActivityAt = Date.now();
@@ -70844,12 +70878,7 @@ async function runJsonEventsMode(params) {
70844
70878
  return;
70845
70879
  }
70846
70880
  if (activeTurn && !activeTurn.finalized) {
70847
- writeEvent({
70848
- type: "turn.failed",
70849
- sessionId,
70850
- turnId: message.turnId,
70851
- error: "another turn is already running"
70852
- });
70881
+ await queueActiveTurnInput(message);
70853
70882
  return;
70854
70883
  }
70855
70884
  activeTurn = {
@@ -70974,6 +71003,55 @@ async function runJsonEventsMode(params) {
70974
71003
  if (activeTurn === turn) activeTurn = null;
70975
71004
  }
70976
71005
  }
71006
+ async function queueActiveTurnInput(message) {
71007
+ if (!message.streamingBehavior) {
71008
+ writeEvent({
71009
+ type: "turn.failed",
71010
+ sessionId,
71011
+ turnId: message.turnId,
71012
+ error: "another turn is already running; specify streamingBehavior ('steer' or 'followUp') to queue the message"
71013
+ });
71014
+ return;
71015
+ }
71016
+ const activeController = await waitForActiveController();
71017
+ if (!activeController) {
71018
+ writeEvent({
71019
+ type: "turn.failed",
71020
+ sessionId,
71021
+ turnId: message.turnId,
71022
+ error: "JSON events runtime is not ready to queue a streaming turn"
71023
+ });
71024
+ return;
71025
+ }
71026
+ try {
71027
+ applyRuntimeSelection(message);
71028
+ trace?.notePendingUserText(message.prompt);
71029
+ trace?.noteRuntimeEvent("json_events_turn_queued", {
71030
+ mode: message.streamingBehavior,
71031
+ turnId: message.turnId
71032
+ });
71033
+ await activeController.prompt(message.prompt, {
71034
+ source: "json-events",
71035
+ streamingBehavior: message.streamingBehavior,
71036
+ displayText: message.prompt,
71037
+ deliverWhileStreaming: message.streamingBehavior === "steer"
71038
+ });
71039
+ writeEvent({
71040
+ type: "turn.queued",
71041
+ sessionId,
71042
+ turnId: message.turnId,
71043
+ mode: message.streamingBehavior,
71044
+ activeTurnId: activeTurn?.turnId
71045
+ });
71046
+ } catch (error) {
71047
+ writeEvent({
71048
+ type: "turn.failed",
71049
+ sessionId,
71050
+ turnId: message.turnId,
71051
+ error: error instanceof Error ? error.message : String(error)
71052
+ });
71053
+ }
71054
+ }
70977
71055
  async function interrupt(message) {
70978
71056
  if (isSessionMismatch(message)) {
70979
71057
  writeEvent({
@@ -71098,6 +71176,7 @@ Commands:
71098
71176
  Interactive Mode Key Bindings:
71099
71177
  Enter Submit message
71100
71178
  \\ + Enter New line (fallback)
71179
+ Alt+Enter Queue steering message for the active turn
71101
71180
  Ctrl+C Exit
71102
71181
  Ctrl+D Exit
71103
71182
  Ctrl+O Expand/collapse tool output
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/pie",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "Pie AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {