feat: add REST API with OpenAPI 3.1 spec#249
Open
pkonowrocki wants to merge 6 commits intosipeed:mainfrom
Open
feat: add REST API with OpenAPI 3.1 spec#249pkonowrocki wants to merge 6 commits intosipeed:mainfrom
pkonowrocki wants to merge 6 commits intosipeed:mainfrom
Conversation
…story Addresses two bugs causing invalid message ordering: 1. Atomic message saving: moves all session saves to after successful LLM completion, preventing orphaned user messages when LLM calls fail. 2. Comprehensive history sanitization: replaces partial tool-message stripping with sanitizeHistory() that handles leading non-user messages, consecutive user messages, orphaned tool results, and trailing incomplete tool-call sequences. 3. Smart truncation: TruncateHistory now scans forward to find the nearest user message boundary, preventing summarization from creating invalid mid-sequence starting points.
Adds opt-in distributed tracing via OTLP/gRPC exporter: - New pkg/tracing package with Init/Shutdown lifecycle - TracingConfig in config.go (enabled + endpoint fields) - Spans for agent.processMessage, agent.llm.call, agent.tool.execute, and provider.chat with relevant attributes - Jaeger all-in-one service in docker-compose.yml (tracing profile) - Tracing initialization in both agentCmd and gatewayCmd
Merges upstream changes (LINE/OneBot channels, GitHub Copilot provider, device monitoring, DuckDuckGo search, I2C/SPI tools, embedded workspace) while preserving our additions (tracing, atomic saves, sanitizeHistory, key rotation, smart truncation). Conflict resolutions: - config.go: keep both Tracing and Devices configs, merge ProviderConfig fields (APIKeys + ConnectMode) - http_provider.go: keep our retry/backoff logic over upstream's simpler error path - manager_test.go: keep both test sets (truncation + filename sanitization) - go.mod/go.sum: merge both dependency sets
historyOffset was computed from len(history) before sanitization, but BuildMessages runs sanitizeHistory which can remove messages. This caused a slice bounds out of range panic when the sanitized history was shorter than the original. Fix: compute offset from actual messages slice length instead.
Add webhook/REST API with bearer token auth, chat endpoint, session listing, health check, and embedded OpenAPI spec serving. Includes auth middleware, request validation, and comprehensive tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
@Zepan This PR adds a REST API with OpenAPI 3.1 spec (+1542/-114). While a REST API could be valuable for programmatic access, it's not currently on the roadmap board. Consideration: This adds an HTTP server to a project designed for <10MB RAM on $10 hardware. The memory and attack surface implications should be evaluated carefully. Also, MCP support (#290, priority: high) may provide a more standard integration protocol for the same use cases. Recommendation: Defer. Not on the roadmap, and MCP (#282) may be a better fit for the extensibility story. Worth revisiting after MCP lands. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/chat(POST),/api/sessions(GET),/api/health(GET),/api/openapi.yaml(GET)Authorizationheader with configurable API key/api/openapi.yamlAPIConfigstruct,GetSessionManager()accessor, andListSessions()methodTest plan
curl -H "Authorization: Bearer <key>" -d '{"message":"hi"}' localhost:18790/api/chat