runhuman 1.3.1 → 1.4.0
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/dist/index.js +90 -196
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,111 +1,81 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var rt=Object.defineProperty;var R=(i,t)=>()=>(i&&(t=i(i=0)),t);var st=(i,t)=>{for(var e in t)rt(i,e,{get:t[e],enumerable:!0})};function it(i){return i instanceof x}function d(i){return it(i)?{message:i.message,exitCode:i.exitCode,details:i.details}:i instanceof Error?{message:i.message,exitCode:1}:{message:String(i),exitCode:1}}var x,B,Y,O,Z,Q,C=R(()=>{"use strict";x=class extends Error{constructor(e,n=1,o){super(e);this.exitCode=n;this.details=o;this.name="CliError"}},B=class extends x{constructor(t="Authentication failed",e){super(t,2,e),this.name="AuthenticationError"}},Y=class extends x{constructor(t="Resource not found",e){super(t,3,e),this.name="NotFoundError"}},O=class extends x{constructor(t="Validation failed",e){super(t,4,e),this.name="ValidationError"}},Z=class extends x{constructor(t="Operation timed out",e){super(t,5,e),this.name="TimeoutError"}},Q=class extends x{constructor(t="Insufficient balance",e){super(t,6,e),this.name="InsufficientBalanceError"}}});function a(i){return{pattern:i,build:e=>{if(!e)return i;let n=i;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 X=R(()=>{"use strict"});var N,me=R(()=>{"use strict";X();N={dashboard:a("/dashboard"),managePlan:a("/dashboard/manage-plan"),plans:a("/dashboard/plans"),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"),organizationJobs:a("/dashboard/organizations/:organizationId/jobs"),organizationApiKeys:a("/dashboard/organizations/:organizationId/api-keys"),organizationIntegrations:a("/dashboard/organizations/:organizationId/integrations"),organizationGitHub:a("/dashboard/organizations/:organizationId/github"),organizationSso:a("/dashboard/organizations/:organizationId/sso"),organizationSchedules:a("/dashboard/organizations/:organizationId/schedules"),organizationImportGitHub:a("/dashboard/organizations/:organizationId/import"),settings:a("/dashboard/settings"),settingsAccount:a("/dashboard/settings/account"),tester:a("/tester"),testerJobs:a("/tester/jobs"),testerSettings:a("/tester/settings"),testerTest:a("/tester/test/:jobId"),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"),schedules:a("/dashboard/:projectId/schedules"),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/setup"),pricing:a("/pricing"),home:a("/"),learn:a("/learn"),learnLesson:a("/learn/:lessonSlug")}});var y,de=R(()=>{"use strict";X();y={jobs:a("/jobs"),job:a("/jobs/:jobId"),jobCancel:a("/jobs/:jobId/cancel"),jobCreateIssue:a("/jobs/:jobId/create-issue"),jobStatus:a("/jobs/:jobId/status"),jobArtifact:a("/jobs/:jobId/artifacts/:artifactType"),jobFeedback:a("/jobs/:jobId/feedback"),jobShare:a("/jobs/:jobId/share"),jobClaim:a("/jobs/:jobId/claim"),run:a("/run"),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"),testerJobPhase:a("/tester/jobs/:jobId/phase"),livekitTesterToken:a("/tester/jobs/:jobId/livekit-token"),livekitEndSession:a("/tester/jobs/:jobId/livekit-end"),livekitTranscript:a("/tester/jobs/:jobId/livekit-transcript"),livekitViewerToken:a("/jobs/:jobId/livekit-viewer-token"),livekitStatus:a("/jobs/:jobId/livekit-status"),livekitRecording:a("/jobs/:jobId/livekit-recording"),keys:a("/keys"),key:a("/keys/:keyId"),keyRevoke:a("/keys/:keyId/revoke"),keyInfo:a("/key-info"),pats:a("/pats"),pat:a("/pats/:patId"),patRevoke:a("/pats/:patId/revoke"),patInfo:a("/pat-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"),projectFlowChartShare:a("/projects/:projectId/flowcharts/:flowchartId/share"),projectSchedules:a("/projects/:projectId/schedules"),projectSchedule:a("/projects/:projectId/schedules/:scheduleId"),projectScheduleExecutions:a("/projects/:projectId/schedules/:scheduleId/executions"),bulkCreateProjects:a("/projects/bulk"),githubOAuthAuthorize:a("/github/oauth/authorize"),githubCallback:a("/github/oauth/callback"),githubLink:a("/github/link"),githubIssuesByRepo:a("/github/issues/:owner/:repo"),githubIssueByRepo:a("/github/issues/:owner/:repo/:issueNumber"),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"),authDeletionPreview:a("/auth/account/deletion-preview"),billingBalance:a("/billing/balance"),billingHasCredits:a("/billing/has-credits"),billingPortal:a("/billing/portal"),billingCheckout:a("/billing/checkout"),billingSubscription:a("/billing/subscription"),billingChangePlan:a("/billing/change-plan"),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"),testerDownloadExtension:a("/tester/download-extension"),testerDownloadMobileApp:a("/tester/download-mobile-app"),testerAvailableJobs:a("/tester/jobs/available"),testerAvatarUploadUrl:a("/tester/profile/avatar-upload-url"),testerAppVersion:a("/tester/app-version"),testerPushToken:a("/tester/push-token"),testerDemoJob:a("/tester/demo-job"),extensionTokens:a("/tester/extension-tokens"),extensionToken:a("/tester/extension-tokens/:tokenId"),extensionStream:a("/extension/stream"),testerJobCorrelate:a("/tester/jobs/:jobId/correlate"),testerJobDataStatus:a("/tester/jobs/:jobId/data-status"),testerJobExtensionToken:a("/tester/jobs/:jobId/extension-token"),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"),organizationJobs:a("/organizations/:organizationId/jobs"),organizationTransferOwnership:a("/organizations/:organizationId/transfer-ownership"),organizationApiKeys:a("/organizations/:organizationId/api-keys"),organizationApiKey:a("/organizations/:organizationId/api-keys/:keyId"),organizationGitHubInstallations:a("/organizations/:organizationId/github/installations"),organizationGitHubInstallation:a("/organizations/:organizationId/github/installations/:installationId"),organizationGitHubRepos:a("/organizations/:organizationId/github/repos"),organizationGitHubInstallationRefresh:a("/organizations/:organizationId/github/installations/:installationId/refresh"),organizationGitHubRepoCheckAccess:a("/organizations/:organizationId/github/repos/check-access"),organizationGitHubRepoFindUrl:a("/organizations/:organizationId/github/repos/find-url"),organizationSchedules:a("/organizations/:organizationId/schedules"),organizationBilling:a("/organizations/:organizationId/billing"),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"),agreements:a("/agreements"),agreementCheck:a("/agreements/check"),organizationSsoConnections:a("/organizations/:organizationId/sso/connections"),organizationSsoConnection:a("/organizations/:organizationId/sso/connections/:connectionId"),enterpriseInquiry:a("/enterprise/inquiry"),changelog:a("/changelog"),changelogUnreadCount:a("/changelog/unread-count"),changelogMarkRead:a("/changelog/mark-read"),telemetrySessions:a("/telemetry/sessions"),telemetrySessionEnd:a("/telemetry/sessions/:sessionId/end"),telemetryBatch:a("/telemetry/sessions/:sessionId/events"),telemetrySessionStatus:a("/telemetry/jobs/:jobId/status"),telemetryShortCodeResolve:a("/telemetry/short-codes/:code")}});var ie=R(()=>{"use strict";X();me();de()});import lt from"axios";var f,T=R(()=>{"use strict";C();ie();f=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.method==="delete"&&!e.data&&delete e.headers["Content-Type"],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 B(o,n);case 402:return new Q(o,n);case 404:return new Y(o,n);case 400:case 422:return new O(o,n);default:return new x(o,1,n)}}return t.code==="ECONNABORTED"?new x("Request timeout",5):t.code==="ENOTFOUND"||t.code==="ECONNREFUSED"?new x("Cannot connect to Runhuman API",1):new x(t.message,1)}async createJob(t){return(await this.client.post(y.jobs.build(),t)).data}async getJob(t){return(await this.client.get(y.job.build({jobId:t}))).data}async listJobs(t){return(await this.client.get(y.jobs.build(),{params:t})).data}async cancelJob(t){await this.client.post(y.jobCancel.build({jobId:t}))}async deleteJob(t){await this.client.delete(y.job.build({jobId:t}))}async listProjects(t){return(await this.client.get(y.projects.build(),{params:t})).data}async getProject(t){return(await this.client.get(y.project.build({projectId:t}))).data}async createProject(t){return(await this.client.post(y.projects.build(),t)).data}async updateProject(t,e){return(await this.client.patch(y.project.build({projectId:t}),e)).data}async deleteProject(t){await this.client.delete(y.project.build({projectId:t}))}async listApiKeys(t){return(await this.client.get(y.organizationApiKeys.build({organizationId:t}))).data}async createApiKey(t,e){return(await this.client.post(y.organizationApiKeys.build({organizationId:t}),{name:e})).data}async getApiKey(t){return(await this.client.get(y.key.build({keyId:t}))).data}async deleteApiKey(t){await this.client.delete(y.key.build({keyId:t}))}async listOrganizations(t){return(await this.client.get(y.organizations.build(),{params:t})).data}async getOrganization(t){return(await this.client.get(y.organization.build({organizationId:t}))).data}async getOrganizationBilling(t){return(await this.client.get(y.organizationBilling.build({organizationId:t}))).data}async listOrganizationProjects(t,e){return(await this.client.get(y.organizationProjects.build({organizationId:t}),{params:e})).data}async listTemplates(t){return(await this.client.get(y.projectTemplates.build({projectId:t}))).data}async getTemplate(t,e){return(await this.client.get(y.projectTemplate.build({projectId:t,templateId:e}))).data}async createTemplate(t,e){return(await this.client.post(y.projectTemplates.build({projectId:t}),e)).data}async updateTemplate(t,e,n){return(await this.client.patch(y.projectTemplate.build({projectId:t,templateId:e}),n)).data}async deleteTemplate(t,e){await this.client.delete(y.projectTemplate.build({projectId:t,templateId:e}))}async getCurrentUser(){return(await this.client.get(y.authMe.build())).data}async listGithubRepos(t,e){return(await this.client.get(y.organizationGitHubRepos.build({organizationId:t}),{params:e})).data}async listGithubIssues(t,e,n){return(await this.client.get(y.githubIssuesByRepo.build({owner:t,repo:e}),{params:n})).data}async getGithubIssue(t,e,n){return(await this.client.get(y.githubIssueByRepo.build({owner:t,repo:e,issueNumber:String(n)}))).data}async initiateTransfer(t,e){return(await this.client.post(y.projectTransfer.build({projectId:t}),{toOrganizationId:e})).data}async listPendingTransfers(){return(await this.client.get(y.transfersPending.build())).data}async listOutgoingTransfers(){return(await this.client.get(y.transfersOutgoing.build())).data}async acceptTransfer(t){return(await this.client.post(y.transferAccept.build({transferId:t}),{})).data}async rejectTransfer(t){return(await this.client.post(y.transferReject.build({transferId:t}),{})).data}async cancelTransfer(t){return(await this.client.post(y.transferCancel.build({transferId:t}),{})).data}}});import{cosmiconfig as ut}from"cosmiconfig";import{homedir as pt}from"os";import{join as L}from"path";import{readFileSync as K,writeFileSync as M,existsSync as v,mkdirSync as ae,chmodSync as mt}from"fs";function ft(i){return gt.includes(i)}var dt,D,z,q,gt,g,A=R(()=>{"use strict";dt="runhuman",D=L(pt(),".config","runhuman"),z=L(D,"config.json"),q=L(D,"credentials.json"),gt=["pretty","json","compact"];g=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,defaultDeviceClass:"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_DEVICE_CLASS&&(t.defaultDeviceClass=process.env.RUNHUMAN_DEFAULT_DEVICE_CLASS),process.env.RUNHUMAN_OUTPUT_FORMAT&&ft(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 ut(dt).search(this.cwd))?.config||null}catch{return null}}loadGlobalConfig(){try{if(!v(z))return null;let t=K(z,"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){v(D)||ae(D,{recursive:!0});let n={};if(v(z)){let o=K(z,"utf-8");n=JSON.parse(o)}n[t]=e,M(z,JSON.stringify(n,null,2))}async setProjectConfig(t,e){let n=L(this.cwd,".runhumanrc"),o={};if(v(n)){let r=K(n,"utf-8");o=JSON.parse(r)}o[t]=e,M(n,JSON.stringify(o,null,2))}async saveProjectConfig(t){let e=L(this.cwd,".runhumanrc"),n={};if(v(e)){let r=K(e,"utf-8");n=JSON.parse(r)}let o={...n,...t};M(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")&&v(z)&&M(z,"{}"),t==="project"||t==="all"){let e=L(this.cwd,".runhumanrc");v(e)&&M(e,"{}")}}saveCredentials(t){v(D)||ae(D,{recursive:!0}),M(q,JSON.stringify(t,null,2));try{process.platform!=="win32"&&mt(q,384)}catch{}}loadCredentials(){try{if(!v(q))return null;let t=K(q,"utf-8");return JSON.parse(t)}catch{return null}}clearCredentials(){v(q)&&M(q,"{}")}saveUserInfo(t){let e=L(D,"user.json");v(D)||ae(D,{recursive:!0}),M(e,JSON.stringify(t,null,2))}loadUserInfo(){try{let t=L(D,"user.json");if(!v(t))return null;let e=K(t,"utf-8");return JSON.parse(e)}catch{return null}}clearUserInfo(){let t=L(D,"user.json");v(t)&&M(t,"{}")}}});import _ from"chalk";import ht from"cli-table3";var l,I=R(()=>{"use strict";l=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 dt=Object.defineProperty;var M=(i,t)=>()=>(i&&(t=i(i=0)),t);var mt=(i,t)=>{for(var e in t)dt(i,e,{get:t[e],enumerable:!0})};function gt(i){return i instanceof x}function m(i){return gt(i)?{message:i.message,exitCode:i.exitCode,details:i.details}:i instanceof Error?{message:i.message,exitCode:1}:{message:String(i),exitCode:1}}var x,Q,X,D,ee,te,I=M(()=>{"use strict";x=class extends Error{constructor(e,r=1,o){super(e);this.exitCode=r;this.details=o;this.name="CliError"}},Q=class extends x{constructor(t="Authentication failed",e){super(t,2,e),this.name="AuthenticationError"}},X=class extends x{constructor(t="Resource not found",e){super(t,3,e),this.name="NotFoundError"}},D=class extends x{constructor(t="Validation failed",e){super(t,4,e),this.name="ValidationError"}},ee=class extends x{constructor(t="Operation timed out",e){super(t,5,e),this.name="TimeoutError"}},te=class extends x{constructor(t="Insufficient balance",e){super(t,6,e),this.name="InsufficientBalanceError"}}});function a(i){return{pattern:i,build:e=>{if(!e)return i;let r=i;for(let[o,n]of Object.entries(e))n!==void 0&&(r=r.replace(`:${o}?`,n),r=r.replace(`:${o}`,n));return r=r.replace(/\/:[^/]+\?/g,""),r=r.replace(/\/+/g,"/"),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),r}}}var oe=M(()=>{"use strict"});var $,Ie=M(()=>{"use strict";oe();$={dashboard:a("/dashboard"),managePlan:a("/dashboard/manage-plan"),plans:a("/dashboard/plans"),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"),organizationJobs:a("/dashboard/organizations/:organizationId/jobs"),organizationApiKeys:a("/dashboard/organizations/:organizationId/api-keys"),organizationIntegrations:a("/dashboard/organizations/:organizationId/integrations"),organizationGitHub:a("/dashboard/organizations/:organizationId/github"),organizationSso:a("/dashboard/organizations/:organizationId/sso"),organizationSchedules:a("/dashboard/organizations/:organizationId/schedules"),organizationImportGitHub:a("/dashboard/organizations/:organizationId/import"),settings:a("/dashboard/settings"),settingsAccount:a("/dashboard/settings/account"),tester:a("/tester"),testerJobs:a("/tester/jobs"),testerSettings:a("/tester/settings"),testerTest:a("/tester/test/:jobId"),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"),schedules:a("/dashboard/:projectId/schedules"),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/setup"),pricing:a("/pricing"),home:a("/"),learn:a("/learn"),learnLesson:a("/learn/:lessonSlug")}});var y,Ae=M(()=>{"use strict";oe();y={jobs:a("/jobs"),job:a("/jobs/:jobId"),jobCancel:a("/jobs/:jobId/cancel"),jobCreateIssue:a("/jobs/:jobId/create-issue"),jobStatus:a("/jobs/:jobId/status"),jobArtifact:a("/jobs/:jobId/artifacts/:artifactType"),jobFeedback:a("/jobs/:jobId/feedback"),jobShare:a("/jobs/:jobId/share"),jobClaim:a("/jobs/:jobId/claim"),run:a("/run"),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"),testerJobPhase:a("/tester/jobs/:jobId/phase"),livekitTesterToken:a("/tester/jobs/:jobId/livekit-token"),livekitEndSession:a("/tester/jobs/:jobId/livekit-end"),livekitTranscript:a("/tester/jobs/:jobId/livekit-transcript"),livekitViewerToken:a("/jobs/:jobId/livekit-viewer-token"),livekitStatus:a("/jobs/:jobId/livekit-status"),livekitRecording:a("/jobs/:jobId/livekit-recording"),keys:a("/keys"),key:a("/keys/:keyId"),keyRevoke:a("/keys/:keyId/revoke"),keyInfo:a("/key-info"),pats:a("/pats"),pat:a("/pats/:patId"),patRevoke:a("/pats/:patId/revoke"),patInfo:a("/pat-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"),projectFlowChartShare:a("/projects/:projectId/flowcharts/:flowchartId/share"),projectSchedules:a("/projects/:projectId/schedules"),projectSchedule:a("/projects/:projectId/schedules/:scheduleId"),projectScheduleExecutions:a("/projects/:projectId/schedules/:scheduleId/executions"),bulkCreateProjects:a("/projects/bulk"),githubOAuthAuthorize:a("/github/oauth/authorize"),githubCallback:a("/github/oauth/callback"),githubLink:a("/github/link"),githubIssuesByRepo:a("/github/issues/:owner/:repo"),githubIssueByRepo:a("/github/issues/:owner/:repo/:issueNumber"),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"),authDeletionPreview:a("/auth/account/deletion-preview"),billingBalance:a("/billing/balance"),billingHasCredits:a("/billing/has-credits"),billingPortal:a("/billing/portal"),billingCheckout:a("/billing/checkout"),billingSubscription:a("/billing/subscription"),billingChangePlan:a("/billing/change-plan"),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"),testerDownloadExtension:a("/tester/download-extension"),testerDownloadMobileApp:a("/tester/download-mobile-app"),testerAvailableJobs:a("/tester/jobs/available"),testerAvatarUploadUrl:a("/tester/profile/avatar-upload-url"),testerAppVersion:a("/tester/app-version"),testerPushToken:a("/tester/push-token"),testerDemoJob:a("/tester/demo-job"),extensionTokens:a("/tester/extension-tokens"),extensionToken:a("/tester/extension-tokens/:tokenId"),extensionStream:a("/extension/stream"),testerJobCorrelate:a("/tester/jobs/:jobId/correlate"),testerJobDataStatus:a("/tester/jobs/:jobId/data-status"),testerJobExtensionToken:a("/tester/jobs/:jobId/extension-token"),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"),organizationJobs:a("/organizations/:organizationId/jobs"),organizationTransferOwnership:a("/organizations/:organizationId/transfer-ownership"),organizationApiKeys:a("/organizations/:organizationId/api-keys"),organizationApiKey:a("/organizations/:organizationId/api-keys/:keyId"),organizationGitHubInstallations:a("/organizations/:organizationId/github/installations"),organizationGitHubInstallation:a("/organizations/:organizationId/github/installations/:installationId"),organizationGitHubRepos:a("/organizations/:organizationId/github/repos"),organizationGitHubInstallationRefresh:a("/organizations/:organizationId/github/installations/:installationId/refresh"),organizationGitHubRepoCheckAccess:a("/organizations/:organizationId/github/repos/check-access"),organizationGitHubRepoFindUrl:a("/organizations/:organizationId/github/repos/find-url"),organizationSchedules:a("/organizations/:organizationId/schedules"),organizationBilling:a("/organizations/:organizationId/billing"),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"),agreements:a("/agreements"),agreementCheck:a("/agreements/check"),organizationSsoConnections:a("/organizations/:organizationId/sso/connections"),organizationSsoConnection:a("/organizations/:organizationId/sso/connections/:connectionId"),enterpriseInquiry:a("/enterprise/inquiry"),changelog:a("/changelog"),changelogUnreadCount:a("/changelog/unread-count"),changelogMarkRead:a("/changelog/mark-read"),telemetrySessions:a("/telemetry/sessions"),telemetrySessionEnd:a("/telemetry/sessions/:sessionId/end"),telemetryBatch:a("/telemetry/sessions/:sessionId/events"),telemetrySessionStatus:a("/telemetry/jobs/:jobId/status"),telemetryShortCodeResolve:a("/telemetry/short-codes/:code")}});var ue=M(()=>{"use strict";oe();Ie();Ae()});import bt from"axios";var h,k=M(()=>{"use strict";I();ue();h=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.method==="delete"&&!e.data&&delete e.headers["Content-Type"],e)),this.client.interceptors.response.use(e=>e,e=>{throw this.handleError(e)})}handleError(t){if(t.response){let e=t.response.status,r=t.response.data,o=r?.error||r?.message||t.message;switch(e){case 401:case 403:return new Q(o,r);case 402:return new te(o,r);case 404:return new X(o,r);case 400:case 422:return new D(o,r);default:return new x(o,1,r)}}return t.code==="ECONNABORTED"?new x("Request timeout",5):t.code==="ENOTFOUND"||t.code==="ECONNREFUSED"?new x("Cannot connect to Runhuman API",1):new x(t.message,1)}async createJob(t){return(await this.client.post(y.jobs.build(),t)).data}async getJob(t){return(await this.client.get(y.job.build({jobId:t}))).data}async listJobs(t){return(await this.client.get(y.jobs.build(),{params:t})).data}async cancelJob(t){await this.client.post(y.jobCancel.build({jobId:t}))}async deleteJob(t){await this.client.delete(y.job.build({jobId:t}))}async listProjects(t){return(await this.client.get(y.projects.build(),{params:t})).data}async getProject(t){return(await this.client.get(y.project.build({projectId:t}))).data}async createProject(t){return(await this.client.post(y.projects.build(),t)).data}async updateProject(t,e){return(await this.client.patch(y.project.build({projectId:t}),e)).data}async deleteProject(t){await this.client.delete(y.project.build({projectId:t}))}async listApiKeys(t){return(await this.client.get(y.organizationApiKeys.build({organizationId:t}))).data}async createApiKey(t,e){return(await this.client.post(y.organizationApiKeys.build({organizationId:t}),{name:e})).data}async getApiKey(t){return(await this.client.get(y.key.build({keyId:t}))).data}async deleteApiKey(t){await this.client.delete(y.key.build({keyId:t}))}async listOrganizations(t){return(await this.client.get(y.organizations.build(),{params:t})).data}async getOrganization(t){return(await this.client.get(y.organization.build({organizationId:t}))).data}async getOrganizationBilling(t){return(await this.client.get(y.organizationBilling.build({organizationId:t}))).data}async listOrganizationProjects(t,e){return(await this.client.get(y.organizationProjects.build({organizationId:t}),{params:e})).data}async listTemplates(t){return(await this.client.get(y.projectTemplates.build({projectId:t}))).data}async getTemplate(t,e){return(await this.client.get(y.projectTemplate.build({projectId:t,templateId:e}))).data}async createTemplate(t,e){return(await this.client.post(y.projectTemplates.build({projectId:t}),e)).data}async updateTemplate(t,e,r){return(await this.client.patch(y.projectTemplate.build({projectId:t,templateId:e}),r)).data}async deleteTemplate(t,e){await this.client.delete(y.projectTemplate.build({projectId:t,templateId:e}))}async getCurrentUser(){return(await this.client.get(y.authMe.build())).data}async listGithubRepos(t,e){return(await this.client.get(y.organizationGitHubRepos.build({organizationId:t}),{params:e})).data}async listGithubIssues(t,e,r){return(await this.client.get(y.githubIssuesByRepo.build({owner:t,repo:e}),{params:r})).data}async getGithubIssue(t,e,r){return(await this.client.get(y.githubIssueByRepo.build({owner:t,repo:e,issueNumber:String(r)}))).data}async initiateTransfer(t,e){let r=await this.client.post(y.projectTransfer.build({projectId:t}),{toOrganizationId:e});return r.status===200?{type:"immediate",project:r.data}:{type:"pending",transfer:r.data}}async listPendingTransfers(){return(await this.client.get(y.transfersPending.build())).data}async listOutgoingTransfers(){return(await this.client.get(y.transfersOutgoing.build())).data}async acceptTransfer(t){return(await this.client.post(y.transferAccept.build({transferId:t}),{})).data}async rejectTransfer(t){return(await this.client.post(y.transferReject.build({transferId:t}),{})).data}async cancelTransfer(t){return(await this.client.post(y.transferCancel.build({transferId:t}),{})).data}}});import{cosmiconfig as yt}from"cosmiconfig";import{homedir as jt}from"os";import{join as _}from"path";import{readFileSync as V,writeFileSync as L,existsSync as R,mkdirSync as pe,chmodSync as wt}from"fs";function At(i){return It.includes(i)}var Ct,N,F,G,It,g,E=M(()=>{"use strict";Ct="runhuman",N=_(jt(),".config","runhuman"),F=_(N,"config.json"),G=_(N,"credentials.json"),It=["pretty","json","compact"];g=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(),r=e?.accessToken?{apiKey:e.accessToken}:{},o=Object.fromEntries(Object.entries(t).filter(([,u])=>u!==void 0));return{...this.getDefaults(),...this.globalConfig,...this.projectConfig,...r,...this.envConfig,...o}}getDefaults(){return{apiUrl:"https://runhuman.com",outputFormat:"pretty",color:!0,autoOpenBrowser:!0,defaultDuration:5,defaultDeviceClass:"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_ORGANIZATION&&(t.organization=process.env.RUNHUMAN_ORGANIZATION),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_DEVICE_CLASS&&(t.defaultDeviceClass=process.env.RUNHUMAN_DEFAULT_DEVICE_CLASS),process.env.RUNHUMAN_OUTPUT_FORMAT&&At(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 yt(Ct).search(this.cwd))?.config||null}catch{return null}}loadGlobalConfig(){try{if(!R(F))return null;let t=V(F,"utf-8");return JSON.parse(t)}catch{return null}}async get(t){return(await this.loadConfig())[t]}async set(t,e,r=!1){r?await this.setGlobalConfig(t,e):await this.setProjectConfig(t,e)}async setGlobalConfig(t,e){R(N)||pe(N,{recursive:!0});let r={};if(R(F)){let o=V(F,"utf-8");r=JSON.parse(o)}r[t]=e,L(F,JSON.stringify(r,null,2))}async setProjectConfig(t,e){let r=_(this.cwd,".runhumanrc"),o={};if(R(r)){let n=V(r,"utf-8");o=JSON.parse(n)}o[t]=e,L(r,JSON.stringify(o,null,2))}async saveProjectConfig(t){let e=_(this.cwd,".runhumanrc"),r={};if(R(e)){let n=V(e,"utf-8");r=JSON.parse(n)}let o={...r,...t};L(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")&&R(F)&&L(F,"{}"),t==="project"||t==="all"){let e=_(this.cwd,".runhumanrc");R(e)&&L(e,"{}")}}saveCredentials(t){R(N)||pe(N,{recursive:!0}),L(G,JSON.stringify(t,null,2));try{process.platform!=="win32"&&wt(G,384)}catch{}}loadCredentials(){try{if(!R(G))return null;let t=V(G,"utf-8");return JSON.parse(t)}catch{return null}}clearCredentials(){R(G)&&L(G,"{}")}saveUserInfo(t){let e=_(N,"user.json");R(N)||pe(N,{recursive:!0}),L(e,JSON.stringify(t,null,2))}loadUserInfo(){try{let t=_(N,"user.json");if(!R(t))return null;let e=V(t,"utf-8");return JSON.parse(e)}catch{return null}}clearUserInfo(){let t=_(N,"user.json");R(t)&&L(t,"{}")}}});import K from"chalk";import St from"cli-table3";var Tt,de,l,S=M(()=>{"use strict";Tt=24,de=60,l=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 r={success:!1,error:{message:t,details:e},timestamp:new Date().toISOString()};console.error(JSON.stringify(r,null,2))}else console.error(this.color("red",`
|
|
3
3
|
Error: ${t}
|
|
4
4
|
`)),e?.code==="INSUFFICIENT_TOKENS"&&e?.link?(console.error(this.color("yellow","Add funds to continue:")),console.error(this.color("cyan",e.link)),console.error("")):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
|
-
`))}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}`))}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`),
|
|
16
|
-
|
|
17
|
-
\u{1F4CA} Job Status: `+t+`
|
|
18
|
-
`),console.log(" Status: "+r.formatStatus(s.status)),s.testerAlias&&console.log(" Tester: "+s.testerAlias),s.url&&console.log(" URL: "+s.url),s.description&&console.log(" Description: "+s.description),s.createdAt&&console.log(" Created: "+s.createdAt),s.completedAt&&console.log(" Completed: "+s.completedAt),s.testDurationSeconds&&console.log(" Duration: "+r.formatDuration(s.testDurationSeconds)),s.costUsd&&console.log(" Cost: $"+s.costUsd.toFixed(3)),s.deviceClass&&console.log(" Device Class: "+s.deviceClass),s.requiredDevices?.length&&console.log(" Required Devices: "+s.requiredDevices.join(", ")),s.requiredLanguages?.length&&console.log(" Required Langs: "+s.requiredLanguages.join(", ")),s.requireSocialVideos&&console.log(" Social Videos: required"),console.log(`
|
|
19
|
-
Dashboard: ${o.apiUrl}${N.jobSimple.build({jobId:t})}
|
|
20
|
-
`),s.status==="pending"||s.status==="waiting"||s.status==="working"?(console.log("\u{1F4A1} Wait for completion:"),console.log(` runhuman wait ${t}
|
|
21
|
-
`)):s.status==="completed"&&(console.log("\u{1F4A1} View results:"),console.log(` runhuman results ${t}
|
|
22
|
-
`))}catch(n){let o=new l({json:e.json}),r=d(n);o.outputError(r.message,r.details),process.exit(r.exitCode)}}),i}oe();T();A();I();C();import{Command as Ao}from"commander";var Ce="=".repeat(80);function U(i){return`
|
|
23
|
-
${Ce}
|
|
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}`))}separator(){this.options.json||this.options.quiet||console.log("=".repeat(de))}sectionHeader(t){this.options.json||this.options.quiet||(console.log(`
|
|
7
|
+
`+"=".repeat(de)),console.log(t),console.log("=".repeat(de)+`
|
|
8
|
+
`))}detail(t,e){this.options.json||this.options.quiet||console.log(` ${t}:`.padEnd(Tt)+String(e))}heading(t){this.options.json||this.options.quiet||console.log(`
|
|
9
|
+
${t}
|
|
10
|
+
`)}hints(t){if(this.options.json||this.options.quiet)return;let r=Math.max(...t.map(([o])=>o.length))+4;for(let[o,n]of t)console.log(` ${o}:`.padEnd(r)+` ${n}`);console.log()}tableHead(t){return t.map(e=>this.color("cyan",e))}formatTimestamp(t){return new Date(t).toLocaleString()}formatShortDate(t){return new Date(t).toLocaleDateString()}formatJobList(t){if(this.options.format==="compact")return t.map(r=>`${r.id} ${r.status} ${r.url}`).join(`
|
|
11
|
+
`);let e=new St({head:this.tableHead(["Job ID","Status","URL","Created","Duration","Cost"]),colWidths:[15,12,30,14,10,10]});return t.forEach(r=>{e.push([r.id,this.formatStatus(r.status),r.url?this.truncate(r.url,28):"-",r.createdAt?this.formatDate(r.createdAt):"-",r.testDurationSeconds?this.formatDuration(r.testDurationSeconds):"-",r.costUsd?`$${r.costUsd.toFixed(3)}`:"-"])}),e.toString()}formatStatus(t){let e={pending:"yellow",waiting:"blue",working:"blue",completed:"green",incomplete:"yellow",abandoned:"red",rejected:"gray",error:"red",failed:"red"},r=t.replaceAll("_"," ");return this.color(e[t]||"white",r)}formatDuration(t){if(t<60)return`${t}s`;let e=Math.floor(t/60),r=t%60;if(e<60)return`${e}m ${r}s`;let o=Math.floor(e/60),n=e%60;return`${o}h ${n}m ${r}s`}formatDate(t){let e=new Date(t),o=new Date().getTime()-e.getTime(),n=Math.floor(o/1e3),u=Math.floor(n/60),s=Math.floor(u/60),c=Math.floor(s/24);return n<60?`${n}s ago`:u<60?`${u}m ago`:s<24?`${s}h ago`:c<30?`${c}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:K.red,green:K.green,blue:K.blue,yellow:K.yellow,cyan:K.cyan,gray:K.gray,white:K.white}[t];return o?o(e):e}static result(t){return{success:!0,data:t,timestamp:new Date().toISOString()}}static error(t,e,r){return{success:!1,error:{message:t,code:e,details:r},timestamp:new Date().toISOString()}}}});var me={};mt(me,{waitCommand:()=>ie,waitForJob:()=>ke});import{Command as Uo}from"commander";import Po from"ora";async function ke(i,t,e,r=600){let o=Date.now(),n=r*1e3,u=1e4,s=null;for(e.options.json||(s=Po("Waiting for job completion...").start());;){let c=Date.now()-o;if(c>=n)throw s&&s.fail("Timeout waiting for job completion"),new ee(`Job did not complete within ${r} seconds`);let p=await t.getJob(i);if(s){let d=e.formatDuration(Math.floor(c/1e3));s.text=`Waiting for job completion... (${d} elapsed, status: ${p.status})`}if(p.status==="completed"){if(s&&s.succeed("Test Completed!"),!e.options.json){if(console.log(),e.detail("Duration",p.testDurationSeconds?e.formatDuration(p.testDurationSeconds):"N/A"),e.detail("Cost","$"+(p.costUsd||0).toFixed(3)),p.testerAlias&&e.detail("Tester",p.testerAlias),p.result){console.log(`
|
|
12
|
+
Results Summary:`);for(let[d,f]of Object.entries(p.result))console.log(` ${d}: ${f}`)}console.log(),e.hints([["Full results",`runhuman results ${i}`]])}return}if(p.status==="error"||p.status==="incomplete"||p.status==="abandoned")throw s&&s.fail(`Test ${p.status}`),new Error(`Job ${p.status}: ${p.testerResponse||"No details available"}`);if(p.status==="rejected")throw s&&s.fail("Test was rejected"),new Error("Job was rejected");await new Promise(d=>setTimeout(d,u))}}function ie(){let i=new Uo("wait");return i.description("Wait for a job to complete and display results").argument("<jobId>","Job ID to wait for").option("-T, --timeout <seconds>","Max wait time (default: 600)",parseInt).option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=new h(o);if(await ke(t,u,n,e.timeout||600),e.json){let s=await u.getJob(t),c=l.result(s);n.output(c)}}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}var se=M(()=>{"use strict";k();E();S();I()});import{Command as st}from"commander";k();E();S();I();import{Command as xo}from"commander";import Ro from"ora";I();var Et={project:{name:"Project ID",flag:"--project",configKey:"project",envVar:"RUNHUMAN_PROJECT",switchCommand:"runhuman projects switch <project-id>"},organization:{name:"Organization ID",flag:"--organization",configKey:"organization",envVar:"RUNHUMAN_ORGANIZATION",switchCommand:"runhuman orgs switch <organization-id>"}};function vt(i,t,e){return i?"flag":process.env[e.envVar]?"env":"global config"}function C(i,t,e,r){let o=Et[i],n=t||e[o.configKey];if(!n)throw new D(`${o.name} is required. You can:
|
|
13
|
+
\u2022 Pass ${o.flag} <id> for this command
|
|
14
|
+
\u2022 Set a default: ${o.switchCommand}
|
|
15
|
+
\u2022 Set via env: export ${o.envVar}=<id>`);let u=vt(t,e,o);return u!=="flag"&&r.info(`Using default ${i}: ${n} [from ${u}]`),n}ue();var ne=["ios","android","pc","mac"],re=["english","spanish"];function ge(){let i=new xo("create");return i.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("--device-class <class>","Device class: desktop|mobile").option("-S, --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("--required-devices <devices>","Required tester devices (comma-separated: ios,android,pc,mac)").option("--required-languages <languages>","Required tester languages (comma-separated: english,spanish)").option("--require-social-videos","Require tester to create social videos").option("-s, --sync","Wait for result before exiting (synchronous mode)").option("--wait <seconds>","Max wait time in sync mode (default: 300)",parseInt).option("-p, --project <id>","Project ID (or use default from config)").option("--api-key <key>","API key (or use from config/env)").option("-j, --json","Output as JSON (for scripting)").option("-q, --quiet","Minimal output (only job ID)").action(async(t,e)=>{try{let o=await new g().loadConfig({apiKey:e.apiKey}),n=new l({json:e.json,quiet:e.quiet,color:o.color}),u=new h(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)");let c={projectId:C("project",e.project,o,n),url:t||o.defaultUrl||"",description:e.description||"",duration:e.duration||o.defaultDuration,deviceClass:e.deviceClass||o.defaultDeviceClass};if(e.schema){let b=await(await import("fs/promises")).readFile(e.schema,"utf-8");c.schema=JSON.parse(b)}else e.schemaInline&&(c.schema=JSON.parse(e.schemaInline));if(e.metadata&&(c.metadata=JSON.parse(e.metadata)),e.githubRepo&&(c.githubRepo=e.githubRepo),e.template&&(c.templateId=e.template),e.requiredDevices){let f=e.requiredDevices.split(",");for(let b of f)if(!ne.includes(b))throw new D(`Invalid device "${b}". Valid values: ${ne.join(", ")}`);c.requiredDevices=f}if(e.requiredLanguages){let f=e.requiredLanguages.split(",");for(let b of f)if(!re.includes(b))throw new D(`Invalid language "${b}". Valid values: ${re.join(", ")}`);c.requiredLanguages=f}e.requireSocialVideos&&(c.requireSocialVideos=!0);let p=e.json?null:Ro("Creating QA test job...").start(),d=await u.createJob(c);if(p&&p.succeed("Job created successfully!"),e.json){let f=l.result({jobId:d.jobId,status:d.status,message:d.message,dashboardUrl:`${o.apiUrl}${$.jobSimple.build({jobId:d.jobId})}`,estimatedCompletionTime:d.estimatedCompletionTime});n.output(f)}else e.quiet?console.log(d.jobId):(n.detail("Job ID",d.jobId),n.detail("Status",d.status),n.detail("URL",c.url),n.detail("Dashboard",`${o.apiUrl}${$.jobSimple.build({jobId:d.jobId})}`),console.log(),n.hints([["Track progress",`runhuman status ${d.jobId}`],["Wait for result",`runhuman wait ${d.jobId}`]]));if(e.sync){let{waitForJob:f}=await Promise.resolve().then(()=>(se(),me));await f(d.jobId,u,n,e.wait||300)}}catch(r){let o=m(r);new l({json:e.json,quiet:!1}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}k();E();S();import{Command as Oo}from"commander";I();function fe(){let i=new Oo("status");return i.description("Check the current status of a job").argument("<jobId>","Job ID to check").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),s=await new h(o).getJob(t);if(e.json){let c=l.result(s);n.output(c)}else n.heading(`Job Status: ${t}`),n.detail("Status",n.formatStatus(s.status)),s.testerAlias&&n.detail("Tester",s.testerAlias),s.url&&n.detail("URL",s.url),s.description&&n.detail("Description",s.description),s.createdAt&&n.detail("Created",n.formatTimestamp(s.createdAt)),s.completedAt&&n.detail("Completed",n.formatTimestamp(s.completedAt)),s.testDurationSeconds&&n.detail("Duration",n.formatDuration(s.testDurationSeconds)),s.costUsd&&n.detail("Cost",`$${s.costUsd.toFixed(3)}`),s.deviceClass&&n.detail("Device Class",s.deviceClass),s.requiredDevices?.length&&n.detail("Required Devices",s.requiredDevices.join(", ")),s.requiredLanguages?.length&&n.detail("Required Langs",s.requiredLanguages.join(", ")),s.requireSocialVideos&&n.detail("Social Videos","required"),n.detail("Dashboard",`${o.apiUrl}${$.jobSimple.build({jobId:t})}`),console.log(),s.status==="pending"||s.status==="waiting"||s.status==="working"?n.hints([["Wait for completion",`runhuman wait ${t}`]]):s.status==="completed"&&n.hints([["View results",`runhuman results ${t}`]])}catch(r){let o=new l({json:e.json}),n=m(r);o.outputError(n.message,n.details),process.exit(n.exitCode)}}),i}se();k();E();S();I();import{Command as No}from"commander";var Ue="=".repeat(60);function O(i){return`
|
|
16
|
+
${Ue}
|
|
24
17
|
${i}
|
|
25
|
-
${
|
|
26
|
-
`}function
|
|
27
|
-
`;let t=i.transcription.segments.map(e=>{let
|
|
18
|
+
${Ue}
|
|
19
|
+
`}function Y(i){return new Date(i).toLocaleTimeString()}function Do(i){let t=Math.floor(i/60),e=Math.floor(i%60);return`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}`}function Pe(i){if(!i.transcription?.segments?.length)return O("Transcript")+` No transcript available
|
|
20
|
+
`;let t=i.transcription.segments.map(e=>{let r=e.words[0];return` [${r?Do(r.start):"00:00"}] ${e.text}`});return O("Transcript")+t.join(`
|
|
28
21
|
`)+`
|
|
29
|
-
`}function
|
|
30
|
-
`;let e=t.map(o=>{let
|
|
22
|
+
`}function xe(i){let t=i.testerData?.consoleMessages;if(!t?.length)return O("Console Logs")+` No console logs recorded
|
|
23
|
+
`;let e=t.map(o=>{let n=Y(o.timestamp);return` [${o.type}] ${n} ${o.message}`}),r=O("Console Logs")+e.join(`
|
|
31
24
|
`)+`
|
|
32
|
-
`;if(i.testerData?.truncationInfo){let o=i.testerData.truncationInfo;
|
|
25
|
+
`;if(i.testerData?.truncationInfo){let o=i.testerData.truncationInfo;r+=`
|
|
33
26
|
(Truncated: ${JSON.stringify(o)})
|
|
34
|
-
`}return
|
|
35
|
-
`;let e=t.map(
|
|
27
|
+
`}return r}function Re(i){let t=i.testerData?.networkRequests;if(!t?.length)return O("Network Requests")+` No network requests recorded
|
|
28
|
+
`;let e=t.map(r=>{let o=Y(r.timestamp),n=r.status??"---";return` ${r.method} ${n} ${r.url} (${o})`});return O("Network Requests")+e.join(`
|
|
36
29
|
`)+`
|
|
37
|
-
`}function
|
|
38
|
-
`;let e=t.map(
|
|
30
|
+
`}function Oe(i){let t=i.testerData?.events;if(!t?.length)return O("User Events")+` No events recorded
|
|
31
|
+
`;let e=t.map(r=>{let o=Y(r.timestamp),n;switch(r.type){case"click":n=`Click at (${r.x}, ${r.y})${r.element?` on ${r.element}`:""}`;break;case"page_load":n=`${r.event}: ${r.url}`;break;case"form_submit":n=`Form submit (${r.formInfo.fieldCount} fields)`;break;case"spa_route_change":n=`Route: ${r.route}`;break;case"keyboard_input":n=`Typed in ${r.elementInfo.tagName}`;break}return` [${r.type}] ${o} ${n}`});return O("User Events")+e.join(`
|
|
39
32
|
`)+`
|
|
40
|
-
`}function
|
|
41
|
-
`;let t=i.keyMoments.map(e=>{let
|
|
33
|
+
`}function De(i){if(!i.keyMoments?.length)return O("Key Moments")+` No key moments available
|
|
34
|
+
`;let t=i.keyMoments.map(e=>{let r=Y(e.timestamp);return` [${e.type}] ${r} ${e.description} (significance: ${e.significance})`});return O("Key Moments")+t.join(`
|
|
42
35
|
`)+`
|
|
43
|
-
`}function
|
|
44
|
-
`;let t=i.conversationHistory.map(e=>{let
|
|
36
|
+
`}function Ne(i){if(!i.conversationHistory?.length)return O("Conversation History")+` No conversation messages
|
|
37
|
+
`;let t=i.conversationHistory.map(e=>{let r=Y(e.timestamp),o=e.role.charAt(0).toUpperCase()+e.role.slice(1);return` [${r}] ${o}: ${e.content}`});return O("Conversation History")+t.join(`
|
|
45
38
|
`)+`
|
|
46
|
-
`}function
|
|
47
|
-
\u{1F4CA} Test Results: `+t+`
|
|
48
|
-
`),console.log("=".repeat(80)),console.log("Job Information"),console.log("=".repeat(80)+`
|
|
49
|
-
`),console.log(" Job ID: "+s.id),console.log(" Status: "+s.status),s.url&&console.log(" URL: "+s.url),s.description&&console.log(" Description: "+s.description),s.createdAt&&console.log(" Started: "+s.createdAt),s.completedAt&&console.log(" Completed: "+s.completedAt),s.testDurationSeconds&&console.log(" Duration: "+r.formatDuration(s.testDurationSeconds)),s.costUsd&&console.log(" Cost: $"+s.costUsd.toFixed(3)),s.testerAlias&&console.log(" Tester: "+s.testerAlias),s.deviceClass&&console.log(" Device Class: "+s.deviceClass),s.requiredDevices?.length&&console.log(" Required Devices: "+s.requiredDevices.join(", ")),s.requiredLanguages?.length&&console.log(" Required Langs: "+s.requiredLanguages.join(", ")),s.requireSocialVideos&&console.log(" Social Videos: required"),s.result&&Object.keys(s.result).length>0&&!e.raw){console.log(`
|
|
50
|
-
`+"=".repeat(80)),console.log("Structured Results (Extracted)"),console.log("=".repeat(80)+`
|
|
51
|
-
`);for(let[p,m]of Object.entries(s.result)){let h=typeof m=="object"?JSON.stringify(m,null,2):String(m);console.log(` ${p}:`.padEnd(30)+h)}}s.testerResponse&&!e.schemaOnly&&(console.log(`
|
|
52
|
-
`+"=".repeat(80)),console.log("Tester Feedback"),console.log("=".repeat(80)+`
|
|
53
|
-
`),console.log(" "+s.testerResponse.split(`
|
|
39
|
+
`}function he(){let i=new No("results");return i.description("Display detailed results for a completed job").argument("<jobId>","Job ID to show results for").option("-j, --json","Output as JSON").option("--schema-only","Show only extracted schema data").option("--raw","Show raw tester response (no processing)").option("--transcript","Show voice transcript").option("--console-logs","Show console log output").option("--network","Show network requests").option("--events","Show user interaction events").option("--key-moments","Show key moments").option("--conversation","Show conversation history").option("-a, --all","Show all rich test data").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),s=await new h(o).getJob(t);if(e.json){let p=l.result(s);n.output(p);return}if(n.heading(`Test Results: ${t}`),n.sectionHeader("Job Information"),n.detail("Job ID",s.id),n.detail("Status",s.status),s.testerAlias&&n.detail("Tester",s.testerAlias),s.url&&n.detail("URL",s.url),s.description&&n.detail("Description",s.description),s.createdAt&&n.detail("Created",n.formatTimestamp(s.createdAt)),s.completedAt&&n.detail("Completed",n.formatTimestamp(s.completedAt)),s.testDurationSeconds&&n.detail("Duration",n.formatDuration(s.testDurationSeconds)),s.costUsd&&n.detail("Cost",`$${s.costUsd.toFixed(3)}`),s.deviceClass&&n.detail("Device Class",s.deviceClass),s.requiredDevices?.length&&n.detail("Required Devices",s.requiredDevices.join(", ")),s.requiredLanguages?.length&&n.detail("Required Langs",s.requiredLanguages.join(", ")),s.requireSocialVideos&&n.detail("Social Videos","required"),s.result&&Object.keys(s.result).length>0&&!e.raw){n.sectionHeader("Structured Results (Extracted)");for(let[p,d]of Object.entries(s.result)){let f=typeof d=="object"?JSON.stringify(d,null,2):String(d);console.log(` ${p}:`.padEnd(30)+f)}}s.testerResponse&&!e.schemaOnly&&(n.sectionHeader("Tester Feedback"),console.log(" "+s.testerResponse.split(`
|
|
54
40
|
`).join(`
|
|
55
|
-
`)));let c=e.all;(c||e.transcript)&&console.log(
|
|
56
|
-
`),
|
|
57
|
-
`))}
|
|
58
|
-
|
|
59
|
-
`),console.log(`
|
|
60
|
-
`),console.log(`\u{1F4A1} Create a job: runhuman create <url> -d "Test description"
|
|
61
|
-
`);return}console.log(`
|
|
62
|
-
\u{1F4CB} Recent Jobs (${p.length} of ${m.total})
|
|
63
|
-
`),console.log(r.formatJobList(p)),console.log(`
|
|
64
|
-
\u{1F4A1} View details: runhuman status <jobId>`),console.log(` View results: runhuman results <jobId>
|
|
65
|
-
`)}}catch(n){let o=new l({json:e.json}),r=d(n);o.outputError(r.message,r.details),process.exit(r.exitCode)}}),i}T();A();I();C();import{Command as Eo}from"commander";import ko from"inquirer";function ve(){let i=new Eo("delete");return i.description("Delete a job permanently").argument("<jobId>","Job 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{let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color});if(!e.json&&!e.force){let{confirmed:s}=await ko.prompt([{type:"confirm",name:"confirmed",message:`Permanently delete job ${t}? This cannot be undone.`,default:!1}]);if(!s)return}if(await new f(o).deleteJob(t),e.json){let s=l.result({success:!0,message:"Job deleted successfully",jobId:t});r.output(s)}else console.log(`
|
|
66
|
-
\u2705 Job deleted successfully
|
|
67
|
-
`),console.log(` Job ID: ${t}`),console.log(` Status: Permanently deleted
|
|
68
|
-
`)}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}T();A();I();C();import{Command as Po}from"commander";import xo from"chokidar";import{existsSync as ne,mkdirSync as vo,readFileSync as ue,writeFileSync as Uo,unlinkSync as Do}from"fs";import{join as Ue}from"path";import{homedir as De}from"os";var $=Ue(De(),".config","runhuman","watch.pid");function Oe(){let i=new Po("watch");return i.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 Ro();return}if(e.status){No();return}Re()&&(console.log(`
|
|
69
|
-
\u26A0\uFE0F Watch mode is already running`),console.log(` Use --stop to stop it first
|
|
70
|
-
`),process.exit(1));let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=o.watch||{},u=t.length>0?t:r.patterns||["src/**/*"],s=e.ignore||r.ignore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"],c=e.debounce||r.debounce||2e3,p=e.url||r.url||o.defaultUrl,m=e.description||r.description||"Auto-test from watch mode",h=e.template||r.template;p||(console.log(`
|
|
41
|
+
`)));let c=e.all;(c||e.transcript)&&console.log(Pe(s)),(c||e.consoleLogs)&&console.log(xe(s)),(c||e.network)&&console.log(Re(s)),(c||e.events)&&console.log(Oe(s)),(c||e.keyMoments)&&console.log(De(s)),(c||e.conversation)&&console.log(Ne(s)),n.separator(),console.log(),s.richResultsGated&&(console.log(" Rich test data (transcript, logs, network) requires a paid plan."),console.log(` Upgrade at https://runhuman.com/pricing
|
|
42
|
+
`))}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}k();E();S();I();import{Command as Mo}from"commander";function be(){let i=new Mo("list");return i.description("List all jobs with optional filtering").argument("[filter]","Status filter: all|pending|claimed|in_progress|completed|failed|timeout").option("-p, --project <id>","Filter by project").option("-n, --limit <number>","Number of results (default: 20)",parseInt).option("--offset <number>","Pagination offset (default: 0)",parseInt).option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,format:e.format,color:o.color}),u=new h(o),s=C("project",e.project,o,n),c={limit:e.limit||20,offset:e.offset||0,projectId:s};t&&t!=="all"&&(c.status=t);let{items:p,pagination:d}=await u.listJobs(c);if(e.json){let f=l.result({jobs:p,pagination:d});n.output(f)}else{if(d.total===0){n.heading("Recent Jobs (0)"),console.log(`No jobs found.
|
|
43
|
+
`),n.hints([["Create a job",'runhuman create <url> -d "Test description"']]);return}n.heading(`Recent Jobs (${p.length} of ${d.total})`),console.log(n.formatJobList(p)),console.log(),n.hints([["View details","runhuman status <jobId>"],["View results","runhuman results <jobId>"]])}}catch(r){let o=new l({json:e.json}),n=m(r);o.outputError(n.message,n.details),process.exit(n.exitCode)}}),i}k();E();S();I();import{Command as $o}from"commander";import Lo from"inquirer";function ye(){let i=new $o("delete");return i.description("Delete a job permanently").argument("<jobId>","Job ID to delete").option("-f, --force","Skip confirmation prompt").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color});if(!e.json&&!e.force){let{confirmed:s}=await Lo.prompt([{type:"confirm",name:"confirmed",message:`Permanently delete job ${t}? This cannot be undone.`,default:!1}]);if(!s)return}if(await new h(o).deleteJob(t),e.json){let s=l.result({success:!0,message:"Job deleted successfully",jobId:t});n.output(s)}else n.success("Job deleted successfully"),n.detail("Job ID",t),console.log()}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}k();E();S();import{Command as _o}from"commander";import zo from"chokidar";I();import{existsSync as ae,mkdirSync as Jo,readFileSync as je,writeFileSync as Fo,unlinkSync as Ko}from"fs";import{join as Me}from"path";import{homedir as $e}from"os";var J=Me($e(),".config","runhuman","watch.pid");function we(){let i=new _o("watch");return i.description("Watch files and auto-create QA test jobs on changes").argument("[patterns...]",'File patterns to watch (e.g., "src/**/*.tsx")').option("-u, --url <url>","URL to test (required)").option("-t, --template <name>","Template to use for tests").option("-d, --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 qo();return}if(e.status){Vo();return}Le()&&(console.log(`
|
|
44
|
+
Watch mode is already running`),console.log(` Use --stop to stop it first
|
|
45
|
+
`),process.exit(1));let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=o.watch||{},u=t.length>0?t:n.patterns||["src/**/*"],s=e.ignore||n.ignore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"],c=e.debounce||n.debounce||2e3,p=e.url||n.url||o.defaultUrl,d=e.description||n.description||"Auto-test from watch mode",f=e.template||n.template;p||(console.log(`
|
|
71
46
|
\u274C Error: URL required
|
|
72
47
|
`),console.log(`Provide via --url flag or set in .runhumanrc:
|
|
73
48
|
`),console.log(' runhuman watch --url "https://myapp.com"'),console.log(` OR add to .runhumanrc: { "watch": { "url": "..." } }
|
|
74
|
-
`),process.exit(1)),o.
|
|
75
|
-
\u274C Error: No project selected
|
|
76
|
-
`),console.log(`Run: runhuman projects switch <project-id>
|
|
77
|
-
`),process.exit(1));let b=new l({color:o.color});console.log(`
|
|
78
|
-
\u{1F440} Starting watch mode
|
|
79
|
-
`),console.log(` Watching: ${u.join(", ")}`),console.log(` Ignoring: ${s.join(", ")}`),console.log(` Debounce: ${c}ms`),console.log(` URL: ${p}`),h&&console.log(` Template: ${h}`),console.log(`
|
|
49
|
+
`),process.exit(1));let b=new l({color:o.color}),T=C("project",void 0,o,b);b.heading("Starting watch mode"),b.detail("Watching",u.join(", ")),b.detail("Ignoring",s.join(", ")),b.detail("Debounce",`${c}ms`),b.detail("URL",p),f&&b.detail("Template",f),console.log(`
|
|
80
50
|
Press Ctrl+C to stop
|
|
81
|
-
`),
|
|
82
|
-
|
|
83
|
-
`);try{let
|
|
51
|
+
`),Ho(process.pid);let w=new h(o),j=null,P=new Set,v=zo.watch(u,{ignored:s,persistent:!0,ignoreInitial:!0});v.on("change",q=>{P.add(q),console.log(` Changed: ${q}`),j&&clearTimeout(j),j=setTimeout(async()=>{let Ce=Array.from(P);P.clear(),console.log(`
|
|
52
|
+
Creating test job for ${Ce.length} file(s)...
|
|
53
|
+
`);try{let le={projectId:T,url:p,description:`${d}
|
|
84
54
|
|
|
85
55
|
Changed files:
|
|
86
|
-
${
|
|
87
|
-
`)}`,templateId:
|
|
56
|
+
${Ce.map(pt=>`- ${pt}`).join(`
|
|
57
|
+
`)}`,templateId:f},B=await w.createJob(le);console.log(` Job created: ${B.jobId}`),console.log(` Dashboard: ${o.apiUrl}${$.jobSimple.build({jobId:B.jobId})}
|
|
88
58
|
`),console.log(` Watching for more changes...
|
|
89
|
-
`)}catch(
|
|
59
|
+
`)}catch(le){let B=m(le);b.outputError(B.message,B.details),console.log(`
|
|
90
60
|
Watching for more changes...
|
|
91
|
-
`)}},c)}),
|
|
92
|
-
\u274C Watch error: ${
|
|
93
|
-
`)});let
|
|
61
|
+
`)}},c)}),v.on("error",q=>{console.error(`
|
|
62
|
+
\u274C Watch error: ${q instanceof Error?q.message:String(q)}
|
|
63
|
+
`)});let W=()=>{console.log(`
|
|
94
64
|
|
|
95
|
-
|
|
96
|
-
`),
|
|
97
|
-
|
|
98
|
-
`);return}try{let i=parseInt(
|
|
99
|
-
|
|
100
|
-
`)}catch{
|
|
101
|
-
|
|
102
|
-
`)}}function
|
|
103
|
-
|
|
65
|
+
Stopping watch mode...
|
|
66
|
+
`),v.close(),Z(),process.exit(0)};process.on("SIGINT",W),process.on("SIGTERM",W)}catch(r){let o=m(r);new l({}).outputError(o.message,o.details),Z(),process.exit(o.exitCode)}}),i}function Ho(i){let t=Me($e(),".config","runhuman");ae(t)||Jo(t,{recursive:!0}),Fo(J,i.toString())}function Z(){ae(J)&&Ko(J)}function Le(){if(!ae(J))return!1;try{let i=parseInt(je(J,"utf-8"));return process.kill(i,0),!0}catch{return Z(),!1}}async function qo(){if(!ae(J)){console.log(`
|
|
67
|
+
Watch mode is not running
|
|
68
|
+
`);return}try{let i=parseInt(je(J,"utf-8"));process.kill(i,"SIGTERM"),Z(),console.log(`
|
|
69
|
+
Watch mode stopped
|
|
70
|
+
`)}catch{Z(),console.log(`
|
|
71
|
+
Watch process not found (already stopped)
|
|
72
|
+
`)}}function Vo(){if(Le()){let i=parseInt(je(J,"utf-8"));console.log(`
|
|
73
|
+
Watch mode is running`),console.log(` PID: ${i}`),console.log(`
|
|
104
74
|
Stop with: runhuman watch --stop
|
|
105
75
|
`)}else console.log(`
|
|
106
|
-
|
|
107
|
-
`)}
|
|
108
|
-
Please visit: ${
|
|
76
|
+
Watch mode is not running
|
|
77
|
+
`)}k();E();I();S();import{Command as Zo}from"commander";import Go from"http";import{URL as Wo}from"url";import Bo from"open";async function ce(i){let{apiUrl:t,autoOpenBrowser:e=!0}=i;return new Promise((r,o)=>{let n=Go.createServer((s,c)=>{if(!s.url){c.writeHead(400),c.end("Bad request");return}let p=new Wo(s.url,"http://localhost");if(p.pathname==="/callback"){let d=p.searchParams.get("token"),f=p.searchParams.get("email"),b=p.searchParams.get("projectId")||"",T=p.searchParams.get("error");if(T){c.writeHead(200,{"Content-Type":"text/html"}),c.end(_e(T)),n.close(),o(new Error(T));return}if(d&&f){c.writeHead(200,{"Content-Type":"text/html"}),c.end(Yo(f)),n.close(),r({token:d,email:f,projectId:b});return}c.writeHead(400,{"Content-Type":"text/html"}),c.end(_e("Missing token or email in callback")),n.close(),o(new Error("Missing token or email in callback"));return}c.writeHead(404),c.end("Not found")});n.listen(0,"127.0.0.1",async()=>{let s=n.address();if(!s||typeof s=="string"){o(new Error("Failed to start local server"));return}let p=`http://127.0.0.1:${s.port}/callback`,d=`${t}/cli/auth?callback=${encodeURIComponent(p)}`;if(console.log(""),e){console.log("Opening browser for authentication...");try{await Bo(d)}catch{console.log("Could not open browser automatically."),console.log(`
|
|
78
|
+
Please visit: ${d}`)}}else console.log(`Please visit: ${d}`);console.log(""),console.log("Waiting for authentication...")});let u=setTimeout(()=>{n.close(),o(new Error("Authentication timed out. Please try again."))},60*1e3);n.on("close",()=>clearTimeout(u)),n.on("error",s=>{clearTimeout(u),o(new Error(`Failed to start local server: ${s.message}`))})})}function Yo(i){return`<!DOCTYPE html>
|
|
109
79
|
<html>
|
|
110
80
|
<head>
|
|
111
81
|
<title>Runhuman CLI - Authenticated</title>
|
|
@@ -147,7 +117,7 @@ Please visit: ${m}`)}}else console.log(`Please visit: ${m}`);console.log(""),con
|
|
|
147
117
|
<p class="close-note">You can close this tab and return to the terminal.</p>
|
|
148
118
|
</div>
|
|
149
119
|
</body>
|
|
150
|
-
</html>`}function
|
|
120
|
+
</html>`}function _e(i){return`<!DOCTYPE html>
|
|
151
121
|
<html>
|
|
152
122
|
<head>
|
|
153
123
|
<title>Runhuman CLI - Authentication Failed</title>
|
|
@@ -190,118 +160,42 @@ Please visit: ${m}`)}}else console.log(`Please visit: ${m}`);console.log(""),con
|
|
|
190
160
|
<div class="error">${i}</div>
|
|
191
161
|
</div>
|
|
192
162
|
</body>
|
|
193
|
-
</html>`}function
|
|
194
|
-
`))
|
|
195
|
-
`)
|
|
196
|
-
`)}catch(e){let
|
|
197
|
-
|
|
198
|
-
`),console.log("
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
`),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 s=r==="apiKey"&&!t.showSecrets?ze(String(u)):u;console.log(` ${r}:`.padEnd(20)+s)}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 s=r==="apiKey"&&!t.showSecrets?ze(String(u)):u;console.log(` ${r}:`.padEnd(20)+s)}console.log()}console.log("\u{1F4A1} Set value: runhuman config set <key> <value>"),console.log(` Get value: runhuman config get <key>
|
|
202
|
-
`)}}catch(e){let n=d(e);new l({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),i.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.
|
|
203
|
-
`),process.exit(0)),await new g().reset(e);let o=new l({json:t.json});if(t.json){let r=l.result({success:!0,scope:e});o.output(r)}else o.success(`Reset ${e} configuration`)}catch(e){let n=d(e);new l({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),i}function ze(i){return i.length<=8?"****":i.substring(0,4)+"*".repeat(i.length-8)+i.substring(i.length-4)}C();I();import{Command as Ho}from"commander";import Go from"inquirer";import{writeFileSync as Wo}from"fs";import{join as Bo}from"path";function Je(){let i=new Ho("init");return i.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 l({json:t.json});!t.json&&!t.yes&&(console.log(`\u{1F680} Welcome to Runhuman!
|
|
204
|
-
`),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
|
|
205
|
-
`),console.log("=".repeat(60)+`
|
|
206
|
-
`));let n=t.name,o=t.url,r=t.githubRepo;if(!t.yes&&!t.json){let c=await Go.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||c.projectName,o=o||c.defaultUrl,r=r||c.githubRepo}let u={defaultUrl:o||void 0,githubRepo:r||void 0,defaultDuration:5,defaultDeviceClass:"desktop"},s=Bo(process.cwd(),".runhumanrc");if(Wo(s,JSON.stringify(u,null,2)),t.json){let c=l.result({success:!0,configPath:s,config:u});e.output(c)}else console.log(`
|
|
207
|
-
`+"=".repeat(60)),e.success("Project initialized successfully!"),console.log(`\u{1F4C1} Configuration saved to: .runhumanrc
|
|
208
|
-
`),console.log(`\u{1F389} All set! Try creating your first test:
|
|
163
|
+
</html>`}function ze(){let i=new Zo("login");return i.description("Authenticate with Runhuman").option("--token <token>","Login with API key (skip browser)").option("--no-browser","Print auth URL instead of opening browser").option("-j, --json","Output as JSON").action(async t=>{try{let e=new g,r=await e.loadConfig(),o=new l({json:t.json,color:r.color});if(t.token)await Qo(e,o,t.token,t.json);else{let n=t.browser!==!1&&r.autoOpenBrowser!==!1;await Xo(e,o,r.apiUrl,n,t.json)}}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i}async function Qo(i,t,e,r){i.saveCredentials({accessToken:e});let o=await i.loadConfig({apiKey:e}),u=await new h(o).getCurrentUser();i.saveUserInfo(u),r?t.output(l.result({success:!0,user:u})):(t.success("Successfully logged in!"),t.detail("Email",u.email),t.detail("Account ID",u.accountId),console.log())}async function Xo(i,t,e,r,o){o||console.log("Logging in to Runhuman...");let n=await ce({apiUrl:e||"https://runhuman.com",autoOpenBrowser:r});i.saveCredentials({accessToken:n.token}),await i.set("project",n.projectId,!0);let u=await i.loadConfig({apiKey:n.token}),c=await new h(u).getCurrentUser();i.saveUserInfo(c),o?t.output(l.result({success:!0,user:c,projectId:n.projectId})):(console.log(""),t.success("Successfully logged in!"),t.detail("Email",c.email),t.detail("Account ID",c.accountId),t.detail("Default Project",n.projectId),console.log()),process.exit(0)}E();I();S();import{Command as en}from"commander";function Je(){let i=new en("logout");return i.description("Log out and clear stored credentials").option("-f, --force","Skip confirmation prompt").option("-j, --json","Output as JSON").action(async t=>{try{let e=new g,r=new l({json:t.json});if(e.clearCredentials(),e.clearUserInfo(),t.json){let o=l.result({success:!0,message:"Logged out successfully"});r.output(o)}else r.success("Logged out successfully!"),console.log(` Credentials have been cleared.
|
|
164
|
+
`)}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i}k();E();I();S();import{Command as tn}from"commander";function Fe(){let i=new tn("whoami");return i.description("Display current user information").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let r=await new g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new l({json:t.json}),u=await new h(r).getCurrentUser();if(t.json){let s=l.result({user:u});o.output(s)}else o.heading("Current User"),o.detail("Email",u.email),o.detail("Account ID",u.accountId),r.project&&(console.log(),o.detail("Default Project",r.project)),console.log()}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i}E();I();S();import{Command as on}from"commander";function Ke(){let i=new on("config");return i.description("Manage CLI configuration"),i.command("get").description("Get a configuration value").argument("<key>","Configuration key").option("-j, --json","Output as JSON").action(async(t,e)=>{try{let o=await new g().get(t),n=new l({json:e.json});if(e.json){let u=l.result({[t]:o});n.output(u)}else console.log(o!==void 0?o:"(not set)")}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("set").description("Set a configuration value").argument("<key>","Configuration key").argument("<value>","Configuration value").option("-g, --global","Set globally (not project-specific)").option("-j, --json","Output as JSON").action(async(t,e,r)=>{try{await new g().set(t,e,r.global);let n=new l({json:r.json});if(r.json){let u=l.result({success:!0,key:t,value:e,scope:r.global?"global":"project"});n.output(u)}else n.success(`Set ${t} = ${e}`+(r.global?" (global)":" (project)"))}catch(o){let n=m(o);new l({json:r.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),i.command("list").description("List all configuration values").option("--show-secrets","Show API keys (default: masked)").option("-j, --json","Output as JSON").action(async t=>{try{let r=await new g().list(),o=new l({json:t.json});if(t.json){let n=l.result(r);o.output(n)}else{o.heading("Configuration");let n=["organization","project","apiKey","apiUrl"],u={organization:"RUNHUMAN_ORGANIZATION",project:"RUNHUMAN_PROJECT",apiKey:"RUNHUMAN_API_KEY",apiUrl:"RUNHUMAN_API_URL"};console.log(`Resolution chain (highest priority \u2192 lowest):
|
|
165
|
+
`);for(let c of n){let p=r.effective[c],d=r.env?.[c],f=r.project?.[c],b=r.global?.[c],T=c==="apiKey",w=v=>T&&!t.showSecrets?nn(String(v)):String(v),j=d?"env":f?"project":b?"global":p?"default":null;console.log(` ${c}:`),console.log(p?` \u2713 ${w(p)} [from ${j}]`:" (not set)");let P=u[c];d&&console.log(` \u251C\u2500 env (${P}): ${w(d)}`),f&&console.log(` \u251C\u2500 project (.runhumanrc): ${w(f)}`),b&&console.log(` \u2514\u2500 global (~/.config/runhuman): ${w(b)}`),console.log()}let s=Object.keys(r.effective).filter(c=>!n.includes(c));if(s.length>0){console.log(`Other settings:
|
|
166
|
+
`);for(let c of s){let p=r.effective[c];p!==void 0&&console.log(` ${c}:`.padEnd(24)+String(p))}console.log()}console.log("Environment Variables:"),console.log(" RUNHUMAN_ORGANIZATION Default organization ID"),console.log(" RUNHUMAN_PROJECT Default project ID"),console.log(" RUNHUMAN_API_KEY API key"),console.log(" RUNHUMAN_API_URL API URL"),console.log(" RUNHUMAN_NO_COLOR=1 Disable colors"),console.log(),o.hints([["Set value","runhuman config set <key> <value>"],["Get value","runhuman config get <key>"]])}}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i.command("reset").description("Reset configuration to defaults").option("-g, --global","Reset global config").option("--project","Reset project config").option("--all","Reset all config").option("-f, --force","Skip confirmation prompt").option("-j, --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.
|
|
167
|
+
`),process.exit(0)),await new g().reset(e);let o=new l({json:t.json});if(t.json){let n=l.result({success:!0,scope:e});o.output(n)}else o.success(`Reset ${e} configuration`)}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i}function nn(i){return i.length<=8?"****":i.substring(0,4)+"*".repeat(i.length-8)+i.substring(i.length-4)}I();S();import{Command as rn}from"commander";import sn from"inquirer";import{writeFileSync as an}from"fs";import{join as cn}from"path";function He(){let i=new rn("init");return i.description("Initialize a new Runhuman project with configuration").option("--name <text>","Project name").option("-u, --url <url>","Default URL").option("--github-repo <owner/repo>","GitHub repository").option("-y, --yes","Skip all prompts (use defaults)").option("-j, --json","Output as JSON").action(async t=>{try{let e=new l({json:t.json});!t.json&&!t.yes&&(console.log(`Welcome to Runhuman!
|
|
168
|
+
`),console.log("Let's set up your project. This will create:"),console.log(" - A configuration file (.runhumanrc)"),console.log(` - Setup your project defaults
|
|
169
|
+
`));let r=t.name,o=t.url,n=t.githubRepo;if(!t.yes&&!t.json){let c=await sn.prompt([{type:"input",name:"projectName",message:"Project name:",default:"My Project",when:!r},{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:!n}]);r=r||c.projectName,o=o||c.defaultUrl,n=n||c.githubRepo}let u={defaultUrl:o||void 0,githubRepo:n||void 0,defaultDuration:5,defaultDeviceClass:"desktop"},s=cn(process.cwd(),".runhumanrc");if(an(s,JSON.stringify(u,null,2)),t.json){let c=l.result({success:!0,configPath:s,config:u});e.output(c)}else e.success("Project initialized successfully!"),console.log(` Configuration saved to: .runhumanrc
|
|
170
|
+
`),console.log(` All set! Try creating your first test:
|
|
209
171
|
`),console.log(` runhuman create https://example.com -d "Test homepage"
|
|
210
|
-
`),console.log(
|
|
211
|
-
`)}catch(e){let
|
|
212
|
-
|
|
213
|
-
`),console.log(`No projects found.
|
|
214
|
-
`),
|
|
215
|
-
`);return}console.log(`
|
|
216
|
-
|
|
217
|
-
`)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
`),
|
|
222
|
-
\u{1F4A1} Check status: runhuman transfers list`),console.log("\u{1F4A1} Cancel: runhuman transfers cancel "+s.id),console.log())}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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{if(!e.json&&!e.force){let{confirmed:s}=await Fe.prompt([{type:"confirm",name:"confirmed",message:`Permanently delete project ${t} and all its data? This cannot be undone.`,default:!1}]);if(!s)return}let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color});if(await new f(o).deleteProject(t),e.json){let s=l.result({success:!0});r.output(s)}else r.success("Project deleted successfully!")}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}T();A();C();I();import{Command as Qo}from"commander";import qe from"cli-table3";function Ve(){let i=new Qo("orgs");return i.alias("organizations"),i.description("Manage organizations"),i.command("list").alias("ls").description("List all organizations you belong to").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 g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new l({json:t.json,color:n.color}),r=new f(n),{items:u,total:s}=await r.listOrganizations({limit:t.limit||20});if(t.json){let c=l.result({organizations:u,pagination:{total:s,limit:t.limit||20,offset:0,hasMore:u.length<s}});o.output(c)}else{console.log(`
|
|
223
|
-
\u{1F3E2} Your Organizations (${u.length} of ${s})
|
|
224
|
-
`);let c=new qe({head:["Organization ID","Name","Projects","Created"].map(p=>p),colWidths:[25,30,12,15]});u.forEach(p=>{c.push([p.id,p.name,p.projectCount?.toString()||"0",new Date(p.createdAt).toLocaleDateString()])}),console.log(c.toString()),console.log(`
|
|
225
|
-
\u{1F4A1} View org details: runhuman orgs show <id>`),console.log(`\u{1F4A1} Check org balance: runhuman orgs balance <id>
|
|
226
|
-
`)}}catch(e){let n=d(e);new l({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),i.command("show").alias("info").alias("get").description("Show detailed organization information").argument("<organizationId>","Organization 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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color}),s=await new f(o).getOrganization(t);if(e.json){let c=l.result(s);r.output(c)}else console.log(`
|
|
227
|
-
\u{1F3E2} Organization Details
|
|
228
|
-
`),console.log(" Organization ID: "+s.id),console.log(" Name: "+s.name),console.log(" Created: "+new Date(s.createdAt).toLocaleString()),console.log(),console.log("\u{1F4A1} List projects: runhuman orgs projects "+s.id),console.log("\u{1F4A1} Check balance: runhuman orgs balance "+s.id),console.log()}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("balance").description("Show organization billing balance").argument("<organizationId>","Organization ID").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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color}),u=new f(o),[s,c]=await Promise.all([u.getOrganization(t),u.getOrganizationBilling(t)]);if(e.json){let p=l.result({balance:c});r.output(p)}else console.log(`
|
|
229
|
-
\u{1F4B0} Organization Balance: ${s.name}
|
|
230
|
-
`),console.log(" Current Balance: $"+c.balanceUsd.toFixed(2)),console.log(" Billing Active: "+(c.hasBilling?"Yes":"No")),console.log(),console.log(" Estimated Tests: ~"+Math.floor(c.balance)+" tests at $1.00 per test"),console.log(),c.hasBilling?console.log("\u{1F4A1} Manage billing: https://runhuman.com/dashboard/organizations/"+t+"/billing"):console.log("\u{1F4A1} Set up billing: https://runhuman.com/dashboard/organizations/"+t+"/billing"),console.log()}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("projects").description("List all projects in an organization").argument("<organizationId>","Organization ID").option("--limit <number>","Number of results (default: 50)",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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color}),u=new f(o),[s,{items:c,total:p}]=await Promise.all([u.getOrganization(t),u.listOrganizationProjects(t,{limit:e.limit||50})]);if(e.json){let m=l.result({organizationId:t,projects:c,total:p});r.output(m)}else{if(p===0){console.log(`
|
|
231
|
-
\u{1F4C1} Projects in ${s.name} (0 projects)
|
|
232
|
-
`),console.log(`No projects found in this organization.
|
|
233
|
-
`),console.log("\u{1F4A1} Create a project: runhuman projects create <name> --organization "+t),console.log("\u{1F4A1} View organization: runhuman orgs show "+t),console.log();return}console.log(`
|
|
234
|
-
\u{1F4C1} Projects in ${s.name} (${c.length} of ${p})
|
|
235
|
-
`);let m=new qe({head:["Name","Project ID","Default URL","Created"].map(h=>h),colWidths:[25,25,30,15]});c.forEach(h=>{let b=h.defaultUrl?h.defaultUrl.length>27?h.defaultUrl.substring(0,24)+"...":h.defaultUrl:"-";m.push([h.name,h.id,b,new Date(h.createdAt).toLocaleDateString()])}),console.log(m.toString()),console.log(`
|
|
236
|
-
\u{1F4A1} View project details: runhuman projects show <project-id>`),console.log("\u{1F4A1} Create new project: runhuman projects create <name> --organization "+t),console.log("\u{1F4A1} View organization: runhuman orgs show "+t),console.log()}}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}T();A();C();I();import{Command as Xo}from"commander";import en from"inquirer";import tn from"cli-table3";function Ge(){let i=new Xo("keys");return i.description("Manage API keys"),i.command("list").alias("ls").description("List all API keys for an organization").option("--organization <id>","Organization ID (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 g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=t.organization;if(!o)throw new Error("Organization ID required (use --organization)");let r=new l({json:t.json,color:n.color}),u=new f(n),{items:s,total:c}=await u.listApiKeys(o);if(t.json){let p=l.result({keys:s,total:c});r.output(p)}else{if(c===0){console.log(`
|
|
237
|
-
\u{1F511} API Keys (0)
|
|
238
|
-
`),console.log(`No API keys found for this organization.
|
|
239
|
-
`),console.log('\u{1F4A1} Create a key: runhuman keys create "Key Name" --organization '+o+`
|
|
240
|
-
`);return}console.log(`
|
|
241
|
-
\u{1F511} API Keys (${s.length} of ${c})
|
|
242
|
-
`);let p=new tn({head:["Key ID","Name","Key","Last Used","Created"].map(m=>m),colWidths:[20,25,20,20,20]});s.forEach(m=>{let h=t.showKeys?m.key:He(m.key),b=m.lastUsedAt?new Date(m.lastUsedAt).toLocaleDateString():"Never";p.push([m.id,m.name,h,b,new Date(m.createdAt).toLocaleDateString()])}),console.log(p.toString()),console.log(`
|
|
243
|
-
\u{1F4A1} Create new key: runhuman keys create "Key Name" --organization `+o),console.log(` Show full key: runhuman keys show <keyId>
|
|
244
|
-
`)}}catch(e){let n=d(e);new l({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),i.command("create").alias("new").description("Create a new API key for an organization").argument("<name>","API key name").option("--organization <id>","Organization 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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=e.organization;if(!r)throw new Error("Organization ID required (use --organization)");let u=new l({json:e.json,color:o.color}),c=await new f(o).createApiKey(r,t);if(e.json){let p=l.result(c);u.output(p)}else u.success("API Key created successfully!"),console.log(`
|
|
245
|
-
Key ID: `+c.id),console.log(" Name: "+c.name),console.log(`
|
|
246
|
-
API Key: `+c.key),console.log(" "+"^".repeat(c.key.length)),console.log(` \u26A0\uFE0F Save this key! It won't be shown again.
|
|
247
|
-
`),console.log("\u{1F4A1} Use this key:"),console.log(" export RUNHUMAN_API_KEY="+c.key),console.log(` runhuman create https://myapp.com -d "Test"
|
|
248
|
-
`),console.log("\u{1F512} Store securely:"),console.log(" - Use environment variables (recommended)"),console.log(" - Use secret management tools"),console.log(` - Never commit to git!
|
|
249
|
-
`)}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color}),s=await new f(o).getApiKey(t);if(e.json){let c=l.result(s);r.output(c)}else console.log(`
|
|
250
|
-
\u{1F511} API Key Details
|
|
251
|
-
`),console.log(" Key ID: "+s.id),console.log(" Name: "+s.name),console.log(" Key: "+(e.showKey?s.key:He(s.key))),console.log(" Created: "+new Date(s.createdAt).toLocaleString()),s.lastUsedAt&&console.log(" Last Used: "+new Date(s.lastUsedAt).toLocaleString()),console.log()}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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{if(!e.json&&!e.force){let{confirmed:s}=await en.prompt([{type:"confirm",name:"confirmed",message:`Permanently delete API key ${t}? This cannot be undone.`,default:!1}]);if(!s)return}let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color});if(await new f(o).deleteApiKey(t),e.json){let s=l.result({success:!0});r.output(s)}else r.success("API key deleted successfully!")}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}function He(i){return i.length<=12?"****":i.substring(0,8)+"*".repeat(i.length-12)+i.substring(i.length-4)}T();A();C();I();import{Command as on}from"commander";import nn from"inquirer";import rn from"cli-table3";function We(){let i=new on("templates");return i.description("Manage test templates"),i.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 g().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 l({json:t.json,color:n.color}),u=new f(n),{items:s,pagination:c}=await u.listTemplates(o);if(t.json){let p=l.result({templates:s,pagination:c});r.output(p)}else{if(c.total===0){console.log(`
|
|
252
|
-
\u{1F4CB} Test Templates (0)
|
|
253
|
-
`),console.log(`No templates found for this project.
|
|
254
|
-
`),console.log('\u{1F4A1} Create a template: runhuman templates create "Template Name" --project '+o+`
|
|
255
|
-
`);return}console.log(`
|
|
256
|
-
\u{1F4CB} Test Templates (${s.length} of ${c.total})
|
|
257
|
-
`);let p=new rn({head:["ID","Name","Description","Created"].map(m=>m),colWidths:[30,25,35,20]});s.forEach(m=>{let h=m.testDescription&&m.testDescription.length>30?m.testDescription.substring(0,27)+"...":m.testDescription||"-";p.push([m.id,m.name,h,new Date(m.createdAt).toLocaleDateString()])}),console.log(p.toString()),console.log(`
|
|
258
|
-
\u{1F4A1} Create new template: runhuman templates create "Template Name" --project `+o),console.log(` View template: runhuman templates show <templateId>
|
|
259
|
-
`)}}catch(e){let n=d(e);new l({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),i.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("--device-class <class>","Device class (desktop/mobile)").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 g().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 l({json:e.json,color:o.color}),s;if(e.schema){let{readFileSync:h}=await import("fs"),b=h(e.schema,"utf-8");s=JSON.parse(b)}let c={name:t,testDescription:e.description,targetDurationMinutes:e.duration?Math.floor(parseInt(e.duration)/60):void 0,deviceClass:e.deviceClass,outputSchema:s},m=await new f(o).createTemplate(r,c);if(e.json){let h=l.result(m);u.output(h)}else u.success("Template created successfully!"),console.log(`
|
|
260
|
-
Template ID: `+m.id),console.log(" Name: "+m.name),m.testDescription&&console.log(" Description: "+m.testDescription),console.log(`
|
|
261
|
-
\u{1F4A1} Use this template:`),console.log(" runhuman create https://myapp.com --template "+m.id+`
|
|
262
|
-
`)}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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 g().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 l({json:e.json,color:o.color}),c=await new f(o).getTemplate(r,t);if(e.json){let p=l.result(c);u.output(p)}else console.log(`
|
|
263
|
-
\u{1F4CB} Template Details
|
|
264
|
-
`),console.log("ID: "+c.id),console.log("Name: "+c.name),console.log("Description: "+(c.testDescription||"-")),console.log("Project: "+c.projectId),c.targetDurationMinutes&&console.log("Duration: "+c.targetDurationMinutes+" minutes"),c.deviceClass&&console.log("Device Class: "+c.deviceClass),console.log("Created: "+new Date(c.createdAt).toLocaleString()),c.outputSchema&&(console.log(`
|
|
265
|
-
Output Schema:`),console.log(JSON.stringify(c.outputSchema,null,2))),console.log(`
|
|
266
|
-
\u{1F4A1} Use this template:`),console.log(" runhuman create https://myapp.com --template "+c.id+`
|
|
267
|
-
`)}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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("--device-class <class>","New device class (desktop/mobile)").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 g().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 l({json:e.json,color:o.color}),s;if(e.schema){let{readFileSync:b}=await import("fs"),w=b(e.schema,"utf-8");s=JSON.parse(w)}let c={name:e.name,testDescription:e.description,targetDurationMinutes:e.duration?Math.floor(parseInt(e.duration)/60):void 0,deviceClass:e.deviceClass,outputSchema:s},p=Object.fromEntries(Object.entries(c).filter(([,b])=>b!==void 0));if(Object.keys(p).length===0)throw new Error("No updates provided. Use --name, --description, --duration, --device-class, or --schema");let h=await new f(o).updateTemplate(r,t,c);if(e.json){let b=l.result(h);u.output(b)}else u.success("Template updated successfully!"),console.log(`
|
|
268
|
-
Template ID: `+h.id),console.log(" Name: "+h.name+`
|
|
269
|
-
`)}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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{if(!e.json&&!e.force){let{confirmed:c}=await nn.prompt([{type:"confirm",name:"confirmed",message:`Permanently delete template ${t}? This cannot be undone.`,default:!1}]);if(!c)return}let o=await new g().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 l({json:e.json,color:o.color});if(await new f(o).deleteTemplate(r,t),e.json){let c=l.result({success:!0});u.output(c)}else u.success("Template deleted successfully!")}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}T();A();C();I();import{Command as sn}from"commander";import Be from"cli-table3";function Ye(){let i=new sn("github");return i.alias("gh"),i.description("GitHub integration commands"),i.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 g,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 l({json:e.json,color:o.color});if(!t.match(/^([^/]+)\/([^/]+)$/))throw new Error("Invalid repository format. Use: owner/repo");if(await new f(o).updateProject(r,{githubRepo:t}),e.json){let p=l.result({success:!0,repository:t});u.output(p)}else u.success("GitHub repository linked successfully!"),console.log(`
|
|
270
|
-
Repository: `+t),console.log(" Project: "+r),console.log(`
|
|
271
|
-
\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+`
|
|
272
|
-
`),await n.saveProjectConfig({githubRepo:t}),console.log(`\u2713 Repository saved to project config (.runhumanrc)
|
|
273
|
-
`)}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("repos").alias("repositories").description("List GitHub repositories accessible to an organization").option("--organization <id>","Organization ID (required)").option("--search <query>","Filter by repository name").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 g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=t.organization;if(!o)throw new Error("Organization ID required (use --organization)");let r=new l({json:t.json,color:n.color}),s=await new f(n).listGithubRepos(o,{search:t.search});if(t.json)r.output(l.result(s));else{console.log(`
|
|
274
|
-
\u{1F517} GitHub Repositories (${s.items.length})
|
|
275
|
-
`);let c=new Be({head:["Repository","Added"].map(p=>p),colWidths:[45,20]});s.items.forEach(p=>{c.push([p.fullName,new Date(p.createdAt).toLocaleDateString()])}),console.log(c.toString()),console.log(`
|
|
276
|
-
\u{1F4A1} Test an issue: runhuman github test <issueNumber> --repo owner/repo
|
|
277
|
-
`)}}catch(e){let n=d(e);new l({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),i.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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color}),u=t.match(/^([^/]+)\/([^/]+)$/);if(!u)throw new Error("Invalid repository format. Use: owner/repo");let[,s,c]=u,m=await new f(o).listGithubIssues(s,c,{state:e.state,labels:e.labels?.split(",")});if(e.json){let h=l.result({issues:m});r.output(h)}else{console.log(`
|
|
278
|
-
\u{1F41B} GitHub Issues for ${t} (${m.length})
|
|
279
|
-
`);let h=new Be({head:["#","Title","State","Labels","Created"].map(b=>b),colWidths:[8,40,10,20,15]});m.forEach(b=>{let w=b.labels?.join(", ")||"-",j=w.length>18?w.substring(0,15)+"...":w;h.push(["#"+b.number,b.title.length>38?b.title.substring(0,35)+"...":b.title,b.state,j,new Date(b.createdAt).toLocaleDateString()])}),console.log(h.toString()),console.log(`
|
|
280
|
-
\u{1F4A1} Test an issue: runhuman github test <issueNumber> --repo `+t+`
|
|
281
|
-
`)}}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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 g().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 l({json:e.json,color:o.color}),s=r.match(/^([^/]+)\/([^/]+)$/);if(!s)throw new Error("Invalid repository format. Use: owner/repo");let[,c,p]=s,m=new f(o),h=await m.getGithubIssue(c,p,parseInt(t));if(!o.project)throw new Error("No project selected. Run: runhuman projects switch <project-id>");let b={projectId:o.project,url:e.url,description:`Test GitHub issue #${t}: ${h.title}
|
|
172
|
+
`),console.log(` Learn more: https://runhuman.com/docs/cli
|
|
173
|
+
`)}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i}k();E();I();S();import{Command as ln}from"commander";import qe from"inquirer";import un from"cli-table3";function Ve(){let i=new ln("projects");return i.description("Manage projects"),i.command("list").alias("ls").description("List all projects").option("-n, --limit <number>","Number of results (default: 20)",parseInt).option("--offset <number>","Pagination offset (default: 0)",parseInt).option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let r=await new g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new l({json:t.json,color:r.color}),n=new h(r),u=t.limit||20,s=t.offset||0,[{items:c,pagination:p},{items:d}]=await Promise.all([n.listProjects({limit:u,offset:s}),n.listOrganizations({})]),f=new Map(d.map(b=>[b.id,b.name]));if(t.json){let b=l.result({projects:c,pagination:p});o.output(b)}else{if(p.total===0){o.heading("Your Projects (0)"),console.log(`No projects found.
|
|
174
|
+
`),o.hints([["Create a project","runhuman projects create <name> -o <org-id>"]]);return}o.heading(`Your Projects (${c.length} of ${p.total})`);let b=new un({head:o.tableHead(["Name","Organization","Project ID","Created"]),colWidths:[25,25,25,15]});c.forEach(P=>{let v=f.get(P.organizationId)||"(unknown)";b.push([P.name,v,P.id,o.formatShortDate(P.createdAt)])}),console.log(b.toString());let T=s+1,w=s+c.length;console.log(`
|
|
175
|
+
Showing ${T}-${w} of ${p.total} projects`);let j=[["View project","runhuman projects show <id>"],["Filter by org","runhuman orgs projects <org-id>"]];p.hasMore&&j.push(["Next page",`runhuman projects list --offset ${s+u}`]),console.log(),o.hints(j)}}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i.command("create").alias("new").description("Create a new project in an organization").argument("<name>","Project name").option("-o, --organization <id>","Organization ID (required)").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("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let r=new g,o=await r.loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=C("organization",e.organization,o,n),c=await new h(o).createProject({name:t,organizationId:u,defaultUrl:e.defaultUrl,githubRepo:e.githubRepo});if(e.setDefault&&await r.set("project",c.id,!1),e.json){let p=l.result(c);n.output(p)}else n.success("Project created successfully!"),console.log(" Project ID: "+c.id),console.log(" Name: "+c.name),e.setDefault&&console.log(" Set as default project"),console.log()}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("show").alias("info").alias("get").description("Show detailed project information").argument("<projectId>","Project ID to show").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=new h(o),s=await u.getProject(t),[c,p]=await Promise.all([u.getOrganization(s.organizationId),u.getOrganizationBilling(s.organizationId)]);if(e.json){let d=l.result({project:s,organization:c,balance:{balance:p.balance,balanceUsd:p.balanceUsd}});n.output(d)}else n.heading("Project Details"),n.detail("Project ID",s.id),n.detail("Name",s.name),n.detail("Organization",c.name+" ("+c.id+")"),n.detail("Org Balance","$"+p.balanceUsd.toFixed(2)),s.defaultUrl&&n.detail("Default URL",s.defaultUrl),s.githubRepo&&n.detail("GitHub Repo",s.githubRepo),n.detail("Created",n.formatTimestamp(s.createdAt)),n.detail("Last Updated",n.formatTimestamp(s.updatedAt)),console.log(),n.hints([["View organization","runhuman orgs show "+c.id],["List org projects","runhuman orgs projects "+c.id],["Check org balance","runhuman orgs balance "+c.id]])}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("switch").alias("use").description("Set default project for CLI commands").argument("<projectId>","Project ID to use as default").option("-g, --global","Set as global default instead of local").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let r=new g,o=await r.loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),s=await new h(o).getProject(t);if(await r.set("project",t,e.global!==!1),e.json){let c=l.result({success:!0,projectId:t,projectName:s.name,scope:e.global!==!1?"global":"local"});n.output(c)}else n.success(`Default project set to: ${s.name} (${t})`),e.global!==!1?console.log(" Scope: global (all directories)"):console.log(" Scope: local (current directory only)"),console.log()}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("update").description("Update project settings").argument("<projectId>","Project ID to update").option("--name <text>","Update name").option("--default-url <url>","Update default URL").option("--github-repo <owner/repo>","Update GitHub repo").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u={name:e.name,defaultUrl:e.defaultUrl,githubRepo:e.githubRepo},c=await new h(o).updateProject(t,u);if(e.json){let p=l.result(c);n.output(p)}else n.success("Project updated successfully!")}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("transfer").description("Transfer a project to another organization").argument("<projectId>","Project ID to transfer").requiredOption("--to-org <organizationId>","Target organization ID").option("-f, --force","Skip confirmation prompt").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=new h(o),[s,c]=await Promise.all([u.getProject(t),u.getOrganization(e.toOrg)]);if(!e.json&&!e.force){let{confirmed:d}=await qe.prompt([{type:"confirm",name:"confirmed",message:`Transfer "${s.name}" to organization "${c.name}"? The current organization will lose access to this project.`,default:!1}]);if(!d)return}let p=await u.initiateTransfer(t,e.toOrg);e.json?n.output(l.result(p)):p.type==="immediate"?(n.success(`Project transferred to ${c.name}!`),n.detail("Project",p.project.name),n.detail("New Organization",c.name),console.log(),n.hints([["View project","runhuman projects show "+t]])):(n.success("Transfer request sent (pending approval)."),n.detail("Transfer ID",p.transfer.id),n.detail("Project",s.name),n.detail("To Organization",c.name),console.log(),n.hints([["Check status","runhuman transfers list"],["Cancel transfer","runhuman transfers cancel "+p.transfer.id]]))}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("delete").alias("rm").description("Delete a project permanently").argument("<projectId>","Project ID to delete").option("-f, --force","Skip confirmation prompt").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{if(!e.json&&!e.force){let{confirmed:s}=await qe.prompt([{type:"confirm",name:"confirmed",message:`Permanently delete project ${t} and all its data? This cannot be undone.`,default:!1}]);if(!s)return}let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color});if(await new h(o).deleteProject(t),e.json){let s=l.result({success:!0});n.output(s)}else n.success("Project deleted successfully!")}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}k();E();I();S();import{Command as pn}from"commander";import Ge from"cli-table3";function We(){let i=new pn("orgs");return i.description("Manage organizations"),i.command("list").alias("ls").description("List all organizations you belong to").option("-n, --limit <number>","Number of results (default: 20)",parseInt).option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let r=await new g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new l({json:t.json,color:r.color}),n=new h(r),{items:u,total:s}=await n.listOrganizations({limit:t.limit||20});if(t.json){let c=l.result({organizations:u,pagination:{total:s,limit:t.limit||20,offset:0,hasMore:u.length<s}});o.output(c)}else{o.heading(`Your Organizations (${u.length} of ${s})`);let c=new Ge({head:o.tableHead(["Organization ID","Name","Projects","Created"]),colWidths:[25,30,12,15]});u.forEach(p=>{c.push([p.id,p.name,p.projectCount?.toString()||"0",o.formatShortDate(p.createdAt)])}),console.log(c.toString()),console.log(),o.hints([["View org details","runhuman orgs show <id>"],["Check org balance","runhuman orgs balance <id>"]])}}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i.command("show").alias("info").alias("get").description("Show detailed organization information").argument("<organizationId>","Organization ID to show").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),s=await new h(o).getOrganization(t);if(e.json){let c=l.result(s);n.output(c)}else n.heading("Organization Details"),n.detail("Organization ID",s.id),n.detail("Name",s.name),n.detail("Created",n.formatTimestamp(s.createdAt)),console.log(),n.hints([["List projects","runhuman orgs projects "+s.id],["Check balance","runhuman orgs balance "+s.id]])}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("balance").description("Show organization billing balance").argument("<organizationId>","Organization ID").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=new h(o),[s,c]=await Promise.all([u.getOrganization(t),u.getOrganizationBilling(t)]);if(e.json){let p=l.result({balance:c});n.output(p)}else n.heading(`Organization Balance: ${s.name}`),n.detail("Current Balance","$"+c.balanceUsd.toFixed(2)),n.detail("Billing Active",c.hasBilling?"Yes":"No"),n.detail("Estimated Tests","~"+Math.floor(c.balance)+" tests at $1.00 per test"),console.log(),c.hasBilling?n.hints([["Manage billing","https://runhuman.com/dashboard/organizations/"+t+"/billing"]]):n.hints([["Set up billing","https://runhuman.com/dashboard/organizations/"+t+"/billing"]])}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("switch").alias("use").description("Set default organization for CLI commands").argument("<organizationId>","Organization ID to use as default").option("-g, --global","Set as global default instead of local").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let r=new g,o=await r.loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),s=await new h(o).getOrganization(t);if(await r.set("organization",t,e.global!==!1),e.json){let c=l.result({success:!0,organizationId:t,organizationName:s.name,scope:e.global!==!1?"global":"local"});n.output(c)}else n.success(`Default organization set to: ${s.name} (${t})`),e.global!==!1?console.log(" Scope: global (all directories)"):console.log(" Scope: local (current directory only)"),console.log()}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("projects").description("List all projects in an organization").argument("<organizationId>","Organization ID").option("-n, --limit <number>","Number of results (default: 50)",parseInt).option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=new h(o),[s,{items:c,total:p}]=await Promise.all([u.getOrganization(t),u.listOrganizationProjects(t,{limit:e.limit||50})]);if(e.json){let d=l.result({organizationId:t,projects:c,total:p});n.output(d)}else{if(p===0){n.heading(`Projects in ${s.name} (0 projects)`),console.log(`No projects found in this organization.
|
|
176
|
+
`),n.hints([["Create a project","runhuman projects create <name> --organization "+t],["View organization","runhuman orgs show "+t]]);return}n.heading(`Projects in ${s.name} (${c.length} of ${p})`);let d=new Ge({head:n.tableHead(["Name","Project ID","Default URL","Created"]),colWidths:[25,25,30,15]});c.forEach(f=>{let b=f.defaultUrl?f.defaultUrl.length>27?f.defaultUrl.substring(0,24)+"...":f.defaultUrl:"-";d.push([f.name,f.id,b,n.formatShortDate(f.createdAt)])}),console.log(d.toString()),console.log(),n.hints([["View project details","runhuman projects show <project-id>"],["Create new project","runhuman projects create <name> --organization "+t],["View organization","runhuman orgs show "+t]])}}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}k();E();I();S();import{Command as dn}from"commander";import mn from"inquirer";import gn from"cli-table3";function Ye(){let i=new dn("keys");return i.description("Manage API keys"),i.command("list").alias("ls").description("List all API keys for an organization").option("-o, --organization <id>","Organization ID (required)").option("--show-keys","Show full API keys (default: masked)").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let r=await new g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new l({json:t.json,color:r.color}),n=C("organization",t.organization,r,o),u=new h(r),{items:s,total:c}=await u.listApiKeys(n);if(t.json){let p=l.result({keys:s,total:c});o.output(p)}else{if(c===0){o.heading("API Keys (0)"),console.log(`No API keys found for this organization.
|
|
177
|
+
`),o.hints([["Create a key",'runhuman keys create "Key Name" --organization '+n]]);return}o.heading(`API Keys (${s.length} of ${c})`);let p=new gn({head:o.tableHead(["Key ID","Name","Key","Last Used","Created"]),colWidths:[20,25,20,20,20]});s.forEach(d=>{let f=t.showKeys?d.key:Be(d.key),b=d.lastUsedAt?o.formatShortDate(d.lastUsedAt):"Never";p.push([d.id,d.name,f,b,o.formatShortDate(d.createdAt)])}),console.log(p.toString()),console.log(),o.hints([["Create new key",'runhuman keys create "Key Name" --organization '+n],["Show full key","runhuman keys show <keyId>"]])}}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i.command("create").alias("new").description("Create a new API key for an organization").argument("<name>","API key name").option("-o, --organization <id>","Organization ID (required)").option("--copy","Copy key to clipboard").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=C("organization",e.organization,o,n),c=await new h(o).createApiKey(u,t);if(e.json){let p=l.result(c);n.output(p)}else n.success("API Key created successfully!"),n.detail("Key ID",c.id),n.detail("Name",c.name),console.log(),n.detail("API Key",c.key),console.log(" "+"^".repeat(c.key.length)),console.log(` \u26A0\uFE0F Save this key! It won't be shown again.
|
|
178
|
+
`),console.log(" Use this key:"),console.log(" export RUNHUMAN_API_KEY="+c.key),console.log(` runhuman create https://myapp.com -d "Test"
|
|
179
|
+
`),console.log(" Store securely:"),console.log(" - Use environment variables (recommended)"),console.log(" - Use secret management tools"),console.log(` - Never commit to git!
|
|
180
|
+
`)}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),s=await new h(o).getApiKey(t);if(e.json){let c=l.result(s);n.output(c)}else n.heading("API Key Details"),n.detail("Key ID",s.id),n.detail("Name",s.name),n.detail("API Key",e.showKey?s.key:Be(s.key)),n.detail("Created",n.formatTimestamp(s.createdAt)),s.lastUsedAt&&n.detail("Last Used",n.formatTimestamp(s.lastUsedAt)),console.log()}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("delete").aliases(["rm","revoke"]).description("Delete an API key permanently").argument("<keyId>","Key ID to delete").option("-f, --force","Skip confirmation prompt").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{if(!e.json&&!e.force){let{confirmed:s}=await mn.prompt([{type:"confirm",name:"confirmed",message:`Permanently delete API key ${t}? This cannot be undone.`,default:!1}]);if(!s)return}let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color});if(await new h(o).deleteApiKey(t),e.json){let s=l.result({success:!0});n.output(s)}else n.success("API key deleted successfully!")}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}function Be(i){return i.length<=12?"****":i.substring(0,8)+"*".repeat(i.length-12)+i.substring(i.length-4)}k();E();I();S();import{Command as fn}from"commander";import hn from"inquirer";import bn from"cli-table3";function Ze(){let i=new fn("templates");return i.description("Manage test templates"),i.command("list").alias("ls").description("List all test templates").option("-p, --project <id>","Filter by project (required)").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let r=await new g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new l({json:t.json,color:r.color}),n=C("project",t.project,r,o),u=new h(r),{items:s,pagination:c}=await u.listTemplates(n);if(t.json){let p=l.result({templates:s,pagination:c});o.output(p)}else{if(c.total===0){o.heading("Test Templates (0)"),console.log(`No templates found for this project.
|
|
181
|
+
`),o.hints([["Create a template",'runhuman templates create "Template Name" --project '+n]]);return}o.heading(`Test Templates (${s.length} of ${c.total})`);let p=new bn({head:o.tableHead(["ID","Name","Description","Created"]),colWidths:[30,25,35,20]});s.forEach(d=>{let f=d.testDescription&&d.testDescription.length>30?d.testDescription.substring(0,27)+"...":d.testDescription||"-";p.push([d.id,d.name,f,o.formatShortDate(d.createdAt)])}),console.log(p.toString()),console.log(),o.hints([["Create new template",'runhuman templates create "Template Name" --project '+n],["View template","runhuman templates show <templateId>"]])}}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i.command("create").alias("new").description("Create a new test template").argument("<name>","Template name").option("-p, --project <id>","Project ID (required)").option("-d, --description <text>","Template description").option("--duration <seconds>","Target test duration in seconds").option("--device-class <class>","Device class (desktop/mobile)").option("-S, --schema <path>","Path to JSON schema file").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=C("project",e.project,o,n),s;if(e.schema){let{readFileSync:f}=await import("fs"),b=f(e.schema,"utf-8");s=JSON.parse(b)}let c={name:t,testDescription:e.description,targetDurationMinutes:e.duration?Math.floor(parseInt(e.duration)/60):void 0,deviceClass:e.deviceClass,outputSchema:s},d=await new h(o).createTemplate(u,c);if(e.json){let f=l.result(d);n.output(f)}else n.success("Template created successfully!"),n.detail("Template ID",d.id),n.detail("Name",d.name),d.testDescription&&n.detail("Description",d.testDescription),console.log(),n.hints([["Use this template","runhuman create https://myapp.com --template "+d.id]])}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("show").alias("info").alias("get").description("Show details of a specific template").argument("<templateId>","Template ID to show").option("-p, --project <id>","Project ID (required)").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=C("project",e.project,o,n),c=await new h(o).getTemplate(u,t);if(e.json){let p=l.result(c);n.output(p)}else n.heading("Template Details"),n.detail("Template ID",c.id),n.detail("Name",c.name),n.detail("Description",c.testDescription||"-"),n.detail("Project",c.projectId),c.targetDurationMinutes&&n.detail("Duration",c.targetDurationMinutes+" minutes"),c.deviceClass&&n.detail("Device Class",c.deviceClass),n.detail("Created",n.formatTimestamp(c.createdAt)),c.outputSchema&&(console.log(`
|
|
182
|
+
Output Schema:`),console.log(JSON.stringify(c.outputSchema,null,2))),console.log(),n.hints([["Use this template","runhuman create https://myapp.com --template "+c.id]])}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("update").alias("edit").description("Update a template").argument("<templateId>","Template ID to update").option("-p, --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("--device-class <class>","New device class (desktop/mobile)").option("-S, --schema <path>","Path to new JSON schema file").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=C("project",e.project,o,n),s;if(e.schema){let{readFileSync:b}=await import("fs"),T=b(e.schema,"utf-8");s=JSON.parse(T)}let c={name:e.name,testDescription:e.description,targetDurationMinutes:e.duration?Math.floor(parseInt(e.duration)/60):void 0,deviceClass:e.deviceClass,outputSchema:s},p=Object.fromEntries(Object.entries(c).filter(([,b])=>b!==void 0));if(Object.keys(p).length===0)throw new Error("No updates provided. Use --name, --description, --duration, --device-class, or --schema");let f=await new h(o).updateTemplate(u,t,c);if(e.json){let b=l.result(f);n.output(b)}else n.success("Template updated successfully!"),n.detail("Template ID",f.id),n.detail("Name",f.name),console.log()}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("delete").alias("rm").description("Delete a template permanently").argument("<templateId>","Template ID to delete").option("-p, --project <id>","Project ID (required)").option("-f, --force","Skip confirmation prompt").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{if(!e.json&&!e.force){let{confirmed:c}=await hn.prompt([{type:"confirm",name:"confirmed",message:`Permanently delete template ${t}? This cannot be undone.`,default:!1}]);if(!c)return}let o=await new g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=C("project",e.project,o,n);if(await new h(o).deleteTemplate(u,t),e.json){let c=l.result({success:!0});n.output(c)}else n.success("Template deleted successfully!")}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}k();E();I();S();import{Command as yn}from"commander";import Qe from"cli-table3";function Xe(){let i=new yn("github");return i.alias("gh"),i.description("GitHub integration commands"),i.command("link").description("Link a GitHub repository to your project").argument("<repo>","Repository in format owner/repo").option("-p, --project <id>","Project ID (required)").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async(t,e)=>{try{let r=new g,o=await r.loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=C("project",e.project,o,n);if(!t.match(/^([^/]+)\/([^/]+)$/))throw new Error("Invalid repository format. Use: owner/repo");if(await new h(o).updateProject(u,{githubRepo:t}),e.json){let p=l.result({success:!0,repository:t});n.output(p)}else n.success("GitHub repository linked successfully!"),n.detail("Repository",t),n.detail("Project",u),console.log(),await r.saveProjectConfig({githubRepo:t}),console.log(` Repository saved to project config (.runhumanrc)
|
|
183
|
+
`),n.hints([["List issues","runhuman github issues "+t],["Test an issue","runhuman github test <issueNumber> --repo "+t],["Bulk test","runhuman github bulk-test --repo "+t]])}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("repos").alias("repositories").description("List GitHub repositories accessible to an organization").option("-o, --organization <id>","Organization ID (required)").option("--search <query>","Filter by repository name").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let r=await new g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new l({json:t.json,color:r.color}),n=C("organization",t.organization,r,o),s=await new h(r).listGithubRepos(n,{search:t.search});if(t.json)o.output(l.result(s));else{o.heading(`GitHub Repositories (${s.items.length})`);let c=new Qe({head:o.tableHead(["Repository","Added"]),colWidths:[45,20]});s.items.forEach(p=>{c.push([p.fullName,o.formatShortDate(p.createdAt)])}),console.log(c.toString()),console.log(),o.hints([["Test an issue","runhuman github test <issueNumber> --repo owner/repo"]])}}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i.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("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color}),u=t.match(/^([^/]+)\/([^/]+)$/);if(!u)throw new Error("Invalid repository format. Use: owner/repo");let[,s,c]=u,d=await new h(o).listGithubIssues(s,c,{state:e.state,labels:e.labels?.split(",")});if(e.json){let f=l.result({issues:d});n.output(f)}else{n.heading(`GitHub Issues for ${t} (${d.length})`);let f=new Qe({head:n.tableHead(["#","Title","State","Labels","Created"]),colWidths:[8,40,10,20,15]});d.forEach(b=>{let T=b.labels?.join(", ")||"-",w=T.length>18?T.substring(0,15)+"...":T;f.push(["#"+b.number,b.title.length>38?b.title.substring(0,35)+"...":b.title,b.state,w,n.formatShortDate(b.createdAt)])}),console.log(f.toString()),console.log(),n.hints([["Test an issue","runhuman github test <issueNumber> --repo "+t]])}}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.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("-u, --url <url>","URL to test (required)").option("--template <id>","Template ID to use").option("-s, --sync","Wait for result before exiting").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=e.repo||o.githubRepo;if(!n)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 l({json:e.json,color:o.color}),s=n.match(/^([^/]+)\/([^/]+)$/);if(!s)throw new Error("Invalid repository format. Use: owner/repo");let[,c,p]=s,d=new h(o),f=await d.getGithubIssue(c,p,parseInt(t)),T={projectId:C("project",void 0,o,u),url:e.url,description:`Test GitHub issue #${t}: ${f.title}
|
|
282
184
|
|
|
283
|
-
${
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
`)
|
|
287
|
-
`);return}if(!n.project)throw new Error("No project selected. Run: runhuman projects switch <project-id>");console.log(`
|
|
288
|
-
\u{1F680} Creating ${b.length} test jobs...
|
|
289
|
-
`);let w=[];for(let j of b){let k={projectId:n.project,url:t.url,description:`Test GitHub issue #${j.number}: ${j.title}
|
|
185
|
+
${f.body}`,metadata:{githubIssue:{owner:c,repo:p,number:parseInt(t),url:f.url}},templateId:e.template},w=await d.createJob(T);if(e.json){let j=l.result(w);u.output(j)}else if(u.success("QA test job created for issue #"+t),u.detail("Job ID",w.jobId),u.detail("Issue","#"+t+" - "+f.title),u.detail("Status",w.status),u.detail("URL",e.url),console.log(),u.hints([["Check status","runhuman status "+w.jobId]]),e.sync){let{waitForJob:j}=await Promise.resolve().then(()=>(se(),me));await j(w.jobId,d,u,600)}}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("bulk-test").description("Create QA test jobs for multiple GitHub issues").option("--repo <owner/repo>","Repository (or use default from config)").option("-u, --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("-n, --limit <number>","Maximum number of jobs to create","10").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let r=await new g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=t.repo||r.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 n=new l({json:t.json,color:r.color}),u=o.match(/^([^/]+)\/([^/]+)$/);if(!u)throw new Error("Invalid repository format. Use: owner/repo");let[,s,c]=u,p=new h(r),d=await p.listGithubIssues(s,c,{state:t.state,labels:t.labels?.split(",")}),f=parseInt(t.limit),b=d.slice(0,f);if(b.length===0){console.log(`No issues found matching the criteria.
|
|
186
|
+
`);return}let T=C("project",void 0,r,n);console.log(`
|
|
187
|
+
Creating ${b.length} test jobs...
|
|
188
|
+
`);let w=[];for(let j of b){let P={projectId:T,url:t.url,description:`Test GitHub issue #${j.number}: ${j.title}
|
|
290
189
|
|
|
291
|
-
${j.body}`,metadata:{githubIssue:{owner:s,repo:c,number:j.number,url:j.url}},templateId:t.template};try{let
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
`)}}catch(e){let
|
|
295
|
-
|
|
296
|
-
`),
|
|
297
|
-
`);
|
|
298
|
-
|
|
299
|
-
`);else{let c=new Ze({head:["Transfer ID","Project","To Org","Status","Created"],colWidths:[20,25,25,15,15]});s.items.forEach(p=>{c.push([p.id.substring(0,18),p.projectName,p.toOrganizationName??"-",p.status,new Date(p.createdAt).toLocaleDateString()])}),console.log(c.toString()),console.log()}console.log("\u{1F4A1} Accept: runhuman transfers accept <transferId>"),console.log("\u{1F4A1} Reject: runhuman transfers reject <transferId>"),console.log("\u{1F4A1} Cancel: runhuman transfers cancel <transferId>"),console.log()}catch(e){let n=d(e);new l({json:t.json}).outputError(n.message,n.details),process.exit(n.exitCode)}}),i.command("accept").description("Accept a pending transfer").argument("<transferId>","Transfer ID to accept").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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color});await new f(o).acceptTransfer(t),e.json?r.output(l.result({success:!0,transferId:t})):(r.success("Transfer accepted!"),console.log(" Transfer ID: "+t),console.log())}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("reject").description("Reject a pending transfer").argument("<transferId>","Transfer ID to reject").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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color});await new f(o).rejectTransfer(t),e.json?r.output(l.result({success:!0,transferId:t})):(r.success("Transfer rejected."),console.log(" Transfer ID: "+t),console.log())}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("cancel").description("Cancel a transfer you initiated").argument("<transferId>","Transfer ID to cancel").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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),r=new l({json:e.json,color:o.color});await new f(o).cancelTransfer(t),e.json?r.output(l.result({success:!0,transferId:t})):(r.success("Transfer cancelled."),console.log(" Transfer ID: "+t),console.log())}catch(n){let o=d(n);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}A();T();import{existsSync as cn}from"fs";import{join as ln}from"path";import{execSync as un}from"child_process";import J from"inquirer";import E from"chalk";import et from"ora";I();async function tt(){let i=new g,t=new l({color:!0});console.log(""),console.log(E.bold("Runhuman")+" - Human QA testing for your apps"),console.log("");let e=await Xe(i);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(`
|
|
300
|
-
Run `+E.cyan("runhuman login")+` when you're ready to sign in.
|
|
301
|
-
`);return}await pn(i,t),Object.assign(e,await Xe(i))}console.log(E.green("Logged in as "+e.userEmail)+`
|
|
302
|
-
`),e.isRunhumanProject?await mn(i,e):await dn(i,e)}async function Xe(i){let t={isAuthenticated:!1,isGitRepo:!1,isRunhumanProject:!1},e=i.loadCredentials();if(e?.accessToken)try{let o=await i.loadConfig({apiKey:e.accessToken}),u=await new f(o).getCurrentUser();t.isAuthenticated=!0,t.userEmail=u.email}catch{t.isAuthenticated=!1}try{un("git rev-parse --is-inside-work-tree",{stdio:"ignore"}),t.isGitRepo=!0}catch{t.isGitRepo=!1}let n=ln(process.cwd(),".runhumanrc");if(cn(n)){t.isRunhumanProject=!0;try{let o=await i.loadConfig();t.projectConfig={defaultUrl:o.defaultUrl,githubRepo:o.githubRepo}}catch{}}return t}async function pn(i,t){let e=await i.loadConfig(),n=e.apiUrl||"https://runhuman.com";console.log("");let o=et("Opening browser for authentication...").start();try{let r=await re({apiUrl:n,autoOpenBrowser:e.autoOpenBrowser!==!1});o.stop(),i.saveCredentials({accessToken:r.token});let u=await i.loadConfig({apiKey:r.token}),c=await new f(u).getCurrentUser();i.saveUserInfo(c),t.success("Successfully logged in!"),console.log("")}catch(r){throw o.stop(),r}}async function mn(i,t){console.log(E.dim("Runhuman project detected")),t.projectConfig?.defaultUrl&&console.log(E.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 ot(i,t);break;case"run-template":console.log(`
|
|
303
|
-
Run `+E.cyan("runhuman templates")+" to see available templates."),console.log("Then run "+E.cyan("runhuman create --template <name>")+` to use one.
|
|
190
|
+
${j.body}`,metadata:{githubIssue:{owner:s,repo:c,number:j.number,url:j.url}},templateId:t.template};try{let v=await p.createJob(P);w.push({issue:j.number,jobId:v.jobId,status:"created"}),console.log(` ok Issue #${j.number} \u2192 Job ${v.jobId}`)}catch(v){let W=m(v);w.push({issue:j.number,error:W.message,status:"failed"}),console.log(` FAIL Issue #${j.number} \u2192 Failed: ${W.message}`)}}if(t.json){let j=l.result({jobs:w});n.output(j)}else{let j=w.filter(v=>v.status==="created").length,P=w.filter(v=>v.status==="failed").length;console.log(`
|
|
191
|
+
Created ${j} jobs`),P>0&&console.log(`Failed ${P} jobs`),console.log(),n.hints([["Check all jobs","runhuman list"]])}}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i}k();E();I();S();import{Command as jn}from"commander";import et from"cli-table3";function tt(){let i=new jn("transfers");return i.description("Manage project transfers between organizations"),i.command("list").alias("ls").description("List pending incoming and outgoing transfers").option("-j, --json","Output as JSON").option("--api-key <key>","API key").option("--api-url <url>","API URL").action(async t=>{try{let r=await new g().loadConfig({apiKey:t.apiKey,apiUrl:t.apiUrl}),o=new l({json:t.json,color:r.color}),n=new h(r),[u,s]=await Promise.all([n.listPendingTransfers(),n.listOutgoingTransfers()]);if(t.json){let c=l.result({incoming:u.items,outgoing:s.items});o.output(c);return}if(o.heading(`Incoming Transfers (${u.total})`),u.items.length===0)console.log(`No pending incoming transfers.
|
|
192
|
+
`);else{let c=new et({head:o.tableHead(["Transfer ID","Project","From","To Org","Created"]),colWidths:[20,25,25,25,15]});u.items.forEach(p=>{c.push([p.id.substring(0,18),p.projectName,p.initiatedByEmail??"Unknown",p.toOrganizationName??"-",o.formatShortDate(p.createdAt)])}),console.log(c.toString()),console.log()}if(o.heading(`Outgoing Transfers (${s.total})`),s.items.length===0)console.log(`No pending outgoing transfers.
|
|
193
|
+
`);else{let c=new et({head:o.tableHead(["Transfer ID","Project","To Org","Status","Created"]),colWidths:[20,25,25,15,15]});s.items.forEach(p=>{c.push([p.id.substring(0,18),p.projectName,p.toOrganizationName??"-",p.status,o.formatShortDate(p.createdAt)])}),console.log(c.toString()),console.log()}o.hints([["Accept transfer","runhuman transfers accept <transferId>"],["Reject transfer","runhuman transfers reject <transferId>"],["Cancel transfer","runhuman transfers cancel <transferId>"]])}catch(e){let r=m(e);new l({json:t.json}).outputError(r.message,r.details),process.exit(r.exitCode)}}),i.command("accept").description("Accept a pending transfer").argument("<transferId>","Transfer ID to accept").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color});await new h(o).acceptTransfer(t),e.json?n.output(l.result({success:!0,transferId:t})):(n.success("Transfer accepted!"),n.detail("Transfer ID",t),console.log())}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("reject").description("Reject a pending transfer").argument("<transferId>","Transfer ID to reject").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color});await new h(o).rejectTransfer(t),e.json?n.output(l.result({success:!0,transferId:t})):(n.success("Transfer rejected."),n.detail("Transfer ID",t),console.log())}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i.command("cancel").description("Cancel a transfer you initiated").argument("<transferId>","Transfer ID to cancel").option("-j, --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 g().loadConfig({apiKey:e.apiKey,apiUrl:e.apiUrl}),n=new l({json:e.json,color:o.color});await new h(o).cancelTransfer(t),e.json?n.output(l.result({success:!0,transferId:t})):(n.success("Transfer cancelled."),n.detail("Transfer ID",t),console.log())}catch(r){let o=m(r);new l({json:e.json}).outputError(o.message,o.details),process.exit(o.exitCode)}}),i}E();k();import{existsSync as wn}from"fs";import{join as Cn}from"path";import{execSync as In}from"child_process";import H from"inquirer";import U from"chalk";import nt from"ora";S();async function rt(){let i=new g,t=new l({color:!0});console.log(""),console.log(U.bold("Runhuman")+" - Human QA testing for your apps"),console.log("");let e=await ot(i);if(!e.isAuthenticated){let{shouldLogin:r}=await H.prompt([{type:"confirm",name:"shouldLogin",message:"You're not logged in. Would you like to sign in?",default:!0}]);if(!r){console.log(`
|
|
194
|
+
Run `+U.cyan("runhuman login")+` when you're ready to sign in.
|
|
195
|
+
`);return}await An(i,t),Object.assign(e,await ot(i))}console.log(U.green("Logged in as "+e.userEmail)+`
|
|
196
|
+
`),e.isRunhumanProject?await Sn(i,e):await Tn(i,e)}async function ot(i){let t={isAuthenticated:!1,isGitRepo:!1,isRunhumanProject:!1},e=i.loadCredentials();if(e?.accessToken)try{let o=await i.loadConfig({apiKey:e.accessToken}),u=await new h(o).getCurrentUser();t.isAuthenticated=!0,t.userEmail=u.email}catch{t.isAuthenticated=!1}try{In("git rev-parse --is-inside-work-tree",{stdio:"ignore"}),t.isGitRepo=!0}catch{t.isGitRepo=!1}let r=Cn(process.cwd(),".runhumanrc");if(wn(r)){t.isRunhumanProject=!0;try{let o=await i.loadConfig();t.projectConfig={defaultUrl:o.defaultUrl,githubRepo:o.githubRepo}}catch{}}return t}async function An(i,t){let e=await i.loadConfig(),r=e.apiUrl||"https://runhuman.com";console.log("");let o=nt("Opening browser for authentication...").start();try{let n=await ce({apiUrl:r,autoOpenBrowser:e.autoOpenBrowser!==!1});o.stop(),i.saveCredentials({accessToken:n.token});let u=await i.loadConfig({apiKey:n.token}),c=await new h(u).getCurrentUser();i.saveUserInfo(c),t.success("Successfully logged in!"),console.log("")}catch(n){throw o.stop(),n}}async function Sn(i,t){console.log(U.dim("Runhuman project detected")),t.projectConfig?.defaultUrl&&console.log(U.dim("URL: "+t.projectConfig.defaultUrl)),console.log("");let{action:e}=await H.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 H.Separator,{name:"Exit",value:"exit"}]}]);switch(e){case"quick-test":await it(i,t);break;case"run-template":console.log(`
|
|
197
|
+
Run `+U.cyan("runhuman templates")+" to see available templates."),console.log("Then run "+U.cyan("runhuman create --template <name>")+` to use one.
|
|
304
198
|
`);break;case"list-jobs":console.log(`
|
|
305
|
-
Run `+
|
|
306
|
-
`);break;case"exit":break}}async function
|
|
307
|
-
Run: runhuman projects switch <project-id>`);return}let c=await new
|
|
199
|
+
Run `+U.cyan("runhuman list")+` to see your recent jobs.
|
|
200
|
+
`);break;case"exit":break}}async function Tn(i,t){t.isGitRepo?console.log(U.dim("Git repository detected (not yet set up with Runhuman)")):console.log(U.dim("Not in a git repository")),console.log("");let{action:e}=await H.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 H.Separator,{name:"Exit",value:"exit"}]}]);switch(e){case"quick-test":await it(i,t);break;case"setup-repo":await En(i);break;case"connect-github":await vn(i);break;case"exit":break}}async function it(i,t){let e=t.projectConfig?.defaultUrl||"",r=await H.prompt([{type:"input",name:"url",message:"URL to test:",default:e||void 0,validate:n=>{if(!n.trim())return"URL is required";try{return new URL(n),!0}catch{return"Please enter a valid URL"}}},{type:"input",name:"description",message:"What should we test? (describe in plain English):",validate:n=>n.trim()?!0:"Description is required"}]),o=nt("Creating test job...").start();try{let n=i.loadCredentials(),u=await i.loadConfig({apiKey:n?.accessToken});if(!u.project){o.fail("No project selected"),console.log(`
|
|
201
|
+
Run: runhuman projects switch <project-id>`);return}let c=await new h(u).createJob({projectId:u.project,url:r.url,description:r.description});o.succeed("Test job created!"),console.log(""),console.log(" Job ID: "+U.cyan(c.jobId)),console.log(" Status: "+c.status),console.log(""),console.log("A human tester will test your app shortly."),console.log("Run "+U.cyan(`runhuman wait ${c.jobId}`)+" to wait for results."),console.log("")}catch(n){throw o.fail("Failed to create test job"),n}}async function En(i){console.log(""),console.log("Setting up Runhuman in the current repository..."),console.log("");let t=await H.prompt([{type:"input",name:"defaultUrl",message:"Default URL to test (optional):"}]);await i.saveProjectConfig({defaultUrl:t.defaultUrl||void 0,defaultDuration:5,defaultDeviceClass:"desktop"}),console.log(""),console.log(U.green("Created .runhumanrc")),console.log(""),console.log("Next steps:"),console.log(" 1. Install the GitHub App to enable @runhuman comments"),console.log(" "+U.cyan("runhuman github connect")),console.log(""),console.log(" 2. Create your first test:"),console.log(" "+U.cyan('runhuman create https://your-app.com -d "Test login flow"')),console.log("")}async function vn(i){let r=`${(await i.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(" "+U.cyan(r)),console.log(""),console.log("After installation, you can comment "+U.bold("@runhuman")+" on any issue"),console.log("to trigger a QA test."),console.log("")}import{readFileSync as kn}from"fs";import{join as Un,dirname as Pn}from"path";import{fileURLToPath as xn}from"url";var Rn=xn(import.meta.url),On=Pn(Rn),Dn=Un(On,"../package.json"),Nn=JSON.parse(kn(Dn,"utf-8")),Mn=Nn.version,A=new st;A.name("runhuman").description("CLI for Runhuman - AI-orchestrated human QA testing").version(Mn);A.addCommand(ge());A.addCommand(fe());A.addCommand(ie());A.addCommand(he());A.addCommand(be());A.addCommand(ye());A.addCommand(we());var z=new st("job");z.description("Manage QA test jobs");z.addCommand(ge());z.addCommand(fe());z.addCommand(ie());z.addCommand(he());z.addCommand(be());z.addCommand(ye());z.addCommand(we());A.addCommand(z);A.addCommand(ze());A.addCommand(Je());A.addCommand(Fe());A.addCommand(Ke());A.addCommand(He());var at=Ve();at.alias("project");A.addCommand(at);var ct=We();ct.aliases(["org","organizations","organization"]);A.addCommand(ct);var lt=Ye();lt.alias("key");A.addCommand(lt);var ut=Ze();ut.alias("template");A.addCommand(ut);A.addCommand(Xe());A.addCommand(tt());process.argv.slice(2).length?A.parse(process.argv):rt().catch(i=>{console.error(i.message),process.exit(1)});
|