Repository navigation
feat(flows): implement AI Segment Image step (SAM 3.1) - #1611
Merged
Merged
Conversation
nguyenvantruc92
force-pushed
the
feat/ai-segment-image-sam
branch
from
November 1, 2026 03:48
7ca09f3 to
7502882
Compare
Adds the `aiSegmentImage` flow step: it finds an object in a contact's
image with SAM 3.1 on the workspace Muse (Meta Model API) integration and
saves a cropped image, routing Found / Not found / Failed.
- packages/ai (`@chatbotx.io/ai/sam`, worker-only): streams `/v1/responses`
and reads only boxes from the output text, parsed against the grammar Meta
publishes for writing your own parser (dev.meta.ai/docs/sam). Mask tokens
are skipped, so no SAM-licensed package is used. Inclusive x2/y2 become
half-open bounds, the frame must match the source image, confidence comes
from include_confidence (an unreadable one is dropped, not fatal), and
failures carry retryable/status for the heavy retry policy. HTTP and
in-stream errors keep Meta's reason through the Muse error helpers shared
with muse-transcribe (`muse-errors.ts`); only server_error and
rate_limit_exceeded retry after HTTP 200. A completion without a streamed
text lane is read from its own output and fails loudly when it has none.
- flow-config/worker-config: step schema (target, largest/all, output and
optional details fields) and the `aiSegmentImage` heavy job.
- worker: downloads and normalizes the image, calls SAM, crops the largest
box or the area covering all boxes with sharp from the source pixels, and
uploads it channel-safe like edit-image (JPEG, PNG only for real
transparency, bounded by HEAVY_MAX_IMAGE_BYTES) under the heavy job id,
then writes `{ count, boxes, crop, source }` details.
- builder: step editor/viewer under Muse AI actions, copy in all locales.
- tests; fixtures are hand-written streams plus ChatbotX's own live
captures.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
nguyenvantruc92
force-pushed
the
feat/ai-segment-image-sam
branch
from
November 1, 2026 03:53
7502882 to
d00bb2f
Compare
hello-jackytruong
referenced
this pull request
in hello-jackytruong/ChatWorkAI
Nov 22, 2026
Adds the `aiSegmentImage` flow step: it finds an object in a contact's
image with SAM 3.1 on the workspace Muse (Meta Model API) integration and
saves a cropped image, routing Found / Not found / Failed.
- packages/ai (`@chatbotx.io/ai/sam`, worker-only): streams `/v1/responses`
and reads only boxes from the output text, parsed against the grammar Meta
publishes for writing your own parser (dev.meta.ai/docs/sam). Mask tokens
are skipped, so no SAM-licensed package is used. Inclusive x2/y2 become
half-open bounds, the frame must match the source image, confidence comes
from include_confidence (an unreadable one is dropped, not fatal), and
failures carry retryable/status for the heavy retry policy. HTTP and
in-stream errors keep Meta's reason through the Muse error helpers shared
with muse-transcribe (`muse-errors.ts`); only server_error and
rate_limit_exceeded retry after HTTP 200. A completion without a streamed
text lane is read from its own output and fails loudly when it has none.
- flow-config/worker-config: step schema (target, largest/all, output and
optional details fields) and the `aiSegmentImage` heavy job.
- worker: downloads and normalizes the image, calls SAM, crops the largest
box or the area covering all boxes with sharp from the source pixels, and
uploads it channel-safe like edit-image (JPEG, PNG only for real
transparency, bounded by HEAVY_MAX_IMAGE_BYTES) under the heavy job id,
then writes `{ count, boxes, crop, source }` details.
- builder: step editor/viewer under Muse AI actions, copy in all locales.
- tests; fixtures are hand-written streams plus ChatbotX's own live
captures.
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.
Adds the
aiSegmentImageflow step: it finds an object in a contact's image with SAM 3.1 on the workspace Muse (Meta Model API) integration and saves a cropped PNG, routing Found / Not found / Failed.@chatbotx.io/ai/sam, worker-only): streams/v1/responsesand reads only boxes from the output text, parsed against the grammar Meta publishes for writing your own parser (dev.meta.ai/docs/sam). Mask tokens are skipped, so no SAM-licensed package is used. Inclusive x2/y2 become half-open bounds, the frame must match the source image, confidence comes from include_confidence, and failures carry retryable/status for the heavy retry policy.aiSegmentImageheavy job.{ count, boxes, crop, source }details.