Files
simstudioai--sim/apps/sim/tools/github/get_workflow.ts
T
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

124 lines
3.4 KiB
TypeScript

import type { GetWorkflowParams, WorkflowResponse } from '@/tools/github/types'
import { WORKFLOW_OUTPUT_PROPERTIES } from '@/tools/github/types'
import type { ToolConfig } from '@/tools/types'
export const getWorkflowTool: ToolConfig<GetWorkflowParams, WorkflowResponse> = {
id: 'github_get_workflow',
name: 'GitHub Get Workflow',
description:
'Get details of a specific GitHub Actions workflow by ID or filename. Returns workflow information including name, path, state, and badge URL.',
version: '1.0.0',
params: {
owner: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Repository owner (user or organization)',
},
repo: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Repository name',
},
workflow_id: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Workflow ID (number) or workflow filename (e.g., "main.yaml")',
},
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'GitHub Personal Access Token',
},
},
request: {
url: (params) =>
`https://api.github.com/repos/${params.owner}/${params.repo}/actions/workflows/${params.workflow_id}`,
method: 'GET',
headers: (params) => ({
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${params.apiKey}`,
'X-GitHub-Api-Version': '2022-11-28',
}),
},
transformResponse: async (response) => {
const data = await response.json()
const content = `Workflow: ${data.name}
State: ${data.state}
Path: ${data.path}
ID: ${data.id}
Badge URL: ${data.badge_url}
Created: ${data.created_at}
Updated: ${data.updated_at}`
return {
success: true,
output: {
content,
metadata: {
id: data.id,
name: data.name,
path: data.path,
state: data.state,
badge_url: data.badge_url,
},
},
}
},
outputs: {
content: { type: 'string', description: 'Human-readable workflow details' },
metadata: {
type: 'object',
description: 'Workflow metadata',
properties: {
id: { type: 'number', description: 'Workflow ID' },
name: { type: 'string', description: 'Workflow name' },
path: { type: 'string', description: 'Path to workflow file' },
state: { type: 'string', description: 'Workflow state (active/disabled)' },
badge_url: { type: 'string', description: 'Badge URL for workflow' },
},
},
},
}
export const getWorkflowV2Tool: ToolConfig<GetWorkflowParams, any> = {
id: 'github_get_workflow_v2',
name: getWorkflowTool.name,
description: getWorkflowTool.description,
version: '2.0.0',
params: getWorkflowTool.params,
request: getWorkflowTool.request,
transformResponse: async (response: Response) => {
const data = await response.json()
return {
success: true,
output: {
id: data.id,
node_id: data.node_id,
name: data.name,
path: data.path,
state: data.state,
html_url: data.html_url,
badge_url: data.badge_url,
url: data.url,
created_at: data.created_at,
updated_at: data.updated_at,
deleted_at: data.deleted_at ?? null,
},
}
},
outputs: {
...WORKFLOW_OUTPUT_PROPERTIES,
},
}