193 Commits

Author SHA1 Message Date
Kayvan Sylvan
816e1bab89 chore: add documentation and improve code style per review feedback
- Add documentation comments for messageTextFromParts, contentBlocksFromMessage,
  prependSystemContentToBlocks, contentBlockFromAttachmentURL, and parseDataURL
- Consolidate two switch statements in normalizeImageMimeType into single
  idiomatic Go switch with direct returns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 15:52:29 -08:00
Kayvan Sylvan
8c38cef1f1 chore: address Copilot review feedback for attachments handling
- Add debug logging for failed data URL parsing
- Add debug logging for unsupported MIME types
- Add debug logging for non-base64 data URLs
- Add documentation for normalizeImageMimeType with API reference
- Add documentation for isPDFURL explaining extension-only limitation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 15:12:23 -08:00
Kayvan Sylvan
bcce1bef99 fix for \\n -> \n 2026-01-21 14:56:16 -08:00
Kayvan Sylvan
eea80f3bee feat: add multi-content support for images and PDFs in Anthropic client
### CHANGES
- Update toMessages to handle multi-content messages with text and attachments
- Add contentBlocksFromMessage to convert message parts to Anthropic blocks
- Implement support for image URLs including data URLs and base64 images
- Add PDF attachment handling via data URLs and URL-based PDFs
- Introduce parseDataURL for extracting MIME type and data from data URLs
- Create normalizeImageMimeType to standardize supported image MIME types
- Add isPDFURL to detect PDF files from URL paths
- Refactor system content accumulation to use text extraction from parts
- Update tests to verify PDF attachment processing in multi-content messages
2026-01-21 14:19:40 -08:00
Kayvan Sylvan
719590abb6 feat: add Spotify metadata retrieval via --spotify flag
## CHANGES
- Add Spotify plugin with OAuth token handling and metadata
- Wire --spotify flag into CLI processing and output
- Register Spotify in plugin setup, env, and registry
- Update shell completions to include --spotify option
- Add i18n strings for Spotify configuration errors
- Add unit and integration tests for Spotify API
- Set gopls integration build tags for workspace
2026-01-20 15:57:59 -08:00
Kayvan Sylvan
a23c698947 feat: add image generation compatibility warnings for unsupported models
## CHANGES

- Add warning to stderr when using incompatible models with image generation
- Add GPT-5, GPT-5-nano, and GPT-5.2 to supported image generation models
- Create `checkImageGenerationCompatibility` function in OpenAI plugin
- Add comprehensive tests for image generation compatibility warnings
- Add integration test scenarios for CLI image generation workflows
- Suggest gpt-4o as alternative in incompatibility warning messages
2026-01-20 11:55:18 -08:00
Kayvan Sylvan
387610bcf8 Add Infermatic provider test case
Adds test coverage for the Infermatic AI provider in
TestCreateClient to verify the provider exists and
creates a valid client.

Part of #1033: Add Infermatic AI provider support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 06:38:38 -08:00
Kayvan Sylvan
9e1ee4d48e WIP: Phase 1 - Add Infermatic provider to ProviderMap
Issue: #1033
Phase: 1 of 2
Status: Pending verification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 06:25:31 -08:00
Kayvan Sylvan
da34f5823a chore: refactor parseOllamaNumCtx for cleaner errors and type fixes
### CHANGES
- Remove value from fractional part error message
- Update overflow check to use float64 for consistency
- Ensure error messages omit unnecessary details for clarity
2026-01-18 10:12:18 -08:00
Kayvan Sylvan
14358a1c1b fix: Edit comments per review comments 2026-01-18 09:59:35 -08:00
Kayvan Sylvan
ce74e881be fix: add validation for NaN, Inf, and negative values in parseOllamaNumCtx
## CHANGES

- Add NaN and Infinity validation for float64 values
- Add NaN and Infinity validation for float32 values
- Add negative value check for int64 type
- Add negative value check for json.Number type
- Add comprehensive test cases for special float values
- Add test cases for negative int64 and json.Number inputs
- Update line reference comments for validation checks
2026-01-18 07:42:10 -08:00
Kayvan Sylvan
6f804d7e46 fix: changes based on PR review 2026-01-18 01:46:09 -08:00
Kayvan Sylvan
8c015b09a1 test: add comprehensive tests for parseOllamaNumCtx and simplify error handling
- Add comprehensive unit tests for `parseOllamaNumCtx` function
- Remove redundant negative value checks in float parsing
- Simplify error messages to avoid exposing internal type info
- Streamline error response in `ollamaChat` handler
- Add helper functions for string containment in tests
- Cover edge cases including overflow, invalid types, and boundaries
2026-01-18 01:34:03 -08:00
Kayvan Sylvan
03108cc69d format fix 2026-01-18 01:02:46 -08:00
Kayvan Sylvan
556e098fc1 fix: Ollama server now respects the default context window
This commit fixes the Ollama server /api/chat endpoint which was ignoring
the client-provided num_ctx parameter and global DEFAULT_MODEL_CONTEXT_LENGTH,
always using a hardcoded value of 2048 tokens.

- Add parseOllamaNumCtx() function in ollama.go with type-safe extraction
  supporting 6 numeric types (float64, float32, int, int64, json.Number, string)
- Extract num_ctx from client request options in ollamaChat()
- Add ModelContextLength field to ChatRequest struct in chat.go
- Replace hardcoded 2048 with request.ModelContextLength in GetChatter() call

- Platform-aware integer overflow protection for 32-bit systems
- DoS protection via 1,000,000 token maximum limit
- Long string truncation in error messages (50 char limit)
- Sanitized error messages (no internal stdlib details exposed)

- Missing/null num_ctx returns (0, nil) to trigger existing default fallback
- Zero API contract changes
- Invalid values return 400 Bad Request with clear error messages

- All existing tests pass
- Compilation successful with no errors or warnings

Fixes #1942
2026-01-18 00:47:37 -08:00
Kayvan Sylvan
2cb2a76200 feat: add support for pattern variables in Ollama API requests
## CHANGES

- Add `Variables` field to `OllamaRequestBody` struct for direct variable passing
- Change `Options` field from empty struct to flexible `map[string]any` type
- Extract variables from top-level `Variables` field or nested `Options.variables`
- Support parsing variables as JSON string or map format
- Pass extracted variables to `PromptRequest` for single message chats
- Pass extracted variables to `PromptRequest` for multi-message chats
- Add `omitempty` JSON tags to optional fields
2026-01-17 06:35:41 -08:00
Kayvan Sylvan
c7c9d73c01 fix: return string error payloads and fail non-stream empty upstream
## CHANGES
- Serialize JSON error field as `err.Error()` string
- Treat non-stream upstream empty content as 502 error
- Keep streaming mode tolerant when upstream returns no content
2026-01-17 05:34:38 -08:00
Kayvan Sylvan
61e8871396 fix: set NDJSON header only after successful upstream response
## CHANGES
- Move NDJSON `Content-Type` header after status validation
- Avoid setting stream headers on upstream error responses
- Log warning when upstream returns no streamed content
- Keep duration timing consistent across response paths
- Preserve existing streaming and non-streaming response behavior
2026-01-17 05:03:03 -08:00
Kayvan Sylvan
04fef11e17 fix: harden Ollama streaming flush and align metric counters with int64
## CHANGES
- Use int64 for prompt and eval count fields
- Skip sending secondary error message on stream write failure
- Allow non-http schemes and validate host only for address
- Flush response only when writer implements http.Flusher
2026-01-17 04:55:49 -08:00
Kayvan Sylvan
c50b9a61de fix: propagate request context and close Ollama stream on errors
## CHANGES
- Use Gin request context for outbound HTTP calls
- Send final stream chunk when response write fails
- Capture timing duration once for consistent metrics
- Build final Ollama response via shared helper function
- Validate Fabric base URL scheme is http/https only
- Add clarifying documentation comments for URL and writers
2026-01-17 04:21:41 -08:00
Kayvan Sylvan
665267842f fix: align Ollama duration fields to int64 nanosecond precision
## CHANGES
- Use int64 for `load_duration` JSON field values
- Use int64 for `prompt_eval_duration` JSON field values
- Remove lossy int casts when assigning nanosecond durations
- Keep duration payloads consistent with `total_duration` precision
- Prevent potential overflow on long-running request timing
2026-01-17 04:01:26 -08:00
Kayvan Sylvan
e2b63ddc2f fix: improve SSE scan errors and validate bare Fabric address inputs
## CHANGES
- Send detailed SSE stream scan errors in responses
- Detect token-too-long and return clear buffer-limit message
- Unify streaming and JSON error messaging for scan failures
- Validate bare Fabric address using URL parsing
- Reject bare addresses missing host or hostname
- Disallow path components in bare Fabric addresses
- Trim trailing slash from validated Fabric chat URL
- Add tests covering invalid bare addresses with paths
2026-01-17 03:32:07 -08:00
Kayvan Sylvan
97b6b76dd2 fix: reject hostless Fabric chat URLs like https://:8080
## CHANGES
- Validate parsed URL host not start with colon
- Return explicit error for missing hostname in URL
- Update unit test to expect error on port-only host
- Prevent accidental acceptance of malformed `https://:port` addresses
2026-01-17 03:06:17 -08:00
Kayvan Sylvan
29a32a8439 fix: validate Fabric chat URL host and tidy Ollama responses
## CHANGES
- Set NDJSON content type before checking upstream errors
- Reject parsed URLs that omit a hostname
- Remove hardcoded eval count placeholders from responses
- Add unit tests for Fabric chat URL builder
- Cover colon-port, host:port, and IP address inputs
2026-01-17 02:31:46 -08:00
Kayvan Sylvan
ae6d4d1fb3 fix: handle upstream non-2xx and return stringified error payloads
## CHANGES
- Convert JSON error responses to use err.Error()
- Detect upstream Fabric non-2xx status before scanning
- Read and log upstream error body when possible
- Return upstream status error message for non-stream mode
- Stream error message via NDJSON when streaming enabled
- Set NDJSON Content-Type header before first streaming write
- Remove per-chunk header setting during streaming output
2026-01-17 01:37:20 -08:00
Kayvan Sylvan
8310695e1a fix(ollama): address Copilot review feedback for error handling
Addresses all 8 Copilot review comments on PR #1940:

Critical fixes:
- Replace log.Fatal with proper HTTP error response to prevent
  server crashes on request failures
- Add streaming-aware error handling to maintain consistent
  response format (prevents mixing JSON with NDJSON)

Error messaging improvements:
- Replace "testing endpoint" placeholders with descriptive
  error messages
- Add clear context for unmarshal and scanning failures

Protocol compliance:
- Set Content-Type: application/x-ndjson for streaming responses
- Ensure all error paths respect stream vs non-stream mode

Code cleanup:
- Remove commented-out dead code

Tested both streaming and non-streaming modes successfully.
2026-01-17 01:19:37 -08:00
Kayvan Sylvan
e318a939aa refactor: rewrite Ollama chat handler to support proper streaming responses
- Add `json:"-"` tag to exclude UpdateChan from JSON serialization
- Extract URL building logic into dedicated `buildFabricChatURL` helper function
- Replace single-read body parsing with streaming `bufio.Scanner` approach
- Add proper SSE data prefix parsing for fabric response format
- Implement real-time streaming with `writeOllamaResponse` helper function
- Add `writeOllamaResponseStruct` for consistent JSON response writing
- Handle both streaming and non-streaming response modes separately
- Add proper error handling for fabric error response types
- Ensure response body is properly closed with defer statement
2026-01-17 00:52:29 -08:00
Kayvan Sylvan
a2370a0e3b chore: Note in the guide about restricted env + modernize fixes 2026-01-15 15:16:40 -08:00
Kayvan Sylvan
f50a7568d1 Merge branch 'main' into kayvan/msft_copilot_vendor_by_claude_opus_4_5 2026-01-15 15:00:42 -08:00
Tom Stetson
d98ad5290c fix: update Copilot SendStream to use domain.StreamUpdate
Update the SendStream interface to match the current Vendor interface
which now uses chan domain.StreamUpdate instead of chan string.

Changes:
- Update SendStream signature to use chan domain.StreamUpdate
- Update sendChatMessageStream signature accordingly
- Update parseSSEStream signature accordingly
- Wrap all channel sends with domain.StreamUpdate{Type: StreamTypeContent}

This fixes the build error introduced when the streaming interface was
updated to support metadata like token usage alongside content.
2026-01-15 14:50:59 -05:00
Kayvan Sylvan
c26a56a368 feat: add DigitalOcean Gradient AI Agents as a new vendor
## CHANGES

- Add DigitalOcean as a new AI provider in plugin registry
- Implement DigitalOcean client with OpenAI-compatible inference endpoint
- Support model access key authentication for inference requests
- Add optional control plane token for model discovery
- Create DigitalOcean setup documentation with environment variables
- Update README to list DigitalOcean in supported providers
- Handle model listing via control plane API with fallback
2026-01-13 22:52:13 -08:00
Kayvan Sylvan
a2058ae26e Merge branch 'main' into kayvan/msft_copilot_vendor_by_claude_opus_4_5 2026-01-13 10:35:24 -08:00
Kayvan Sylvan
7e7ab9e5f2 feat: add Mammouth as new OpenAI-compatible AI provider
## CHANGES

- Add Mammouth provider configuration with API base URL
- Configure Mammouth to use standard OpenAI-compatible interface
- Disable Responses API implementation for Mammouth provider
- Add "Mammouth" to VSCode spell check dictionary
2026-01-12 09:27:28 -08:00
Kayvan Sylvan
cf55be784f refactor: add NewVendorPluginBase factory function to reduce duplication
Add centralized factory function for AI vendor plugin initialization:
- Add NewVendorPluginBase(name, configure) to internal/plugins/plugin.go
- Update 8 vendor files (anthropic, bedrock, gemini, lmstudio, ollama,
  openai, perplexity, vertexai) to use the factory function
- Add 3 test cases for the new factory function

This removes ~40 lines of duplicated boilerplate code and ensures
consistent plugin initialization across all vendors.

MAESTRO: Loop 00001 refactoring implementation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 20:12:58 -08:00
Henri Cook
8017f376b1 fix: use MaxTokens not ModelContextLength for output limit 2026-01-08 19:23:21 +00:00
Kayvan Sylvan
6f103b2db2 feat: refactor Gemini region logic into getGeminiRegion method
### CHANGES

- Extract `getGeminiRegion` method for region determination
- Use `getGeminiRegion` in `sendGemini` for location setting
- Apply `getGeminiRegion` in `sendStreamGemini` for consistency
2026-01-08 11:19:31 -08:00
Kayvan Sylvan
19aeebe6f5 refactor: extract fetchModelsPage in Vertex AI to improve pagination
- Extract model fetching logic into a dedicated helper function.
- Improve response body cleanup during Vertex AI pagination loops.
- Remove unused time import and timeout constant from models.
- Streamline listPublisherModels function by delegating API requests to helper.
2026-01-08 11:16:25 -08:00
Kayvan Sylvan
2d79d3b706 chore: format fixes 2026-01-08 10:56:56 -08:00
Henri Cook
2501cbf47e feat(vertexai): add dynamic model listing and multi-model support
- Dynamic model listing from Vertex AI Model Garden API
- Support for both Gemini (genai SDK) and Claude (Anthropic SDK) models
- Curated Gemini model list (no API available to list them)
- Web search support for Gemini models
- Thinking/extended thinking support for Gemini
- TopP parameter support for Claude models
- Model filtering (excludes imagen, embeddings, legacy models)
- Model sorting (Gemini > Claude > DeepSeek > Llama > Mistral > Others)
2026-01-08 17:24:19 +00:00
Kayvan Sylvan
b381bae24a Merge pull request #1915 from majiayu000/fix-1842-feature-request-parallelize-au-0101-2335
feat: parallelize audio chunk transcription for improved performance
2026-01-04 13:04:56 -08:00
Kayvan Sylvan
0776e77872 Merge branch 'main' into fix-1910-bug-rest-api-chat-endpoint-doe-0101-2307 2026-01-03 17:09:28 -08:00
Kayvan Sylvan
cb2759a5a1 Merge branch 'main' into fix-1842-feature-request-parallelize-au-0101-2335 2026-01-03 17:05:14 -08:00
majiayu000
8a28ca7b1e feat: parallelize audio chunk transcription using goroutines
Signed-off-by: majiayu000 <1835304752@qq.com>
2026-01-01 23:38:32 +08:00
majiayu000
6ea5551f06 fix: pass Search and SearchLocation parameters to ChatOptions in /chat endpoint
Signed-off-by: majiayu000 <1835304752@qq.com>
2026-01-01 23:09:30 +08:00
berniegreen
b04346008b fix: add missing newline to end of chatter_test.go 2025-12-31 16:59:30 -06:00
berniegreen
c7ecac3262 test: add test for metadata stream propagation 2025-12-31 15:56:20 -06:00
berniegreen
8166ee7a18 docs: update swagger documentation and fix dryrun tests 2025-12-31 15:13:20 -06:00
berniegreen
c539b1edfc feat: implement REST API support for metadata streaming (Phase 5) 2025-12-31 12:43:48 -06:00
berniegreen
66d3bf786e feat: implement CLI support for metadata display (Phase 4) 2025-12-31 12:41:06 -06:00
berniegreen
569f50179d refactor: implement structured streaming in all AI vendors (Phase 3) 2025-12-31 12:38:38 -06:00