Skip to content

Conversation

@minpeter
Copy link
Owner

@minpeter minpeter commented Nov 3, 2025

No description provided.

minpeter and others added 5 commits November 3, 2025 19:06
- Added pre.json configuration file to enable canary releases in changesets
- Set up initial version tracking for 6 packages in the ai-sdk-tool ecosystem
- Configured pre-release mode with 'canary' tag for development builds
* chore: update dependencies to beta versions and patch updates

- Updated AI SDK packages to latest beta versions:
  - @ai-sdk/openai from 2.0.56 to 3.0.0-beta.48
  - @ai-sdk/openai-compatible from 1.0.23 to 2.0.0-beta.31
  - @ai-sdk/provider from 2.0.0 to 3.0.0-beta.14
  - @ai-sdk/provider-utils from 3.0.13 to 4.0.0-beta.30
- Upgraded ai package from 5.0.81 to 6.0.0-beta.92
- Updated dev dependencies:
  - @biomejs/biome from 2.3.1 to 2.3.3
  - @types/node from 24.9.1 to 24.10.0
  - @vitest/coverage-

* feat: upgrade AI SDK to version 6

- Updated @ai-sdk-tool/parser package to support AI SDK v6 compatibility
- Updated @ai-sdk-tool/eval package to work with new AI SDK v6 APIs
- Note: Middleware remains on v3 pending future update
* chore: update dependencies to beta versions and patch updates

- Updated AI SDK packages to latest beta versions:
  - @ai-sdk/openai from 2.0.56 to 3.0.0-beta.48
  - @ai-sdk/openai-compatible from 1.0.23 to 2.0.0-beta.31
  - @ai-sdk/provider from 2.0.0 to 3.0.0-beta.14
  - @ai-sdk/provider-utils from 3.0.13 to 4.0.0-beta.30
- Upgraded ai package from 5.0.81 to 6.0.0-beta.92
- Updated dev dependencies:
  - @biomejs/biome from 2.3.1 to 2.3.3
  - @types/node from 24.9.1 to 24.10.0
  - @vitest/coverage-

* feat: upgrade AI SDK to version 6

- Updated @ai-sdk-tool/parser package to support AI SDK v6 compatibility
- Updated @ai-sdk-tool/eval package to work with new AI SDK v6 APIs
- Note: Middleware remains on v3 pending future update

* feat: upgrade language model interfaces to V3

- Updated all references from LanguageModelV2 to LanguageModelV3 across middleware, benchmarks, and protocols
- Replaced OpenRouter API integration with Friendli API in stream tool call example
- Added parse_reasoning flag and custom fetch wrapper for Friendli API integration
- Updated middleware documentation to reflect V3 interface changes
- Added spacing improvements in middleware architecture documentation

* RELEASING: Releasing 2 package(s)

Releases:
  @ai-sdk-tool/[email protected]
  @ai-sdk-tool/[email protected]

[skip ci]

* feat: upgrade parser to support language model V3

- Added changeset for major version bump of @ai-sdk-tool/parser package
- Reverted canary versions in package.json files back to stable versions
- Removed canary changelog entries from both parser and eval packages
- Updated parser to support V3 language model interfaces

* feat: update middleware specification version to v3

- Changed middleware version check from "v2" to "v3" in index.test.ts
- Updated version property name from middlewareVersion to specificationVersion
- Modified version assertions in tool-call-middleware.test.ts to match new spec
- Changed branch configuration in changesets/action from hardcoded 'main' to dynamic github.ref_name
- Enables workflow to work correctly on different release branches instead of only main
- Improves flexibility for projects using multiple release branches or different branch naming conventions
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 3, 2025 11:26
@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2025

🦋 Changeset detected

Latest commit: e7089c2

The changes in this PR will be included in the next version bump.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@minpeter minpeter marked this pull request as draft November 3, 2025 11:26
@codecov
Copy link

codecov bot commented Nov 3, 2025

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request migrates the codebase to support AI SDK v6 by upgrading from LanguageModelV2 to LanguageModelV3 interfaces. The migration primarily involves renaming type references and updating middleware specifications while maintaining backward compatibility through consistent code style improvements.

Key changes:

  • Updated all LanguageModelV2* type references to LanguageModelV3* throughout the codebase
  • Changed middleware middlewareVersion property to specificationVersion with value "v3"
  • Upgraded dependency versions for @ai-sdk/provider, @ai-sdk/provider-utils, @ai-sdk/openai, and ai packages to v6/beta versions
  • Applied consistent code style by replacing ++/-- operators with += 1/-= 1 throughout

Reviewed Changes

Copilot reviewed 72 out of 73 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/parser/src/tool-call-middleware.ts Updated middleware specification version from v2 to v3
packages/parser/src/**/*.ts Replaced all LanguageModelV2 type references with LanguageModelV3
packages/parser/package.json Upgraded AI SDK dependencies to v6 beta versions
packages/eval/src/**/*.ts Updated LanguageModelV2Benchmark to LanguageModelV3Benchmark
packages/eval/package.json Upgraded dependencies to match v6 requirements
packages/rxml/src/**/*.ts Normalized increment operators to += 1 style
.changeset/*.md Added changelog entries for major version bump
.github/workflows/release-changeset.yml Updated branch reference to be dynamic
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @minpeter, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant upgrade to align the project with AI SDK version 6. The primary goal is to update all language model interfaces and related components to LanguageModelV3, ensuring the project leverages the latest features and improvements from the AI SDK. Additionally, it introduces automated dependency management to streamline future updates and maintains overall code health.

Highlights

  • AI SDK V6 Migration: The core change involves migrating the codebase to support AI SDK v6, specifically updating all LanguageModelV2 interfaces and types to LanguageModelV3 across the @ai-sdk-tool/parser and @ai-sdk-tool/eval packages.
  • Dependency Updates: Key dependencies such as @ai-sdk/openai, @ai-sdk/openai-compatible, and ai have been updated to their latest beta versions (v3 and v6 respectively) to ensure compatibility with the new AI SDK version.
  • Automated Dependency Management: A new Dependabot configuration file (.github/dependabot.yml) has been added to automate daily updates for npm packages and GitHub Actions, improving maintenance and security.
  • Package Version Bumps: The @ai-sdk-tool/parser and @ai-sdk-tool/eval packages are receiving major version bumps (3.0.0-canary.0 and 1.0.0-canary.0 respectively), as indicated by new changeset files, reflecting the breaking changes introduced by the AI SDK v6 migration.
  • Example Code Updates: The examples/parser-core has been updated to switch from openrouter to friendli as a language model provider and now includes handling for reasoning-delta stream parts, showcasing new capabilities.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/release-changeset.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully migrates the project to support AI SDK v6 by adopting the LanguageModelV3 interface. The changes are comprehensive, spanning across documentation, examples, and core packages like eval and parser. Key changes include updating all LanguageModelV2 types to V3, bumping dependencies to their new major/beta versions, and correctly updating the middleware interface from middlewareVersion to specificationVersion. The updates are consistent and well-tested. The code quality is high, and the migration appears to be thorough and correct.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary: V3 migration looks good. ? Changeset bot warning resolved. Flagged potential release workflow branch risk and a type/version mismatch in examples. See inline.

minpeter and others added 15 commits November 3, 2025 20:32
- Added file pattern configuration to include all files except .changeset directory
- Ensures consistent linting across codebase while excluding changesets from analysis
- Renamed package from @ai-sdk-tool/parser to @ai-sdkx/tool-parser to align with new naming standards
- Added "sdkx" to VS Code spell checker dictionary for consistent recognition
- Maintained version number and package configuration
- Moved sijawara XML middleware implementations into dedicated sijawara.ts file for better code organization
- Simplified index.ts to re-export middleware from sijawara module
- Preserved original functionality while improving maintainability through better file structure
- Updated @ai-sdk/provider dependency from 2.0.0 to 3.0.0-beta.14 for v3 compatibility
- Added specificationVersion: "v3" to loggingMiddleware to comply with v3 interface
- Removed unnecessary newline in middleware implementation for cleaner code structure
- Moved ai from peerDependencies to dependencies with version 6.0.0-beta.92
- Removed unused v5 dependencies and snapshots from lock file
* refactor: consolidate TypeScript configuration with shared tsconfig package

- Created centralized @ai-sdkx/tsconfig package with base, ts-library, and react-library configurations
- Migrated eval package to use shared tsconfig and project references
- Updated build scripts to use separate build config and improved clean process

* refactor: replace path alias imports with relative imports

- Changed from "@/" alias to "../" relative imports across benchmark and reporter modules
- Updated imports in bfcl.ts, json-generation.ts, and all reporter files for consistency

* refactor: clean up TypeScript configuration and remove unused version file

- Removed unused version.ts file from eval package
- Standardized module resolution by removing explicit ESNext module setting from shared tsconfigs
- Updated lib target to use lowercase 'esnext' for consistency

* chore: add TypeScript project references automation

- Added update-ts-references package to automatically manage TypeScript project references across the monorepo
- Updated tsconfig.json files to include proper project references between packages and examples
- Integrated reference validation check into CI workflow to ensure references stay synchronized

* refactor: reorganize parser package build configuration and imports

- Moved @ai-sdkx/tsconfig to devDependencies in eval and parser packages
- Updated TypeScript configuration to use separate build config with adjusted rootDir
- Replaced path alias imports (@/) with relative imports (../) across all test and source files
- Added version.ts for package version tracking with build-time injection
- Enhanced build scripts with clean step and explicit tsconfig reference

* refactor: replace local collect helper with convertReadableStreamToArray utility

- Removed duplicate collect() helper functions across 11 test files
- Imported convertReadableStreamToArray from @ai-sdk/provider-utils/test for consistent stream collection
- Removed unnecessary vi.mock setup for generateId in affected test files

* chore: update rootDir to src in package tsconfigs

* refactor: standardize vitest configuration across packages

- Added package version injection via __PACKAGE_VERSION__ define for runtime access
- Enabled typecheck in test configuration for better type safety
- Unified test file patterns and exclusions using glob syntax
- Removed unnecessary watch mode and globals configuration

* chore: clean up test configuration and remove e2e scripts

- Removed obsolete e2e test scripts (generate.e2e.ts, stream.e2e.ts) from parser package
- Standardized tsconfig.json by removing redundant include patterns and adding vitest.config.ts to exclusions
- Simplified vitest coverage exclude patterns to be more concise
- Fixed incorrect import path in tool-call-middleware test mock

* refactor: update TypeScript configuration for bundler compatibility

- Changed module system from NodeNext to esnext with bundler resolution for better build tool support
- Removed $schema references from tsconfig files to reduce external dependencies
- Reorganized include array position for consistency across configuration files

* chore: add rxml package reference to parser tsconfig

* fix: correct slice index calculation in streaming test

Changed from `Math.max(0, afterEndIndex)` to `afterEndIndex + 1` to properly exclude the text-end chunk itself when checking for subsequent tool-call chunks
- Moved test-related files to dedicated test/ directory for better organization
- Added better-reasoning-middleware.ts forked from Vercel AI SDK for extracting XML-tagged reasoning sections
- Created placeholder for hcx-14b-think test implementation
- Extracted processTextPart function to handle reasoning text extraction in generate mode
- Refactored stream processing logic into smaller, focused helper functions (createPublisher, getPrefix, enqueueReasoningStart, enqueueDelta, updateExtractionState, handleFullMatch, processTagMatch, processBuffer)
- Simplified main stream processing loop by delegating to processBuffer helper
- Increased MAX_STEPS from 4 to 5 for extended reasoning capability
- Reduced temperature from 0.5 to 0.1 for more deterministic outputs
- Added comprehensive Korean system prompt defining CLOVA X AI behavior and tool usage guidelines
- Reorganized system prompt with clearer sections and hierarchy for better readability
- Enhanced tool usage principles with explicit dependency handling and sequential execution rules
- Added response format guidelines with concrete examples to prevent XML tag leakage
* feat: add proxy-core example demonstrating OpenAI-compatible server

- Created comprehensive example showing how to wrap AI models with middleware and expose them via HTTP proxy
- Implemented server with tool calling, streaming support, and standard OpenAI API endpoints
- Added detailed documentation with curl examples and integration guidance for ChatGPT clients and LangChain

* docs: update proxy-core example documentation and configuration

- Fixed numbering sequence in README setup instructions
- Removed colons from section headers for consistency
- Updated server port from 3000 to 3005 and tool calling test port to 3004
- Modified model configuration to use Qwen3-235B with native OpenAI compatibility (removed morphXmlToolMiddleware)
- Added comprehensive README and testing guide for @ai-sdk-tool/proxy package

* refactor: simplify proxy server configuration and add fallback handler

- Inlined model configuration in OpenAIProxyServer for cleaner code structure
- Switched from Qwen model to GLM-4.6 with hermesToolMiddleware
- Added universal fallback handler for unknown AI SDK chunk types to maintain stream continuity

* refactor: reorganize stream chunk conversion with handler pattern

- Extracted chunk type handlers into a map-based architecture for better maintainability
- Added helper functions for creating consistent OpenAI response formats
- Improved type safety with explicit type definitions for stream chunks and tool calls

* feat: split tool call arguments into multiple streaming chunks

- Implemented splitToolCallArguments function to divide tool arguments into configurable segments (default 7)
- Modified tool-call-delta handler to emit multiple chunks instead of single chunk with complete arguments
- First chunk includes role, tool call ID, and function name; subsequent chunks contain argument segments only

* refactor: improve tool call streaming implementation

- Relocated splitToolCallArguments function for better code organization
- Enhanced argument splitting logic to handle JSON structure more accurately with key-value pair detection
- Added proper TypeScript types for streaming tool call deltas to improve type safety

* refactor: update default model to DeepSeek-R1-0528

* feat: add detailed request logging for proxy server

- Implemented structured logging for incoming OpenAI requests with model, stream mode, temperature, and tool information
- Added conversion logging to track AI SDK parameter transformation with truncated previews
- Created helper functions for message summarization and content truncation to improve log readability

* feat: add detailed tool schema serialization for debugging

- Implemented Zod schema serializer to convert tool input schemas to JSON-compatible format
- Enhanced logging to include full message content and complete tool definitions instead of summaries
- Renamed summarizeMessages to serializeMessages to reflect its new purpose of full serialization

* refactor: convert prompt-based to messages-based format in proxy

- Replaced string concatenation prompt building with structured messages array
- Added helper functions for normalizing message content and formatting tool calls/responses
- Updated logging to reflect new messages-based structure instead of prompt preview

* refactor: simplify fetch override and update middleware configuration

- Refactored fetch override in parser-core to use more concise async/await syntax
- Updated proxy-core to use morphXmlToolMiddleware and extractReasoningMiddleware with array format
- Removed redundant fetch override from proxy-core (now handled by middleware)

* refactor: add reasoning support to proxy server and improve fetch override safety

- Added fetch override in proxy-core to enable reasoning mode via chat_template_kwargs
- Improved fetch override in parser-core with safer optional body handling using conditional spread
- Both implementations now properly handle cases where options.body might be undefined

* refactor: enable native reasoning parsing and switch to DeepSeek model

- Added parse_reasoning flag to chat_template_kwargs for native reasoning extraction
- Switched default model from GLM-4.6 to DeepSeek-R1-0528
- Disabled extractReasoningMiddleware as reasoning is now handled natively by the model
- Removed unused extractReasoningMiddleware import

* docs: add AI SDK reference documentation

- Added comprehensive AI SDK reference documentation covering core concepts, APIs, and usage patterns
- Included examples for text generation, structured data generation, agents, and UI integration
- Documented unified provider architecture and framework integrations (Next.js, React, Svelte, Vue)
- Added package configuration, build setup, and TypeScript definitions reference

* refactor: add stateful stream converter and tool choice mapping

- Implemented createOpenAIStreamConverter factory to maintain stream state across chunks (tool calls, finish flags)
- Replaced stateless convertAISDKStreamChunkToOpenAI with stateful converter pattern
- Added mapOpenAIToolChoice function to convert OpenAI tool_choice format to AI SDK toolChoice
- Changed maxTokens to maxOutputTokens in converter to align with AI SDK naming
- Implemented mergeTools method to combine server-defined an

* test: add comprehensive response converter and SSE formatting tests

- Added test suite for convertAISDKResultToOpenAI covering both stream and non-stream modes
- Implemented tests for text, tool calls, and usage mapping in chat completion responses
- Added SSE formatting tests to verify reasoning delta, content delta, and tool call streaming
- Verified finish_reason handling for both stop and tool_calls scenarios
- Added start handler to stream converter to handle initial stream state
- Switche

* refactor: switch to Hermes tool middleware and adjust reasoning configuration

- Replaced morphXmlToolMiddleware with hermesToolMiddleware for tool call parsing
- Moved parse_reasoning flag from chat_template_kwargs to top-level request body
- Switched default model from GLM-4.6 to DeepSeek-R1-0528

* refactor: reorganize converter modules and extract response utilities

- Renamed converters.js to openai-request-converter.js to better reflect its purpose
- Extracted generateResponseId and getCurrentTimestamp into separate response-utils.js module
- Updated imports across index.ts, response-converter.ts, and server.ts to reflect new module structure
- Improved module organization by separating request conversion, response conversion, and utility functions

* feat: extract reasoning middleware into dedicated package

- Created new @ai-sdk-tool/middleware package for reusable AI SDK middlewares
- Moved extractReasoningMiddleware from example test code to packages/middleware/src/reasoning-parser
- Added package.json with proper exports configuration for main entry and reasoning-parser subpath
- Updated parser-core example to import extractReasoningMiddleware from new package location
- Configured tsup build setup with dual format (CJS/ESM) and TypeScript declarations

* test: reorganize test files and add comprehensive converter tests

- Moved test files from src/test/ to src/ with descriptive suffixes (*.result.test.ts, *.sse.test.ts, *.stream.test.ts)
- Added normalizeMessageContent unit tests covering string, array, object, and primitive inputs
- Enhanced stream converter tests with edge cases: finish without finish-step, finish-step without finish, multiple tool-call deltas
- Removed obsolete converters.test.ts and SSE utility helpers
- Updated vitest config

* docs: add TODO list for proxy package improvements

- Created comprehensive TODO.md covering documentation alignment, migration guides, and testing enhancements
- Outlined 7 action items including port consistency fixes, converter refactor migration notes, E2E streaming tests, structured logging guidance, tool merging examples, middleware usage showcase, and performance smoke tests
- Categorized tasks by owner (Documentation/Testing/Core/Examples) and priority (High/Medium/Low)

* feat: add HyperCLOVAX model support with custom reasoning extraction

- Added @ai-sdk-tool/middleware dependency to proxy-core example
- Implemented HyperCLOVAX-SEED-Think-14B model configuration with custom reasoning tags
- Configured extractReasoningMiddleware with "/think\n" and "\nassistant\n" delimiters
- Set parse_reasoning to false and force_reasoning to true in chat_template_kwargs
- Commented out DeepSeek model configuration for reference
- Switched active model from DeepSeek to HyperCLOVA

* refactor: ensure consistent response ID across stream chunks and remove middleware tests

- Modified createOpenAIStreamConverter to generate and maintain single response ID per stream lifecycle
- Updated createFinishResponse, createContentResponse, and createToolCallResponse to accept responseId parameter
- Initialized streamResponseId in converter state and reset on stream start
- Added SSE test to verify all chunks share the same response ID
- Removed test script from middleware package.json
-

* build: configure TypeScript project references for middleware and proxy packages

- Added middleware package reference to parser-core example tsconfig
- Added parser package reference to proxy package tsconfig
- Reordered root tsconfig references to include middleware and proxy packages
- Ensures proper TypeScript compilation order and dependency resolution across monorepo

* docs: add OpenAI Responses API migration reference documentation

- Added comprehensive migration guide from Chat Completions API to Responses API
- Documented API benefits including improved performance, lower costs, and agentic capabilities
- Included side-by-side code examples comparing Chat Completions and Responses patterns
- Covered migration steps for endpoints, item definitions, multi-turn conversations, and function calling
- Added capability comparison table and structured outputs migration

* feat: add default system prompt middleware with configurable placement

- Created defaultSystemPromptMiddleware to inject or merge system prompts into model calls
- Implemented extractSystemText helper to normalize content from string, array, or object formats
- Added mergeSystemPrompts function supporting "before" and "after" placement strategies
- Configured HyperCLOVAX model with comprehensive Korean system prompt covering tool usage principles, response formatting rules, and output guidelines

* feat: add configurable logging and parser debug options to proxy

- Added parserDebug configuration to ProxyConfig for middleware-level debugging control
- Implemented logging configuration with granular toggles for requests, conversions, and stream chunks
- Modified convertOpenAIRequestToAISDK to accept parserDebug config and forward to providerOptions.toolCallMiddleware
- Updated createOpenAIStreamConverter to accept logChunks option with conditional chunk logging
- Refactored logIncomingRequest an

* feat: add structured logging for tool call parsing failures with truncation

- Created logParseFailure utility in debug.ts for standardized parse error logging
- Added formatError helper to safely stringify Error objects with stack traces
- Implemented truncateSnippet function with 800 char limit to prevent log overflow
- Added truncateToolCall helper in json-mix-protocol for consistent tool call truncation
- Instrumented processToolCallJson to log generated-text phase parse failures
- Instrumented emitIncompleteToolCall

* feat: switch to GLM-4.6 with morphXmlToolMiddleware and add Qwen hermes support

- Imported morphXmlToolMiddleware from parser package
- Switched deepseek model from DeepSeek-R1-0528 to GLM-4.6
- Replaced hermesToolMiddleware with morphXmlToolMiddleware in deepseek configuration
- Added hermesToolMiddleware to Qwen model configuration
- Changed active server model from hcx to deepseek
- Removed truncateToolCall helper function from json-mix-protocol
- Updated logParseFailure calls to use raw snipp

* feat: add lenient XML close tag normalization and repair logic for malformed tool calls

- Implemented normalizeCloseTags to fix malformed closing tags like </ step> or </\n name>
- Added balanceTags function to insert missing </step> boundaries and auto-close unclosed tags
- Created repairParsedAgainstSchema to coerce string array items into objects when schema expects objects
- Added tryParseSecondaryXml fallback parser with tag normalization and schema repair
- Implemented extractStepStatusFromString to extract step/

* test: add shell tool malformed closing tag test and improve XML normalization logic

- Added test case for shell tool with stray </command> tag to verify correct array parsing
- Modified tryParseSecondaryXml to only allow balancing when malformed close tags are present
- Fixed handleClosingTagSegment to skip unmatched closing tags instead of appending them
- Merged raw and normalized tool call results with deduplication by position
- Added fallback length estimation in collectToolCallsFromNormalizedText

* feat: externalize system prompts to files and switch active model to GLM-4.6

- Added file system imports (fs, path, fileURLToPath) for loading external prompt files
- Created glm_codex_xml_prompt and hcx_tool_prompt variables loading from .txt files
- Moved GLM-4.6 configuration from _deepseek to _glm_codex variable
- Added defaultSystemPromptMiddleware to GLM-4.6 with externalized prompt and "after" placement
- Replaced inline Korean system prompt in HyperCLOVAX with external hcx_tool_prompt file

* refactor: remove unused HyperCLOVAX test files and reasoning middleware

- Deleted hcx-14b-think.ts example test file with location/weather tool demonstration
- Removed better-reasoning-middleware.ts containing forked extractReasoningMiddleware implementation
- Cleaned up duplicate reasoning extraction logic and HyperCLOVAX-specific test code

* refactor: reorganize model configurations into separate modules

- Moved glm-codex-xml.txt and hcx-tool-hermes.txt prompt files to models/ directory
- Extracted GLM-4.6 configuration to models/glm-codex.ts module
- Extracted HyperCLOVAX configuration to models/hcx.ts module
- Extracted Qwen configuration to models/qwen.ts module
- Simplified server.ts by importing glm_codex model from dedicated module
- Removed inline model configurations and middleware setup from server.ts

* refactor: standardize prompt file naming and add placement option with tests

- Renamed glm-codex-xml.txt to codex-xml.txt for generic reuse across models
- Renamed hcx-tool-hermes.txt to hcx-hermes.txt for consistency
- Updated glm_codex_xml_prompt variable to extra_system_prompt in glm-codex.ts
- Updated hcx_tool_prompt variable to extra_system_prompt in hcx.ts
- Changed placement option terminology from "before"/"after" to "first"/"last" in defaultSystemPromptMiddleware
- Switched HyperCLOVAX

* test: consolidate shell tool tests and add duplicate tag deduplication logic

- Renamed xml-protocol.shell-tool.malformed-closing.test.ts to xml-protocol.real-usecases.shell-tool.test.ts
- Updated test suite description from "shell tool malformed closing tag handling" to "shell tool"
- Prefixed existing malformed closing tag test with "[malformed closing tag handling]" label
- Added placeholder "TEST" test case for git log command with multiple command tags
- Implemented shouldDeduplicateStringTags to

* refactor: convert fullRawText to lazy getter in debug summary transform

- Changed fullRawText parameter to getFullRawText callback in createDebugSummaryTransform
- Added logRawChunk call to output raw text before extracting tool call segments
- Updated wrapStream to pass arrow function returning fullRawText instead of direct value
- Deferred raw text access until finish event to ensure complete text is available

* refactor: convert apply_patch examples from JSON array to multi-tag XML format

- Changed shell tool command examples from JSON array syntax to multiple <command> tags
- Split apply_patch invocations into separate <command> tags for command name and patch content
- Removed escaped newlines (\n) and quotes from patch content for better readability
- Updated both "Update File" and "Add File" examples to use new multi-tag format
- Improved example formatting with proper line breaks and indentation in

* feat: add quick rules and plain text example to apply_patch documentation

- Added "Quick rules" section with concise bullet points for common apply_patch usage
- Added "Detailed usage" section with comprehensive patch format specifications
- Included new example (#3) demonstrating how to add plain text files with bullet lists
- Clarified prefix requirements for Add File operations and EOF anchor usage
- Documented validation rules for duplicate paths and missing target files
- Upgraded @biomejs/biome from 2.3.3 to 2.3.4
- Upgraded @vitest/coverage-v8 and vitest from 4.0.6 to 4.0.8
- Upgraded @vitest/ui from 4.0.6 to 4.0.8
- Upgraded ultracite from 6.2.0 to 6.3.2
- Upgraded fastify from 5.2.0 to 5.6.2
- Upgraded zod from 3.23.8 to 4.1.12
- Updated all @rollup/* platform-specific binaries to 4.53.2
- Updated @inquirer/external-editor to 1.0.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants