mirror of
https://github.com/simstudioai/sim.git
synced 2026-10-30 19:32:46 +08:00
* feat(integrations): add Bitbucket Cloud * fix(bitbucket): enforce selector workspace slugs * fix(bitbucket): overfetch small pipeline log tails * fix(bitbucket): harden provider edge cases * fix(bitbucket): accept provider diff redirect specs * fix(bitbucket): stop advanced-field leakage and harden log, status, and selector paths Splits the `closeSourceBranch` advanced subBlock into per-operation ids. Advanced fields serialize without evaluating their condition, so a value set on Create Pull Request reached Merge Pull Request and closed the source branch unprompted. Also: - read step logs through the byte-capped server transport and map an empty-log 416 to an empty result, keeping a genuine 416 an error - trim a step log's partial leading line after the character cap rather than before, and never return an empty log when the retained window held content - surface Bitbucket's `error.detail` alongside `error.message` - treat commit-status `key`/`state` as nullable so one malformed row cannot drop a page - match repository `full_name` case-insensitively and reject dot segments in a workspace slug before the outbound request - type `reviewerAccountIds` as the comma-separated string it is - trim optional Bitbucket query strings; correct the token lifetime to two hours --------- Co-authored-by: Bill Leoutsakos <billleoutsakos@Bills-MacBook-Pro.local> Co-authored-by: Waleed Latif <walif6@gmail.com>
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import {
|
|
BITBUCKET_COMMENT_OUTPUT_PROPERTIES,
|
|
type BitbucketComment,
|
|
type BitbucketCreatePullRequestCommentParams,
|
|
type BitbucketToolResponse,
|
|
} from '@/tools/bitbucket/types'
|
|
import {
|
|
BITBUCKET_API_BASE,
|
|
BITBUCKET_ERROR_EXTRACTOR,
|
|
BITBUCKET_PULL_REQUEST_PARAMS,
|
|
bitbucketHeaders,
|
|
bitbucketJson,
|
|
bitbucketPullRequestPath,
|
|
normalizeBitbucketComment,
|
|
} from '@/tools/bitbucket/utils'
|
|
import { requireBitbucketPositiveInteger } from '@/tools/bitbucket/validation'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const bitbucketCreatePullRequestCommentTool: ToolConfig<
|
|
BitbucketCreatePullRequestCommentParams,
|
|
BitbucketToolResponse<{ comment: BitbucketComment }>
|
|
> = {
|
|
id: 'bitbucket_create_pull_request_comment',
|
|
name: 'Bitbucket Create Pull Request Comment',
|
|
description: 'Create a global comment or reply on a pull request',
|
|
version: '1.0.0',
|
|
oauth: { required: true, provider: 'bitbucket', requiredScopes: ['pullrequest'] },
|
|
params: {
|
|
...BITBUCKET_PULL_REQUEST_PARAMS,
|
|
content: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Raw comment content',
|
|
},
|
|
parentId: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Parent comment ID when creating a reply',
|
|
},
|
|
},
|
|
request: {
|
|
url: (params) =>
|
|
`${BITBUCKET_API_BASE}${bitbucketPullRequestPath(params.workspaceSlug, params.repoSlug, params.prId)}/comments`,
|
|
method: 'POST',
|
|
headers: (params) => bitbucketHeaders(params.accessToken, { json: true }),
|
|
body: (params) => {
|
|
if (typeof params.content !== 'string' || params.content.trim().length === 0) {
|
|
throw new Error('content must be a non-empty string')
|
|
}
|
|
return {
|
|
content: { raw: params.content },
|
|
...(params.parentId !== undefined
|
|
? { parent: { id: requireBitbucketPositiveInteger(params.parentId, 'parentId') } }
|
|
: {}),
|
|
}
|
|
},
|
|
},
|
|
transformResponse: async (response) => ({
|
|
success: true,
|
|
output: { comment: normalizeBitbucketComment(await bitbucketJson(response)) },
|
|
}),
|
|
outputs: {
|
|
comment: {
|
|
type: 'object',
|
|
description: 'Created comment',
|
|
properties: BITBUCKET_COMMENT_OUTPUT_PROPERTIES,
|
|
},
|
|
},
|
|
errorExtractor: BITBUCKET_ERROR_EXTRACTOR,
|
|
}
|