d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
139 lines
3.7 KiB
TypeScript
139 lines
3.7 KiB
TypeScript
import type { AddLabelsParams, LabelsResponse } from '@/tools/github/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const addLabelsTool: ToolConfig<AddLabelsParams, LabelsResponse> = {
|
|
id: 'github_add_labels',
|
|
name: 'GitHub Add Labels',
|
|
description: 'Add labels to an issue in a GitHub repository',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
owner: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Repository owner',
|
|
},
|
|
repo: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Repository name',
|
|
},
|
|
issue_number: {
|
|
type: 'number',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Issue number',
|
|
},
|
|
labels: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Comma-separated list of label names to add to the issue',
|
|
},
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'GitHub API token',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) =>
|
|
`https://api.github.com/repos/${params.owner}/${params.repo}/issues/${params.issue_number}/labels`,
|
|
method: 'POST',
|
|
headers: (params) => ({
|
|
Accept: 'application/vnd.github.v3+json',
|
|
Authorization: `Bearer ${params.apiKey}`,
|
|
'X-GitHub-Api-Version': '2022-11-28',
|
|
}),
|
|
body: (params) => {
|
|
const labelsArray = params.labels
|
|
.split(',')
|
|
.map((l) => l.trim())
|
|
.filter((l) => l)
|
|
return {
|
|
labels: labelsArray,
|
|
}
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response, params) => {
|
|
const labelsData = await response.json()
|
|
|
|
const labels = labelsData.map((label: any) => label.name)
|
|
|
|
const content = `Labels added to issue successfully!
|
|
All labels on issue: ${labels.join(', ')}`
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
content,
|
|
metadata: {
|
|
labels,
|
|
issue_number: params?.issue_number ?? 0,
|
|
html_url: params
|
|
? `https://github.com/${params.owner}/${params.repo}/issues/${params.issue_number}`
|
|
: '',
|
|
},
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
content: { type: 'string', description: 'Human-readable labels confirmation' },
|
|
metadata: {
|
|
type: 'object',
|
|
description: 'Labels metadata',
|
|
properties: {
|
|
labels: { type: 'array', description: 'All labels currently on the issue' },
|
|
issue_number: { type: 'number', description: 'Issue number' },
|
|
html_url: { type: 'string', description: 'GitHub issue URL' },
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
export const addLabelsV2Tool: ToolConfig<AddLabelsParams, any> = {
|
|
id: 'github_add_labels_v2',
|
|
name: addLabelsTool.name,
|
|
description: addLabelsTool.description,
|
|
version: '2.0.0',
|
|
params: addLabelsTool.params,
|
|
request: addLabelsTool.request,
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const labels = await response.json()
|
|
return {
|
|
success: true,
|
|
output: {
|
|
items: labels.map((label: any) => ({
|
|
...label,
|
|
description: label.description ?? null,
|
|
})),
|
|
count: labels.length,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
items: {
|
|
type: 'array',
|
|
description: 'Array of label objects on the issue',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'number', description: 'Label ID' },
|
|
name: { type: 'string', description: 'Label name' },
|
|
color: { type: 'string', description: 'Label color' },
|
|
description: { type: 'string', description: 'Label description', optional: true },
|
|
},
|
|
},
|
|
},
|
|
count: { type: 'number', description: 'Number of labels' },
|
|
},
|
|
}
|