Commit Graph

61 Commits

  • feat(ai): add PI_AI_ANTIGRAVITY_VERSION env var override
    Allows users to override the Antigravity User-Agent version when Google
    updates their version requirements, avoiding the need to wait for a
    package release.
    
    Fixes #1129
  • feat(ai): add Kimi For Coding provider support
    - Add kimi-coding provider using Anthropic Messages API
    - API endpoint: https://api.kimi.com/coding/v1
    - Environment variable: KIMI_API_KEY
    - Models: kimi-k2-thinking (text), k2p5 (text + image)
    - Add context overflow detection pattern for Kimi errors
    - Add tests for all standard test suites
  • feat(ai): add PI_CACHE_RETENTION env var for extended prompt caching
    Adds support for extended cache retention via PI_CACHE_RETENTION=long:
    - Anthropic: 5m -> 1h TTL
    - OpenAI: in-memory -> 24h retention
    
    Only applies to direct API calls (api.anthropic.com, api.openai.com).
    Proxies and other providers are unaffected.
    
    fixes #967
  • fix(ai): skip errored/aborted assistant messages in transform-messages
    Fixes OpenAI Responses 400 error 'reasoning without following item' by
    skipping errored/aborted assistant messages entirely rather than filtering
    at the provider level. This covers openai-responses, openai-codex-responses,
    and future providers.
    
    Removes strictResponsesPairing compat option (no longer needed).
    
    Closes #838
  • feat(ai): add strictResponsesPairing for Azure OpenAI Responses API
    Split OpenAICompat into OpenAICompletionsCompat and OpenAIResponsesCompat
    for type-safe API-specific compat settings. Added strictResponsesPairing
    option to suppress orphaned reasoning/tool calls on incomplete turns,
    fixing 400 errors on Azure's Responses API which requires strict pairing.
    
    Closes #768
  • Fix z.ai thinking/reasoning params, fixes #688
    Z.ai uses thinking: { type: "enabled" | "disabled" } instead of
    OpenAI's reasoning_effort. Added thinkingFormat compat flag to handle
    this. Thinking is now explicitly enabled/disabled based on user setting.
  • Add MiniMax provider support (#656 by @dannote)
    - Add minimax to KnownProvider and Api types
    - Add MINIMAX_API_KEY to getEnvApiKey()
    - Generate MiniMax-M2 and MiniMax-M2.1 models
    - Add context overflow detection pattern
    - Add tests to all required test files
    - Update README and CHANGELOG with attribution
    
    Also fixes:
    - Bedrock duplicate toolResult ID when content has multiple blocks
    - Sandbox extension unused parameter lint warning
  • feat(ai): Add Amazon Bedrock provider (#494)
    Adds support for Amazon Bedrock with Claude models including:
    - Full streaming support via Converse API
    - Reasoning/thinking support for Claude models
    - Cross-region inference model ID handling
    - Multiple AWS credential sources (profile, IAM keys, API keys)
    - Image support in messages and tool results
    - Unicode surrogate sanitization
    
    Also adds 'Adding a New Provider' documentation to AGENTS.md and README.
    
    Co-authored-by: nickchan2 <nickchan2@users.noreply.github.com>
  • Fix Google Cloud Code Assist OAuth for paid subscriptions
    - Properly handle long-running operations for project provisioning
    - Support GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_PROJECT_ID env vars for paid tiers
    - Handle VPC-SC affected users
    - Update docs for paid subscription requirements
    
    Closes #582
  • Resolve os.homedir() lazily instead of at module load time
    - Move homedir() calls into functions for lazy evaluation
    - Add GOOGLE_APPLICATION_CREDENTIALS support for Vertex AI
  • feat(ai,agent,coding-agent): add sessionId for provider session-based caching
    - Add sessionId to StreamOptions for providers that support session-based caching
    - OpenAI Codex provider uses sessionId for prompt_cache_key and routing headers
    - Agent class now accepts and forwards sessionId to stream functions
    - coding-agent passes session ID from SessionManager and updates on session changes
    - Update ai package README with table of contents, OpenAI Codex OAuth docs, and env vars table
    - Increase Codex instructions cache TTL from 15 minutes to 24 hours
    - Add tests for sessionId forwarding in ai and agent packages
  • Add Vertex AI provider with ADC support
    - Implement google-vertex provider in packages/ai
    - Support ADC (Application Default Credentials) via @google/generative-ai
    - Add Gemini model catalog for Vertex AI
    - Update packages/coding-agent to handle google-vertex provider
  • Update READMEs: remove agent section from pi-ai, rewrite pi-agent-core
    - Removed Agent API section from pi-ai README (moved to agent package)
    - Rewrote agent package README for new architecture:
      - No more transports (ProviderTransport, AppTransport removed)
      - Uses streamFn directly with streamProxy for proxy usage
      - Documents convertToLlm and transformContext
      - Documents low-level agentLoop/agentLoopContinue API
      - Updated custom message types documentation
  • WIP: Add CLI for OAuth login, update README
    - Add src/cli.ts with login command for OAuth providers
    - Add bin entry to package.json for 'npx @mariozechner/pi-ai'
    - Update README: remove setApiKey docs, rewrite OAuth section
    - OAuth storage is caller's responsibility, not library's
    - Use getOAuthProviders() instead of duplicating provider list
  • Add configurable OAuth storage backend and respect --models in model selector
    - Add setOAuthStorage() and resetOAuthStorage() to pi-ai for custom storage backends
    - Configure coding-agent to use its own configurable OAuth path via getOAuthPath()
    - Model selector (/model command) now only shows models from --models scope when set
    - Rewrite OAuth documentation in pi-ai README with examples
    
    Fixes #255
  • Add tool result streaming
    - Add AgentToolUpdateCallback type and optional onUpdate callback to AgentTool.execute()
    - Add tool_execution_update event with toolCallId, toolName, args, partialResult
    - Normalize tool_execution_end to always use AgentToolResult (no more string fallback)
    - Bash tool streams truncated rolling buffer output during execution
    - ToolExecutionComponent shows last N lines when collapsed (not first N)
    - Interactive mode handles tool_execution_update events
    - Update RPC docs and ai/agent READMEs
    
    fixes #44
  • Add Mistral as AI provider
    - Add Mistral to KnownProvider type and model generation
    - Implement Mistral-specific compat handling in openai-completions:
      - requiresToolResultName: tool results need name field
      - requiresAssistantAfterToolResult: synthetic assistant message between tool/user
      - requiresThinkingAsText: thinking blocks as <thinking> text
      - requiresMistralToolIds: tool IDs must be exactly 9 alphanumeric chars
    - Add MISTRAL_API_KEY environment variable support
    - Add Mistral tests across all test files
    - Update documentation (README, CHANGELOG) for both ai and coding-agent packages
    - Remove client IDs from gemini.md, reference upstream source instead
    
    Closes #165
  • Simplify compaction: remove proactive abort, use Agent.continue() for retry
    - Add agentLoopContinue() to pi-ai for resuming from existing context
    - Add Agent.continue() method and transport.continue() interface
    - Simplify AgentSession compaction to two cases: overflow (auto-retry) and threshold (no retry)
    - Remove proactive mid-turn compaction abort
    - Merge turn prefix summary into main summary
    - Add isCompacting property to AgentSession and RPC state
    - Block input during compaction in interactive mode
    - Show compaction count on session resume
    - Rename RPC.md to rpc.md for consistency
    
    Related to #128
  • Add xhigh thinking level for OpenAI codex-max models
    - Add 'xhigh' to ThinkingLevel type in ai and agent packages
    - Map xhigh to reasoning_effort: 'max' for OpenAI providers
    - Add thinkingXhigh color token to theme schema and built-in themes
    - Show xhigh option only when using codex-max models
    - Update CHANGELOG for both ai and coding-agent packages
    
    closes #143
  • Add custom headers support for models.json
    Fixes #39
    
    - Added headers field to Model type (provider and model level)
    - Model headers override provider headers when merged
    - Supported in all APIs:
      - Anthropic: defaultHeaders
      - OpenAI (completions/responses): defaultHeaders
      - Google: httpOptions.headers
    - Enables bypassing Cloudflare bot detection for proxied endpoints
    - Updated documentation with examples
    
    Also fixed:
    - Mistral/Chutes syntax error (iif -> if)
    - process.env.ANTHROPIC_API_KEY bug (use delete instead of = undefined)
  • Add image support in tool results across all providers
    Tool results now use content blocks and can include both text and images.
    All providers (Anthropic, Google, OpenAI Completions, OpenAI Responses)
    correctly pass images from tool results to LLMs.
    
    - Update ToolResultMessage type to use content blocks
    - Add placeholder text for image-only tool results in Google/Anthropic
    - OpenAI providers send tool result + follow-up user message with images
    - Fix Anthropic JSON parsing for empty tool arguments
    - Add comprehensive tests for image-only and text+image tool results
    - Update README with tool result content blocks API
  • refactor(ai): improve error handling and stop reason types
    - Add 'aborted' as a distinct stop reason separate from 'error'
    - Change AssistantMessage.error to errorMessage for clarity
    - Update error event to include reason field ('error' | 'aborted')
    - Map provider-specific safety/refusal reasons to 'error' stop reason
    - Reorganize utility functions into utils/ directory
    - Rename agent.ts to agent-loop.ts for better clarity
    - Fix error handling in all providers to properly distinguish abort from error
  • feat(ai): add partial JSON parsing for streaming tool calls
    - Added partial-json package for parsing incomplete JSON during streaming
    - Tool call arguments now contain partially parsed JSON during toolcall_delta events
    - Enables progressive UI updates (e.g., showing file paths before content is complete)
    - Arguments are always valid objects (minimum empty {}), never undefined
    - Full validation still occurs at toolcall_end when arguments are complete
    - Updated all providers (Anthropic, OpenAI Completions/Responses) to use parseStreamingJson
    - Added comprehensive documentation and examples in README
    - Added test to verify arguments are always defined during streaming
  • Replace Zod with TypeBox for schema validation
    - Switch from Zod to TypeBox for tool parameter schemas
    - TypeBox schemas can be serialized/deserialized as JSON
    - Use AJV for runtime validation instead of Zod's parse
    - Add StringEnum helper for Google API compatibility (avoids anyOf/const patterns)
    - Export Type and Static from main package for convenience
    - Update all tests and documentation to reflect TypeBox usage
  • feat(ai): Implement Zod-based tool validation and improve Agent API
    - Replace JSON Schema with Zod schemas for tool parameter definitions
    - Add runtime validation for all tool calls at provider level
    - Create shared validation module with detailed error formatting
    - Update Agent API with comprehensive event system
    - Add agent tests with calculator tool for multi-turn execution
    - Add abort test to verify proper handling of aborted requests
    - Update documentation with detailed event flow examples
    - Rename generate.ts to stream.ts for clarity
  • refactor(ai): Simplify API with new streaming interface and model management
    - Replace createLLM with getModel/getModels/getProviders functions
    - Rename PROVIDERS to MODELS (internal only, not exposed)
    - Add streamSimple/completeSimple for unified reasoning interface
    - Update README with new API examples and comprehensive documentation
    - Remove model registration (models are now fixed from build time)
    - Add proper TypeScript typing for provider-specific options
    - Document context serialization, cross-provider handoffs, and browser usage
  • docs(ai): Add browser usage section to README
    - Document browser support and API key requirements
    - Add security warning about exposing keys in frontend
    - Keep documentation concise and practical
  • feat(ai): Add cross-provider message handoff support
    - Add transformMessages utility to handle cross-provider compatibility
    - Convert thinking blocks to <thinking> tagged text when switching providers
    - Preserve native thinking blocks when staying with same provider/model
    - Add comprehensive handoff tests verifying all provider combinations
    - Fix OpenAI Completions to return partial results on abort
    - Update tool call ID format for Anthropic compatibility
    - Document cross-provider handoff capabilities in README
  • feat(ai): Add start event emission to all providers
    - Emit start event with model and provider info after creating stream
    - Add abort signal tests for all providers
    - Update README abort signal section to reflect non-throwing API
    - Fix model references in README examples
  • docs(ai): Add all event types to streaming example
    - Add 'start' event with model/provider info
    - Add 'done' event with stop reason and usage stats
    - Add 'error' event handling
    - Show more detailed event data in examples