-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathget_workflow.ts
More file actions
123 lines (113 loc) · 3.36 KB
/
Copy pathget_workflow.ts
File metadata and controls
123 lines (113 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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,
},
}