runhuman 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +120 -103
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -648,7 +648,7 @@ See [@runhuman/mcp](https://www.npmjs.com/package/@runhuman/mcp) for details.
|
|
|
648
648
|
4. **AI extracts data** - GPT-4o processes feedback into structured JSON
|
|
649
649
|
5. **You get results** - Clean, typed data ready for automation
|
|
650
650
|
|
|
651
|
-
**Pricing:** Pay-per-second ($0.
|
|
651
|
+
**Pricing:** Pay-per-second ($0.0085/sec of tester time). No monthly fees, no minimums.
|
|
652
652
|
|
|
653
653
|
---
|
|
654
654
|
|
package/dist/index.js
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var st=Object.defineProperty;var it=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var b=(s,t)=>()=>(s&&(t=s(s=0)),t);var at=(s,t)=>{for(var e in t)st(s,e,{get:t[e],enumerable:!0})};function ct(s){return s instanceof R}function m(s){return ct(s)?{message:s.message,exitCode:s.exitCode,details:s.details}:s instanceof Error?{message:s.message,exitCode:1}:{message:String(s),exitCode:1}}var R,W,q,D,V,I=b(()=>{"use strict";R=class extends Error{constructor(e,n=1,o){super(e);this.exitCode=n;this.details=o;this.name="CliError"}},W=class extends R{constructor(t="Authentication failed",e){super(t,2,e),this.name="AuthenticationError"}},q=class extends R{constructor(t="Resource not found",e){super(t,3,e),this.name="NotFoundError"}},D=class extends R{constructor(t="Validation failed",e){super(t,4,e),this.name="ValidationError"}},V=class extends R{constructor(t="Operation timed out",e){super(t,5,e),this.name="TimeoutError"}}});var ie=b(()=>{"use strict"});var ee=b(()=>{"use strict"});var ae=b(()=>{"use strict"});var pe=b(()=>{"use strict";ie();ee();ae()});var me=b(()=>{"use strict"});var de=b(()=>{"use strict";me()});var ge=b(()=>{"use strict"});var fe=b(()=>{"use strict";ee()});var he=b(()=>{"use strict";ge();fe()});function p(s){return{pattern:s,build:e=>{if(!e)return s;let n=s;for(let[o,r]of Object.entries(e))r!==void 0&&(n=n.replace(`:${o}?`,r),n=n.replace(`:${o}`,r));return n=n.replace(/\/:[^/]+\?/g,""),n=n.replace(/\/+/g,"/"),n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),n}}}var B=b(()=>{"use strict"});var ye,be=b(()=>{"use strict";B();ye={dashboard:p("/dashboard"),onboarding:p("/dashboard/onboarding"),projects:p("/dashboard/projects"),usage:p("/dashboard/usage"),managePlan:p("/dashboard/manage-plan"),admin:p("/dashboard/admin"),settings:p("/dashboard/settings"),settingsAccount:p("/dashboard/settings/account"),settingsGitHub:p("/dashboard/settings/github"),settingsApiKeys:p("/dashboard/settings/api-keys"),project:p("/dashboard/:projectId"),playground:p("/dashboard/:projectId/playground"),jobs:p("/dashboard/:projectId/jobs"),job:p("/dashboard/:projectId/jobs/:jobId"),templates:p("/dashboard/:projectId/templates"),template:p("/dashboard/:projectId/templates/:templateId"),issues:p("/dashboard/:projectId/issues"),issue:p("/dashboard/:projectId/issues/:issueNumber"),issueSessions:p("/dashboard/:projectId/issue-sessions"),issueSession:p("/dashboard/:projectId/issue-sessions/:sessionId"),projectSettings:p("/dashboard/:projectId/settings"),quickStart:p("/start"),publicJob:p("/j/:jobId/:token"),docs:p("/docs/quick-start"),pricing:p("/pricing"),home:p("/")}});var w,we=b(()=>{"use strict";B();w={jobs:p("/jobs"),job:p("/jobs/:jobId"),jobStatus:p("/jobs/:jobId/status"),run:p("/run"),publicJob:p("/public/jobs/:jobId/:token"),keys:p("/keys"),key:p("/keys/:keyId"),keyRevoke:p("/keys/:keyId/revoke"),projects:p("/projects"),project:p("/projects/:projectId"),projectJobs:p("/projects/:projectId/jobs"),projectApiKeys:p("/projects/:projectId/api-keys"),projectTemplates:p("/projects/:projectId/templates"),projectTemplate:p("/projects/:projectId/templates/:templateId"),bulkCreateProjects:p("/projects/bulk"),githubOAuthAuthorize:p("/github/oauth/authorize"),githubCallback:p("/github/auth/callback"),githubInstallations:p("/github/installations"),githubInstallation:p("/github/installations/:installationId"),githubInstallationRefresh:p("/github/installations/:installationId/refresh"),githubRepos:p("/github/repos"),githubRepoCheckAccess:p("/github/repos/check-access"),githubRepoFindUrl:p("/github/repos/find-url"),githubIssuesByRepo:p("/github/issues/:owner/:repo"),githubIssues:p("/github/issues"),githubIssue:p("/github/issues/:issueNumber"),githubIssueComments:p("/github/issues/:issueNumber/comments"),githubIssueLabels:p("/github/issues/labels"),githubIssueAssignees:p("/github/issues/assignees"),githubIssueTest:p("/github/issues/test"),githubIssuesBulkTest:p("/github/issues/bulk-test"),githubTestSessions:p("/github/issues/test-sessions"),githubTestSession:p("/github/issues/test-sessions/:sessionId"),githubTestSessionSeen:p("/github/issues/test-sessions/:sessionId/seen"),githubTestSessionsCounts:p("/github/issues/test-sessions/counts"),githubBulkTest:p("/github/bulk-test"),githubWebhooks:p("/github/webhooks"),authSync:p("/auth/sync"),authMe:p("/auth/me"),authStartup:p("/auth/startup"),authDeleteAccount:p("/auth/account"),tokensBalance:p("/tokens/balance"),tokensTransactions:p("/tokens/transactions"),tokensContact:p("/tokens/contact"),health:p("/health"),templates:p("/templates"),issueAnalyzer:p("/issue-analyzer"),prAnalyzer:p("/pr-analyzer"),logs:p("/logs"),relevantIssuesDiscover:p("/relevant-issues/discover"),relevantIssuesLatest:p("/relevant-issues/latest"),onboarding:p("/onboarding"),onboardingComplete:p("/onboarding/complete"),onboardingCheck:p("/onboarding/check"),search:p("/search"),testerApply:p("/tester/apply"),testerProfile:p("/tester/profile"),testerPublicProfile:p("/testers/:testerId/profile"),repoTemplates:p("/repos/:owner/:repo/templates"),repoTemplate:p("/repos/:owner/:repo/templates/:templateName")}});var je=b(()=>{"use strict";B();be();we()});var Ce=b(()=>{"use strict"});var Ie=b(()=>{"use strict"});var Se=b(()=>{"use strict";Ce();Ie()});var Ae=b(()=>{"use strict"});var ke=b(()=>{"use strict"});var Ue=b(()=>{"use strict";Ae();ke()});var xe=b(()=>{"use strict"});var Pe=b(()=>{"use strict"});var Te=b(()=>{"use strict";xe();Pe()});var Re=b(()=>{"use strict";pe();de();he();je();Se();Ue();Te()});import Lt from"axios";var g,x=b(()=>{"use strict";I();Re();g=class{client;config;constructor(t){if(this.config=t,!t.apiUrl)throw new Error("apiUrl is required in CLI config");this.client=Lt.create({baseURL:t.apiUrl+"/api",timeout:3e4,headers:{"Content-Type":"application/json"}}),this.client.interceptors.request.use(e=>(this.config.apiKey&&(e.headers.Authorization=`Bearer ${this.config.apiKey}`),e)),this.client.interceptors.response.use(e=>e,e=>{throw this.handleError(e)})}handleError(t){if(t.response){let e=t.response.status,n=t.response.data,o=n?.error||n?.message||t.message;switch(e){case 401:case 403:return new W(o,n);case 404:return new q(o,n);case 400:case 422:return new D(o,n);default:return new R(o,1,n)}}return t.code==="ECONNABORTED"?new R("Request timeout",5):t.code==="ENOTFOUND"||t.code==="ECONNREFUSED"?new R("Cannot connect to Runhuman API",1):new R(t.message,1)}async createJob(t){return(await this.client.post(w.jobs.build(),t)).data}async getJob(t){return(await this.client.get(w.jobStatus.build({jobId:t}))).data}async listJobs(t){return(await this.client.get(w.jobs.build(),{params:t})).data}async cancelJob(t){await this.client.post(`${w.job.build({jobId:t})}/cancel`)}async deleteJob(t){await this.client.delete(w.job.build({jobId:t}))}async listProjects(t){return(await this.client.get(w.projects.build(),{params:t})).data}async getProject(t){return(await this.client.get(w.project.build({projectId:t}))).data}async createProject(t){return(await this.client.post(w.projects.build(),t)).data}async updateProject(t,e){return(await this.client.put(w.project.build({projectId:t}),e)).data}async deleteProject(t){await this.client.delete(w.project.build({projectId:t}))}async listApiKeys(t){return(await this.client.get(w.projectApiKeys.build({projectId:t}))).data}async createApiKey(t,e){return(await this.client.post(w.projectApiKeys.build({projectId:t}),{name:e})).data}async deleteApiKey(t){await this.client.delete(w.key.build({keyId:t}))}async listTemplates(t){return(await this.client.get(w.projectTemplates.build({projectId:t}))).data}async getTemplate(t,e){return(await this.client.get(w.projectTemplate.build({projectId:t,templateId:e}))).data}async createTemplate(t,e){return(await this.client.post(w.projectTemplates.build({projectId:t}),e)).data}async updateTemplate(t,e,n){return(await this.client.put(w.projectTemplate.build({projectId:t,templateId:e}),n)).data}async deleteTemplate(t,e){await this.client.delete(w.projectTemplate.build({projectId:t,templateId:e}))}async getCurrentUser(){return(await this.client.get(w.authMe.build())).data}async getTokenBalance(){return(await this.client.get(w.tokensBalance.build())).data}async linkGithubRepo(t,e,n){return(await this.client.post(`${w.project.build({projectId:t})}/github/link`,{owner:e,repo:n})).data}async listGithubRepos(t){let e=t?{projectId:t}:void 0;return(await this.client.get(w.githubRepos.build(),{params:e})).data}async listGithubIssues(t,e,n){return(await this.client.get(w.githubIssuesByRepo.build({owner:t,repo:e}),{params:n})).data}async getGithubIssue(t,e,n){return(await this.client.get(`${w.githubIssuesByRepo.build({owner:t,repo:e})}/${n}`)).data}}});import{cosmiconfig as Jt}from"cosmiconfig";import{homedir as _t}from"os";import{join as v}from"path";import{readFileSync as F,writeFileSync as O,existsSync as P,mkdirSync as te,chmodSync as Ft}from"fs";function zt(s){return Ht.includes(s)}var Kt,E,M,K,Ht,d,k=b(()=>{"use strict";Kt="runhuman",E=v(_t(),".config","runhuman"),M=v(E,"config.json"),K=v(E,"credentials.json"),Ht=["pretty","json","compact"];d=class{constructor(t=process.cwd()){this.cwd=t}projectConfig=null;globalConfig=null;envConfig=null;async loadConfig(t={}){this.envConfig=this.loadEnvConfig(),this.projectConfig=await this.loadProjectConfig(),this.globalConfig=this.loadGlobalConfig();let e=this.loadCredentials(),n=e?.accessToken?{apiKey:e.accessToken}:{},o=Object.fromEntries(Object.entries(t).filter(([,l])=>l!==void 0));return{...this.getDefaults(),...this.globalConfig,...this.projectConfig,...n,...this.envConfig,...o}}getDefaults(){return{apiUrl:"https://runhuman.com",outputFormat:"pretty",color:!0,autoOpenBrowser:!0,defaultDuration:5,defaultScreenSize:"desktop"}}loadEnvConfig(){let t={};return process.env.RUNHUMAN_API_KEY&&(t.apiKey=process.env.RUNHUMAN_API_KEY),process.env.RUNHUMAN_API_URL&&(t.apiUrl=process.env.RUNHUMAN_API_URL),process.env.RUNHUMAN_PROJECT&&(t.project=process.env.RUNHUMAN_PROJECT),process.env.RUNHUMAN_DEFAULT_URL&&(t.defaultUrl=process.env.RUNHUMAN_DEFAULT_URL),process.env.RUNHUMAN_DEFAULT_DURATION&&(t.defaultDuration=parseInt(process.env.RUNHUMAN_DEFAULT_DURATION,10)),process.env.RUNHUMAN_DEFAULT_SCREEN_SIZE&&(t.defaultScreenSize=process.env.RUNHUMAN_DEFAULT_SCREEN_SIZE),process.env.RUNHUMAN_OUTPUT_FORMAT&&zt(process.env.RUNHUMAN_OUTPUT_FORMAT)&&(t.outputFormat=process.env.RUNHUMAN_OUTPUT_FORMAT),process.env.RUNHUMAN_NO_COLOR==="1"&&(t.color=!1),t}async loadProjectConfig(){try{return(await Jt(Kt).search(this.cwd))?.config||null}catch{return null}}loadGlobalConfig(){try{if(!P(M))return null;let t=F(M,"utf-8");return JSON.parse(t)}catch{return null}}async get(t){return(await this.loadConfig())[t]}async set(t,e,n=!1){n?await this.setGlobalConfig(t,e):await this.setProjectConfig(t,e)}async setGlobalConfig(t,e){P(E)||te(E,{recursive:!0});let n={};if(P(M)){let o=F(M,"utf-8");n=JSON.parse(o)}n[t]=e,O(M,JSON.stringify(n,null,2))}async setProjectConfig(t,e){let n=v(this.cwd,".runhumanrc"),o={};if(P(n)){let r=F(n,"utf-8");o=JSON.parse(r)}o[t]=e,O(n,JSON.stringify(o,null,2))}async saveProjectConfig(t){let e=v(this.cwd,".runhumanrc"),n={};if(P(e)){let r=F(e,"utf-8");n=JSON.parse(r)}let o={...n,...t};O(e,JSON.stringify(o,null,2))}async list(){let t=await this.loadConfig();return{global:this.globalConfig,project:this.projectConfig,env:this.envConfig,effective:t}}async reset(t){if((t==="global"||t==="all")&&P(M)&&O(M,"{}"),t==="project"||t==="all"){let e=v(this.cwd,".runhumanrc");P(e)&&O(e,"{}")}}saveCredentials(t){P(E)||te(E,{recursive:!0}),O(K,JSON.stringify(t,null,2));try{process.platform!=="win32"&&Ft(K,384)}catch{}}loadCredentials(){try{if(!P(K))return null;let t=F(K,"utf-8");return JSON.parse(t)}catch{return null}}clearCredentials(){P(K)&&O(K,"{}")}saveUserInfo(t){let e=v(E,"user.json");P(E)||te(E,{recursive:!0}),O(e,JSON.stringify(t,null,2))}loadUserInfo(){try{let t=v(E,"user.json");if(!P(t))return null;let e=F(t,"utf-8");return JSON.parse(e)}catch{return null}}clearUserInfo(){let t=v(E,"user.json");P(t)&&O(t,"{}")}}});import L from"chalk";import Gt from"cli-table3";var a,S=b(()=>{"use strict";a=class{constructor(t={}){this.options=t}output(t){this.options.json?console.log(JSON.stringify(t,null,2)):t.success?t.data&&!this.options.quiet&&this.outputPretty(t.data):this.outputError(t.error?.message||"An error occurred")}outputPretty(t){typeof t=="string"?console.log(t):(Array.isArray(t),console.log(JSON.stringify(t,null,2)))}outputError(t,e){if(this.options.json){let n={success:!1,error:{message:t,details:e},timestamp:new Date().toISOString()};console.error(JSON.stringify(n,null,2))}else console.error(this.color("red",`
|
|
2
|
+
var lt=Object.defineProperty;var ut=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var b=(s,t)=>()=>(s&&(t=s(s=0)),t);var pt=(s,t)=>{for(var e in t)lt(s,e,{get:t[e],enumerable:!0})};function mt(s){return s instanceof R}function m(s){return mt(s)?{message:s.message,exitCode:s.exitCode,details:s.details}:s instanceof Error?{message:s.message,exitCode:1}:{message:String(s),exitCode:1}}var R,W,q,D,V,I=b(()=>{"use strict";R=class extends Error{constructor(e,n=1,o){super(e);this.exitCode=n;this.details=o;this.name="CliError"}},W=class extends R{constructor(t="Authentication failed",e){super(t,2,e),this.name="AuthenticationError"}},q=class extends R{constructor(t="Resource not found",e){super(t,3,e),this.name="NotFoundError"}},D=class extends R{constructor(t="Validation failed",e){super(t,4,e),this.name="ValidationError"}},V=class extends R{constructor(t="Operation timed out",e){super(t,5,e),this.name="TimeoutError"}}});var ie=b(()=>{"use strict"});var ee=b(()=>{"use strict"});var ae=b(()=>{"use strict"});var pe=b(()=>{"use strict";ie();ee();ae()});var me=b(()=>{"use strict"});var de=b(()=>{"use strict";me()});var ge=b(()=>{"use strict"});var fe=b(()=>{"use strict";ee()});var he=b(()=>{"use strict";ge();fe()});function a(s){return{pattern:s,build:e=>{if(!e)return s;let n=s;for(let[o,r]of Object.entries(e))r!==void 0&&(n=n.replace(`:${o}?`,r),n=n.replace(`:${o}`,r));return n=n.replace(/\/:[^/]+\?/g,""),n=n.replace(/\/+/g,"/"),n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),n}}}var B=b(()=>{"use strict"});var be,ye=b(()=>{"use strict";B();be={dashboard:a("/dashboard"),onboarding:a("/dashboard/onboarding"),projects:a("/dashboard/projects"),usage:a("/dashboard/usage"),managePlan:a("/dashboard/manage-plan"),jobSimple:a("/dashboard/jobs/:jobId"),admin:a("/dashboard/admin"),organizations:a("/dashboard/organizations"),organization:a("/dashboard/organizations/:organizationId"),organizationMembers:a("/dashboard/organizations/:organizationId/members"),organizationSettings:a("/dashboard/organizations/:organizationId/settings"),organizationUsage:a("/dashboard/organizations/:organizationId/usage"),organizationProjects:a("/dashboard/organizations/:organizationId/projects"),settings:a("/dashboard/settings"),settingsAccount:a("/dashboard/settings/account"),settingsGitHub:a("/dashboard/settings/github"),settingsApiKeys:a("/dashboard/settings/api-keys"),tester:a("/tester"),testerJobs:a("/tester/jobs"),testerSettings:a("/tester/settings"),project:a("/dashboard/:projectId"),playground:a("/dashboard/:projectId/playground"),jobs:a("/dashboard/:projectId/jobs"),job:a("/dashboard/:projectId/jobs/:jobId"),templates:a("/dashboard/:projectId/templates"),template:a("/dashboard/:projectId/templates/:templateId"),issues:a("/dashboard/:projectId/issues"),issue:a("/dashboard/:projectId/issues/:issueNumber"),issueSessions:a("/dashboard/:projectId/issue-sessions"),issueSession:a("/dashboard/:projectId/issue-sessions/:sessionId"),projectSettings:a("/dashboard/:projectId/settings"),flowCharts:a("/dashboard/:projectId/flowcharts"),flowChart:a("/dashboard/:projectId/flowcharts/:flowchartId"),flowChartView:a("/view/flowchart/:projectId/:flowchartId"),invite:a("/invite/:token"),quickStart:a("/start"),publicJob:a("/j/:jobId/:token"),statuspage:a("/statuspage"),docs:a("/docs/quick-start"),pricing:a("/pricing"),home:a("/")}});var j,je=b(()=>{"use strict";B();j={jobs:a("/jobs"),job:a("/jobs/:jobId"),jobStatus:a("/jobs/:jobId/status"),jobFeedback:a("/jobs/:jobId/feedback"),jobClaim:a("/jobs/:jobId/claim"),run:a("/run"),execute:a("/execute"),publicJob:a("/public/jobs/:jobId/:token"),testerJob:a("/tester/jobs/:jobId"),testerJobUploadUrls:a("/tester/jobs/:jobId/upload-urls"),testerJobProcessResults:a("/tester/jobs/:jobId/process-results"),testerJobProcessingStatus:a("/tester/jobs/:jobId/processing/:processingJobId"),testerJobExtractFrames:a("/tester/jobs/:jobId/extract-frames"),testerJobAbort:a("/tester/jobs/:jobId/abort"),testerJobInvalid:a("/tester/jobs/:jobId/invalid"),keys:a("/keys"),key:a("/keys/:keyId"),keyRevoke:a("/keys/:keyId/revoke"),keyInfo:a("/key-info"),projects:a("/projects"),project:a("/projects/:projectId"),projectJobs:a("/projects/:projectId/jobs"),projectApiKeys:a("/projects/:projectId/api-keys"),projectTransfer:a("/projects/:projectId/transfer"),projectTemplates:a("/projects/:projectId/templates"),projectTemplate:a("/projects/:projectId/templates/:templateId"),projectFlowCharts:a("/projects/:projectId/flowcharts"),projectFlowChartsUpload:a("/projects/:projectId/flowcharts/upload"),projectFlowChart:a("/projects/:projectId/flowcharts/:flowchartId"),projectFlowChartData:a("/projects/:projectId/flowcharts/:flowchartId/data"),projectFlowChartChat:a("/projects/:projectId/flowcharts/:flowchartId/chat"),bulkCreateProjects:a("/projects/bulk"),githubOAuthAuthorize:a("/github/oauth/authorize"),githubCallback:a("/github/oauth/callback"),githubLink:a("/github/link"),githubInstallations:a("/github/installations"),githubInstallation:a("/github/installations/:installationId"),githubInstallationRefresh:a("/github/installations/:installationId/refresh"),githubRepos:a("/github/repos"),githubRepoCheckAccess:a("/github/repos/check-access"),githubRepoFindUrl:a("/github/repos/find-url"),githubIssuesByRepo:a("/github/issues/:owner/:repo"),githubIssues:a("/github/issues"),githubIssue:a("/github/issues/:issueNumber"),githubIssueComments:a("/github/issues/:issueNumber/comments"),githubIssueLabels:a("/github/issues/labels"),githubIssueAssignees:a("/github/issues/assignees"),githubIssueTest:a("/github/issues/test"),githubIssuesBulkTest:a("/github/issues/bulk-test"),githubTestSessions:a("/github/issues/test-sessions"),githubTestSession:a("/github/issues/test-sessions/:sessionId"),githubTestSessionSeen:a("/github/issues/test-sessions/:sessionId/seen"),githubTestSessionsCounts:a("/github/issues/test-sessions/counts"),githubBulkTest:a("/github/bulk-test"),githubWebhooks:a("/github/webhooks"),authSync:a("/auth/sync"),authMe:a("/auth/me"),authStartup:a("/auth/startup"),authDeleteAccount:a("/auth/account"),tokensBalance:a("/tokens/balance"),tokensTransactions:a("/tokens/transactions"),tokensContact:a("/tokens/contact"),health:a("/health"),status:a("/status"),templates:a("/templates"),issueAnalyzer:a("/issue-analyzer"),prAnalyzer:a("/pr-analyzer"),logs:a("/logs"),relevantIssuesDiscover:a("/relevant-issues/discover"),relevantIssuesLatest:a("/relevant-issues/latest"),onboarding:a("/onboarding"),onboardingComplete:a("/onboarding/complete"),onboardingCheck:a("/onboarding/check"),search:a("/search"),testerApply:a("/tester/apply"),testerProfile:a("/tester/profile"),testerPublicProfile:a("/testers/:testerId/profile"),testerDownloadApp:a("/tester/download-app"),testerAvatarUploadUrl:a("/tester/profile/avatar-upload-url"),testerAppVersion:a("/tester/app-version"),repoTemplates:a("/repos/:owner/:repo/templates"),repoTemplate:a("/repos/:owner/:repo/templates/:templateName"),organizations:a("/organizations"),organization:a("/organizations/:organizationId"),organizationMembers:a("/organizations/:organizationId/members"),organizationInvite:a("/organizations/:organizationId/invite"),organizationMember:a("/organizations/:organizationId/members/:userId"),organizationProjects:a("/organizations/:organizationId/projects"),organizationTokens:a("/organizations/:organizationId/tokens"),organizationTokenTransactions:a("/organizations/:organizationId/tokens/transactions"),organizationJobs:a("/organizations/:organizationId/jobs"),organizationTransferOwnership:a("/organizations/:organizationId/transfer-ownership"),organizationApiKeys:a("/organizations/:organizationId/api-keys"),transfersPending:a("/transfers/pending"),transfersOutgoing:a("/transfers/outgoing"),transferAccept:a("/transfers/:transferId/accept"),transferReject:a("/transfers/:transferId/reject"),transferCancel:a("/transfers/:transferId/cancel"),invite:a("/invites/:token"),inviteRedeem:a("/invites/:token/redeem")}});var we=b(()=>{"use strict";B();ye();je()});var Ce=b(()=>{"use strict"});var Ie=b(()=>{"use strict"});var Se=b(()=>{"use strict";Ce();Ie()});var Ae=b(()=>{"use strict"});var ke=b(()=>{"use strict"});var xe=b(()=>{"use strict";Ae();ke()});var Ue=b(()=>{"use strict"});var Pe=b(()=>{"use strict"});var Te=b(()=>{"use strict";Ue();Pe()});var Re=b(()=>{"use strict"});var Ee=b(()=>{"use strict";Re()});var Oe=b(()=>{"use strict"});var Ne=b(()=>{"use strict";Oe()});var ve=b(()=>{"use strict";pe();de();he();we();Se();xe();Te();Ee();Ne()});import Bt from"axios";var g,U=b(()=>{"use strict";I();ve();g=class{client;config;constructor(t){if(this.config=t,!t.apiUrl)throw new Error("apiUrl is required in CLI config");this.client=Bt.create({baseURL:t.apiUrl+"/api",timeout:3e4,headers:{"Content-Type":"application/json"}}),this.client.interceptors.request.use(e=>(this.config.apiKey&&(e.headers.Authorization=`Bearer ${this.config.apiKey}`),e)),this.client.interceptors.response.use(e=>e,e=>{throw this.handleError(e)})}handleError(t){if(t.response){let e=t.response.status,n=t.response.data,o=n?.error||n?.message||t.message;switch(e){case 401:case 403:return new W(o,n);case 404:return new q(o,n);case 400:case 422:return new D(o,n);default:return new R(o,1,n)}}return t.code==="ECONNABORTED"?new R("Request timeout",5):t.code==="ENOTFOUND"||t.code==="ECONNREFUSED"?new R("Cannot connect to Runhuman API",1):new R(t.message,1)}async createJob(t){return(await this.client.post(j.jobs.build(),t)).data}async getJob(t){return(await this.client.get(j.jobStatus.build({jobId:t}))).data}async listJobs(t){return(await this.client.get(j.jobs.build(),{params:t})).data}async cancelJob(t){await this.client.post(`${j.job.build({jobId:t})}/cancel`)}async deleteJob(t){await this.client.delete(j.job.build({jobId:t}))}async listProjects(t){return(await this.client.get(j.projects.build(),{params:t})).data}async getProject(t){return(await this.client.get(j.project.build({projectId:t}))).data}async createProject(t){return(await this.client.post(j.projects.build(),t)).data}async updateProject(t,e){return(await this.client.put(j.project.build({projectId:t}),e)).data}async deleteProject(t){await this.client.delete(j.project.build({projectId:t}))}async listApiKeys(t){return(await this.client.get(j.projectApiKeys.build({projectId:t}))).data}async createApiKey(t,e){return(await this.client.post(j.projectApiKeys.build({projectId:t}),{name:e})).data}async deleteApiKey(t){await this.client.delete(j.key.build({keyId:t}))}async listTemplates(t){return(await this.client.get(j.projectTemplates.build({projectId:t}))).data}async getTemplate(t,e){return(await this.client.get(j.projectTemplate.build({projectId:t,templateId:e}))).data}async createTemplate(t,e){return(await this.client.post(j.projectTemplates.build({projectId:t}),e)).data}async updateTemplate(t,e,n){return(await this.client.put(j.projectTemplate.build({projectId:t,templateId:e}),n)).data}async deleteTemplate(t,e){await this.client.delete(j.projectTemplate.build({projectId:t,templateId:e}))}async getCurrentUser(){return(await this.client.get(j.authMe.build())).data}async getTokenBalance(){return(await this.client.get(j.tokensBalance.build())).data}async linkGithubRepo(t,e,n){return(await this.client.post(`${j.project.build({projectId:t})}/github/link`,{owner:e,repo:n})).data}async listGithubRepos(t){let e=t?{projectId:t}:void 0;return(await this.client.get(j.githubRepos.build(),{params:e})).data}async listGithubIssues(t,e,n){return(await this.client.get(j.githubIssuesByRepo.build({owner:t,repo:e}),{params:n})).data}async getGithubIssue(t,e,n){return(await this.client.get(`${j.githubIssuesByRepo.build({owner:t,repo:e})}/${n}`)).data}}});import{cosmiconfig as Zt}from"cosmiconfig";import{homedir as Qt}from"os";import{join as N}from"path";import{readFileSync as F,writeFileSync as O,existsSync as P,mkdirSync as te,chmodSync as Xt}from"fs";function to(s){return eo.includes(s)}var Yt,E,M,z,eo,d,k=b(()=>{"use strict";Yt="runhuman",E=N(Qt(),".config","runhuman"),M=N(E,"config.json"),z=N(E,"credentials.json"),eo=["pretty","json","compact"];d=class{constructor(t=process.cwd()){this.cwd=t}projectConfig=null;globalConfig=null;envConfig=null;async loadConfig(t={}){this.envConfig=this.loadEnvConfig(),this.projectConfig=await this.loadProjectConfig(),this.globalConfig=this.loadGlobalConfig();let e=this.loadCredentials(),n=e?.accessToken?{apiKey:e.accessToken}:{},o=Object.fromEntries(Object.entries(t).filter(([,u])=>u!==void 0));return{...this.getDefaults(),...this.globalConfig,...this.projectConfig,...n,...this.envConfig,...o}}getDefaults(){return{apiUrl:"https://runhuman.com",outputFormat:"pretty",color:!0,autoOpenBrowser:!0,defaultDuration:5,defaultScreenSize:"desktop"}}loadEnvConfig(){let t={};return process.env.RUNHUMAN_API_KEY&&(t.apiKey=process.env.RUNHUMAN_API_KEY),process.env.RUNHUMAN_API_URL&&(t.apiUrl=process.env.RUNHUMAN_API_URL),process.env.RUNHUMAN_PROJECT&&(t.project=process.env.RUNHUMAN_PROJECT),process.env.RUNHUMAN_DEFAULT_URL&&(t.defaultUrl=process.env.RUNHUMAN_DEFAULT_URL),process.env.RUNHUMAN_DEFAULT_DURATION&&(t.defaultDuration=parseInt(process.env.RUNHUMAN_DEFAULT_DURATION,10)),process.env.RUNHUMAN_DEFAULT_SCREEN_SIZE&&(t.defaultScreenSize=process.env.RUNHUMAN_DEFAULT_SCREEN_SIZE),process.env.RUNHUMAN_OUTPUT_FORMAT&&to(process.env.RUNHUMAN_OUTPUT_FORMAT)&&(t.outputFormat=process.env.RUNHUMAN_OUTPUT_FORMAT),process.env.RUNHUMAN_NO_COLOR==="1"&&(t.color=!1),t}async loadProjectConfig(){try{return(await Zt(Yt).search(this.cwd))?.config||null}catch{return null}}loadGlobalConfig(){try{if(!P(M))return null;let t=F(M,"utf-8");return JSON.parse(t)}catch{return null}}async get(t){return(await this.loadConfig())[t]}async set(t,e,n=!1){n?await this.setGlobalConfig(t,e):await this.setProjectConfig(t,e)}async setGlobalConfig(t,e){P(E)||te(E,{recursive:!0});let n={};if(P(M)){let o=F(M,"utf-8");n=JSON.parse(o)}n[t]=e,O(M,JSON.stringify(n,null,2))}async setProjectConfig(t,e){let n=N(this.cwd,".runhumanrc"),o={};if(P(n)){let r=F(n,"utf-8");o=JSON.parse(r)}o[t]=e,O(n,JSON.stringify(o,null,2))}async saveProjectConfig(t){let e=N(this.cwd,".runhumanrc"),n={};if(P(e)){let r=F(e,"utf-8");n=JSON.parse(r)}let o={...n,...t};O(e,JSON.stringify(o,null,2))}async list(){let t=await this.loadConfig();return{global:this.globalConfig,project:this.projectConfig,env:this.envConfig,effective:t}}async reset(t){if((t==="global"||t==="all")&&P(M)&&O(M,"{}"),t==="project"||t==="all"){let e=N(this.cwd,".runhumanrc");P(e)&&O(e,"{}")}}saveCredentials(t){P(E)||te(E,{recursive:!0}),O(z,JSON.stringify(t,null,2));try{process.platform!=="win32"&&Xt(z,384)}catch{}}loadCredentials(){try{if(!P(z))return null;let t=F(z,"utf-8");return JSON.parse(t)}catch{return null}}clearCredentials(){P(z)&&O(z,"{}")}saveUserInfo(t){let e=N(E,"user.json");P(E)||te(E,{recursive:!0}),O(e,JSON.stringify(t,null,2))}loadUserInfo(){try{let t=N(E,"user.json");if(!P(t))return null;let e=F(t,"utf-8");return JSON.parse(e)}catch{return null}}clearUserInfo(){let t=N(E,"user.json");P(t)&&O(t,"{}")}}});import L from"chalk";import oo from"cli-table3";var c,S=b(()=>{"use strict";c=class{constructor(t={}){this.options=t}output(t){this.options.json?console.log(JSON.stringify(t,null,2)):t.success?t.data&&!this.options.quiet&&this.outputPretty(t.data):this.outputError(t.error?.message||"An error occurred")}outputPretty(t){typeof t=="string"?console.log(t):(Array.isArray(t),console.log(JSON.stringify(t,null,2)))}outputError(t,e){if(this.options.json){let n={success:!1,error:{message:t,details:e},timestamp:new Date().toISOString()};console.error(JSON.stringify(n,null,2))}else console.error(this.color("red",`
|
|
3
3
|
Error: ${t}
|
|
4
4
|
`)),e&&console.error(this.color("gray",JSON.stringify(e,null,2)))}success(t){!this.options.json&&!this.options.quiet&&console.log(this.color("green",`
|
|
5
5
|
${t}
|
|
6
6
|
`))}info(t){!this.options.json&&!this.options.quiet&&console.log(this.color("blue",t))}warn(t){!this.options.json&&!this.options.quiet&&console.warn(this.color("yellow",`Warning: ${t}`))}formatJobList(t){if(this.options.format==="compact")return t.map(n=>`${n.id} ${n.status} ${n.url}`).join(`
|
|
7
|
-
`);let e=new
|
|
8
|
-
Duration: `+(
|
|
9
|
-
\u{1F4CB} Results Summary:`);for(let[f,h]of Object.entries(
|
|
7
|
+
`);let e=new oo({head:["Job ID","Status","URL","Created","Duration","Cost"].map(n=>this.color("cyan",n)),colWidths:[15,12,30,14,10,10]});return t.forEach(n=>{e.push([n.id,this.formatStatus(n.status),this.truncate(n.url,28),this.formatDate(n.createdAt),n.testDurationSeconds?this.formatDuration(n.testDurationSeconds):"-",n.costUsd?`$${n.costUsd.toFixed(3)}`:"-"])}),e.toString()}formatStatus(t){let e={pending:"yellow",waiting:"blue",working:"blue",creating_issues:"cyan",completed:"green",incomplete:"yellow",abandoned:"red",rejected:"gray",error:"red",failed:"red"},n=t.replace("_"," ");return this.color(e[t]||"white",n)}formatDuration(t){if(t<60)return`${t}s`;let e=Math.floor(t/60),n=t%60;if(e<60)return`${e}m ${n}s`;let o=Math.floor(e/60),r=e%60;return`${o}h ${r}m ${n}s`}formatDate(t){let e=new Date(t),o=new Date().getTime()-e.getTime(),r=Math.floor(o/1e3),u=Math.floor(r/60),i=Math.floor(u/60),l=Math.floor(i/24);return r<60?`${r}s ago`:u<60?`${u}m ago`:i<24?`${i}h ago`:l<30?`${l}d ago`:e.toLocaleDateString()}truncate(t,e){return t.length<=e?t:t.substring(0,e-3)+"..."}color(t,e){if(this.options.color===!1)return e;let o={red:L.red,green:L.green,blue:L.blue,yellow:L.yellow,cyan:L.cyan,gray:L.gray,white:L.white}[t];return o?o(e):e}static result(t){return{success:!0,data:t,timestamp:new Date().toISOString()}}static error(t,e,n){return{success:!1,error:{message:t,code:e,details:n},timestamp:new Date().toISOString()}}}});var ne={};pt(ne,{waitCommand:()=>oe,waitForJob:()=>De});import{Command as no}from"commander";import ro from"ora";async function De(s,t,e,n=600){let o=Date.now(),r=n*1e3,u=1e4,i=null;for(e.options.json||(i=ro("\u23F3 Waiting for job completion...").start());;){let l=Date.now()-o;if(l>=r)throw i&&i.fail("Timeout waiting for job completion"),new V(`Job did not complete within ${n} seconds`);let p=await t.getJob(s);if(i){let f=e.formatDuration(Math.floor(l/1e3));i.text=`\u23F3 Waiting for job completion... (${f} elapsed, status: ${p.status})`}if(p.status==="completed"){if(i&&i.succeed("\u2705 Test Completed!"),!e.options.json){if(console.log(`
|
|
8
|
+
Duration: `+(p.testDurationSeconds?e.formatDuration(p.testDurationSeconds):"N/A")),console.log(" Cost: $"+(p.costUsd||0).toFixed(3)),p.testerName&&console.log(" Tester: "+p.testerName),p.result){console.log(`
|
|
9
|
+
\u{1F4CB} Results Summary:`);for(let[f,h]of Object.entries(p.result))console.log(` ${f}: ${h}`)}console.log(`
|
|
10
10
|
\u{1F4BE} Full results:`),console.log(` runhuman results ${s}
|
|
11
|
-
`)}return}if(
|
|
11
|
+
`)}return}if(p.status==="error"||p.status==="incomplete"||p.status==="abandoned")throw i&&i.fail(`Test ${p.status}`),new Error(`Job ${p.status}: ${p.testerResponse||"No details available"}`);if(p.status==="rejected")throw i&&i.fail("Test was rejected"),new Error("Job was rejected");await new Promise(f=>setTimeout(f,u))}}function oe(){let s=new no("wait");return s.description("Wait for a job to complete and display results").argument("<jobId>","Job ID to wait for").option("--timeout <seconds>","Max wait time (default: 600)",parseInt).option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color}),u=new g(o);if(await De(t,u,r,e.timeout||600),e.json){let i=await u.getJob(t),l=c.result(i);r.output(l)}}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s}var Z=b(()=>{"use strict";U();k();S();I()});import{Command as Zo}from"commander";U();k();S();I();import{Command as so}from"commander";import io from"ora";function $e(){let s=new so("create");return s.description("Create a new QA test job").argument("[url]","URL to test").option("-d, --description <text>","Test instructions for the human tester").option("-t, --template <name>","Use a template as base configuration").option("--duration <minutes>","Target duration (1-60 minutes)",parseInt).option("--screen-size <preset>","Screen size: desktop|laptop|tablet|mobile").option("--schema <file>","Path to JSON schema file for structured output").option("--schema-inline <json>","Inline JSON schema").option("--metadata <json>","Metadata for tracking (JSON string)").option("--github-repo <owner/repo>","GitHub repo for context").option("--create-issues","Auto-create GitHub issues from findings").option("--sync","Wait for result before exiting (synchronous mode)").option("--wait <seconds>","Max wait time in sync mode (default: 300)",parseInt).option("--project <id>","Project ID (or use default from config)").option("--api-key <key>","API key (or use from config/env)").option("--json","Output as JSON (for scripting)").option("--quiet","Minimal output (only job ID)").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,project:e.project}),r=new c({json:e.json,quiet:e.quiet,color:o.color}),u=new g(o);if(!t&&!e.template&&!o.defaultUrl)throw new D("URL is required (provide as argument, via --template, or set defaultUrl in config)");if(!e.description&&!e.template)throw new D("Description is required (use -d flag or --template)");if(!o.project)throw new D(`Project ID is required. Set a default project with:
|
|
12
12
|
runhuman projects switch <project-id>
|
|
13
|
-
Or use the --project flag`);let i={projectId:o.project,url:t||o.defaultUrl||"",description:e.description||"",duration:e.duration||o.defaultDuration,screenSize:e.screenSize||o.defaultScreenSize};if(e.schema){let h=await(await import("fs/promises")).readFile(e.schema,"utf-8");i.schema=JSON.parse(h)}else e.schemaInline&&(i.schema=JSON.parse(e.schemaInline));e.metadata&&(i.metadata=JSON.parse(e.metadata)),e.githubRepo&&(i.githubRepo=e.githubRepo),e.createIssues&&(i.createIssues=!0),e.template&&(i.templateId=e.template);let
|
|
14
|
-
`+"=".repeat(60)),console.log(" Job ID: "+
|
|
15
|
-
`),console.log("\u{1F4A1} Track progress:"),console.log(` runhuman status ${
|
|
16
|
-
`));if(e.sync){let{waitForJob:f}=await Promise.resolve().then(()=>(
|
|
13
|
+
Or use the --project flag`);let i={projectId:o.project,url:t||o.defaultUrl||"",description:e.description||"",duration:e.duration||o.defaultDuration,screenSize:e.screenSize||o.defaultScreenSize};if(e.schema){let h=await(await import("fs/promises")).readFile(e.schema,"utf-8");i.schema=JSON.parse(h)}else e.schemaInline&&(i.schema=JSON.parse(e.schemaInline));e.metadata&&(i.metadata=JSON.parse(e.metadata)),e.githubRepo&&(i.githubRepo=e.githubRepo),e.createIssues&&(i.createIssues=!0),e.template&&(i.templateId=e.template);let l=e.json?null:io("Creating QA test job...").start(),p=await u.createJob(i);if(l&&l.succeed("Job created successfully!"),e.json){let f=c.result({jobId:p.jobId,status:p.status,message:p.message,dashboardUrl:`${o.apiUrl}/dashboard/jobs/${p.jobId}`,estimatedCompletionTime:p.estimatedCompletionTime});r.output(f)}else e.quiet?console.log(p.jobId):(console.log(`
|
|
14
|
+
`+"=".repeat(60)),console.log(" Job ID: "+p.jobId),console.log(" Status: "+p.status),console.log(` Dashboard: ${o.apiUrl}/dashboard/jobs/${p.jobId}`),console.log("=".repeat(60)+`
|
|
15
|
+
`),console.log("\u{1F4A1} Track progress:"),console.log(` runhuman status ${p.jobId}`),console.log(` runhuman wait ${p.jobId}
|
|
16
|
+
`));if(e.sync){let{waitForJob:f}=await Promise.resolve().then(()=>(Z(),ne));await f(p.jobId,u,r,e.wait||300)}}catch(n){let o=m(n);new c({json:e.json,quiet:!1}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s}U();k();S();I();import{Command as ao}from"commander";function Me(){let s=new ao("status");return s.description("Check the current status of a job").argument("<jobId>","Job ID to check").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color}),i=await new g(o).getJob(t);if(e.json){let l=c.result(i);r.output(l)}else console.log(`
|
|
17
17
|
\u{1F4CA} Job Status: `+t+`
|
|
18
18
|
`),console.log(" Status: "+r.formatStatus(i.status)),i.testerName&&console.log(" Tester: "+i.testerName),console.log(" URL: "+i.url),console.log(" Description: "+i.description),console.log(" Created: "+i.createdAt),i.completedAt&&console.log(" Completed: "+i.completedAt),i.testDurationSeconds&&console.log(" Duration: "+r.formatDuration(i.testDurationSeconds)),i.costUsd&&console.log(" Cost: $"+i.costUsd.toFixed(3)),console.log(`
|
|
19
|
-
Dashboard: ${o.apiUrl}/jobs/${t}
|
|
19
|
+
Dashboard: ${o.apiUrl}/dashboard/jobs/${t}
|
|
20
20
|
`),i.status==="pending"||i.status==="waiting"||i.status==="working"?(console.log("\u{1F4A1} Wait for completion:"),console.log(` runhuman wait ${t}
|
|
21
21
|
`)):i.status==="completed"&&(console.log("\u{1F4A1} View results:"),console.log(` runhuman results ${t}
|
|
22
|
-
`))}catch(n){let o=new
|
|
22
|
+
`))}catch(n){let o=new c({json:e.json}),r=m(n);o.outputError(r.message,r.details),process.exit(r.exitCode)}}),s}Z();U();k();S();I();import{Command as co}from"commander";function Le(){let s=new co("results");return s.description("Display detailed results for a completed job").argument("<jobId>","Job ID to show results for").option("--json","Output as JSON").option("--schema-only","Show only extracted schema data").option("--raw","Show raw tester response (no processing)").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color}),i=await new g(o).getJob(t);if(e.json){let l=c.result(i);r.output(l)}else{if(console.log(`
|
|
23
23
|
\u{1F4CA} Test Results: `+t+`
|
|
24
24
|
`),console.log("=".repeat(80)),console.log("Job Information"),console.log("=".repeat(80)+`
|
|
25
25
|
`),console.log(" Job ID: "+i.id),console.log(" Status: "+i.status),console.log(" URL: "+i.url),console.log(" Description: "+i.description),console.log(" Started: "+i.createdAt),i.completedAt&&console.log(" Completed: "+i.completedAt),i.testDurationSeconds&&console.log(" Duration: "+r.formatDuration(i.testDurationSeconds)),i.costUsd&&console.log(" Cost: $"+i.costUsd.toFixed(3)),i.testerName&&console.log(" Tester: "+i.testerName),i.result&&Object.keys(i.result).length>0&&!e.raw){console.log(`
|
|
26
26
|
`+"=".repeat(80)),console.log("Structured Results (Extracted)"),console.log("=".repeat(80)+`
|
|
27
|
-
`);for(let[
|
|
27
|
+
`);for(let[l,p]of Object.entries(i.result)){let f=typeof p=="object"?JSON.stringify(p,null,2):String(p);console.log(` ${l}:`.padEnd(30)+f)}}i.testerResponse&&!e.schemaOnly&&(console.log(`
|
|
28
28
|
`+"=".repeat(80)),console.log("Tester Feedback"),console.log("=".repeat(80)+`
|
|
29
29
|
`),console.log(" "+i.testerResponse.split(`
|
|
30
30
|
`).join(`
|
|
31
31
|
`))),console.log(`
|
|
32
32
|
`+"=".repeat(80)+`
|
|
33
|
-
`)}}catch(n){let o=m(n);new
|
|
34
|
-
\u{1F4CB} Recent Jobs (${
|
|
35
|
-
`),console.log(r.formatJobList(
|
|
33
|
+
`)}}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s}U();k();S();I();import{Command as lo}from"commander";function Je(){let s=new lo("list");return s.description("List all jobs with optional filtering").argument("[filter]","Status filter: all|pending|claimed|in_progress|completed|failed|timeout").option("--project <id>","Filter by project").option("--limit <number>","Number of results (default: 20)",parseInt).option("--offset <number>","Pagination offset (default: 0)",parseInt).option("--json","Output as JSON").option("--format <type>","Output format: table|json|compact").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,format:e.format,color:o.color}),u=new g(o),i={limit:e.limit||20,offset:e.offset||0};t&&t!=="all"&&(i.status=t),e.project&&(i.projectId=e.project);let{jobs:l,total:p}=await u.listJobs(i);if(e.json){let f=c.result({jobs:l,total:p});r.output(f)}else console.log(`
|
|
34
|
+
\u{1F4CB} Recent Jobs (${l.length} of ${p})
|
|
35
|
+
`),console.log(r.formatJobList(l)),console.log(`
|
|
36
36
|
\u{1F4A1} View details: runhuman status <jobId>`),console.log(` View results: runhuman results <jobId>
|
|
37
|
-
`)}catch(n){let o=new
|
|
37
|
+
`)}catch(n){let o=new c({json:e.json}),r=m(n);o.outputError(r.message,r.details),process.exit(r.exitCode)}}),s}U();k();S();I();import{Command as uo}from"commander";function _e(){let s=new uo("delete");return s.description("Delete a job permanently").argument("<jobId>","Job ID to delete").option("--confirm","Skip confirmation prompt").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color});if(!e.json&&!e.confirm)throw console.log(`
|
|
38
38
|
\u26A0\uFE0F Warning: This will permanently delete job ${t}`),console.log(` This action cannot be undone.
|
|
39
|
-
`),new Error("Please use --confirm flag to delete the job");if(await new g(o).deleteJob(t),e.json){let i=
|
|
39
|
+
`),new Error("Please use --confirm flag to delete the job");if(await new g(o).deleteJob(t),e.json){let i=c.result({success:!0,message:"Job deleted successfully",jobId:t});r.output(i)}else console.log(`
|
|
40
40
|
\u2705 Job deleted successfully
|
|
41
41
|
`),console.log(` Job ID: ${t}`),console.log(` Status: Permanently deleted
|
|
42
|
-
`)}catch(n){let o=m(n);new
|
|
42
|
+
`)}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s}U();k();S();I();import{Command as po}from"commander";import mo from"chokidar";import{existsSync as Q,readFileSync as re,writeFileSync as go,unlinkSync as fo}from"fs";import{join as Fe}from"path";import{homedir as ze}from"os";var $=Fe(ze(),".config","runhuman","watch.pid");function Ke(){let s=new po("watch");return s.description("Watch files and auto-create QA test jobs on changes").argument("[patterns...]",'File patterns to watch (e.g., "src/**/*.tsx")').option("--url <url>","URL to test (required)").option("--template <name>","Template to use for tests").option("--description <text>","Test description").option("--debounce <ms>","Debounce delay in milliseconds",parseInt).option("--ignore <patterns...>","Patterns to ignore").option("--stop","Stop existing watch process").option("--status","Check if watch is running").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{if(e.stop){await bo();return}if(e.status){yo();return}Ge()&&(console.log(`
|
|
43
43
|
\u26A0\uFE0F Watch mode is already running`),console.log(` Use --stop to stop it first
|
|
44
|
-
`),process.exit(1));let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=o.watch||{},
|
|
44
|
+
`),process.exit(1));let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=o.watch||{},u=t.length>0?t:r.patterns||["src/**/*"],i=e.ignore||r.ignore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"],l=e.debounce||r.debounce||2e3,p=e.url||r.url||o.defaultUrl,f=e.description||r.description||"Auto-test from watch mode",h=e.template||r.template;p||(console.log(`
|
|
45
45
|
\u274C Error: URL required
|
|
46
46
|
`),console.log(`Provide via --url flag or set in .runhumanrc:
|
|
47
47
|
`),console.log(' runhuman watch --url "https://myapp.com"'),console.log(` OR add to .runhumanrc: { "watch": { "url": "..." } }
|
|
48
48
|
`),process.exit(1)),o.project||(console.log(`
|
|
49
49
|
\u274C Error: No project selected
|
|
50
50
|
`),console.log(`Run: runhuman projects switch <project-id>
|
|
51
|
-
`),process.exit(1));let y=new
|
|
51
|
+
`),process.exit(1));let y=new c({color:o.color});console.log(`
|
|
52
52
|
\u{1F440} Starting watch mode
|
|
53
|
-
`),console.log(` Watching: ${
|
|
53
|
+
`),console.log(` Watching: ${u.join(", ")}`),console.log(` Ignoring: ${i.join(", ")}`),console.log(` Debounce: ${l}ms`),console.log(` URL: ${p}`),h&&console.log(` Template: ${h}`),console.log(`
|
|
54
54
|
Press Ctrl+C to stop
|
|
55
|
-
`),
|
|
55
|
+
`),ho(process.pid);let w=new g(o),C=null,v=new Set,T=mo.watch(u,{ignored:i,persistent:!0,ignoreInitial:!0});T.on("change",_=>{v.add(_),console.log(` \u{1F4DD} Changed: ${_}`),C&&clearTimeout(C),C=setTimeout(async()=>{let se=Array.from(v);v.clear(),console.log(`
|
|
56
56
|
\u{1F680} Creating test job for ${se.length} file(s)...
|
|
57
|
-
`);try{let Y={projectId:o.project,url:
|
|
57
|
+
`);try{let Y={projectId:o.project,url:p,description:`${f}
|
|
58
58
|
|
|
59
59
|
Changed files:
|
|
60
|
-
${se.map(
|
|
61
|
-
`)}`,templateId:h},
|
|
60
|
+
${se.map(ct=>`- ${ct}`).join(`
|
|
61
|
+
`)}`,templateId:h},G=await w.createJob(Y);console.log(` \u2705 Job created: ${G.jobId}`),console.log(` \u{1F4CA} Dashboard: https://runhuman.com/dashboard/jobs/${G.jobId}
|
|
62
62
|
`),console.log(` Watching for more changes...
|
|
63
|
-
`)}catch(Y){let
|
|
63
|
+
`)}catch(Y){let G=m(Y);y.outputError(G.message,G.details),console.log(`
|
|
64
64
|
Watching for more changes...
|
|
65
|
-
`)}},
|
|
65
|
+
`)}},l)}),T.on("error",_=>{console.error(`
|
|
66
66
|
\u274C Watch error: ${_ instanceof Error?_.message:String(_)}
|
|
67
|
-
`)});let
|
|
67
|
+
`)});let K=()=>{console.log(`
|
|
68
68
|
|
|
69
69
|
\u{1F44B} Stopping watch mode...
|
|
70
|
-
`),T.close(),
|
|
70
|
+
`),T.close(),H(),process.exit(0)};process.on("SIGINT",K),process.on("SIGTERM",K)}catch(n){let o=m(n);new c({}).outputError(o.message,o.details),H(),process.exit(o.exitCode)}}),s}function ho(s){let t=Fe(ze(),".config","runhuman");Q(t)||ut("fs").mkdirSync(t,{recursive:!0}),go($,s.toString())}function H(){Q($)&&fo($)}function Ge(){if(!Q($))return!1;try{let s=parseInt(re($,"utf-8"));return process.kill(s,0),!0}catch{return H(),!1}}async function bo(){if(!Q($)){console.log(`
|
|
71
71
|
\u2139\uFE0F Watch mode is not running
|
|
72
|
-
`);return}try{let s=parseInt(re($,"utf-8"));process.kill(s,"SIGTERM"),
|
|
72
|
+
`);return}try{let s=parseInt(re($,"utf-8"));process.kill(s,"SIGTERM"),H(),console.log(`
|
|
73
73
|
\u2705 Watch mode stopped
|
|
74
|
-
`)}catch{
|
|
74
|
+
`)}catch{H(),console.log(`
|
|
75
75
|
\u2139\uFE0F Watch process not found (already stopped)
|
|
76
|
-
`)}}function
|
|
76
|
+
`)}}function yo(){if(Ge()){let s=parseInt(re($,"utf-8"));console.log(`
|
|
77
77
|
\u2705 Watch mode is running`),console.log(` \u{1F4DD} PID: ${s}`),console.log(`
|
|
78
78
|
Stop with: runhuman watch --stop
|
|
79
79
|
`)}else console.log(`
|
|
80
80
|
\u2139\uFE0F Watch mode is not running
|
|
81
|
-
`)}
|
|
82
|
-
Please visit: ${f}`)}}else console.log(`Please visit: ${f}`);console.log(""),console.log("Waiting for authentication...")});let
|
|
81
|
+
`)}U();k();I();S();import{Command as So}from"commander";import jo from"http";import{URL as wo}from"url";import Co from"open";async function X(s){let{apiUrl:t,autoOpenBrowser:e=!0}=s;return new Promise((n,o)=>{let r=jo.createServer((i,l)=>{if(!i.url){l.writeHead(400),l.end("Bad request");return}let p=new wo(i.url,"http://localhost");if(p.pathname==="/callback"){let f=p.searchParams.get("token"),h=p.searchParams.get("email"),y=p.searchParams.get("projectId"),w=p.searchParams.get("error");if(w){l.writeHead(200,{"Content-Type":"text/html"}),l.end(He(w)),r.close(),o(new Error(w));return}if(f&&h&&y){l.writeHead(200,{"Content-Type":"text/html"}),l.end(Io(h)),r.close(),n({token:f,email:h,projectId:y});return}l.writeHead(400,{"Content-Type":"text/html"}),l.end(He("Missing token, email, or projectId in callback")),r.close(),o(new Error("Missing token, email, or projectId in callback"));return}l.writeHead(404),l.end("Not found")});r.listen(0,"127.0.0.1",async()=>{let i=r.address();if(!i||typeof i=="string"){o(new Error("Failed to start local server"));return}let p=`http://127.0.0.1:${i.port}/callback`,f=`${t}/cli/auth?callback=${encodeURIComponent(p)}`;if(console.log(""),e){console.log("Opening browser for authentication...");try{await Co(f)}catch{console.log("Could not open browser automatically."),console.log(`
|
|
82
|
+
Please visit: ${f}`)}}else console.log(`Please visit: ${f}`);console.log(""),console.log("Waiting for authentication...")});let u=setTimeout(()=>{r.close(),o(new Error("Authentication timed out. Please try again."))},60*1e3);r.on("close",()=>clearTimeout(u)),r.on("error",i=>{clearTimeout(u),o(new Error(`Failed to start local server: ${i.message}`))})})}function Io(s){return`<!DOCTYPE html>
|
|
83
83
|
<html>
|
|
84
84
|
<head>
|
|
85
85
|
<title>Runhuman CLI - Authenticated</title>
|
|
@@ -91,19 +91,26 @@ Please visit: ${f}`)}}else console.log(`Please visit: ${f}`);console.log(""),con
|
|
|
91
91
|
align-items: center;
|
|
92
92
|
min-height: 100vh;
|
|
93
93
|
margin: 0;
|
|
94
|
-
background: linear-gradient(135deg, #
|
|
95
|
-
color:
|
|
94
|
+
background: linear-gradient(135deg, #121212 0%, #171717 100%);
|
|
95
|
+
color: #f0f0f0;
|
|
96
96
|
}
|
|
97
97
|
.container {
|
|
98
98
|
text-align: center;
|
|
99
99
|
padding: 40px;
|
|
100
|
-
background: rgba(
|
|
100
|
+
background: rgba(189, 224, 57, 0.1);
|
|
101
|
+
border: 1px solid rgba(189, 224, 57, 0.2);
|
|
101
102
|
border-radius: 16px;
|
|
102
103
|
backdrop-filter: blur(10px);
|
|
103
104
|
}
|
|
104
|
-
h1 {
|
|
105
|
+
h1 {
|
|
106
|
+
margin-bottom: 16px;
|
|
107
|
+
color: #BDE039;
|
|
108
|
+
}
|
|
105
109
|
p { opacity: 0.9; }
|
|
106
|
-
.email {
|
|
110
|
+
.email {
|
|
111
|
+
font-weight: bold;
|
|
112
|
+
color: #BDE039;
|
|
113
|
+
}
|
|
107
114
|
.close-note { margin-top: 24px; font-size: 14px; opacity: 0.7; }
|
|
108
115
|
</style>
|
|
109
116
|
</head>
|
|
@@ -114,7 +121,7 @@ Please visit: ${f}`)}}else console.log(`Please visit: ${f}`);console.log(""),con
|
|
|
114
121
|
<p class="close-note">You can close this tab and return to the terminal.</p>
|
|
115
122
|
</div>
|
|
116
123
|
</body>
|
|
117
|
-
</html>`}function
|
|
124
|
+
</html>`}function He(s){return`<!DOCTYPE html>
|
|
118
125
|
<html>
|
|
119
126
|
<head>
|
|
120
127
|
<title>Runhuman CLI - Authentication Failed</title>
|
|
@@ -126,18 +133,28 @@ Please visit: ${f}`)}}else console.log(`Please visit: ${f}`);console.log(""),con
|
|
|
126
133
|
align-items: center;
|
|
127
134
|
min-height: 100vh;
|
|
128
135
|
margin: 0;
|
|
129
|
-
background: linear-gradient(135deg, #
|
|
130
|
-
color:
|
|
136
|
+
background: linear-gradient(135deg, #121212 0%, #171717 100%);
|
|
137
|
+
color: #f0f0f0;
|
|
131
138
|
}
|
|
132
139
|
.container {
|
|
133
140
|
text-align: center;
|
|
134
141
|
padding: 40px;
|
|
135
|
-
background: rgba(
|
|
142
|
+
background: rgba(230, 72, 61, 0.1);
|
|
143
|
+
border: 1px solid rgba(230, 72, 61, 0.2);
|
|
136
144
|
border-radius: 16px;
|
|
137
145
|
backdrop-filter: blur(10px);
|
|
138
146
|
}
|
|
139
|
-
h1 {
|
|
140
|
-
|
|
147
|
+
h1 {
|
|
148
|
+
margin-bottom: 16px;
|
|
149
|
+
color: #e6483d;
|
|
150
|
+
}
|
|
151
|
+
.error {
|
|
152
|
+
background: rgba(230, 72, 61, 0.2);
|
|
153
|
+
padding: 12px;
|
|
154
|
+
border-radius: 8px;
|
|
155
|
+
margin-top: 16px;
|
|
156
|
+
border: 1px solid rgba(230, 72, 61, 0.3);
|
|
157
|
+
}
|
|
141
158
|
</style>
|
|
142
159
|
</head>
|
|
143
160
|
<body>
|
|
@@ -147,96 +164,96 @@ Please visit: ${f}`)}}else console.log(`Please visit: ${f}`);console.log(""),con
|
|
|
147
164
|
<div class="error">${s}</div>
|
|
148
165
|
</div>
|
|
149
166
|
</body>
|
|
150
|
-
</html>`}function
|
|
151
|
-
`))}async function
|
|
152
|
-
`))}k();I();S();import{Command as
|
|
153
|
-
`)}catch(e){let n=m(e);new
|
|
167
|
+
</html>`}function We(){let s=new So("login");return s.description("Authenticate with Runhuman").option("--token <token>","Login with API key (skip browser)").option("--no-browser","Print auth URL instead of opening browser").option("--json","Output as JSON").action(async t=>{try{let e=new d,n=await e.loadConfig(),o=new c({json:t.json,color:n.color});if(t.token)await Ao(e,o,t.token,t.json);else{let r=t.browser!==!1&&n.autoOpenBrowser!==!1;await ko(e,o,n.apiUrl,r,t.json)}}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s}async function Ao(s,t,e,n){s.saveCredentials({accessToken:e});let o=await s.loadConfig({apiKey:e}),u=await new g(o).getCurrentUser();s.saveUserInfo(u),n?t.output(c.result({success:!0,user:u})):(t.success("Successfully logged in!"),console.log(` User: ${u.email}`),console.log(` Account ID: ${u.accountId}
|
|
168
|
+
`))}async function ko(s,t,e,n,o){o||console.log("Logging in to Runhuman...");let r=await X({apiUrl:e||"https://runhuman.com",autoOpenBrowser:n});s.saveCredentials({accessToken:r.token}),await s.set("project",r.projectId,!0);let u=await s.loadConfig({apiKey:r.token}),l=await new g(u).getCurrentUser();s.saveUserInfo(l),o?t.output(c.result({success:!0,user:l,projectId:r.projectId})):(console.log(""),t.success("Successfully logged in!"),console.log(` User: ${l.email}`),console.log(` Account ID: ${l.accountId}`),console.log(` Default Project: ${r.projectId}
|
|
169
|
+
`)),process.exit(0)}k();I();S();import{Command as xo}from"commander";function qe(){let s=new xo("logout");return s.description("Log out and clear stored credentials").option("--force","Skip confirmation prompt").option("--json","Output as JSON").action(async t=>{try{let e=new d,n=new c({json:t.json});if(e.clearCredentials(),e.clearUserInfo(),t.json){let o=c.result({success:!0,message:"Logged out successfully"});n.output(o)}else n.success("Logged out successfully!"),console.log(`Credentials have been cleared.
|
|
170
|
+
`)}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s}U();k();I();S();import{Command as Uo}from"commander";function Ve(){let s=new Uo("whoami");return s.description("Display current user information").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let e=new d,n=await e.loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new c({json:t.json}),r=new g(n),u=await r.getCurrentUser(),i;try{i=(await r.getTokenBalance()).balance}catch{i=null}let l=e.loadUserInfo();if(t.json){let p=c.result({user:u,balance:i});o.output(p)}else console.log(`
|
|
154
171
|
\u{1F464} Current User
|
|
155
|
-
`),console.log(" Email: "+
|
|
156
|
-
Default Project: `+n.project),console.log()}catch(e){let n=m(e);new
|
|
157
|
-
\u{1F4B0}
|
|
158
|
-
`),console.log(` Current Balance:
|
|
159
|
-
`),console.log(`\u{1F4A1}
|
|
160
|
-
`)}catch(e){let n=m(e);new
|
|
172
|
+
`),console.log(" Email: "+u.email),console.log(" Account ID: "+u.accountId),i!==null&&console.log(" Token Balance: $"+i.toFixed(2)),n.project&&console.log(`
|
|
173
|
+
Default Project: `+n.project),console.log()}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s}U();k();I();S();import{Command as Po}from"commander";function Be(){let s=new Po("tokens");return s.description("View token balance and usage"),s.command("balance").description("Check account balance").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let n=await new d().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new c({json:t.json,color:n.color}),r=new g(n),{balance:u}=await r.getTokenBalance();if(t.json){let i=c.result({balance:u});o.output(i)}else{let i=(u/100).toFixed(2),l=Math.floor(u/100);console.log(`
|
|
174
|
+
\u{1F4B0} Account Balance
|
|
175
|
+
`),console.log(` Current Balance: $${i}`),console.log(` Estimated Tests: ~${l} tests at $1.00 per test
|
|
176
|
+
`),console.log(`\u{1F4A1} Monitor your Usage: https://runhuman.com/dashboard/usage
|
|
177
|
+
`)}}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s.command("history").description("View token usage history").option("--limit <number>","Number of records (default: 20)",parseInt).option("--offset <number>","Pagination offset (default: 0)",parseInt).option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let n=await new d().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new c({json:t.json,color:n.color});if(t.json){let r=c.result({message:"Token history endpoint not yet available",history:[]});o.output(r)}else console.log(`
|
|
161
178
|
\u{1F4CA} Token Usage History
|
|
162
179
|
`),console.log(` This feature is coming soon!
|
|
163
180
|
`),console.log(" For now, view usage in the dashboard:"),console.log(` https://runhuman.com/dashboard/usage
|
|
164
|
-
`)}catch(e){let n=m(e);new
|
|
181
|
+
`)}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s}k();I();S();import{Command as To}from"commander";function Qe(){let s=new To("config");return s.description("Manage CLI configuration"),s.command("get").description("Get a configuration value").argument("<key>","Configuration key").option("--json","Output as JSON").action(async(t,e)=>{try{let o=await new d().get(t),r=new c({json:e.json});if(e.json){let u=c.result({[t]:o});r.output(u)}else console.log(o!==void 0?o:"(not set)")}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("set").description("Set a configuration value").argument("<key>","Configuration key").argument("<value>","Configuration value").option("--global","Set globally (not project-specific)").option("--json","Output as JSON").action(async(t,e,n)=>{try{await new d().set(t,e,n.global);let r=new c({json:n.json});if(n.json){let u=c.result({success:!0,key:t,value:e,scope:n.global?"global":"project"});r.output(u)}else r.success(`Set ${t} = ${e}`+(n.global?" (global)":" (project)"))}catch(o){let r=m(o);new c({json:n.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),s.command("list").description("List all configuration values").option("--show-secrets","Show API keys (default: masked)").option("--json","Output as JSON").action(async t=>{try{let n=await new d().list(),o=new c({json:t.json});if(t.json){let r=c.result(n);o.output(r)}else{if(console.log(`
|
|
165
182
|
\u2699\uFE0F Configuration
|
|
166
|
-
`),n.global&&Object.keys(n.global).length>0){console.log("Global (~/.config/runhuman/config.json):");for(let[r,
|
|
167
|
-
`)}}catch(e){let n=m(e);new
|
|
168
|
-
`),process.exit(0)),await new d().reset(e);let o=new
|
|
183
|
+
`),n.global&&Object.keys(n.global).length>0){console.log("Global (~/.config/runhuman/config.json):");for(let[r,u]of Object.entries(n.global)){let i=r==="apiKey"&&!t.showSecrets?Ze(String(u)):u;console.log(` ${r}:`.padEnd(20)+i)}console.log()}if(n.project&&Object.keys(n.project).length>0){console.log("Project (.runhumanrc):");for(let[r,u]of Object.entries(n.project)){let i=r==="apiKey"&&!t.showSecrets?Ze(String(u)):u;console.log(` ${r}:`.padEnd(20)+i)}console.log()}console.log("\u{1F4A1} Set value: runhuman config set <key> <value>"),console.log(` Get value: runhuman config get <key>
|
|
184
|
+
`)}}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s.command("reset").description("Reset configuration to defaults").option("--global","Reset global config").option("--project","Reset project config").option("--all","Reset all config").option("--force","Skip confirmation prompt").option("--json","Output as JSON").action(async t=>{try{if(!t.global&&!t.project&&!t.all)throw new Error("Specify --global, --project, or --all");let e=t.all?"all":t.global?"global":"project";t.force||(console.log(`\u26A0\uFE0F This will reset ${e} configuration to defaults.`),console.log(`Use --force to skip this prompt.
|
|
185
|
+
`),process.exit(0)),await new d().reset(e);let o=new c({json:t.json});if(t.json){let r=c.result({success:!0,scope:e});o.output(r)}else o.success(`Reset ${e} configuration`)}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s}function Ze(s){return s.length<=8?"****":s.substring(0,4)+"*".repeat(s.length-8)+s.substring(s.length-4)}I();S();import{Command as Ro}from"commander";import Eo from"inquirer";import{writeFileSync as Oo}from"fs";import{join as No}from"path";function Xe(){let s=new Ro("init");return s.description("Initialize a new Runhuman project with configuration").option("--name <text>","Project name").option("--url <url>","Default URL").option("--github-repo <owner/repo>","GitHub repository").option("--yes","Skip all prompts (use defaults)").option("--json","Output as JSON").action(async t=>{try{let e=new c({json:t.json});!t.json&&!t.yes&&(console.log(`\u{1F680} Welcome to Runhuman!
|
|
169
186
|
`),console.log("Let's set up your project. This will create:"),console.log(" \u2022 A configuration file (.runhumanrc)"),console.log(` \u2022 Setup your project defaults
|
|
170
187
|
`),console.log("=".repeat(60)+`
|
|
171
|
-
`));let n=t.name,o=t.url,r=t.githubRepo;if(!t.yes&&!t.json){let
|
|
188
|
+
`));let n=t.name,o=t.url,r=t.githubRepo;if(!t.yes&&!t.json){let l=await Eo.prompt([{type:"input",name:"projectName",message:"Project name:",default:"My Project",when:!n},{type:"input",name:"defaultUrl",message:"Default URL (optional):",when:!o},{type:"input",name:"githubRepo",message:"Link to GitHub repository (optional, e.g., owner/repo):",when:!r}]);n=n||l.projectName,o=o||l.defaultUrl,r=r||l.githubRepo}let u={defaultUrl:o||void 0,githubRepo:r||void 0,defaultDuration:5,defaultScreenSize:"desktop"},i=No(process.cwd(),".runhumanrc");if(Oo(i,JSON.stringify(u,null,2)),t.json){let l=c.result({success:!0,configPath:i,config:u});e.output(l)}else console.log(`
|
|
172
189
|
`+"=".repeat(60)),e.success("Project initialized successfully!"),console.log(`\u{1F4C1} Configuration saved to: .runhumanrc
|
|
173
190
|
`),console.log(`\u{1F389} All set! Try creating your first test:
|
|
174
191
|
`),console.log(` runhuman create https://example.com -d "Test homepage"
|
|
175
192
|
`),console.log(`\u{1F4DA} Learn more: https://runhuman.com/docs/cli
|
|
176
|
-
`)}catch(e){let n=m(e);new
|
|
177
|
-
\u{1F4C1} Your Projects (${
|
|
178
|
-
`);let
|
|
193
|
+
`)}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s}U();k();I();S();import{Command as vo}from"commander";import Do from"cli-table3";function Ye(){let s=new vo("projects");return s.description("Manage projects"),s.command("list").alias("ls").description("List all projects").option("--limit <number>","Number of results (default: 20)",parseInt).option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let n=await new d().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new c({json:t.json,color:n.color}),r=new g(n),{items:u,pagination:i}=await r.listProjects({limit:t.limit||20});if(t.json){let l=c.result({projects:u,pagination:i});o.output(l)}else{console.log(`
|
|
194
|
+
\u{1F4C1} Your Projects (${u.length} of ${i.total})
|
|
195
|
+
`);let l=new Do({head:["Project ID","Name","Created"].map(p=>p),colWidths:[20,30,20]});u.forEach(p=>{l.push([p.id,p.name,new Date(p.createdAt).toLocaleDateString()])}),console.log(l.toString()),console.log(`
|
|
179
196
|
\u{1F4A1} Set default project: runhuman config set project <id>
|
|
180
|
-
`)}}catch(e){let n=m(e);new
|
|
197
|
+
`)}}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s.command("create").alias("new").description("Create a new project").argument("<name>","Project name").option("--description <text>","Project description").option("--default-url <url>","Default URL for tests").option("--github-repo <owner/repo>","Link to GitHub repository").option("--set-default","Set as default project").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let n=new d,o=await n.loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color}),i=await new g(o).createProject({name:t,description:e.description,defaultUrl:e.defaultUrl,githubRepo:e.githubRepo});if(e.setDefault&&await n.set("project",i.id,!1),e.json){let l=c.result(i);r.output(l)}else r.success("Project created successfully!"),console.log(" Project ID: "+i.id),console.log(" Name: "+i.name),e.setDefault&&console.log(" Set as default project"),console.log()}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("show").alias("info").alias("get").description("Show detailed project information").argument("<projectId>","Project ID to show").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color}),i=await new g(o).getProject(t);if(e.json){let l=c.result(i);r.output(l)}else console.log(`
|
|
181
198
|
\u{1F4C1} Project Details
|
|
182
|
-
`),console.log(" Project ID: "+i.id),console.log(" Name: "+i.name),i.description&&console.log(" Description: "+i.description),i.defaultUrl&&console.log(" Default URL: "+i.defaultUrl),i.githubRepo&&console.log(" GitHub Repo: "+i.githubRepo),console.log(" Created: "+new Date(i.createdAt).toLocaleString()),console.log()}catch(n){let o=m(n);new
|
|
183
|
-
`),process.exit(0));let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new
|
|
199
|
+
`),console.log(" Project ID: "+i.id),console.log(" Name: "+i.name),i.description&&console.log(" Description: "+i.description),i.defaultUrl&&console.log(" Default URL: "+i.defaultUrl),i.githubRepo&&console.log(" GitHub Repo: "+i.githubRepo),console.log(" Created: "+new Date(i.createdAt).toLocaleString()),console.log()}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("switch").alias("use").description("Set default project for CLI commands").argument("<projectId>","Project ID to use as default").option("--global","Set as global default instead of local").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let n=new d,o=await n.loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color}),i=await new g(o).getProject(t);if(await n.set("project",t,e.global!==!1),e.json){let l=c.result({success:!0,projectId:t,projectName:i.name,scope:e.global!==!1?"global":"local"});r.output(l)}else r.success(`Default project set to: ${i.name} (${t})`),e.global!==!1?console.log(" Scope: global (all directories)"):console.log(" Scope: local (current directory only)"),console.log()}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("update").description("Update project settings").argument("<projectId>","Project ID to update").option("--name <text>","Update name").option("--description <text>","Update description").option("--default-url <url>","Update default URL").option("--github-repo <owner/repo>","Update GitHub repo").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color}),u={name:e.name,description:e.description,defaultUrl:e.defaultUrl,githubRepo:e.githubRepo},l=await new g(o).updateProject(t,u);if(e.json){let p=c.result(l);r.output(p)}else r.success("Project updated successfully!")}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("delete").alias("rm").description("Delete a project permanently").argument("<projectId>","Project ID to delete").option("--force","Skip confirmation prompt").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{e.force||(console.log("\u26A0\uFE0F This will permanently delete the project and all its data."),console.log(`Use --force to skip this prompt.
|
|
200
|
+
`),process.exit(0));let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color});if(await new g(o).deleteProject(t),e.json){let i=c.result({success:!0});r.output(i)}else r.success("Project deleted successfully!")}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s}U();k();I();S();import{Command as $o}from"commander";import Mo from"cli-table3";function et(){let s=new $o("keys");return s.description("Manage API keys"),s.command("list").alias("ls").description("List all API keys").option("--project <id>","Filter by project (required)").option("--show-keys","Show full API keys (default: masked)").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let n=await new d().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=t.project||n.project;if(!o)throw new Error("Project ID required (use --project or set default project)");let r=new c({json:t.json,color:n.color}),i=await new g(n).listApiKeys(o);if(t.json){let l=c.result({keys:i});r.output(l)}else{console.log(`
|
|
184
201
|
\u{1F511} API Keys (${i.length})
|
|
185
|
-
`);let
|
|
202
|
+
`);let l=new Mo({head:["Key ID","Name","Key","Last Used","Created"].map(p=>p),colWidths:[20,25,20,20,20]});i.forEach(p=>{let f=t.showKeys?p.key:Lo(p.key),h=p.lastUsedAt?new Date(p.lastUsedAt).toLocaleDateString():"Never";l.push([p.id,p.name,f,h,new Date(p.createdAt).toLocaleDateString()])}),console.log(l.toString()),console.log(`
|
|
186
203
|
\u{1F4A1} Create new key: runhuman keys create "Key Name" --project <id>`),console.log(` Show full key: runhuman keys show <keyId>
|
|
187
|
-
`)}}catch(e){let n=m(e);new
|
|
188
|
-
Key ID: `+
|
|
189
|
-
API Key: `+
|
|
190
|
-
`),console.log("\u{1F4A1} Use this key:"),console.log(" export RUNHUMAN_API_KEY="+
|
|
204
|
+
`)}}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s.command("create").alias("new").description("Create a new API key").argument("<name>","API key name").option("--project <id>","Project ID (required)").option("--copy","Copy key to clipboard").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.project||o.project;if(!r)throw new Error("Project ID required (use --project or set default project)");let u=new c({json:e.json,color:o.color}),l=await new g(o).createApiKey(r,t);if(e.json){let p=c.result(l);u.output(p)}else u.success("API Key created successfully!"),console.log(`
|
|
205
|
+
Key ID: `+l.id),console.log(" Name: "+l.name),console.log(`
|
|
206
|
+
API Key: `+l.key),console.log(" "+"^".repeat(l.key.length)),console.log(` \u26A0\uFE0F Save this key! It won't be shown again.
|
|
207
|
+
`),console.log("\u{1F4A1} Use this key:"),console.log(" export RUNHUMAN_API_KEY="+l.key),console.log(` runhuman create https://myapp.com -d "Test"
|
|
191
208
|
`),console.log("\u{1F512} Store securely:"),console.log(" - Use environment variables (recommended)"),console.log(" - Use secret management tools"),console.log(` - Never commit to git!
|
|
192
|
-
`)}catch(n){let o=m(n);new
|
|
193
|
-
`)}catch(n){let o=m(n);new
|
|
194
|
-
`),process.exit(0));let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new
|
|
209
|
+
`)}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("show").alias("info").alias("get").description("Show details of a specific API key").argument("<keyId>","Key ID to show").option("--show-key","Show full API key (default: masked)").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl});new c({json:e.json,color:o.color}).warn("Note: keys show requires listing all keys first"),console.log(`Use: runhuman keys list --show-keys
|
|
210
|
+
`)}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("delete").aliases(["rm","revoke"]).description("Delete an API key permanently").argument("<keyId>","Key ID to delete").option("--force","Skip confirmation prompt").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{e.force||(console.log("\u26A0\uFE0F This will permanently delete the API key."),console.log(`Use --force to skip this prompt.
|
|
211
|
+
`),process.exit(0));let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color});if(await new g(o).deleteApiKey(t),e.json){let i=c.result({success:!0});r.output(i)}else r.success("API key deleted successfully!")}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s}function Lo(s){return s.length<=12?"****":s.substring(0,8)+"*".repeat(s.length-12)+s.substring(s.length-4)}U();k();I();S();import{Command as Jo}from"commander";import _o from"cli-table3";function tt(){let s=new Jo("templates");return s.description("Manage test templates"),s.command("list").alias("ls").description("List all test templates").option("--project <id>","Filter by project (required)").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let n=await new d().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=t.project||n.project;if(!o)throw new Error("Project ID required (use --project or set default project)");let r=new c({json:t.json,color:n.color}),i=await new g(n).listTemplates(o);if(t.json){let l=c.result({templates:i});r.output(l)}else{console.log(`
|
|
195
212
|
\u{1F4CB} Test Templates (${i.length})
|
|
196
|
-
`);let
|
|
213
|
+
`);let l=new _o({head:["ID","Name","Description","Created"].map(p=>p),colWidths:[30,25,35,20]});i.forEach(p=>{let f=p.description&&p.description.length>30?p.description.substring(0,27)+"...":p.description||"-";l.push([p.id,p.name,f,new Date(p.createdAt).toLocaleDateString()])}),console.log(l.toString()),console.log(`
|
|
197
214
|
\u{1F4A1} Create new template: runhuman templates create "Template Name" --project <id>`),console.log(` View template: runhuman templates show <templateId>
|
|
198
|
-
`)}}catch(e){let n=m(e);new
|
|
215
|
+
`)}}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s.command("create").alias("new").description("Create a new test template").argument("<name>","Template name").option("--project <id>","Project ID (required)").option("-d, --description <text>","Template description").option("--duration <seconds>","Target test duration in seconds").option("--screen-size <size>","Default screen size (desktop/mobile/tablet)").option("--schema <path>","Path to JSON schema file").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.project||o.project;if(!r)throw new Error("Project ID required (use --project or set default project)");let u=new c({json:e.json,color:o.color}),i;if(e.schema){let{readFileSync:h}=await import("fs"),y=h(e.schema,"utf-8");i=JSON.parse(y)}let l={name:t,description:e.description,targetDurationMinutes:e.duration?Math.floor(parseInt(e.duration)/60):void 0,defaultScreenSize:e.screenSize,outputSchema:i},f=await new g(o).createTemplate(r,l);if(e.json){let h=c.result(f);u.output(h)}else u.success("Template created successfully!"),console.log(`
|
|
199
216
|
Template ID: `+f.id),console.log(" Name: "+f.name),f.description&&console.log(" Description: "+f.description),console.log(`
|
|
200
217
|
\u{1F4A1} Use this template:`),console.log(" runhuman create https://myapp.com --template "+f.id+`
|
|
201
|
-
`)}catch(n){let o=m(n);new
|
|
218
|
+
`)}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("show").alias("info").alias("get").description("Show details of a specific template").argument("<templateId>","Template ID to show").option("--project <id>","Project ID (required)").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.project||o.project;if(!r)throw new Error("Project ID required (use --project or set default project)");let u=new c({json:e.json,color:o.color}),l=await new g(o).getTemplate(r,t);if(e.json){let p=c.result(l);u.output(p)}else console.log(`
|
|
202
219
|
\u{1F4CB} Template Details
|
|
203
|
-
`),console.log("ID: "+
|
|
204
|
-
Output Schema:`),console.log(JSON.stringify(
|
|
205
|
-
\u{1F4A1} Use this template:`),console.log(" runhuman create https://myapp.com --template "+
|
|
206
|
-
`)}catch(n){let o=m(n);new
|
|
220
|
+
`),console.log("ID: "+l.id),console.log("Name: "+l.name),console.log("Description: "+(l.description||"-")),console.log("Project: "+l.projectId),l.targetDurationMinutes&&console.log("Duration: "+l.targetDurationMinutes+" minutes"),l.defaultScreenSize&&console.log("Screen Size: "+l.defaultScreenSize),console.log("Created: "+new Date(l.createdAt).toLocaleString()),l.outputSchema&&(console.log(`
|
|
221
|
+
Output Schema:`),console.log(JSON.stringify(l.outputSchema,null,2))),console.log(`
|
|
222
|
+
\u{1F4A1} Use this template:`),console.log(" runhuman create https://myapp.com --template "+l.id+`
|
|
223
|
+
`)}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("update").alias("edit").description("Update a template").argument("<templateId>","Template ID to update").option("--project <id>","Project ID (required)").option("--name <name>","New template name").option("-d, --description <text>","New description").option("--duration <seconds>","New target duration in seconds").option("--screen-size <size>","New default screen size").option("--schema <path>","Path to new JSON schema file").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.project||o.project;if(!r)throw new Error("Project ID required (use --project or set default project)");let u=new c({json:e.json,color:o.color}),i;if(e.schema){let{readFileSync:y}=await import("fs"),w=y(e.schema,"utf-8");i=JSON.parse(w)}let l={name:e.name,description:e.description,targetDurationMinutes:e.duration?Math.floor(parseInt(e.duration)/60):void 0,defaultScreenSize:e.screenSize,outputSchema:i},p=Object.fromEntries(Object.entries(l).filter(([,y])=>y!==void 0));if(Object.keys(p).length===0)throw new Error("No updates provided. Use --name, --description, --duration, --screen-size, or --schema");let h=await new g(o).updateTemplate(r,t,l);if(e.json){let y=c.result(h);u.output(y)}else u.success("Template updated successfully!"),console.log(`
|
|
207
224
|
Template ID: `+h.id),console.log(" Name: "+h.name+`
|
|
208
|
-
`)}catch(n){let o=m(n);new
|
|
209
|
-
`),process.exit(0));let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.project||o.project;if(!r)throw new Error("Project ID required (use --project or set default project)");let
|
|
225
|
+
`)}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("delete").alias("rm").description("Delete a template permanently").argument("<templateId>","Template ID to delete").option("--project <id>","Project ID (required)").option("--force","Skip confirmation prompt").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{e.force||(console.log("\u26A0\uFE0F This will permanently delete the template."),console.log(`Use --force to skip this prompt.
|
|
226
|
+
`),process.exit(0));let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.project||o.project;if(!r)throw new Error("Project ID required (use --project or set default project)");let u=new c({json:e.json,color:o.color});if(await new g(o).deleteTemplate(r,t),e.json){let l=c.result({success:!0});u.output(l)}else u.success("Template deleted successfully!")}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s}U();k();I();S();import{Command as Fo}from"commander";import ot from"cli-table3";function nt(){let s=new Fo("github");return s.alias("gh"),s.description("GitHub integration commands"),s.command("link").description("Link a GitHub repository to your project").argument("<repo>","Repository in format owner/repo").option("--project <id>","Project ID (required)").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let n=new d,o=await n.loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.project||o.project;if(!r)throw new Error("Project ID required (use --project or set default project)");let u=new c({json:e.json,color:o.color}),i=t.match(/^([^/]+)\/([^/]+)$/);if(!i)throw new Error("Invalid repository format. Use: owner/repo");let[,l,p]=i,h=await new g(o).linkGithubRepo(r,l,p);if(e.json){let y=c.result(h);u.output(y)}else u.success("GitHub repository linked successfully!"),console.log(`
|
|
210
227
|
Repository: `+t),console.log(" Project: "+r),console.log(`
|
|
211
228
|
\u{1F4A1} Now you can:`),console.log(" - List issues: runhuman github issues "+t),console.log(" - Test an issue: runhuman github test <issueNumber> --repo "+t),console.log(" - Bulk test: runhuman github bulk-test --repo "+t+`
|
|
212
229
|
`),await n.saveProjectConfig({githubRepo:t}),console.log(`\u2713 Repository saved to project config (.runhumanrc)
|
|
213
|
-
`)}catch(n){let o=m(n);new
|
|
230
|
+
`)}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("repos").alias("repositories").description("List linked GitHub repositories").option("--project <id>","Filter by project").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let n=await new d().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=t.project||n.project,r=new c({json:t.json,color:n.color}),i=await new g(n).listGithubRepos(o);if(t.json){let l=c.result({repositories:i});r.output(l)}else{console.log(`
|
|
214
231
|
\u{1F517} Linked GitHub Repositories (${i.length})
|
|
215
|
-
`);let
|
|
232
|
+
`);let l=new ot({head:["Repository","Project","Linked"].map(p=>p),colWidths:[35,30,20]});i.forEach(p=>{l.push([p.fullName,p.projectId,new Date(p.linkedAt).toLocaleDateString()])}),console.log(l.toString()),console.log(`
|
|
216
233
|
\u{1F4A1} Test an issue: runhuman github test <issueNumber> --repo owner/repo
|
|
217
|
-
`)}}catch(e){let n=m(e);new
|
|
234
|
+
`)}}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s.command("issues").description("List GitHub issues for a repository").argument("<repo>","Repository in format owner/repo").option("--state <state>","Filter by state (open/closed/all)","open").option("--labels <labels>","Filter by comma-separated labels").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new c({json:e.json,color:o.color}),u=t.match(/^([^/]+)\/([^/]+)$/);if(!u)throw new Error("Invalid repository format. Use: owner/repo");let[,i,l]=u,f=await new g(o).listGithubIssues(i,l,{state:e.state,labels:e.labels?.split(",")});if(e.json){let h=c.result({issues:f});r.output(h)}else{console.log(`
|
|
218
235
|
\u{1F41B} GitHub Issues for ${t} (${f.length})
|
|
219
|
-
`);let h=new
|
|
236
|
+
`);let h=new ot({head:["#","Title","State","Labels","Created"].map(y=>y),colWidths:[8,40,10,20,15]});f.forEach(y=>{let w=y.labels?.join(", ")||"-",C=w.length>18?w.substring(0,15)+"...":w;h.push(["#"+y.number,y.title.length>38?y.title.substring(0,35)+"...":y.title,y.state,C,new Date(y.createdAt).toLocaleDateString()])}),console.log(h.toString()),console.log(`
|
|
220
237
|
\u{1F4A1} Test an issue: runhuman github test <issueNumber> --repo `+t+`
|
|
221
|
-
`)}}catch(n){let o=m(n);new
|
|
238
|
+
`)}}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("test").description("Create a QA test job for a GitHub issue").argument("<issueNumber>","Issue number to test").option("--repo <owner/repo>","Repository (or use default from config)").option("--url <url>","URL to test (required)").option("--template <id>","Template ID to use").option("--sync","Wait for result before exiting").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new d().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.repo||o.githubRepo;if(!r)throw new Error("Repository required (use --repo or set default with: runhuman github link)");if(!e.url)throw new Error("URL required (use --url)");let u=new c({json:e.json,color:o.color}),i=r.match(/^([^/]+)\/([^/]+)$/);if(!i)throw new Error("Invalid repository format. Use: owner/repo");let[,l,p]=i,f=new g(o),h=await f.getGithubIssue(l,p,parseInt(t));if(!o.project)throw new Error("No project selected. Run: runhuman projects switch <project-id>");let y={projectId:o.project,url:e.url,description:`Test GitHub issue #${t}: ${h.title}
|
|
222
239
|
|
|
223
|
-
${h.body}`,metadata:{githubIssue:{owner:
|
|
224
|
-
Job ID: `+
|
|
225
|
-
\u{1F4A1} Check status: runhuman status `+
|
|
226
|
-
`),e.sync){let{waitForJob:C}=await Promise.resolve().then(()=>(
|
|
240
|
+
${h.body}`,metadata:{githubIssue:{owner:l,repo:p,number:parseInt(t),url:h.url}},templateId:e.template},w=await f.createJob(y);if(e.json){let C=c.result(w);u.output(C)}else if(u.success("QA test job created for issue #"+t),console.log(`
|
|
241
|
+
Job ID: `+w.jobId),console.log(" Issue: #"+t+" - "+h.title),console.log(" Status: "+w.status),console.log(" URL: "+e.url),console.log(`
|
|
242
|
+
\u{1F4A1} Check status: runhuman status `+w.jobId+`
|
|
243
|
+
`),e.sync){let{waitForJob:C}=await Promise.resolve().then(()=>(Z(),ne));await C(w.jobId,f,u,600)}}catch(n){let o=m(n);new c({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),s.command("bulk-test").description("Create QA test jobs for multiple GitHub issues").option("--repo <owner/repo>","Repository (or use default from config)").option("--url <url>","URL to test (required)").option("--labels <labels>","Filter issues by comma-separated labels").option("--state <state>","Filter by state (open/closed/all)","open").option("--template <id>","Template ID to use").option("--limit <number>","Maximum number of jobs to create","10").option("--json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let n=await new d().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=t.repo||n.githubRepo;if(!o)throw new Error("Repository required (use --repo or set default with: runhuman github link)");if(!t.url)throw new Error("URL required (use --url)");let r=new c({json:t.json,color:n.color}),u=o.match(/^([^/]+)\/([^/]+)$/);if(!u)throw new Error("Invalid repository format. Use: owner/repo");let[,i,l]=u,p=new g(n),f=await p.listGithubIssues(i,l,{state:t.state,labels:t.labels?.split(",")}),h=parseInt(t.limit),y=f.slice(0,h);if(y.length===0){console.log(`No issues found matching the criteria.
|
|
227
244
|
`);return}if(!n.project)throw new Error("No project selected. Run: runhuman projects switch <project-id>");console.log(`
|
|
228
245
|
\u{1F680} Creating ${y.length} test jobs...
|
|
229
|
-
`);let
|
|
246
|
+
`);let w=[];for(let C of y){let v={projectId:n.project,url:t.url,description:`Test GitHub issue #${C.number}: ${C.title}
|
|
230
247
|
|
|
231
|
-
${C.body}`,metadata:{githubIssue:{owner:i,repo:
|
|
232
|
-
\u2713 Created ${C} jobs`),
|
|
248
|
+
${C.body}`,metadata:{githubIssue:{owner:i,repo:l,number:C.number,url:C.url}},templateId:t.template};try{let T=await p.createJob(v);w.push({issue:C.number,jobId:T.jobId,status:"created"}),console.log(` \u2713 Issue #${C.number} \u2192 Job ${T.jobId}`)}catch(T){let K=m(T);w.push({issue:C.number,error:K.message,status:"failed"}),console.log(` \u2717 Issue #${C.number} \u2192 Failed: ${K.message}`)}}if(t.json){let C=c.result({jobs:w});r.output(C)}else{let C=w.filter(T=>T.status==="created").length,v=w.filter(T=>T.status==="failed").length;console.log(`
|
|
249
|
+
\u2713 Created ${C} jobs`),v>0&&console.log(`\u2717 Failed ${v} jobs`),console.log(`
|
|
233
250
|
\u{1F4A1} Check all jobs: runhuman list
|
|
234
|
-
`)}}catch(e){let n=m(e);new
|
|
235
|
-
Run `+
|
|
236
|
-
`);return}await
|
|
237
|
-
`),e.isRunhumanProject?await
|
|
238
|
-
Run `+
|
|
251
|
+
`)}}catch(e){let n=m(e);new c({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),s}k();U();import{existsSync as zo}from"fs";import{join as Ko}from"path";import{execSync as Go}from"child_process";import J from"inquirer";import x from"chalk";import st from"ora";S();async function it(){let s=new d,t=new c({color:!0});console.log(""),console.log(x.bold("Runhuman")+" - Human QA testing for your apps"),console.log("");let e=await rt(s);if(!e.isAuthenticated){let{shouldLogin:n}=await J.prompt([{type:"confirm",name:"shouldLogin",message:"You're not logged in. Would you like to sign in?",default:!0}]);if(!n){console.log(`
|
|
252
|
+
Run `+x.cyan("runhuman login")+` when you're ready to sign in.
|
|
253
|
+
`);return}await Ho(s,t),Object.assign(e,await rt(s))}console.log(x.green("Logged in as "+e.userEmail)+`
|
|
254
|
+
`),e.isRunhumanProject?await Wo(s,e):await qo(s,e)}async function rt(s){let t={isAuthenticated:!1,isGitRepo:!1,isRunhumanProject:!1},e=s.loadCredentials();if(e?.accessToken)try{let o=await s.loadConfig({apiKey:e.accessToken}),u=await new g(o).getCurrentUser();t.isAuthenticated=!0,t.userEmail=u.email}catch{t.isAuthenticated=!1}try{Go("git rev-parse --is-inside-work-tree",{stdio:"ignore"}),t.isGitRepo=!0}catch{t.isGitRepo=!1}let n=Ko(process.cwd(),".runhumanrc");if(zo(n)){t.isRunhumanProject=!0;try{let o=await s.loadConfig();t.projectConfig={defaultUrl:o.defaultUrl,githubRepo:o.githubRepo}}catch{}}return t}async function Ho(s,t){let e=await s.loadConfig(),n=e.apiUrl||"https://runhuman.com";console.log("");let o=st("Opening browser for authentication...").start();try{let r=await X({apiUrl:n,autoOpenBrowser:e.autoOpenBrowser!==!1});o.stop(),s.saveCredentials({accessToken:r.token});let u=await s.loadConfig({apiKey:r.token}),l=await new g(u).getCurrentUser();s.saveUserInfo(l),t.success("Successfully logged in!"),console.log("")}catch(r){throw o.stop(),r}}async function Wo(s,t){console.log(x.dim("Runhuman project detected")),t.projectConfig?.defaultUrl&&console.log(x.dim("URL: "+t.projectConfig.defaultUrl)),console.log("");let{action:e}=await J.prompt([{type:"list",name:"action",message:"What would you like to do?",choices:[{name:"Quick test a URL",value:"quick-test"},{name:"Run a template",value:"run-template"},{name:"View recent jobs",value:"list-jobs"},new J.Separator,{name:"Exit",value:"exit"}]}]);switch(e){case"quick-test":await at(s,t);break;case"run-template":console.log(`
|
|
255
|
+
Run `+x.cyan("runhuman templates")+" to see available templates."),console.log("Then run "+x.cyan("runhuman create --template <name>")+` to use one.
|
|
239
256
|
`);break;case"list-jobs":console.log(`
|
|
240
|
-
Run `+
|
|
241
|
-
`);break;case"exit":break}}async function
|
|
242
|
-
Run: runhuman projects switch <project-id>`);return}let
|
|
257
|
+
Run `+x.cyan("runhuman list")+` to see your recent jobs.
|
|
258
|
+
`);break;case"exit":break}}async function qo(s,t){t.isGitRepo?console.log(x.dim("Git repository detected (not yet set up with Runhuman)")):console.log(x.dim("Not in a git repository")),console.log("");let{action:e}=await J.prompt([{type:"list",name:"action",message:"What would you like to do?",choices:[{name:"Quick test a URL",value:"quick-test"},{name:"Set up this repo with Runhuman",value:"setup-repo",disabled:!t.isGitRepo},{name:"Connect a GitHub repo",value:"connect-github"},new J.Separator,{name:"Exit",value:"exit"}]}]);switch(e){case"quick-test":await at(s,t);break;case"setup-repo":await Vo(s);break;case"connect-github":await Bo(s);break;case"exit":break}}async function at(s,t){let e=t.projectConfig?.defaultUrl||"",n=await J.prompt([{type:"input",name:"url",message:"URL to test:",default:e||void 0,validate:r=>{if(!r.trim())return"URL is required";try{return new URL(r),!0}catch{return"Please enter a valid URL"}}},{type:"input",name:"description",message:"What should we test? (describe in plain English):",validate:r=>r.trim()?!0:"Description is required"}]),o=st("Creating test job...").start();try{let r=s.loadCredentials(),u=await s.loadConfig({apiKey:r?.accessToken});if(!u.project){o.fail("No project selected"),console.log(`
|
|
259
|
+
Run: runhuman projects switch <project-id>`);return}let l=await new g(u).createJob({projectId:u.project,url:n.url,description:n.description});o.succeed("Test job created!"),console.log(""),console.log(" Job ID: "+x.cyan(l.jobId)),console.log(" Status: "+l.status),console.log(""),console.log("A human tester will test your app shortly."),console.log("Run "+x.cyan(`runhuman wait ${l.jobId}`)+" to wait for results."),console.log("")}catch(r){throw o.fail("Failed to create test job"),r}}async function Vo(s){console.log(""),console.log("Setting up Runhuman in the current repository..."),console.log("");let t=await J.prompt([{type:"input",name:"defaultUrl",message:"Default URL to test (optional):"}]);await s.saveProjectConfig({defaultUrl:t.defaultUrl||void 0,defaultDuration:5,defaultScreenSize:"desktop"}),console.log(""),console.log(x.green("Created .runhumanrc")),console.log(""),console.log("Next steps:"),console.log(" 1. Install the GitHub App to enable @runhuman comments"),console.log(" "+x.cyan("runhuman github connect")),console.log(""),console.log(" 2. Create your first test:"),console.log(" "+x.cyan('runhuman create https://your-app.com -d "Test login flow"')),console.log("")}async function Bo(s){let n=`${(await s.loadConfig()).apiUrl||"https://runhuman.com"}/dashboard/settings/github`;console.log(""),console.log("To connect your GitHub repos, install the Runhuman GitHub App:"),console.log(""),console.log(" "+x.cyan(n)),console.log(""),console.log("After installation, you can comment "+x.bold("@runhuman")+" on any issue"),console.log("to trigger a QA test."),console.log("")}import{readFileSync as Qo}from"fs";import{join as Xo,dirname as Yo}from"path";import{fileURLToPath as en}from"url";var tn=en(import.meta.url),on=Yo(tn),nn=Xo(on,"../package.json"),rn=JSON.parse(Qo(nn,"utf-8")),sn=rn.version,A=new Zo;A.name("runhuman").description("CLI for Runhuman - AI-orchestrated human QA testing").version(sn);A.addCommand($e());A.addCommand(Me());A.addCommand(oe());A.addCommand(Le());A.addCommand(Je());A.addCommand(_e());A.addCommand(Ke());A.addCommand(We());A.addCommand(qe());A.addCommand(Ve());A.addCommand(Be());A.addCommand(Qe());A.addCommand(Xe());A.addCommand(Ye());A.addCommand(et());A.addCommand(tt());A.addCommand(nt());process.argv.slice(2).length?A.parse(process.argv):it().catch(s=>{console.error(s.message),process.exit(1)});
|