- Close stdout in addition to stdin to prevent hanging writes during shutdown
- Add shuttingDown guard to ensure cleanup runs only once
Made-with: Cursor
The ACP process was ignoring SIGTERM because signal handlers registered
elsewhere in the CLI startup path (e.g., stdin raw mode restoration)
override Node.js's default exit behavior. This caused the process to
remain alive after the IDE sends SIGTERM, leading to zombie connections
and exit code 143 errors in JetBrains IntelliJ IDEA.
Add explicit SIGTERM/SIGINT handlers in runAcpAgent() that destroy
stdin, which closes the ndjson stream and resolves connection.closed,
allowing the process to exit gracefully.
Made-with: Cursor
- Add exitCode fallback in startup failure message to handle edge case
where exit event hasn't fired yet
- Add guard check in exit handler to avoid redundant cleanup if
disconnect() already ran
- Add JSDoc for onDisconnected callback
- Add comment explaining exit code 143 (SIGTERM) in test
Made-with: Cursor
- Record lastExitCode/lastExitSignal for better error messages on startup failure
- Reset exit info on reconnect to avoid stale data
- Add onDisconnected callback so upper layers can react to process exit
- Add clarifying comment on ensureConnection defense-in-depth checks
- Expand tests: onDisconnected contract, disconnect kill verification, exit info init
Made-with: Cursor
When the ACP child process exits unexpectedly (e.g., user cancels execution),
the connection state (sdkConnection, sessionId, child) was not being cleaned up.
This caused subsequent message sends to fail with cryptic errors instead of
a clear "Not connected" message.
Changes:
- Clear sdkConnection/sessionId/child in the exit handler
- Check child.exitCode in isConnected to detect spontaneous exits
- Add isConnected check to ensureConnection as defense-in-depth
- Add unit tests for isConnected, ensureConnection, and disconnect cleanup
Made-with: Cursor
This aligns the test with the updated error handling that uses `status` instead of `code` for HTTP status codes.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Add comprehensive documentation for the Agent Arena feature, covering
usage, configuration, best practices, troubleshooting, and limitations.
Update navigation metadata to include the new page.
This enables users to discover and learn about the multi-model comparison
capability for competitive task execution.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Move getErrorStatus from retry.ts to errors.ts for better organization
- Add getErrorType utility to extract error class/category names
- Enhance getErrorMessage to include cause chain for better debugging
- Refactor ApiErrorEvent to use options object pattern (more readable)
- Rename 'error' to 'error_message' in ApiErrorEvent for clarity
- Make isQwenQuotaExceededError more precise: requires status=429,
code='insufficient_quota', and 'free allocated quota exceeded' message
- Update all tests to match new error detection behavior
This improves error telemetry and makes quota detection more reliable.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add truncateToolOutput helper in truncation.ts to centralize threshold reading, file saving, and telemetry logging
- Refactor shell.ts to use the new helper, removing duplicate code
- Add truncation support for MCP tool output while preserving non-text content (images, audio, resources)
- Refactor getDisplayFromParts to work on transformed Part[] instead of raw MCP response
This reduces code duplication and ensures consistent truncation behavior across shell and MCP tools.
- Add hasExplicitOutputLimit() to detect models with defined output limits
- For known models: cap user max_tokens to model limit (avoid API errors)
- For unknown models (deployment aliases, self-hosted): respect user config
- Update tests to cover new behavior
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add os.tmpdir() to allowed paths in read-file tool
- Add tests for reading files from OS temp directory
- Add terminal capture scenario for PR review testing
This supports the PR review workflow which saves context to temp files.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Increase DEFAULT_OUTPUT_TOKEN_LIMIT from 16K to 32K
- Remove auto-detection from modelsConfig, apply at provider level
- Use conservative default (min of model limit and 32K) when user hasn't configured max_tokens
- Respect user configuration but cap at model's max output limit to avoid API errors
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Checkout PR branch instead of remote viewing for full file access
- Save PR context to temp file to avoid repeating in agent prompts
- Add guidance to prevent 4x diff duplication across agents
- Include environment restoration step after review
This enables agents to read files directly and use git diff against base branch,
improving review quality and reducing prompt bloat.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Task tools spawn independent sub-agents with no shared mutable state,
making them safe to run in parallel. This change executes all task
tools concurrently while keeping other tools sequential to preserve
any implicit ordering the model may rely on.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Remove unused outputFile property from AgentToolResultEvent and its
associated test case. This property is not needed for agent tool
result handling.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add helper functions for better code organization (createPrintableKey,
getCompleteCsiSequenceLength, parsePlainTextPrefix)
- Drop unsupported Kitty CSI-u keys without blocking subsequent input
- Recover plain text that arrives in same chunk after unsupported CSI-u keys
- Add comprehensive tests for edge cases (CAPS_LOCK, event metadata variants)
Improves robustness of Kitty keyboard protocol parsing by gracefully
handling unsupported key codes and ensuring plain text input is not lost.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Add documentation for encoding detection, default encoding settings,
CRLF handling for batch files, and UTF-8 BOM for PowerShell scripts on
Windows.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add needsUtf8Bom() to detect when UTF-8 BOM is needed based on file
extension and system code page
- PowerShell 5.1 on non-UTF-8 Windows systems (e.g. GBK) requires BOM
to read scripts correctly
- Remove default UTF8 encoding; undefined now triggers auto-detection
- Add tests for needsUtf8Bom() covering Windows/non-Windows scenarios
This ensures PowerShell scripts are written with UTF-8 BOM on systems
that need it, fixing character encoding issues for non-ASCII content.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Refactor the vi.mock for 'os' to use a simpler direct mock object
instead of the importOriginal pattern, making the test setup more concise.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Make CRLF conversion for .bat/.cmd files Windows-only
- Extract PowerShell UTF-8 prefix into reusable function
- Replace custom UTF-8 validation with Node.js built-in isUtf8()
This ensures .bat/.cmd files are only converted on Windows where cmd.exe
actually requires CRLF, and reduces code duplication for shell encoding.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This removes the Windows-specific encoding integration tests that are
no longer needed after consolidating the encoding utilities.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Update JSDoc to make clear that detectEncodingFromBuffer only performs
chardet statistical detection and returns null on failure. Callers like
getCachedEncodingForBuffer are responsible for providing fallback logic.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Move system encoding fallback from detectEncodingFromBuffer into
getCachedEncodingForBuffer for clearer responsibility. Remove unused
WINDOWS_UTF8_CODE_PAGE export and inline the value.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>