eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.88 kB
JavaScript
import{object,string}from"../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/classic/schemas.js";import"../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/index.js";import{runVercel,runVercelCaptureStdout}from"#setup/primitives/run-vercel.js";import{createPromptCommandOutput,withPhase}from"#setup/cli/index.js";const TEAMS_TRIGGER_PATH=`/eve/v1/teams`,TeamsConnectorSchema=object({id:string().min(1),uid:string().min(1)});function parseCreatedTeamsConnector(e){try{let t=TeamsConnectorSchema.safeParse(JSON.parse(e));return t.success?t.data:void 0}catch{return}}async function provisionTeamsConnector(e){let t=e.deps??{runVercel,runVercelCaptureStdout},n=createPromptCommandOutput(e.log),r=await withPhase(e.log,`Creating Microsoft Teams connector…`,()=>t.runVercelCaptureStdout([`connect`,`create`,`microsoft-teams`,`--name`,e.name,`-F`,`json`,`--scope`,e.project.orgId],{cwd:e.projectRoot,nonInteractive:!0,onOutput:n,signal:e.signal}));if(e.signal?.throwIfAborted(),!r.ok){let e=[r.stderr,r.stdout].find(e=>e!==void 0&&e.trim().length>0);throw Error(e?`Microsoft Teams connector creation failed:\n${e}`:`Microsoft Teams connector creation failed.`)}let i=parseCreatedTeamsConnector(r.stdout);if(i===void 0)throw Error(`Vercel returned an invalid Microsoft Teams connector.`);let a=[`connect`,`attach`,i.uid,`--project`,e.project.projectId,`--environment`,`production`,`--triggers`,`--trigger-path`,TEAMS_TRIGGER_PATH,`--yes`,`--scope`,e.project.orgId],o=await withPhase(e.log,`Connecting Microsoft Teams activities…`,()=>t.runVercel(a,{cwd:e.projectRoot,nonInteractive:!0,onOutput:n,signal:e.signal}));if(e.signal?.throwIfAborted(),!o)throw Error(`Microsoft Teams connector was created, but its trigger destination could not be registered. Run \`vercel ${a.join(` `)}\`.`);return i}export{TEAMS_TRIGGER_PATH,parseCreatedTeamsConnector,provisionTeamsConnector};