Repository navigation
feat(ai): add Muse (Meta Model API) provider - #1586
Merged
Merged
Conversation
nguyenvantruc92
force-pushed
the
feat/ai-muse
branch
3 times, most recently
from
October 31, 2026 05:39
f7d9ac6 to
9907eb1
Compare
Adds Muse (Meta Model API) as an AI provider: a Muse integration in workspace settings, Muse models for the flow AI steps, and Muse voice transcribe as a Speech to Text provider. Muse voice transcribe provider for Speech to Text Muse accepts only WAV (PCM 16-bit, mono, 16/24 kHz, at most 10 min, request at most 32 MB). The step checks the RIFF header and sends any other file (ogg voice notes, mp3, stereo, 44.1 kHz) to the error branch. Nothing is converted, because the heavy worker has no ffmpeg. - The flow-config schema becomes a provider union (openai | muse). The Muse branch adds languageBias and keywords; OpenAI steps reject both. - The heavy worker gets a Muse transcription client, MUSE_TRANSCRIBE_* env limits and a per-provider attempt budget. The budget sizes the completion deadline, the fallback resume and the heavy lock (10 min); the outcome TTL now outlives that deadline. - The heavy job id is sent as Meta's sessionId and stays the same across BullMQ retries. - A malformed transcribe response is not retried, and only transcript is required in the response schema. - No content-type allowlist: inspectMuseWav decides, so WAV served as binary/octet-stream or without a header is accepted. - Builder: a Muse Speech to Text menu entry, a provider-aware dialog with a WAV format note, and i18n strings in all 21 locales. Muse request shaping - Muse counts reasoning against max_tokens, so the provider adds 1024 tokens of headroom: without it Spark 1.3/1.2 return empty replies at an agent budget of 100 and the 128-token handoff classifier never fits its tool call. maxOutputTokens is therefore the reply-text budget for Muse; the API descriptions say the extra reasoning tokens are billed. - Muse temperature is at most 1 (at 2 it returns empty replies or 500s). The Generate Text and Analyze Image step schemas reject a higher value, the step dialog caps the input, and the provider still clamps agents. - Muse accepts only tool_choice "auto". A named or "required" choice becomes "auto" and "none" drops the tools; before this the handoff re-entry classifier got a 400 on every Muse model. Heavy step outcome - Heavy step results move from one outputValue to outputValues[] plus a skip status; the Redis outcome records resultStatus so a retried skip still resumes through skip. - outputValues are stored on the outcome when the write is claimed; a retry after a partial write replays them instead of calling the provider again (no double billing, no re-reading an overwritten input field). STALE_WRITE_MS is 10s so speech retries (15s backoff) also replay; the resume lease keeps its own 30s constant. - A fresh write lease held by another attempt returns "busy" instead of "writing", which let two attempts write the same fields. AI agent replies - textStream concatenates every step's text, so text a model writes before a tool call ran into the reply after the tool result. The text is rebuilt from result.stream with a paragraph break between steps, so each step is sent as its own message. - AI Action set_custom_field ids are opaque createId() values, so the model left `values` empty unless the When text spelled out what to save. The tool description now names the custom field behind each value action. The AI Segment Image step (SAM 3.1) and @meta-sam/parser (SAM License) are not part of this change; they are kept on a separate branch until Meta confirms the license. Deploy the worker before the builder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nguyenvantruc92
force-pushed
the
feat/ai-muse
branch
from
October 31, 2026 09:50
599156e to
58a7e52
Compare
hello-jackytruong
referenced
this pull request
in hello-jackytruong/ChatWorkAI
Nov 22, 2026
Adds Muse (Meta Model API) as an AI provider: a Muse integration in workspace settings, Muse models for the flow AI steps, and Muse voice transcribe as a Speech to Text provider. Muse voice transcribe provider for Speech to Text Muse accepts only WAV (PCM 16-bit, mono, 16/24 kHz, at most 10 min, request at most 32 MB). The step checks the RIFF header and sends any other file (ogg voice notes, mp3, stereo, 44.1 kHz) to the error branch. Nothing is converted, because the heavy worker has no ffmpeg. - The flow-config schema becomes a provider union (openai | muse). The Muse branch adds languageBias and keywords; OpenAI steps reject both. - The heavy worker gets a Muse transcription client, MUSE_TRANSCRIBE_* env limits and a per-provider attempt budget. The budget sizes the completion deadline, the fallback resume and the heavy lock (10 min); the outcome TTL now outlives that deadline. - The heavy job id is sent as Meta's sessionId and stays the same across BullMQ retries. - A malformed transcribe response is not retried, and only transcript is required in the response schema. - No content-type allowlist: inspectMuseWav decides, so WAV served as binary/octet-stream or without a header is accepted. - Builder: a Muse Speech to Text menu entry, a provider-aware dialog with a WAV format note, and i18n strings in all 21 locales. Muse request shaping - Muse counts reasoning against max_tokens, so the provider adds 1024 tokens of headroom: without it Spark 1.3/1.2 return empty replies at an agent budget of 100 and the 128-token handoff classifier never fits its tool call. maxOutputTokens is therefore the reply-text budget for Muse; the API descriptions say the extra reasoning tokens are billed. - Muse temperature is at most 1 (at 2 it returns empty replies or 500s). The Generate Text and Analyze Image step schemas reject a higher value, the step dialog caps the input, and the provider still clamps agents. - Muse accepts only tool_choice "auto". A named or "required" choice becomes "auto" and "none" drops the tools; before this the handoff re-entry classifier got a 400 on every Muse model. Heavy step outcome - Heavy step results move from one outputValue to outputValues[] plus a skip status; the Redis outcome records resultStatus so a retried skip still resumes through skip. - outputValues are stored on the outcome when the write is claimed; a retry after a partial write replays them instead of calling the provider again (no double billing, no re-reading an overwritten input field). STALE_WRITE_MS is 10s so speech retries (15s backoff) also replay; the resume lease keeps its own 30s constant. - A fresh write lease held by another attempt returns "busy" instead of "writing", which let two attempts write the same fields. AI agent replies - textStream concatenates every step's text, so text a model writes before a tool call ran into the reply after the tool result. The text is rebuilt from result.stream with a paragraph break between steps, so each step is sent as its own message. - AI Action set_custom_field ids are opaque createId() values, so the model left `values` empty unless the When text spelled out what to save. The tool description now names the custom field behind each value action. The AI Segment Image step (SAM 3.1) and @meta-sam/parser (SAM License) are not part of this change; they are kept on a separate branch until Meta confirms the license. Deploy the worker before the builder. Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Adds Muse (Meta Model API,
https://api.meta.ai/v1) as an AI provider. A workspace connects it with an API key, like Claude, DeepSeek and Gemini.Muse can be used in:
This PR also fixes two bugs that affect all providers:
Deploy
Deploy the worker before the builder. Once the builder is out, users can connect Muse and save Muse steps, and an older worker cannot run them.
Changes
Muse provider
packages/ai:createMuse, built on@ai-sdk/openai-compatible. Each request is adjusted for Muse:reasoning_effortisminimalbelow 1024 tokens, otherwiselow.max_tokensfor reasoning, so short replies do not come back empty.temperatureis capped at 1.tool_choice: "auto". A forced choice becomesauto, andnoneremoves the tools.muse-spark-1.3(default),muse-spark-1.2,muse-wonder-1.0(preview) andmuse-image-1.0.packages/database: newIntegrationMusetable (migration20261027162148_add_integration_muse, new table only).museis added tointegrationTypesandaiAgentProviders.packages/business: connect, update and disconnect; API key check againstGET /v1/models; cleanup when a workspace is deleted. Defaults aremuse-spark-1.3and 4096 tokens.packages/connections: Muse can be connected withPOST /v1/connections. The old/v1/integrations/ai/{provider}routes also acceptmuse.packages/flow-config: Muse is added to the AI step providers. Generate text and analyze image reject a Muse temperature above 1.apps/builder: settings pagesettings/integrations/muse, Muse in the model selects and the perform-action menu, and strings in all 21 locales.Muse images
heavy/handlers/channel-safe-image.ts).Speech to Text with Muse
Muse accepts only WAV: PCM 16-bit, mono, 16 or 24 kHz, at most 10 minutes. Anything else (Ogg voice notes, mp3, stereo, 44.1 kHz) goes to the error branch. Nothing is converted, because the heavy worker has no ffmpeg.
openai|muse). Muse steps can setlanguageBiasandkeywords.packages/ai/src/server/muse-transcribe.ts: the transcription client. It checks the WAV header, not the content type.MUSE_TRANSCRIBE_MAX_AUDIO_BYTES(default 32 MiB − 64 KiB) andMUSE_TRANSCRIBE_TIMEOUT_MS(default 9 minutes). The heavy worker lock and the step deadline grow to fit them.sessionId, so every retry of one step run uses the same session.Test plan
turbo check-typespnpm lint(includesdb:check-drift)