Ai tools scope public apis - #1150
Merged
Merged
Conversation
…ctions, ai-mcp-servers Removes the ai-triggers feature end to end (schema, repository, relations, service, UI, actions) since it has been superseded, and drops its AITrigger/AITriggerToIntegrationOpenai tables via a new migration. Adds workspace-token endpoints under existing scopes for AI files (create, list, delete — including SSRF-checked URL ingestion), AI functions (CRUD + duplicate), and AI MCP servers (CRUD), following the established pattern: each handler delegates to the same packages/business service method the private UI action already calls. Also adds Facebook/Instagram comment moderation service methods (edit, delete, change-attributes) consumed by the existing messages public API, and extracts ai-file/ai-function/ai-mcp-server data access out of the app layer into new business services. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… scoping Phase 1: fixes two of PR #1150's own failing tests — the SSRF test asserted uploadFileFromUrl's callback was called directly instead of invoking the captured validate callback, and ai-function's create test needed a name-free mock now that create pre-checks isNameTaken. Adds coverage for the isNameTaken skip-on-tx path. Phase 2: fixes three defects in the URL-ingestion upload path — recorded size now comes from the real streamed byte count (buffer.byteLength) instead of the origin's self-reported content-length, which can under-report and send a mismatched ContentLength to S3; infrastructure failures (storage outage, network error) now surface as a generic 502 with server-side logging instead of a 400 that echoed internal error text (e.g. connect ECONNREFUSED ...) and the raw SSRF-guard message (which echoed the submitted URL) verbatim to any automation-token holder; and the public create schema now rejects a payload carrying both `file` and `url` instead of silently dropping one via z.union's first-match resolution. Phase 3: closes test gaps around properties that were already correct but unguarded — MCP auth secret redaction through the real publicAIMcpServerResource schema, upload.ts's byte-cap/redirect logic via a mocked fetch, cross-workspace isolation for ai-mcp-server and ai-function update/delete, and the create-ai-file action's noEmbeddingProvider translation branch (lost when the old action test was deleted). Phase 5 nit: aligns ai-function's update/delete to scope by {workspaceId, id} instead of bare id, matching ai-mcp-server's pattern, for defense in depth. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
apps/worker's bounded-download.ts and packages/filesystem's upload.ts each carried a near-verbatim copy of the byte-limited body reader and the manual-redirect-with-re-validation loop — the worker copy already had test coverage, and the filesystem copy is what introduced the ContentLength bug fixed in the previous commit. Extracts both into a shared packages/filesystem/src/lib/bounded-fetch.ts, parameterized over the caller's own error type (UploadValidationError vs ExpectedHeavyStepError) and fetch implementation (platform fetch vs ky, so the worker keeps its abort-signal/ timeout support), so both call sites stay behaviorally identical without a second implementation to drift. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…unded-fetch cap Actions for ai-functions/ai-mcp-servers now call the service and catch validationException instead of pre-checking name uniqueness, so create/update race conditions surface as a proper conflict instead of a lost check. Service methods drop the optional TranslationFn param and throw plain-English errors, letting both the app layer and the public API share one error path. The MCP server delete public API now checks the deleted-rows result and 404s when nothing matched. readBodyWithLimit also enforces the byte cap when a response has no body stream, closing a bypass in uploadFileFromUrl.
…gerIds column listAIFunctions was missing the chatbot access check present on sibling ai-* queries. aiTriggerIds became dead weight after ai-triggers retirement in cddb767; drop the column and its schema-default-parity exception.
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.
No description provided.