@@ -46,6 +46,14 @@ export async function deployAgent(inputs: ActionInputs): Promise<DeploymentResul
4646 result = await deployFileAgent ( client , agentName , inputs ) ;
4747 break ;
4848
49+ case 'npm' :
50+ result = await deployNpmAgent ( client , agentName , inputs ) ;
51+ break ;
52+
53+ case 'pip' :
54+ result = await deployPipAgent ( client , agentName , inputs ) ;
55+ break ;
56+
4957 default : {
5058 // Exhaustiveness check - this should never happen
5159 const exhaustiveCheck : never = inputs . sourceType ;
@@ -186,3 +194,87 @@ async function deployFileAgent(
186194 objectId : uploadResult . objectId ,
187195 } ;
188196}
197+
198+ /**
199+ * Deploy an agent from an NPM package.
200+ */
201+ async function deployNpmAgent (
202+ client : RunloopSDK ,
203+ agentName : string ,
204+ inputs : ActionInputs
205+ ) : Promise < DeploymentResult > {
206+ core . info ( 'Deploying NPM agent...' ) ;
207+
208+ if ( ! inputs . npmPackage ) {
209+ throw new Error ( 'npm-package is required for npm agent deployment' ) ;
210+ }
211+
212+ const npmSource : Record < string , unknown > = {
213+ package_name : inputs . npmPackage ,
214+ } ;
215+ if ( inputs . npmRegistryUrl ) {
216+ npmSource . registry_url = inputs . npmRegistryUrl ;
217+ }
218+ if ( inputs . setupCommands && inputs . setupCommands . length > 0 ) {
219+ npmSource . agent_setup = inputs . setupCommands ;
220+ }
221+
222+ const agent = await client . api . post < unknown , AgentResponse > ( '/v1/agents' , {
223+ body : {
224+ name : agentName ,
225+ version : inputs . agentVersion ,
226+ is_public : inputs . isPublic ,
227+ source : {
228+ type : 'npm' ,
229+ npm : npmSource ,
230+ } ,
231+ } ,
232+ } ) ;
233+
234+ return {
235+ agentId : agent . id ,
236+ agentName : agent . name ,
237+ } ;
238+ }
239+
240+ /**
241+ * Deploy an agent from a PyPI package.
242+ */
243+ async function deployPipAgent (
244+ client : RunloopSDK ,
245+ agentName : string ,
246+ inputs : ActionInputs
247+ ) : Promise < DeploymentResult > {
248+ core . info ( 'Deploying pip agent...' ) ;
249+
250+ if ( ! inputs . pipPackage ) {
251+ throw new Error ( 'pip-package is required for pip agent deployment' ) ;
252+ }
253+
254+ const pipSource : Record < string , unknown > = {
255+ package_name : inputs . pipPackage ,
256+ } ;
257+ if ( inputs . pipIndexUrl ) {
258+ pipSource . index_url = inputs . pipIndexUrl ;
259+ }
260+ if ( inputs . setupCommands && inputs . setupCommands . length > 0 ) {
261+ pipSource . agent_setup = inputs . setupCommands ;
262+ }
263+
264+ const agent = await client . api . post < unknown , AgentResponse > ( '/v1/agents' , {
265+ body : {
266+ name : agentName ,
267+ version : inputs . agentVersion ,
268+ is_public : inputs . isPublic ,
269+ source : {
270+ type : 'pip' ,
271+ pip : pipSource ,
272+ } ,
273+ } ,
274+ } ) ;
275+
276+ return {
277+ agentId : agent . id ,
278+ agentName : agent . name ,
279+ } ;
280+ }
0 commit comments