@nrwl/nx-cloud 13.0.2-beta.2 → 13.1.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.
@@ -1,153 +1 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CloudRunApi = void 0;
13
- const output_1 = require("@nrwl/workspace/src/utilities/output");
14
- const axios_1 = require("../../../utilities/axios");
15
- const environment_1 = require("../../../utilities/environment");
16
- const fs_1 = require("fs");
17
- const zlib_1 = require("zlib");
18
- const util_1 = require("util");
19
- const metric_logger_1 = require("../../../utilities/metric-logger");
20
- class CloudRunApi {
21
- constructor(messages, runContext, options, machineInfo) {
22
- this.messages = messages;
23
- this.runContext = runContext;
24
- this.machineInfo = machineInfo;
25
- this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
26
- }
27
- startRun(distributedExecutionId, hashes) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const recorder = (0, metric_logger_1.createMetricRecorder)('startRun');
30
- try {
31
- const request = {
32
- meta: {
33
- nxCloudVersion: this.nxCloudVersion(),
34
- },
35
- branch: (0, environment_1.getBranch)(),
36
- runGroup: (0, environment_1.getRunGroup)(),
37
- distributedExecutionId,
38
- hashes,
39
- };
40
- if (environment_1.VERBOSE_LOGGING) {
41
- output_1.output.note({
42
- title: 'RunStart',
43
- bodyLines: ['\n' + JSON.stringify(request, null, 2)],
44
- });
45
- }
46
- const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/start', request), environment_1.NUMBER_OF_TRIES);
47
- recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
48
- if (resp.data && resp.data.message) {
49
- this.messages.message = resp.data.message;
50
- }
51
- if (!resp.data || !resp.data.urls) {
52
- this.messages.apiError = `Invalid Nx Cloud response: ${JSON.stringify(resp.data)}`;
53
- return {};
54
- }
55
- return resp.data.urls;
56
- }
57
- catch (e) {
58
- recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
59
- this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
60
- return {};
61
- }
62
- });
63
- }
64
- endRun(run, tasks) {
65
- var _a;
66
- return __awaiter(this, void 0, void 0, function* () {
67
- // API is not working, don't make the end request
68
- if (this.messages.apiError)
69
- return false;
70
- const uncompressedReqBody = {
71
- meta: {
72
- nxCloudVersion: this.nxCloudVersion(),
73
- },
74
- tasks,
75
- run: run,
76
- machineInfo: this.machineInfo,
77
- };
78
- const uncompressedBuffer = Buffer.from(JSON.stringify(uncompressedReqBody));
79
- const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
80
- const recorder = (0, metric_logger_1.createMetricRecorder)('endRun');
81
- try {
82
- if (environment_1.VERBOSE_LOGGING) {
83
- const t = tasks.map((tt) => {
84
- return Object.assign(Object.assign({}, tt), { terminalOutput: tt.terminalOutput
85
- ? `${tt.terminalOutput.slice(0, 20)}...`
86
- : undefined });
87
- });
88
- output_1.output.note({
89
- title: 'RunEnd. Completed tasks',
90
- bodyLines: ['\n' + JSON.stringify(t, null, 2)],
91
- });
92
- }
93
- const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/runs/end', compressedBuffer, {
94
- headers: Object.assign(Object.assign({}, this.apiAxiosInstance.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
95
- }), environment_1.NUMBER_OF_TRIES);
96
- if (resp) {
97
- recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
98
- if (resp.data && resp.data.runUrl && resp.data.status === 'success') {
99
- this.runContext.runUrl = resp.data.runUrl;
100
- return true;
101
- }
102
- if (resp.data && resp.data.status) {
103
- this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data.message)}`;
104
- }
105
- else if (resp.data && typeof resp.data === 'string') {
106
- if (resp.data !== 'success') {
107
- this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
108
- }
109
- }
110
- else {
111
- this.messages.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`;
112
- }
113
- if (environment_1.VERBOSE_LOGGING) {
114
- output_1.output.note({
115
- title: 'Invalid end run response',
116
- bodyLines: [JSON.stringify(resp.data, null, 2)],
117
- });
118
- }
119
- }
120
- else {
121
- output_1.output.error({
122
- title: 'Nx Cloud: Unknown Error Occurred',
123
- bodyLines: [
124
- 'Run completion responded with `undefined`.',
125
- 'Run Details:',
126
- JSON.stringify(run, null, 2),
127
- 'Stack Trace:',
128
- JSON.stringify(new Error().stack, null, 2),
129
- ],
130
- });
131
- }
132
- return false;
133
- }
134
- catch (ee) {
135
- recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
136
- const e = (_a = ee.axiosException) !== null && _a !== void 0 ? _a : ee;
137
- this.messages.apiError = this.messages.extractErrorMessage(e, 'api');
138
- return false;
139
- }
140
- });
141
- }
142
- nxCloudVersion() {
143
- try {
144
- const v = JSON.parse((0, fs_1.readFileSync)(`package.json`).toString());
145
- return v.devDependencies['@nrwl/nx-cloud'];
146
- }
147
- catch (e) {
148
- return 'unknown';
149
- }
150
- }
151
- }
152
- exports.CloudRunApi = CloudRunApi;
153
- //# sourceMappingURL=cloud-run.api.js.map
1
+ const a3_0x12c4=['mapRespToPerfEntry','parse','../../../utilities/environment','stack','machineInfo','status','data','createMetricRecorder','gzip','startRun','messages','toString','/nx-cloud/runs/end','devDependencies','Invalid\x20Nx\x20Cloud\x20response:\x20','unknown','extractErrorMessage','Run\x20Details:','runUrl','getBranch','defineProperty','output','message','axiosException','error','post','readFileSync','nxCloudVersion','@nrwl/workspace/src/utilities/output','defaults','stringify','zlib','Invalid\x20end\x20run\x20response','Stack\x20Trace:','package.json','recordMetric','CloudRunApi','success','terminalOutput','RUNNER_FAILURE_PERF_ENTRY','__esModule','value','slice','apiError','runContext','@nrwl/nx-cloud','headers','/nx-cloud/runs/start','assign','NUMBER_OF_TRIES','endRun','Run\x20completion\x20responded\x20with\x20`undefined`.','...','note','apiAxiosInstance','axiosMultipleTries','createApiAxiosInstance','urls','RunStart','then','getRunGroup','VERBOSE_LOGGING','../../../utilities/metric-logger','Invalid\x20end\x20run\x20response:\x20','from','__awaiter','api'];(function(_0x39a8fd,_0x12c4bd){const _0x22e2b1=function(_0x2156d4){while(--_0x2156d4){_0x39a8fd['push'](_0x39a8fd['shift']());}};_0x22e2b1(++_0x12c4bd);}(a3_0x12c4,0x156));const a3_0x22e2=function(_0x39a8fd,_0x12c4bd){_0x39a8fd=_0x39a8fd-0x0;let _0x22e2b1=a3_0x12c4[_0x39a8fd];return _0x22e2b1;};'use strict';var __awaiter=this&&this[a3_0x22e2('0x3a')]||function(_0x54155d,_0x43ebdd,_0x3b7dce,_0x3995d6){function _0x186f16(_0x30ba72){return _0x30ba72 instanceof _0x3b7dce?_0x30ba72:new _0x3b7dce(function(_0x3a5e3d){_0x3a5e3d(_0x30ba72);});}return new(_0x3b7dce||(_0x3b7dce=Promise))(function(_0x39ad07,_0x30d0f5){function _0x415d88(_0x1b586d){try{_0xadca1b(_0x3995d6['next'](_0x1b586d));}catch(_0x5b1ce0){_0x30d0f5(_0x5b1ce0);}}function _0x3bf289(_0x121a1e){try{_0xadca1b(_0x3995d6['throw'](_0x121a1e));}catch(_0x5005ae){_0x30d0f5(_0x5005ae);}}function _0xadca1b(_0x5a4612){_0x5a4612['done']?_0x39ad07(_0x5a4612[a3_0x22e2('0x22')]):_0x186f16(_0x5a4612[a3_0x22e2('0x22')])[a3_0x22e2('0x34')](_0x415d88,_0x3bf289);}_0xadca1b((_0x3995d6=_0x3995d6['apply'](_0x54155d,_0x43ebdd||[]))['next']());});};Object[a3_0x22e2('0xd')](exports,a3_0x22e2('0x21'),{'value':!![]});exports[a3_0x22e2('0x1d')]=void 0x0;const output_1=require(a3_0x22e2('0x15'));const axios_1=require('../../../utilities/axios');const environment_1=require(a3_0x22e2('0x3e'));const fs_1=require('fs');const zlib_1=require(a3_0x22e2('0x18'));const util_1=require('util');const metric_logger_1=require(a3_0x22e2('0x37'));class CloudRunApi{constructor(_0x50e1ff,_0x404134,_0x4c6cc9,_0x500dc1){this[a3_0x22e2('0x3')]=_0x50e1ff;this[a3_0x22e2('0x25')]=_0x404134;this[a3_0x22e2('0x40')]=_0x500dc1;this[a3_0x22e2('0x2f')]=(0x0,axios_1[a3_0x22e2('0x31')])(_0x4c6cc9);}[a3_0x22e2('0x2')](_0x2b3e81,_0xb2555d){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x50018a=(0x0,metric_logger_1[a3_0x22e2('0x0')])('startRun');try{const _0x3b5b2c={'meta':{'nxCloudVersion':this[a3_0x22e2('0x14')]()},'branch':(0x0,environment_1[a3_0x22e2('0xc')])(),'runGroup':(0x0,environment_1[a3_0x22e2('0x35')])(),'distributedExecutionId':_0x2b3e81,'hashes':_0xb2555d};if(environment_1['VERBOSE_LOGGING']){output_1['output']['note']({'title':a3_0x22e2('0x33'),'bodyLines':['\x0a'+JSON[a3_0x22e2('0x17')](_0x3b5b2c,null,0x2)]});}const _0x51582d=yield(0x0,axios_1[a3_0x22e2('0x30')])(()=>this[a3_0x22e2('0x2f')][a3_0x22e2('0x12')](a3_0x22e2('0x28'),_0x3b5b2c),environment_1[a3_0x22e2('0x2a')]);_0x50018a['recordMetric']((0x0,metric_logger_1[a3_0x22e2('0x3c')])(_0x51582d));if(_0x51582d['data']&&_0x51582d[a3_0x22e2('0x42')][a3_0x22e2('0xf')]){this[a3_0x22e2('0x3')][a3_0x22e2('0xf')]=_0x51582d[a3_0x22e2('0x42')][a3_0x22e2('0xf')];}if(!_0x51582d[a3_0x22e2('0x42')]||!_0x51582d[a3_0x22e2('0x42')][a3_0x22e2('0x32')]){this['messages'][a3_0x22e2('0x24')]=a3_0x22e2('0x7')+JSON[a3_0x22e2('0x17')](_0x51582d[a3_0x22e2('0x42')]);return{};}return _0x51582d[a3_0x22e2('0x42')][a3_0x22e2('0x32')];}catch(_0x1a59a1){_0x50018a[a3_0x22e2('0x1c')](metric_logger_1[a3_0x22e2('0x20')]);this[a3_0x22e2('0x3')][a3_0x22e2('0x24')]=this[a3_0x22e2('0x3')][a3_0x22e2('0x9')](_0x1a59a1,a3_0x22e2('0x3b'));return{};}});}[a3_0x22e2('0x2b')](_0x1cc8df,_0x5b9213){var _0x127176;return __awaiter(this,void 0x0,void 0x0,function*(){if(this[a3_0x22e2('0x3')]['apiError'])return![];const _0x1f0261={'meta':{'nxCloudVersion':this[a3_0x22e2('0x14')]()},'tasks':_0x5b9213,'run':_0x1cc8df,'machineInfo':this[a3_0x22e2('0x40')]};const _0x187c05=Buffer[a3_0x22e2('0x39')](JSON[a3_0x22e2('0x17')](_0x1f0261));const _0x109d0b=yield(0x0,util_1['promisify'])(zlib_1[a3_0x22e2('0x1')])(_0x187c05);const _0x494c66=(0x0,metric_logger_1[a3_0x22e2('0x0')])(a3_0x22e2('0x2b'));try{if(environment_1[a3_0x22e2('0x36')]){const _0x2005d6=_0x5b9213['map'](_0x4331a4=>{return Object[a3_0x22e2('0x29')](Object[a3_0x22e2('0x29')]({},_0x4331a4),{'terminalOutput':_0x4331a4[a3_0x22e2('0x1f')]?_0x4331a4['terminalOutput'][a3_0x22e2('0x23')](0x0,0x14)+a3_0x22e2('0x2d'):undefined});});output_1[a3_0x22e2('0xe')][a3_0x22e2('0x2e')]({'title':'RunEnd.\x20Completed\x20tasks','bodyLines':['\x0a'+JSON[a3_0x22e2('0x17')](_0x2005d6,null,0x2)]});}const _0x4085cd=yield(0x0,axios_1[a3_0x22e2('0x30')])(()=>this[a3_0x22e2('0x2f')][a3_0x22e2('0x12')](a3_0x22e2('0x5'),_0x109d0b,{'headers':Object[a3_0x22e2('0x29')](Object[a3_0x22e2('0x29')]({},this[a3_0x22e2('0x2f')][a3_0x22e2('0x16')][a3_0x22e2('0x27')]),{'Content-Encoding':a3_0x22e2('0x1'),'Content-Type':'application/octet-stream'})}),environment_1[a3_0x22e2('0x2a')]);if(_0x4085cd){_0x494c66['recordMetric']((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x4085cd));if(_0x4085cd['data']&&_0x4085cd[a3_0x22e2('0x42')]['runUrl']&&_0x4085cd[a3_0x22e2('0x42')][a3_0x22e2('0x41')]===a3_0x22e2('0x1e')){this[a3_0x22e2('0x25')][a3_0x22e2('0xb')]=_0x4085cd['data'][a3_0x22e2('0xb')];return!![];}if(_0x4085cd[a3_0x22e2('0x42')]&&_0x4085cd[a3_0x22e2('0x42')][a3_0x22e2('0x41')]){this[a3_0x22e2('0x3')][a3_0x22e2('0x24')]='Invalid\x20end\x20run\x20response:\x20'+JSON['stringify'](_0x4085cd[a3_0x22e2('0x42')][a3_0x22e2('0xf')]);}else if(_0x4085cd[a3_0x22e2('0x42')]&&typeof _0x4085cd[a3_0x22e2('0x42')]==='string'){if(_0x4085cd[a3_0x22e2('0x42')]!==a3_0x22e2('0x1e')){this[a3_0x22e2('0x3')]['apiError']=a3_0x22e2('0x38')+JSON[a3_0x22e2('0x17')](_0x4085cd[a3_0x22e2('0x42')]);}}else{this[a3_0x22e2('0x3')]['apiError']=a3_0x22e2('0x38')+JSON[a3_0x22e2('0x17')](_0x4085cd['data']);}if(environment_1['VERBOSE_LOGGING']){output_1[a3_0x22e2('0xe')]['note']({'title':a3_0x22e2('0x19'),'bodyLines':[JSON[a3_0x22e2('0x17')](_0x4085cd[a3_0x22e2('0x42')],null,0x2)]});}}else{output_1[a3_0x22e2('0xe')][a3_0x22e2('0x11')]({'title':'Nx\x20Cloud:\x20Unknown\x20Error\x20Occurred','bodyLines':[a3_0x22e2('0x2c'),a3_0x22e2('0xa'),JSON[a3_0x22e2('0x17')](_0x1cc8df,null,0x2),a3_0x22e2('0x1a'),JSON[a3_0x22e2('0x17')](new Error()[a3_0x22e2('0x3f')],null,0x2)]});}return![];}catch(_0xc2dafe){_0x494c66[a3_0x22e2('0x1c')](metric_logger_1[a3_0x22e2('0x20')]);const _0x549b64=(_0x127176=_0xc2dafe[a3_0x22e2('0x10')])!==null&&_0x127176!==void 0x0?_0x127176:_0xc2dafe;this[a3_0x22e2('0x3')][a3_0x22e2('0x24')]=this['messages'][a3_0x22e2('0x9')](_0x549b64,'api');return![];}});}[a3_0x22e2('0x14')](){try{const _0x393dff=JSON[a3_0x22e2('0x3d')]((0x0,fs_1[a3_0x22e2('0x13')])(a3_0x22e2('0x1b'))[a3_0x22e2('0x4')]());return _0x393dff[a3_0x22e2('0x6')][a3_0x22e2('0x26')];}catch(_0x46dfbe){return a3_0x22e2('0x8');}}}exports['CloudRunApi']=CloudRunApi;
@@ -1,73 +1 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DistributedAgentApi = void 0;
13
- const output_1 = require("@nrwl/workspace/src/utilities/output");
14
- const axios_1 = require("../../../utilities/axios");
15
- const environment_1 = require("../../../utilities/environment");
16
- const metric_logger_1 = require("../../../utilities/metric-logger");
17
- class DistributedAgentApi {
18
- constructor(options, runGroup, agentName) {
19
- this.runGroup = runGroup;
20
- this.agentName = agentName;
21
- this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
22
- }
23
- tasks(executionId, statusCode, completedTasks) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const recorder = (0, metric_logger_1.createMetricRecorder)('dtePollTasks');
26
- try {
27
- const res = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/tasks', {
28
- runGroup: this.runGroup,
29
- agentName: this.agentName,
30
- executionId,
31
- statusCode,
32
- completedTasks,
33
- }), 30);
34
- recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(res));
35
- return res.data;
36
- }
37
- catch (e) {
38
- recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
39
- throw e;
40
- }
41
- });
42
- }
43
- completeRunGroupWithError(error) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- if (environment_1.VERBOSE_LOGGING) {
46
- output_1.output.note({
47
- title: 'Completing run group with an error',
48
- bodyLines: [`runGroup: ${this.runGroup}`, `error: ${error}`],
49
- });
50
- }
51
- const recorder = (0, metric_logger_1.createMetricRecorder)('completeRunGroup');
52
- try {
53
- const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
54
- runGroup: this.runGroup,
55
- agentName: this.agentName,
56
- criticalErrorMessage: error,
57
- }), 3);
58
- if (environment_1.VERBOSE_LOGGING) {
59
- output_1.output.note({
60
- title: 'Completed run group with an error',
61
- });
62
- }
63
- recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
64
- }
65
- catch (e) {
66
- recorder.recordMetric(metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
67
- console.error(e);
68
- }
69
- });
70
- }
71
- }
72
- exports.DistributedAgentApi = DistributedAgentApi;
73
- //# sourceMappingURL=distributed-agent.api.js.map
1
+ const a4_0x594d=['note','throw','DistributedAgentApi','defineProperty','then','error:\x20','Completing\x20run\x20group\x20with\x20an\x20error','next','../../../utilities/axios','error','__esModule','dtePollTasks','done','apiAxiosInstance','/nx-cloud/executions/tasks','VERBOSE_LOGGING','../../../utilities/environment','axiosMultipleTries','mapRespToPerfEntry','tasks','completeRunGroupWithError','runGroup:\x20','recordMetric','runGroup','data','agentName','/nx-cloud/executions/complete-run-group','__awaiter','output','post','../../../utilities/metric-logger','RUNNER_FAILURE_PERF_ENTRY','createMetricRecorder','completeRunGroup','value'];(function(_0x4b73fa,_0x594d57){const _0x558db7=function(_0x6c34e6){while(--_0x6c34e6){_0x4b73fa['push'](_0x4b73fa['shift']());}};_0x558db7(++_0x594d57);}(a4_0x594d,0x1a1));const a4_0x558d=function(_0x4b73fa,_0x594d57){_0x4b73fa=_0x4b73fa-0x0;let _0x558db7=a4_0x594d[_0x4b73fa];return _0x558db7;};'use strict';var __awaiter=this&&this[a4_0x558d('0x1e')]||function(_0x2907fa,_0x269f90,_0x761493,_0x65d701){function _0xcfc440(_0x1f4382){return _0x1f4382 instanceof _0x761493?_0x1f4382:new _0x761493(function(_0x18eef9){_0x18eef9(_0x1f4382);});}return new(_0x761493||(_0x761493=Promise))(function(_0x102b93,_0x1bde63){function _0x553787(_0x34aa0c){try{_0x298ff8(_0x65d701[a4_0x558d('0xa')](_0x34aa0c));}catch(_0x4d7019){_0x1bde63(_0x4d7019);}}function _0x342754(_0x2050b1){try{_0x298ff8(_0x65d701[a4_0x558d('0x4')](_0x2050b1));}catch(_0x37e6a9){_0x1bde63(_0x37e6a9);}}function _0x298ff8(_0x1b88ca){_0x1b88ca[a4_0x558d('0xf')]?_0x102b93(_0x1b88ca['value']):_0xcfc440(_0x1b88ca[a4_0x558d('0x2')])[a4_0x558d('0x7')](_0x553787,_0x342754);}_0x298ff8((_0x65d701=_0x65d701['apply'](_0x2907fa,_0x269f90||[]))[a4_0x558d('0xa')]());});};Object[a4_0x558d('0x6')](exports,a4_0x558d('0xd'),{'value':!![]});exports['DistributedAgentApi']=void 0x0;const output_1=require('@nrwl/workspace/src/utilities/output');const axios_1=require(a4_0x558d('0xb'));const environment_1=require(a4_0x558d('0x13'));const metric_logger_1=require(a4_0x558d('0x21'));class DistributedAgentApi{constructor(_0x1696c1,_0x31568d,_0x1014d5){this[a4_0x558d('0x1a')]=_0x31568d;this[a4_0x558d('0x1c')]=_0x1014d5;this[a4_0x558d('0x10')]=(0x0,axios_1['createApiAxiosInstance'])(_0x1696c1);}[a4_0x558d('0x16')](_0x319ab4,_0x273bd6,_0x106064){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x25c2a6=(0x0,metric_logger_1[a4_0x558d('0x0')])(a4_0x558d('0xe'));try{const _0x6fc4c3=yield(0x0,axios_1['axiosMultipleTries'])(()=>this[a4_0x558d('0x10')][a4_0x558d('0x20')](a4_0x558d('0x11'),{'runGroup':this[a4_0x558d('0x1a')],'agentName':this[a4_0x558d('0x1c')],'executionId':_0x319ab4,'statusCode':_0x273bd6,'completedTasks':_0x106064}),0x1e);_0x25c2a6[a4_0x558d('0x19')]((0x0,metric_logger_1[a4_0x558d('0x15')])(_0x6fc4c3));return _0x6fc4c3[a4_0x558d('0x1b')];}catch(_0x2004ea){_0x25c2a6[a4_0x558d('0x19')](metric_logger_1[a4_0x558d('0x22')]);throw _0x2004ea;}});}[a4_0x558d('0x17')](_0xd8654e){return __awaiter(this,void 0x0,void 0x0,function*(){if(environment_1['VERBOSE_LOGGING']){output_1[a4_0x558d('0x1f')][a4_0x558d('0x3')]({'title':a4_0x558d('0x9'),'bodyLines':[a4_0x558d('0x18')+this['runGroup'],a4_0x558d('0x8')+_0xd8654e]});}const _0x140dfa=(0x0,metric_logger_1[a4_0x558d('0x0')])(a4_0x558d('0x1'));try{const _0x123d65=yield(0x0,axios_1[a4_0x558d('0x14')])(()=>this[a4_0x558d('0x10')][a4_0x558d('0x20')](a4_0x558d('0x1d'),{'runGroup':this[a4_0x558d('0x1a')],'agentName':this[a4_0x558d('0x1c')],'criticalErrorMessage':_0xd8654e}),0x3);if(environment_1[a4_0x558d('0x12')]){output_1['output'][a4_0x558d('0x3')]({'title':'Completed\x20run\x20group\x20with\x20an\x20error'});}_0x140dfa[a4_0x558d('0x19')]((0x0,metric_logger_1['mapRespToPerfEntry'])(_0x123d65));}catch(_0x86b7d5){_0x140dfa[a4_0x558d('0x19')](metric_logger_1[a4_0x558d('0x22')]);console[a4_0x558d('0xc')](_0x86b7d5);}});}}exports[a4_0x558d('0x5')]=DistributedAgentApi;
@@ -1,239 +1 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.startAgent = void 0;
13
- const output_1 = require("@nrwl/workspace/src/utilities/output");
14
- const child_process_1 = require("child_process");
15
- const stripJsonComments = require("strip-json-comments");
16
- const distributed_agent_api_1 = require("./distributed-agent.api");
17
- const waiter_1 = require("../../../utilities/waiter");
18
- const environment_1 = require("../../../utilities/environment");
19
- const print_run_group_error_1 = require("../../error/print-run-group-error");
20
- const create_no_new_messages_timeout_1 = require("../../../utilities/create-no-new-messages-timeout");
21
- const fs_1 = require("fs");
22
- const metric_logger_1 = require("../../../utilities/metric-logger");
23
- function executeTasks(options, api) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- let completedStatusCode = 0;
26
- let apiResponse = null;
27
- const failIfSameTasksIn30Mins = (0, create_no_new_messages_timeout_1.createNoNewMessagesTimeout)();
28
- const waiter = new waiter_1.Waiter();
29
- let completedTasks = [];
30
- const startTime = new Date();
31
- let executedAnyTasks = false;
32
- while (true) {
33
- if (environment_1.VERBOSE_LOGGING) {
34
- output_1.output.note({
35
- title: 'Fetching tasks...',
36
- });
37
- }
38
- apiResponse = yield api.tasks(apiResponse ? apiResponse.executionId : null, completedStatusCode, completedTasks);
39
- if (environment_1.VERBOSE_LOGGING) {
40
- output_1.output.note({
41
- title: 'API Response',
42
- bodyLines: [
43
- `completed: ${apiResponse.completed}`,
44
- `retryDuring: ${apiResponse.retryDuring}`,
45
- `executionId: ${apiResponse.executionId}`,
46
- `number of tasks: ${apiResponse.tasks.length}`,
47
- `error: ${apiResponse.criticalErrorMessage}`,
48
- `maxParallel: ${apiResponse.maxParallel}`,
49
- ],
50
- });
51
- }
52
- if (apiResponse.criticalErrorMessage) {
53
- output_1.output.error({
54
- title: 'Distributed Execution Terminated',
55
- bodyLines: ['Error:', apiResponse.criticalErrorMessage],
56
- });
57
- process.exit(0);
58
- }
59
- // run group is completed but it might be a rerun
60
- // we will try several times before going further and
61
- // completed the response
62
- // we only do it if we haven't executed any tasks
63
- if ((apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) &&
64
- (apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.retryDuring) !== 0 &&
65
- !executedAnyTasks &&
66
- new Date().getTime() - startTime.getTime() > apiResponse.retryDuring) {
67
- yield waiter.wait();
68
- continue;
69
- }
70
- if (apiResponse.completed)
71
- return;
72
- failIfSameTasksIn30Mins(apiResponse.tasks.map((t) => t.taskId).join(''));
73
- if (!apiResponse.executionId) {
74
- if (environment_1.VERBOSE_LOGGING) {
75
- output_1.output.note({
76
- title: 'Waiting...',
77
- });
78
- }
79
- yield waiter.wait();
80
- completedStatusCode = 0;
81
- completedTasks = [];
82
- continue;
83
- }
84
- waiter.reset();
85
- executedAnyTasks = true;
86
- const r = invokeTasksUsingRunMany(options, apiResponse.executionId, apiResponse.tasks, apiResponse.maxParallel);
87
- completedStatusCode = r.completedStatusCode;
88
- completedTasks = r.completedTasks;
89
- }
90
- });
91
- }
92
- function readCompletedTasks(options, distributedExecutionId) {
93
- const errorMessage = `Command execution failed (distributed task execution: ${distributedExecutionId}). Tasks hashes haven\'t been recorded.`;
94
- let completedTasks;
95
- try {
96
- const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
97
- const taskHashesFile = `${cacheDirectory}/tasks-hashes-${distributedExecutionId}`;
98
- completedTasks = JSON.parse((0, fs_1.readFileSync)(taskHashesFile).toString());
99
- // remove it such that if the next command crashes we don't read an obsolete file
100
- (0, fs_1.unlinkSync)(taskHashesFile);
101
- }
102
- catch (e) {
103
- throw new Error(errorMessage);
104
- }
105
- if (completedTasks.length == 0) {
106
- throw new Error(errorMessage);
107
- }
108
- return completedTasks;
109
- }
110
- function invokeTasksUsingRunMany(options, executionId, tasks, maxParallel) {
111
- let completedStatusCode = 0;
112
- const completedTasks = [];
113
- for (const g of groupByTarget(tasks)) {
114
- const config = g.configuration ? `--configuration=${g.configuration}` : ``;
115
- const parallel = maxParallel > 1 ? ` --parallel --max-parallel=${maxParallel}` : ``;
116
- // TODO use pnpx or yarn when needed
117
- const command = `npx nx run-many --target=${g.target} ${config} --projects=${g.projects.join(',')} ${g.params}${parallel}`;
118
- if (environment_1.VERBOSE_LOGGING) {
119
- output_1.output.note({
120
- title: `Executing: '${command}'`,
121
- });
122
- }
123
- try {
124
- (0, child_process_1.execSync)(command, {
125
- stdio: ['inherit', 'inherit', 'inherit'],
126
- env: Object.assign(Object.assign({}, process.env), { NX_CACHE_FAILURES: 'true', NX_CLOUD_DISTRIBUTED_EXECUTION_ID: executionId }),
127
- });
128
- }
129
- catch (e) {
130
- if (e.status === environment_1.DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE) {
131
- throw e;
132
- }
133
- else {
134
- completedStatusCode = 1;
135
- }
136
- }
137
- finally {
138
- completedTasks.push(...readCompletedTasks(options, executionId));
139
- }
140
- }
141
- return { completedStatusCode, completedTasks };
142
- }
143
- function groupByTarget(tasks) {
144
- const res = [];
145
- tasks.forEach((t) => {
146
- const r = res.find((rr) => rr.target === t.target && rr.configuration === t.configuration);
147
- if (r) {
148
- r.projects.push(t.projectName);
149
- }
150
- else {
151
- res.push({
152
- target: t.target,
153
- projects: [t.projectName],
154
- params: t.params,
155
- configuration: t.configuration,
156
- });
157
- }
158
- });
159
- return res;
160
- }
161
- function getAgentName() {
162
- if (process.env.NX_AGENT_NAME !== undefined) {
163
- return process.env.NX_AGENT_NAME;
164
- }
165
- else if (process.env.CIRCLECI !== undefined) {
166
- return process.env.CIRCLE_STAGE;
167
- }
168
- else {
169
- return `Agent ${Math.floor(Math.random() * 100000)}`;
170
- }
171
- }
172
- function createAgentLockfile(options, agentName) {
173
- const cacheDirectory = options.cacheDirectory || './node_modules/.cache/nx';
174
- const lockFileDirectory = `${cacheDirectory}/lockfiles`;
175
- const lockFilePath = `${lockFileDirectory}/${agentName}.lock`;
176
- if (!(0, fs_1.existsSync)(lockFileDirectory)) {
177
- (0, fs_1.mkdirSync)(lockFileDirectory, { recursive: true });
178
- }
179
- // Check for other agents' lockfiles and warn if exist
180
- const lockFiles = (0, fs_1.readdirSync)(lockFileDirectory);
181
- if (lockFiles.length) {
182
- // Check to make sure the current agent name is not in use (only 1/100000 ^ 2 chance of this)
183
- if (lockFiles.includes(`${agentName}.lock`)) {
184
- output_1.output.error({
185
- title: 'Duplicate Agent ID Detected',
186
- bodyLines: [
187
- 'We have detected another agent with this ID running in this workspace. This should not happen.',
188
- '',
189
- 'End all currently running agents, run "npx nx-cloud clean-up-agents", and try again.',
190
- ],
191
- });
192
- process.exit(1);
193
- }
194
- output_1.output.warn({
195
- title: 'Other Nx Cloud Agents Detected',
196
- bodyLines: [
197
- 'We have detected other agents running in this workspace. This can cause unexpected behavior.',
198
- '',
199
- 'This can also be a false positive caused by agents that did not shut down correctly.',
200
- 'If you believe this is the case, run "npx nx-cloud clean-up-agents".',
201
- ],
202
- });
203
- }
204
- (0, fs_1.writeFileSync)(lockFilePath, '');
205
- process.on('exit', () => cleanupAgentLockfile(lockFilePath));
206
- process.on('SIGINT', () => cleanupAgentLockfile(lockFilePath));
207
- }
208
- function cleanupAgentLockfile(lockFilePath) {
209
- if ((0, fs_1.existsSync)(lockFilePath)) {
210
- (0, fs_1.unlinkSync)(lockFilePath);
211
- }
212
- }
213
- function startAgent() {
214
- return __awaiter(this, void 0, void 0, function* () {
215
- const runGroup = (0, environment_1.getRunGroup)();
216
- if (!runGroup) {
217
- (0, print_run_group_error_1.printRunGroupError)();
218
- return process.exit(1);
219
- }
220
- output_1.output.note({
221
- title: 'Starting an agent for running Nx tasks',
222
- });
223
- const options = JSON.parse(stripJsonComments((0, fs_1.readFileSync)('nx.json').toString())).tasksRunnerOptions.default.options;
224
- const agentName = getAgentName();
225
- createAgentLockfile(options, agentName);
226
- const api = new distributed_agent_api_1.DistributedAgentApi(options, runGroup, agentName);
227
- return executeTasks(options, api)
228
- .then((res) => __awaiter(this, void 0, void 0, function* () {
229
- yield (0, metric_logger_1.submitRunMetrics)(options);
230
- return res;
231
- }))
232
- .catch((e) => __awaiter(this, void 0, void 0, function* () {
233
- yield api.completeRunGroupWithError(`Critical Error in Agent: "${e.message}"`);
234
- throw e;
235
- }));
236
- });
237
- }
238
- exports.startAgent = startAgent;
239
- //# sourceMappingURL=distributed-agent.impl.js.map
1
+ const a5_0x3fe2=['Distributed\x20Execution\x20Terminated','child_process','length','defineProperty','taskId','apply','API\x20Response','maxParallel','.lock','forEach','CIRCLECI','target','NX_AGENT_NAME','execSync','Starting\x20an\x20agent\x20for\x20running\x20Nx\x20tasks','../../../utilities/environment','floor','cacheDirectory','push','error','map','./distributed-agent.api','options','./node_modules/.cache/nx','completed','includes','join','createNoNewMessagesTimeout','submitRunMetrics','params','random','--configuration=','maxParallel:\x20','toString',').\x20Tasks\x20hashes\x20haven\x27t\x20been\x20recorded.','nx.json','printRunGroupError','inherit','Other\x20Nx\x20Cloud\x20Agents\x20Detected','startAgent','retryDuring','We\x20have\x20detected\x20another\x20agent\x20with\x20this\x20ID\x20running\x20in\x20this\x20workspace.\x20This\x20should\x20not\x20happen.','number\x20of\x20tasks:\x20','../../../utilities/waiter','Executing:\x20\x27','writeFileSync','note','completed:\x20','projectName','value','Error:','CIRCLE_STAGE','true','then','parse','throw','projects','completedStatusCode','We\x20have\x20detected\x20other\x20agents\x20running\x20in\x20this\x20workspace.\x20This\x20can\x20cause\x20unexpected\x20behavior.','existsSync','assign','next','../../../utilities/create-no-new-messages-timeout','readdirSync','This\x20can\x20also\x20be\x20a\x20false\x20positive\x20caused\x20by\x20agents\x20that\x20did\x20not\x20shut\x20down\x20correctly.','getRunGroup','Command\x20execution\x20failed\x20(distributed\x20task\x20execution:\x20','completedTasks','mkdirSync','__awaiter','\x20--parallel\x20--max-parallel=','criticalErrorMessage','env','tasks','readFileSync','exit','/tasks-hashes-','npx\x20nx\x20run-many\x20--target=','Agent\x20','error:\x20','\x20--projects=','find','/lockfiles','VERBOSE_LOGGING','executionId','DISTRIBUTED_TASK_EXECUTION_INTERNAL_ERROR_STATUS_CODE','__esModule','wait','getTime','../../error/print-run-group-error','configuration','executionId:\x20','output','unlinkSync'];(function(_0x34cbc2,_0x3fe2e4){const _0x36ea18=function(_0x3a9a8d){while(--_0x3a9a8d){_0x34cbc2['push'](_0x34cbc2['shift']());}};_0x36ea18(++_0x3fe2e4);}(a5_0x3fe2,0x141));const a5_0x36ea=function(_0x34cbc2,_0x3fe2e4){_0x34cbc2=_0x34cbc2-0x0;let _0x36ea18=a5_0x3fe2[_0x34cbc2];return _0x36ea18;};'use strict';var __awaiter=this&&this[a5_0x36ea('0x1e')]||function(_0x4dc787,_0x23418d,_0x16ad54,_0x32e9e5){function _0x5f3975(_0x5506a0){return _0x5506a0 instanceof _0x16ad54?_0x5506a0:new _0x16ad54(function(_0x491c6){_0x491c6(_0x5506a0);});}return new(_0x16ad54||(_0x16ad54=Promise))(function(_0x2485fd,_0x407dad){function _0x5c2c04(_0x4ebed1){try{_0x36b22a(_0x32e9e5[a5_0x36ea('0x16')](_0x4ebed1));}catch(_0x3b3ed9){_0x407dad(_0x3b3ed9);}}function _0x2f4ff2(_0x220e46){try{_0x36b22a(_0x32e9e5[a5_0x36ea('0x10')](_0x220e46));}catch(_0x461aa5){_0x407dad(_0x461aa5);}}function _0x36b22a(_0x20f264){_0x20f264['done']?_0x2485fd(_0x20f264[a5_0x36ea('0xa')]):_0x5f3975(_0x20f264['value'])[a5_0x36ea('0xe')](_0x5c2c04,_0x2f4ff2);}_0x36b22a((_0x32e9e5=_0x32e9e5[a5_0x36ea('0x3c')](_0x4dc787,_0x23418d||[]))['next']());});};Object[a5_0x36ea('0x3a')](exports,a5_0x36ea('0x2f'),{'value':!![]});exports['startAgent']=void 0x0;const output_1=require('@nrwl/workspace/src/utilities/output');const child_process_1=require(a5_0x36ea('0x38'));const stripJsonComments=require('strip-json-comments');const distributed_agent_api_1=require(a5_0x36ea('0x4c'));const waiter_1=require(a5_0x36ea('0x4'));const environment_1=require(a5_0x36ea('0x46'));const print_run_group_error_1=require(a5_0x36ea('0x32'));const create_no_new_messages_timeout_1=require(a5_0x36ea('0x17'));const fs_1=require('fs');const metric_logger_1=require('../../../utilities/metric-logger');function executeTasks(_0x2370f9,_0x12291f){return __awaiter(this,void 0x0,void 0x0,function*(){let _0x4793e7=0x0;let _0x17cfb5=null;const _0x5bcaa6=(0x0,create_no_new_messages_timeout_1[a5_0x36ea('0x52')])();const _0x3818fe=new waiter_1['Waiter']();let _0x5be301=[];const _0x1dae99=new Date();let _0x34d9be=![];while(!![]){if(environment_1['VERBOSE_LOGGING']){output_1[a5_0x36ea('0x35')][a5_0x36ea('0x7')]({'title':'Fetching\x20tasks...'});}_0x17cfb5=yield _0x12291f[a5_0x36ea('0x22')](_0x17cfb5?_0x17cfb5[a5_0x36ea('0x2d')]:null,_0x4793e7,_0x5be301);if(environment_1[a5_0x36ea('0x2c')]){output_1[a5_0x36ea('0x35')]['note']({'title':a5_0x36ea('0x3d'),'bodyLines':[a5_0x36ea('0x8')+_0x17cfb5[a5_0x36ea('0x4f')],'retryDuring:\x20'+_0x17cfb5[a5_0x36ea('0x1')],a5_0x36ea('0x34')+_0x17cfb5[a5_0x36ea('0x2d')],a5_0x36ea('0x3')+_0x17cfb5['tasks'][a5_0x36ea('0x39')],a5_0x36ea('0x28')+_0x17cfb5[a5_0x36ea('0x20')],a5_0x36ea('0x57')+_0x17cfb5[a5_0x36ea('0x3e')]]});}if(_0x17cfb5[a5_0x36ea('0x20')]){output_1[a5_0x36ea('0x35')][a5_0x36ea('0x4a')]({'title':a5_0x36ea('0x37'),'bodyLines':[a5_0x36ea('0xb'),_0x17cfb5[a5_0x36ea('0x20')]]});process[a5_0x36ea('0x24')](0x0);}if((_0x17cfb5===null||_0x17cfb5===void 0x0?void 0x0:_0x17cfb5[a5_0x36ea('0x1')])&&(_0x17cfb5===null||_0x17cfb5===void 0x0?void 0x0:_0x17cfb5[a5_0x36ea('0x1')])!==0x0&&!_0x34d9be&&new Date()[a5_0x36ea('0x31')]()-_0x1dae99['getTime']()>_0x17cfb5[a5_0x36ea('0x1')]){yield _0x3818fe[a5_0x36ea('0x30')]();continue;}if(_0x17cfb5[a5_0x36ea('0x4f')])return;_0x5bcaa6(_0x17cfb5[a5_0x36ea('0x22')][a5_0x36ea('0x4b')](_0x49eeae=>_0x49eeae[a5_0x36ea('0x3b')])[a5_0x36ea('0x51')](''));if(!_0x17cfb5[a5_0x36ea('0x2d')]){if(environment_1['VERBOSE_LOGGING']){output_1[a5_0x36ea('0x35')][a5_0x36ea('0x7')]({'title':'Waiting...'});}yield _0x3818fe[a5_0x36ea('0x30')]();_0x4793e7=0x0;_0x5be301=[];continue;}_0x3818fe['reset']();_0x34d9be=!![];const _0x258d69=invokeTasksUsingRunMany(_0x2370f9,_0x17cfb5['executionId'],_0x17cfb5[a5_0x36ea('0x22')],_0x17cfb5[a5_0x36ea('0x3e')]);_0x4793e7=_0x258d69[a5_0x36ea('0x12')];_0x5be301=_0x258d69[a5_0x36ea('0x1c')];}});}function readCompletedTasks(_0x5106fb,_0x3f23e7){const _0x6d079d=a5_0x36ea('0x1b')+_0x3f23e7+a5_0x36ea('0x59');let _0x3a2b4d;try{const _0x22fb31=_0x5106fb['cacheDirectory']||a5_0x36ea('0x4e');const _0x19a4d4=_0x22fb31+a5_0x36ea('0x25')+_0x3f23e7;_0x3a2b4d=JSON['parse']((0x0,fs_1[a5_0x36ea('0x23')])(_0x19a4d4)[a5_0x36ea('0x58')]());(0x0,fs_1[a5_0x36ea('0x36')])(_0x19a4d4);}catch(_0x582d1f){throw new Error(_0x6d079d);}if(_0x3a2b4d[a5_0x36ea('0x39')]==0x0){throw new Error(_0x6d079d);}return _0x3a2b4d;}function invokeTasksUsingRunMany(_0x65a4d6,_0x2a3585,_0x5167a2,_0x66424f){let _0x47769c=0x0;const _0x6287e9=[];for(const _0x17dc94 of groupByTarget(_0x5167a2)){const _0x5c6309=_0x17dc94[a5_0x36ea('0x33')]?a5_0x36ea('0x56')+_0x17dc94[a5_0x36ea('0x33')]:'';const _0x1f2b73=_0x66424f>0x1?a5_0x36ea('0x1f')+_0x66424f:'';const _0x45647b=a5_0x36ea('0x26')+_0x17dc94[a5_0x36ea('0x42')]+'\x20'+_0x5c6309+a5_0x36ea('0x29')+_0x17dc94['projects']['join'](',')+'\x20'+_0x17dc94[a5_0x36ea('0x54')]+_0x1f2b73;if(environment_1['VERBOSE_LOGGING']){output_1['output']['note']({'title':a5_0x36ea('0x5')+_0x45647b+'\x27'});}try{(0x0,child_process_1[a5_0x36ea('0x44')])(_0x45647b,{'stdio':[a5_0x36ea('0x5c'),a5_0x36ea('0x5c'),a5_0x36ea('0x5c')],'env':Object[a5_0x36ea('0x15')](Object[a5_0x36ea('0x15')]({},process[a5_0x36ea('0x21')]),{'NX_CACHE_FAILURES':a5_0x36ea('0xd'),'NX_CLOUD_DISTRIBUTED_EXECUTION_ID':_0x2a3585})});}catch(_0x22bad5){if(_0x22bad5['status']===environment_1[a5_0x36ea('0x2e')]){throw _0x22bad5;}else{_0x47769c=0x1;}}finally{_0x6287e9[a5_0x36ea('0x49')](...readCompletedTasks(_0x65a4d6,_0x2a3585));}}return{'completedStatusCode':_0x47769c,'completedTasks':_0x6287e9};}function groupByTarget(_0x120cff){const _0x3a658b=[];_0x120cff[a5_0x36ea('0x40')](_0x161fbb=>{const _0xc9bc95=_0x3a658b[a5_0x36ea('0x2a')](_0x24c2e5=>_0x24c2e5['target']===_0x161fbb['target']&&_0x24c2e5[a5_0x36ea('0x33')]===_0x161fbb[a5_0x36ea('0x33')]);if(_0xc9bc95){_0xc9bc95[a5_0x36ea('0x11')][a5_0x36ea('0x49')](_0x161fbb[a5_0x36ea('0x9')]);}else{_0x3a658b[a5_0x36ea('0x49')]({'target':_0x161fbb['target'],'projects':[_0x161fbb[a5_0x36ea('0x9')]],'params':_0x161fbb[a5_0x36ea('0x54')],'configuration':_0x161fbb['configuration']});}});return _0x3a658b;}function getAgentName(){if(process['env'][a5_0x36ea('0x43')]!==undefined){return process[a5_0x36ea('0x21')]['NX_AGENT_NAME'];}else if(process['env'][a5_0x36ea('0x41')]!==undefined){return process[a5_0x36ea('0x21')][a5_0x36ea('0xc')];}else{return a5_0x36ea('0x27')+Math[a5_0x36ea('0x47')](Math[a5_0x36ea('0x55')]()*0x186a0);}}function createAgentLockfile(_0x52705d,_0xe9aab4){const _0x525f6a=_0x52705d[a5_0x36ea('0x48')]||a5_0x36ea('0x4e');const _0x1fb216=_0x525f6a+a5_0x36ea('0x2b');const _0xa4f0de=_0x1fb216+'/'+_0xe9aab4+a5_0x36ea('0x3f');if(!(0x0,fs_1[a5_0x36ea('0x14')])(_0x1fb216)){(0x0,fs_1[a5_0x36ea('0x1d')])(_0x1fb216,{'recursive':!![]});}const _0x445431=(0x0,fs_1[a5_0x36ea('0x18')])(_0x1fb216);if(_0x445431[a5_0x36ea('0x39')]){if(_0x445431[a5_0x36ea('0x50')](_0xe9aab4+a5_0x36ea('0x3f'))){output_1['output']['error']({'title':'Duplicate\x20Agent\x20ID\x20Detected','bodyLines':[a5_0x36ea('0x2'),'','End\x20all\x20currently\x20running\x20agents,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22,\x20and\x20try\x20again.']});process[a5_0x36ea('0x24')](0x1);}output_1[a5_0x36ea('0x35')]['warn']({'title':a5_0x36ea('0x5d'),'bodyLines':[a5_0x36ea('0x13'),'',a5_0x36ea('0x19'),'If\x20you\x20believe\x20this\x20is\x20the\x20case,\x20run\x20\x22npx\x20nx-cloud\x20clean-up-agents\x22.']});}(0x0,fs_1[a5_0x36ea('0x6')])(_0xa4f0de,'');process['on'](a5_0x36ea('0x24'),()=>cleanupAgentLockfile(_0xa4f0de));process['on']('SIGINT',()=>cleanupAgentLockfile(_0xa4f0de));}function cleanupAgentLockfile(_0x1c87f4){if((0x0,fs_1['existsSync'])(_0x1c87f4)){(0x0,fs_1[a5_0x36ea('0x36')])(_0x1c87f4);}}function startAgent(){return __awaiter(this,void 0x0,void 0x0,function*(){const _0x26efab=(0x0,environment_1[a5_0x36ea('0x1a')])();if(!_0x26efab){(0x0,print_run_group_error_1[a5_0x36ea('0x5b')])();return process[a5_0x36ea('0x24')](0x1);}output_1[a5_0x36ea('0x35')][a5_0x36ea('0x7')]({'title':a5_0x36ea('0x45')});const _0x1bd994=JSON[a5_0x36ea('0xf')](stripJsonComments((0x0,fs_1[a5_0x36ea('0x23')])(a5_0x36ea('0x5a'))[a5_0x36ea('0x58')]()))['tasksRunnerOptions']['default'][a5_0x36ea('0x4d')];const _0x430e75=getAgentName();createAgentLockfile(_0x1bd994,_0x430e75);const _0x5ac814=new distributed_agent_api_1['DistributedAgentApi'](_0x1bd994,_0x26efab,_0x430e75);return executeTasks(_0x1bd994,_0x5ac814)['then'](_0x54a349=>__awaiter(this,void 0x0,void 0x0,function*(){yield(0x0,metric_logger_1[a5_0x36ea('0x53')])(_0x1bd994);return _0x54a349;}))['catch'](_0x423a71=>__awaiter(this,void 0x0,void 0x0,function*(){yield _0x5ac814['completeRunGroupWithError']('Critical\x20Error\x20in\x20Agent:\x20\x22'+_0x423a71['message']+'\x22');throw _0x423a71;}));});}exports[a5_0x36ea('0x0')]=startAgent;