-
Notifications
You must be signed in to change notification settings - Fork 3.4k
improvement(mothership): add file patch tool #3712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sg312
wants to merge
25
commits into
staging
Choose a base branch
from
improvement/mothership-file-patches
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,290
−133
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
704d06f
v0
Sg312 8abb884
Fix ppt load
Sg312 b28556f
Fixes
Sg312 dde64aa
Fixes
Sg312 4a537ff
Fix lint
Sg312 aa9fc10
Fix wid
Sg312 5954abd
Download image
Sg312 77a4f2f
Update tools
Sg312 d071248
Fix lint
Sg312 844c9a2
Fix error msg
Sg312 46e8964
Tool fixes
Sg312 6549a50
Reenable subagent stream
Sg312 98f4dfd
Subagent stream
Sg312 1e7a987
Fix edit workflow hydration
Sg312 0b3000a
Throw func execute error on error
Sg312 e21a987
Sandbox PPTX generation in subprocess with vm.createContext
waleedlatif1 cc50d1e
upgrade deps, file viewer
waleedlatif1 119d5a5
Fix auth bypass, SSRF, and wrong size limit comment
waleedlatif1 cc214cd
Fix Buffer not assignable to BodyInit in preview route
waleedlatif1 c5f73a7
Fix SSRF bypass, IPv6 coverage, download size cap, and missing deps
waleedlatif1 ad2dab1
Replace hand-rolled SSRF guard with secureFetchWithValidation
waleedlatif1 51b47f1
Fix streaming preview cache ordering and patch ambiguity
waleedlatif1 7ab98e2
Fix subprocess env leak, unbounded preview spawning, and dead code
waleedlatif1 6ffb4b9
Wire abort signal through to subprocess and correct security comment
waleedlatif1 5de3616
Remove implementation-specific comments from pptx worker files
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { createLogger } from '@sim/logger' | ||
| import { type NextRequest, NextResponse } from 'next/server' | ||
| import { getSession } from '@/lib/auth' | ||
| import { generatePptxFromCode } from '@/lib/execution/pptx-vm' | ||
| import { verifyWorkspaceMembership } from '@/app/api/workflows/utils' | ||
|
|
||
| export const dynamic = 'force-dynamic' | ||
| export const runtime = 'nodejs' | ||
|
|
||
| const logger = createLogger('PptxPreviewAPI') | ||
|
|
||
| /** | ||
| * POST /api/workspaces/[id]/pptx/preview | ||
| * Compile PptxGenJS source code and return the binary PPTX for streaming preview. | ||
| */ | ||
| export async function POST(req: NextRequest, { params }: { params: Promise<{ id: string }> }) { | ||
| const { id: workspaceId } = await params | ||
|
|
||
| try { | ||
| const session = await getSession() | ||
| if (!session?.user?.id) { | ||
| return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) | ||
| } | ||
|
|
||
| const membership = await verifyWorkspaceMembership(session.user.id, workspaceId) | ||
| if (!membership) { | ||
| return NextResponse.json({ error: 'Insufficient permissions' }, { status: 403 }) | ||
| } | ||
|
|
||
| const body = await req.json() | ||
| const { code } = body as { code?: string } | ||
|
|
||
| if (typeof code !== 'string' || code.trim().length === 0) { | ||
| return NextResponse.json({ error: 'code is required' }, { status: 400 }) | ||
| } | ||
|
|
||
| const buffer = await generatePptxFromCode(code, workspaceId, req.signal) | ||
|
|
||
| return new NextResponse(new Uint8Array(buffer), { | ||
| status: 200, | ||
| headers: { | ||
| 'Content-Type': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', | ||
| 'Content-Length': String(buffer.length), | ||
| 'Cache-Control': 'private, no-store', | ||
| }, | ||
| }) | ||
| } catch (err) { | ||
| const message = err instanceof Error ? err.message : 'PPTX generation failed' | ||
| logger.error('PPTX preview generation failed', { error: message, workspaceId }) | ||
| return NextResponse.json({ error: message }, { status: 500 }) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.