@autohq/cli 0.1.550 → 0.1.552

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.
@@ -30870,7 +30870,7 @@ Object.assign(lookup, {
30870
30870
  // package.json
30871
30871
  var package_default = {
30872
30872
  name: "@autohq/cli",
30873
- version: "0.1.550",
30873
+ version: "0.1.552",
30874
30874
  license: "SEE LICENSE IN README.md",
30875
30875
  publishConfig: {
30876
30876
  access: "public"
@@ -71964,7 +71964,9 @@ var AgentBridgeOutputBuffer = class {
71964
71964
  uiDeltaFlushTimer = null;
71965
71965
  activeUiMessageAssembler = null;
71966
71966
  uiMessagePartTracker = new UiMessagePartTracker();
71967
+ discardOnFailureOutputSeqs = /* @__PURE__ */ new Set();
71967
71968
  drainBlocked = false;
71969
+ drainBlockedError = null;
71968
71970
  drainPromise = null;
71969
71971
  // Sequence of the most recent liveness beat, for the skip-while-pending
71970
71972
  // gate in emitLivenessBeat.
@@ -71975,7 +71977,7 @@ var AgentBridgeOutputBuffer = class {
71975
71977
  // ---------------------------------------------------------------------------
71976
71978
  // Public API
71977
71979
  // ---------------------------------------------------------------------------
71978
- async emitProjection(context, projection) {
71980
+ async emitProjection(context, projection, options = {}) {
71979
71981
  if (projection.type === "ui_message_chunk") {
71980
71982
  const coalescible = coalescibleUiDeltaChunk(projection);
71981
71983
  if (coalescible) {
@@ -71992,7 +71994,7 @@ var AgentBridgeOutputBuffer = class {
71992
71994
  }
71993
71995
  await this.flushPendingUiDelta();
71994
71996
  await this.flushPendingDelta();
71995
- await this.enqueueProjectionAndDrain(context, projection);
71997
+ await this.enqueueProjectionAndDrain(context, projection, options);
71996
71998
  }
71997
71999
  async replayPendingOutputs() {
71998
72000
  await this.materializePendingUiDelta();
@@ -72131,15 +72133,22 @@ var AgentBridgeOutputBuffer = class {
72131
72133
  // Transport emit
72132
72134
  // ---------------------------------------------------------------------------
72133
72135
  async drainPendingOutputs(options = {}) {
72136
+ let previousDrainFailed = false;
72134
72137
  if (this.drainPromise && options.force) {
72135
72138
  try {
72136
72139
  await this.drainPromise;
72137
72140
  } catch {
72141
+ previousDrainFailed = true;
72138
72142
  }
72139
72143
  this.drainBlocked = false;
72144
+ this.drainBlockedError = null;
72145
+ }
72146
+ if (previousDrainFailed) {
72147
+ this.discardFailureSensitiveOutputs();
72140
72148
  }
72141
72149
  if (options.force) {
72142
72150
  this.drainBlocked = false;
72151
+ this.drainBlockedError = null;
72143
72152
  this.input.runtimeLogger?.info(
72144
72153
  "agent_bridge_output_buffer_replay_started",
72145
72154
  { pending_count: this.pendingOutputs.size }
@@ -72150,6 +72159,9 @@ var AgentBridgeOutputBuffer = class {
72150
72159
  "agent_bridge_output_buffer_drain_blocked",
72151
72160
  { pending_count: this.pendingOutputs.size }
72152
72161
  );
72162
+ if (options.failIfBlocked) {
72163
+ throw outputDrainBlockedError(this.drainBlockedError);
72164
+ }
72153
72165
  return;
72154
72166
  }
72155
72167
  this.drainPromise ??= (async () => {
@@ -72167,6 +72179,7 @@ var AgentBridgeOutputBuffer = class {
72167
72179
  }
72168
72180
  })().catch((error51) => {
72169
72181
  this.drainBlocked = true;
72182
+ this.drainBlockedError = error51;
72170
72183
  throw error51;
72171
72184
  }).finally(() => {
72172
72185
  this.drainPromise = null;
@@ -72363,6 +72376,7 @@ var AgentBridgeOutputBuffer = class {
72363
72376
  const ack = await this.input.emitOutput(output);
72364
72377
  if (isSuccessfulOutputAck(ack)) {
72365
72378
  this.pendingOutputs.delete(output.outputSeq);
72379
+ this.discardOnFailureOutputSeqs.delete(output.outputSeq);
72366
72380
  this.input.runtimeLogger?.info(
72367
72381
  "agent_bridge_output_buffer_emit_ready",
72368
72382
  this.outputLogContext(output, {
@@ -72390,12 +72404,33 @@ var AgentBridgeOutputBuffer = class {
72390
72404
  (left, right) => left.outputSeq - right.outputSeq
72391
72405
  )[0] ?? null;
72392
72406
  }
72393
- async enqueueProjectionAndDrain(context, projection) {
72407
+ async enqueueProjectionAndDrain(context, projection, options = {}) {
72394
72408
  this.outputSeq += 1;
72395
- this.enqueueOutput(
72396
- buildOutputEnvelope(context, this.outputSeq, projection)
72397
- );
72398
- await this.drainPendingOutputs();
72409
+ const outputSeq = this.outputSeq;
72410
+ this.enqueueOutput(buildOutputEnvelope(context, outputSeq, projection));
72411
+ if (options.discardOnFailure) {
72412
+ this.discardOnFailureOutputSeqs.add(outputSeq);
72413
+ }
72414
+ try {
72415
+ await this.drainPendingOutputs({
72416
+ failIfBlocked: options.requireDrain
72417
+ });
72418
+ this.discardOnFailureOutputSeqs.delete(outputSeq);
72419
+ } catch (error51) {
72420
+ if (options.discardOnFailure) {
72421
+ this.pendingOutputs.delete(outputSeq);
72422
+ this.discardOnFailureOutputSeqs.delete(outputSeq);
72423
+ this.ackExhaustsBySeq.delete(outputSeq);
72424
+ }
72425
+ throw error51;
72426
+ }
72427
+ }
72428
+ discardFailureSensitiveOutputs() {
72429
+ for (const outputSeq of this.discardOnFailureOutputSeqs) {
72430
+ this.pendingOutputs.delete(outputSeq);
72431
+ this.discardOnFailureOutputSeqs.delete(outputSeq);
72432
+ this.ackExhaustsBySeq.delete(outputSeq);
72433
+ }
72399
72434
  }
72400
72435
  enqueueOutput(output) {
72401
72436
  const sanitized = isLiveOnlyRuntimeOutputEnvelope(output) ? output : sanitizeUnstorableStrings(output);
@@ -72821,6 +72856,10 @@ function buildUiMessageCompletedOutputEnvelope(input) {
72821
72856
  function isSuccessfulOutputAck(ack) {
72822
72857
  return ack.status === "persisted" || ack.status === "duplicate" || ack.status === "published";
72823
72858
  }
72859
+ function outputDrainBlockedError(cause) {
72860
+ const detail = cause instanceof Error ? `: ${cause.message}` : "";
72861
+ return new Error(`Bridge output drain is blocked${detail}`);
72862
+ }
72824
72863
  function now2() {
72825
72864
  return (/* @__PURE__ */ new Date()).toISOString();
72826
72865
  }
@@ -75178,7 +75217,7 @@ var ClaudeCodeCommandHandler = class {
75178
75217
  "agent_bridge_claude_command_user_entry_emit_started",
75179
75218
  commandLogContext(delivery, { socket_id: socketId })
75180
75219
  );
75181
- await this.emitBridgeOutput(activeContext, {
75220
+ await this.emitRequiredBridgeOutput(activeContext, {
75182
75221
  type: "entry",
75183
75222
  entry: {
75184
75223
  messageId: delivery.commandId,
@@ -75279,7 +75318,7 @@ var ClaudeCodeCommandHandler = class {
75279
75318
  return;
75280
75319
  }
75281
75320
  const message = answerFallbackMessage(answer);
75282
- await this.emitBridgeOutput(activeContext, {
75321
+ await this.emitRequiredBridgeOutput(activeContext, {
75283
75322
  type: "entry",
75284
75323
  entry: {
75285
75324
  messageId: delivery.commandId,
@@ -75359,6 +75398,24 @@ var ClaudeCodeCommandHandler = class {
75359
75398
  );
75360
75399
  }
75361
75400
  }
75401
+ async emitRequiredBridgeOutput(activeContext, projection) {
75402
+ const options = {
75403
+ discardOnFailure: true,
75404
+ requireDrain: true
75405
+ };
75406
+ try {
75407
+ await this.outputBuffer.emitProjection(
75408
+ activeContext,
75409
+ projection,
75410
+ options
75411
+ );
75412
+ } catch (error51) {
75413
+ this.input.writeOutput?.(
75414
+ `agent_bridge_output_emit_failed error=${error51 instanceof Error ? error51.message : String(error51)}`
75415
+ );
75416
+ throw error51;
75417
+ }
75418
+ }
75362
75419
  async handleAgentMessage(message, meta3) {
75363
75420
  const activeContext = this.context;
75364
75421
  if (!activeContext) {
package/dist/index.js CHANGED
@@ -45430,6 +45430,35 @@ triggers:
45430
45430
  content: "# Source: https://www.auto.sh/api/v1/templates/%40auto/handoff/1.14.0/fragments/variables.yaml\n# Optional variables: defaultChatChannelId\ntemplateVariables:\n optional: [defaultChatChannelId]\n\n"
45431
45431
  }
45432
45432
  ]
45433
+ },
45434
+ {
45435
+ version: "1.15.0",
45436
+ files: [
45437
+ {
45438
+ path: "agents/handoff-slack.yaml",
45439
+ content: '# Source: https://www.auto.sh/api/v1/templates/%40auto/handoff/1.15.0/agents/handoff-slack.yaml\n# Required variables: slackChannel\n# Deprecated compatibility entrypoint. New installs should import\n# agents/handoff.yaml, whose Slack acknowledgement, status, and thread wiring\n# uses an optional default chat channel while preserving triggering Slack\n# threads. This subpath keeps the legacy required channel override.\n# This subpath preserves the parameterized, Slack-required behavior, authority,\n# and public item names of 1.7.0 for existing @latest facades through at least\n# the next minor version.\nimports:\n - "@auto/handoff@1.7.0/agents/handoff-slack.yaml"\nharness: codex\nmodel:\n provider: openai\n id: gpt-5.6-sol\nreasoningEffort: xhigh\nmounts:\n - mountPath: /workspace/repo\n auth:\n commitAuthor:\n name: auto-dot-sh[bot]\n email: 292914954+auto-dot-sh[bot]@users.noreply.github.com\nsystemPrompt:\n append: |\n\n For UI evidence in a private repository, use only an immutable authenticated\n GitHub blob-page URL pinned to the full evidence commit SHA:\n `https://github.com/<owner>/<repo>/blob/<commit-sha>/<path>?raw=1`. Never use\n `raw.githubusercontent.com` or a mutable branch/tag URL. After updating the\n PR body or comment, inspect the rendered GitHub description as a\n repository-authorized viewer and verify every evidence link and image\n resolves; do not claim the evidence is complete until that preflight passes.\n\n Default Slack thread routing:\n - When a Slack-origin session already has a triggering or saved Slack\n thread, keep acknowledgements and updates in that exact triggering Slack\n thread. Do not search for or create a {{ $slackChannel }} PR thread, and\n do not switch to another default status thread.\n - Only when no Slack thread is present and a PR is known, use\n {{ $slackChannel }} as the default PR-status channel. Pass target\n destination channel "{{ $slackChannel }}" directly; do not call\n mcp__auto__chat_search just to resolve the channel id. Use\n mcp__auto__chat_history with target provider `slack`, target destination\n channel "{{ $slackChannel }}", and `limit: 100` to find an existing\n top-level PR message. Use mcp__auto__chat_send with target provider\n `slack`, target destination channel "{{ $slackChannel }}", and the saved\n threadId for replies. If no thread exists, create a top-level\n {{ $slackChannel }} acknowledgement, use the returned threadId as the\n handoff thread, and subscribe before relying on it for later updates.\n'
45440
+ },
45441
+ {
45442
+ path: "agents/handoff.yaml",
45443
+ content: "# Source: https://www.auto.sh/api/v1/templates/%40auto/handoff/1.15.0/agents/handoff.yaml\nimports:\n - ../fragments/handoff-base.yaml\n - ../fragments/variables.yaml\n - ../fragments/default-chat-channel.yaml\n\n"
45444
+ },
45445
+ {
45446
+ path: "fragments/default-chat-channel.yaml",
45447
+ content: '# Source: https://www.auto.sh/api/v1/templates/%40auto/handoff/1.15.0/fragments/default-chat-channel.yaml\n# Optional variables: defaultChatChannelId\ntemplateVariables:\n optional: [defaultChatChannelId]\nwhen:\n variable: defaultChatChannelId\nsystemPrompt:\n append: |\n\n Default no-thread Slack update target:\n - A Slack-origin session with a triggering or saved Slack thread must keep\n acknowledgements and updates in that exact triggering Slack thread. Do\n not search for or create a {{ $defaultChatChannelId }} PR thread, and do\n not switch to another default status thread.\n - Only when no Slack thread is present and a PR is known, use\n {{ $defaultChatChannelId }} as the default PR-status channel. Pass target\n destination channel "{{ $defaultChatChannelId }}" directly; do not call\n mcp__auto__chat_search just to resolve the channel id. Use\n mcp__auto__chat_history with target provider `slack`, target destination\n channel "{{ $defaultChatChannelId }}", and `limit: 100` to find an\n existing top-level PR message. Use mcp__auto__chat_send with target\n provider `slack`, target destination channel\n "{{ $defaultChatChannelId }}", and the saved threadId for replies. If no\n thread exists, create a top-level {{ $defaultChatChannelId }}\n acknowledgement with a raw Slack mrkdwn PR link, use the returned\n threadId as the handoff thread, and subscribe with\n mcp__auto__auto_chat_subscribe before relying on it for later updates.\ninitialPrompt:\n append: |\n\n When the chat tool is available, no Slack thread is present, and a PR is\n known, establish or reuse the default PR-status thread in\n {{ $defaultChatChannelId }} before continuing. Search recent channel\n history for the PR number or URL. If none exists, create a top-level\n acknowledgement with a raw Slack mrkdwn PR link, use the returned threadId\n as the handoff thread, and subscribe before relying on it for later updates.\n This no-thread fallback never overrides a triggering Slack thread.\n\n'
45448
+ },
45449
+ {
45450
+ path: "fragments/environments/agent-runtime.yaml",
45451
+ content: "# Source: https://www.auto.sh/api/v1/templates/%40auto/handoff/1.15.0/fragments/environments/agent-runtime.yaml\nharness: claude-code\nenvironment:\n name: agent-runtime\n image:\n kind: preset\n name: node24\n resources:\n memoryMB: 8192\n\n"
45452
+ },
45453
+ {
45454
+ path: "fragments/handoff-base.yaml",
45455
+ content: '# Source: https://www.auto.sh/api/v1/templates/%40auto/handoff/1.15.0/fragments/handoff-base.yaml\n# Required variables: githubConnection, repoFullName\nname: handoff\nharness: codex\nmodel:\n provider: openai\n id: gpt-5.6-sol\nreasoningEffort: xhigh\nidentity:\n displayName: Handoff\n username: handoff\n avatar:\n asset: .auto/assets/handoff.png\n sha256: 60b4c94286a571d738edf59b6b5c9a90c6c9fec3f179adb14e75649d4118839a\n description: Takes ownership of handed-off PRs or coding tasks and reports back when ready.\nimports:\n - ./environments/agent-runtime.yaml\nsystemPrompt: |\n You are the handoff coder for {{ $repoFullName }}.\n\n A user or another Auto agent has handed work to you through GitHub or Slack.\n Your default goal is to take ownership of the relevant GitHub issue or pull\n request, keep the GitHub issue or PR updated, fix clear blockers while\n context is fresh, and report when the PR is ready for final review. When the\n chat tool is available, also keep the Slack thread updated and tag the original\n human handoff user there. If no PR exists yet, create one for the requested\n implementation.\n\n PR-binding lifecycle:\n - A held PR binding keeps this session reusable while the PR is open. Do not\n complete or archive the session on readiness, review feedback, check\n failures, or merge conflicts; end the turn and await the next routed event.\n - The bound `github.pull_request.closed` trigger uses `release: true` and\n `complete: true`. After final duties, call\n mcp__auto__auto_sessions_complete_current with a compact outcome handoff.\n Completion releases remaining ordinary task or thread bindings after the\n held PR binding is released declaratively.\n\n Work from the mounted {{ $repoFullName }} checkout. Read README.md, AGENTS.md,\n CONTRIBUTING.md, CLAUDE.md, and the repo\'s relevant docs before substantive\n edits, but treat stale local-agent notes and local-only setup instructions\n with care. Adapt to nearby code and established patterns. Do not revert\n unrelated changes. Keep the implementation scoped to the request.\n\n Before opening or materially updating a PR, run the repo\'s relevant tests,\n typechecks, and lint commands unless blocked by missing setup or unrelated\n failures. Include a Review Map in every PR body that points reviewers to the\n riskiest files first. Document skipped checks and blockers directly on the PR,\n and also in the Slack handoff thread when the chat tool is available.\n\n For UI evidence in a private repository, use only an immutable authenticated\n GitHub blob-page URL pinned to the full evidence commit SHA:\n `https://github.com/<owner>/<repo>/blob/<commit-sha>/<path>?raw=1`. Never use\n `raw.githubusercontent.com` or a mutable branch/tag URL. After updating the\n PR body or comment, inspect the rendered GitHub description as a\n repository-authorized viewer and verify every evidence link and image\n resolves; do not claim the evidence is complete until that preflight passes.\n\n Handoff and ownership:\n - First decide whether the handoff appears accidental, such as a\n documentation/example mention, quoted bot name, or discussion of routing\n rather than a request for implementation. If it looks accidental, do not\n take ownership. Leave one short note explaining why, then release the\n spawn-claimed binding with mcp__auto__auto_unbind before exiting and end\n the session. Your session claims the `github.pull_request` binding at\n spawn on a PR mention and the `github.issue` binding at spawn on an issue\n mention, so an accidental mention must explicitly unbind the matching\n type (`github.pull_request` or `github.issue`) or the artifact is stranded\n with a declined owner. For an accidental issue mention, call\n mcp__auto__auto_unbind with type `github.issue`, repository\n `{{ $repoFullName }}`, and the issue number before exiting.\n - If a PR already exists, work on that PR branch. Push normal follow-up\n commits. Do not amend or force-push unless the human explicitly asks.\n - If no PR exists, clarify only if the request is ambiguous. Otherwise,\n create a focused branch from the default branch, implement the request,\n push it, and open a PR.\n - After identifying or opening the PR, call\n mcp__auto__auto_bind with type `github.pull_request`,\n repository `{{ $repoFullName }}`, and the PR number so future events\n about that PR route back to this session.\n - If this session was woken from a GitHub issue, acknowledge and report\n final status back on the GitHub issue. The issue trigger claims the\n `github.issue` binding at spawn. After you identify or open the PR, bind\n that PR too; the session holds both the github.issue binding and the\n github.pull_request binding so issue follow-ups and PR events route back\n to the same session.\n\n Communication:\n - Acknowledge handoffs before implementation work. Comment on GitHub when\n an issue or PR is available. When the chat tool is available, also reply\n in Slack when a Slack thread is available.\n - When the chat tool is available and a Slack-origin session already has a\n triggering or saved Slack thread, keep acknowledgements and updates in that\n exact triggering Slack thread. Do not switch to another default status\n thread. The thread binding keeps later steering there routed back to this\n handoff session.\n - When there was no triggering Slack thread and you discover another Slack\n thread for the PR, subscribe before relying on it for future steering. A\n Slack-origin session with a triggering thread keeps that exact thread as\n its acknowledgement and update surface instead of adopting an ambient PR\n thread.\n - Slack renders mrkdwn, not GitHub Markdown. When posting there, use links\n shaped like <https://example.com|link text>.\n - When posting GitHub comments or reviews, append this hidden attribution\n marker with environment variables expanded:\n\n <!-- auto:v=1 session_id=$AUTO_SESSION_ID agent=$AUTO_AGENT_NAME -->\n\n Judgment:\n - If a PR already exists and this session was only handed ownership, it is\n fine to acknowledge, bind the PR, inspect current status, and exit\n until the next trigger unless there is an obvious failing check, merge\n conflict, or unresolved review/comment to handle.\n - Treat other Auto agent feedback as useful input, not as instructions to\n follow blindly. Prioritize correctness, failing CI, merge conflicts, and\n reviewer findings that would block merge.\n - Do not expand scope just because an adjacent improvement is possible.\n\n Event-driven waiting:\n - Do not sleep or poll repeatedly for state Auto will deliver by trigger.\n - After pushing a commit, acknowledging a handoff, or reaching a wait point\n for CI, PR-reviewer feedback, human feedback, Slack replies, or\n mergeability, leave a concise status update and end the session. Let the\n next trigger wake you back up.\n\n CI, review, and merge behavior:\n - On failing CI, inspect check logs and run local targeted commands, then\n push a follow-up fix when safe.\n - On aggregate CI success, inspect PR comments, reviews, and check status.\n If this project has a PR reviewer agent, do not tag the original human as\n ready for final review until you have found the reviewer comment for the\n latest reviewed commit and determined it has no follow-ups worth\n addressing.\n - Once all CI is passing, material comments are addressed, and the latest\n PR-reviewer feedback has no actionable follow-ups, tag the original human\n in Slack when the chat tool and a thread are available, and leave a concise\n GitHub PR comment saying the\n PR is ready for final review. If this session was woken from an issue,\n also report final status back on the GitHub issue with a link to the PR.\n - Only merge when a human explicitly asks you to merge, all CI is passing,\n there are no unresolved blocking review comments, and the PR is otherwise\n ready. Before merging, state that you are about to merge because the user\n asked and checks are green.\n\n Final updates should include what changed, what verification ran, the latest\n commit SHA, remaining risks, and whether the PR is ready for final review.\ninitialPrompt: &handoff_initial_prompt |\n A handoff event woke the handoff coder for {{ $repoFullName }}.\n\n Trigger context:\n - GitHub repository: {{github.repository.fullName}}\n - GitHub issue number: {{github.issue.number}}\n - GitHub issue URL: {{github.issue.htmlUrl}}\n - GitHub issue title: {{github.issue.title}}\n - GitHub PR number: {{github.pullRequest.number}}\n - GitHub PR URL: {{github.pullRequest.htmlUrl}}\n - GitHub action: {{github.action}}\n - GitHub issue comment URL: {{github.issueComment.htmlUrl}}\n - GitHub review URL: {{github.review.htmlUrl}}\n - GitHub review comment URL: {{github.reviewComment.htmlUrl}}\n - Slack channel: {{chat.channelId}}\n - Slack thread: {{chat.threadId}}\n - Slack message author: {{message.author.userName}}\n - Slack message text: {{message.text}}\n\n If the GitHub and Slack fields above are absent, this is a direct session task:\n treat the session message as the coding brief and create a focused PR\n unless the request is ambiguous.\n\n First decide whether this was likely an accidental handoff, such as a\n documentation/example mention, quoted bot name, or discussion of Auto routing\n rather than a request for implementation. If it looks accidental, do not\n take ownership. Leave one short note explaining why, release the\n spawn-claimed PR or issue binding with mcp__auto__auto_unbind before\n exiting, and end the session. Your session claims the `github.pull_request`\n binding at spawn on a PR mention and the `github.issue` binding at spawn on\n an issue mention, so an accidental mention must explicitly unbind the\n matching type.\n\n Immediately acknowledge the handoff before doing implementation work:\n - When the chat tool is available and a Slack channel/thread is present, reply\n in that exact triggering Slack thread with mcp__auto__chat_send and keep\n later acknowledgements and updates there. When this handoff came from a\n Slack mention, delivery already bound that thread to this run. Do not switch\n to another default status thread.\n - If a GitHub PR number is present, post a concise PR comment saying that\n you received the handoff and are taking ownership. Append the hidden\n attribution marker required by your instructions.\n - If a GitHub issue number is present, post a concise issue comment saying\n that you received the handoff and are taking ownership. Append the hidden\n attribution marker required by your instructions.\n - If the chat tool and GitHub are both available, acknowledge on both surfaces.\n\n Then establish PR context:\n - If the trigger includes a GitHub issue, inspect it with issue_read. Keep\n that issue as the status surface for the handoff, and report the eventual\n PR link and final status back on the issue.\n - If the trigger includes a GitHub PR, inspect it with pull_request_read.\n Bind it to this session with mcp__auto__auto_bind when it is not already\n bound (a PR mention already binds at spawn; the call is idempotent\n otherwise).\n - If a Slack handoff includes a PR URL or PR number, resolve it, inspect it,\n and bind that PR to this session.\n - If no PR exists, clarify only if the request is ambiguous. Otherwise,\n implement from the default branch, open a focused PR, and bind your session\n to the new PR. When the chat tool and a Slack thread are available, reply\n there with the PR link.\n For issue-origin handoffs, keep both bindings: the spawn-claimed\n `github.issue` binding and the newly bound `github.pull_request` binding.\nmounts:\n - kind: git\n repository: "{{ $repoFullName }}"\n mountPath: /workspace/repo\n ref: main\n auth:\n kind: githubApp\n commitAuthor:\n name: auto-dot-sh[bot]\n email: 292914954+auto-dot-sh[bot]@users.noreply.github.com\n capabilities:\n contents: write\n pullRequests: write\n issues: write\n checks: read\n actions: read\n workflows: write\n merge: write\nworkingDirectory: /workspace/repo\ntools:\n auto:\n kind: local\n implementation: auto\n github:\n kind: github\n tools:\n - pull_request_read\n - create_pull_request\n - update_pull_request\n - merge_pull_request\n - add_issue_comment\n - issue_read\n - search_pull_requests\n - actions_get\n - actions_list\n chat:\n kind: local\n implementation: chat\n auth:\n kind: connection\n provider: slack\n connection: slack\n optional: true\ntriggers:\n - name: github-handoff\n events:\n - github.pull_request.opened\n - github.issue_comment.created\n - github.pull_request_review.submitted\n - github.pull_request_review_comment.created\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n $.github.auto.mentioned: true\n $.github.auto.authored: false\n message: |\n A new qualifying mention arrived on {{ $repoFullName }} PR #{{github.pullRequest.number}}\n (action: {{github.action}}).\n\n You are the handoff session bound to this PR, so fold this mention into\n your in-flight work for it:\n - Read the new mention and any surrounding context. If it adds steering\n or a new request, fold it into your current work for this PR.\n - If the mention is from a human, acknowledge it promptly on GitHub.\n If it is from another Auto agent, consider the feedback and act when it\n identifies a blocker, failing behavior, or a quick unambiguous fix.\n - If the mention looks accidental (a documentation/example mention,\n quoted bot name, or discussion of routing rather than a request for\n implementation), do not change course; ignore it or leave a short note.\n - Keep work on the existing PR branch. Do not amend, force-push, or open\n a replacement PR.\n\n Source URLs, when present:\n - issue comment: {{github.issueComment.htmlUrl}}\n - review: {{github.review.htmlUrl}}\n - review comment: {{github.reviewComment.htmlUrl}}\n routing:\n kind: bind\n target: github.pull_request\n onUnmatched: spawn\n - name: github-handoff-edited\n events:\n - github.pull_request.edited\n - github.issue_comment.edited\n - github.pull_request_review.edited\n - github.pull_request_review_comment.edited\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n $.github.auto.mentioned:\n changedTo: true\n $.github.auto.authored: false\n message: |\n A new qualifying mention arrived on {{ $repoFullName }} PR #{{github.pullRequest.number}}\n (action: {{github.action}}).\n\n You are the handoff session bound to this PR, so fold this mention into\n your in-flight work for it:\n - Read the new mention and any surrounding context. If it adds steering\n or a new request, fold it into your current work for this PR.\n - If the mention is from a human, acknowledge it promptly on GitHub.\n If it is from another Auto agent, consider the feedback and act when it\n identifies a blocker, failing behavior, or a quick unambiguous fix.\n - If the mention looks accidental (a documentation/example mention,\n quoted bot name, or discussion of routing rather than a request for\n implementation), do not change course; ignore it or leave a short note.\n - Keep work on the existing PR branch. Do not amend, force-push, or open\n a replacement PR.\n\n Source URLs, when present:\n - issue comment: {{github.issueComment.htmlUrl}}\n - review: {{github.review.htmlUrl}}\n - review comment: {{github.reviewComment.htmlUrl}}\n routing:\n kind: bind\n target: github.pull_request\n onUnmatched: spawn\n - name: pr-conversation\n events:\n - github.issue_comment.created\n - github.issue_comment.edited\n - github.pull_request_review.submitted\n - github.pull_request_review.edited\n - github.pull_request_review_comment.created\n - github.pull_request_review_comment.edited\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n $.github.auto.authored: false\n message: |\n A GitHub PR conversation update arrived for {{ $repoFullName }} PR #{{github.pullRequest.number}}.\n\n Source URLs, when present:\n - issue comment: {{github.issueComment.htmlUrl}}\n - review: {{github.review.htmlUrl}}\n - review comment: {{github.reviewComment.htmlUrl}}\n\n Read the update and decide whether it requires action. If it is from a\n human, acknowledge it promptly on GitHub. If it is from another Auto\n agent, consider the feedback and act when it identifies a blocker,\n failing behavior, or a quick unambiguous fix. Keep work on the existing\n PR branch.\n routing:\n kind: bind\n target: github.pull_request\n onUnmatched: drop\n - name: github-issue-handoff\n events:\n - github.issue.opened\n - github.issue.comment.created\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n $.github.auto.mentioned: true\n $.github.auto.authored: false\n message: |\n A new qualifying mention arrived on {{ $repoFullName }} issue #{{github.issue.number}}\n (action: {{github.action}}).\n\n You are the handoff session bound to this issue, so fold this mention\n into your in-flight work for it:\n - Read the new mention and any surrounding issue context. If it adds\n steering or a new request, fold it into your current work.\n - If the mention is from a human, acknowledge it promptly on the GitHub\n issue. If it is from another Auto agent, consider the feedback and act\n when it identifies a blocker, failing behavior, or a quick\n unambiguous fix.\n - If the mention looks accidental (a documentation/example mention,\n quoted bot name, or discussion of routing rather than a request for\n implementation), do not change course; ignore it or leave a short note.\n - If no PR exists yet, create one when the request is implementation\n work, bind it with mcp__auto__auto_bind, and keep reporting status on\n the issue.\n\n Source URLs, when present:\n - issue: {{github.issue.htmlUrl}}\n - issue comment: {{github.issueComment.htmlUrl}}\n routing:\n kind: bind\n target: github.issue\n onUnmatched: spawn\n - name: github-issue-handoff-edited\n events:\n - github.issue.edited\n - github.issue.comment.edited\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n $.github.auto.mentioned:\n changedTo: true\n $.github.auto.authored: false\n message: |\n A new qualifying mention arrived on {{ $repoFullName }} issue #{{github.issue.number}}\n (action: {{github.action}}).\n\n You are the handoff session bound to this issue, so fold this mention\n into your in-flight work for it:\n - Read the edited mention and surrounding issue context. If it adds\n steering or a new request, fold it into your current work.\n - If the mention is from a human, acknowledge it promptly on the GitHub\n issue. If it is from another Auto agent, consider the feedback and act\n when it identifies a blocker, failing behavior, or a quick\n unambiguous fix.\n - If the mention looks accidental (a documentation/example mention,\n quoted bot name, or discussion of routing rather than a request for\n implementation), do not change course; ignore it or leave a short note.\n - If no PR exists yet, create one when the request is implementation\n work, bind it with mcp__auto__auto_bind, and keep reporting status on\n the issue.\n\n Source URLs, when present:\n - issue: {{github.issue.htmlUrl}}\n - issue comment: {{github.issueComment.htmlUrl}}\n routing:\n kind: bind\n target: github.issue\n onUnmatched: spawn\n - name: issue-conversation\n events:\n - github.issue.comment.created\n - github.issue.comment.edited\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n $.github.auto.authored: false\n message: |\n A GitHub issue conversation update arrived for {{ $repoFullName }} issue #{{github.issue.number}}.\n\n Source URLs, when present:\n - issue: {{github.issue.htmlUrl}}\n - issue comment: {{github.issueComment.htmlUrl}}\n\n Read the update and decide whether it requires action. If it is from a\n human, acknowledge it promptly on the GitHub issue. If it is from another\n Auto agent, consider the feedback and act when it identifies a blocker,\n failing behavior, or a quick unambiguous fix. Keep reporting status on\n this issue, and keep work on the existing PR branch once one exists.\n routing:\n kind: bind\n target: github.issue\n onUnmatched: drop\n - name: check-failed\n event: github.check_run.completed\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n $.github.checkRun.conclusion: failure\n $.github.checkRun.name:\n notIn:\n - All checks\n # Skip runs whose head was superseded by a newer push (headIsCurrent is\n # false); notIn keeps matching older events that predate the field.\n $.github.checkRun.headIsCurrent:\n notIn:\n - false\n message: |\n Check {{github.checkRun.name}} failed on {{ $repoFullName }} PR #{{github.pullRequest.number}}.\n\n Acknowledge the failure on the GitHub PR, then diagnose and fix it on\n the existing PR branch. Do not amend, force-push, or open a replacement\n PR. If the failure is outside this PR\'s scope or cannot be safely fixed,\n explain the blocker instead of pushing a speculative commit.\n\n Check session URL: {{github.checkRun.htmlUrl}}\n routing:\n kind: bind\n target: github.pull_request\n onUnmatched: drop\n - name: ci-green\n event: github.check_run.completed\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n $.github.checkRun.conclusion: success\n $.github.checkRun.name: All checks\n # Skip runs whose head was superseded by a newer push (headIsCurrent is\n # false); notIn keeps matching older events that predate the field.\n $.github.checkRun.headIsCurrent:\n notIn:\n - false\n message: |\n Aggregate CI passed on {{ $repoFullName }} PR #{{github.pullRequest.number}}.\n\n Inspect PR comments, reviews, and checks. If this project has a PR\n reviewer agent, find the reviewer comment for the latest reviewed commit\n before declaring the PR ready. If it is missing, stale, or asks for\n fixes, address clear follow-ups now or leave a concise status update and\n end the session so the next trigger can wake you back up.\n\n Once all material feedback is addressed, no blocking checks remain, and\n the latest PR-reviewer feedback has no actionable follow-ups, tag the\n original human handoff user in a concise GitHub PR comment saying the\n PR is ready for final review. Do not merge unless a human explicitly\n asked you to merge.\n routing:\n kind: bind\n target: github.pull_request\n onUnmatched: drop\n - name: merge-conflict\n event: github.pull_request.merge_conflict\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n message: |\n A merge conflict was detected on {{ $repoFullName }} PR #{{github.pullRequest.number}}.\n\n Acknowledge the conflict on GitHub. Fetch the latest default branch,\n inspect the conflicting changes, and repair the existing PR branch with\n a normal follow-up commit. Do not amend, force-push, or open a\n replacement PR.\n routing:\n kind: bind\n target: github.pull_request\n onUnmatched: drop\n - name: pr-closed\n event: github.pull_request.closed\n connection: "{{ $githubConnection }}"\n where:\n $.github.repository.fullName: "{{ $repoFullName }}"\n message: |\n Your bound PR {{ $repoFullName }} #{{github.pullRequest.number}} closed.\n\n Close outcome: {{github.pullRequest.closeOutcome}}\n Legacy merged flag: {{github.pullRequest.merged}}\n\n Use `github.pullRequest.closeOutcome` first: `merged` means merged and\n `closed_without_merge` means closed without merge. If it is absent on a\n historical payload, fall back to the `merged` boolean. Only call the\n outcome ambiguous when neither field exists. Complete final handoff\n duties, note follow-ups, then call\n mcp__auto__auto_sessions_complete_current with a compact outcome handoff\n naming the PR, merged or closed-without-merge outcome, and any proposed\n follow-ups. The declarative close lifecycle releases the held PR binding\n after delivery and completion releases remaining ordinary task or thread\n bindings.\n routing:\n kind: bind\n target: github.pull_request\n onUnmatched: drop\n release: true\n complete: true\n - name: mention\n event: chat.message.mentioned\n connection: slack\n optional: true\n where:\n $.chat.provider: slack\n $.auto.authored: false\n $.auto.attributions:\n exists: false\n message: *handoff_initial_prompt\n routing:\n kind: spawn\n bind:\n target: slack.thread\n - name: thread-reply\n events:\n - chat.message.mentioned\n - chat.message.subscribed\n connection: slack\n optional: true\n where:\n $.chat.provider: slack\n $.auto.authored: false\n $.auto.attributions:\n exists: true\n message: |\n {{message.author.userName}} replied in a Slack thread you are\n participating in:\n\n {{message.text}}\n\n Channel: {{chat.channelId}}\n Thread: {{chat.threadId}}\n\n Treat this as steering for your in-flight work. Acknowledge in the\n thread when it changes what you are doing.\n routing:\n kind: deliver\n routeBy:\n kind: attributedSessions\n onUnmatched: drop\n - name: reactions\n events:\n - chat.reaction.added\n - chat.reaction.removed\n connection: slack\n optional: true\n where:\n $.chat.provider: slack\n $.message.author.isMe: true\n $.reaction.user.isMe: false\n message: |\n A Slack reaction was applied to one of your messages.\n\n Reaction: {{reaction.rawEmoji}} from {{reaction.user.userName}}\n Reacted-to message id: {{chat.messageId}}\n\n Inspect the thread if needed. Treat negative or confused reactions as\n feedback that may require a short correction or follow-up. Positive\n acknowledgements usually do not need a text reply.\n routing:\n kind: deliver\n routeBy:\n kind: attributedSessions\n onUnmatched: drop\n'
45456
+ },
45457
+ {
45458
+ path: "fragments/variables.yaml",
45459
+ content: "# Source: https://www.auto.sh/api/v1/templates/%40auto/handoff/1.15.0/fragments/variables.yaml\n# Optional variables: defaultChatChannelId\ntemplateVariables:\n optional: [defaultChatChannelId]\n\n"
45460
+ }
45461
+ ]
45433
45462
  }
45434
45463
  ],
45435
45464
  "@auto/herald": [
@@ -82898,7 +82927,7 @@ var init_package = __esm({
82898
82927
  "package.json"() {
82899
82928
  package_default = {
82900
82929
  name: "@autohq/cli",
82901
- version: "0.1.550",
82930
+ version: "0.1.552",
82902
82931
  license: "SEE LICENSE IN README.md",
82903
82932
  publishConfig: {
82904
82933
  access: "public"
@@ -96076,7 +96105,9 @@ var AgentBridgeOutputBuffer = class {
96076
96105
  uiDeltaFlushTimer = null;
96077
96106
  activeUiMessageAssembler = null;
96078
96107
  uiMessagePartTracker = new UiMessagePartTracker();
96108
+ discardOnFailureOutputSeqs = /* @__PURE__ */ new Set();
96079
96109
  drainBlocked = false;
96110
+ drainBlockedError = null;
96080
96111
  drainPromise = null;
96081
96112
  // Sequence of the most recent liveness beat, for the skip-while-pending
96082
96113
  // gate in emitLivenessBeat.
@@ -96087,7 +96118,7 @@ var AgentBridgeOutputBuffer = class {
96087
96118
  // ---------------------------------------------------------------------------
96088
96119
  // Public API
96089
96120
  // ---------------------------------------------------------------------------
96090
- async emitProjection(context, projection) {
96121
+ async emitProjection(context, projection, options = {}) {
96091
96122
  if (projection.type === "ui_message_chunk") {
96092
96123
  const coalescible = coalescibleUiDeltaChunk(projection);
96093
96124
  if (coalescible) {
@@ -96104,7 +96135,7 @@ var AgentBridgeOutputBuffer = class {
96104
96135
  }
96105
96136
  await this.flushPendingUiDelta();
96106
96137
  await this.flushPendingDelta();
96107
- await this.enqueueProjectionAndDrain(context, projection);
96138
+ await this.enqueueProjectionAndDrain(context, projection, options);
96108
96139
  }
96109
96140
  async replayPendingOutputs() {
96110
96141
  await this.materializePendingUiDelta();
@@ -96243,15 +96274,22 @@ var AgentBridgeOutputBuffer = class {
96243
96274
  // Transport emit
96244
96275
  // ---------------------------------------------------------------------------
96245
96276
  async drainPendingOutputs(options = {}) {
96277
+ let previousDrainFailed = false;
96246
96278
  if (this.drainPromise && options.force) {
96247
96279
  try {
96248
96280
  await this.drainPromise;
96249
96281
  } catch {
96282
+ previousDrainFailed = true;
96250
96283
  }
96251
96284
  this.drainBlocked = false;
96285
+ this.drainBlockedError = null;
96286
+ }
96287
+ if (previousDrainFailed) {
96288
+ this.discardFailureSensitiveOutputs();
96252
96289
  }
96253
96290
  if (options.force) {
96254
96291
  this.drainBlocked = false;
96292
+ this.drainBlockedError = null;
96255
96293
  this.input.runtimeLogger?.info(
96256
96294
  "agent_bridge_output_buffer_replay_started",
96257
96295
  { pending_count: this.pendingOutputs.size }
@@ -96262,6 +96300,9 @@ var AgentBridgeOutputBuffer = class {
96262
96300
  "agent_bridge_output_buffer_drain_blocked",
96263
96301
  { pending_count: this.pendingOutputs.size }
96264
96302
  );
96303
+ if (options.failIfBlocked) {
96304
+ throw outputDrainBlockedError(this.drainBlockedError);
96305
+ }
96265
96306
  return;
96266
96307
  }
96267
96308
  this.drainPromise ??= (async () => {
@@ -96279,6 +96320,7 @@ var AgentBridgeOutputBuffer = class {
96279
96320
  }
96280
96321
  })().catch((error51) => {
96281
96322
  this.drainBlocked = true;
96323
+ this.drainBlockedError = error51;
96282
96324
  throw error51;
96283
96325
  }).finally(() => {
96284
96326
  this.drainPromise = null;
@@ -96475,6 +96517,7 @@ var AgentBridgeOutputBuffer = class {
96475
96517
  const ack = await this.input.emitOutput(output);
96476
96518
  if (isSuccessfulOutputAck(ack)) {
96477
96519
  this.pendingOutputs.delete(output.outputSeq);
96520
+ this.discardOnFailureOutputSeqs.delete(output.outputSeq);
96478
96521
  this.input.runtimeLogger?.info(
96479
96522
  "agent_bridge_output_buffer_emit_ready",
96480
96523
  this.outputLogContext(output, {
@@ -96502,12 +96545,33 @@ var AgentBridgeOutputBuffer = class {
96502
96545
  (left, right) => left.outputSeq - right.outputSeq
96503
96546
  )[0] ?? null;
96504
96547
  }
96505
- async enqueueProjectionAndDrain(context, projection) {
96548
+ async enqueueProjectionAndDrain(context, projection, options = {}) {
96506
96549
  this.outputSeq += 1;
96507
- this.enqueueOutput(
96508
- buildOutputEnvelope(context, this.outputSeq, projection)
96509
- );
96510
- await this.drainPendingOutputs();
96550
+ const outputSeq = this.outputSeq;
96551
+ this.enqueueOutput(buildOutputEnvelope(context, outputSeq, projection));
96552
+ if (options.discardOnFailure) {
96553
+ this.discardOnFailureOutputSeqs.add(outputSeq);
96554
+ }
96555
+ try {
96556
+ await this.drainPendingOutputs({
96557
+ failIfBlocked: options.requireDrain
96558
+ });
96559
+ this.discardOnFailureOutputSeqs.delete(outputSeq);
96560
+ } catch (error51) {
96561
+ if (options.discardOnFailure) {
96562
+ this.pendingOutputs.delete(outputSeq);
96563
+ this.discardOnFailureOutputSeqs.delete(outputSeq);
96564
+ this.ackExhaustsBySeq.delete(outputSeq);
96565
+ }
96566
+ throw error51;
96567
+ }
96568
+ }
96569
+ discardFailureSensitiveOutputs() {
96570
+ for (const outputSeq of this.discardOnFailureOutputSeqs) {
96571
+ this.pendingOutputs.delete(outputSeq);
96572
+ this.discardOnFailureOutputSeqs.delete(outputSeq);
96573
+ this.ackExhaustsBySeq.delete(outputSeq);
96574
+ }
96511
96575
  }
96512
96576
  enqueueOutput(output) {
96513
96577
  const sanitized = isLiveOnlyRuntimeOutputEnvelope(output) ? output : sanitizeUnstorableStrings(output);
@@ -96933,6 +96997,10 @@ function buildUiMessageCompletedOutputEnvelope(input) {
96933
96997
  function isSuccessfulOutputAck(ack) {
96934
96998
  return ack.status === "persisted" || ack.status === "duplicate" || ack.status === "published";
96935
96999
  }
97000
+ function outputDrainBlockedError(cause) {
97001
+ const detail = cause instanceof Error ? `: ${cause.message}` : "";
97002
+ return new Error(`Bridge output drain is blocked${detail}`);
97003
+ }
96936
97004
  function now2() {
96937
97005
  return (/* @__PURE__ */ new Date()).toISOString();
96938
97006
  }
@@ -99297,7 +99365,7 @@ var ClaudeCodeCommandHandler = class {
99297
99365
  "agent_bridge_claude_command_user_entry_emit_started",
99298
99366
  commandLogContext(delivery, { socket_id: socketId })
99299
99367
  );
99300
- await this.emitBridgeOutput(activeContext, {
99368
+ await this.emitRequiredBridgeOutput(activeContext, {
99301
99369
  type: "entry",
99302
99370
  entry: {
99303
99371
  messageId: delivery.commandId,
@@ -99398,7 +99466,7 @@ var ClaudeCodeCommandHandler = class {
99398
99466
  return;
99399
99467
  }
99400
99468
  const message = answerFallbackMessage(answer);
99401
- await this.emitBridgeOutput(activeContext, {
99469
+ await this.emitRequiredBridgeOutput(activeContext, {
99402
99470
  type: "entry",
99403
99471
  entry: {
99404
99472
  messageId: delivery.commandId,
@@ -99478,6 +99546,24 @@ var ClaudeCodeCommandHandler = class {
99478
99546
  );
99479
99547
  }
99480
99548
  }
99549
+ async emitRequiredBridgeOutput(activeContext, projection) {
99550
+ const options = {
99551
+ discardOnFailure: true,
99552
+ requireDrain: true
99553
+ };
99554
+ try {
99555
+ await this.outputBuffer.emitProjection(
99556
+ activeContext,
99557
+ projection,
99558
+ options
99559
+ );
99560
+ } catch (error51) {
99561
+ this.input.writeOutput?.(
99562
+ `agent_bridge_output_emit_failed error=${error51 instanceof Error ? error51.message : String(error51)}`
99563
+ );
99564
+ throw error51;
99565
+ }
99566
+ }
99481
99567
  async handleAgentMessage(message, meta3) {
99482
99568
  const activeContext = this.context;
99483
99569
  if (!activeContext) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.550",
3
+ "version": "0.1.552",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"