MCPcopy Index your code
hub / github.com/simstudioai/sim / openPullRequest

Function openPullRequest

apps/sim/executor/handlers/pi/cloud-backend.ts:147–181  ·  view source on GitHub ↗
(
  params: PiCloudRunParams,
  branch: string,
  detectedBase: string | undefined,
  totals: PiRunTotals
)

Source from the content-addressed store, hash-verified

145}
146
147async function openPullRequest(
148 params: PiCloudRunParams,
149 branch: string,
150 detectedBase: string | undefined,
151 totals: PiRunTotals
152): Promise<string | undefined> {
153 const base = params.baseBranch?.trim() || detectedBase
154 if (!base) {
155 throw new Error(
156 `Branch ${branch} pushed, but the base branch could not be determined — set "Base Branch" on the block and re-run.`
157 )
158 }
159 const title = defaultTitle(params)
160 const body = params.prBody?.trim() || buildPrBody(params.task, totals.finalText)
161
162 const result = await executeTool('github_create_pr', {
163 owner: params.owner,
164 repo: params.repo,
165 title,
166 head: branch,
167 base,
168 body,
169 draft: params.draft,
170 apiKey: params.githubToken,
171 })
172
173 if (!result.success) {
174 throw new Error(
175 `Branch ${branch} pushed but PR creation failed: ${result.error ?? 'unknown error'}`
176 )
177 }
178
179 const output = result.output as { metadata?: { html_url?: string } } | undefined
180 return output?.metadata?.html_url
181}
182
183export const runCloudPi: PiBackendRun<PiCloudRunParams> = async (params, context) => {
184 if (!params.isBYOK) {

Callers 1

runCloudPiFunction · 0.85

Calls 3

executeToolFunction · 0.90
defaultTitleFunction · 0.85
buildPrBodyFunction · 0.85

Tested by

no test coverage detected